EVOLUTION-NINJA
Edit File: edit_batch.php
<?php echo view('includes/admin_header.php') ?> <link rel="stylesheet" type="text/css" href="<?php echo base_url('public/assets/website_assets/css/timepicki.css'); ?>" /> <link rel="stylesheet" type="text/css" href="<?php echo base_url('public/assets/sumoselect/sumoselect.css'); ?>" /> <link href="<?php echo base_url('public/assets/css/jquery-ui.css'); ?>" rel="stylesheet"> <script type="text/javascript" src="<?php echo base_url('public/assets/sumoselect/jquery.sumoselect.min.js'); ?>"></script> <script src="<?php echo base_url('public/assets/js/jquery-ui.js'); ?>"></script> <script src="<?php echo base_url('public/assets/ckeditor/ckeditor.js'); ?>"></script> <script src="<?php echo base_url('public/assets/ckeditor/config.js'); ?>"></script> <script type="text/javascript" src="<?php echo base_url('public/assets/website_assets/js/timepicki.js'); ?>"></script> <!-- Content Wrapper. Contains page content --> <div class="content-wrapper"> <!-- Content Header (Page header) --> <section class="content-header"> <h1> Update Batch <small></small> </h1> </section> <!-- Main content --> <section class="content"> <a href="javascript:history.back()" class="btn btn-primary" style="float: right;margin-bottom:30px" ;>Back</a> <div class="middle_work"> <form class="form-horizontal course_form"> <input type="hidden" class="form-control col-sm-8" name="login_id" value="<?= session()->get('login_id') ?>"> <input type="hidden" class="form-control col-sm-8" name="user_type_id" value="<?= session()->get('user_type_id') ?>"> <input type="hidden" class="form-control batch_id" name="batch_id" required> <div class="row"> <div class="col-sm-7"> <div class="form-group"> <label class="control-label col-sm-4">Course Type</label> <div class="col-sm-8"> <input class="course_type" onclick="selected_course_type('Live');" style="width: 21% !important;margin-top: 10px;" type="radio" value="Live" name="course_type">Live</label> <input class="course_type" onclick="selected_course_type('Recorded');" style="width: 21% !important;margin-top: 10px;" type="radio" value="Recorded" name="course_type">Recorded</label> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Select Category</label> <div class="col-sm-8"> <select class="form-control" id="catagory" name="domain_id" required> <option value="">Select 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 sub_cate_div1"> <label class="control-label col-sm-4">Select Sub Category</label> <div class="col-sm-8 "> --> <!-- <input type="text" class="form-control sub_domain_ids" name="sub_domain_ids"> --> <!-- <select class="form-control sub_domain_ids" id="sub_domain_ids" name="sub_domain_ids"> <option value="">Select Sub Category</option> <?php if ($sub_domain) { foreach ($sub_domain as $val) { ?> <?php if ($batch) { foreach ($batch as $values) { ?> <option <?php if ($values->sub_domain_id == $val->sub_domain_id) { echo 'selected="selected"'; } ?> value="<?php echo $val->sub_domain_id; ?>"><?php echo $val->sub_domain; ?></option> <?php } } } } ?> </select> </div> </div> --> <div class="form-group sub_cate_div"> <label class="control-label col-sm-4">Select Sub Category</label> <div class="col-sm-8 "> <!-- <select class="form-control sub_category_list test" id="sub_domain_id" name="sub_domain_id" required> --> <select class="form-control sub_category_list test" id="sub_domain_id" name="sub_domain_id" required> <option value="" selected>Select a sub category</option> </select> </div> </div> <div class="form-group faculty_name1"> <label class="control-label col-sm-4">Select Faculty</label> <div class="col-sm-8 "> <select class="form-control faculty" id="faculty_names" name="faculty_names"> <option value="">Select Faculty</option> <?php foreach ($faculty as $fac) { ?> <?php if ($batch) { foreach ($batch as $values) { ?> <option <?php if ($values->faculty_id == $fac['faculty_id']) { echo 'selected="selected"'; } ?> value="<?php echo $fac['faculty_id']; ?>"><?php echo $fac['faculty_name']; ?></option> <?php } } } ?> </select> <input type="hidden" class="form-control faculty_name_id" name="faculty_name_id" id="faculty_name_id"> </div> </div> <div class="form-group faculty_name"> <label class="control-label col-sm-4">Select Faculty</label> <div class="col-sm-8 "> <select class="form-control faculty_list" id="faculty_id" name="faculty_id"> </select> </div> </div> <div class="form-group edit_avail_time"> <label class="control-label col-sm-4">Available Timings</label> <div class="col-sm-8 "> <input type="text" class="form-control existing_time" name="time_list"> </div> </div> <div class="form-group avail_time" style="display: none;"> <label class="control-label col-sm-4">Available Timings</label> <div class="col-sm-8 "> <select class="form-control time_list" id="from_time" name="from_time"> </select> </div> </div> <div class="form-group duration_div"> <label class="control-label col-sm-4">Duration</label> <div class="col-sm-8 "> <input type="text" class="form-control batch_duration" id="batch_duration" name="batch_duration" readonly> </div> </div> <div class="form-group timings_div" style="margin-bottom: -15px !important;"> </div> <div class="form-group multiple_fields"></div> </div> <div class="col-sm-5"> <div class="form-group"> <label class="control-label col-sm-4">Batch Name</label> <div class="col-sm-8"> <input type="text" class="form-control" name="batch_name" id="batch_name" value="<?php //$a = $batch->batch_id+1; echo 'NP000'.$a; ?>" required readonly> </div> </div> <div class="form-group"> <label class="control-label col-sm-4">Batch Size</label> <div class="col-sm-8"> <!-- <input type="number" class="form-control" name="batch_size" min="1" required> --> <input class="batch_size" style="width: 21% !important;margin-top: 10px;" type="radio" value="Fixed" name="batch_type" onclick="select_batch_size('fixed');" required="">Fixed</label><br class="hidden-xs hidden-md hidden-lg"> <input class="batch_size" style="width: 21% !important;margin-top: 10px;" type="radio" value="Range" name="batch_type" onclick="select_batch_size('range');" required="">Range</label> <!-- <input type="number" class="form-control" name="batch_size" min="1" required> --> </div> </div> <div class="form-group fixed" style="display: none;"> <label class="control-label col-sm-4">No of participants</label> <div class="col-sm-8"> <input type="number" class="form-control" name="batch_fixed_size" min="1" placeholder="Enter Batch size like 10 etc." id="fixed_size"> </div> </div> <div class="form-group range" style="display: none;"> <label class="control-label col-sm-4">Range</label> <div class="col-sm-8"> <select type="text" class="form-control" name="batch_range_size" id="range_size"> <option value="">Select Range</option> <option value="1 - 1">1 - 1</option> <option value="10">10</option> <option value="20">20</option> <option value="30">30</option> <option value="40">40</option> <option value="50">50</option> <option value="60">60</option> <option value="70">70</option> <option value="80">80</option> <option value="90">90</option> <option value="100">100</option> </select> </div> </div> <div class="form-group batch_from_date"> <label class="control-label col-sm-4">Start Date</label> <div class="col-sm-8"> <input type="" id="from_date" name="batch_from_date" class="form-control batch_from_date" readonly required /> </div> </div> <div class="form-group batch_to_date"> <label class="control-label col-sm-4">End Date</label> <div class="col-sm-8"> <input type="" id="to_date" name="batch_to_date" class="form-control batch_to_date" readonly required /> </div> </div> </div> </div><!--- row ----> <div class="form-group" style="text-align:center;padding-top:30px;"> <button type="submit" class="btn btn-primary submit">Update</button> </div> </form> </div> </section> <!-- /.content --> </div> <script type="text/javascript"> $(document).ready(function() { var dateToday = new Date(); $('#from_date').datepicker({ dateFormat: 'dd-mm-yy', minDate: dateToday, //numberOfMonths: 2, onSelect: function(selected) { $("#to_date").datepicker("option", "minDate", selected) } }); $('#to_date').datepicker({ dateFormat: 'dd-mm-yy', onSelect: function(selected) { $("#from_date").datepicker("option", "maxDate", selected) } }); }); // function select_batch_size(str) { // if (str == 'fixed') { // $('.fixed').show(); // $('.range').hide(); // $('#range_size').val(Select); // } else { // $('.fixed').hide(); // $('.range').show(); // $('#fixed_size').val(0); // } function select_batch_size(str) { if (str == 'fixed') { $('.fixed').show(); $('.range').hide(); } else { $('.fixed').hide(); $('.range').show(); } } $(document).ready(function() { var batch_id = '<?= service('request')->uri->getSegment(2) ?>'; $(".batch_id").val(batch_id); $('.sub_cate_div').hide(); $('.faculty_name').hide(); $.ajax({ url: "<?php echo site_url('single_batch_details') ?>", type: "POST", data: { 'batch_id': batch_id }, async: false, success: function(response) { // response = jQuery.parseJSON(response); if (response.result == 1) { if (response.batch_details.course_type == "Recorded") { $('input[value="Recorded"]').prop("checked", true); $('.edit_avail_time').hide(); $('.existing_time').val(""); } else { $('input[value="Live"]').prop("checked", true); $('.edit_avail_time').show(); } $('#catagory option[value="' + response.batch_details.domain_id + '"').attr('selected', 'selected'); $("input[name=sub_domain_ids]").val(response.batch_details.sub_domain); $("input[name=faculty_names]").val(response.batch_details.fullname); $("input[name=faculty_name_id]").val(response.batch_details.login_id); if (response.batch_details.from_time == 'full_day') { $("input[name=time_list]").val('Full Day'); } else { $("input[name=time_list]").val(response.batch_details.from_time); } $("input[name=batch_name]").val(response.batch_details.batch_name); if (response.batch_details.batch_type == "Fixed") { $('input[value="Fixed"]').prop("checked", true); $('.range').hide(); $('.fixed').show(); $("input[name=batch_fixed_size]").val(response.batch_details.batch_size); } else { $('input[value="Range"]').prop("checked", true); $('.range').show(); $('.fixed').hide(); if (response.batch_details.batch_size == 1) { $('#range_size option[value="1 - 1"').attr('selected', 'selected'); } else { $('#range_size option[value="' + response.batch_details.batch_size + '"').attr('selected', 'selected'); } } //$("input[name=batch_size]").val(response.batch_details.batch_size); $("input[name=batch_duration]").val(response.batch_details.batch_duration); $(".batch_from_date").val(response.batch_details.batch_from_date); $(".batch_to_date").val(response.batch_details.batch_to_date); SubCategory(response.batch_details.domain_id, response.batch_details.sub_domain_id); // Faculty(response.batch_details.domain_id,response.batch_details.sub_domain_id); } } }); /* $('#from_date').datepicker({ dateFormat: 'dd-mm-yy' }); $('#to_date').datepicker({ dateFormat: 'dd-mm-yy' });*/ }); </script> <script type="text/javascript"> function selected_course_type(str) { if (str == 'Recorded') { $('.edit_avail_time').hide(); $('.avail_time').hide(); $('.existing_time').val(""); } else { $('.avail_time').show(); var fac_id = $('#faculty_names').val(); var sub_domain_id = $('#sub_domain_ids').val(); $.ajax({ url: "<?php echo base_url('get_not_enrolled_fac_timings'); ?>", // Make sure to use the correct URL type: "POST", data: { 'id': fac_id, 'sub_domain_id': sub_domain_id }, async: false, success: function(response) { // Handle the response console.log(response); if (response.result == 1) { // Process the data var content = '<option value="0">Select Time</option>'; $.each(response.message, function(idx, vx) { if (vx.available_type == 'timings') { content += '<option value="' + vx.from_time + ' - ' + vx.to_time + '">' + vx.from_time + ' - ' + vx.to_time + '</option>'; } else { content += '<option value="full_day">Full Day</option>'; } }); $('.time_list').html(content); $('.existing_time').val(''); } else { // Handle the case when there is no data $("#from_time").empty(); $("#to_time").empty(); } } }); } } var timings_global = ''; var coursetype_global = ''; //------------------------------------------------------------------------------------------------// function SubCategory(domain_id, sub_domain_id) { $.ajax({ url: "<?php echo site_url('get_sub_domain') ?>", type: "POST", data: { 'domain_id': domain_id }, async: false, success: function(response) { // response=jQuery.parseJSON(response); console.log(response); if (response.result == 1) { var content = ''; content += '<label class="control-label col-sm-4">Select Sub Category</label>'; content += '<div class="col-sm-8">'; content += '<select class="form-control sub_category_list" name="sub_domain_id">'; $.each(response.message, function(idx, vx) { content += '<option value="' + vx.sub_domain_id + '">' + vx.sub_domain + '</option>'; }); content += '</select>'; content += '</div>'; $('.sub_cate_div').html(content); // $('.sub_category_list').SumoSelect({ selectAll: true }); // var sub_domains = jQuery.parseJSON(sub_domain_id); //$.each(sub_domains,function(index,value){ // $('.sub_category_list')[0].sumo.selectItem($('.sub_category_list').find('option[value="' + sub_domains + '"]').index()); // }); } else { $('.sub_category_list').empty(); } } }); } //----------------------------------------------------------------------------------------------// $("#catagory").change(function() { $('.sub_cate_div').show(); $('.faculty_name').show(); $('.sub_cate_div1').hide(); $('.faculty_name1').hide(); var domain_id = $("#catagory").val(); $.ajax({ url: "<?php echo site_url('get_sub_domain') ?>", type: "POST", data: { 'domain_id': domain_id }, async: false, success: function(response) { // response=jQuery.parseJSON(response); console.log(response); if (response.result == 1) { var content = ''; content += '<label class="control-label col-sm-4">Select Sub Category</label>'; content += '<div class="col-sm-8">'; content += '<select class="form-control sub_category_list" name="sub_domain_id" id="sub_domain_id">'; content += '<option value="">Select</option>'; $.each(response.message, function(idx, vx) { content += '<option value="' + vx.sub_domain_id + '">' + vx.sub_domain + '</option>'; }); content += '</select>'; content += '</div>'; $('.sub_cate_div').html(content); // $('.sub_category_list').SumoSelect({ selectAll: true }); } else { $('.sub_category_list').empty(); } } }); }); $(document).on('change', '#sub_domain_id', function() { var sub_domain_id = $('#sub_domain_id').val(); var domain_id = $('#catagory').val(); $.ajax({ url: "<?php echo site_url('get_faculty') ?>", type: "POST", data: { 'sub_domain_id': sub_domain_id, 'domain_id': domain_id }, async: false, success: function(response) { // response = jQuery.parseJSON(response); console.log(response); if (response.result == 1) { var content = ''; content += '<option value="0">Select</option>'; $.each(response.message, function(idx, vx) { content += '<option value="' + vx.faculty_id + '">' + vx.faculty_name + '</option>'; }); $('.faculty_list').html(content); } else { $('.faculty_list').empty(); } } }); }); $(document).on('change', '#sub_domain_ids', function() { $('.faculty_name1').hide(); $('.faculty_name').show(); var sub_domain_id = $('#sub_domain_ids').val(); var domain_id = $('#catagory').val(); $.ajax({ url: "<?php echo site_url('get_faculty') ?>", type: "POST", data: { 'sub_domain_id': sub_domain_id, 'domain_id': domain_id }, async: false, success: function(response) { // response = jQuery.parseJSON(response); console.log(response); if (response.result == 1) { var content = ''; content += '<option value="0">Select</option>'; $.each(response.message, function(idx, vx) { content += '<option value="' + vx.faculty_id + '">' + vx.faculty_name + '</option>'; }); $('.faculty_list').html(content); } else { $('.faculty_list').empty(); } } }); }); $(document).on('change', '#faculty_id', function() { $('.edit_avail_time').hide(); $('.avail_time').show(); var domain_id = $('#catagory').val(); var sub_domain_id = $('#sub_domain_ids').val(); var fac_id = $("#faculty_id").val(); $.ajax({ url: "<?= site_url('get_not_enrolled_fac_timings'); ?>", // Use the URL defined in the route type: "POST", data: { 'id': fac_id, 'sub_domain_id': sub_domain_id, 'domain_id': domain_id }, async: false, success: function(response) { // Handle the response console.log(response); if (response.result == 1) { var content = ''; content += '<option value="0">Select Time</option>'; $.each(response.message, function(idx, vx) { if (vx.available_type == 'timings') { content += '<option value="' + vx.from_time + ' - ' + vx.to_time + '">' + vx.from_time + ' - ' + vx.to_time + '</option>'; } else { content += '<option value="full_day">Full Day</option>'; } }); $('.time_list').html(content); $('.existing_time').val(0); // Additional AJAX requests can go here } else { toastr["error"](response.message); $("#from_time").empty(); $("#to_time").empty(); } } }); }); $(document).on('change', '#faculty_names', function() { $('.edit_avail_time').hide(); $('.avail_time').show(); var domain_id = $('#catagory').val(); var sub_domain_id = $('#sub_domain_ids').val(); var fac_id = $("#faculty_names").val(); $.ajax({ url: "<?= site_url('get_not_enrolled_fac_timings') ?>", type: "POST", data: { 'id': fac_id, 'sub_domain_id': sub_domain_id, 'domain_id': domain_id }, async: false, success: function(response) { console.log(response); if (response.result == 1) { var content = ''; content += '<option value="0">Select Time</option>'; $.each(response.message, function(idx, vx) { if (vx.available_type == 'timings') { content += '<option value="' + vx.from_time + ' - ' + vx.to_time + '">' + vx.from_time + ' - ' + vx.to_time + '</option>'; } else { content += '<option value="full_day">Full Day</option>'; } }); $('.time_list').html(content); $('.existing_time').val(0); $.ajax({ url: "<?= site_url('get_training_plan_duration') ?>", type: "POST", data: { 'faculty_id': fac_id, 'sub_domain_id': sub_domain_id, 'domain_id': domain_id }, async: false, success: function(response) { console.log(response); if (response.result == 1) { var content = ''; content += '<label class="control-label col-sm-4">Duration(In hrs)</label>'; content += '<div class="col-sm-8">'; content += '<input type="text" class="form-control duration" id="batch_duration" name="batch_duration" value="' + response.message + '" readonly>'; content += '</div>'; $('.duration_div').html(content); } else { } } }); } else { toastr["error"](response.message); $("#from_time").empty(); $("#to_time").empty(); } } }); }); //----------------------------------------------------------------------------------------------// // $('.course_form').submit(function(e) { // e.preventDefault(); // $("#loading").show(); // var duration = $('#batch_duration').val(); // if (duration != '00:00') { // formdata = new FormData($(this)[0]); // $.ajax({ // type: 'post', // url: '<?php //echo site_url("update_batch") ?>', // data: formdata, // contentType: false, // processData: false, // success: function(response) { // response = jQuery.parseJSON(response); // console.log(response); // if (response.result == 1) { // toastr["success"](response.message); // $(".submit").text("Update"); // $(".submit").removeAttr('disabled'); // window.location = '<?php //echo site_url('batch_list'); ?>'; // } else { // toastr["error"](response.message); // $(".submit").text("Update"); // $(".submit").removeAttr('disabled'); // } // } // }); // } else { // toastr["error"]('Duration is not added by faculty in training plan!'); // } // }); // $('.course_form').submit(function (e) { // e.preventDefault(); // $("#loading").show(); // var duration = $('#batch_duration').val(); // if (duration !== '00:00') { // var formdata = new FormData($(this)[0]); // $.ajax({ // type: 'POST', // url: "<? //= site_url('update-batch') ?>", // Use the URL helper function // data: formdata, // contentType: false, // processData: false, // success: function (response) { // console.log(response); // if (response.result === 1) { // toastr["success"](response.message); // $(".submit").text("Update"); // $(".submit").removeAttr('disabled'); // window.location = "<? //= site_url('batch-list') ?>"; // Use the URL helper function // } else { // toastr["error"](response.message); // $(".submit").text("Update"); // $(".submit").removeAttr('disabled'); // } // } // }); // } else { // toastr["error"]('Duration is not added by faculty in training plan!'); // } // }); $('.course_form').submit(function(e) { e.preventDefault(); $("#loading").show(); var duration = $('#batch_duration').val(); if (duration != '00:00') { formdata = new FormData($(this)[0]); $.ajax({ type: 'post', url: '<?php echo site_url("update-batch") ?>', data: formdata, contentType: false, processData: false, success: function(response) { // response=jQuery.parseJSON(response); console.log(response); if (response.result == 1) { toastr["success"](response.message); $(".submit").text("Update"); $(".submit").removeAttr('disabled'); window.location = '<?php echo site_url('batch_list'); ?>'; } else { toastr["error"](response.message); $(".submit").text("Update"); $(".submit").removeAttr('disabled'); } } }); } else { toastr["error"]('Duration is not added by faculty in training plan!'); } }); </script> <style> .content-wrapper{ background-image: url(http://localhost/amcad/public/assets/website_assets/images/banner.png); background-size:cover; } .form-control{ border-radius: 5px; } .middle_work { padding-bottom: 30px; padding-top: 30px; } .row { margin: 0 !important; } </style> <?php echo view('includes/admin_footer.php') ?>