File: /var/www/html/hrms-production/storage/framework/views/055a5c0d96bb60ef8c55f2e9fffcc37f3c7af3fc.php
<div class="modal fade" id="addControllingOfficer">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Add Controlling Officer</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<!-- Main content -->
<form id="addControllingOfficerform">
<input type="hidden" name="_token" id="token_controlling_officer" value="<?php echo e(csrf_token()); ?>">
<div class="card-body">
<div class="row">
<div class="col-md-12">
<div class="form-group mb-2">
<label class="mb-0" for="name">Controlling Officer Name<span class="text-danger">*</span></label>
<input type="text" class="form-control form-control-sm" id="ControllingOfficerName" name="ControllingOfficerName" required>
</div>
</div>
</div>
<hr />
<div class="row">
<div class="col-12">
<div class="d-flex align-items-center justify-content-center">
<button type="button" class="btn btn-sm btn-outline-secondary mx-1"
data-dismiss="modal" aria-label="Close">Cancel</button>
<button type="submit" id="btn-save-new-controlling-officer"
class="btn btn-sm btn-outline-info mx-1">Save & New</button>
<button type="submit" id="btn-save-controlling-officer"
class="btn btn-sm btn-info mx-1">Save</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<div class="modal fade" id="updateControllingOfficer">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Controlling Officer <span id="ControllingOfficerName" class="text-info"></span></h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<!-- Main content -->
<form id="updateControllingOfficerform">
<input type="hidden" name="_token" id="token_controlling_officer_update" value="<?php echo e(csrf_token()); ?>">
<input type="hidden" id="ControllingOfficerId" name="ControllingOfficerId">
<div class="card-body">
<div class="row">
<div class="col-md-12">
<div class="form-group mb-2">
<label class="mb-0" for="name">Controlling Officer Name<span class="text-danger">*</span></label>
<input type="text" class="form-control form-control-sm" id="editControllingOfficerName"
name="ControllingOfficerName" onkeyup="checkDuplicateControllingOfficer(this);" required>
<span id='editCheckControllingOfficer'></span>
</div>
</div>
</div>
<hr />
<div class="row">
<div class="col-12">
<div class="d-flex align-items-center justify-content-center">
<button type="button" class="btn btn-sm btn-outline-secondary mx-1"
data-dismiss="modal" aria-label="Close">Cancel</button>
<button type="button" id="btn-update-controlling-officer" name="Update" value="Update"
class="btn btn-sm btn-info mx-1" disabled>Update</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<script>
function checkDuplicateControllingOfficer(element, id){
var id = id;
var ControllingOfficerName = $(element).val();
if (ControllingOfficerName == "") {
$('span#CheckControllingOfficer, #editCheckControllingOfficer').css("display", "none");
} else {
$('span#CheckControllingOfficer, #editCheckControllingOfficer').css("display", "block");
}
//alert (ControllingOfficer);
$.ajax({
type: "GET",
url: '<?php echo e(url("/")); ?>/check-controlling-officer/',
data: {ControllingOfficerName:ControllingOfficerName, id:id},
dataType: "json",
success: function(res) {
if(res.exists){
$('span#CheckControllingOfficer, span#editCheckControllingOfficer').html('<span class="text-danger">Controlling Officer is already exist!</span>');
$('#btn-save-new-controlling-officer, #btn-save-controlling-officer, #btn-update-controlling-officer').attr('disabled', true);
} else {
$('span#CheckControllingOfficer, span#editCheckControllingOfficer').html('<span class="text-success">Controlling Officer is available!</span>');
$('#btn-save-new-controlling-officer, #btn-save-controlling-officer, #btn-update-controlling-officer').attr('disabled', false);
}
},
error: function (jqXHR, exception) {
}
});
}
</script>
<script>
var reload = 0;
$(function () {
$.validator.setDefaults({
submitHandler: function () {
saveControllingOfficerRecord();
}
});
// Reload page after data save
$('#btn-save-controlling-officer').click(function(){
reload = 1;
});
// Validate Fields
$('#addControllingOfficerform').validate({
rules: {
ControllingOfficerName: {
required: true,
},
remote: {
type: "POST",
url:'<?php echo e(url("/")); ?>/check-duplicate-controlling-officer',
data: {
ControllingOfficerName: function() {
return $( "#ControllingOfficerName" ).val();
},
'_token':$('meta[name="csrf-token"]').attr('content')
}
},
},
messages: {
ControllingOfficerName: {
required: "Please enter the Controlling Officer name.",
},
},
errorElement: 'span',
errorPlacement: function (error, element) {
error.addClass('invalid-feedback');
element.closest('.form-group').append(error);
},
highlight: function (element, errorClass, validClass) {
$(element).addClass('is-invalid');
},
unhighlight: function (element, errorClass, validClass) {
$(element).removeClass('is-invalid');
}
});
});
</script>
<script>
function saveControllingOfficerRecord() {
event.preventDefault();
$.ajax({
type: "post",
url: "<?php echo e(url('store-controlling-officer')); ?>",
dataType: "json",
data: $('form#addControllingOfficerform').serialize(),
success: function(response) {
const Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 2000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
Toast.fire({
icon: 'success',
title: 'Controlling Officer added successfully!'
});
$('form#addControllingOfficerform').each(function() {
this.reset();
});
$('span#CheckControllingOfficer').html('');
if(reload)
{
location.reload();
}
},
error: function(response) {
const Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
Toast.fire({
icon: 'error',
title: 'Sorry, Something went wrong!'
})
}
});
}
</script>
<script>
// Activate
function activateControllingOfficer(ControllingOfficerId) {
var ControllingOfficerId = ControllingOfficerId;
Swal.fire({
title: 'Activate Controlling Officer?',
text: "Are you sure you want to activate Controlling Officer!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, activate it!'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
type: "get",
url: "<?php echo e(url('/')); ?>/change-status-controlling-officer/" + ControllingOfficerId,
success: function(response) {
Swal.fire({
icon: 'success',
title: 'Controlling Officer has been activated!',
showConfirmButton: false,
timer: 1500
}).then(function() {
location.reload();
});
}
});
}
});
}
// Deactivate
function deactivateControllingOfficer(ControllingOfficerId) {
var ControllingOfficerId = ControllingOfficerId;
Swal.fire({
title: 'De-activate Controlling Officer?',
text: "Are you sure you want to De-activate Controlling Officer!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, De-activate it!'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
type: "get",
url: "<?php echo e(url('/')); ?>/change-status-controlling-officer/" + ControllingOfficerId,
success: function(response) {
Swal.fire({
icon: 'success',
title: 'Controlling Officer has been De-activated!',
showConfirmButton: false,
timer: 1500
}).then(function() {
location.reload();
});
}
});
}
});
}
</script>
<script>
function editControllingOfficer(ControllingOfficerId)
{
var ControllingOfficerId = ControllingOfficerId;
$('#updateControllingOfficer').modal('show');
$.ajax({
type: "GET",
url: "<?php echo e(url('/')); ?>/edit-controlling-officer/" +ControllingOfficerId,
success: function (response) {
$('#editControllingOfficerName').val(response.ControllingOfficer.ControllingOfficerName);
$('#ControllingOfficerId').val(ControllingOfficerId);
$('span#ControllingOfficerName').html('#' +response.ControllingOfficer.ControllingOfficerName);
}
});
}
</script>
<script>
$("#btn-update-controlling-officer").click(function (event) {
event.preventDefault();
var Name = $("#editControllingOfficerName").val();
if (Name == "") {
Swal.fire({
icon: "warning",
title: "Name is required!",
showConfirmButton: false,
timer: 2000,
});
} else {
$.ajax({
type: "post",
url: "<?php echo e(url('update-controlling-officer')); ?>",
dataType: "json",
data: $("form#updateControllingOfficerform").serialize(),
success: function (response) {
Swal.fire({
icon: "success",
title: "Controlling Officer has been updated!",
showConfirmButton: false,
timer: 2000,
}).then(function () {
location.reload();
});
},
error: function (response) {
Swal.fire({
icon: "error",
title: "Sorry, Some thing went wrong!",
showConfirmButton: false,
timer: 2000,
});
},
});
}
});
</script>
<script>
//Delete Controlling Officer
function deleteControllingOfficer(ControllingOfficerId) {
var ControllingOfficerId = ControllingOfficerId;
$.ajax({
type: "GET",
url: "<?php echo e(url('/')); ?>/check-employee-controlling-officer/" + ControllingOfficerId,
success: function (response) {
if (response.exists) {
Swal.fire({
icon: "warning",
title: "Can't be deleted!",
text: "This Controlling Officer is associated with empolyee(s)!",
showConfirmButton: true,
});
} else {
Swal.fire({
title: "Delete Controlling Officer?",
text: "Are you sure you want to delete this Controlling Officer?",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
confirmButtonText: "Yes, delete it!",
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
type: "get",
url:
"<?php echo e(url('/')); ?>/delete-controlling-officer/" + ControllingOfficerId,
success: function (response) {
Swal.fire({
icon: "success",
title: "Controlling Officer has been deleted!",
showConfirmButton: false,
timer: 1500,
}).then(function () {
location.reload();
});
},
});
}
});
}
},
});
}
</script><?php /**PATH /var/www/html/hrms-production/resources/views/components/controlling-officer-modal.blade.php ENDPATH**/ ?>