EVOLUTION-NINJA
Edit File: request_list.php
<?php echo view('includes/admin_header.php') ?> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('public/assets/css/jquery-ui.css'); ?>" /> <link rel="stylesheet" href="<?php echo base_url('public/assets/toastr/toastr.min.css'); ?>"> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('public/assets/jqgrid/css/ui.jqgrid.css'); ?>" /> <!--<link rel="stylesheet" type="text/css" href="<?php echo base_url('public/assets/website_assets/css/innerpage.css'); ?>"/>--> <script type="text/javascript" src="<?php echo base_url('public/assets/toastr/toastr.min.js'); ?>"></script> <script type="text/ecmascript" src="<?php echo base_url('public/assets/jqgrid/js/jquery.jqGrid.min.js'); ?>"></script> <script type="text/ecmascript" src="<?php echo base_url('public/assets/jqgrid/js/i18n/grid.locale-en.js'); ?>"></script> <script src="<?php echo base_url('public/assets/js/jquery-ui.js'); ?>" type="text/javascript"></script> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <!-- Content Header (Page header) --> <section class="content-header"> <h1> Request List <small></small> </h1> </section> <!-- Main content --> <!-- Button trigger modal --> <section class="content"> <div id="jaytab" style="margin-top:3%" class="grid"> <table id="list2"></table> <div id="pager2"></div> <div id="dialogSelectRow" title="Warning" style="display:none"> <p>Please select row</p> </div> </div> </section> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel">Add Comment</h4> </div> <div class="modal-body"> <form id="add_comment" class="comment_form"> <div class="row land_owner_a"> <div class="form-group col-sm-12 col-md-12"> <label class="col-sm-4">Comment</label> <input type="hidden" name="mapping_id" class="mapping_id"> <input type="hidden" name="faculty_id" class="faculty_id"> <textarea row="3" cols="40" name="comment" required="required"></textarea> </div> </div> <!-- row 1--> <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 return_submit">Submit</button> </div> <div class="col-sm-4 col-md-4"></div> </div> <!-- row 6--> </form> </div> </div> </div> </div> <div class="modal fade" id="approval_subjects" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> <h4 class="modal-title" id="myModalLabel">Request List</h4> </div> <div class="modal-body"> <form id="approve_subjects"> <div class="row land_owner_a"> <div class="col-sm-4 sub_categories"> </div> <!-- row 1--> <div class="col-sm-4 session_type"> </div> <div class="col-sm-4 sub_timings"> </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">Approve</button> </div> <div class="col-sm-4 col-md-4"></div> </div> <!-- row 6--> </form> </div> </div> </div> </div> </div> <!--- col-sm-8 --> <script type="text/javascript"> $(document).ready(function() { CallGrid(); function CallGrid(access_rights_global, access_result_global) { jQuery("#list2").jqGrid({ url: "<?php echo site_url('request_details') ?>", mtype: "get", datatype: "json", colNames: ['SI', 'Faculty Name', 'Comment', 'Category', 'Sub Category', 'Batch Size', 'Session Type', 'Timings', 'Sent On', 'Status', 'Action'], colModel: [{ name: 'id', index: 'id', width: 10, hidden: true, editable: false, key: true }, { name: 'user_name', index: 'user_name', editable: false, width: 100 }, { name: 'comments', index: 'comments', editable: false, width: 120 }, { name: 'domain_name', index: 'domain_name', editable: false, width: 150 }, { name: 'sub_domains', index: 'sub_domains', editable: false, width: 110 }, { name: 'batch_size', index: 'batch_size', editable: false, width: 80 }, { name: 'available_type', index: 'available_type', editable: false, width: 100 }, { name: 'timings', index: 'timings', editable: false, width: 170 }, { name: "created_at", index: "created_at", editable: false, width: 140 }, { name: 'approval_status', index: 'approval_status', align: 'center', editable: false, width: 145 }, { name: 'delete', index: 'delete', editable: false, width: 50, search: false }, ], rowNum: 20, rowTotal: 2000, rowList: [20, 30], rownumbers: true, //rownumWidth: 20, pager: "#pager2", sortname: 'id', viewrecords: true, gridview: true, autowidth: true, sortorder: "asc", shrinkToFit: true, loadonce: true, caption: "Request List", }); $("#list2").jqGrid("setLabel", "rn", "SL"); $("#list2").jqGrid('filterToolbar', { searchOperators: false, stringResult: true, searchOnEnter: false, defaultSearch: "cn" }); //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, closeAfterDelete: true, closeAfterEdit: true }, ); } }); // function fun_del(id, login_id) { // $.ajax({ // type: "post", // url: "<?php //echo site_url('check_material_exist'); ?>", // data: { // 'id': id, // 'login_id': login_id // }, // success: function(response) { // // response = jQuery.parseJSON(response); // console.log(response); // if (response.result == 1) { // swal("Material is added to this domain you cannot delete this") // } else { // var type = "post"; // swal({ // title: "Are you sure?", // text: "You will not be able to recover this layout!", // 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: type, // url: "<?php //echo site_url('delete_request'); ?>", // data: { // 'id': id // }, // success: function(response) { // // response = jQuery.parseJSON(response); // console.log(response); // if (response.result == 1) { // toastr["success"]('Deleted Successfully'); // $("#list2").setGridParam({ // datatype: 'json', // page: 1 // }).trigger('reloadGrid'); // } else { // toastr["error"]('Something Went Wrong..'); // } // } // }); // } else { // $(".sweet-alert").hide(); // $(".sweet-overlay").hide(); // } // }); // } // } // }); // } // function fun_del(id, login_id) { // // First, check if material exists for the given id and login_id // $.ajax({ // type: "post", // url: "<?php echo site_url('check_material_exist'); ?>", // data: { // 'id': id, // 'login_id': login_id // }, // success: function (response) { // // response = jQuery.parseJSON(response); // console.log(response); // if (response.result == 1) { // swal("Material is added to this domain, and you cannot delete this."); // } else { // // Material does not exist, so proceed with the deletion // var type = "post"; // swal({ // title: "Are you sure?", // text: "You will not be able to recover this layout!", // 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(); // // Now, send the request to delete the item // $.ajax({ // type: type, // url: "<?php echo site_url('delete_request'); ?>", // data: { // 'id': id // }, // success: function (response) { // // response = jQuery.parseJSON(response); // console.log(response); // if (response.result == 1) { // toastr["success"]('Deleted Successfully'); // // Assuming you're using jqGrid, reload the grid // $("#list2").trigger('reloadGrid'); // } else { // toastr["error"]('Something Went Wrong..'); // } // } // }); // } else { // $(".sweet-alert").hide(); // $(".sweet-overlay").hide(); // } // }); // } // } // }); // } function fun_del(id, login_id) { // First, check if material exists for the given id and login_id $.ajax({ type: "post", url: "<?php echo site_url('check_material_exist'); ?>", data: { 'id': id, 'login_id': login_id }, success: function (response) { console.log(response); if (response.result == 1) { swal("Material is added to this domain, and you cannot delete this."); } else { // Material does not exist, so proceed with the deletion var type = "post"; swal({ title: "Are you sure?", text: "You will not be able to recover this layout!", 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(); // Now, send the request to delete the item $.ajax({ type: type, url: "<?php echo site_url('delete_request'); ?>", data: { 'id': id }, success: function (response) { console.log(response); if (response.result == 1) { toastr["success"]('Deleted Successfully'); // Assuming you're using jqGrid, reload the grid $("#list2").trigger('reloadGrid'); } else { toastr["error"]('Something Went Wrong..'); } } }); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } } }); } function fun_approve(id, mapping_id) { var type = "post"; $.ajax({ type: type, url: "<?php echo site_url('approve_faculty_subjects'); ?>", data: { 'id': id, 'mapping_id': mapping_id }, success: function(response) { // response = jQuery.parseJSON(response); console.log(response); if (response.result == 1) { var fields = ''; fields += '<input type="hidden" name="id" value="' + id + '">'; fields += '<input type="hidden" name="mapping_id" value="' + mapping_id + '">'; fields += '<h4 style="margin-left: 8%;" class="timings">Course Details</h4>'; $.each(response.message.result, function(key, val) { fields += '<div class="form-group col-sm-offset-2 col-sm-12 col-md-12 ">'; fields += '<input type="checkbox" name="sub_domain_id[]" value="' + val.sub_domain_id + '" class="sub_domain_id"> ' + val.sub_domain + ''; fields += '</div>'; }); var session_fields = ''; var time_fields = ''; time_fields += '<input type="hidden" name="id" value="' + id + '">'; time_fields += '<input type="hidden" name="mapping_id" value="' + mapping_id + '">'; time_fields += '<h4 style="margin-left: 8%;" class="timings">Course Timings</h4>'; if (response.message.course_type == 'fullday') { session_fields += '<h4 style="margin-left: 8%;" class="timings">Session Type</h4>'; session_fields += '<input type="hidden" name="available_type" value="fullday">'; //time_fields += '<p style="margin-left: 50px;"> Fullday</p>'; time_fields += '<p style="margin-left: 50px;"><input type="checkbox" name="course_type[]"> Fullday</p>'; session_fields += '<input type="hidden" name="time_id[]" value="' + response.message.timings.time_id + '">'; var course_type = jQuery.parseJSON(response.message.timings.course_type); session_fields += '<div class="form-group col-sm-offset-5 col-sm-12 col-md-12 ">'; $.each(course_type, function(x, y) { session_fields += '<p> ' + y.charAt(0).toUpperCase() + y.slice(1).toLowerCase() + '</p>'; //session_fields += '<p><input type="checkbox" name="course_type[]" value="'+y+'" class="sub_domain_id"> '+y.charAt(0).toUpperCase() + y.slice(1).toLowerCase()+'</p>'; }); session_fields += '</div>'; } else if (response.message.course_type == 'recorded') { session_fields += '<h4 style="margin-left:10%;" class="timings">Session Type</h4>'; session_fields += '<p style="margin-left: 50px;">Recorded</p>'; time_fields += '<input type="hidden" name="available_type" value="recorded">'; time_fields += '<div class="form-group col-sm-offset-2 col-sm-12 col-md-12 ">'; time_fields += '<input type="hidden" name="time_id[]" value="' + response.message.timings.time_id + '">'; var course_type = jQuery.parseJSON(response.message.timings.course_type); $.each(course_type, function(x, y) { time_fields += '<p style="display:none;"><input checked type="checkbox" name="course_type[]" value="' + y + '" class="sub_domain_id"> ' + y.charAt(0).toUpperCase() + y.slice(1).toLowerCase() + '</p>'; }); time_fields += '</div>'; } else { session_fields += '<h4 style="margin-left: 8%;" class="timings">Session Type</h4>'; // var course_type = JSON.parse(response.message.course_type); $.each(course_type, function(x, y) { session_fields += '<p style="margin-left:32%">' + y.charAt(0).toUpperCase() + y.slice(1).toLowerCase() + '</p>'; }); time_fields += '<input type="hidden" name="available_type" value="timings">'; $.each(response.message.timings, function(vx, vy) { time_fields += '<div class="form-group col-sm-12 col-md-12 ">'; time_fields += '<input type="checkbox" name="course_type[]" value="' + vy.time_id + '" class="sub_domain_id"> ' + vy.from_time + ' To ' + vy.to_time; time_fields += '</div>'; }); } $('.sub_categories').html(fields); $('.session_type').html(session_fields); $('.sub_timings').html(time_fields); $("#approval_subjects").modal("show"); } else { toastr["error"](response.message); } } }); } $('#approve_subjects').submit(function(e) { e.preventDefault(); formdata = new FormData($(this)[0]); var sub_domain = $('input[name="sub_domain_id[]"]:checked').map(function(_, el) { return $(el).val(); }).get(); var time_id = $('input[name="course_type[]"]:checked').map(function(_, el) { return $(el).val(); }).get(); // var favailable_type = $('input[name="favailable_type"]:checked').map(function(_, el) { // return $(el).val(); // }).get(); if (sub_domain != "") { if (time_id != "") { // if(favailable_type != "") // { swal({ title: "Are you sure?", text: "Do You Want to Approve!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, approve it!", cancelButtonText: "No, cancel plz!", closeOnConfirm: false, closeOnCancel: false }, function(isConfirm) { if (isConfirm) { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); $(".submit").text("Approving.."); $.ajax({ type: 'post', url: '<?php echo site_url("approve_request") ?>', data: formdata, contentType: false, processData: false, success: function(response) { response = jQuery.parseJSON(response); console.log(response); if (response.result == 1) { $("#list2").setGridParam({ datatype: 'json', page: 1 }).trigger('reloadGrid'); $("#approval_subjects").modal("hide"); //toastr["success"](response.message); swal(response.message); $(".submit").text("Approve"); $(".submit").removeAttr('disabled'); $('#approval_subjects')[0].reset(); } else { $("#approval_subjects").modal("hide"); //toastr["error"](response.message); swal(response.message); $(".submit").text("Approve"); $(".submit").removeAttr('disabled'); } } }); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); // } // else // { // toastr["error"]('Please select available type'); // } } else { toastr["error"]('Please select timings'); } } else { toastr["error"]('Please select subject'); } }); function fun_return(mapping_id, login_id) { var type = "post"; swal({ title: "Are you sure?", text: "Do You Want to Return!", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", confirmButtonText: "Yes, Return it!", cancelButtonText: "No, cancel plz!", closeOnConfirm: false, closeOnCancel: false }, function(isConfirm) { if (isConfirm) { $('.faculty_id').val(mapping_id); $('.mapping_id').val(login_id); $(".sweet-alert").hide(); $(".sweet-overlay").hide(); $("#return").val("Returning.."); $("#myModal").modal("show"); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } $('#add_comment').submit(function(e) { e.preventDefault(); formdata = new FormData($(this)[0]); $(".return_submit").attr('disabled', 'disabled'); $(".return_submit").text("Submitting..."); $.ajax({ type: 'post', url: '<?php echo site_url("returned_request_comment") ?>', data: formdata, contentType: false, processData: false, success: function(response) { // response = jQuery.parseJSON(response); console.log(response); if (response.result == 1) { $("#myModal").modal("hide"); toastr["success"](response.message); $('.comment_form')[0].reset(); $(".return_submit").text("Submit"); $(".return_submit").removeAttr('disabled'); $("#list2").setGridParam({ datatype: 'json', page: 1 }).trigger('reloadGrid'); } else { $("#myModal").modal("hide"); toastr["error"](response.message); $(".return_submit").text("Submit"); $(".return_submit").removeAttr('disabled'); } } }); }); </script> <?php echo view('includes/admin_footer') ?> <style type="text/css"> #pager2_left { display: none !important; } #pager2_center { padding-left: 350px !important; } .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: 43%; margin-top: -7px !important; } .ui-jqdialog-content td.navButton { padding-top: 12px !important; } .ui-jqgrid .ui-jqgrid-titlebar { height: 27px !important; /*background:#1e7ad7 !important;*/ color: white !important; } .ui-jqgrid-bdiv { height: auto !important; } .ui-widget-overlay { z-index: 0 !important; } .ui-jqgrid-hdiv ui-state-default { 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; } #jaytab { overflow-x: scroll; } @media only screen and (min-width:320px) and (max-width:640px) { #jaytab { width: auto !important; overflow-x: scroll !important; } .ui-jqgrid ui-widget ui-widget-content ui-corner-all { width: 900px !important; } .ui-jqgrid-view { width: 900px !important; } .ui-jqgrid-hdiv { width: 900px !important; } .ui-jqgrid-htable { width: 900px !important; } .ui-jqgrid-bdiv { width: 900px !important; } #list2 { width: 900px !important; } #pager2 { width: 900px !important; } .timings { text-align: center; } .ui-jqgrid { width: 100% !important; } } @media only screen and (min-width:641px) and (max-width:991px) { #jaytab { width: auto !important; overflow-x: scroll !important; } .ui-jqgrid ui-widget ui-widget-content ui-corner-all { width: 900px !important; } .ui-jqgrid-view { width: 900px !important; } .ui-jqgrid-hdiv { width: 900px !important; } .ui-jqgrid-htable { width: 900px !important; } .ui-jqgrid-bdiv { width: 900px !important; } #list2 { width: 900px !important; } #pager2 { width: 900px !important; } .ui-jqgrid { width: 100% !important; } } @media only screen and (min-width:992px) and (max-width:1258px) { #jaytab { width: auto !important; overflow-x: scroll !important; } .ui-jqgrid ui-widget ui-widget-content ui-corner-all { width: 900px !important; } .ui-jqgrid-view { width: 900px !important; } .ui-jqgrid-hdiv { width: 900px !important; } .ui-jqgrid-htable { width: 900px !important; } .ui-jqgrid-bdiv { width: 900px !important; } #list2 { width: 900px !important; } #pager2 { width: 900px !important; } .ui-jqgrid { width: 100% !important; } } </style>