283 lines
13 KiB
PHP
283 lines
13 KiB
PHP
<!-- ============================================================== -->
|
||
<!-- 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 Branch List</h4>
|
||
<div class="page-title-right">
|
||
<ol class="breadcrumb m-0">
|
||
<li class=""> <a href="#" id="add_branch_model_open" data-toggle="modal" data-target="#bike_make_login-modal" class="btn btn-primary waves-effect">
|
||
Add Branch
|
||
</a>
|
||
</ol>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<!-- end page title -->
|
||
|
||
|
||
<div class="row">
|
||
<div class="col-12">
|
||
<div class="card">
|
||
<div class="card-body">
|
||
|
||
|
||
<table id="datatable-buttons" class="table table-striped dt-responsive nowrap w-100">
|
||
<thead>
|
||
<tr>
|
||
<th>Client</th>
|
||
<th>Branch Name</th>
|
||
<th>GST No</th>
|
||
<th>Address</th>
|
||
<th>City</th>
|
||
<th>State</th>
|
||
<th>Postal Code</th>
|
||
<th>Mobile No</th>
|
||
<th>Active</th>
|
||
<th>Action</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<?php foreach ($clientBranchList as $value) :?>
|
||
<tr>
|
||
<td><?= $value['client_name']; ?></td>
|
||
<td><?= $value['name']; ?></td>
|
||
<td><?= $value['gst_no']; ?></td>
|
||
<td><?= $value['address']; ?></td>
|
||
<td><?= $value['city']; ?></td>
|
||
<td><?= $value['state']; ?></td>
|
||
<td><?= $value['pin_code']; ?></td>
|
||
<td><?= $value['mobile_no']; ?></td>
|
||
<td>
|
||
<?php if ($value['is_active'] == 0): ?>
|
||
<span style="color: red;">Inactive</span>
|
||
<?php else: ?>
|
||
<span style="color: green;">Active</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 data-toggle="modal" data-target="#bike_make_login-modal" value="<?= $value['id']; ?>" onclick="editBranch(this)" class="edit-button dropdown-item"><i
|
||
class="ri-pencil-line" style="margin-right: 16px !important;margin-left: 5px;"></i>Edit</a>
|
||
<a href="<?= base_url("delete_client_branch/".$value['id']); ?>"
|
||
class="delete-button dropdown-item"><i style="margin-right: 16px !important;margin-left: 5px;" class="ri-delete-bin-line"></i>Delete</a>
|
||
</div>
|
||
</div>
|
||
</td>
|
||
<?php endforeach; ?>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
</div> <!-- end card body-->
|
||
</div> <!-- end card -->
|
||
</div><!-- end col-->
|
||
</div>
|
||
|
||
|
||
|
||
</div> <!-- container -->
|
||
|
||
</div> <!-- content -->
|
||
|
||
|
||
<div id="bike_make_login-modal" aria-hidden="true" aria-modal="true" data-backdrop="static" 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>Add Branch </h4>
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button></div>
|
||
<div class="modal-body" style="margin-top: -29px;">
|
||
<div class="text-center mt-2 mb-4">
|
||
</div>
|
||
<form id="model_form_data" class="px-4">
|
||
|
||
<input type="text" id="business_id" value="" hidden>
|
||
<input type="text" id="branch_id" hidden>
|
||
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="form-group">
|
||
<label for="client">Client</label>
|
||
<select name="client" id="client" class="form-control" style="width: auto;">
|
||
<option value="0">Select Client</option>
|
||
<?php foreach ($client_list as $key => $value) { ?>
|
||
<option value="<?php echo $value['client_id']; ?>"><?php echo $value['name']; ?></option>
|
||
<?php } ?>
|
||
</select>
|
||
|
||
</div>
|
||
</div>
|
||
<div class="col-md-6">
|
||
<div class="form-group">
|
||
<label for="branchname">Branch Name</label>
|
||
<input class="form-control" name="branch_name" type="text" id="branch_name" required="" placeholder="Branch Name">
|
||
</div>
|
||
</div>
|
||
|
||
<div class="col-md-6">
|
||
<div class="form-group">
|
||
<label for="gstno">GST No</label>
|
||
<input class="form-control" name="gst_no" type="text" id="gst_no" required="" placeholder="GST No" pattern="[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[0-9]{1}[Z]{1}[0-9A-Z]{1}">
|
||
</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="" minlength="6" maxlength="16" placeholder="Mobile No">
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="form-group">
|
||
<label for="address">Address</label>
|
||
<input class="form-control" name="address" type="text" id="address" required="" placeholder="Address">
|
||
</div>
|
||
</div>
|
||
<div class="col-md-6">
|
||
<div class="form-group">
|
||
<label for="city">City</label>
|
||
<input class="form-control" name="city" type="text" id="city" required="" placeholder="City">
|
||
</div>
|
||
</div>
|
||
<div class="col-md-6">
|
||
<div class="form-group">
|
||
<label for="state">State</label>
|
||
<input class="form-control" name="state" type="text" id="state" value="Tamil Nadu" required="" placeholder="State">
|
||
</div>
|
||
</div>
|
||
<div class="col-md-6">
|
||
<div class="form-group">
|
||
<label for="country">Country</label>
|
||
<input class="form-control" name="country" type="text" value="India" id="country" required="" placeholder="Country">
|
||
</div>
|
||
</div>
|
||
<div class="col-md-6">
|
||
<div class="form-group">
|
||
<label for="pincode">Pin Code</label>
|
||
<input class="form-control" name="postal_code" type="text" id="postal_code" required="" placeholder="Postal Code">
|
||
</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 -->
|
||
|
||
|
||
<script>
|
||
|
||
$(document).ready(function() {
|
||
$('#client').select2();
|
||
});
|
||
|
||
function submitBranch(params) {
|
||
|
||
if ($('#branch_id').val()) {
|
||
var url = '<?= base_url("edit_client_branch/"); ?>'+$('#branch_id').val();
|
||
}else{
|
||
var url = '<?= base_url("add_client_branch"); ?>';
|
||
}
|
||
|
||
var formData = {
|
||
client_id: $('#client').val(),
|
||
gst_no: $('#gst_no').val(),
|
||
email: $('#email').val(),
|
||
contact: $('#contact').val(),
|
||
country: $('#country').val(),
|
||
state_code: $('#state_code').val(),
|
||
name: $('#branch_name').val(),
|
||
address: $('#address').val(),
|
||
city: $('#city').val(),
|
||
state: $('#state').val(),
|
||
postal_code: $('#postal_code').val(),
|
||
mobile_no: $('#mobile_no').val()
|
||
};
|
||
|
||
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;
|
||
}
|
||
var business_id = $('#business_id').val();
|
||
|
||
$.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 editBranch(params) {
|
||
$.ajax({
|
||
type: 'GET',
|
||
url: '<?= base_url("get_client_branch/"); ?>' +params.getAttribute('value'),
|
||
dataType: 'json',
|
||
success: function(response) {
|
||
console.log(response);
|
||
$('#client').val(response.client_id);
|
||
$('#branch_name').val(response.name);
|
||
$('#gst_no').val(response.gst_no);
|
||
$('#email').val(response.email);
|
||
$('#mobile_no').val(response.mobile_no);
|
||
$('#address').val(response.address);
|
||
$('#branch_id').val(response.branch_id);
|
||
$('#city').val(response.city);
|
||
$('#postal_code').val(response.pin_code);
|
||
$('#state').val(response.state);
|
||
$('#country').val(response.country);
|
||
$('#state_code').val(response.state_code);
|
||
|
||
},
|
||
error: function(xhr, status, error) {
|
||
// Handle error response here
|
||
console.error(xhr.responseText);
|
||
}
|
||
});
|
||
}
|
||
</script>
|
||
|
||
|