EVOLUTION-NINJA
Edit File: tax_invoice_form.php
<?php $this->load->view('includes/header');?> <script src="<?php echo base_url('assets/admin_dashboard/js/jquery.table2excel.js');?>"></script> <section class="content-header"> <h1> Tax Invoice Form</h1> </section> <!--- section 1 --> <div role="tabpanel" class="tab-pane" id="tax"> <form id="land_owner" class="form-inline tax_invoice_form"> <!---- row 2--> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-4"> <label class="col-sm-4 ">From date</label> <input type="text" class="form-control col-sm-8 from_date_picker tax_from" id="tax_invoice_from" name="from_date"> </div> <div class="form-group col-sm-12 col-md-4"> <label class="col-sm-4">To date</label> <input type="text" class="form-control col-sm-5 to_date_picker tax_to" id="tax_invoice_to" name="to_date"> </div> <div class="form-group col-sm-12 col-md-4"> <label class="col-sm-4 ">Select Holder Name</label> <select class="form-control col-sm-8 holder_name" name="holder_name" id="holder_name"> <option value="">Select</option> <?php foreach($bank_details as $bank) { ?> <option value="<?php echo $bank->holder_name;?>"><?php echo $bank->holder_name;?></option> <?php } ?> </select> </div> <!-- row 2--> </div> <div class="row land_owner_a"> <div class="col-sm-4 col-md-4"></div> <div class="col-sm-4 col-md-4"> <button type="submit" class="btn btn-primary center-block submit">Submit</button> </div> <div class="col-sm-4 col-md-4"></div> </div> </form> </div> <hr> <!-- Button trigger modal --> <section class="content"> <div class="col-sm-12 col-md-12 buttons"> <div style="display:none;"> <table border="1" style="border-spacing: 0px !important;" id="print_table" class="print_table"></table> </div> <button type="submit" class="btn btn-primary" onclick="print_page();" >Print</button> <button type="submit" class="btn btn-primary" onclick="export_page();">Export</button> </div> <div id = "jaytab3" style="margin-top:3%;" class="col-sm-12 grid"> <div class="grid_div"></div><table id="list7"></table> <div id="pager7"></div> <div id="dialogSelectRow3" title="Warning" style="display:none"> <p>Please select row</p> </div> </div> <div style="display:none;"><table border="1" style="border-spacing: 0px !important;" id="tax_invoice_print_table" class="tax_invoice_print_table"></table></div> <div style="display:none;"><table border="1" style="border-spacing: 0px !important;" id="tax_invoice_export_table" class="tax_invoice_export_table"></table></div> </section> <!-- Modal --> <div class="modal fade" id="edit_modal" role="dialog"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Update Invoice details</h4> </div> <div class="modal-body"> <form id="land_owner" class="form-inline update_form"> <input type="hidden" class="form-control col-sm-8 invoice_id_pk" name="id" required="required"> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Invoice number</label> <input type="text" class="form-control col-sm-8 invoice_number" name="invoice_number" required="required"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Invoice Type</label> <input type="text" class="form-control col-sm-8 invoice_type" name="invoice_type" required="required"> </div> </div> <!-- row 1----> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">To</label> <input type="text" class="form-control col-sm-8 invoice_to" name="invoice_to"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4 col-md-4">Bank</label> <div id="pkgbody"></div> </div> </div> <!-- row 1----> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Total Sqft</label> <input type="text" class="form-control col-sm-8 total_sqft" name="total_sqft"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Rate Per Sqft</label> <input type="text" class="form-control col-sm-8 rate_per_sqft" name="rate_per_sqft"> </div> </div> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Basic Amount</label> <input type="text" class="form-control col-sm-8 total_amt" name="total_amt"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">SGST</label> <input type="text" class="form-control col-sm-8 sgst" name="sgst"> </div> </div> <!-- row 3----> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">CGST</label> <input type="text" class="form-control col-sm-8 cgst" name="cgst"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Total</label> <input type="text" class="form-control col-sm-8 total_withgst_amt" onfocusout="myFunction()" name="total_withgst_amt"> </div> </div> <div class="row land_owner_a"> <div class="col-sm-4 col-md-4"></div> <div class="col-sm-4 col-md-4"> <button type="submit" class="btn btn-primary center-block submit">Submit</button> </div> <div class="col-sm-4 col-md-4"></div> </div> <!-- row 4----> </form> </div> <!-- <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> <button type="button" class="btn btn-primary" data-dismiss="modal">Submit</button> </div> --> </div> </div> </div> <!-- This is the Javascript file of jqGrid --> <script type="text/ecmascript" src="<?php echo base_url('jqgrid/js/jquery.jqGrid.min.js'); ?>"></script> <!-- This is the localization file of the grid controlling messages, labels, etc. <!-- We support more than 40 localizations --> <script type="text/ecmascript" src="<?php echo base_url('jqgrid/js/i18n/grid.locale-en.js'); ?>"></script> <!-- A link to a jQuery UI ThemeRoller theme, more than 22 built-in and many more custom --> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('assets/css/jquery-ui.css'); ?>" /> <!-- The link to the CSS that the grid needs --> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('jqgrid/css/ui.jqgrid.css'); ?>" /> <script src="<?php echo base_url('assets/js/jquery-ui.js'); ?>" type="text/javascript"></script> <style type="text/css"> a { color: inherit; } .form-control:focus, input[type="Submit"]:focus, input[type="button"]:focus { border-color: #FF0000; box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(255, 0, 0, 0.6); } #FrmGrid_list2 { width: 100% !important; } .ui-jqdialog .ui-jqdialog-titlebar { height: 29px !important; background-color: #001a00; color: white; padding-left: 10px; } .fm-button { height: 21px !important; padding: 1px; margin-right: 10px !important; height: 21px !important; width: 50%; margin-top: -7px !important; } .ui-jqdialog-content td.navButton { padding-top: 12px !important; } .ui-jqgrid .ui-jqgrid-titlebar { height: 27px !important; background:#AF0100 !important; color:white !important; } .ui-jqgrid-bdiv { height: auto !important; } .ui-widget-overlay { z-index:0 !important; } .ui-resizable { z-index:9999 !important; } .ui-widget-header { background: #1e7ad7 !important; } .ui-jqgrid-hdiv ui-state-default { width: 873px !important; cursor: default!important } ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight { border: 1px solid #fed22f; background: #ffe45c; } .ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { font-weight: bold; color: black; } .ui-jqgrid .ui-jqgrid-bdiv { overflow-y: scroll; //overflow-x: hidden; } .agr_appr { font-weight:bold !important; color:#AF0100; cursor: pointer; } </style> <script type="text/javascript"> $('.from_date_picker').datepicker({ changeMonth:true, changeYear:true, yearRange: "2000:c", dateFormat: 'dd-mm-yy' }); $('.to_date_picker').datepicker({ changeMonth:true, changeYear:true, yearRange: "2000:c", dateFormat: 'dd-mm-yy' }); $('.tax_invoice_form').submit(function(e){ e.preventDefault(); var from= $("#tax_invoice_from").val(); var to= $("#tax_invoice_to").val(); var name= $("#holder_name").val(); jQuery("#list7").jqGrid({ url:"<?php echo site_url('tax-invoice-list')?>?from_date="+from+"&to_date="+to+"&holder_name="+name, type : "GET", datatype: "json", colNames:['SI','Project Name','Sites','Invoice No','Invoice Type','To','Total SQFT','Rate/SQFT','Basic Amt','SGST','CGST','Total CGST','Total SGST','With GST Total Amt','Holder Name','Date','Status','Edit','Delete','Print'], colModel:[ {name:'id',index:'id', width:50, hidden:true,editable:false,key:true}, {name:'project_name',index:'project_name', width:100, editable:false}, {name:'site_numbers',index:'site_numbers', width:100, editable:false, formatter: function (cellvalue, options, rowObject) { if(rowObject.site_numbers){ var site_number=jQuery.parseJSON(rowObject.site_numbers); console.log(site_number); var retVal = ''; $.each(site_number, function(key, val){ retVal +=''+val+','; }); return retVal; } else{ return 'No Id proof'; } }}, {name:'invoice_number',index:'invoice_number', width:100, editable:false}, {name:'tax_status',index:'tax_status', width:100, editable:false}, {name:'invoice_to',index:'invoice_to', width:100, editable:false}, {name:'total_sqft',index:'total_sqft', width:100, editable:false}, {name:'rate_per_sqft',index:'rate_per_sqft', width:100, editable:false}, {name:'without_gst_total_amt',index:'without_gst_total_amt', width:100, editable:false}, {name:'sgst',index:'sgst', width:100, editable:false}, {name:'cgst',index:'cgst', width:100, editable:false}, {name:'total_cgst',index:'total_cgst', width:100, editable:false}, {name:'total_sgst',index:'total_sgst', width:100, editable:false}, {name:'with_gst_total_amt',index:'with_gst_total_amt', width:100, editable:false}, {name:'bank_name',index:'bank_name', width:100, editable:false}, {name:'created_at',index:'created_at', width:100, editable:false}, {name:'delete_status',index:'delete_status', width:100, editable:false}, {name:' ',index:' ',editable:false,align: "center",editrules:{required: true},search:false, width:50,cellattr: function (rowId, tv, rawObject, cm, rdata) { return ' onclick="fun($(this))" '; },formatter:function (cellvalue, options, rowObject) { return "<input type='button' value='EDIT' \>"; }}, {name:'delete',index:'delete',align: "center",editable:false,search:false,editrules:{required: true}, width:70,cellattr: function (rowId, tv, rawObject, cm, rdata) { return ' onclick="fun_delete($(this))" '; },formatter:function (cellvalue, options, rowObject) { return "<input type='button' value='DELETE' \>"; }}, {name:'print',index:'print',align: "center",editable:false,search:false,editrules:{required: true}, width:70,cellattr: function (rowId, tv, rawObject, cm, rdata) { return ' onclick="fun_print($(this))" '; },formatter:function (cellvalue, options, rowObject) { return "<input type='button' value='PRINT' \>"; }}, ], rowNum:2000, rowTotal: 2000, rowList : [10,20,30,50,100,500,1000], rownumbers: true, rownumWidth: 40, pager:"#pager7", sortname:'owner_id', viewrecords: true, gridview: true, autowidth: true, sortorder:"asc", shrinkToFit: false, emptyrecords: 'No records to display', // multiselect: true, // multiboxonly: true, loadonce:true, caption:" Invoice List", }); $("#list7").jqGrid("setLabel", "rn", "SL"); $("#list7").jqGrid('filterToolbar',{searchOperators : false}); //for multisearch code,remove if not required $("#list7").jqGrid('navGrid','#pager7', {edit:true,add:false,del:false,search:true,refreshstate:"current"}, { }, { }, { }, { sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'], closeOnEscape: true, multipleSearch: true, closeAfterSearch: true } ); }); function fun_delete(rowId) { var id = rowId.closest('tr').attr('id'); swal({ title: "Are you sure?", text: "You will not be able to recover this data!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, Delete it!", cancelButtonText: "No, cancel plz!", closeOnConfirm: false, closeOnCancel: false }, function(isConfirm){ if (isConfirm) { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); $.ajax({ type : 'post', url : '<?php echo site_url("delete_invoice")?>', data : {id:id}, success:function(response) { response=jQuery.parseJSON(response); console.log(response); if(response.result == 1) { toastr["success"](response.message); $("#list1").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid'); } } }); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } function fun(rowId) { var id = rowId.closest('tr').attr('id'); // var id = rowId.closest('tr').attr('id'); //alert(id); window.location.href = "<?php echo site_url('edit-tax-invoice-form');?>?id="+id; } $(".rate_per_sqft").focusout(function(){ var total_sqft=$('.total_sqft').val(); var rate_per_sqft=$('.rate_per_sqft').val(); var amount=parseFloat(total_sqft) * parseFloat(rate_per_sqft); $('.total_amt').val(amount.toFixed()); }); $(".total_amt").focusout(function(){ var total_sqft=$('.total_sqft').val(); var total_amt=$('.total_amt').val(); var amount=parseFloat(total_amt) / parseFloat(total_sqft); $('.rate_per_sqft').val(amount.toFixed()); }); $(".sgst").focusout(function(){ var total_sqft=$('.total_sqft').val(); var rate_per_sqft=$('.rate_per_sqft').val(); var amount=parseFloat(total_sqft) * parseFloat(rate_per_sqft); var sgst=$('.sgst').val(); var cgst=$('.cgst').val(); var total_sgst=(parseFloat(amount) * parseFloat(sgst))/100; var total_cgst=(parseFloat(amount) * parseFloat(cgst))/100; if(total_cgst > 0) { var tot_amount=parseFloat(amount) + parseFloat(total_sgst) + parseFloat(total_cgst); } else { var tot_amount=parseFloat(amount) + parseFloat(total_sgst); } $('.total_withgst_amt').val(tot_amount.toFixed()); }); $(".cgst").focusout(function(){ var total_sqft=$('.total_sqft').val(); var rate_per_sqft=$('.rate_per_sqft').val(); var amount=parseFloat(total_sqft) * parseFloat(rate_per_sqft); var sgst=$('.sgst').val(); var cgst=$('.cgst').val(); var total_sgst=(parseFloat(amount) * parseFloat(sgst))/100; var total_cgst=(parseFloat(amount) * parseFloat(cgst))/100; if(total_sgst>0) { var tot_amount=parseFloat(amount) + parseFloat(total_sgst) + parseFloat(total_cgst); } else { var tot_amount=parseFloat(amount) + parseFloat(total_cgst); } $('.total_withgst_amt').val(tot_amount.toFixed()); }); $(".total_withgst_amt").focusout(function(){ var total_withgst_amt=$('.total_withgst_amt').val(); var basic_amt=$('.total_amt').val(); if(sgst>0 && cgst>0) { var total_sgst=(parseFloat(total_amt) * parseFloat(sgst))/100; var total_cgst=(parseFloat(total_amt) * parseFloat(cgst))/100; if(total_sgst>0) { var tot_amount=parseFloat(total_amt) + parseFloat(total_sgst) + parseFloat(total_cgst); } else { var tot_amount=parseFloat(total_amt) + parseFloat(total_cgst); } $('.total_withgst_amt').val(tot_amount.toFixed()); } }); function myFunction() { var total_withgst_amt=$('.total_withgst_amt').val(); //alert(total_withgst_amt); var sgst=$('.sgst').val(); var cgst=$('.cgst').val(); var total_gst = parseFloat(sgst)+parseFloat(cgst); var amount = (parseFloat(total_withgst_amt)-(parseFloat(total_withgst_amt)*(100/(100+parseFloat(total_gst))))); var amount1 = parseFloat(total_withgst_amt)- parseFloat(amount); $('.total_amt').val(amount1.toFixed()); } function fun_print(rowId) { var id = rowId.closest('tr').attr('id'); window.location.href = "<?php echo site_url('tax-invoice-print');?>?id="+id; } function print_page() { var id = jQuery("#list7").jqGrid('getDataIDs'); $.ajax({ type : 'post', url : '<?php echo site_url("get_table_details_invoice")?>', data : {id:id}, success:function(data){ response=jQuery.parseJSON(data); console.log(response); $('.print_table').empty(); var count =1; var content = ''; content +='<thead><tr><th>SI</th>,<th>Project Name</th>,<th>Sites</th>,<th>Invoice No</th>,<th>Invoice Type</th>,<th>To</th>,<th>Total SQFT</th>,<th>Rate/SQFT</th>,<th>Without GST Total Amt</th>,<th>SGST</th>,<th>CGST</th>,<th>Total CGST</th>,<th>Total SGST</th>,<th>With GST Total Amt</th>,<th>Holder Name</th>,<th>Date</th></tr></thead>'; $.each(response,function(key,val){ $.each(val,function(key,va){ var sites=jQuery.parseJSON(va.site_numbers); content +='<tr><td>'+count+'</td> <td>'+va.project_name+'</td>'; content +='<td>'; $.each(sites,function(key,va){ content+=va; content+=','; }); //}); content +='<td>'+va.invoice_number+'</td> <td>'+va.invoice_type+'</td> <td>'+va.invoice_to+'</td>'; content +='</td>'; content +='<td>'+va.total_sqft+'</td>'; content +='<td>'+va.rate_per_sqft+'</td>'; content +='<td>'+va.without_gst_total_amt+'</td>'; content +='<td>'+va.sgst+'</td>'; content +='<td>'+va.cgst+'</td>'; content +='<td>'+va.total_cgst+'</td>'; content +='<td>'+va.total_sgst+'</td>'; content +='<td>'+va.with_gst_total_amt+'</td>'; content +='<td>'+va.bank_name+'</td>'; content +='<td>'+va.created_at+'</td>'; content +='</tr>'; count++; }); }); $('.print_table').append(content); print_page1(); } }); } function export_page() { var id = jQuery("#list7").jqGrid('getDataIDs'); $.ajax({ type : 'post', url : '<?php echo site_url("get_table_details_invoice")?>', data : {id:id}, success:function(data) { response=jQuery.parseJSON(data); console.log(response); $('.print_table').empty(); var count =1; var content = ''; content +='<thead><tr><th>SI</th>,<th>Project Name</th>,<th>Sites</th>,<th>Invoice No</th>,<th> Invoice Type</th>,<th>To</th>,<th>Total SQFT</th>,<th>Rate/SQFT</th>,<th>Without GST Total Amt</th>,<th>SGST</th>,<th>CGST</th>,<th>Total CGST</th>,<th>Total SGST</th>,<th>With GST Total Amt</th>,<th>Holder Name</th>,<th>Date</th></tr></thead>'; $.each(response,function(key,val){ $.each(val,function(key,va){ var sites=jQuery.parseJSON(va.site_numbers); content +='<tr><td>'+count+'</td> <td>'+va.project_name+'</td>'; content +='<td>'; $.each(sites,function(key,va){ content+=va; content+=','; }); //}); content +='<td>'+va.invoice_number+'</td> <td>'+va.invoice_type+'</td> <td>'+va.invoice_to+'</td>'; content +='</td>'; content +='<td>'+va.total_sqft+'</td>'; content +='<td>'+va.rate_per_sqft+'</td>'; content +='<td>'+va.without_gst_total_amt+'</td>'; content +='<td>'+va.sgst+'</td>'; content +='<td>'+va.cgst+'</td>'; content +='<td>'+va.total_cgst+'</td>'; content +='<td>'+va.total_sgst+'</td>'; content +='<td>'+va.with_gst_total_amt+'</td>'; content +='<td>'+va.bank_name+'</td>'; content +='<td>'+va.created_at+'</td>'; content +='</tr>'; count++; }); }); $('.print_table').append(content); export_data(); } }); } function export_data(){ $("#print_table").table2excel({ exclude: ".noExl", name: "Excel Document Name", filename: "tax-invoice-list", fileext: ".xls", exclude_img: true, exclude_links: true, exclude_inputs: true }); } function print_page1() { var divToPrint=document.getElementById('print_table'); newWin= window.open(""); newWin.document.write('<html><head><title></title>'); newWin.document.write('</head>'); newWin.document.write(divToPrint.outerHTML); newWin.document.write('</html>'); newWin.print(); document.getElementById('print_table').style.display=''; newWin.close(); location.reload(); } </script> <?php $this->load->view('includes/footer');?>