367 lines
15 KiB
PHP
Executable File
367 lines
15 KiB
PHP
Executable File
<style>
|
||
.table th,
|
||
.table td {
|
||
padding: 8px;
|
||
}
|
||
|
||
table.dataTable tbody td {
|
||
padding: 4px 4px !important;
|
||
}
|
||
|
||
table.dataTable thead th {
|
||
padding: 4px 4px !important;
|
||
}
|
||
|
||
.col-12 {
|
||
|
||
max-width: 98% !important;
|
||
}
|
||
</style>
|
||
|
||
<div class="row" id="client_list">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
<div class="row" style="margin-bottom:1rem;">
|
||
<div class="col-6" style="align-self: center;">
|
||
<h4 style="position: relative;">CD Master List</h4>
|
||
</div>
|
||
<div class="col-6" style="text-align: right; position: relative;top: 56px;">
|
||
<button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light"
|
||
data-toggle="modal" data-target="#con-close-modal" data-placement="top" title="Add"
|
||
data-trigger="hover">ADD</button>
|
||
</div>
|
||
</div>
|
||
<table class="table table-sm table-hover m-0 table-centered dt-responsive w-100" cellspacing="0"
|
||
id="tickets-table">
|
||
<thead class="bg-light">
|
||
<tr>
|
||
<th class="font-weight-medium">Client Name</th>
|
||
<th class="font-weight-medium">Insurer Name</th>
|
||
<th class="font-weight-medium">Opening Date</th>
|
||
<th class="font-weight-medium">CD Account No</th>
|
||
<th class="font-weight-medium">Opening Amount</th>
|
||
<th class="font-weight-medium">Date/User</th>
|
||
<th class="font-weight-medium">Action</th>
|
||
</tr>
|
||
</thead>
|
||
|
||
<tbody>
|
||
<?php foreach($CD_Master_Data as $row){ ?>
|
||
<tr>
|
||
<td><?php echo $row['client_name']; ?>( <?= $row['short_name'] ?> )</td>
|
||
<td><?php echo $row['insurer_name']; ?></td>
|
||
<td><?php echo date('d-m-Y', strtotime($row['opening_date'])); ?></td>
|
||
<td><?php echo $row['cd_ac_no']; ?></td>
|
||
<td><?php echo $row['opening_bal']; ?></td>
|
||
<td><?php echo date('d-M-Y h:i A', strtotime($row['created_at'])) ?> by
|
||
<?php echo $row['user_name']; ?></td>
|
||
<td>
|
||
<?php if($row['cd_ac_no_count'] > 0 && $row['cd_ac_no_count_cd_tranction'] > 1) {?>
|
||
<div class="btn-group dropdown">
|
||
<!-- <a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm"aria-expanded="false"></i></a> -->
|
||
</div>
|
||
<?php } else { ?>
|
||
|
||
<div class="btn-group dropdown">
|
||
<a href="javascript: void(0);"class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
|
||
<div class="dropdown-menu dropdown-menu-right">
|
||
<?php if($row['cd_ac_no_count_cd_tranction'] <= 1) { ?>
|
||
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-toggle="modal" data-target="#con-close-modal"> <i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||
<?php } ?>
|
||
<?php if($row['cd_ac_no_count'] == 0) { ?>
|
||
<a class="dropdown-item" data-id="<?= $row['id'];?>" onclick="removeCDMaster(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
|
||
<?php } ?>
|
||
</div>
|
||
</div>
|
||
|
||
<?php } ?>
|
||
</td>
|
||
</tr>
|
||
<?php } ?>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</div><!-- end col -->
|
||
</div>
|
||
<!-- end row -->
|
||
|
||
|
||
<!-- modal content -->
|
||
|
||
<div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
|
||
aria-hidden="true" data-backdrop="static" style="display: none;">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<h4 class="modal-title" id="title">Add Opening Amount</h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
</div>
|
||
|
||
<div class="modal-body p-4">
|
||
<div class="">
|
||
|
||
<form role="form" class="parsley-examples" method="post" id="CDMasterForm" action=""
|
||
enctype="multipart/form-data">
|
||
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
|
||
<input type="hidden" name="PrimaryKey" id="CD_Master_ID" />
|
||
<div class="form-group">
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="emp_code">Client<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="client_id" name="client_id" required>
|
||
<option value="">Select Client</option>
|
||
<?php foreach($clients as $value) { ?>
|
||
<option value="<?= $value['id'] ?>"><?= $value['client_name'] ?></option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="profile">Insurer<span class="text-danger">*</span></label>
|
||
<select class="form-control" id="insurer_id" name="insurer_id" required>
|
||
<option value="">Select Insurer</option>
|
||
<?php foreach($insurers as $value) { ?>
|
||
<option value="<?= $value['id'] ?>"><?= $value['name'] ?></option>
|
||
<?php } ?>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="email">Opening Date<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" name="opening_date" id="opening_date" required>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="mobile">CD Account Number<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="cd_ac_no" name="cd_ac_no" required>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div class="form-row">
|
||
<div class="form-group col-md-12">
|
||
<label for="mobile">Opening Amount<span class="text-danger">*</span></label>
|
||
<input type="text" class="form-control" id="opening_bal" name="opening_bal" onkeypress="return onlyNumbers(event)" required>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<div class="form-group text-right m-b-0">
|
||
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
|
||
id="btnSubmit">Submit</button>
|
||
<!-- <button type="button" class="btn btn-secondry waves-effect waves-light mr-1" data-dismiss="modal" aria-hidden="true">Close</button> -->
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div><!-- /.modal -->
|
||
|
||
|
||
<script>
|
||
$(document).ready(function() {
|
||
|
||
$('#tickets-table').DataTable({
|
||
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
|
||
"<'row'<'col-sm-12'tr>>" +
|
||
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
|
||
buttons: [{
|
||
extend: 'csv',
|
||
text: 'CSV',
|
||
title: 'CD-Master-List',
|
||
className: 'my_class',
|
||
exportOptions: {
|
||
columns: ':not(:last-child)'
|
||
},
|
||
}],
|
||
language: {
|
||
search: "_INPUT_",
|
||
searchPlaceholder: "Search..."
|
||
},
|
||
paging: true,
|
||
});
|
||
|
||
})
|
||
|
||
|
||
$(document).ready(function(){
|
||
|
||
<?php if (session()->has('error')) : ?>
|
||
toastr.error('<?= session()->getFlashdata('error') ?>', 'Failed');
|
||
<?php endif; ?>
|
||
|
||
<?php if (session()->has('success')) : ?>
|
||
toastr.success('<?= session()->getFlashdata('success') ?>', 'success');
|
||
<?php endif; ?>
|
||
|
||
var endDatePicker = flatpickr("#opening_date", {
|
||
dateFormat: "d-m-Y",
|
||
// defaultDate: endDate,
|
||
allowInput: false
|
||
});
|
||
|
||
$('#client_id').select2();
|
||
$('#insurer_id').select2();
|
||
|
||
})
|
||
|
||
|
||
$('#btnAdd').click(function(){
|
||
$('#client_id').val('');
|
||
$('#insurer_id').val('');
|
||
$('#opening_date').val('');
|
||
$('#cd_ac_no').val('');
|
||
$('#opening_bal').val('');
|
||
$('#CDMasterForm').attr('action', '<?php echo base_url('master/cash_deposite/create');?>');
|
||
$('#title').html('Add Opening Amount');
|
||
$('#btnSubmit').html('Submit');
|
||
|
||
|
||
})
|
||
|
||
|
||
$('.close').click(function(){
|
||
$('#CD_Master_ID').val('');
|
||
$('#client_id').val('').change();
|
||
$('#insurer_id').val('').change();
|
||
$('#opening_date').val('');
|
||
$('#cd_ac_no').val('');
|
||
$('#opening_bal').val('');
|
||
$('#CDMasterForm')[0].reset();
|
||
$('#CDMasterForm').parsley().reset();
|
||
$('#client_id').prop("disabled", false);
|
||
$('#insurer_id').prop("disabled", false);
|
||
$('#cd_ac_no').prop("disabled", false);
|
||
|
||
})
|
||
|
||
|
||
$('body').on('click', '.btnEdit', function () {
|
||
|
||
var cd_id = $(this).attr('data-id');
|
||
$('#title').html('Update Opening Amount');
|
||
|
||
$.ajax({
|
||
url: '<?php echo base_url('master/cash_deposite/list/');?>'+cd_id,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
|
||
console.log(res)
|
||
|
||
$('#updateModal').modal('show');
|
||
$('#CDMasterForm').attr('action', '<?php echo base_url('master/cash_deposite/edit');?>');
|
||
$('#CD_Master_ID').val(res.data.id);
|
||
$('#client_id').val(res.data.client_id).change();
|
||
$('#client_id').prop("disabled", true);
|
||
$('#insurer_id').val(res.data.insurer_id).change();
|
||
$('#insurer_id').prop("disabled", true);
|
||
$('#opening_date').val(res.data.opening_date);
|
||
$('#cd_ac_no').val(res.data.cd_ac_no);
|
||
$('#cd_ac_no').prop("disabled", true);
|
||
$('#opening_bal').val(res.data.opening_bal);
|
||
$('#btnSubmit').html('Update');
|
||
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
});
|
||
|
||
|
||
$('#cd_ac_no').change(function(){
|
||
|
||
var cd_ac_no = $(this).val();
|
||
console.log(cd_ac_no +'-'+cd_ac_no.length);
|
||
cd_ac_no = cd_ac_no.trim();
|
||
console.log(cd_ac_no +'-'+cd_ac_no.length);
|
||
|
||
|
||
$.ajax({
|
||
url: '<?php echo base_url('util/check_cd_ac_no/');?>'+cd_ac_no,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
success: function (res) {
|
||
|
||
console.log(res)
|
||
if(res.status == true){
|
||
toastr.warning(res.message, 'warning');
|
||
$('#cd_ac_no').val('');
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
}
|
||
});
|
||
|
||
})
|
||
|
||
|
||
function removeCDMaster(element) {
|
||
|
||
Swal.fire({
|
||
title: "Are you sure?",
|
||
text: "You need to remove this CD.",
|
||
icon: "info",
|
||
showCancelButton: true,
|
||
confirmButtonColor: "#3085d6",
|
||
confirmButtonText: "Yes",
|
||
}).then((result) => {
|
||
|
||
if (result.isConfirmed) {
|
||
var id = element.getAttribute('data-id');
|
||
var form_action = '<?= base_url("master/cash_deposite/remove/") ?>' + id;
|
||
$.ajax({
|
||
url: form_action,
|
||
type: "GET",
|
||
dataType: 'json',
|
||
processData: false,
|
||
contentType: false,
|
||
success: function(res) {
|
||
// console.log(res.status == true);
|
||
if(res){
|
||
if (res.status == true) {
|
||
toastr.success('CD removed successfully.', 'success');
|
||
location.reload();
|
||
} else {
|
||
toastr.warning('Failed to remove CD.', 'warning');
|
||
}
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error(xhr.responseText);
|
||
console.error(status, error);
|
||
$('.loader').fadeOut();
|
||
$('.loader-mask').delay(350).fadeOut('slow');
|
||
console.log('Something Wrong!', 'warning');
|
||
}
|
||
});
|
||
}
|
||
|
||
});
|
||
|
||
}
|
||
|
||
|
||
function onlyNumbers(event) {
|
||
var charcode;
|
||
charcode = event.which || event.keyCode;
|
||
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
|
||
return false;
|
||
}
|
||
</script>
|