CHANGE_ADMIN_LOGIN_BUSINESS_SELECT_DROPDOWN : AADHAVAN

This commit is contained in:
aadhavan valli 2024-07-04 17:24:17 +05:30
parent 24ff1f0586
commit 731568ac44
7 changed files with 280 additions and 100 deletions

View File

@ -31,6 +31,8 @@ class BusinessController extends BaseController
public function business_list()
{
$data['business'] = $this->BusinessModel->findAll();
$data['business_list'] = $this->BusinessModel->findAll();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
echo view('layout/header', ['Data'=>$staffdata]);
echo view('business_list',$data);
@ -48,6 +50,8 @@ class BusinessController extends BaseController
$data['page_name']="Edit Business" ;
}
$data['business_id'] = $business_id;
$data['business_list'] = $this->BusinessModel->findAll();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
echo view('layout/header', ['Data'=>$staffdata]);
echo view('business_form',$data);

View File

@ -262,18 +262,31 @@ class ClientController extends BaseController
public function client_branch_list()
{
// if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$data['clientBranchList'] = $this->ClientBranchModel->select('client_branch.*, client.name as client_name')
$data['clientBranchList'] = $this->ClientBranchModel->select('client_branch.*, client.name as client_name, service_group.business_id')
->join('client', 'client.client_id = client_branch.client_id', 'left')
// ->where('client.branch_id',$this->session->get('logged_in_staff_branch_id'))
->join('client_docs', 'client_docs.client_branch_id = client_branch.id')
->join('template', 'template.template_id = client_docs.template_id')
->join('service_group', 'service_group.service_group_id = template.service_group_id') // ->where('client.branch_id',$this->session->get('logged_in_staff_branch_id'))
// ->groupBy('client_branch.client_id')
->findAll();
$data['client_list'] = $this->ClientModel->select('client_id, name')->where('is_active', 1)->findAll();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
foreach (json_decode($staffdata->business_id) as $key => $value) {
$business = $this->BusinessModel->where('business_id', $value)->first();
if ($business) {
$data['business_list'][] = $business;
$data['business_list'] = $this->BusinessModel->findAll();
$business_id = $this->session->get('logged_in_staff_business_id');
$business_id_check = 0;
foreach ($data['clientBranchList'] as $index => $value) {
foreach (json_decode($value['business_id']) as $key => $values) {
if($values == $business_id){
$business_id_check = $business_id;
}
}
if($business_id_check != 0){
$data['clientBranchList'][$index] =$value;
}else{
unset($data['clientBranchList'][$index]); // Remove the element completely
}
$business_id_check = 0;
}
echo view('layout/header', ['Data'=>$staffdata]);
echo view('client_branch_list',$data);

View File

@ -69,9 +69,10 @@ class MasterController extends BaseController
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$serviceGroups = $this->ServiceGroupModel->select('service_group.*')->findAll();
// Fetch services grouped by service_group_id
$services = $this->ServiceGroupModel->select('service_group.service_group_id, services.service_name')
$services = $this->ServiceGroupModel->select('service_group.service_group_id, service_group.business_id, services.service_name')
->join('services', 'service_group.service_group_id = services.service_group_id', 'left')
->findAll();
// Initialize an array to store service counts and service names by group
$serviceCounts = [];
$serviceNamesByGroup = [];
@ -116,6 +117,23 @@ class MasterController extends BaseController
// Update the serviceGroupList array with the new data
$data['serviceGroupList'][$key] = $value;
}
$business_id = $this->session->get('logged_in_staff_business_id');
$business_id_check = 0;
foreach ($data['serviceGroupList'] as $index => $value) {
foreach (json_decode($value['business_id']) as $key => $values) {
if($values == $business_id){
$business_id_check = $business_id;
}
}
if($business_id_check != 0){
$data['serviceGroupList'][$index] =$value;
}else{
unset($data['serviceGroupList'][$index]); // Remove the element completely
}
$business_id_check = 0;
}
// dd($data);
echo view('layout/header', ['Data'=>$staffdata]);
echo view('service_group_list',$data);
echo view('layout/footer');
@ -152,21 +170,31 @@ class MasterController extends BaseController
public function service_list()
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$data['serviceList'] = $this->ServiceModel->select('services.* , service_group.group_name ,COUNT(template.template_id) as template_count')
$data['serviceList'] = $this->ServiceModel->select('services.* ,service_group.business_id, service_group.group_name ,COUNT(template.template_id) as template_count')
->join('template', 'services.service_id = template.service_id', 'left')
->join('service_group', 'services.service_group_id = service_group.service_group_id', 'left')
// ->where('services.branch_id',$this->session->get('logged_in_staff_branch_id'))
->groupBy('services.service_id')
->orderBy('services.service_group_id')
->findAll();
$business_id = $this->session->get('logged_in_staff_business_id');
$business_id_check = 0;
foreach ($data['serviceList'] as $index => $value) {
foreach (json_decode($value['business_id']) as $key => $values) {
if($values == $business_id){
$business_id_check = $business_id;
}
}
if($business_id_check != 0){
$data['serviceList'][$index] =$value;
}else{
unset($data['serviceList'][$index]); // Remove the element completely
}
$business_id_check = 0;
}
$data['serviceGroupData'] = $this->ServiceGroupModel->where('is_active',1)->findall();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
foreach (json_decode($staffdata->business_id) as $key => $value) {
$business = $this->BusinessModel->where('business_id', $value)->first();
if ($business) {
$data['business_list'][] = $business;
}
}
$data['business_list'] = $this->BusinessModel->findAll();
echo view('layout/header', ['Data'=>$staffdata]);
echo view('service_list',$data);
echo view('layout/footer');
@ -205,16 +233,26 @@ class MasterController extends BaseController
public function template_list()
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$data['templateData'] = $this->TemplateModel->select('template.* , services.service_name , service_group.group_name')
$data['templateData'] = $this->TemplateModel->select('template.* , services.service_name , service_group.group_name, service_group.business_id')
->join('services', 'services.service_id = template.service_id', 'left')
->join('service_group', 'template.service_group_id = service_group.service_group_id', 'left')
->findAll();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
foreach (json_decode($staffdata->business_id) as $key => $value) {
$business = $this->BusinessModel->where('business_id', $value)->first();
if ($business) {
$data['business_list'][] = $business;
$data['business_list'] = $this->BusinessModel->findAll();
$business_id = $this->session->get('logged_in_staff_business_id');
$business_id_check = 0;
foreach ($data['templateData'] as $index => $value) {
foreach (json_decode($value['business_id']) as $key => $values) {
if($values == $business_id){
$business_id_check = $business_id;
}
}
if($business_id_check != 0){
$data['templateData'][$index] =$value;
}else{
unset($data['templateData'][$index]); // Remove the element completely
}
$business_id_check = 0;
}
echo view('layout/header', ['Data'=>$staffdata]);
echo view('template_list',$data);
@ -242,12 +280,17 @@ class MasterController extends BaseController
$data['AllServiceGroupData'] = $this->ServiceGroupModel->findAll();
$data['AllBusinessData'] = $this->BusinessModel->where('isactive',1)->findAll();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
foreach (json_decode($staffdata->business_id) as $key => $value) {
$business = $this->BusinessModel->where('business_id', $value)->first();
if ($business) {
$data['business_list'][] = $business;
if($staffdata->role == 'Staff'){
foreach (json_decode($staffdata->business_id) as $key => $value) {
$business = $this->BusinessModel->where('business_id', $value)->first();
if ($business) {
$data['business_list'][] = $business;
}
}
}else{
$data['business_list'] = $this->BusinessModel->findAll();
}
echo view('layout/header', ['Data'=>$staffdata]);
echo view('template_form',$data);
echo view('layout/footer');
@ -308,56 +351,111 @@ class MasterController extends BaseController
$financialYearStart = $financialYearStart->format('Y-m-d');
$financialYearEnd = $financialYearEnd->format('Y-m-d');
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
$business_id = $this->session->get('logged_in_staff_business_id');
$data['doc_list'] = $this->ClientDocsModel->select('client_docs.*,
services.service_name,
service_group.group_name,
client_branch.name as client_branch_name,
client.name as client_name, service_group.business_id')
->join('template', 'template.template_id = client_docs.template_id', 'left')
->join('services', 'services.service_id = template.service_id', 'left')
->join('service_group', 'service_group.service_group_id = template.service_group_id', 'left')
->join('client_branch', 'client_branch.id = client_docs.client_branch_id', 'left')
->join('client', 'client.client_id = client_branch.client_id ' , 'left')
// ->where('client.business_id', $business_id)
->where('client_docs.created_at >=', $financialYearStart)
->where('client_docs.created_at <=', $financialYearEnd)
// ->where("JSON_CONTAINS(service_group.business_id, '" . $business_id . "')")
->orderBy('client_docs.id', 'DESC')
->get()
->getResultArray();
$business_id_check = 0;
foreach ($data['doc_list'] as $index => $value) {
foreach (json_decode($value['business_id']) as $key => $values) {
if($values == $business_id){
$business_id_check = $business_id;
}
}
if($business_id_check != 0){
$data['doc_list'][$index] =$value;
}else{
unset($data['doc_list'][$index]); // Remove the element completely
}
if($this->session->get('logged_in_staff_role') == 'Admin'){
$business_id = $this->session->get('logged_in_staff_business_id');
$data['doc_list'] = $this->ClientDocsModel->select('client_docs.*,
services.service_name,
service_group.group_name,
client_branch.name as client_branch_name,
client.name as client_name, service_group.business_id')
->join('template', 'template.template_id = client_docs.template_id', 'left')
->join('services', 'services.service_id = template.service_id', 'left')
->join('service_group', 'service_group.service_group_id = template.service_group_id', 'left')
->join('client_branch', 'client_branch.id = client_docs.client_branch_id', 'left')
->join('client', 'client.client_id = client_branch.client_id ' , 'left')
// ->where('client.business_id', $business_id)
->where('client_docs.created_at >=', $financialYearStart)
->where('client_docs.created_at <=', $financialYearEnd)
// ->where("JSON_CONTAINS(service_group.business_id, '" . $business_id . "')")
->orderBy('client_docs.id', 'DESC')
->get()
->getResultArray();
$business_id_check = 0;
}
$docStatusByClientId = [];
// Fetch all doc_status entries and group them by client_docs_id
$data['clientdata'] = $this->ClientBranchModel->select('client.name as client_name , client_branch.name as client_branch_name , client_branch.id as client_branch_id')
->join('client', 'client_branch.client_id = client.client_id', 'left')
// ->where('client.business_id',$this->session->get('logged_in_staff_business_id'))
->findAll();
$data['serviceGroupData'] = $this->ServiceGroupModel->findAll();
foreach ($data['serviceGroupData'] as $key => $value) {
$check_its_okay = 0;
foreach (json_decode($value['business_id']) as $values) {
if($values == $business_id){
$check_its_okay =1;
foreach ($data['doc_list'] as $index => $value) {
foreach (json_decode($value['business_id']) as $key => $values) {
if($values == $business_id){
$business_id_check = $business_id;
}
}
if($business_id_check != 0){
$data['doc_list'][$index] =$value;
}else{
unset($data['doc_list'][$index]); // Remove the element completely
}
$business_id_check = 0;
}
$docStatusByClientId = [];
// Fetch all doc_status entries and group them by client_docs_id
$data['clientdata'] = $this->ClientBranchModel->select('client.name as client_name , client_branch.name as client_branch_name , client_branch.id as client_branch_id')
->join('client', 'client_branch.client_id = client.client_id', 'left')
// ->where('client.business_id',$this->session->get('logged_in_staff_business_id'))
->findAll();
$data['serviceGroupData'] = $this->ServiceGroupModel->findAll();
foreach ($data['serviceGroupData'] as $key => $value) {
$check_its_okay = 0;
foreach (json_decode($value['business_id']) as $values) {
if($values == $business_id){
$check_its_okay =1;
}
}
if($check_its_okay == 0){
unset($data['serviceGroupData'][$key]);
}
$check_its_okay = 0;
}
if($check_its_okay == 0){
unset($data['serviceGroupData'][$key]);
}else{
$business_id = $this->session->get('logged_in_staff_business_id');
$data['doc_list'] = $this->ClientDocsModel->select('client_docs.*,
services.service_name,
service_group.group_name,
client_branch.name as client_branch_name,
client.name as client_name, service_group.business_id')
->join('template', 'template.template_id = client_docs.template_id', 'left')
->join('services', 'services.service_id = template.service_id', 'left')
->join('service_group', 'service_group.service_group_id = template.service_group_id', 'left')
->join('client_branch', 'client_branch.id = client_docs.client_branch_id', 'left')
->join('client', 'client.client_id = client_branch.client_id ' , 'left')
// ->where('client.business_id', $business_id)
->where('client_docs.created_at >=', $financialYearStart)
->where('client_docs.created_at <=', $financialYearEnd)
// ->where("JSON_CONTAINS(service_group.business_id, '" . $business_id . "')")
->orderBy('client_docs.id', 'DESC')
->get()
->getResultArray();
$business_id_check = 0;
foreach ($data['doc_list'] as $index => $value) {
foreach (json_decode($value['business_id']) as $key => $values) {
if($values == $business_id){
$business_id_check = $business_id;
}
}
if($business_id_check != 0){
$data['doc_list'][$index] =$value;
}else{
unset($data['doc_list'][$index]); // Remove the element completely
}
$business_id_check = 0;
}
$docStatusByClientId = [];
// Fetch all doc_status entries and group them by client_docs_id
$data['clientdata'] = $this->ClientBranchModel->select('client.name as client_name , client_branch.name as client_branch_name , client_branch.id as client_branch_id')
->join('client', 'client_branch.client_id = client.client_id', 'left')
// ->where('client.business_id',$this->session->get('logged_in_staff_business_id'))
->findAll();
$data['serviceGroupData'] = $this->ServiceGroupModel->findAll();
foreach ($data['serviceGroupData'] as $key => $value) {
$check_its_okay = 0;
foreach (json_decode($value['business_id']) as $values) {
if($values == $business_id){
$check_its_okay =1;
}
}
if($check_its_okay == 0){
unset($data['serviceGroupData'][$key]);
}
$check_its_okay = 0;
}
$check_its_okay = 0;
}
foreach ($data['doc_list'] as $doc) {
$doc_id_temp = $doc['id'];
@ -373,12 +471,18 @@ class MasterController extends BaseController
$doc['doc_status'] = isset($docStatusByClientId[$doc['id']]) ? $docStatusByClientId[$doc['id']] : [];
}
$data['business_list'] = [];
if($staffdata->role == 'Staff'){
foreach (json_decode($staffdata->business_id) as $key => $value) {
$business = $this->BusinessModel->where('business_id', $value)->first();
if ($business) {
$data['business_list'][] = $business;
}
}
}else{
$data['business_list'] = $this->BusinessModel->findAll();
}
// echo "<pre>";
// print_r($data);die;
echo view('layout/header', ['Data'=>$staffdata]);
echo view('share_docs',$data);
echo view('layout/footer');
@ -391,7 +495,7 @@ class MasterController extends BaseController
}else{
$this->session->set('include_archived', $checked_or_not);
}
print_r($this->session->get('include_archived'));die;
// print_r($this->session->get('include_archived'));die;
return $this->response->setJSON(['status' => 'success']);
}
@ -413,7 +517,9 @@ class MasterController extends BaseController
$financialYearEnd = $financialYearEnd->format('Y-m-d');
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
if($this->session->get('logged_in_staff_role') == 'Admin'){
$data['doc_list'] = $this->ClientDocsModel->select('client_docs.* , services.service_name , service_group.group_name , client_branch.name as client_branch_name , client.name as client_name')
$data['doc_list'] = $this->ClientDocsModel->select('client_docs.* , services.service_name ,
service_group.group_name , client_branch.name as client_branch_name ,
client.name as client_name, service_group.business_id')
->join('template', 'template.template_id = client_docs.template_id', 'left')
->join('services', 'services.service_id = template.service_id', 'left')
->join('service_group', 'service_group.service_group_id = template.service_group_id', 'left')
@ -427,6 +533,22 @@ class MasterController extends BaseController
->findAll();
$data['serviceGroupData'] = $this->ServiceGroupModel->findAll();
}
$business_id = $this->session->get('logged_in_staff_business_id');
$business_id_check = 0;
foreach ($data['doc_list'] as $index => $value) {
foreach (json_decode($value['business_id']) as $key => $values) {
if($values == $business_id){
$business_id_check = $business_id;
}
}
if($business_id_check != 0){
$data['doc_list'][$index] =$value;
}else{
unset($data['doc_list'][$index]); // Remove the element completely
}
$business_id_check = 0;
}
foreach ($data['doc_list'] as $doc) {
$doc_id_temp = $doc['id'];
$docStatusByClientId[$doc_id_temp] = $this->db->table('docs_status')
@ -440,13 +562,13 @@ class MasterController extends BaseController
foreach ($data['doc_list'] as &$doc) {
$doc['doc_status'] = isset($docStatusByClientId[$doc['id']]) ? $docStatusByClientId[$doc['id']] : [];
}
$data['business_list'] = [];
foreach (json_decode($staffdata->business_id) as $key => $value) {
$business = $this->BusinessModel->where('business_id', $value)->first();
if ($business) {
$data['business_list'][] = $business;
}
}
$data['business_list'] = $this->BusinessModel->findAll();
// foreach (json_decode($staffdata->business_id) as $key => $value) {
// $business = $this->BusinessModel->where('business_id', $value)->first();
// if ($business) {
// $data['business_list'][] = $business;
// }
// }
echo view('layout/header', ['Data'=>$staffdata]);
echo view('share_docs',$data);
echo view('layout/footer');

View File

@ -97,6 +97,23 @@ class StaffController extends BaseController
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$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();
$data['business_list'] = $this->BusinessModel->findAll();
$business_id = $this->session->get('logged_in_staff_business_id');
$business_id_check = 0;
foreach ($data['staffList'] as $index => $value) {
foreach (json_decode($value['business_id']) as $key => $values) {
if($values == $business_id){
$business_id_check = $business_id;
}
}
if($business_id_check != 0){
$data['staffList'][$index] =$value;
}else{
unset($data['staffList'][$index]); // Remove the element completely
}
$business_id_check = 0;
}
echo view('layout/header', ['Data'=>$staffdata]);
echo view('staff_list',$data);
echo view('layout/footer');
@ -124,6 +141,7 @@ class StaffController extends BaseController
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
$data['business'] = $this->BusinessModel->where('isactive', 1)->findAll();
$data['page_heading'] = "Create Staff";
$data['business_list'] = $this->BusinessModel->findAll();
echo view('layout/header', ['Data'=>$staffdata]);
echo view('staff_form', $data);
echo view('layout/footer');
@ -146,6 +164,7 @@ class StaffController extends BaseController
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
$data['business'] = $this->BusinessModel->where('isactive', 1)->findAll();
$data['page_heading'] = "Edit Staff";
$data['business_list'] = $this->BusinessModel->findAll();
echo view('layout/header', ['Data'=>$staffdata]);
echo view('staff_form',$data);
echo view('layout/footer');
@ -171,16 +190,31 @@ class StaffController extends BaseController
public function client_list()
{
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
$data['clientList'] = $this->ClientModel->findAll();
$data['clientList'] = $this->ClientModel->select('client.*, service_group.business_id')
->join('client_branch', 'client_branch.client_id = client.client_id')
->join('client_docs', 'client_docs.client_branch_id = client_branch.id')
->join('template', 'template.template_id = client_docs.template_id')
->join('service_group', 'service_group.service_group_id = template.service_group_id')
->findAll();
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))
->get()
->getRow();
foreach (json_decode($staffdata->business_id) as $key => $value) {
$business = $this->BusinessModel->where('business_id', $value)->first();
if ($business) {
$data['business_list'][] = $business;
}
}
$data['business_list'] = $this->BusinessModel->findAll();
$business_id = $this->session->get('logged_in_staff_business_id');
$business_id_check = 0;
foreach ($data['clientList'] as $index => $value) {
foreach (json_decode($value['business_id']) as $key => $values) {
if($values == $business_id){
$business_id_check = $business_id;
}
}
if($business_id_check != 0){
$data['clientList'][$index] =$value;
}else{
unset($data['clientList'][$index]); // Remove the element completely
}
$business_id_check = 0;
}
echo view('layout/header', ['Data'=>$staffdata]);
echo view('client_list',$data);
echo view('layout/footer');

View File

@ -89,8 +89,9 @@ class NotificationHelper
$senderId = getenv('SENDER_ID');
if($message_type_name == 'doc_verify')
{
$message = 'Dear '. $client_full_data['client_name'] .',
'. $otp .' is OTP to approve '. $client_full_data['group_name'] .' for '. $client_full_data['service_name'] .' purposes. -L D RAJ AND CO';
'. $otp .' is OTP to approve '. $client_full_data['group_name'] .' for '. $client_full_data['service_name'] .' purposes. -L D RAJ AND CO';
}
$serviceName = getenv('SERVICE_NAME'); // Service name

View File

@ -26,22 +26,22 @@
<!-- <div class="rightbar-overlay"></div> -->
<script>
function handleBusinessClick(businessId) {
// console.log("Business ID:", businessId.id);
// console.log("Business ID:", businessId.id);
$.ajax({
url: '<?= base_url("set_business_in_session/") ?>' + businessId.id,
type: 'GET',
dataType: 'json',
success: function(response) {
console.log(response);
window.location.reload();
},
error: function(xhr, status, error) {
// Handle error
console.error(xhr.responseText);
$.ajax({
url: '<?= base_url("set_business_in_session/") ?>' + businessId.id,
type: 'GET',
dataType: 'json',
success: function(response) {
console.log(response);
window.location.reload();
},
error: function(xhr, status, error) {
// Handle error
console.error(xhr.responseText);
}
});
}
});
}
$(document).ready(function() {
<?php if (isset($business_list) && isset($_SESSION['logged_in_staff_business_id'])) { ?>
var business_list = <?php echo json_encode($business_list); ?>;

View File

@ -161,6 +161,12 @@
</style>
<style>
.dropdown-menu-right {
right: auto !important;
top: auto !important;
/* left: auto !important; */
}
.modal-xg {
max-width: 70%; /* Adjust the percentage as needed */
}