290 lines
12 KiB
PHP
290 lines
12 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">Branch List - <?php echo $business_name;?></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>Branch Name</th>
|
|
<th>GST</th>
|
|
<th>Address</th>
|
|
<th>City</th>
|
|
<th>State</th>
|
|
<th>Postal Code</th>
|
|
<th>Contact</th>
|
|
<th>Active</th>
|
|
<!-- <th>User List</th> -->
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
|
|
<?php foreach ($branch as $value) :
|
|
?>
|
|
<tr>
|
|
<td><?= $value['branch_name']; ?></td>
|
|
<td><?= $value['gstno']; ?></td>
|
|
<td><?= $value['address']; ?></td>
|
|
<td><?= $value['city']; ?></td>
|
|
<td><?= $value['state']; ?></td>
|
|
<td><?= $value['postal_code']; ?></td>
|
|
<td><?= $value['contact_1']; ?></td>
|
|
<td>
|
|
<?php if ($value['isactive'] == 0): ?>
|
|
<span style="color: red;">Inactive</span>
|
|
<?php else: ?>
|
|
<span style="color: green;">Active</span>
|
|
<?php endif; ?>
|
|
</td>
|
|
<!-- <td>
|
|
<a href="<?= base_url("user_list/" . $value['branch_id']) ?>" style="margin-left: 15px;">View</a>
|
|
</td> -->
|
|
<td>
|
|
|
|
<a data-toggle="modal" data-target="#bike_make_login-modal" value="<?= $value['branch_id']; ?>" onclick="editBranch(this)" class="edit-button"><i
|
|
class="ri-pencil-line" style="margin-right: 5px;"></i></a>
|
|
|
|
<a href="<?= base_url("delete_branch/".$value['branch_id']); ?>"
|
|
class="delete-button"><i class="ri-delete-bin-line"></i></a>
|
|
</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" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-body">
|
|
<div class="text-center mt-2 mb-4">
|
|
<h4>Add Branch - <?php echo $business_name;?></h4>
|
|
</div>
|
|
<form id="model_form_data" class="px-4">
|
|
|
|
<input type="text" id="business_id" value="<?php echo $business_id; ?>" hidden>
|
|
<input type="text" id="branch_id" hidden>
|
|
|
|
<div class="row">
|
|
<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="contact1">Contact 1</label>
|
|
<input class="form-control" name="contact_1" type="text" id="contact_1" required="" minlength="6" maxlength="16" placeholder="Contact 1">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="contact2">Contact 2</label>
|
|
<input class="form-control" name="contact_2" type="text" id="contact_2" required="" minlength="6" maxlength="16" placeholder="Contact 2">
|
|
</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" required="" placeholder="State">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="pincode">Country</label>
|
|
<input class="form-control" name="country" type="text" 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 class="col-md-6">
|
|
<div class="form-group">
|
|
<label for="statecode">State Code</label>
|
|
<input class="form-control" name="state_code" type="text" id="state_code" required="" placeholder="State Code">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group text-center">
|
|
<button class="btn btn-rounded btn-primary" type="submit" onclick="submitBranch(this)">Submit</button>
|
|
</div>
|
|
|
|
</form>
|
|
</div>
|
|
</div><!-- /.modal-content -->
|
|
</div><!-- /.modal-dialog -->
|
|
</div><!-- /.modal -->
|
|
|
|
|
|
|
|
<!-- ============================================================== -->
|
|
<!-- End Page content -->
|
|
<!-- ============================================================== -->
|
|
|
|
|
|
<script>
|
|
|
|
function submitBranch(params) {
|
|
|
|
if ($('#branch_id').val()) {
|
|
var url = '<?= base_url("edit_branch/"); ?>'+$('#branch_id').val();
|
|
}else{
|
|
var url = '<?= base_url("add_branch/".$business_id); ?>';
|
|
}
|
|
|
|
var formData = {
|
|
gstno: $('#gst_no').val(),
|
|
email: $('#email').val(),
|
|
contact_1: $('#contact_1').val(),
|
|
contact_2: $('#contact_2').val(),
|
|
country: $('#country').val(),
|
|
state_code: $('#state_code').val(),
|
|
branch_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();
|
|
// console.log(formData);
|
|
|
|
$.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_branch/"); ?>' +params.getAttribute('value'),
|
|
dataType: 'json',
|
|
success: function(response) {
|
|
// console.log(response);
|
|
$('#branch_name').val(response.branch_name);
|
|
$('#gst_no').val(response.gstno);
|
|
$('#email').val(response.email);
|
|
$('#contact_1').val(response.contact_1);
|
|
$('#contact_2').val(response.contact_2);
|
|
$('#address').val(response.address);
|
|
$('#branch_id').val(response.branch_id);
|
|
$('#city').val(response.city);
|
|
$('#postal_code').val(response.postal_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);
|
|
}
|
|
});
|
|
}
|
|
|
|
$('#add_branch_model_open').click( function(){
|
|
$('#model_form_data')[0].reset();
|
|
})
|
|
|
|
</script>
|