bb_sign/app/Views/branch_list.php

310 lines
14 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">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>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>
<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['branch_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_branch/".$value['branch_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" 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 Branch</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="branch_id" hidden>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="branchname">Business</label>
<select name="business" id="business" class="form-control">
<option value="0">Select Business</option>
<?php foreach ($business_list as $key => $value) { ?>
<option value="<?php echo $value['business_id'] ?>"><?php echo $value['business_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="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" value="Tamil Nadu" 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" value="India" 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>
<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() {
$('#business').select2();
});
function submitBranch(params) {
if ($('#branch_id').val()) {
var url = '<?= base_url("edit_branch/"); ?>'+$('#branch_id').val();
}else{
var url = '<?= base_url("add_branch"); ?>';
}
var formData = {
business_id: $('#business').val(),
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) {
$('#branch_action_type').html('Edit Branch');
$.ajax({
type: 'GET',
url: '<?= base_url("get_branch/"); ?>' +params.getAttribute('value'),
dataType: 'json',
success: function(response) {
// console.log(response);
$('#business').val(response.business_id);
$('#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(){
$('#branch_action_type').html('Add Branch');
$('#model_form_data')[0].reset();
})
</script>