ok
Direktori : /home2/selectio/public_html/vijay-gases/ |
Current File : //home2/selectio/public_html/vijay-gases/purchase-add.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 id="content-div"> <div class="row"> <div class="col-md-2"> <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-md-2"> <div class="form-group"> <label class="required" for="name">Invoice No</label> <input type="text" name="invoice_no" class="form-control tip" id="invoice_no" required="required" /> </div> </div> <div class="col-md-2"> <div class="form-group"> <label class="required" for="name">Quantity</label> <input type="text" name="pro_qty" value="0" class="form-control tip" id="pro_qty" required="required" readonly/> </div> </div> <div class="col-sm-2"> <div class="form-group"> <label class="control-label" for="departement_id">Company Name</label> <select name="location" class="form-control select2" style="width:100%" id="location"> <option value="">All Companny 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-sm-2"> <div class="form-group"> <label class="control-label" for="departement_id">Select Purchase<span id="append_of_sup_balance" style="color:red;"></span></label> <select name="supplier" class="form-control tip select2" style="width:100%" id="supplier" z> <option value="">All Purchase</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> </div> <div class="col-md-1"> <a href="modal/purchase-supplier-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> <center><b>Purchase Refil Cylinder</b></center> <div class="row"> <div class="col-sm-3"> <div class="form-group"> <label class="control-label" for="departement_id">Select Gas</label> <select name="gas_type" class="form-control select2" style="width:100%" id="gas_type" > <option value="">Select Gas</option> <?php $statement = $pdo->prepare("SELECT * FROM `tbl_gas` where status='1'"); $statement->execute(); $location_result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($location_result as $result) { echo "<option value=".$result['id'].">".$result['gas_name']."</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 cylinder_no_search" id="search_text" style='text-transform:uppercase'/> <div class="result" style="overflow-y: scroll;max-height: 200px;"></div> </div> </div> <div class="col-md-1"> <a href="modal/purchase_create-product.php" data-toggle='ajax-modal' class="tip btn btn-warning btn-xs" style="margin-top: 35px;margin-left: -56%;"><i class="fa fa-plus-circle" aria-hidden="true" style="font-size:22px;"></i></a> </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 hidden>Quantity</th> <th>Action</th> </tr> </thead> <tbody id="purchase_table"> <tr style="background-color: burlywood;"> <td></td> <td style="text-align:right;"><b>Sub Total</b> </td> <td><input type="text" id="total_sell_rate" name="total_sell_rate" value="0" class="form-control tip total_sell_rate" style="border:3px solid #00a65a"></td> <td hidden></td> <td></td> </tr> </tbody> </table> </div> </div> <br> <div class="row"> <div class="col-12 col-sm-12 col-md-12 col-lg-12"> <span id="append_particular_gas"></span> </div> </div> <div class="row"> <div class="col-md-12"> <div class="row"> <div class="col-md-3"> <div class="form-group"> <label class="required" for="name">Select GST</label> <select name="gst_percentage" class="form-control select2" id="tax" style="width: 100%;" onkeyup="calculate()" onchange="calculate()"> <option value="0">Select GST</option> <?php $statement = $pdo->prepare("SELECT * FROM `tbl_gst` where status='1'"); $statement->execute(); $location_result = $statement->fetchAll(PDO::FETCH_ASSOC); foreach ($location_result as $result) { echo "<option value=".$result['gst_percentage'].">".$result['gst_percentage']." %</option>"; }?> </select> </div> </div> <div class="col-md-3"> <div class="form-group"> <label class="required" for="name">Select Tax Type</label> <select name="tax_type" id="tax_type" onkeyup="calculate()" style="width: 100%;" onchange="calculate()" data-placeholder="Select Customer" required="required" class="form-control select2"> <option value="1" selected="selected">Exclusive</option> <option value="2">Inclusive</option> </select> </div> </div> <div class="col-md-3"> <div class="form-group"> <label class="required" for="name">Select GST Type</label> <select name="gst_type" id="gst_type" onkeyup="calculate()" onchange="calculate()" data-placeholder="Select Customer" required="required" class="form-control select2"> <option value="1" selected="selected">GST</option> <option value="2">IGST</option> </select> </div> </div> <div class="row" style="margin-left:0px;"> <div class="col-md-4" id="div-cgst"> <div class="form-group"> <label class="" for="name">Total CGST <span style="color: blue;font-weight: 900;font-size: 18px;" id='cgst_tax_per' name='cgst_tax_per'>0.00</span> % </label><br> <span style="color: blue;font-weight: 900;font-size: 18px;" id='cgst_tax_amount'>0.00</span> </div> </div> <div class="col-md-4" id="div-sgst"> <div class="form-group"> <label class="" for="name">Total CGST <span style="color: blue;font-weight: 900;font-size: 18px;" id='sgst_tax_per'>0.00</span> % </label><br> <span style="color: blue;font-weight: 900;font-size: 18px;" id='sgst_tax_amount'>0.00</span> </div> </div> <div class="col-md-4" id="div-sgst"> <div class="form-group"> <label class="" for="name">Total <span id='gst_type_span'></span> <span style="color: blue;font-weight: 900;font-size: 18px;" id='gst_tax_per' name='gst_tax_per'>0.00</span> % </label><br> <span style="color: blue;font-weight: 900;font-size: 18px;" id='total_tax'>0.00</span> </div> </div> </div> <!-- Hidden GST Values Here --> <input type="hidden" name="gst_or_igst_amount" id="total_tax_input" value=""> <input type="hidden" name="cgst_or_sgst_amount" id="cgst_tax_per_input" value=""> <!-- Hidden GST Values Here --> <div class="col-md-3"> <div class="form-group"> <label class="required" for="name">After Tax Amount</label> <input type="text" name="total_amount" value="0" class="form-control tip" id="tax_after_total" onkeypress="return isNumberKey(this, event);" required="required" readonly/> </div> </div> <div class="col-md-3"> <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" required="required" onkeypress="return isNumberKey(this, event);"/> </div> </div> <div class="col-md-3"> <div class="form-group"> <label class="" for="name">Vehicle No</label> <input type="text" name="vehicle_no" value="0" class="form-control tip" id="vehicle_no"/> </div> </div> <div class="col-md-3"> <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()"> <option value="0">Select The Pay Term</option> <option value="1">Cash</option> <option value="2">Online</option> <option value="3">Cheque</option> <option value="4">Credit</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-6" 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 Payment Type</option> <option value="1">Fully Paid</option> <option value="2">Partially Paid</option> <option value="3">Month Due</option> <option value="4">Days Due</option> </select> </div> </div> </div> </div> <div class="col-md-12"> </div> </div> <div class="form-group" style="text-align:center;"> <input type="submit" name="add_purchase" value="Add Purchase" class="btn btn-success" /> </div> </div> </form> <div id="loading-div" style="display: none; padding-bottom: 80px;"> <center> <img src="img/loading.gif" style="width: 250px;"><br><b class="blinking">Processing Please Wait...</b></center> </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 type="text/javascript"> function select_supplier() { // $('#sub_caste').empty(); supplier_id=$("#supplier").val(); console.log('selcetd cate gete if:'+supplier_id); $.ajax({ url:'apis/balance-amount-supplier.php', type:'POST', data:{supplier_id:supplier_id}, success:function(data) { console.log(data); $("#append_of_sup_balance").append(data); } }); } </script> <script type="text/javascript"> $(document).ready(function(){ $(".cylinder_no_search").keypress(function(event) { $("#pro_qty").val($('.cylinder_no').length); empty_gas_type = $('#gas_type').val(); if(empty_gas_type==''){ alert("Select First Gas Type"); }else{ if(event.keyCode == 13) { cylinder_no = $('#search_text').val(); cylinder_type = $('#gas_type').val(); if(cylinder_no==''){ alert("Please Enter Barcode"); }else{ var is_new = 1; var posk_id=0; $.ajax({ url: 'apis/get-sku-by-pro-id.php', type: 'post', dataType: 'text', data:{pro_cylinder_no:cylinder_no,cylinder_type:cylinder_type}, success: function (response) { posk_id=response; console.log('get-sku-by-pro-id'+posk_id); $(".pro_ids ").each(function(){ console.log('for Hyrate Id:'+$(this).val()+' ----Entered Id:'+posk_id); if(posk_id==$(this).val()){ console.log(posk_id); is_new=0; return false; } }); if(is_new==1){ $.ajax({ url: 'apis/get-search-purchase.php', type: 'post', dataType: 'text', data:{pro_cylinder_no:cylinder_no,cylinder_type:cylinder_type}, success: function (response) { $('#table_refill_cylinder').prepend(response); new_cylinder_calculation(); $('#search_text input[type="text"]').val(''); $("#search_text").val(''); $("#search_text").empty(); $("#pro_qty").val($('.cylinder_no').length); } }); }else{ alert('This Cylinder Is 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(); if($('#supplier').val()==''){ alert('Please Select The Customer .....'); }else if($('#location').val()==''){ alert('Please Select The Location .....'); }else{ $('#loading-div').show(); $('#content-div').hide(); $("#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) { if(response['status']==200){ //put success coode $('#add_purchase_form').trigger("reset"); $("#add_purchase").removeAttr('disabled'); alert(response['message']); $('#loading-div').hide(); $('#content-div').show(); window.location.href = 'purchase.php'; }else{ //put falied code alert(response['message']); $("#add_purchase").removeAttr('disabled'); $('#loading-div').hide(); $('#content-div').show(); } } }); } }); }); // ************************** INSERT AJAX END ****************************** </script> <script> 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(); calculate(); } $(document).ready(function(){ new_cylinder_calculation(); $('table#table_refill_cylinder tbody').on('change keyup', 'tr.remove_refill_cylinder_row', function() { calculate(); }); $('table#add_purchase_new_cylinder tbody').on('change keyup', 'tr.cylinder_row', function() { //console.log('Table Calculation'); new_cylinder_calculation(); calculate(); }); }); </script> <script> $(document).ready(function() { $("form").bind("keypress", function(e) { if (e.keyCode == 13) { return false; } }); }); </script> <!--Payment Condition Div Selection Start 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> <script> $(document).ready(function(){ calculate(); }); function calculate(){ var pids=[]; $('.pro_ids').each(function(){ pids.push($(this).val()); }); console.log(pids); $("#append_particular_gas").empty(); $.ajax({ url:'apis/get-particular-gas-api.php', type:'POST', data:{pids:pids}, success:function(data) { $("#append_particular_gas").append(data); console.log('data:'+data); } }); var sub_total=0; $sub=0; sub_total=$('#total_sell_rate').val(); var sub_charges=0; sub_charges=$('#charges').val() || 0; var payable=0; var tax=$('#tax').val(); //tax peerc var tax_type=$('#tax_type').val(); //tax type if(tax==0){ $('#tax_after_total').val(sub_total); $('#total_amount').val(sub_total); $('#div-cgst').hide(); $('#div-sgst').hide(); $("#cgst_tax_amount").html(0); $("#sgst_tax_amount").html(0); $("#total_tax").html(0); //New One $('#cgst_tax_per_input').val(0); $('#total_tax_input').val(0); $('#cgst_tax_per').text(0); $('#sgst_tax_per').text(0); $('#gst_tax_per').text(0); }else{ if(tax_type==1){ //exclusive $('#tax_before_total').text(sub_total); $('#tax_after_total').val(parseFloat(sub_total)+(parseFloat(sub_total)*tax/100)); $('#total_tax').text((sub_total*tax/100)); $('#total_tax_input').val((sub_total*tax/100)); payable = sub_total+(sub_total*tax/100); $('#gst_tax_per').text(tax); $('#sgst_tax_per').text(tax/2); $('#cgst_tax_per').text(tax/2); $('#cgst_tax_amount').text((sub_total*tax/100)/2); $('#cgst_tax_per_input').val(parseFloat((sub_total*tax/100)/2).toFixed(2)); $('#sgst_tax_amount').text((sub_total*tax/100)/2); }else{ $('#tax_before_total').text((parseFloat(sub_total)-(parseFloat(sub_total)*parseFloat(tax))/(parseFloat(100)+parseFloat(tax))).toFixed(2)); $('#tax_after_total').val((parseFloat(sub_total)).toFixed(2)); $('#total_tax').text(((parseFloat(sub_total)*parseFloat(tax))/(parseFloat(100)+parseFloat(tax))).toFixed(2)); $('#total_tax_input').val(((parseFloat(sub_total)*parseFloat(tax))/(parseFloat(100)+parseFloat(tax))).toFixed(2)); payable = sub_total; $('#gst_tax_per').text(tax); $('#sgst_tax_per').text(tax/2); $('#cgst_tax_per').text(tax/2); var tax_sub=((parseFloat(sub_total)*parseFloat(tax))/(parseFloat(100)+parseFloat(tax)))/2; $('#cgst_tax_amount').text(parseFloat(tax_sub).toFixed(2)); $('#cgst_tax_per_input').val(parseFloat(tax_sub).toFixed(2)); $('#sgst_tax_amount').text(parseFloat(tax_sub).toFixed(2)); } $('#div-cgst').show(); $('#div-sgst').show(); } var gst_type=$('#gst_type').val(); console.log('gdt Type;'+gst_type); if(gst_type==1){ $('#gst_type_span').text('GST'); $('#div-cgst').show(); $('#div-sgst').show(); }else{ $('#gst_type_span').text('IGST'); $('#div-cgst').hide(); $('#div-sgst').hide(); } } </script> <!-- New GST Calculation Ends Here --> <?php include "footer.php";?> <!--Payment Condition Div Selection End Here--> <?php include "footer.php"; ?> <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> @media screen and (max-width: 600px) { table { margin-left: -14% !important; } } 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>