EVOLUTION-NINJA
Edit File: budget_list.php
<?php $this->load->view('includes/header.php')?> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('assets/css/grid_style.css'); ?>" /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('assets/css/jquery-ui.css'); ?>" /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('assets/jqgrid/css/ui.jqgrid.css'); ?>" /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('assets/jqgrid/css/ui.jqgrid-bootstrap.css'); ?>" /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('assets/jqgrid/css/ui.jqgrid-bootstrap-ui.css'); ?>" /> <script type="text/ecmascript" src="<?php echo base_url('assets/jqgrid/js/jquery.jqGrid.min.js'); ?>"></script> <script type="text/ecmascript" src="<?php echo base_url('assets/jqgrid/js/i18n/grid.locale-en.js'); ?>"></script> <script src="<?php echo base_url('assets/js/jquery-ui.js'); ?>" type="text/javascript"></script> <div class="content-wrapper"> <div class="row"> <div class="col-md-12 grid-margin stretch-card"> <div class="card"> <div class="card-body"> <div id ="jaytab" style="margin-top:3%" class="grid table-responsive"> <table id="list1"></table> <div id="pager1"></div> <div id="dialogSelectRow" title="Warning" style="display:none"> <p>Please select row</p> </div> </div> <div id ="jaytab1" style="margin-top:3%" class="grid table-responsive"> <table id="list2"></table> <div id="pager2"></div> <div id="dialogSelectRow" title="Warning" style="display:none"> <p>Please select row</p> </div> </div> </div> </div> </div> </div> </div> <script type="text/javascript"> CallGrid(); function CallGrid() { jQuery("#list1").jqGrid({ url:"<?php echo site_url('get-budget-list')?>", mtype : "get", datatype: "json", colNames:['id','Type Of Work','Material','Length','Breadth','Depth','Number','Total','Unit/Total','Ratio/Unit','RF','Quantity','Unit/QTY','Rate/Unit','Total Amt','GST','GST Amt','Final Amt','Labour Charges without GST','Labour Charges 40% without GST','Approval','','Action'], colModel:[ {name:'id',index:'id', width:100, hidden:true,editable:false,key:true}, {name:'type_of_work',index:'type_of_work', width:150, hidden:false,editable:false}, {name:'material',index:'material', width:100, hidden:false,editable:false}, {name:'length',index:'length', width:100, hidden:false,editable:false}, {name:'breadth',index:'breadth', width:100, hidden:false,editable:false}, {name:'dimension',index:'dimension', width:100, hidden:false,editable:false}, {name:'number',index:'number', width:100, hidden:false,editable:false}, {name:'total',index:'total', width:100, hidden:false,editable:false}, {name:'unit_name',index:'unit_name', width:150, hidden:false,editable:false}, {name:'radio_unit',index:'radio_unit', width:100, hidden:false,editable:false}, {name:'rf',index:'rf', width:80, hidden:false,editable:false}, {name:'quantity',index:'quantity', width:100, hidden:false,editable:false}, {name:'unit_quantity',index:'unit_quantity', width:150, hidden:false,editable:false}, {name:'rate_unit',index:'rate_unit', width:100, hidden:false,editable:false}, {name:'total_amount',index:'total_amount', width:150, hidden:false,editable:false}, {name:'gst',index:'gst', width:80, hidden:false,editable:false}, {name:'gst_amount',index:'gst_amount', width:150, hidden:false,editable:false}, {name:'final_amount',index:'final_amount', width:100, hidden:false,editable:false}, {name:'labour_charges_without_gst',index:'labour_charges_without_gst', width:150, hidden:false,editable:false}, {name:'labour_charges_fourty_without_gst',index:'labour_charges_fourty_without_gst', width:150, hidden:false,editable:false}, /*{name:'approval',index:'approval',editable:false,align:'center',editrules:{required: true},search:true, width:120,cellattr: function (rowId, tv, rawObject, cm, rdata) { return ' onclick="fun_approve('+rawObject.id+')" '; },formatter:function (cellvalue, options, rowObject) { if(cellvalue == 'APPROVED') return "APPROVED"; else if(cellvalue == 'NOT_APPROVED') return "<input type='button' value='APPROVE' \>"; }},*/ {name:'approval',index:'approval',editable:false,align:'center',editrules:{required: true},search:true, width:120,cellattr: function (rowId, tv, rawObject, cm, rdata) { return ' onclick="fun_approve('+rawObject.id+')" '; },formatter:function (cellvalue, options, rowObject) { if(cellvalue == 'APPROVED') return "<input type='checkbox' value='APPROVE' checked readonly \>"; else if(cellvalue == 'NOT_APPROVED') return "<input type='checkbox' value='APPROVE' \>"; }}, {name:'edited_status',index:'edited_status', width:150, hidden:true,editable:false}, {name:'',index:'',width:120, search:false,editable:false,align:'center',formatter: function (cellvalue, options, rowObject) { var retVal = ""; var retVal1 = ""; var retVal = '<a onclick="edit_budget('+rowObject.id+');" href="javascript:void(0);"><i class="fa fa-pencil-square-o" style="color:blue;" aria-hidden="true"></i></a> <a onclick="delete_budget('+rowObject.id+')"; href="javascript:void(0);"><i class="fa fa-trash" style="color:red;" aria-hidden="true"></i></a>'; //return retVal; var retVal1 = '<a onclick="edit_budget_approved('+rowObject.id+');" href="javascript:void(0);"><i class="fa fa-pencil-square-o" style="color:blue;" aria-hidden="true"></i></a> <a onclick="delete_budget_approved('+rowObject.id+')"; href="javascript:void(0);"><i class="fa fa-trash" style="color:red;" aria-hidden="true"></i></a>'; if(rowObject.approval == 'NOT_APPROVED') return retVal; else return retVal1; }}, ], rowNum:20, rowTotal: 2000, rowList : [20,30], rownumbers: true, //rownumWidth: 60, pager:"#pager1", sortname:'id', viewrecords: true, gridview: true, autowidth: true, sortorder:"asc", shrinkToFit: true, loadonce:true, autoencode: true, caption:"Budget List", //Subgrid1... subGrid: false, loadComplete: function () { var rows = $("#list1").getDataIDs(); for (var i = 0; i < rows.length; i++) { var status = $("#list1").getCell(rows[i],"edited_status"); //alert(status); if(status == "YES") { $("#list1").jqGrid('setRowData',rows[i],false, { background:'#ecabb7c4'}); } } } }); $("#list1").jqGrid("setLabel", "rn", "SL"); $("#list1").jqGrid('filterToolbar',{searchOperators : false}); //for multisearch code,remove if not required $("#list1").jqGrid('navGrid','#pager2', {edit:false,add:false,del:false,search:false,refreshstate:"current"}, { }, { }, { }, { sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'], closeOnEscape: true, multipleSearch: true, closeAfterSearch: true, closeAfterDelete:true, closeAfterEdit:true }, ); /*------------------------------- Edited Budget List ----------------------------*/ jQuery("#list2").jqGrid({ url:"<?php echo site_url('edited-budget-list')?>", mtype : "get", datatype: "json", colNames:['id','Type Of Work','Material','Length','Breadth','Depth','Number','Total','Unit/Total','Ratio/Unit','RF','Quantity','Unit/QTY','Rate/Unit','Total Amt','GST','GST Amt','Final Amt','Labour Charges without GST','Labour Charges 40% without GST','Approval','Edited By','Edited On','Edited At'], colModel:[ {name:'id',index:'id', width:100, hidden:true,editable:false,key:true}, {name:'type_of_work',index:'type_of_work', width:150, hidden:false,editable:false}, {name:'material',index:'material', width:100, hidden:false,editable:false}, {name:'length',index:'length', width:100, hidden:false,editable:false}, {name:'breadth',index:'breadth', width:100, hidden:false,editable:false}, {name:'dimension',index:'dimension', width:100, hidden:false,editable:false}, {name:'number',index:'number', width:100, hidden:false,editable:false}, {name:'total',index:'total', width:100, hidden:false,editable:false}, {name:'unit_name',index:'unit_name',width:150, hidden:false,editable:false}, {name:'radio_unit',index:'radio_unit',width:100, hidden:false,editable:false}, {name:'rf',index:'rf', width:80, hidden:false,editable:false}, {name:'quantity',index:'quantity', width:100, hidden:false,editable:false}, {name:'unit_quantity',index:'unit_quantity', width:150, hidden:false,editable:false}, {name:'rate_unit',index:'rate_unit', width:100, hidden:false,editable:false}, {name:'total_amount',index:'total_amount', width:150, hidden:false,editable:false}, {name:'gst',index:'gst', width:80, hidden:false,editable:false}, {name:'gst_amount',index:'gst_amount', width:150, hidden:false,editable:false}, {name:'final_amount',index:'final_amount', width:100, hidden:false,editable:false}, {name:'labour_charges_without_gst',index:'labour_charges_without_gst', width:150, hidden:false,editable:false}, {name:'labour_charges_fourty_without_gst',index:'labour_charges_fourty_without_gst', width:150, hidden:false,editable:false}, {name:'approval',index:'approval',editable:false,align:'center',editrules:{required: true},search:true, width:100,cellattr: function (rowId, tv, rawObject, cm, rdata) { return ' onclick="fun_approve_edited('+rawObject.id+')" '; },formatter:function (cellvalue, options, rowObject) { /*if(cellvalue == 'APPROVED') return "APPROVED"; else if(cellvalue == 'NOT_APPROVED') return "<input type='button' value='APPROVE' \>";*/ if(cellvalue == 'APPROVED') return "<input type='checkbox' value='APPROVE' checked readonly \>"; else if(cellvalue == 'NOT_APPROVED') return "<input type='checkbox' value='APPROVE' \>"; }}, {name:'created_by',index:'created_by', width:100, hidden:false,editable:false}, {name:'created_on',index:'created_on', width:150, hidden:false,editable:false,formatter: 'date', formatoptions: { newformat: 'd-m-Y' }}, {name:'created_at',index:'created_at', width:150, hidden:false,editable:false,formatter: 'date', formatoptions: {srcformat: "ISO8601Long", newformat: 'd-m-Y h:i:s' }}, ], rowNum:20, rowTotal: 2000, rowList : [20,30], rownumbers: true, //rownumWidth: 60, pager:"#pager2", sortname:'id', viewrecords: true, gridview: true, autowidth: true, sortorder:"asc", shrinkToFit: true, loadonce:true, autoencode: true, caption:"Edited Budget List", //Subgrid1... subGrid: false, }); $("#list2").jqGrid("setLabel", "rn", "SL"); $("#list2").jqGrid('filterToolbar',{searchOperators : false}); //for multisearch code,remove if not required $("#list2").jqGrid('navGrid','#pager2', {edit:false,add:false,del:false,search:false,refreshstate:"current"}, { }, { }, { }, { sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'], closeOnEscape: true, multipleSearch: true, closeAfterSearch: true, closeAfterDelete:true, closeAfterEdit:true }, ); } function edit_budget_approved(rowId) { swal({ title: "This Budget is already Approved, cannot Edit!", type: "warning", showCancelButton: false, confirmButtonColor: "#DD6B55", confirmButtonText: "OK" }); } function delete_budget_approved(id) { swal({ title: "This Budget is already Approved, cannot Delete!", type: "warning", showCancelButton: false, confirmButtonColor: "#DD6B55", confirmButtonText: "OK", }); } function edit_budget(rowId) { var id = rowId; window.location.href = '<?php echo site_url('budget-page');?>/'+id; } function delete_budget(id) { swal({ title: "Are you sure of deleting?", text: "You will not be able to recover this Layout 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-budget');?>", data : {'id':id}, success:function(response) { response=jQuery.parseJSON(response); console.log(response); if(response.result==1){ toastr["success"](response.message); $("#list1").setGridParam({datatype:'json', page:1}).trigger('reloadGrid'); } else { toastr["error"](response.message); $("#list1").setGridParam({datatype:'json', page:1}).trigger('reloadGrid'); } } }); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } function fun_approve(id) { swal({ title: "Are you sure?", text: "You want to Approve this?", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes!", 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('budget-approval');?>", data : {'budget_id':id}, success:function(response) { response=jQuery.parseJSON(response); console.log(response); if(response.result==1) { toastr["success"](response.message); $("#list1").setGridParam({datatype:'json', page:1}).trigger('reloadGrid'); } else { toastr["error"](response.message); $("#list1").setGridParam({datatype:'json', page:1}).trigger('reloadGrid'); } } }); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); $("#list1").setGridParam({datatype:'json', page:1}).trigger('reloadGrid'); } }); } function fun_approve_edited(id) { swal({ title: "Are you sure?", text: "You want to Approve this?", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes!", 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('budget-approval');?>", data : {'budget_id':id}, success:function(response) { response=jQuery.parseJSON(response); console.log(response); if(response.result==1) { toastr["success"](response.message); $("#list2").setGridParam({datatype:'json', page:1}).trigger('reloadGrid'); } else { toastr["error"](response.message); $("#list2").setGridParam({datatype:'json', page:1}).trigger('reloadGrid'); } } }); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); $("#list2").setGridParam({datatype:'json', page:1}).trigger('reloadGrid'); } }); } </script> <?php $this->load->view('includes/footer.php')?>