EVOLUTION-NINJA
Edit File: edit_tax_invoice_form.php
<?php echo view('includes/header');?> <!---<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('public/assets/css/multiple-select.css'); ?>" /> <script src="<?php echo base_url('public/assets/js/multiple-select.js'); ?>" type="text/javascript"></script>--> <link rel="stylesheet" href="<?php echo base_url('public/assets/jquery.sumoselect-master/sumoselect.css');?>"> <script src="<?php echo base_url('public/assets/jquery.sumoselect-master/jquery.sumoselect.min.js');?>"></script> <section class="content-header"> <h1>Tax Invoice Update Form</h1> </section> <!--- section 1 --> <?php //print_r($invoice); ?> <section class="content"> <section class="content"> <div class="col-sm-12 col-md-12"> <form id="land_owner" class="form-inline invoice_form" method="post"> <?php foreach($invoice as $invoice_details) { ?> <input type="hidden" class="form-control col-sm-8 invoice_id_pk" name="id" value="<?php echo $invoice_details['id'];?>" required="required"> <input type="hidden" class="form-control col-sm-8 invoice_number" name="invoice_number" value="<?php echo $invoice_details['invoice_number'];?>" required="required"> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Project</label> <select class="form-control col-sm-8 projects_list" onchange="change_project();" name="project_name" required="required"> <option value="<?php echo $invoice_details['project_id'];?>"><?php echo $invoice_details['project_name'];?></option> <?php foreach($project_names as $project_name){?> <option value="<?php echo $project_name->project_id;?>"><?php echo $project_name->project_name;?></option> <?php } ?> </select> </div> <?php } ?> </div> <!-- row 1----> <div class="row"> <div id = "jaytab3" style="margin-top:3%;margin-left: -28px;" class="col-sm-12 grid" > <div class="grid_div"></div> <table id="list3"></table> <div id="pager3"></div> <div id="dialogSelectRow3" title="Warning" style="display:none"> <p>Please select row</p> </div> <div class="row land_owner_a"> <div class="col-sm-4 col-md-4"></div> <div class="col-sm-4 col-md-4" style="margin-top:2%;"> <button type="button" class="btn btn-primary center-block get_site_grid" onclick="getSelectedRow();" >Submit</button> </div> <div class="col-sm-4 col-md-4"></div> </div> <!-- row 4----> </div> </div> <div class="row"> <div id = "jaytab2" style="margin-top:3%;margin-left: -28px;" class="col-sm-12 grid2"> <div class="grid_div"></div> <table id="list2"></table> <div id="pager2"></div> <div id="dialogSelectRow" title="Warning" style="display:none"> <p>Please select row</p> </div> <div class="row land_owner_a"> <div class="col-sm-4 col-md-4"></div> <div class="col-sm-4 col-md-4" style="margin-top:2%;"> <button type="button" class="btn btn-primary center-block get_site_grid" onclick="getSelectedRow1();" >Submit</button> </div> <div class="col-sm-4 col-md-4"></div> </div> <!-- row 4----> </div> </div> <div class="row show-remaining" style="display:none;"> <?php foreach($invoice as $invoice_details){ //foreach($invoice_details as $val){?> <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" name="invoice_number" value="<?php echo $invoice_details['invoice_number'];?>" required="required" readonly> </div> </div> <!-- row 2----> <div class="row land_owner_a"> <input type="hidden" class="form-control col-sm-8 site_list" name="site_list" required="required"> <input type="hidden" class="form-control col-sm-8 site_number" name="site_number" required="required"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Invoice Type</label> <select class="form-control col-sm-8" id="it" name="invoice_type" onchange="invoice_type(this);" required="required"> <option value="<?php echo $invoice_details['invoice_type'];?>"><?php echo $invoice_details['invoice_type'];?></option> <option value="Tax Invoice">Tax Invoice</option> <option value="Proforma Invoice">Proforma Invoice</option> </select> </div> <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" name="invoice_to" required="required" value="<?php echo $invoice_details['invoice_to'];?>"> </div> </div> <!-- row 2----> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Date</label> <input type="text" class="form-control col-sm-8 dob date_picker" value="<?php echo $invoice_details['created_at'];?>" name="day" max=""> </div> <div class="form-group col-sm-12 col-md-6"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4 col-md-4">Bank Holder Name</label> <select class="form-control col-sm-8" name="bank_holder_name" id="sel1"> <option value="<?php echo $invoice_details['bank_name'];?>"><?php echo $invoice_details['bank_name'];?></option> <?php foreach($bank_name as $val) { ?> <option value="<?php echo $val->holder_name;?>"><?php echo $val->holder_name;?></option> <?php } ?> </select> </div> </div> <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" value="<?php echo $invoice_details['total_sqft'];?>" required="required"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4 col-md-4">Rate/SQFT</label> <input type="text" class="col-sm-8 rate_per_sqft" name="rate_per_sqft" value="<?php echo $invoice_details['rate_per_sqft'];?>" required="required"> </div> </div> <!-- row 2----> <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" value="<?php echo $invoice_details['without_gst_total_amt'];?>" required="required"> </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" value="<?php echo $invoice_details['sgst'];?>" required="required"> </div> </div> <!-- row 2----> <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" value="<?php echo $invoice_details['cgst'];?>" required="required"> </div> <div class="form-group col-sm-12 col-md-6"> <label class="col-sm-4">Total amount</label> <input type="text" class="form-control col-sm-8 total_withgst_amt" onfocusout="myFunction()" value="<?php echo $invoice_details['with_gst_total_amt'];?>" name="total_withgst_amt" required="required"> </div> </div> <!-- row 2----> <?php } ?> <div class="row land_owner_a"> <div class="form-group 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">Update</button> </div> <div class="col-sm-4 col-md-4"></div> </div> <!-- row 4----> </div> </form> </div> </section> <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; } .content-wrapper { min-height: 1170px !important; } </style> <!-- This is the Javascript file of jqGrid --> <script type="text/ecmascript" src="<?php echo base_url('public/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('public/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('public/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('public/jqgrid/css/ui.jqgrid.css'); ?>" /> <script src="<?php echo base_url('public/assets/js/jquery-ui.js'); ?>" type="text/javascript"></script> <script type="text/javascript"> var ids=<?php echo $details->id ?>; var inv = <?php echo json_encode($details->invoice_number ?? ''); ?>; // Ensure it's a valid JS value function change_project() { //alert(); var project_id=$('.projects_list').val(); //alert(project_id); jQuery("#list2").jqGrid({ url:"<?php echo site_url('get_project_sites_edit')?>?project_id="+project_id, type : "GET", datatype: "json", colNames:['SI','','Project','Site','Dimension','Date','TSV','Status'], colModel:[ {name:'id',index:'id', width:150, hidden:true,editable:false,key:true}, {name:'project_id',index:'project_id',hidden:true, width:150,editable:false}, {name:'project_name',index:'project_name', width:150,editable:false}, {name:'site_number',index:'site_number', width:75, editable:false}, {name:'dimension',index:'dimension', width:75, editable:false}, {name:'registration_date',index:'registration_date', width:100,formatter: 'date', formatoptions: { srcformat: 'Y/m/d', newformat: 'd-m-Y'}, editable:false}, {name:'tsv',index:'tsv', width:75, editable:false}, {name:'booking_status',index:'booking_status', width:100, editable:false}, ], rowNum:20000, rowTotal: 2000, rowList : [10,20,30,50,100,500,1000], rownumbers: true, rownumWidth: 40, pager:"#pager2", sortname:'id', viewrecords: true, gridview: true, autowidth: true, sortorder:"desc", shrinkToFit: true, //emptyrecords: loctionreload, multiselect: true, // multiboxonly: true, //loadonce:true, caption:" Site Details", }); $('#jaytab3').hide(); $('#jaytab2').show(); // $('.get_site_grid').show(); $("#list2").jqGrid("setLabel", "rn", "SL"); $("#list2").jqGrid('navGrid','#pager2', {edit:true,add:false,del:false,search:true,refreshstate:"current"}, { }, { }, { }, { sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'], closeOnEscape: true, multipleSearch: true, closeAfterSearch: true } ); } $(document).ready(function (){ grid_load(); }); function grid_load() { var project_id=$('.projects_list').val(); var inv_num=$('.invoice_number').val(); // alert(inv_num); jQuery("#list3").jqGrid({ url: "<?php echo site_url('get_project_sites_edit')?>?project_id=" + project_id + "&inv=" + inv_num, type: "GET", datatype: "json", colNames: ['SI', '', 'Project', 'Site', 'Dimension', 'Date', 'TSV', 'Status'], colModel: [ {name: 'id', index: 'id', width: 150, hidden: true, editable: false, key: true}, {name: 'project_id', index: 'project_id', hidden: true, width: 150, editable: false}, {name: 'project_name', index: 'project_name', width: 150, editable: false}, {name: 'site_number', index: 'site_number', width: 75, editable: false}, {name: 'dimension', index: 'dimension', width: 75, editable: false}, {name: 'registration_date', index: 'registration_date', width: 100, formatter: 'date', formatoptions: {srcformat: 'Y/m/d', newformat: 'd-m-Y'}, editable: false}, {name: 'tsv', index: 'tsv', width: 75, editable: false}, {name: 'booking_status', index: 'booking_status', width: 100, editable: false} ], rowNum: 20000, rowList: [10, 20, 30, 50, 100, 500, 1000], pager: "#pager3", sortname: 'id', viewrecords: true, gridview: true, autowidth: true, sortorder: "asc", shrinkToFit: true, multiselect: true, caption: "Site Details", loadComplete: function(data) { console.log("Data Loaded: ", data); } }); $('#jaytab2').hide(); $('#jaytab3').show(); //$('.get_site_grid').show(); $("#list3").jqGrid("setLabel", "rn", "SL"); $("#list3").jqGrid('navGrid','#pager3', {edit:true,add:false,del:false,search:true,refreshstate:"current"}, { }, { }, { }, { sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'], closeOnEscape: true, multipleSearch: true, closeAfterSearch: true } ); // Example: Button has data-id="123" } $('.date_picker').datepicker({ changeMonth:true, changeYear:true, yearRange: "1940:c", // dateFormat: 'yy-mm-dd' dateFormat: 'dd-mm-yy' }); $('.invoice_form').submit(function(e){ e.preventDefault(); var id = $('.invoice_id_pk').val(); //alert(id); formdata = new FormData($(this)[0]); $(".submit_button").attr('disabled', 'disabled'); $(".submit_button").text("Updating..."); $.ajax({ type : 'post', url : '<?php echo site_url("update-invoice-details")?>', data : formdata, contentType: false, processData: false, success:function(response){ //response=jQuery.parseJSON(response); console.log(response); if(response.result == 1) { toastr["success"](response.message); setTimeout(function(){ window.location.href = "<?php echo site_url('tax-invoice-form');?>?id="+response.message }, 1500); } else if(response.result == 2) { toastr["error"](response.message); $(".submit_button").text("Submit"); $(".submit_button").removeAttr('disabled'); } else { toastr["error"](response.message); $(".submit_button").text("Submit"); $(".submit_button").removeAttr('disabled'); } } }); }); // function loctionreload() { toastr["success"]('No data Found for this project'); setTimeout(function(){ location.reload(); }, 1500); } function getSelectedRow() { var id; id = jQuery("#list3").jqGrid('getGridParam','selarrrow'); var row = $("#list3").jqGrid('getGridParam','selrow'); if(row != null ) { var $grid = $("#list3"), selIds = $grid.jqGrid("getGridParam", "selarrrow"), i, n, cellValues1 = []; cellValues2 = []; for (i = 0, n = selIds.length; i < n; i++) { cellValues1.push($grid.jqGrid("getCell", selIds[i], "project_id")); cellValues2.push($grid.jqGrid("getCell", selIds[i], "site_number")); var project_id=cellValues1.join(","); var site_id=cellValues2.join(","); // alert(site_id); } $.ajax({ type : 'post', url : '<?php echo site_url("get_sites_sqft")?>', data : {'project_id':cellValues1,'site_id':cellValues2}, success:function(response) { //response=jQuery.parseJSON(response); console.log(response); if(response.result == 1) { $('.total_sqft').val(response.message); $('.site_list').val(response.site_id); $('.site_number').val(response.site_number); // $("#list3").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid'); } } }); //$('#list3').attr('checked', true); $('#list3').addClass( "ui-state-highlight" ); $('.show-remaining').show(); } else $( "#dialogSelectRow3" ).dialog(); } function getSelectedRow1() { var id; id = jQuery("#list2").jqGrid('getGridParam','selarrrow'); var row = $("#list2").jqGrid('getGridParam','selrow'); if(row != null ) { var $grid = $("#list2"), selIds = $grid.jqGrid("getGridParam", "selarrrow"), i, n, cellValues1 = []; cellValues2 = []; for (i = 0, n = selIds.length; i < n; i++) { cellValues1.push($grid.jqGrid("getCell", selIds[i], "project_id")); cellValues2.push($grid.jqGrid("getCell", selIds[i], "site_number")); var project_id=cellValues1.join(","); var site_id=cellValues2.join(","); //alert(site_id); } $.ajax({ type : 'post', url : '<?php echo site_url("get_sites_sqft")?>', data : {'project_id':cellValues1,'site_id':cellValues2}, success:function(response) { // response=jQuery.parseJSON(response); console.log(response); if(response.result == 1) { $('.total_sqft').val(response.message); $('.site_list').val(response.site_id); $('.site_number').val(response.site_number); $("#list2").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid'); } } }); //$('#list2').attr('checked', true); $('#list2').addClass( "ui-state-highlight" ); $('.show-remaining').show(); } else $( "#dialogSelectRow" ).dialog(); } $(".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()); }); function myFunction() { var total_withgst_amt=$('.total_withgst_amt').val(); //alert(total_withgst_amt); var total_sqft=$('.total_sqft').val(); 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); var rate_per_sqft = parseFloat(amount1)/parseFloat(total_sqft); $('.total_amt').val(amount1.toFixed()); $('.rate_per_sqft').val(rate_per_sqft.toFixed()); } function get_row_details(ids) { console.log("Fetching data for ID:", ids); // Debugging log to ensure IDs are passed correctly $.ajax({ type: 'post', url: '<?php echo site_url("get-row-details")?>', data: { 'id': ids }, success: function(response) { console.log("Response:", response); // Debugging log to check response data if (response.result === 1) { // Assuming you're processing and populating the form fields here: const sites = JSON.parse(response.message.site_numbers); // Ensure it's parsed correctly // Populate your table or fields with the data $('#someField').val(response.message.someField); // Example field population } else { toastr["error"](response.message); } }, error: function(xhr, status, error) { console.error("AJAX Error:", status, error); toastr["error"]("Failed to retrieve data"); } }); } </script> <?php echo view('includes/footer');?>