EVOLUTION-NINJA
Edit File: admin_material_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" 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'); ?>"/>--> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('public/assets/jqgrid/css/ui.jqgrid-bootstrap.css'); ?>" /> <link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url('public/assets/jqgrid/css/ui.jqgrid-bootstrap-ui.css'); ?>" /> <link rel="stylesheet" href="<?php echo base_url('public/assets/datatables/jquery.dataTables.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> <script src="<?php echo base_url('public/assets/sweet_alert/sweet-alert.js'); ?>"></script> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <!-- Content Header (Page header) --> <section class="content-header"> <h1 style="padding-bottom:10px;border-bottom:2px dashed #468662;margin-bottom:20px; font-weight: bold;"> ADMIN CONTENTS LIST <small></small> </h1> </section> <!-- Main content --> <!-- Button trigger modal --> <section class="content"> <a href="javascript:history.back()" class="btn btn-primary" style="float: right;">Back</a> <div id="" class="table-responsive"> <div id="jaytab" 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> </section> <div class="modal fade" id="session_return" 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="session_return_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="training_plan_id" class="training_plan_id"> <textarea row="3" cols="40" name="return_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 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="editmyModal" 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="login_id" value="<?= session()->get('login_id') ?>" /> <input type="hidden" class="material_id_pk" name="material_id" value="" /> <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> </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> <!-- Modal --> <div class="modal fade" id="uploads_modal" role="dialog"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close close_material" data-dismiss="modal">×</button> <h4 class="modal-title">Content Uploads</h4> </div> <div class="modal-body"> <ul class="nav nav-pills" style="background:white; padding:15px;"> <li class="active"><a data-toggle="pill" href="#video">Video File</a></li> <li><a data-toggle="pill" href="#pdf">PDF File</a></li> <li><a data-toggle="pill" href="#images">Images</a></li> <!--<li><a data-toggle="pill" href="#questions" onclick="CallQuestionGrid()">Question Bank</a></li>--> </ul> <div class="tab-content" style="background:white; padding:15px;"> <div id="video" class="tab-pane fade in active"> <div class="row" id="video_uploads_div"> </div><!-- row ----> </div><!-- video ----> <div id="pdf" class="tab-pane fade"> <div class="row" id="pdf_uploads_div"> </div><!-- row ----> </div><!-- pdf ----> <div id="images" class="tab-pane fade"> <div class="row" id="image_uploads_div"> </div><!-- row ----> </div><!-- images ----> <input type="hidden" id="faculty_id" /> <input type="hidden" id="chapter_id" /> <!--<div id="questions" class="tab-pane fade"> <div class="row" id="question_uploads_div"> <div id="" class="table-responsive"> <div id ="questiontab" style="margin-top:3%" class="grid table-responsive"> <table id="list3"></table> <div id="pager3"></div> <div id="dialogSelectRow" title="Warning" style="display:none"> <p>Please select row</p> </div> </div> </div> </div><!-- row ----> </div><!-- images ----> </div> </div> </div> </div> <!-- Modal --> <div class="modal fade" id="sessions_modal" role="dialog"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Session Details</h4> </div> <div class="modal-body"> <div class="row table-responsive" style="margin:0 !important;"> <table class="table table-bordered list_table" border="1"> <thead> <tr> <th scope="col">#</th> <th scope="col">Subject</th> <th scope="col">Chapters</th> <th scope="col">Session Time</th> <th scope="col">Status</th> </tr> </thead> <tbody id="course_tbody"> </tbody> </table> </div><!-- row1 ----> </div> </div> </div> </div> </div> <!--- col-sm-8 --> <!-- Modal --> <div id="questions_data" class="modal fade" role="dialog"> <div class="modal-dialog" style="width: 80%; margin: 30px auto;"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title">Questions</h4> </div> <div class="modal-body"> <input type="hidden" id="faculty_id1" /> <input type="hidden" id="chapter_id1" /> <div class="table1 table-responsive"> <table class="table table-striped table-hover list_table" id="myTable"> <thead> <tr> <th>SI</th> <th>Chapter Name</th> <th>Question</th> <th>Number Of Options</th> <th>Option 1</th> <th>Option 2</th> <th>Option 3</th> <th>Option 4</th> <th>Correct Answer</th> <th>Explanation</th> </tr> </thead> <tbody id="table_body"> </tbody> </table> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default close_questions" data-dismiss="modal">Close</button> </div> </div> </div> </div> <div class="modal fade" id="uploads_modal" role="dialog"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close close_material" data-dismiss="modal">×</button> <h4 class="modal-title">Content Uploads</h4> </div> <div class="modal-body"> <ul class="nav nav-pills" style="background:white; padding:15px;"> <li class="active"><a data-toggle="pill" href="#video">Video File</a></li> <li><a data-toggle="pill" href="#pdf">PDF File</a></li> <li><a data-toggle="pill" href="#images">Images</a></li> <!--<li><a data-toggle="pill" href="#questions" onclick="CallQuestionGrid()">Question Bank</a></li>--> </ul> <div class="tab-content" style="background:white; padding:15px;"> <div id="video" class="tab-pane fade in active"> <div class="row" id="video_uploads_div"> </div><!-- row ----> </div><!-- video ----> <div id="pdf" class="tab-pane fade"> <div class="row" id="pdf_uploads_div"> </div><!-- row ----> </div><!-- pdf ----> <div id="images" class="tab-pane fade"> <div class="row" id="image_uploads_div"> </div><!-- row ----> </div><!-- images ----> <input type="hidden" id="faculty_id" /> <input type="hidden" id="chapter_id" /> <!--<div id="questions" class="tab-pane fade"> <div class="row" id="question_uploads_div"> <div id="" class="table-responsive"> <div id ="questiontab" style="margin-top:3%" class="grid table-responsive"> <table id="list3"></table> <div id="pager3"></div> <div id="dialogSelectRow" title="Warning" style="display:none"> <p>Please select row</p> </div> </div> </div> </div><!-- row ----> </div><!-- images ----> </div> </div> </div> </div> <script src="<?php echo base_url('public/assets/datatables/jquery.dataTables.js'); ?>"></script> <script type="text/javascript"> $(document).ready(function() { // var domain_id = $('#edit_category_list').val(); // $('#edit_category_list option[value!="'+domain_id+'"]').remove(); //grid CallGrid(); function CallGrid(access_rights_global, access_result_global) { jQuery("#list2").jqGrid({ url: "<?php echo site_url('get_admin_added_contents') ?>", 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: 200 }, { name: 'sub_domain', index: 'sub_domain', editable: false, width: 160 }, { name: 'chapter_name', index: 'chapter_name', editable: false, width: 150 }, // {name:'username',index:'username',editable:false, width:100}, { name: 'question', search: false, index: 'question', align: "center", editable: false, editrules: { required: true }, width: 150, 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, autoencode: 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', 'Topic', 'Added Date', 'Action'], colModel: [{ name: 'material_id', index: 'material_id', width: 50, hidden: true, editable: false, key: true }, { name: 'topic_name', index: 'topic_name', editable: false, width: 50 }, { name: "created_at", index: "created_at", width: 40 }, { name: '', index: '', search: false, width: 20, editable: false, formatter: function(cellvalue, options, rowObject) { var retVal = ""; var retVal = '<a data-toggle="tooltip" data-original-title="View" title="View" class="" onclick="call_uploads(' + rowObject.material_id + ',' + rowObject.created_by + ',' + rowObject.chapter_id + ')"><span class="glyphicon glyphicon-search"></span></a> <a data-toggle="tooltip" title="Edit" class="edit" onclick="edit(' + rowObject.material_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; } }, ], 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 edit(id) { var type = "post"; $(".material_id_pk").val(id); $.ajax({ type: type, url: "<?php echo site_url('New_Project/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(); } } } }); $("#editmyModal").modal('show'); } $('.ui-sghref').click(function(e) { toggleSubgrid(); }) 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(); } } }); } function subjects(domain_id) { $.ajax({ url: "<?php echo site_url('get_domain_subdomain_admin') ?>", 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 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); } } }); } function topics(id) { var login_id = '<?= session()->get('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); } } }); } $('#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"]("Updated Successfully"); $("#list2").setGridParam({ datatype: 'json', page: 1 }).trigger('reloadGrid'); $('#update_materials')[0].reset(); $("#editmyModal").modal('hide'); } else { toastr["error"](response.message); $(".update_submit").removeAttr('disabled'); } } }); }); function toggleSubgrid() { alert(); if ($('#subgrid_id td').hasClass('sgexpanded')) { $('.ui-icon-minus').trigger('click'); } else if ($('#subgrid_id td').hasClass('sgcollapsed')) { $('.ui-icon-plus').trigger('click'); } } function call_uploads(material_id, faculty_id, chapter_id) { //CallQuestionGrid(faculty_id,chapter_id); var material_id = material_id; //$('#questions').empty(); $("#faculty_id").val(faculty_id); $("#chapter_id").val(chapter_id); $.ajax({ type: 'post', url: "<?php echo site_url('get_where_material_details_admin'); ?>", data: { 'material_id': material_id }, success: function(response) { // response = jQuery.parseJSON(response); console.log(response); if (response.result == 1) { var video_fields = ''; var pdf_fields = ''; var image_fields = ''; if (response.message.video != "") { var videos = jQuery.parseJSON(response.message.video); $.each(videos, function(key, val) { video_fields += '<div class="col-sm-4 video">'; //video_fields += '<iframe class="embed-responsive-item" width="100%" height="250" src="<?php echo base_url('subject_videos'); ?>/'+val+'" allowfullscreen></iframe>'; video_fields += '<video width="320" width="100%" height="250" height="240" controls>'; video_fields += '<source src="<?php echo base_url('subject_videos'); ?>/' + val + '" type="video/mp4">'; video_fields += '</video>'; video_fields += '<br>'; video_fields += '<p style="text-align:center"><b>Content Name:</b> ' + val.substr(10) + '<br><b>Subject Name:</b> ' + response.message.sub_domain + '<br><b>Added Date:</b>' + response.created_at; video_fields += '</div>'; }); } else { video_fields += '<div class="col-sm-4 video">'; video_fields += '<p>No video available</p>'; video_fields += '</div>'; } if (response.message.pdf != "") { var pdf = jQuery.parseJSON(response.message.pdf); $.each(pdf, function(key, val) { pdf_fields += '<div class="col-sm-4 pdf_file">'; pdf_fields += '<a href="<?php echo base_url('subject_pdf'); ?>/' + val + '" target="_blank" ><img src="<?php echo base_url('public/assets/images/pdf_file.png'); ?>" class="img-responsive center-block"></a>'; pdf_fields += '<p style="text-align:center"><b>Content Name:</b> ' + val.substr(10) + '<br><b>Subject Name:</b> ' + response.message.sub_domain + '<br><b>Added Date:</b>' + response.created_at; pdf_fields += '</div>'; }); } else { pdf_fields += '<div class="col-sm-4 video">'; pdf_fields += '<p>No pdf available</p>'; pdf_fields += '</div>'; } if (response.message.image != "") { var image = jQuery.parseJSON(response.message.image); $.each(image, function(key, val) { image_fields += '<div class="col-sm-4 images_file">'; image_fields += '<a href="<?php echo base_url('subject_images'); ?>/' + val + '" target="_blank" ><img src="<?php echo base_url('subject_images'); ?>/' + val + '" class="img-responsive center-block"></a>'; image_fields += '<p style="text-align:center"><b>Content Name:</b> ' + val.substr(10) + '<br><b>Subject Name:</b> ' + response.message.sub_domain + '<br><b>Added Date:</b>' + response.created_at; image_fields += '</div>'; }); } else { image_fields += '<div class="col-sm-4 video">'; image_fields += '<p>No image available</p>'; image_fields += '</div>'; } $("#video_uploads_div").html(video_fields); $("#pdf_uploads_div").html(pdf_fields); $("#image_uploads_div").html(image_fields); $("#uploads_modal").modal('show'); } else { } } }); } function CallQuestionGrid(material_id, faculty_id, chapter_id) { var faculty_ids = faculty_id; var chapter_ids = chapter_id; /* $("#faculty_id1").val(faculty_id); $("#chapter_id1").val(chapter_id); */ //var faculty_id=$("#faculty_id").val(); //var chapter_id=$("#chapter_id").val(); $.ajax({ type: "POST", url: "<?php echo site_url('question_details') ?>", data: { 'id': faculty_ids, 'chapter_id': chapter_ids }, success: function(response) { // var res = jQuery.parseJSON(response); console.log(response); var content = ''; if (res.result == 1) { var i = 1; $.each(res.data_result, function(idx, vx) { content += '<tr>'; content += '<td>' + i + '</td>'; content += '<td>' + vx.chapter_name + '</td>'; content += '<td>' + vx.questions + '</td>'; content += '<td>' + vx.no_of_options + '</td>'; content += '<td>' + vx.ans1 + '</td>'; content += '<td>' + vx.ans2 + '</td>'; content += '<td>' + vx.ans3 + '</td>'; content += '<td>' + vx.ans4 + '</td>'; content += '<td>' + vx.ans + '</td>'; content += '<td>' + vx.explanation + '</td>'; content += '</tr>'; $("#table_body").html(content); i++; }); $("#questions_data").modal('show'); $('#myTable').DataTable().destroy(); $('#myTable').DataTable({ "scrollX": true }); } else if (res.result == 0) { //alert("Date not found"); $("#table_body").empty(); } } }); } function Delete(id) { var login_id = '<?= session()->get('login_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_admin_content'); ?>", data: { 'material_id': id, 'login_id': login_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 fun_approve(id, faculty_id) { $('#sub_approve' + id).text('Approving..') var type = "post"; 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(); $("#sub_approve" + id).val("Approving.."); $.ajax({ type: type, url: "<?php echo site_url('approve_materials'); ?>", data: { 'id': id, 'faculty_id': faculty_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); } } }); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } function fun_return(id, faculty_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(id); $('.faculty_ids').val(faculty_id); $(".sweet-alert").hide(); $(".sweet-overlay").hide(); $("#myModal").modal("show"); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } function call_sessions(id, login_id) { $.ajax({ type: 'post', url: "<?php echo site_url('get_where_subject_syllabus'); ?>", data: { 'sub_domain_id': id, 'login_id': login_id }, success: function(response) { // response = jQuery.parseJSON(response); console.log(response); if (response.result == 1) { var table_fields = ""; var i = 1; var sr_no = 'Session ' + i; $.each(response.message, function(key, val) { var training_plan_id = val.training_plan_id; table_fields += '<tr>'; table_fields += '<th scope="row">' + sr_no + '</th>'; table_fields += '<td>' + val.sub_domain + '</td>'; table_fields += '<td>' + val.chapters + '</td>'; table_fields += '<td>' + val.session_time + ' Hours</td>'; if (val.approval_status == 'NOT_APPROVED') { if (val.return_status == 'NOT_RETURNED') { table_fields += '<td><button class="approve' + training_plan_id + '" onclick="fun_approve_training_plan(' + training_plan_id + ');">Approve</button><b> / </b><button class="return' + training_plan_id + '" onclick="fun_return_training_plan(' + training_plan_id + ');">Return</button></td>'; } else { table_fields += '<td><button class="approve' + training_plan_id + '" onclick="fun_approve_training_plan(' + training_plan_id + ');">Approve</button><b> / RETURNED</b></td>'; } } else { table_fields += '<td><b>APPROVED / </b><button class="return' + training_plan_id + '" onclick="fun_return_training_plan(' + training_plan_id + ');">Return</button></td>'; } table_fields += '</tr>'; i = i + 1; sr_no = 'Session ' + i; }); $("#course_tbody").html(table_fields); $("#sessions_modal").modal('show'); } else { $("#course_tbody").empty(); $("#sessions_modal").modal('show'); } } }); } $('#add_comment').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("returned_material_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(); $(".submit").text("Submit"); $(".submit").removeAttr('disabled'); $("#list2").setGridParam({ datatype: 'json', page: 1 }).trigger('reloadGrid'); } else { $("#myModal").modal("hide"); toastr["error"](response.message); $(".submit").text("Submit"); $(".submit").removeAttr('disabled'); } } }); }); function question_approve(rowId) { var id = rowId.closest('tr').attr('id'); //alert(id); var type = "post"; 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(); $("#sub_approve" + id).val("Approving.."); $.ajax({ type: type, url: "<?php echo site_url('approve_questions'); ?>", data: { 'id': id }, success: function(response) { // response = jQuery.parseJSON(response); console.log(response); if (response.result == 1) { toastr["success"](response.message); $("#list3").setGridParam({ datatype: 'json', page: 1 }).trigger('reloadGrid'); } else { toastr["error"](response.message); } } }); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } function question_disapprove(rowId) { var id = rowId.closest('tr').attr('id'); //alert(id); var type = "post"; swal({ title: "Are you sure?", text: "Do You Want to Dispprove!", 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(); $("#sub_approve" + id).val("Approving.."); $.ajax({ type: type, url: "<?php echo site_url('disapprove_questions'); ?>", data: { 'id': id }, success: function(response) { // response = jQuery.parseJSON(response); console.log(response); if (response.result == 1) { toastr["success"](response.message); $("#list3").setGridParam({ datatype: 'json', page: 1 }).trigger('reloadGrid'); } else { toastr["error"](response.message); } } }); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } function fun_approve_training_plan(id) { 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) { $('.approve' + id + '').text('Approving..'); $(".sweet-alert").hide(); $(".sweet-overlay").hide(); $.ajax({ type: 'post', url: "<?php echo site_url('approve_training_plan'); ?>", data: { 'training_plan_id': id }, success: function(response) { // response = jQuery.parseJSON(response); console.log(response); if (response.result == 1) { $("#sessions_modal").modal('hide'); $('.approve' + id + '').text('Approve'); toastr["success"](response.message); $("#list2").setGridParam({ datatype: 'json', page: 1 }).trigger('reloadGrid'); } else { $("#sessions_modal").modal('hide'); $('.approve' + id + '').text('Approve'); toastr["error"](response.message); } } }); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } function fun_return_training_plan(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) { $('.training_plan_id').val(id); $(".sweet-alert").hide(); $(".sweet-overlay").hide(); $("#sessions_modal").modal('hide'); $("#session_return").modal("show"); } else { $(".sweet-alert").hide(); $(".sweet-overlay").hide(); } }); } $('#session_return_comment').submit(function (e) { e.preventDefault(); var formdata = new FormData($(this)[0]); $(".submit").attr('disabled', 'disabled'); $(".submit").text("Submitting..."); $.ajax({ type: 'post', url: '<?= site_url("return_training_plan") ?>', // Use the site_url function data: formdata, contentType: false, processData: false, success: function (response) { console.log(response); if (response.result == 1) { $("#session_return").modal("hide"); $("#sessions_modal").modal('hide'); toastr["success"](response.message); $('.session_return_comment')[0].reset(); $(".submit").text("Submit"); $(".submit").removeAttr('disabled'); // You may reload the page or update the content as needed. } else { $("#session_return").modal("hide"); $("#sessions_modal").modal('hide'); toastr["error"](response.message); $(".submit").text("Submit"); $(".submit").removeAttr('disabled'); } } }); }); </script> <?php echo view('includes/admin_footer') ?> <style type="text/css"> .content-wrapper{ background-image: url(public/assets/website_assets/images/banner.png); } #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; } @media only screen and (min-width:320px) and (max-width:640px) { #jaytab { width: 1100px !important; overflow-x: scroll !important; } .ui-jqgrid-htable { width: 900px !important; } .ui-jqgrid-bdiv { width: 900px !important; } #list2 { width: 900px !important; } #pager2 { width: 900px !important; } .subgrid-data { width: 1100px !important; overflow-x: scroll !important; } .table-responsive { border: transparent; } .ui-jqgrid { background-color: #ecf0f5; border: 1px solid #ecf0f5 !important; border-radius: 0px !important; } #myTable { overflow-x: scroll; width: 1200px; } } @media only screen and (min-width:641px) and (max-width:991px) { #jaytab { width: 1100px !important; overflow-x: scroll !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; } .subgrid-data { width: 1100px !important; overflow-x: scroll !important; } .table-responsive { border: transparent; } .ui-jqgrid { background-color: #ecf0f5; border: 1px solid #ecf0f5 !important; border-radius: 0px !important; } } /*@media only screen and (min-width:992px) and (max-width:1258px) { #jaytab { width: 1100px !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; } .subgrid-data { width: 1100px !important; overflow-x: scroll !important; } .table-responsive { border: transparent; } .ui-jqgrid { background-color: #ecf0f5; border: 1px solid #ecf0f5 !important; border-radius: 0px !important; } }*/ .table-bordered>thead>tr>th, .table-bordered>tbody>tr>td, .table-bordered>tbody>tr>th { border: 1px solid #555; } .table>thead:first-child>tr:first-child>th { border-top: 1px solid #555; } table.table-bordered th:last-child, table.table-bordered td:last-child { border-right: 1px solid #555; } </style>