175 lines
7.0 KiB
PHP
175 lines
7.0 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">Business List</h4>
|
|
<div class="page-title-right">
|
|
<!-- <a href="#" id="add_branch_model_open" data-toggle="modal" data-target="#bike_make_login-modal" class="btn btn-primary waves-effect"> -->
|
|
|
|
<a href="<?= base_url('new_business/0'); ?>" class="btn btn-primary waves-effect waves-light">
|
|
Create Business
|
|
</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>#</th>
|
|
<th>Business Name</th>
|
|
<th>Status</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
|
|
|
|
<tbody>
|
|
|
|
<?php foreach ($business as $value) :
|
|
?>
|
|
<tr>
|
|
<td><?= $value['business_id']; ?></td>
|
|
<td><?= $value['business_name']; ?></td>
|
|
<td>
|
|
<?php if($value['isactive'] == 1): ?>
|
|
<span style="color:green">Active</span>
|
|
<?php else: ?>
|
|
<span style="color:red">Inactive</span>
|
|
<?php endif; ?>
|
|
</td>
|
|
<!-- Call the model method -->
|
|
<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 href="<?= "new_business/" . $value['business_id']; ?>" class="edit-button dropdown-item" >
|
|
<i class="ri-pencil-line" style="margin-right: 16px !important;margin-left: 5px;"></i>Edit
|
|
</a>
|
|
|
|
<?php if($value['isactive'] == 1): ?>
|
|
<a class="dropdown-item" data-id="<?php echo $value['business_id']; ?>" data-isactive="<?php echo $value['isactive']; ?>" title="Deactivate" onclick="statusChange(this)"><i class="fas fa-building"></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['business_id']; ?>" data-isactive="<?php echo $value['isactive']; ?>" title="Activate" onclick="statusChange(this)"><i class="fas fa-building" style="margin-right:10px"></i>Activate</a>
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
</div>
|
|
</td>
|
|
|
|
<?php endforeach; ?>
|
|
</tr>
|
|
|
|
|
|
</tbody>
|
|
</table>
|
|
|
|
</div> <!-- end card body-->
|
|
</div> <!-- end card -->
|
|
</div><!-- end col-->
|
|
</div>
|
|
|
|
|
|
|
|
</div> <!-- container -->
|
|
|
|
</div> <!-- content -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- ============================================================== -->
|
|
<!-- End Page content -->
|
|
<!-- ============================================================== -->
|
|
|
|
|
|
<script>
|
|
|
|
function statusChange(params) {
|
|
var status = params.getAttribute('data-isactive');
|
|
var business_id = params.getAttribute('data-id');
|
|
if(status == 1){
|
|
var isactive= 0;
|
|
}else{
|
|
var isactive= 1;
|
|
}
|
|
|
|
var formData = {
|
|
business_id: business_id,
|
|
isactive: isactive
|
|
};
|
|
console.log(formData);
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
url: '<?php echo base_url()."status_business"?>',
|
|
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 editbusiness(params) {
|
|
$('#business_type').html('Edit Business');
|
|
$.ajax({
|
|
type: 'GET',
|
|
url: '<?= base_url("get_business/"); ?>' +params.getAttribute('value'),
|
|
dataType: 'json',
|
|
success: function(response) {
|
|
$('#business_name').val(response.business_name);
|
|
$('#business_id').val(response.business_id);
|
|
|
|
$('#letter_header').val(response.letter_header);
|
|
// Update image preview
|
|
if (response.logo && response.logo !== "") {
|
|
$('#uploadPreview').attr('src', '<?= base_url() ?>public/uploads/' + response.logo);
|
|
} else {
|
|
$('#uploadPreview').attr('src', '<?= base_url() ?>public/assets/images/avatar_2x.png');
|
|
}
|
|
},
|
|
error: function(xhr, status, error) {
|
|
// Handle error response here
|
|
console.error(xhr.responseText);
|
|
}
|
|
});
|
|
}
|
|
|
|
$('#add_branch_model_open').click(function () {
|
|
$('#model_form_data').trigger('reset');
|
|
$('#business_type').html('Add Business');
|
|
$('#uploadPreview').attr('src', '<?= base_url() ?>public/assets/images/avatar_2x.png');
|
|
})
|
|
|
|
|
|
|
|
</script>
|