EVOLUTION-NINJA
Edit File: admin_index.php
<?php $this->load->view('includes/admin_dashboard_header');?> <script> $(document).ready(function() { function disableBack() { window.history.forward() } window.onload = disableBack(); window.onpageshow = function(evt) { if (evt.persisted) disableBack() } }); </script> <div id="wrapper"> <!-- Navigation --> <?php $this->load->view('includes/admin_menu');?> <div id="page-wrapper"> <div class="container-fluid"> <!-- Page Heading --> <div class="row"> <div class="col-lg-12"> </div> </div> <!-- /.row --> <div class="row"> <div class="col-sm-6 p_list"> <h3>Product List</h3> <table id="list2"></table> <div id="pager2"></div> </div> <div class="col-sm-6 c_list"> <h3>Category List</h3> <table id="list3"></table> <div id="pager3"></div> </div> <?php $ci =& get_instance(); $base_url = base_url(); ?> </div> <!-- /.row end--> </div> <!-- /.container-fluid --> </div> <!-- /#page-wrapper --> <!-- /#wrapper --> </div> <style> @media only screen and (min-width:320px) and (max-width:641px){ .ui-jqgrid { margin-left: 1px !important; } #sData span, #cData span { margin-left: 0 !important; } } @media only screen and (min-width:641px) and (max-width:991px){ .ui-jqgrid { margin-left: 1px !important; } #jaytab{ margin-top: 0 !important; margin-left: 0 !important; overflow-x: scroll; width: 100% !important; padding-left:0 !important; padding-right:9px !important; } } #sData span, #cData span { margin-left: 3px; } #sData { height: 29px; } #cData { height: 29px; } .jqgfirstrow { height: 0px !important; } .text_color a{ color:white !important; } </style> <?php $this->load->view('includes/admin_dashboard_footer');?> <script type="text/ecmascript" src="<?php echo base_url('jqgrid/js/jquery.jqGrid.js'); ?>"></script> <!-- This is the Javascript file of jqGrid --> <script type="text/ecmascript" src="<?php echo base_url('jqgrid/js/i18n/grid.locale-en.js'); ?>"></script> <script type="text/ecmascript" src="<?php echo base_url('jqgrid/js/jquery.jqGrid.min.js'); ?>"></script> <script> $(document).ready(function (){ jQuery("#list2").jqGrid({ url:"<?php echo site_url('controller/product_view');?>", mtype : "post", datatype: "json", colNames:['Id','Product','Created On'], colModel:[ {name:'id',index:'id', width:50, align:'center',key:true,editable:true,hidden:true}, {name:'product',index:'product', width:50, align:'center',key:true,editable:true}, {name:'createdate', index:'createdate', align:'center',editable:false, width:50,formatter:'date', formatoptions:{srcformat:'Y-m-d',newformat:'d-m-Y'}} ], rowNum:10, rowTotal: 2000, rowList : [10,20,40,80], rownumbers: true, rownumWidth: 40, pager:"#pager2", sortname:'id', viewrecords: true, loadonce:true, gridview: true, autowidth: true, sortorder:"asc", caption:"Product" }); $("#list2").jqGrid('filterToolbar',{searchOperators : false});//for multisearch code,remove if not required $("#list2").jqGrid('navGrid','#pager2', {edit:false,add:false,del:false,search:true,refreshstate:"current"}, { }, { }, { }, { sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'], closeOnEscape: true, multipleSearch: true, closeAfterSearch: true, multipleGroup:true, caption:"search" } ); $('#pager2').css("height", "auto"); $("#list2").navButtonAdd('#pager2', { caption:"", buttonicon:"ui-icon-plus", onClickButton: addRow, position: "last", title:"", cursor:"pointer", id:"client_add" } ); $("#list2").navButtonAdd('#pager2', { caption:"", buttonicon:"ui-icon-pencil", onClickButton: editRow, position: "last", title:"", cursor: "pointer", id:"client_edit" } ); }); function addRow() { // Get the currently selected row $("#list2").jqGrid('editGridRow','new', { modal:true,jqModal:true, recreateForm: true, beforeSubmit: function(postdata,formid){ var product = $("#product").val(); var createdate = $("#createdate").val(); const alphaNumericPattern = /^[a-zA-Z0-9\s,._-]+$/; if (!alphaNumericPattern.test(product) ) { alert("Invalid input detected."); return false; } $.ajax({ url:"<?php echo site_url('controller/product_add');?>", type:"POST", data:{'product':product,'createdate':createdate}, async:false, success:function(data){ alert('Successfully Added.'); $("#editmodlist2").remove(); //jqtab(); $("#list2").trigger("reloadGrid"); window.location.reload(); } }); }, closeAfterAdd: true, reloadAfterSubmit:false, closeOnEscape:true, clearAfterAdd: true, afterSubmit :false }); } function editRow() { // Get the currently selected row var row = $("#list2").jqGrid('getGridParam','selrow'); if( row != null ) $("#list2").jqGrid('editGridRow',row, { modal:true,jqModal:true, recreateForm: true, beforeSubmit: function(postdata,formid){ var product = $("#product").val(); var createdate = $("#createdate").val(); const alphaNumericPattern = /^[a-zA-Z0-9\s,._-]+$/; if (!alphaNumericPattern.test(product) ) { alert("Invalid input detected."); return false; } var id = $("#id").val(); $.ajax({ url:"<?php echo site_url('controller/product_edit');?>", type:"POST", data:{'product':product,'createdate':createdate,'id':id}, async:false, success:function(data){ if(data==""){ alert('Successfully Updated.'); $("#list2").trigger("reloadGrid"); jQuery('#list2').jqGrid('editRow',id,true,reload()); } else{ alert('Successfully Updated'); $("#editmodlist2").remove(); window.location.reload(); } } }); }, closeAfterEdit: true, reloadAfterSubmit:false, afterSubmit : false }); else alert("please select row"); } </script> <script> $(document).ready(function (){ jQuery("#list3").jqGrid({ url:"<?php echo site_url('controller/category_view');?>", mtype : "post", datatype: "json", colNames:['id','Category','Created On'], colModel:[ {name:'id',index:'id', width:50, align:'center',key:true,editable:true,hidden:true}, {name:'category',index:'category', width:50, align:'center',key:true,editable:true}, {name:'createdate', index:'createdate', align:'center',editable:false, width:50,formatter:'date', formatoptions:{srcformat:'Y-m-d',newformat:'d-m-Y'}} ], rowNum:10, rowTotal: 2000, rowList : [10,20,40,80], rownumbers: true, rownumWidth: 40, pager:"#pager3", sortname:'id', viewrecords: true, loadonce:true, gridview: true, autowidth: true, sortorder:"asc", //multiple: true, caption:"Category" }); $("#list3").jqGrid('filterToolbar',{searchOperators : false});//for multisearch code,remove if not required $("#list3").jqGrid('navGrid','#pager3', {edit:false,add:false,del:false,search:true,refreshstate:"current"}, { }, { }, { }, { sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'], closeOnEscape: true, multipleSearch: true, closeAfterSearch: true, multipleGroup:true, caption:"search" } ); $('#pager3').css("height", "auto"); $("#list3").navButtonAdd('#pager3', { caption:"", buttonicon:"ui-icon-plus", onClickButton: addRow1, position: "last", title:"", cursor:"pointer", id:"client_add" } ); $("#list3").navButtonAdd('#pager3', { caption:"", buttonicon:"ui-icon-pencil", onClickButton: editRow1, position: "last", title:"", cursor: "pointer", id:"client_edit" } ); }); function addRow1() { // Get the currently selected row $("#list3").jqGrid('editGridRow','new', { modal:true,jqModal:true, recreateForm: true, beforeSubmit: function(postdata,formid){ var category = $("#category").val(); var createdate = $("#createdate").val(); const alphaNumericPattern = /^[a-zA-Z0-9\s,._-]+$/; if (!alphaNumericPattern.test(category) ) { alert("Invalid input detected."); return false; } $.ajax({ url:"<?php echo site_url('controller/category_add');?>", type:"POST", data:{'category':category,'createdate':createdate}, async:false, success:function(data){ alert('Successfully Added.'); $("#editmodlist2").remove(); //jqtab(); $("#list2").trigger("reloadGrid"); window.location.href="<?php echo site_url('controller/admin');?>"; // window.location.reload(); } }); }, closeAfterAdd: true, reloadAfterSubmit:false, closeOnEscape:true, clearAfterAdd: true, afterSubmit :false }); } function editRow1() { // Get the currently selected row var row = $("#list3").jqGrid('getGridParam','selrow'); if( row != null ) $("#list3").jqGrid('editGridRow',row, { modal:true,jqModal:true, recreateForm: true, beforeSubmit: function(postdata,formid){ var category = $("#category").val(); var createdate = $("#createdate").val(); const alphaNumericPattern = /^[a-zA-Z0-9\s,._-]+$/; if (!alphaNumericPattern.test(category) ) { alert("Invalid input detected."); return false; } var id = $("#id").val(); $.ajax({ url:"<?php echo site_url('controller/category_edit');?>", type:"POST", data:{'category':category,'createdate':createdate,'id':id}, async:false, success:function(data){ if(data==""){ alert('Successfully Updated.'); $("#list2").trigger("reloadGrid"); jQuery('#list2').jqGrid('editRow',id,true,reload()); } else{ alert('Successfully Updated'); $("#editmodlist3").remove(); //window.location.reload(); window.location.href="<?php echo site_url('controller/admin');?>"; } } }); }, closeAfterEdit: true, reloadAfterSubmit:false, afterSubmit : false }); /*else $( "#dialogSelectRow" ).dialog();*/ else alert("please select row"); } </script>