166 lines
4.5 KiB
PHP
166 lines
4.5 KiB
PHP
<style>
|
|
form label.error,
|
|
#secNameerr {
|
|
color: red;
|
|
}
|
|
</style>
|
|
<main class="wraper responsive-width" id="main">
|
|
|
|
<!----admin template scholarship---->
|
|
<div class="admin_tempblock">
|
|
<div class="admin_tempsec">
|
|
<div class="admin_sec">
|
|
|
|
<form action="<?php echo base_url() ?>admin/ae-scholarship-type/<?php echo $id ?>" method="post" id="scholarshipForm">
|
|
|
|
<?php if ($id == 0) { ?>
|
|
|
|
|
|
<div class="subsec_sec">
|
|
<div class="subject_l subject_l_full_width">
|
|
<div class="subject_lsec">
|
|
<div class="subject_lhead"><?php echo $title ?></div>
|
|
<div class="subject_lformarea">
|
|
<div class="form-group">
|
|
<label for="">Name<span class="text-danger font-weight-bold">*</span></label>
|
|
|
|
<input type="text" name="scholarshiptype_name" class="form-control" placeholder="Name of the scholarship">
|
|
<label id="secNameerr" style="display : none"></label>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="">Status<span class="text-danger font-weight-bold">*</span></label>
|
|
<select name="is_active" class="form-control">
|
|
<option selected disable value="">Choose scholarship status</option>
|
|
<option value="yes">Yes</option>
|
|
<option value="no">No</option>
|
|
</select>
|
|
</div>
|
|
|
|
<input type="submit" class="subject_addbtn" value="Save">
|
|
<a href="<?= base_url(); ?>admin/scholarship-types"><button type="button" class="subject_addbtn bg-dark ml-2">Back</button></a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</form>
|
|
|
|
<?php } else { ?>
|
|
|
|
<div class="subsec_sec">
|
|
<div class="subject_l subject_l_full_width">
|
|
<div class="subject_lsec">
|
|
<div class="subject_lhead"><?php echo $title ?></div>
|
|
<div class="subject_lformarea">
|
|
<div class="form-group">
|
|
<label for="">Name <span class="text-danger font-weight-bold">*</span></label>
|
|
<input type="text" name="scholarshiptype_name" value="<?php echo $result['scholarshiptype_name'] ?>" class="form-control" placeholder="Name of the scholarship">
|
|
<label id="secNameerr" style="display : none"></label>
|
|
</div>
|
|
|
|
|
|
<div class="form-group">
|
|
<label for="">Status<span class="text-danger font-weight-bold">*</span></label>
|
|
<select name="is_active" class="form-control">
|
|
<option selected value="<?php echo $result['is_active'] ?>"><?php echo $result['is_active'] ?></option>
|
|
<?php if ($result['is_active'] == 'yes') { ?>
|
|
<option value="no">no</option>
|
|
<?php } else { ?>
|
|
<option value="yes">yes</option>
|
|
<?php } ?>
|
|
</select>
|
|
</div>
|
|
|
|
<input type="submit" class="subject_addbtn" value="Update">
|
|
<a href="<?= base_url(); ?>admin/scholarship-types"><button type="button" class="subject_addbtn bg-dark ml-2">Back</button></a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</form>
|
|
|
|
<?php } ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!----admin template scholarship end---->
|
|
</main>
|
|
<!--End right-top side-->
|
|
|
|
|
|
<script>
|
|
$(document).on('keypress', function(e) {
|
|
if (e.which == 13) {
|
|
$('form').submit();
|
|
}
|
|
});
|
|
$(document).ready(function() {
|
|
let url = window.location.pathname.split('/');
|
|
|
|
|
|
let scholarshipId = url[4];
|
|
|
|
jQuery.validator.addMethod("alphanumeric", function(value, element) {
|
|
return this.optional(element) || /^[a-z0-9\-\s]+$/i.test(value);
|
|
}, "Please enter alphanumeric Characters only");
|
|
|
|
|
|
$("#scholarshipForm").validate({
|
|
|
|
rules: {
|
|
scholarship_name: {
|
|
required: true,
|
|
minlength: 1,
|
|
alphanumeric: true
|
|
},
|
|
is_active: "required"
|
|
},
|
|
messages: {
|
|
|
|
scholarship_name: {
|
|
required: "Please provide a scholarship name",
|
|
minlength: "Please enter more than 4 Characters"
|
|
},
|
|
is_active: 'Please select the status of scholarship'
|
|
|
|
},
|
|
submitHandler: function(form) {
|
|
|
|
var inputValue = $("input[name='scholarship_name']", form).val();
|
|
inputValue = inputValue.toLowerCase();
|
|
|
|
let flag = false;
|
|
|
|
$.ajax({
|
|
url: '<?php echo base_url() ?>' + 'admin/validateSectionName',
|
|
data: {
|
|
value: inputValue,
|
|
id: <?php echo $id ?>
|
|
},
|
|
type: 'POST',
|
|
async: false,
|
|
success: function(data) {
|
|
console.log(data);
|
|
if (data == 'success') {
|
|
flag = true
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
|
|
if (flag) {
|
|
form.submit();
|
|
} else {
|
|
$('#secNameerr').show();
|
|
$('#secNameerr').text('This scholarship name already exists.');
|
|
}
|
|
|
|
|
|
}
|
|
});
|
|
|
|
});
|
|
</script>
|