ok

Mini Shell

Direktori : /home2/selectio/www/vijay-gases/
Upload File :
Current File : //home2/selectio/www/vijay-gases/purchase-add(04-09-2023).php

<?php  include "header.php";?>
<div class="content-wrapper">
        <section class="content-header">
            <h1>Add Purchase</h1>
            <ol class="breadcrumb">
                <li><a href="index.php"><i class="fa fa-dashboard"></i> Home</a></li>
                <li class="active">Add Purchase</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="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/purchase_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>
                <div class="box-body">
                    <div class="col-lg-12">

                        <form enctype="multipart/form-data" method="post" id="add_purchase_form">
                                                                 
                        <div class="row">
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="required" for="name">Purchase Date</label>                                    
                                    <input type="date" name="purchase_date" value="<?=date('Y-m-d')?>" class="form-control tip" id="purchase_date"  required="required" />
                                </div>
                            </div>
                            
                            <div class="col-sm-4">
                                    <div class="form-group">
                                        <label class="control-label" for="departement_id">Select Supplier</label>
                                           <select name="supplier" class="form-control tip select2" style="width:100%" id="supplier" required="required">
                                                <option value="">All Supplier</option>
                                                <?php $statement = $pdo->prepare("SELECT * FROM `tbl_customer` where status='1' and cust_type='2'");
                                                    $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>
                                     <span></span>
                             </div>
                            
                            
                            <div class="col-sm-4">
                                    <div class="form-group">
                                        <label class="control-label" for="departement_id">Select Location</label>
                                           <select name="location" class="form-control select2" style="width:100%" id="location" required="required">
                                                <option value="">All Location</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>
                        
                        <div class="row">
                            <div class="col-md-12">
                                <center><b>Purchase Refil Cylinder</b></center>
                                <div class="row">
                                    <div class="col-md-12">
                                        <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="table_refill_cylinder">
                                            <thead>
                                                <tr>
                                                <th>HSN /SAC No.</th>
                                                <th>Cylinder No.</th>
                                                <th>Product Name</th>
                                                <th>Purchase Rate</th>
                                                <th>Sell Rate</th>
                                                <th>Quantity</th>
                                                <th>Action</th>
                                              </tr>
                                            </thead>
                                              
                                              <tbody id="purchase_table">
                                                  
                                                  <tr style="background-color: burlywood;">
                                                      <td></td>
                                                      <td></td>
                                                      <td></td>
                                                      <td></td>
                                                      <td><input type="text" name="total_sell_rate"  value="0" class="form-control tip total_sell_rate" readonly/></td>
                                                      <td></td>
                                                      <td></td>
                                                  </tr>
                                                  
                                              </tbody>
                                         </table>
                                    </div>
                                </div>
                                
                            </div>
                            
                            <div class="col-md-6" hidden >
                                <center><b>Purchase New Cylinder</b></center><br>
                               <center><span id="add_new_purchase" class="btn btn-warning btn-sm"><i class="fa fa-plus"></i>Purchase New Cylinder</span></center> <br>
                               <table id="add_purchase_new_cylinder">
                                   <thead>
                                        <tr>
                                           <th>Product Name</th>
                                           <th>HSN/SAC No.</th>
                                           <th>Cylinder No.</th>
                                           <th>Purchase Price</th>
                                           <th>Stock</th>
                                           <th>Sell Price</th>
                                           <th>Action</th>
                                       </tr>
                                       
                                       
                                   </thead>
                                   <tbody>
                                       
                                   </tbody>
                                   <tfoot>
                                       <tr style="background-color: burlywood;">
                                           <td></td>
                                           <td></td>
                                           <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>
                                       </tr>
                                   </tfoot>
                               </table> 
                                
                            </div>
                        </div>
                       <br>
                        <div class="row">
                            <div class="col-md-6"></div>
                            <div class="col-md-6">
                                <div class="row">
                                    <div class="col-md-4"></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/>
                                        </div>
                                    </div>
                                    <div class="col-md-4">
                                        <div class="form-group">
                                            <label class="required" for="name">Advance Amount</label>                                    
                                            <input type="text" name="advance_amount" value="0" class="form-control tip" id="advance_amount"/>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="form-group" style="text-align:center;">
                            <input type="submit" name="add_purchase" value="Add Purchase"  class="btn btn-success" />
                        </form>
                        </div>

                    </div>
                        <div class="form-group" style="text-align:center;">
                            <a href="purchase-add.php"><button class="btn btn-primary" ><i class="fa fa-refresh"></i> Reset Form</button></a>
                            <a href="purchase.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).on('click', '.remove_rows', function() {
        $(this).closest('.cylinder_row').remove();
    });
    $('#add_new_purchase').on('click', function() {
        html = '<tr class="cylinder_row"><td><input type="text" name="new_product_name[]" class="form-control tip" required="required"/></td><td><input type="text" name="new_sku_no[]" class="form-control tip" required="required"/></td><td><input type="text" name="cylinder_no[]" class="form-control tip" required="required"/></td><td><input type="text" name="new_purchse_price[]" class="form-control tip" required="required"/></td><td><input type="text" name="new_stock[]" class="form-control tip" value="1" required="required" readonly/></td><td><input type="text" name="new_sell_price[]" class="form-control tip new_cylinder_sell_price" required="required"/></td><td><button class="btn btn-danger btn-sm remove_rows"><i class="fa fa-trash-o"></i></button></td></tr>';
        $('#add_purchase_new_cylinder').append(html);
    });
    
   
</script>
<script>

        $(document).ready(function(){
                var n='';
                n=parseInt(n) || 0;
                //console.log('bn Value='+n);
                
                $('.search-box input[type="text"]').on("keyup input", function(){
                    var search_text = $(this).val();
                    var resultDropdown = $(this).siblings(".result");
                    if(search_text.length>1){
                        $.get("apis/purchase-search-api.php", {search_text: search_text}).done(function(data){
                            resultDropdown.html(data);
                        });
                    } else{
                        resultDropdown.empty();
                    }
                });
            });
            
            
            function append_row(id){
    /*console.log('table row added'+id);*/
    $('.search-box input[type="text"]').val('');
    $(".result").empty();
    $('.search-box input[type="text"]').focus();
}

         function product_selection(id){ 
             
           var is_new = 1;
            $(".pro_ids").each(function(){
                if(id==$(this).val()){
                    is_new=0;
                     return false;
                }
            });  
             
      if(is_new==1){       
         // console.log('table row added'+id);
        $.ajax({
            url: 'apis/get-search-purchase.php',
            type: 'post',
            dataType: 'text',
            data:{pro_id:id},
            success: function (response) {
               // console.log('Id   :'+id);
                $('#purchase_table').prepend(response);
                $('.search-box input[type="text"]').val('');
                $(".result").empty();
                $('.search-box input[type="text"]').focus();
            }
        });
      }else{
          alert('this product Already Added..');
          $('.search-box input[type="text"]').val('');
          $(".result").empty();
          $('.search-box input[type="text"]').focus();
      }
        
        
        
        
       }
</script>


<script>

// ************************** INSERT AJAX START ******************************
    $(document).ready(function(){
   
    $('#add_purchase_form').on('submit', function(e){
                e.preventDefault();
               $("#add_purchase").attr('disabled','disabled');
                console.log('Purchase Submit Option Start...');
                var formData = new FormData(this);
                formData.append('type', 'add_new_purchase');
                            $.ajax({
                            url: 'apis/purchase-add-api.php',
                            type: 'post',
                            dataType: 'json',
                            data: formData,
                            cache: false,
                            contentType: false,
                            processData: false,
                            enctype: 'multipart/form-data',
                            success: function (response) {
                                console.log(response);
                                
                                
                                console.log("Response id " +response['id']);
                                
                                
                                if(response['status']==200){
                                    
                                    
                                    
                                                 //put success coode  
                                                 $('#add_purchase_form').trigger("reset");
                                                 $("#add_purchase").removeAttr('disabled');
                                      alert(response['message']);  
                                      
                                }else{
                                    //put falied code
                                    alert(response['message']);
                                    $("#add_purchase").removeAttr('disabled');
                                   
                                }
                                
                               
                            }
                        });
                
    }); 
    
    
            });
// ************************** INSERT AJAX END ******************************
</script>

<script>
    
    $(document).ready(function(){
    
    
}); 
    
    
</script>


<script>
    
    $(document).ready(function(){
        
         $('table#table_refill_cylinder tbody').on('change keyup', 'tr.remove_refill_cylinder_row', function() {

        final_calculation();
        
        
    });

    function final_calculation(){
        
        console.log('BRINDHA');
         var sum = 0;
            $(".sell_rate").each(function(){
                sum += +$(this).val();
            });
            $(".total_sell_rate").val(sum);
            total_final_amount();
           
    }
    
    
    
     $('table#add_purchase_new_cylinder tbody').on('change keyup', 'tr.cylinder_row', function() {
            console.log('Table Calculation');
        new_cylinder_calculation();
        
        
    });

    function new_cylinder_calculation(){
         var sum = 0;
            $(".new_cylinder_sell_price").each(function(){
                
                console.log('Venkateshan Anna');
                sum += +$(this).val();
            });
            $(".total_new_cylinder_sell_rate").val(sum);
            total_final_amount();
          
    }
    
     function total_final_amount(){
        
        console.log('Final Calculation Starts Here');
        
        console.log('BRINDHA');
         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"; ?>
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></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%;
  padding-right:4%;
}

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;
    }
</style>

Zerion Mini Shell 1.0