ok

Mini Shell

Direktori : /home2/selectio/public_html/vijay-gases/
Upload File :
Current File : /home2/selectio/public_html/vijay-gases/sale-add.php

<?php  include "header.php";?>
<div class="content-wrapper">
        <section class="content-header">
            <h1>Add Sales</h1>
            <ol class="breadcrumb">
                <li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
                <li class="active">Add Sales</li>            
            </ol>
        </section>


        <div class="col-lg-12 alerts">
            <div id="custom-alerts" style="display:none;">
                <div class="alert alert-dismissable">
                    <div class="custom-msg"></div>
                </div>
            </div>
            <?php if ($error)  { ?>
            <div class="alert alert-danger alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4><i class="icon fa fa-ban"></i> Error</h4>
                <?= $error; ?>
            </div>
            <?php $error=0;} if ($warning) { ?>
            <div class="alert alert-warning alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4><i class="icon fa fa-warning"></i> Warning</h4>
                <?= $warning; ?>
            </div>
            <?php  $warning=0;} if ($message) { ?>
            <div class="alert alert-success alert-dismissable">
                <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                <h4>    <i class="icon fa fa-check"></i> Success</h4>
                <?= $message; ?>
            </div>
            <?php $message=0; } ?>
        </div>
        <div class="clearfix"></div>







<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box box-primary" style="background-color: burlywood;">
                <div class="box-header">
                    <div class="row" style="">
                        <div class="col-md-10 col-sm-10 col-xs-8">
                            <div style="list-style: none; padding-inline-start: 0px; padding: 5px 0px 5px 0px;">
                                <?php include "header/sale_header.php"; ?>
                             </div>
                        </div>
                        <div class="col-md-2 col-sm-2 col-xs-4">
                            <?php //include "header/buttons-ui.php"; ?>
                        </div>
                    </div>
                </div>
                <div class="box-body">
                    <div class="col-lg-12">

                        <form enctype="multipart/form-data" method="POST" id="add_sale_form">
                                                                 
                        <div class="row">
                            
                            <div class="col-md-2">
                                <div class="form-group">
                                    <label class="required" for="name">Sale Date</label>                                    
                                    <input type="date" name="sale_date" value="<?=date('Y-m-d')?>" class="form-control tip" id="sale_date"  required="required" />
                                </div>
                            </div>
                            <div class="col-sm-3">
                                    <div class="form-group">
                                        <label class="control-label required" for="departement_id">Select Customer</label>
                                           <select name="customer" class="form-control tip select2" style="width:100%" id="customer" onchange="customer_cylinders()">
                                                <option value="">All Customer</option>
                                                <?php $statement = $pdo->prepare("SELECT * FROM `tbl_customer` where status='1' and cust_type='1'");
                                                    $statement->execute();
                                                    $location_result = $statement->fetchAll(PDO::FETCH_ASSOC); 
                                                    foreach ($location_result as $result) {
                                                        echo "<option value=".$result['id'].">".$result['customer_name']."</option>";
                                                }?>
                                            </select>
                                     </div>
                                     
                             </div>
                            <div class="col-md-1">
                                    <a href="modal/sale-customer-add.php" data-toggle='ajax-modal' class="tip btn btn-warning btn-xs"  style="margin-top:28px;margin-left: -32%;"><i class="fa fa-plus-circle" aria-hidden="true" style="font-size:22px;"></i></a>
                              </div>
                            <div class="col-sm-3">
                                    <div class="form-group">
                                        <label class="control-label required" for="departement_id">Company Name</label>
                                           <select name="location" class="form-control select2" style="width:100%" id="location_id">
                                                <option value="">Select Company Name</option>
                                                <?php $statement = $pdo->prepare("SELECT * FROM `tbl_location` where status='1'");
                                                    $statement->execute();
                                                    $location_result = $statement->fetchAll(PDO::FETCH_ASSOC); 
                                                    foreach ($location_result as $result) {
                                                        echo "<option value=".$result['id'].">".$result['name']."</option>";
                                                }?>
                                            </select>
                                     </div>
                             </div>
                            <div class="col-md-2" id="rate_section">
                                <div class="form-group">
                                    <label class="required" for="cube_rate">Cube Rate</label>                                    
                                    <input type="text" name="cube_rate" value="" class="form-control tip" id="cube_rate"  required="required" />
                                </div>
                            </div>
                        </div>
                    
                        <div class="row">
                            <div class="col-md-6">
                                <center><b>Empty Cylinder</b></center>
                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="form-group" style="margin-top: 30px;">
                                               <select name="customer_empty_cylinder" class="form-control tip select2" style="width:100%" id="customer_empty_cylinder" >
                                                    <option value="">Select Cylinder</option>
                                                </select>
                                         </div>
                                    </div>
                                    
                                    
                                    <div class="col-md-8">
                                        
                                        <div class="form-group search-box">
                                           <label class="" for="pro_category">Search Cylinder No./  Product Name</label>                         
                                            <input type="text" name="search_item"  placeholder="Search Product" class="form-control tip " id="search_text"  style='text-transform:uppercase'/>
                                            <div class="result" style="overflow-y: scroll;max-height: 200px;"></div>
                                        </div>
                                        
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-12">
                                        <table id="collect_customer_table">
                                            <thead>
                                                <tr>
                                                <th>HSN / SAC No.</th>
                                                <th>Cylinder No.</th>
                                                <th>Product Name</th>
                                                <th hidden>Sell Rate</th>
                                                <th hidden>Quantity</th>
                                                <th>Action</th>
                                              </tr>
                                            </thead>
                                              
                                              <tbody id="collect_customer_row">
                                                  
                                                  <tr style="background-color: burlywood;">
                                                      <td></td>
                                                      <td></td>
                                                      <td></td>
                                                      <td hidden><input type="text" name="total_sell_rate"  value="0" class="form-control tip total_sell_rate" readonly/></td>
                                                      <td hidden></td>
                                                      <td></td>
                                                  </tr>
                                                  
                                              </tbody>
                                         </table>
                                    </div>
                                </div>
                                
                            </div>
                            
                            <div class="col-md-6">
                                <center><b>Full Cylinder</b></center>
                               <div class="row">
                                    <div class="col-md-12">
                                        <div class="form-group sale-search-box">
                                           <label class="" for="pro_category">Search Cylinder No./  Product Name</label>                         
                                            <input type="text" name="sale_search_item"  placeholder="Search Product" class="form-control tip " id="sale_search_text"  style='text-transform:uppercase'/>
                                            <div class="sale_result" style="overflow-y: scroll;max-height: 200px;"></div>
                                        </div>
                                    </div>
                                </div>
                                <table id="return_customer_table">
                                            <thead>
                                                <tr>
                                                <th>HSN / SAC No.</th>
                                                <th>Cylinder No.</th>
                                                <th>Product Name</th>
                                                <th>Sell Rate</th>
                                                <th hidden>Quantity</th>
                                                <th>Action</th>
                                              </tr>
                                            </thead>
                                              
                                              <tbody id="return_customer_row">
                                                  
                                                  <tr style="background-color: burlywood;">
                                                      <td></td>
                                                      <td></td>
                                                      <td></td>
                                                      <td><input type="text" name="total_new_sell_rate"  value="0" class="form-control tip total_new_cylinder_sell_rate" readonly/></td>
                                                      <td ></td>
                                                      <td></td>
                                                  </tr>
                                                  
                                              </tbody>
                                         </table>
                            </div>
                        </div>
                       <br>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="row">
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="required" for="name">Vehicle Number</label>                                    
                                            <input type="text" name="vh_no" value="" class="form-control tip" id="vh_no"  required="required" />
                                        </div>
                                    </div>
                                      <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="required" for="name">Driver Name</label>                                    
                                            <input type="text" name="d_name" value="" class="form-control tip" id="d_name"  required="required"  />
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="required" for="name">Total Amount</label>                                    
                                            <input type="text" name="total_amount" value="0" class="form-control tip total_final_amount" id="total_amount"  required="required" readonly onkeypress="return isNumberKey(this, event);"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="row">
                                    
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="required" for="name">Paid Amount</label>                                    
                                            <input type="text" name="advance_amount" value="0" class="form-control tip" id="advance_amount" onkeypress="return isNumberKey(this, event);" required="required" />
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                         <div class="form-group">
                                            <label class="control-label" for="departement_id">Payment Mode</label>
                                               <select name="pay_mode" class="form-control select2" style="width:100%" id="pay_mode" onchange="pay_condition_amount()" required>
                                                    <option value="0">Select Payment Mode</option>
                                                    <option value="1">Cash</option>
                                                    <option value="2">Online</option>
                                                    <option value="3">Cheque</option>
                                                    <option value="4">Credit Card</option>
                                                </select>
                                         </div>
                                     </div>
                                     
                                     <div id="online_pay_mode">
                                             <div class="col-md-3">
                                                 <div class="form-group">
                                                    <label class="control-label required" for="departement_id">Received By</label>
                                                       <select name="payment_condition" class="form-control select2" style="width:100%" id="received_by">
                                                            <option value=""> Select Received By</option>
                                                             <?php $statement = $pdo->prepare("SELECT * FROM `tbl_location` where status='1'");
                                                            $statement->execute();
                                                            $location_result = $statement->fetchAll(PDO::FETCH_ASSOC); 
                                                            foreach ($location_result as $result) {
                                                                echo "<option value=".$result['name'].">".$result['name']."</option>";
                                                        }?>
                                                        </select>
                                                 </div>
                                             </div>
                                         </div>
                                         <div id="cheque_no_div">
                                             <div class="col-md-3">
                                                 <div class="form-group">
                                                    <label class="required" for="name">Cheque No</label>                                    
                                                    <input type="text" name="payment_condition" value="0" class="form-control tip" id="cheque_no" />
                                                </div>
                                             </div>
                                         </div>
                                     
                                    <div class="col-md-4" hidden>
                                         <div class="form-group">
                                            <label class="control-label" for="departement_id">Payment Type</label>
                                               <select name="pay_type" class="form-control select2" style="width:100%" id="pay_type">
                                                    <option value="0">Select The Payment Type</option>
                                                    <option value="1">Fully Paid</option>
                                                    <option value="2">Partially Paid</option>
                                                    <option value="3">Monthly Due</option>
                                                    <option value="4">Days Due</option>
                                                </select>
                                         </div>
                                     </div>
                                    
                                </div>
                            </div>
                        </div>
                            
                        <div class="form-group" style="text-align:center;">
                            <input type="submit" name="add_sale" value="Add Sale"  class="btn btn-success" />
                        </form>
                        </div>

                    </div>
                        <div class="form-group" style="text-align:center;">
                            <a href="sale-add.php"><button class="btn btn-primary" ><i class="fa fa-refresh"></i> Reset Form</button></a>
                            <a href="sales.php"><button class="btn btn-warning" ><i class="fa fa-chevron-left"></i> Back to List</button></a>
                         </div>
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
    </div>
</section>


<script>

        $(document).ready(function(){
                var n='';
                n=parseInt(n) || 0;
                
                $('.search-box input[type="text"]').on("keyup input", function(){
                    
                    cylinder_customer = $('#customer').val();
                    
                    if(cylinder_customer==''){
                        alert('Please Select The Customer First');
                    }else{
                        
                        
                        var search_text = $(this).val();
                        var resultDropdown = $(this).siblings(".result");
                        if(search_text.length>1){
                            $.get("apis/sale-search-api.php", {search_text: search_text,cylinder_customer:cylinder_customer}).done(function(data){
                                resultDropdown.html(data);
                            });
                        } else{
                            resultDropdown.empty();
                        }
                    }
                    
                    
                });
            });
            
            
            function append_row(id){
    $('.search-box input[type="text"]').val('');
    $(".result").empty();
    $('.search-box input[type="text"]').focus();
}
//var selectedIds=[];

         function product_selection(id){ 
        // selectedIds.push(id);  // Use a more descriptive variable name
        var is_new = 1;
            $(".pro_ids").each(function(){
                if(id==$(this).val()){
                    is_new=0;
                     return false;
                }
            });  
            
     
      if(is_new==1){
          cylinder_customer = $('#customer').val();
        $.ajax({
            url: 'apis/get-search-sale.php',
            type: 'post',
            dataType: 'json',
            data:{pro_id:id,type:'customer_sale_search',cylinder_customer:cylinder_customer},
            success: function (response) {
                if(response[0]['error']==false){
                    
                     $('#collect_customer_table').prepend(response[0]['content']);
                    $('.search-box input[type="text"]').val('');
                    $(".result").empty();
                    $('.search-box input[type="text"]').focus();
                    final_calculation();
                    new_cylinder_calculation(); 
                }else{
                    alert(response[0]['content']);
                    $('.search-box input[type="text"]').val('');
                    $(".result").empty();
                    $('.search-box input[type="text"]').focus();
                    final_calculation();
                    new_cylinder_calculation(); 
                }
                
               
                
            }
        });
      }else{
          alert('this product Already Added..');
          $('.search-box input[type="text"]').val('');
          $(".result").empty();
          $('.search-box input[type="text"]').focus();
      }
       }
</script>
<!--Sale Search And Append Query Is Started Here-->
<script>
// Full Cylinder Search ==== Selling to Customer
        $(document).ready(function(){
               
                
                $('.sale-search-box input[type="text"]').on("keyup input", function(){
                    var search_text = $(this).val();
                    var resultDropdown = $(this).siblings(".sale_result");
                    if(search_text.length>1){
                        $.get("apis/customer_sale-search-api.php", 
                        {search_text: search_text}).done(function(data){
                            resultDropdown.html(data);
                        });
                    } else{
                        resultDropdown.empty();
                    }
                });
            });
            
            
            function append_row(id){
    $('.sale-search-box input[type="text"]').val('');
    $(".sale_result").empty();
    $('.sale-search-box input[type="text"]').focus();
}
//var selectedIds=[];

         function product_selections(id){ 
             var location_id = $("#location_id").val();
             
       //  selectedIds.push(id);  // Use a more descriptive variable name
       
       var is_new = 1;
            $(".return_pro_ids").each(function(){
                if(id==$(this).val()){
                    is_new=0;
                     return false;
                }
            });  
             
      if(is_new==1){
           
        $.ajax({
            url: 'apis/get-search-sale.php',
            type: 'post',
            dataType: 'text',
            
            data:{return_pro_id:id,type:'return_customer_sale_search', location_id:location_id},
            success: function (response) {
              
                $('#return_customer_table').prepend(response);
                $('.sale-search-box input[type="text"]').val('');
                $(".sale_result").empty();
                $('.sale-search-box input[type="text"]').focus();
                final_calculation();
                new_cylinder_calculation();
            }
        });
      }
      else{
          alert('this product Already Added..');
          $('.sale-search-box input[type="text"]').val('');
          $(".sale_result").empty();
          $('.sale-search-box input[type="text"]').focus();
      }
       }
</script>

<!--Sale Search And Append Query Is Ended Here-->
<script>

// ************************** INSERT AJAX START ******************************
    $(document).ready(function(){
   
    $('#add_sale_form').on('submit', function(e){
        e.preventDefault();
                if($('#customer').val()==''){
                    alert('Please Select The Customer .....');
                }else if($('#location_id').val()==''){
                    alert('Please Select The Location .....');
                }else{
        
                
               $("#add_sale").attr('disabled','disabled');
                var formData = new FormData(this);
                formData.append('type', 'add_sale');
                            $.ajax({
                            url: 'apis/cylinder-sale-add-api.php',
                            type: 'post',
                            dataType: 'json',
                            data: formData,
                            cache: false,
                            contentType: false,
                            processData: false,
                            enctype: 'multipart/form-data',
                            success: function (response) {
                               
                                if(response['status']==200){
                                    
                                    
                                    
                                                 //put success coode  
                                                 $('#add_sale_form').trigger("reset");
                                                 $("#add_sale").removeAttr('disabled');
                                                 alert(response['message']);  
                                                 window.location.href = 'sales.php';
                                      
                                }else{
                                    //put falied code
                                    alert(response['message']);
                                    $("#add_sale").removeAttr('disabled');
                                   
                                }
                                
                               
                            }
                        });
                }
                
    }); 
    
    
            });
// ************************** INSERT AJAX END ******************************
</script>



<!--------------------------------- Payment Condition Ajax Append Jquery Starts Here--------------------------->

<script>
$(document).ready(function(){
    pay_condition_amount();
});
function pay_condition_amount(){
 
var purchase_payment_mode=$('#pay_mode').val(); 

if(purchase_payment_mode==0){
  $('#online_pay_mode').hide();
  $('#cheque_no_div').hide();
  
  $('#received_by').val('');
  $('#cheque_no').val('');
  
}else if(purchase_payment_mode==1){
   $('#online_pay_mode').hide();
   $('#cheque_no_div').hide(); 
   
   $('#received_by').val('');
   $('#cheque_no').val('');
}else if(purchase_payment_mode==2){
  $('#online_pay_mode').show();
  $('#cheque_no_div').hide();
  $('#cheque_no').val('');
}else if(purchase_payment_mode==3){
    $('#online_pay_mode').hide();
    $('#cheque_no_div').show();
    $('#received_by').val('');
}else if(purchase_payment_mode==4){
    $('#online_pay_mode').hide();
    $('#cheque_no_div').hide();
    $('#received_by').val('');
   $('#cheque_no').val('');
}
    }
    

</script>
<!--------------------------------- Payment Condition Ajax Append Jquery Ends  Here--------------------------->
<script>
$(document).on('change', '#location_id', function() {
        location_rate();
    });
    
    
$(document).ready(function(){
   
    
    $("#rate_section").hide();
    
}); 
    
    
</script>


<script>
 function new_cylinder_calculation(){
        var cube_rate = $("#cube_rate").val();
        var location_id = $("#location_id").val();
        
        
       
        
        
        
         var sum = 0;
            $(".return_sell_rate").each(function(){
                sum += +$(this).val();
            });
            
        if(location_id==4){
            cube_rate = cube_rate === "" ? 0 : cube_rate;
            cal = cube_rate*sum;
        }else{
            cal = sum;
        }
        
            $(".total_new_cylinder_sell_rate").val(cal);
            total_final_amount();
          
    }
    
function final_calculation(){
       
         var sum = 0;
            $(".sell_rate").each(function(){
                sum += +$(this).val();
            });
            $(".total_sell_rate").val(sum);
            total_final_amount();
           
    }
    
    
    $(document).ready(function(){
        final_calculation();
        new_cylinder_calculation();
         $('table#collect_customer_table tbody').on('change keyup', 'tr.remove_refill_cylinder_row', function() {

        final_calculation();
        
        
    });

    
    
    
    
     $('table#return_customer_table tbody').on('change keyup', 'tr.remove_return_cylinder_row', function() {
        new_cylinder_calculation();
        
        
    });

   
     
}); 
    
    function total_final_amount(){
         var sum = 0;
            $(".total_sell_rate").each(function(){
                sum += +$(this).val();
            });
            $(".total_new_cylinder_sell_rate").each(function(){
                sum += +$(this).val();
            });
            $(".total_final_amount").val(sum);
    }
</script>


<?php include "footer.php"; ?>
<script>
    
    function location_rate(){
        console.log("Working");
        var location_id = $("#location_id").val();
        console.log("Working"+location_id);
        if(location_id==4){
            $("#rate_section").show();
        }else{
            $("#rate_section").hide();
        }
    }
    
    function customer_cylinders(){
        var customer_id = $("#customer").val();
        
        $.ajax({
                    url: 'api/get-values-api.php',
                    type: 'post',
                    dataType: 'json',
                    data: {type:'customer_cylinders',customer_id:customer_id},
                    success: function (response) {
                        console.log(response);
                        var m='<option value="">Select Cylinder</option>';
                        if(response['error']==false){
                            for(var n=0;n<response['data'].length;n++){
                                m+='<option value='+response['data'][n]['id']+' onclick="product_selection('+response['data'][n]['id']+')">'+response['data'][n]['cylinder_no']+'</option>';
                            }
                        }
                        $('#customer_empty_cylinder').append(m);  
                        $('#customer_empty_cylinder').trigger("change");
                       
                    }
                });
                        
                        
                        
        /*$.ajax({
            url: 'apis/get-search-sale.php',
            type: 'post',
            data:{type:'customer_cylinders',customer_id:customer_id},
            success: function (response) {
                $('#customer_empty_cylinder').prepend(response);
            }
        });*/
        
    }
</script>

<style>
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: rgb(228, 228, 228);
    box-sizing: border-box;
    display: inline-block;
    margin-left: 5px;
    margin-top: 5px;
    position: relative;
    max-width: 100%;
    text-overflow: ellipsis;
    vertical-align: bottom;
    white-space-collapse: collapse;
    text-wrap: nowrap;
    border-width: 1px;
    border-style: solid;
    border-color: rgb(170, 170, 170);
    border-image: initial;
    border-radius: 4px;
    padding: 0px 10px 0px 20px;
    overflow: hidden;
    color: black;
    font-weight: 800;
}
.select2-container--default .select2-selection--multiple {
    background-color: white;
    border: 1px solid #aaa;
    border-radius: 4px;
    cursor: text;
    height: 100px;
    padding-bottom: 5px;
    padding-right: 5px;
    position: relative;
}
</style>
<style>
table {
  border-collapse: collapse;
  width: 100%;
}

tr:nth-child(even){background-color: #f2f2f2}
th{
        background-color: #b34923;
        color: white;
        text-align: center;
        padding-top: 5px;
        padding-bottom: 5px;
}
</style>

<style>
    body {
    font-weight: bolder;
    background: white;
}

.search-box{
        width: auto;
        display: inline-block;
        font-size: 14px;
    }
    .search-box {
        padding: 5px 10px;
       
        font-size: 14px;
    }
    .result{
        position: absolute;        
        z-index: 999;
        top: 89%;
        left: 0;
    }
    .search-box, .result{
        width: 100%;
        box-sizing: border-box;
    }
    /* Formatting result items */
    .result div{
        margin: 0;
        background: white;
        padding: 7px 10px;
        border: 1px solid #CCCCCC;
        border-top: none;
        cursor: pointer;
        margin-top:-10px;
    }
    .result div:hover{
        background: blue;
        color: white;
    }
    
  /*sale Search Style Starts Here */ 
  
  
  
  .sale-search-box{
        width: auto;
        display: inline-block;
        font-size: 14px;
    }
    .sale-search-box {
        padding: 5px 10px;
       
        font-size: 14px;
    }
    .sale_result{
        position: absolute;        
        z-index: 999;
        top: 89%;
        left: 0;
    }
    .sale-search-box, .sale_result{
        width: 100%;
        box-sizing: border-box;
    }
    /* Formatting result items */
    .sale_result div{
        margin: 0;
        background: white;
        padding: 7px 10px;
        border: 1px solid #CCCCCC;
        border-top: none;
        cursor: pointer;
        margin-top:-10px;
    }
    .sale_result div:hover{
        background: blue;
        color: white;
    }
  
  /*Sale Search Style Ends Here*/
    
</style>

Zerion Mini Shell 1.0