EVOLUTION-NINJA
Edit File: supervisor_view.php
<?php $this->load->view('includes/admin_dashboard_header');?> <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"> <!-- <h1 class="page-header"> Dashboard <small>Statistics Overview</small> </h1> <ol class="breadcrumb"> <li class="active"> <i class="fa fa-user" aria-hidden="true"></i> Manage Users </li> </ol>--> </div> </div> <!-- /.row --> <section class="admin_heading"> <div class="col-sm-12"> <h3>Supervisor</h3> </div> <div class="col-sm-12"> <div id = "jaytab" style="width: 100%; margin-top:1%;"> <p>Last Updated Date and Time is : <?php if(empty($time)) { echo "Data not found"; }else{ echo $time->createdate; } ?></p> <table id="list2"></table> <div id="pager2"></div> <div id="dialogSelectRow" title="Warning" style="display:none"> <p>Please select row</p> </div> </div> </div> </section> <input type="hidden" id="demo"/> <input type="hidden" id="demo1"/> <input type="hidden" id="demo2"/> <?php $ci =& get_instance(); $base_url = base_url(); ?> <!-- /.row end--> </div> <!-- /.container-fluid --> </div> </div> <?php $this->load->view('includes/admin_dashboard_footer');?> <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> <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/supervisor_view_insert');?>", mtype : "post", datatype: "json", colNames:['Id','usercode','Region','Username','Email','Password','Phone','Department','Role'], colModel:[ {name:'id',index:'id', width:100, align:'center',key:true,hidden:true,editable:true}, {name:'usercode', index:'usercode', align:'center',editable:true, width:100}, {name:'region', index:'region', width:100, align:'center', sortable:false,formatter: 'select',editable:true, edittype:'select',editoptions:{value:{<?php foreach($region as $reg) {?> <?php echo $reg->id ; ?> :'<?php echo $reg->region;?>',<?php } ?>} } }, {name:'username', index:'username', width:150, align:'center', sortable:false,editable:true,edittype:'text'}, {name:'email', index:'email', width:200, align:'center',editable:true,edittype:'text'}, {name:'password', index:'password', width:100, align:'center', sortable:false,editable:true,edittype:'password'}, {name:'phone', index:'phone', width:120, align:'center', sortable:false,editable:true,edittype:'text'}, {name:'department', index:'department', width:140, align:'center', sortable:false,editable:true, edittype:'select',formatter: 'select',editoptions:{value:{<?php foreach($supervisor as $sup){ ?> <?php echo $sup->id ; ?> :'<?php echo $sup->role;?>',<?php } ?>} } }, {name:'role', index:'role', width:100, align:'center', sortable:false,formatter: 'select',editable:true,edittype:'select',editoptions:{value:{<?php foreach($role as $rol){ ?> <?php echo $rol->id;?>:'<?php echo $rol->role;?>',<?php } ?>} } } ], rowNum:50, rowTotal: 2000, rowList : [50,100,200], rownumbers: true, rownumWidth: 40, pager:"#pager2", sortname:'id', viewrecords: true, loadonce:true, gridview: true, autowidth: true, sortorder:"asc", //multiple: true, caption:"supervisor" }); $("#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:"Add", buttonicon:"ui-icon-plus", onClickButton: addRow, position: "last", title:"", cursor:"pointer", id:"client_add" } ); $("#list2").navButtonAdd('#pager2', { caption:"Edit", buttonicon:"ui-icon-pencil", onClickButton: editRow, position: "last", title:"", cursor: "pointer", id:"client_edit" } ); $("#list2").navButtonAdd('#pager2', { caption:"Delete", buttonicon:"ui-icon-trash", onClickButton: deleteRow, position: "last", title:"", cursor: "pointer", id:"client_delete" } ); }); function addRow() { // Get the currently selected row $("#list2").jqGrid('editGridRow', 'new', { modal: true, jqModal: true, recreateForm: true, beforeSubmit: function(postdata, formid) { var usercode = $("#usercode").val(); var region = $("#region").val(); var username = $("#username").val(); var email = $("#email").val(); var password = $("#password").val(); var phone = $("#phone").val(); var department = $("#department").val(); var role = $("#role").val(); var image = $("#image").val(); var createdate = $("#createdate").val(); var status = $("#status").val(); var strongPasswordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/; if (!strongPasswordRegex.test(password)) { return [false, "Password must be at least 8 characters long and include at least one uppercase letter, one lowercase letter, one number, and one special character."]; } var alphanumericRegex = /^[a-zA-Z0-9\s,._-]+$/; // Validate fields for alphanumeric input only if (!alphanumericRegex.test(usercode) || !alphanumericRegex.test(region) || !alphanumericRegex.test(username) || !alphanumericRegex.test(department) || !alphanumericRegex.test(role)) { return [false, "Only letters and numbers are allowed in these fields."]; } var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if (!emailRegex.test(email)) { return [false, "Please enter a valid email address."]; } // Phone validation (only numbers) var phoneRegex = /^[0-9]+$/; if (!phoneRegex.test(phone)) { return [false, "Please enter a valid phone number (numbers only)."]; } alert("Sending Email to " + email); var ccEmail = prompt("Enter the Cc to:", ""); alert("You are sending Cc to: " + ccEmail); if (ccEmail != null) { document.getElementById("demo1").value = ccEmail; } var cc = $("#demo1").val(); $.ajax({ url: "<?php echo site_url('controller/supervisor_view_add');?>", type: "POST", data: { 'usercode': usercode, 'region': region, 'username': username, 'email': email, 'password': password, 'phone': phone, 'department': department, 'role': role, 'image': image, 'createdate': createdate, 'status': status, 'cc': cc }, async: false, success: function(data) { alert('Successfully Added.'); $("#editmodlist2").remove(); window.location.reload(); } }); }, closeAfterAdd: true, reloadAfterSubmit: false, closeOnEscape: true, clearAfterAdd: true, afterSubmit: false }); } function deleteRow() { // Get the currently selected row var row = $("#list2").jqGrid('getGridParam','selrow'); var email=$("#email").val(row); if( row != null ) $("#list2").jqGrid('delGridRow',row, { modal:true,jqModal:true, recreateForm: true, beforeSubmit: function(postdata,formid){ alert("sending Email to "+email) var myAge = prompt("Enter the Cc to :","") alert("you are sending Cc to:"+ myAge) if (myAge!=null) { x=myAge; document.getElementById("demo2").value=x; } var cc=$("#demo2").val(); $.ajax({ url:"<?php echo site_url('controller/supervisor_view_delete');?>", type:"POST", data:{'id':row,'cc':cc}, async:false, success:function(data){ if(data==""){ alert(''); } else{ alert('Successfully Deleted'); $("#delmodlist2").remove(); window.location.reload(); } } }); }, closeAfterEdit: true, reloadAfterSubmit:false, afterSubmit : false }); else $( "#dialogSelectRow" ).dialog(); } function editRow() { var row = $("#list2").jqGrid('getGridParam','selrow'); if( row != null ) $("#list2").jqGrid('editGridRow',row, { modal:true,jqModal:true, recreateForm: true, beforeSubmit: function(postdata,formid){ var id = $("#id").val(); var usercode = $("#usercode").val(); var region = $("#region").val(); var username = $("#username").val(); var email = $("#email").val(); var password = $("#password").val(); var phone = $("#phone").val(); var department = $("#department").val(); var role = $("#role").val(); var image = $("#image").val(); var createdate = $("#createdate").val(); var status = $("#status").val(); var strongPasswordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$/; if (!strongPasswordRegex.test(password)) { return [false, "Password must be at least 8 characters long and include at least one uppercase letter, one lowercase letter, one number, and one special character."]; } var alphanumericRegex = /^[a-zA-Z0-9\s,._-]+$/; /*if (!alphanumericRegex.test(usercode) || !alphanumericRegex.test(region) || !alphanumericRegex.test(username) || !alphanumericRegex.test(department) || !alphanumericRegex.test(role)) { return [false, "Only letters and numbers are allowed in these fields."]; }*/ var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if (!emailRegex.test(email)) { return [false, "Please enter a valid email address."]; } // Phone validation (only numbers) var phoneRegex = /^[0-9]+$/; if (!phoneRegex.test(phone)) { return [false, "Please enter a valid phone number (numbers only)."]; } alert("sending Email to "+email) var myAge = prompt("Enter the Cc to :","") alert("you are sending Cc to:"+ myAge) if (myAge!=null) { x=myAge; document.getElementById("demo").value=x; } var cc=$("#demo").val(); $.ajax({ url:"<?php echo site_url('controller/supervisor_view_edit');?>", type:"POST", data:{'id':id,'usercode':usercode,'region':region,'username':username,'email':email,'password':password,'phone':phone,'department':department,'role':role,'image':image,'createdate':createdate,'status':status,'cc':cc}, async:false, success:function(data){ if(data==""){ alert('Successfully .'); } else{ alert('Successfully Updated'); $("#editmodlist2").remove(); window.location.reload(); } } }); }, closeAfterEdit: true, reloadAfterSubmit:false, afterSubmit : false }); else $( "#dialogSelectRow" ).dialog(); } </script>