156 lines
8.2 KiB
PHP
Executable File
156 lines
8.2 KiB
PHP
Executable File
<style>
|
||
.pad {
|
||
padding-bottom: 1%;
|
||
}
|
||
|
||
.badge {
|
||
color: red;
|
||
background-color: #fff;
|
||
}
|
||
</style>
|
||
|
||
<div class="content-page">
|
||
<div class="content">
|
||
<!-- Start Content-->
|
||
<div class="container-fluid">
|
||
<!-- start page title -->
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="page-title-box page-title-box-alt">
|
||
<h4 class="page-title">Add Department Details</h4>
|
||
<a class="btn btn-secondary" href="<?php echo base_url(); ?>departmentListing"><span class="bold">Back</span></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- end page title -->
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body" style="padding: 1rem 2rem !important;">
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<form role="form" id="addDepartment" action="<?php echo base_url() ?>savedepartment" method="post">
|
||
<div class="box-body">
|
||
<!-- Supplier Information -->
|
||
<div class="col-md-12" style="margin-bottom: 27px;">
|
||
<legend style="margin-left:-10px;color: #4f7c97;">Department Information</legend>
|
||
<div class="form-row" style="margin-top:10px">
|
||
<div class="col-md-4">
|
||
<label class="col-form-label" for="DepartmentName">Department Name<span class="badge">*</span></label>
|
||
<input type="text" name="DepartmentName" id="DepartmentName" class="form-control" required>
|
||
</div>
|
||
<div class="col-md-4">
|
||
<label class="col-form-label" for="HeadDepartment">Head Department<span class="badge">*</span></label>
|
||
<select class="form-control required" id="HeadDept" name="HeadDept">
|
||
<option value="" required> Master Department</option>
|
||
<?php
|
||
if (!empty($depcode)) {
|
||
foreach ($depcode as $DC) {
|
||
?>
|
||
<option value="<?php echo $DC->DEPCode ?>"><?php echo $DC->DEPCode . " - " . $DC->DepartmentName ?></option>
|
||
<?php
|
||
}
|
||
}
|
||
?>
|
||
|
||
</select>
|
||
</div>
|
||
<div class="col-md-4 d-flex align-items-center">
|
||
<input type="hidden"
|
||
value="1"
|
||
id="IsActive" name="IsActive" style="margin-top: 16px;">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-12 text-right">
|
||
<input type="reset" id="reset" class="btn btn-reset" style="background-color: red;color: white; margin-right: 15px;width: 80px;" value="Reset" />
|
||
<input type="button" id="deptBtnId" value="Submit" class="btn btn-success">
|
||
</div>
|
||
</div>
|
||
</form>
|
||
<div class="col-md-4">
|
||
<?php
|
||
helper('form');
|
||
$error = session()->getFlashdata('error');
|
||
if ($error) {
|
||
?>
|
||
<div class="alert alert-danger alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<?php echo session()->getFlashdata('error'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
<?php
|
||
$success = session()->getFlashdata('success');
|
||
if ($success) {
|
||
?>
|
||
<div class="alert alert-success alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<?php echo session()->getFlashdata('success'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<?php // \Config\Services::validation()->listErrors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>');
|
||
?> </div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- end row -->
|
||
</div>
|
||
</div> <!-- end card -->
|
||
</div><!-- end col -->
|
||
</div>
|
||
<!-- end row -->
|
||
</div> <!-- container -->
|
||
</div> <!-- content -->
|
||
</div>
|
||
|
||
|
||
|
||
<script>
|
||
|
||
$("#deptBtnId").on('click',function(){
|
||
let departmentName = $("#DepartmentName").val().trim();
|
||
let headDepCode =$("#HeadDept").val()??'';
|
||
let depCode =$("#DEPCode").val() ?? '';
|
||
|
||
if(departmentName.length<1){
|
||
alert(`Department Name cannot be empty..!!`);
|
||
return;
|
||
}
|
||
|
||
$('#loader').show();
|
||
$.ajax({
|
||
type:"POST",
|
||
data:{departmentName,headDepCode ,depCode},
|
||
url:"<?php echo base_url();?>checkDepartmentName",
|
||
success:function(data){
|
||
if(data && data.length >0){
|
||
let isActive = data[0]. IsActive;
|
||
if(isActive == 1){
|
||
alert("Department name already Exists ..!! ");
|
||
}else{
|
||
alert("Department Name already Existing in the deleted section.!!");
|
||
}
|
||
}else{
|
||
console.log("submitting the form..!!")
|
||
$("#addDepartment").submit();
|
||
}
|
||
|
||
},
|
||
error:function(error){
|
||
console.log("error occured..!!")
|
||
console.error(error);
|
||
},
|
||
complete:function(){
|
||
$('#loader').hide();
|
||
console.log("ajax call is completed..!!")
|
||
}
|
||
|
||
})
|
||
|
||
})
|
||
|
||
</script>
|