BBnepal-Accounts/application/views/admin/ae_subject.php
Sampanna Rimal 9cd05ef3cb commitall
2024-07-10 18:28:19 +05:45

310 lines
17 KiB
PHP

<style>
.error {
color: red;
padding-top: 2px;
}
.form-group.form-group-iconselect {
position: relative;
margin: 0px 0px 25px 0px;
}
label#subject_icon-error {
position: absolute;
bottom: -25px;
}
</style>
<div class="wraper responsive-width">
<main class="" id="main">
<div class="from-group">
</div>
<div class="admin_tempblock">
<div class="admin_tempsec">
<div class="admin_sec">
<div class="subsec_sec">
<div class="subject_l subject_l_full_width">
<div class="subject_lsec">
<div class="subject_lhead"><?php echo $title; ?></div>
<?php
$subject_name = (isset($subject['subject_name'])) ? $subject['subject_name'] : '';
$subject_icon = (isset($subject['subject_icon'])) ? $subject['subject_icon'] : '';
$subject_code = (isset($subject['subject_code'])) ? $subject['subject_code'] : '';
$is_optional = (isset($subject['is_optional'])) ? $subject['is_optional'] : 'No';
$credit_hrs = (isset($subject['credit_hours'])) ? $subject['credit_hours'] : '';
$is_additional = (isset($subject['is_additional'])) ? $subject['is_additional'] : 'No';
$is_active = (isset($subject['is_active'])) ? $subject['is_active'] : '';
$action_url = base_url() . 'admin/ae-subject/' . $id;
?>
<p id="success" style="color:green;"></p>
<form id="subjectfrom" method="post" action="<?= $action_url; ?>">
<input type="hidden" name="id" id="id" value="<?= $id; ?>">
<div class="subject_lformarea">
<div class="form-group">
<label for="">Subject Name <span class="text-danger font-weight-bold">*</span></label>
<input type="text" name="subject_name" id="subject_name" class="form-control" value="<?= $subject_name; ?>" placeholder="Enter subject name">
<label id="subjecterror" class="error" style="display : none"></label>
</div>
<div class="form-group form-group-iconselect">
<input type="hidden" id="subject_icon" name="subject_icon" value="<?= $subject_icon; ?>" />
<label for="">Subject Icon <span class="text-danger font-weight-bold">*</span></label>
<div class="sub-icon-select">Select<i class="fas fa-caret-down"></i></div>
<div class="sub-icon-drpdown">
<a href="#" onclick="icon('sub1.png','sub1')">
<div class="sub-icon-option" id="sub1"><img src="<?= base_url(); ?>assets_admin/images/icons/sub1.png"></div>
</a>
<a href="#" onclick="icon('sub2.png','sub2')">
<div class="sub-icon-option" id="sub2"><img src="<?= base_url(); ?>assets_admin/images/icons/sub2.png"></div>
</a>
<a href="#" onclick="icon('sub3.png','sub3')">
<div class="sub-icon-option" id="sub3"><img src="<?= base_url(); ?>assets_admin/images/icons/sub3.png"></div>
</a>
<a href="#" onclick="icon('sub4.png','sub4')">
<div class="sub-icon-option" id="sub4"><img src="<?= base_url(); ?>assets_admin/images/icons/sub4.png"></div>
</a>
<a href="#" onclick="icon('sub5.png','sub5')">
<div class="sub-icon-option" id="sub5"><img src="<?= base_url(); ?>assets_admin/images/icons/sub5.png"></div>
</a>
<a href="#" onclick="icon('sub6.png','sub6')">
<div class="sub-icon-option" id="sub6"><img src="<?= base_url(); ?>assets_admin/images/icons/sub6.png"></div>
</a>
<a href="#" onclick="icon('sub7.png','sub7')">
<div class="sub-icon-option" id="sub7"><img src="<?= base_url(); ?>assets_admin/images/icons/sub7.png"></div>
</a>
<a href="#" onclick="icon('sub8.png','sub8')">
<div class="sub-icon-option" id="sub8"><img src="<?= base_url(); ?>assets_admin/images/icons/sub8.png"></div>
</a>
<a href="#" onclick="icon('sub9.png','sub9')">
<div class="sub-icon-option" id="sub9"><img src="<?= base_url(); ?>assets_admin/images/icons/sub9.png"></div>
</a>
<a href="#" onclick="icon('sub10.png','sub10')">
<div class="sub-icon-option" id="sub10"><img src="<?= base_url(); ?>assets_admin/images/icons/sub10.png"></div>
</a>
<a href="#" onclick="icon('sub11.png','sub11')">
<div class="sub-icon-option" id="sub11"><img src="<?= base_url(); ?>assets_admin/images/icons/sub11.png"></div>
</a>
<a href="#" onclick="icon('sub12.png','sub12')">
<div class="sub-icon-option" id="sub12"><img src="<?= base_url(); ?>assets_admin/images/icons/sub12.png"></div>
</a>
<a href="#" onclick="icon('sub13.png','sub13')">
<div class="sub-icon-option" id="sub13"><img src="<?= base_url(); ?>assets_admin/images/icons/sub13.png"></div>
</a>
<a href="#" onclick="icon('sub14.png','sub14')">
<div class="sub-icon-option" id="sub14"><img src="<?= base_url(); ?>assets_admin/images/icons/sub14.png"></div>
</a>
<a href="#" onclick="icon('sub15.png','sub15')">
<div class="sub-icon-option" id="sub15"><img src="<?= base_url(); ?>assets_admin/images/icons/sub15.png"></div>
</a>
<a href="#" onclick="icon('sub16.png','sub16')">
<div class="sub-icon-option" id="sub16"><img src="<?= base_url(); ?>assets_admin/images/icons/sub16.png"></div>
</a>
<a href="#" onclick="icon('sub17.png','sub17')">
<div class="sub-icon-option" id="sub17"><img src="<?= base_url(); ?>assets_admin/images/icons/sub17.png"></div>
</a>
</div>
</div>
<!-- <input type="file" id="upload" name="syllabus" accept=".pdf" value = "<?php //echo $syllabus
?>-->
<div class="form-group">
<label for="">Subject code</label>
<input type="text" name="subject_code" id="subject_code" class="form-control" value="<?php echo $subject_code; ?>" placeholder="Please Enter Subject code">
</div>
<div class="form-group">
<label for="">Status <span class="text-danger font-weight-bold">*</span></label>
<?php
if ($id > 0) {
?>
<select name="is_active" id="is_active" class="form-control">
<option selected value="<?php echo $is_active; ?>"><?php echo $is_active; ?></option>
<?php if ($is_active == 'yes') { ?>
<option value="no">No</option>
<?php } else { ?>
<option value="yes">Yes</option>
<?php } ?>
</select>
<?php
} else {
?>
<select name="is_active" id="is_active" class="form-control">
<option value=""> -- Please Select --</option>
<option selected value="yes">Yes</option>
<option value="no">No</option>
</select>
<?php } ?>
</div>
<div class="form-group">
<label for="">Is Optional Subject <span class="text-danger font-weight-bold">*</span></label>
<select name="is_optional" id="is_optional" class="form-control">
<option value="No" <?php if($is_optional == 'No'){?> selected <?php }?> >No</option>
<option value="Yes" <?php if($is_optional == 'Yes'){?> selected <?php }?> >Yes</option>
</select>
</div>
<div class="form-group">
<label for="">Credit Hours</label>
<input type="number" min='1' name="credit_hours" id="credit_hours" class="form-control" value="<?php echo $credit_hrs; ?>" placeholder="Please Enter Subject credit hours">
</div>
<div class="form-group">
<label for="">Is Additional Subject <span class="text-danger font-weight-bold">*</span></label>
<select name="is_additional" id="is_additional" class="form-control">
<option value="No" <?php if($is_additional == 'No'){?> selected <?php }?> >No</option>
<option value="Yes" <?php if($is_additional == 'Yes'){?> selected <?php }?> >Yes</option>
</select>
</div>
<input type="submit" class="subject_addbtn" value="<?php echo $btn_name = ($id > 0) ? 'Update' : 'Add'; ?>">
<a href="<?= base_url(); ?>admin/subject"><button type="button" class=" ml-2 subject_addbtn bg-dark">Back</button></a>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
</div>
<script>
$(".sub-icon-select").click(function() {
$(".sub-icon-drpdown").toggleClass("sub-icon-drpdown-show");
});
</script>
<script type="text/javascript">
function hide_all_subject_error() {
$('#sname_error').hide();
$('#success').html('');
}
function cleanup_subject_val() {
$('#sname').val('');
$('#exists_error').html('');
}
function icon(icn, id) {
// alert(icn);
$('#subject_icon').val(icn);
$('.sub-icon-drpdown div').removeClass('active');
$('#' + id).addClass('active');
}
$(document).ready(function() {
var icon = $('#subject_icon').val();
if (icon != '') {
$(".sub-icon-drpdown").addClass("sub-icon-drpdown-show");
var pos = icon.lastIndexOf('.');
var iconName = icon.substr(0, pos);
// alert(iconName);
$('#' + iconName).addClass('active');
}
});
$(document).ready(function() {
$("#flash-msg").delay(3000).fadeOut("slow");
});
$(document).ready(function() {
jQuery.validator.addMethod("inputregx", function(value, element) {
return this.optional(element) || /^[a-zA-Z0-9 ]{3,50}$/.test(value);
}, 'Please enter alpha and numeric characters only ');
$("#subjectfrom").validate({
ignore: "input[type='text']:hidden",
rules: {
subject_name: {
required: true,
rangelength: [2, 50],
inputregx: true,
},
subject_icon: {
required: true,
},
is_active: {
required: true,
},
credit_hours: {
required: true,
},
},
messages: {
subject_name: {
required: "Please enter subject name ",
},
subject_icon: {
required: "Please Select subject icon",
},
is_active: {
required: "Please Select Status",
},
credit_hours: {
required: "Please enter the credit hours",
},
},
submitHandler: function(form) {
var EditId = "<?= $id ?>";
// if (EditId == 0)
/* { */
var inputValue = $("input[name='subject_name']", form).val();
let flag = false;
$.ajax({
url: "<?= base_url() ?>admin/checknamewithId",
data: {
id:EditId,
value: inputValue,
tablename: "subject",
column: "subject_name"
},
type: 'POST',
async: false,
success: function(data) {
// console.log(data);
if(data == 'success') {
flag=true;
}
}
});
if(flag) {
form.submit();
} else {
$('#subjecterror').show();
$('#subjecterror').text('This Subject name already exists.');
}
// } else {
// form.submit();
// }
}
});
});
</script>