bb_sign/app/Views/client_list.php

298 lines
12 KiB
PHP
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.

<!-- ============================================================== -->
<!-- Start Page Content here -->
<!-- ============================================================== -->
<div class="content-page">
<!-- 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">Client List</h4>
<div class="page-title-right">
<a id="add_client_button" data-toggle="modal" data-target="#bike_make_login-modal" class="btn btn-primary waves-effect waves-light">
Create Client
</a>
</div>
</div>
</div>
</div>
<!-- end page title -->
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<table id="datatable-buttonss" class="table table-striped dt-responsive nowrap w-100">
<thead>
<tr>
<th>Name</th>
<th>PAN</th>
<th>Mobile</th>
<th>Email</th>
<th>Shared Docs</th>
<th>Status</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($clientList as $key => $value) { ?>
<tr>
<td> <?php echo $value['name']; ?></td>
<td> <?php echo $value['pan_no']; ?></td>
<td><?php echo $value['mobile_no']; ?></td>
<td><?php echo $value['email']; ?></td>
<td><?php echo $value['docs_count']; ?></td>
<td>
<?php if($value['is_active'] == 1): ?>
<span style="color:green">Active</span>
<?php else: ?>
<span style="color:red">Inactive</span>
<?php endif; ?>
</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" data-toggle="modal" data-target="#bike_make_login-modal" value="<?= $value['client_id']; ?>" onclick="editBranch(this)"> <i class='mdi mdi-pencil-outline mr-1' style="margin-right: 16px !important;margin-left: 5px;"></i>Edit</a>
<?php if($value['is_active'] == 1): ?>
<a class="dropdown-item" data-id="<?php echo $value['client_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Deactivate" onclick="statusChange(this)"><i class="ri-shield-user-line"></i><i class="fa fa-times" style="font-size: x-small;margin-right:10px"></i>Deactivate</a>
<?php else: ?>
<a class="dropdown-item" data-id="<?php echo $value['client_id']; ?>" data-isactive="<?php echo $value['is_active']; ?>" title="Activate" onclick="statusChange(this)"><i class="ri-shield-user-line" style="margin-right:10px"></i>Activate</a>
<?php endif; ?>
<a class="dropdown-item" href="<?= base_url()."shared_docs_list?client_id=".$value['client_id']; ?>" > <i class='mdi mdi-file-document-outline mr-1' style="margin-right: 16px !important;margin-left: 5px;"></i>Documents</a>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
</div> <!-- container -->
</div> <!-- content -->
<div id="bike_make_login-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 id="branch_action_type">Add Client</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<form id="model_form_data" class="px-4">
<input type="text" id="business_id" value="" hidden>
<input type="text" id="client_id" value="" hidden>
<input type="text" id="branch_id" hidden>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name">Name</label>
<input class="form-control" name="name" type="text" id="name" required="" placeholder="Name">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="panno">Pan No</label>
<input class="form-control" parsley-trigger="change" name="pan_no" type="text" id="pan_no" required="" placeholder="PAN No" pattern="[A-Z]{5}[0-9]{4}[A-Z]{1}" title="Please enter a valid PAN in the format ABCDE1234F">
<span id="error-message" style="color:red;display:none;">Invalid PAN Number.</span>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="email">Email</label>
<input class="form-control" name="email" type="email" id="email" required="" placeholder="Email">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label for="mobile_no">Mobile No</label>
<input class="form-control" name="mobile_no" type="text" id="mobile_no" required placeholder="Mobile No" pattern="[0-9]{6,16}" minlength="6" maxlength="16" title="Please enter a valid mobile number between 6 and 16 digits">
</div>
</div>
</div>
<div class="form-group text-right">
<button class="btn btn-info waves-effect waves-light" type="submit" onclick="submitBranch(this)">Submit</button>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<!-- ============================================================== -->
<!-- End Page content -->
<!-- ============================================================== -->
<script>
$(document).ready(function() {
$('#datatable-buttonss').DataTable({
"ordering": false
});
});
function submitBranch(params) {
var formData = {
pan_no: $('#pan_no').val(),
email: $('#email').val(),
name: $('#name').val(),
mobile_no: $('#mobile_no').val()
};
if ($('#client_id').val()) {
formData.client_id = $('#client_id').val();
var url = '<?= base_url("client_edit/"); ?>'+$('#client_id').val();
}else{
var url = '<?= base_url("client_create"); ?>';
}
var form = $(params).parent().parent();
// console.log(form);
var isValid = true;
form[0].querySelectorAll('[required]').forEach(function(element) {
if (!element.value.trim()) {
isValid = false;
}
});
if (!isValid) {
return;
}
$.ajax({
type: 'POST',
url: url,
data: formData,
dataType: 'json',
success: function(response) {
console.log(response);
$('#bike_model_login-modal').modal('hide');
window.location.reload();
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
function statusChange(params) {
console.log(params);
var status = params.getAttribute('data-isactive');
var client_id = params.getAttribute('data-id');
if(status == 1){
var is_active= 0;
}else{
var is_active= 1;
}
var formData = {
client_id: client_id,
is_active: is_active
};
$.ajax({
type: 'POST',
url: '<?php echo base_url()."status_client"?>',
data: formData,
dataType: 'json',
success: function(response) {
if (response.data) {
window.location.reload();
}
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
function validatePanNumber() {
var panNumber = document.getElementById("pan_no").value;
var errorMessage = document.getElementById("error-message");
// Example regex: Adjust according to the format you need to validate
var regex = /^[A-Za-z]{5}\d{4}[A-Za-z]$/;
if (regex.test(panNumber)) {
errorMessage.style.display = "none";
} else {
errorMessage.style.display = "inline";
}
}
function editBranch(params) {
$('#branch_action_type').html('Edit Client');
$.ajax({
type: 'GET',
url: '<?= base_url("client_edit/"); ?>' +params.getAttribute('value'),
dataType: 'json',
success: function(response) {
console.log(response);
$('#client_id').val(response.client_id);
$('#name').val(response.name);
$('#pan_no').val(response.pan_no);
$('#email').val(response.email);
$('#mobile_no').val(response.mobile_no);
},
error: function(xhr, status, error) {
// Handle error response here
console.error(xhr.responseText);
}
});
}
$('##bike_make_login-modal').click(function (params) {
$('#branch_action_type').html('Add Client');
})
</script>