214 lines
7.5 KiB
PHP
214 lines
7.5 KiB
PHP
|
<main class="common_margin" id="main">
|
||
|
<div class="main-wrap">
|
||
|
<div class="dashboard-cover">
|
||
|
|
||
|
<div class="subject_r">
|
||
|
<div class="subsec_sec">
|
||
|
<div class="subject_r">
|
||
|
<div class="subject_lsec">
|
||
|
<div class="common-heading">
|
||
|
<h2><?php echo $title . ' Batch wise route'; ?></h2>
|
||
|
</div>
|
||
|
<?php
|
||
|
$permissions=array();$batch_id='';
|
||
|
|
||
|
|
||
|
if(isset($role_permissions['route_ids']) && $role_permissions['route_ids']!=''){
|
||
|
$permissions = explode(',', $role_permissions['route_ids']);
|
||
|
$batch_id = $role_permissions['batch_id'];
|
||
|
}
|
||
|
?>
|
||
|
<form action='<?php echo base_url().'route-batch-add-edit/'.$idVal;?>' id="addEditRoleForm" method="post">
|
||
|
<input type='hidden' name='id' id='id' value='<?php echo $idVal;?>' />
|
||
|
<div class="subject_lformarea role_formarea">
|
||
|
|
||
|
<div class="form-group">
|
||
|
<label for="">Batch<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<select name="batch_id" id="status" class="form-control">
|
||
|
<option value="">Choose Batch</option>
|
||
|
<?php foreach ($batch_list as $key => $value) {
|
||
|
if (!empty($batch_id)) {
|
||
|
echo ($batch_id == $value['id']) ? '<option value="'.$value['id'] .'" selected>'. batchdateFormatTo($value['b_from'], $value['b_end']).' </option> ': '';
|
||
|
}else{
|
||
|
?>
|
||
|
<option value="<?php echo $value['id'] ?>" <?php echo ($batch_id == $value['id']) ? 'selected' : ''; echo ($value['is_active'] == 'yes') ? '' : 'disabled'; ?> >
|
||
|
<?php echo batchdateFormatTo($value['b_from'], $value['b_end']); ?>
|
||
|
</option>
|
||
|
<?php } }?>
|
||
|
</select>
|
||
|
<label style="display : none" class="form_err" id='status_error'></label>
|
||
|
</div>
|
||
|
|
||
|
<div class="form-group">
|
||
|
<label for=""> Route Permissions<span class="text-danger font-weight-bold">*</span></label>
|
||
|
<div class="roles_checkbox">
|
||
|
<?php
|
||
|
if(isset($route_list) && !empty($route_list))
|
||
|
{
|
||
|
foreach($route_list as $m)
|
||
|
{
|
||
|
?>
|
||
|
<div class="form-check">
|
||
|
<input class="form-check-input role_perm" type="checkbox" value="<?php echo $m['id'];?>" name="role_permissions[]" <?php if(in_array($m['id'], $permissions)){?>checked<?php } ?> >
|
||
|
<label class="form-check-label" ><?php echo $m['route_name'];?></label>
|
||
|
</div>
|
||
|
<?php
|
||
|
}
|
||
|
}
|
||
|
?>
|
||
|
</div>
|
||
|
<label style="display : none" class="form_err" id='permissions_error'></label>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
</form>
|
||
|
<!-- <button type="submit" class="subject_addbtn"><?php echo $title ?></button> -->
|
||
|
<?php if ($idVal > 0) {
|
||
|
if (isset($check_active) && !empty($check_active)) {
|
||
|
if ($check_active['is_active'] == 'yes' ){ ?>
|
||
|
<button type="button" class="subject_addbtn" onclick='validate_role_form()'><?php echo $title ?></button>
|
||
|
<?php }else{}
|
||
|
}
|
||
|
} else{?>
|
||
|
<button type="button" class="subject_addbtn" onclick='validate_role_form()'><?php echo $title ?></button>
|
||
|
<?php } ?>
|
||
|
|
||
|
|
||
|
<a href='<?php echo base_url()."route-batch-list";?>'>
|
||
|
<button class="btn btn-dark btn-sm">Back</button>
|
||
|
</a>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</main>
|
||
|
<!--End right-top side-->
|
||
|
</div>
|
||
|
<!-- <script src="<?php echo base_url(); ?>assets-bustracking/js/jquery-3.2.1.slim.min.js"></script> -->
|
||
|
<script src="<?php echo base_url(); ?>assets-bustracking/js/jquery-3.4.1.min.js" ></script>
|
||
|
<script src="<?php echo base_url(); ?>assets-bustracking/js/popper.min.js"></script>
|
||
|
<script src="<?php echo base_url(); ?>assets-bustracking/js/bootstrap.min.js"></script>
|
||
|
<script src="https://cdn.datatables.net/1.10.22/js/jquery.dataTables.min.js"></script>
|
||
|
<script defer src="<?php echo base_url(); ?>assets-bustracking/js/all.js"></script>
|
||
|
<script defer src="<?php echo base_url(); ?>assets-bustracking/js/main.js"></script>
|
||
|
<script src="<?php echo base_url(); ?>assets-bustracking/owl-carousel/js/owl.carousel.min.js"></script>
|
||
|
<script>
|
||
|
$(document).ready(function(){
|
||
|
$('.user-drpdown').click(function(){
|
||
|
$('.drpdown-items').toggle();
|
||
|
});
|
||
|
});
|
||
|
//table js
|
||
|
$('#tbl').DataTable( {
|
||
|
"lengthMenu": [[5,10, 25, 50, -1], [5,10, 25, 50, "All"]]
|
||
|
} );
|
||
|
//table js end
|
||
|
</script>
|
||
|
|
||
|
<script type="text/javascript">
|
||
|
var jsAddOrEdit = '<?php echo $idVal;?>';
|
||
|
$(document).ready(function(){
|
||
|
$(document).on('keypress', function(e){
|
||
|
if(e.which==13)
|
||
|
{
|
||
|
validate_role_form();
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
function hide_all_role_errors()
|
||
|
{
|
||
|
// $('#role_name_error').hide();
|
||
|
$('#status_error').hide();
|
||
|
$('#permissions_error').hide();
|
||
|
}
|
||
|
|
||
|
function validate_role_form()
|
||
|
{
|
||
|
hide_all_role_errors();
|
||
|
|
||
|
var errArr = new Array();
|
||
|
var content_id = <?php echo $idVal; ?>;
|
||
|
|
||
|
var status = $('#status').val().trim();
|
||
|
|
||
|
if(status=='')
|
||
|
errArr.push('status_Sep@Str_Please select the user Batch.');
|
||
|
else{
|
||
|
if(content_id === 0) {
|
||
|
$.ajax({
|
||
|
type: 'post',
|
||
|
url: '<?= base_url(); ?>BustrackingAdmin/check_batch_exits',
|
||
|
async:false,
|
||
|
data: {'batch_id' : status},
|
||
|
success: function(result){
|
||
|
//alert(result);
|
||
|
if(result=='Success')
|
||
|
{
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
errArr.push('status_Sep@Str_This Batch already exist');
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
var epCnt = 0;
|
||
|
var route_ids = [];
|
||
|
$('.role_perm').each(function(i){
|
||
|
if($(this).prop('checked')){
|
||
|
epCnt++;
|
||
|
route_ids[i] = $(this).val();
|
||
|
}
|
||
|
|
||
|
});
|
||
|
if (route_ids.length > 0) {
|
||
|
const newArr = route_ids.filter((a) => a);
|
||
|
console.log(newArr);
|
||
|
$.ajax({
|
||
|
type: 'post',
|
||
|
url: '<?= base_url(); ?>BustrackingAdmin/check_batch_route_assign',
|
||
|
async:false,
|
||
|
data: {'route_ids' : newArr,'id':<?php echo $idVal; ?>},
|
||
|
success: function(result){
|
||
|
|
||
|
if(result=='Success'){
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
errArr.push('permissions_Sep@Str_You cant uncheck the route because already assign to student.');
|
||
|
}
|
||
|
route_ids = [];
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
if(epCnt == 0)
|
||
|
errArr.push('permissions_Sep@Str_Please select the Route permissions.');
|
||
|
|
||
|
//var errArr = new Array();
|
||
|
if(errArr.length>0)
|
||
|
{
|
||
|
for(i=0; i<errArr.length; i++)
|
||
|
{
|
||
|
var resArr = errArr[i].split("_Sep@Str_");
|
||
|
$("#"+resArr[0]+"_error").html(resArr[1]);;
|
||
|
$("#"+resArr[0]+"_error").show();
|
||
|
}
|
||
|
var xxxVal = errArr[0].split('_Sep@Str_');
|
||
|
$('#'+xxxVal[0]).focus();
|
||
|
return false;
|
||
|
}
|
||
|
else{
|
||
|
$('#addEditRoleForm').submit();
|
||
|
}
|
||
|
}
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|