EVOLUTION-NINJA
Edit File: materials.php
<?php echo view('includes/faculty_header'); ?> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('public/assets/css/jquery-ui.css'); ?>" /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('public/assets/jqgrid/css/ui.jqgrid.css'); ?>" /> <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> <div id="page-wrapper"> <!-- /.row --> <!-- /.row --> <div class="row my_header"> <h3 style="padding-bottom:10px;border-bottom:2px dashed #468662;margin-bottom:20px; font-weight: bold;">ADD CONTENT</h3> <a href="javascript:history.back()" class="btn btn-primary" style="float:right; margin-right: 50px;">Back</a> <div class="col-md-2"></div> <div class="col-md-8"> <form class="form-horizontal" id="add_materials" enctype="multipart/form-data"> <input type="hidden" name="faculty_institution_id" value="<?php echo session()->get('faculty_institution_id') ?>"> <div class="form-group"> <label class="control-label col-sm-4">Category</label> <div class="col-sm-8" name="subject"> <select class="form-control" name="domain_id" id="category_list" required> <option value="">Category</option> <?php if ($domain) { foreach ($domain as $val) { ?> <option value="<?php echo $val->domain_id ?>"><?php echo $val->domain_name; ?></option> <?php } } ?> </select> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Subject</label> <div class="col-sm-8" name="subject"> <!-- <select class="form-control" name="sub_domain_id" id="sub_domains" required> <option value="">Subject</option> <?php //f ($sub_domain) { //foreach ($sub_domain as $val) { ?> <option value="<?php //echo $val->sub_domain_id ?>"><?php //echo $val->sub_domain ?></option> <?php //} //} ?> </select> --> <select class="form-control" name="sub_domain_id" id="sub_domains" required> <option value="">Subject</option> <?php if (isset($sub_domain) && is_array($sub_domain)) { foreach ($sub_domain as $val) { ?> <option value="<?php echo $val->sub_domain_id ?>"><?php echo $val->sub_domain ?></option> <?php } } ?> </select> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Chapter</label> <div class="col-sm-8"> <select class="form-control" name="chapter" id="chapter" onfocus='this.size=8;' onblur='this.size=1;' onchange='this.size=1; this.blur();' required> <option value="">Chapter</option> </select> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Topics</label> <div class="col-sm-8"> <select class="form-control" name="topic_id" id="topics" required> <option value="">Topic</option> </select> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Video</label> <div class="col-sm-8"> <input name="upvideo[]" multiple id="" accept="video/*" type="file"> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Image</label> <div class="col-sm-8"> <input name="upimg[]" multiple id="" accept="image/*" type="file"> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Pdf</label> <div class="col-sm-8"> <input name="uppdf[]" multiple id="" accept=".pdf" type="file"> </div> </div> <div class="form-group" style="padding-top:10px;"> <!-- <div class="col-sm-offset-4 col-sm-8"> <button type="submit" class="btn btn-primary submit">Submit</button> </div> --> <div class=" row view_faculty" style="margin-left:30%;"> <div class="col-sm-6"> <center><button type="submit" class="btn btn-primary submit">Submit</button></center> </div> <div class="col-sm-6"> <button type="button" id="cancel" class="btn btn-danger center-block cancel cancel_1">Cancel</button> </div> </div> </div> </form> </div> <div class="col-md-2"></div> </div> <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> <!-- Modal --> <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">Update Content</h4> </div> <div class="modal-body"> <form class="form-horizontal" id="update_materials"> <input type="hidden" class="material_id_pk" name="material_id" value="" /> <input type="hidden" class="chapter_id_pk" name="chapter_id" value="" /> <input type="hidden" name="login_id" value="<?php echo session()->get('faculty_login_id') ?>"> <div class="form-group"> <label class="control-label col-sm-4">Category</label> <div class="col-sm-8" name="subject"> <select class="form-control" name="domain_id" id="edit_category_list" required> <?php if ($domain) { foreach ($domain as $val) { ?> <option value="<?php echo $val->domain_id ?>"><?php echo $val->domain_name; ?></option> <?php } } ?> </select> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Subject</label> <div class="col-sm-8" name="subject"> <!-- <select class="form-control sub_domain_list" id="sub_domain_list" name="sub_domain_id" required> <option value="">Subject</option> <?php //if ($sub_domain) { //foreach ($sub_domain as $val) { ?> <option value="<?php //echo $val->sub_domain_id ?>"><?php //echo $val->sub_domain ?></option> <?php //} // } ?> </select> --> <select class="form-control sub_domain_list" id="sub_domain_list" name="sub_domain_id" required> <option value="">Subject</option> <?php if (isset($sub_domain) && is_array($sub_domain)) { foreach ($sub_domain as $val) { ?> <option value="<?php echo $val->sub_domain_id ?>"><?php echo $val->sub_domain ?></option> <?php } } ?> </select> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Chapter</label> <div class="col-sm-8"> <select class="form-control" name="chapter" id="modal_chapter" required> <option value="">Chapter</option> </select> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Topics</label> <div class="col-sm-8"> <select class="form-control edit_topics" name="topic_id" id="edit_topics" required> <option value="">Topic</option> </select> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Video</label> <div class="col-sm-8"> <input name="upvideo[]" multiple id="" accept="video/*" type="file"> </div> <div class="col-sm-8 demo_video"> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Image</label> <div class="col-sm-8"> <input name="upimg[]" multiple id="" accept="image/*" type="file"> </div> <div class="col-sm-8 images"> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Pdf</label> <div class="col-sm-8"> <input name="uppdf[]" multiple id="" accept=".pdf" type="file"> </div> <div class="col-sm-8 pdf"> </div> </div> <div class="form-group" style="padding-top:10px;"> <div class="col-sm-offset-4 col-sm-8"> <button type="submit" class="btn btn-primary submit update_submit">Update</button> </div> </div> </form> </div> </div> </div> </div> <!-- /.row --> </div> <!-- /#page-wrapper --> <!-- /#wrapper --> <!-- jQuery --> <script type="text/javascript"> $(document).ready(function() { // var domain_id = $('#edit_category_list').val(); // $('#edit_category_list option[value!="'+domain_id+'"]').remove(); $('#add_materials').submit(function(e) { e.preventDefault(); formdata = new FormData($(this)[0]); $(".submit").attr('disabled', 'disabled'); $(".submit").text("Submitting..."); $.ajax({ type: 'post', url: '<?php echo site_url('add_material') ?>', data: formdata, contentType: false, processData: false, success: function(response) { response=jQuery.parseJSON(response); console.log(response); if (response.result == 1) { $("#loading").hide(); $(".submit").text("Submit"); $(".submit").removeAttr('disabled'); toastr["success"]("Added Successfully"); $("#list2").setGridParam({ datatype: 'json', page: 1 }).trigger('reloadGrid'); $('#add_materials')[0].reset(); } else { $(".submit").text("Submit"); $("#loading").hide(); toastr["error"](response.message); $(".submit").removeAttr('disabled'); } } }); }); //grid CallGrid(); function CallGrid(access_rights_global, access_result_global) { jQuery("#list2").jqGrid({ url: "<?php echo site_url('get_material_details') ?>", mtype: "get", datatype: "json", colNames: ['ID', 'sub_domain_id', 'chapter_id', 'created_by', 'Category', 'Subject', 'Chapter', 'Questions'], colModel: [{ name: 'material_id', index: 'material_id', width: 5, hidden: true, editable: false, key: true }, { name: 'sub_domain_id', index: 'sub_domain_id', width: 5, hidden: true, editable: false }, { name: 'chapter_id', index: 'chapter_id', width: 5, hidden: true, editable: false }, { name: 'created_by', index: 'created_by', width: 5, hidden: true, editable: false }, { name: 'domain_name', index: 'domain_name', editable: false, width: 300 }, { name: 'sub_domain', index: 'sub_domain', editable: false, width: 300 }, { name: 'chapter_name', index: 'chapter_name', editable: false, width: 400 }, // { // name: 'username', // index: 'username', // editable: false, // width: 100 // }, { name: 'question', search: false, index: 'question', align: "center", editable: false, editrules: { required: true }, width: 200, cellattr: function(cellvalue, options, rowObject) { return ' onclick="add_question(' + rowObject.material_id + ')" '; }, formatter: function(cellvalue, options, rowObject) { return "<input type='button' value='Add Question' \>"; } }, ], 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, caption: "Content List", subGrid: true, subGridRowExpanded: function(subgrid_id, row_id) { var sub_domain_ids = $('#list2').jqGrid('getCell', row_id, 'sub_domain_id'); var login_ids = $('#list2').jqGrid('getCell', row_id, 'created_by'); var chapter_id = $('#list2').jqGrid('getCell', row_id, 'chapter_id'); var subgrid_table_id; subgrid_table_id = subgrid_id + "_t"; jQuery("#" + subgrid_id).html("<table id='" + subgrid_table_id + "' class='scroll'></table>"); // CallQuestionGrid(row_id); jQuery("#" + subgrid_table_id).jqGrid({ url: "<?php echo site_url('get_topic_wise_materials'); ?>/" + login_ids + '/' + sub_domain_ids + '/' + chapter_id, datatype: "json", colNames: ['SI', 'Action', 'Topic', 'Added Date', 'Approval Status'], colModel: [{ name: 'material_id', index: 'material_id', align: 'center', width: 50, hidden: true, editable: false, key: true }, { name: '', index: '', search: false, width: 20, align: 'center', editable: false, formatter: function(cellvalue, options, rowObject) { var retVal = ""; var retVal = '<a data-toggle="tooltip" data-original-title="View" title="View" class="" href="<?php echo site_url('material-details'); ?>/' + rowObject.material_id + '"><span class="glyphicon glyphicon-search"></span></a> <a data-toggle="tooltip" title="Edit" class="edit" onclick="edit(' + rowObject.material_id + ',' + rowObject.chapter_id + ')" material_id="' + rowObject.material_id + '" href="javascript:void(0);"><span class="glyphicon glyphicon-edit"></span></a> <a data-toggle="tooltip" title="Delete" onclick="Delete(' + rowObject.material_id + ')"; class="delete" href="javascript:void(0);"><span class="glyphicon glyphicon-trash"></span></a>'; return retVal; } }, { name: 'topic_name', index: 'topic_name', align: 'center', editable: false, width: 50 }, { name: "created_at", index: "created_at", align: 'center', width: 40 }, { name: 'approval_status', index: 'approval_status', align: 'center', editable: false, width: 50 }, ], height: 'auto', autowidth: true, shrinkToFit: true, rowNum: 20, sortname: 'num', sortorder: "asc", pager: subgrid_table_id, loadonce: true, autoencode: true, }).navGrid('#' + subgrid_table_id + '', { edit: false, add: false, del: false, search: false }); } }); $("#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: false, refreshstate: "current" }, {}, {}, {}, { sopt: ['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'], closeOnEscape: true, multipleSearch: true, closeAfterSearch: true, closeAfterDelete: true, closeAfterEdit: true }, ); } }); function Delete(id) { var type = "post"; swal({ title: "Are you sure?", text: "You will not be able to recover this content !", 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_subject_material'); ?>", data: { 'material_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 { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } function edit(id, chapter_id) { var type = "post"; $(".material_id_pk").val(id); $(".chapter_id_pk").val(chapter_id); $.ajax({ type: type, url: "<?php echo site_url('single_material_details'); ?>", data: { 'material_id': id }, success: function(response) { // response=jQuery.parseJSON(response); console.log(response); if (response.result == 1) { $(".chapter").val(response.message.chapter_name); // $("#edit_category_list").val(response.message.domain_id); CallCategories(response.message.domain_id); subjects(response.message.domain_id); $(".sub_domain_list").val(response.message.sub_domain_id); if (response.message.approval_status == 'APPROVED') { $('.sub_domain_list option[value!="' + response.message.sub_domain_id + '"]').remove(); } chapter(response.message.sub_domain_id); $("#modal_chapter").val(response.message.chapter_id); $('#modal_chapter option[value!="' + response.message.chapter_id + '"]').remove(); topics(response.message.chapter_id); $('.edit_topics option[value!="' + response.message.topic_id + '"]').remove(); if (response.message.video) { var videos = jQuery.parseJSON(response.message.video); var retVal = ""; $.each(videos, function(key, val) { var video_name = val.slice(10); retVal += '<p><a href="<?php echo base_url('subject_videos'); ?>/' + val + '" target="_blank" >' + video_name + '</a></p>'; }); $('.demo_video').html(retVal); } else { $('.demo_video').empty(); } if (response.message.image) { var images = jQuery.parseJSON(response.message.image); var img_field = ""; $.each(images, function(key, val) { var img_name = val.slice(10); img_field += '<p><a href="<?php echo base_url('subject_images'); ?>/' + val + '" target="_blank" >' + img_name + '</a></p>'; }); $('.images').html(img_field); } else { $('.images').empty(); } if (response.message.pdf) { var pdfs = jQuery.parseJSON(response.message.pdf); var pdf_field = ""; $.each(pdfs, function(key, val) { var pdf_name = val.slice(10); pdf_field += '<p><a href="<?php echo base_url('subject_pdf'); ?>/' + val + '" target="_blank" >' + pdf_name + '</a></p>'; }); $('.pdf').html(pdf_field); } else { $('.pdf').empty(); } } } }); $("#myModal").modal('show'); } // CallCategories(); function CallCategories(domain_id) { var option = ''; $.ajax({ type: 'get', url: '<?php echo site_url('get_faculty_domains') ?>', success: function(response) { // response=jQuery.parseJSON(response); console.log(response); if (response.result == 1) { $.each(response.categories_list, function(key, val) { option += '<option value="' + val.domain_id + '">' + val.domain_name + '</option>'; }); $("#edit_category_list").html(option); $("#edit_category_list").val(domain_id); $('#edit_category_list option[value!="' + domain_id + '"]').remove(); } } }); } $('#update_materials').submit(function(e) { e.preventDefault(); formdata = new FormData($(this)[0]); $(".update_submit").attr('disabled', 'disabled'); $(".update_submit").text("Updating..."); $.ajax({ type: 'post', url: '<?php echo site_url('update_material') ?>', data: formdata, contentType: false, processData: false, success: function(response) { // response=jQuery.parseJSON(response); console.log(response); if (response.result == 1) { $(".update_submit").text("Submit"); $(".update_submit").removeAttr('disabled'); toastr["success"]("Added Successfully"); $("#list2").setGridParam({ datatype: 'json', page: 1 }).trigger('reloadGrid'); $('#update_materials')[0].reset(); $("#myModal").modal('hide'); } else { toastr["error"](response.message); $(".update_submit").removeAttr('disabled'); toastr["success"]("Added Successfully"); } } }); }); $("#sub_domains").change(function() { var sub_domain_id = $("#sub_domains").val(); $.ajax({ url: "<?php echo site_url('get_subject_chapters') ?>", type: "POST", data: { 'sub_domain_id': sub_domain_id }, async: false, success: function(response) { // response=jQuery.parseJSON(response); console.log(response); if (response.result == 1) { var options = ''; options += '<option value="">Select Chapter</option>'; $.each(response.message, function(idx, vx) { options += '<option value="' + vx.chapter_id + '">' + vx.chapter_name + '</option>'; }); $('#chapter').html(options); } else { var options = ''; options += '<option value="">Select Chapter</option>'; $('#chapter').html(options); } } }); }); $("#chapter").change(function() { var chapter_id = $("#chapter").val(); topics(chapter_id); }); function topics(id) { var login_id = '<?php echo session()->get('faculty_login_id') ?>'; $.ajax({ url: "<?php echo site_url('get_chapter_topics') ?>", type: "POST", data: { 'chapter_id': id, 'login_id': login_id }, async: false, success: function(response) { // response=jQuery.parseJSON(response); console.log(response); if (response.result == 1) { var options = ''; options += '<option value="">Select Topic</option>'; $.each(response.message, function(idx, vx) { options += '<option value="' + vx.topic_id + '">' + vx.topic_name + '</option>'; }); $('#topics').html(options); $('#edit_topics').html(options); } else { var options = ''; options += '<option value="">Select Topic</option>'; $('#topics').html(options); $('#edit_topics').html(options); } } }); } $("#sub_domain_list").change(function() { var sub_domain_id = $("#sub_domain_list").val(); chapter(sub_domain_id); }); function chapter(sub_domain_id) { $.ajax({ url: "<?php echo site_url('get_subject_chapters') ?>", type: "POST", data: { 'sub_domain_id': sub_domain_id }, async: false, success: function(response) { // response=jQuery.parseJSON(response); console.log(response); if (response.result == 1) { var options = ''; options += '<option value="">Select Chapter</option>'; $.each(response.message, function(idx, vx) { options += '<option value="' + vx.chapter_id + '">' + vx.chapter_name + '</option>'; }); $('#modal_chapter').html(options); } else { var options = ''; options += '<option value="">Select Chapter</option>'; $('#modal_chapter').html(options); } } }); } $("#category_list").change(function() { var domain_id = $("#category_list").val(); $.ajax({ url: "<?php echo site_url('get_domain_subdomain') ?>", type: "POST", data: { 'domain_id': domain_id }, async: false, success: function(response) { // response=jQuery.parseJSON(response); console.log(response); if (response.result == 1) { var options = ''; options += '<option value="">Select Category</option>'; $.each(response.message, function(idx, vx) { options += '<option value="' + vx.sub_domain_id + '">' + vx.sub_domain + '</option>'; }); $('#sub_domains').html(options); } else { var options = ''; options += '<option value="">Select Category</option>'; $('#sub_domains').html(options); } } }); }); $("#edit_category_list").change(function() { var domain_id = $("#edit_category_list").val(); subjects(domain_id); }); function subjects(domain_id) { $.ajax({ url: "<?php echo site_url('get_domain_subdomain') ?>", type: "POST", data: { 'domain_id': domain_id }, async: false, success: function(response) { // response=jQuery.parseJSON(response); console.log(response); if (response.result == 1) { var options = ''; options += '<option value="">Select Category</option>'; $.each(response.message, function(idx, vx) { options += '<option value="' + vx.sub_domain_id + '">' + vx.sub_domain + '</option>'; }); $('#sub_domain_list').html(options); } else { var options = ''; options += '<option value="">Select Category</option>'; $('#sub_domain_list').html(options); } } }); } function add_question(id) { //var id = rowId.closest('tr').attr('id'); window.location.href = "<?php echo site_url('add-question-bank'); ?>/" + id; } const cancelButton = document.getElementById("cancel"); // Add a click event listener to the cancel button cancelButton.addEventListener("click", function() { // Clear the form data document.forms[0].reset(); }); </script> <?php echo view('includes/faculty_footer'); ?> <style> #page-wrapper{ background-image: url(public/assets/website_assets/images/banner.png); background-size:cover; } #FrmGrid_list2 { width: 100% !important; } #add_materials{ margin-right: 25%; } .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-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: scroll ; } .ui-jqgrid-htable{ width: 100% !important; } #list2{ width: 100% !important; } */ #jaytab { width: auto !important; overflow-x: scroll !important; } @media only screen and (min-width:320px) and (max-width:640px) { #jaytab { width: auto !important; overflow-x: scroll !important; } } @media only screen and (min-width:641px) and (max-width:991px) { #jaytab { width: auto !important; overflow-x: scroll !important; } } @media only screen and (min-width:992px) and (max-width:1258px) { #jaytab { width: auto !important; overflow-x: scroll !important; } } </style>