nhance/app/Views/client_list.php
2024-11-05 20:51:49 +05:30

297 lines
10 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<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;">Client List</h4>
</div>
<div class="col-2" style="text-align: right; position: relative;top: 56px; left: 303px;">
<a class="btn btn-primary waves-effect waves-light" onclick="showModal()">Add From Lead</a>
</div>
<div class="col-1" style="text-align: right; position: relative;top: 56px; left: 294px;">
<a href="<?= base_url("client/create"); ?>" type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" data-toggle="" data-placement="top" title="Add" data-trigger="hover">Add</a>
</div>
</div>
<table class="table table-sm table-hover m-0 table-centered dt-responsive nowrap 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">Account Manager</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php foreach($clientList as $row){ ?>
<tr >
<td class="client_info" data-id="<?php echo $row->id; ?>"><?php echo $row->client_name; ?> ( <?php echo $row->short_name; ?> ) </td>
<td>
<?php $account_managers = ''; ?>
<?php foreach ($client_rm as $client): ?>
<?php if ($client->client_id == $row->id): ?>
<?php $account_managers .= $client->account_manager . ', '; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php echo rtrim($account_managers, ', '); ?>
</td>
<td>
<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">
<a class="dropdown-item" href="<?= base_url("client/list/"); ?><?= $row->id;?>"><i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a class="dropdown-item" href="<?= base_url("client/deposit/{$row->id}"); ?>"><i class="mdi mdi-cash mr-2 text-muted font-18 vertical-middle"></i>CD Transactions</a>
<?php if(get_role_id() != 3 && get_role_id() != 4) { ?>
<a class="dropdown-item" data-id="<?= $row->id;?>" onclick="removeClient(this)"><i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
<?php } ?>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div><!-- end col -->
</div>
<!-- end row -->
<div id="append_client_info"></div>
<!-- Center modal content -->
<div class="modal fade" id="lead_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="false">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myCenterModalLabel">Lead List</h4>
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<div class="form-group col-md-12">
<label for="lead_id"> Lead List <span class="text-danger">*</span></label>
<select class="form-control" id="lead_id" name="lead_id" required>
<option value="">Select Lead</option>
<?php if(isset($lead_data)) { ?>
<?php foreach ($lead_data as $value) { ?>
<option value="<?= $value['id']?>"><?= $value['client_name'] ?></option>
<?php } ?>
<?php } ?>
</select>
</div>
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
<button type="submit" class="btn btn-primary" onclick="featchClient()">Featch Client</button>
</div>
</div>
</div><!-- /.modal-content -->
</div>
</div><!-- /.modal -->
<script>
$(document).ready(function(){
$('#lead_id').select2();
})
$(document).ready(function()
{
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-7 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'ClientList',
className: 'my_class',
exportOptions: {
columns: ':not(:last-child)'
},
}],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true ,
// pagingType: 'full_numbers'
});
})
function removeClient(element)
{
Swal.fire({
title: "Are you sure?",
text: "You need to remove this client.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("client/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res){
if (res.status == true) {
toastr.success('Client removed successfully.', 'success');
location.reload();
} else {
Swal.fire({
title: "warning!",
text: res.message,
icon: "warning"
});
// toastr.warning(res.message, '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');
}
});
}
});
}
$(document).on('click', '.client_info', function() {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var client_id = $(this).data('id')
$('#append_client_info').empty();
console.log(client_id);
console.log('client_info');
$('#client_info').show();
$('#client_list').hide();
$.ajax({
url: "<?= base_url('util/get-client-details/') ?>" + client_id,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log(res);
console.log(res.data.length);
$('#append_client_info').append(res.data);
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
});
$(document).on('click', '.client_info_close', function() {
console.log('client_info_close');
$('#client_info').hide();
$('#client_list').show();
});
function showModal(){
var myModal = new bootstrap.Modal(document.getElementById('lead_modal'));
myModal.show();
}
function featchClient(){
let lead_id = $('#lead_id').val();
console.log('lead_id : ', lead_id)
let url = '<?= base_url('leads/featchLeadDataAndInsertClient/') ?>' + lead_id
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
$.ajax({
url: url,
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
if(res.status == true){
let client_url = '<?= base_url('client/list/') ?>'+res.client_id;
toastr.success(res.message, 'SUCCESS')
window.location.href = client_url
}else{
toastr.success(res.message, 'WARNING')
}
$('.close').click()
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
$('.close').click()
}
});
}
</script>