CHANGE_STAFF_ADD_BUSINESS_BRANCH : AADHAVAN
This commit is contained in:
parent
9f69987f2f
commit
6d00930f9c
@ -5,6 +5,7 @@ use App\Helpers\MailHelper;
|
||||
use App\Models\StaffModel;
|
||||
use App\Models\ClientModel;
|
||||
use App\Models\ServiceModel;
|
||||
use App\Models\BusinessModel;
|
||||
use App\Models\BranchModel;
|
||||
use App\Models\TemplateModel;
|
||||
|
||||
@ -17,6 +18,8 @@ class StaffController extends BaseController
|
||||
protected $StaffModel;
|
||||
protected $ClientModel;
|
||||
protected $ServiceModel;
|
||||
|
||||
protected $BusinessModel;
|
||||
protected $BranchModel;
|
||||
protected $TemplateModel;
|
||||
|
||||
@ -28,6 +31,7 @@ class StaffController extends BaseController
|
||||
$this->StaffModel = new StaffModel();
|
||||
$this->ClientModel = new ClientModel();
|
||||
$this->ServiceModel = new ServiceModel();
|
||||
$this->BusinessModel = new BusinessModel();
|
||||
$this->BranchModel = new BranchModel();
|
||||
$this->TemplateModel = new TemplateModel();
|
||||
}
|
||||
@ -100,8 +104,9 @@ class StaffController extends BaseController
|
||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||
|
||||
|
||||
$data['staffList'] = $this->StaffModel->where('staff.staff_id != ',session()->get('is_staff_logged_in') )->where('branch_id',$this->session->get('logged_in_staff_branch_id'))->findAll();
|
||||
|
||||
$data['staffList'] = $this->StaffModel->getStaffWithBusinessAndBranch(session()->get('is_staff_logged_in'), $this->session->get('logged_in_staff_branch_id'));
|
||||
|
||||
|
||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||
echo view('layout/header', ['Data'=>$staffdata]);
|
||||
echo view('staff_list',$data);
|
||||
@ -114,8 +119,9 @@ class StaffController extends BaseController
|
||||
if($this->request->getmethod() == 'POST')
|
||||
{
|
||||
$staffData = $this->request->getVar();
|
||||
// print_r($staffData);die;
|
||||
$staffData['created_by'] = $this->session->get('is_staff_logged_in');
|
||||
$staffData['branch_id'] = $this->session->get('logged_in_staff_branch_id');
|
||||
// $staffData['branch_id'] = $this->session->get('logged_in_staff_branch_id');
|
||||
$insert = $this->StaffModel->save($staffData);
|
||||
if($insert)
|
||||
{
|
||||
@ -125,8 +131,11 @@ class StaffController extends BaseController
|
||||
}else{
|
||||
|
||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||
$data['business'] = $this->BusinessModel->where('isactive', 1)->findAll();
|
||||
$data['branch'] = $this->BranchModel->where('isactive', 1)->findAll();
|
||||
$data['page_heading'] = "Create Staff";
|
||||
echo view('layout/header', ['Data'=>$staffdata]);
|
||||
echo view('staff_form');
|
||||
echo view('staff_form', $data);
|
||||
echo view('layout/footer');
|
||||
}
|
||||
}
|
||||
@ -146,8 +155,10 @@ class StaffController extends BaseController
|
||||
|
||||
$data['staffData'] = $this->StaffModel->where('md5(staff.staff_id)', $this->request->getVar('staff_id') )->get()->getRow();
|
||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||
|
||||
echo view('layout/header', ['Data'=>$staffdata]);
|
||||
$data['business'] = $this->BusinessModel->where('isactive', 1)->findAll();
|
||||
$data['branch'] = $this->BranchModel->where('isactive', 1)->findAll();
|
||||
$data['page_heading'] = "Edit Staff";
|
||||
echo view('layout/header', ['Data'=>$staffdata]);
|
||||
echo view('staff_form',$data);
|
||||
echo view('layout/footer');
|
||||
|
||||
|
||||
@ -43,5 +43,21 @@ class StaffModel extends Model
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getStaffWithBusinessAndBranch($is_staff_logged_in, $logged_in_staff_branch_id) {
|
||||
$query = $this->db->table('staff')
|
||||
->select('staff.*, business.business_name AS business_name, branches.branch_name AS branch_name')
|
||||
->join('business', 'business.business_id = staff.business_id')
|
||||
->join('branches', 'branches.branch_id = staff.branch_id')
|
||||
->where('staff.staff_id != ', $is_staff_logged_in)
|
||||
->where('staff.branch_id', $logged_in_staff_branch_id);
|
||||
|
||||
// Execute the query and fetch results as an array
|
||||
$result = $query->get()->getResultArray();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -97,7 +97,8 @@
|
||||
<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>
|
||||
<div class="modal-header">
|
||||
<h4 id="branch_type">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">
|
||||
@ -230,7 +231,9 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
$('#add_branch_model_open').click(function () {
|
||||
$('#branch_type').html('Create Branch');
|
||||
})
|
||||
|
||||
function submitBranch(params) {
|
||||
|
||||
@ -289,6 +292,7 @@
|
||||
|
||||
|
||||
function editBranch(params) {
|
||||
$('#branch_type').html('Edit Branch');
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '<?= base_url("get_client_branch/"); ?>' +params.getAttribute('value'),
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
<!-- Start Page Content here -->
|
||||
<!-- ============================================================== -->
|
||||
|
||||
|
||||
<div class="content-page">
|
||||
<!-- Start Content-->
|
||||
<div class="container-fluid">
|
||||
@ -10,7 +11,7 @@
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
<h4 class="page-title">Create Staff</h4>
|
||||
<h4 class="page-title"><?php echo $page_heading; ?></h4>
|
||||
|
||||
<div class="page-title-right">
|
||||
<button type="reset" onclick="window.history.back()" class="btn btn-secondary waves-effect">
|
||||
@ -34,7 +35,7 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
|
||||
<h5 class="mb-3 text-uppercase bg-light p-2"><i class="mdi mdi-account-circle mr-1"></i> Personal Info</h5>
|
||||
<h5 class="mb-3 text-uppercase bg-light p-2"><i class="mdi mdi-account-circle mr-1"></i> Personal Info</h5>
|
||||
|
||||
<form method="post"
|
||||
<?php if(isset($staffData)){ ?> action="<?= base_url()."staff_edit"; ?>"
|
||||
@ -48,6 +49,30 @@
|
||||
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="business">Business<span class="text-danger">*</span></label>
|
||||
<select class="form-control business slect2_dropdown" id="business_id" name="business_id" parsley-trigger="change" required >
|
||||
<option >Select Business</option>
|
||||
<?php foreach ($business as $key => $value) { ?>
|
||||
<option value="<?php echo $value['business_id']; ?>" <?php if(isset($staffData)){ echo ($staffData->business_id == $value['business_id']) ? 'selected' : '';} ?>>
|
||||
<?php echo $value['business_name']; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="branch">Branch<span class="text-danger">*</span></label>
|
||||
<select class="form-control branch slect2_dropdown" id="branch_id" name="branch_id" parsley-trigger="change" required >
|
||||
<option >Select Branch</option>
|
||||
<?php if(isset($staffData)){ foreach ($branch as $key => $value) { ?>
|
||||
<option value="<?php echo $value['branch_id']; ?>" <?php echo ($staffData->branch_id == $value['branch_id']) ? 'selected' : ''; ?>>
|
||||
<?php echo $value['branch_name']; ?>
|
||||
</option>
|
||||
<?php }} ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group col-md-1">
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="role">Role<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="selectize-select" name="role" id="role" parsley-trigger="change" required >
|
||||
@ -154,6 +179,57 @@
|
||||
|
||||
</div> <!-- content -->
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function() {
|
||||
// $('.slect2_dropdown').select2();
|
||||
// $('.branch').select2();
|
||||
});
|
||||
|
||||
$('#business_id').change(function (params) {
|
||||
var business_id = $(params.target).val();
|
||||
if (business_id) {
|
||||
var branch_list = <?php echo json_encode($branch); ?>;
|
||||
|
||||
// Clear existing options or elements if needed
|
||||
// $('.branch').empty(); // Clear previous options
|
||||
|
||||
// Filter branch_list based on business_id
|
||||
var filteredBranches = branch_list.filter(function(element) {
|
||||
return element.business_id == business_id;
|
||||
});
|
||||
|
||||
// $('.branch').append("<option>Select Branch</option>");
|
||||
// Append filtered branches to the select dropdown or another container
|
||||
// filteredBranches.forEach(function(branch) {
|
||||
$('#branch_id').empty();
|
||||
$('#branch_id option:not(:first)').remove();
|
||||
|
||||
$('#branch_id').append($('<option>', {
|
||||
text: "Select Branch"
|
||||
}));
|
||||
$.each(filteredBranches, function(index, item) {
|
||||
console.log(item);
|
||||
$('#branch_id').append($('<option>', {
|
||||
value: item.branch_id,
|
||||
text: item.branch_name
|
||||
}));
|
||||
});
|
||||
// Create an <option> element for each branch
|
||||
// var option = $('<option>').val(branch.branch_id).text(branch.branch_name);
|
||||
|
||||
// Append the option to the select dropdown
|
||||
// $('.branch').append(option);
|
||||
// });
|
||||
|
||||
// Optional: Trigger change event after appending options
|
||||
// $('.branch').trigger('change');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Business And Branch</th>
|
||||
<th>Email</th>
|
||||
<th>Mobile</th>
|
||||
<th>Role</th>
|
||||
@ -47,6 +48,7 @@
|
||||
|
||||
<tr>
|
||||
<td> <?php echo $value['name']; ?></td>
|
||||
<td><?php echo $value['business_name']; ?> - <?php echo $value['branch_name']; ?></td>
|
||||
<td><?php echo $value['email']; ?></td>
|
||||
<td><?php echo $value['mobile_no']; ?></td>
|
||||
<td><?php echo $value['role']; ?></td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user