CHANGE_CONTROLLER_ARRENGE : AADHAVAN
This commit is contained in:
parent
f94330d565
commit
9fe35452df
@ -12,30 +12,27 @@ use CodeIgniter\API\ResponseTrait;
|
|||||||
|
|
||||||
class BranchController extends BaseController
|
class BranchController extends BaseController
|
||||||
{
|
{
|
||||||
|
|
||||||
public $session;
|
public $session;
|
||||||
protected $BranchModel;
|
protected $BranchModel;
|
||||||
|
protected $BusinessModel;
|
||||||
protected $StaffModel;
|
protected $StaffModel;
|
||||||
|
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->session = session();
|
$this->session = session();
|
||||||
$this->BranchModel = new BranchModel();
|
$this->BranchModel = new BranchModel();
|
||||||
|
$this->BusinessModel = new BusinessModel();
|
||||||
$this->StaffModel = new StaffModel();
|
$this->StaffModel = new StaffModel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function branch_index()
|
public function branch_index()
|
||||||
{
|
{
|
||||||
$BranchModel = new BranchModel();
|
$data['branch'] = $this->BranchModel->select('branches.*, business.business_name')
|
||||||
$BusinessModel = new BusinessModel();
|
|
||||||
$data['branch'] = $BranchModel->select('branches.*, business.business_name')
|
|
||||||
->join('business', 'branches.business_id = business.business_id', 'left')
|
->join('business', 'branches.business_id = business.business_id', 'left')
|
||||||
->findAll();
|
->findAll();
|
||||||
$data['business_list'] = $BusinessModel->findAll();
|
$data['business_list'] = $this->BusinessModel->findAll();
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
|
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
@ -43,57 +40,43 @@ class BranchController extends BaseController
|
|||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function new_business($business_id)
|
public function new_business($business_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if ($business_id === '0') {
|
if ($business_id === '0') {
|
||||||
|
|
||||||
$data['business'] = [];
|
$data['business'] = [];
|
||||||
$data['page_name']="Add Business";
|
$data['page_name']="Add Business";
|
||||||
} else if ($business_id !== '0') {
|
} else if ($business_id !== '0') {
|
||||||
|
$business=$this->BusinessModel->getBusinessById($business_id);
|
||||||
$BusinessModel = new BusinessModel();
|
|
||||||
$business=$BusinessModel->getBusinessById($business_id);
|
|
||||||
$data['business']=$business;
|
$data['business']=$business;
|
||||||
$data['page_name']="Edit Business" ;
|
$data['page_name']="Edit Business" ;
|
||||||
}
|
}
|
||||||
$data['business_id'] = $business_id;
|
$data['business_id'] = $business_id;
|
||||||
|
|
||||||
return view('business_form',$data);
|
return view('business_form',$data);
|
||||||
}
|
}
|
||||||
public function new_branch()
|
public function new_branch()
|
||||||
{
|
{
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
$BranchModel = new BranchModel();
|
$insert=$this->BranchModel->insert($data);
|
||||||
|
if($insert){
|
||||||
$BranchModel->insert($data);
|
|
||||||
|
|
||||||
return json_encode(true);
|
return json_encode(true);
|
||||||
|
}else{
|
||||||
|
return ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function get_branch($branch_id)
|
public function get_branch($branch_id)
|
||||||
{
|
{
|
||||||
if ($branch_id) {
|
if ($branch_id) {
|
||||||
$BranchModel = new BranchModel();
|
$branch =$this->BranchModel->where('branch_id',$branch_id)->first();
|
||||||
$branch =$BranchModel->where('branch_id',$branch_id)->first();
|
|
||||||
|
|
||||||
return json_encode($branch);
|
return json_encode($branch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function edit_branch($branch_id)
|
public function edit_branch($branch_id)
|
||||||
{
|
{
|
||||||
if ($branch_id) {
|
if ($branch_id) {
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
$BranchModel = new BranchModel();
|
$this->BranchModel->update($branch_id,$data);
|
||||||
|
|
||||||
$BranchModel->update($branch_id,$data);
|
|
||||||
return json_encode(true);
|
return json_encode(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,15 +86,11 @@ class BranchController extends BaseController
|
|||||||
$branch_id = $this->request->getPost('branch_id');
|
$branch_id = $this->request->getPost('branch_id');
|
||||||
if ($branch_id) {
|
if ($branch_id) {
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
$BranchModel = new BranchModel();
|
$this->BranchModel->update($branch_id,$data);
|
||||||
|
|
||||||
$BranchModel->update($branch_id,$data);
|
|
||||||
return json_encode(true);
|
return json_encode(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function status_branch()
|
public function status_branch()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -32,161 +32,106 @@ class BusinessController extends BaseController
|
|||||||
{
|
{
|
||||||
$data['business'] = $this->BusinessModel->findAll();
|
$data['business'] = $this->BusinessModel->findAll();
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
|
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
echo view('business_list',$data);
|
echo view('business_list',$data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function new_business($business_id)
|
public function new_business($business_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if ($business_id === '0') {
|
if ($business_id === '0') {
|
||||||
$data['business'] = [];
|
$data['business'] = [];
|
||||||
$data['page_name']="Create Business";
|
$data['page_name']="Create Business";
|
||||||
} else if ($business_id !== '0') {
|
} else if ($business_id !== '0') {
|
||||||
|
$business=$this->BusinessModel->getBusinessById($business_id);
|
||||||
$BusinessModel = new BusinessModel();
|
|
||||||
$business=$BusinessModel->getBusinessById($business_id);
|
|
||||||
$data['business']=$business;
|
$data['business']=$business;
|
||||||
$data['page_name']="Edit Business" ;
|
$data['page_name']="Edit Business" ;
|
||||||
}
|
}
|
||||||
$data['business_id'] = $business_id;
|
$data['business_id'] = $business_id;
|
||||||
|
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
|
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
echo view('business_form',$data);
|
echo view('business_form',$data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function new_branch($business_id)
|
public function new_branch($business_id)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if ($business_id === '0') {
|
if ($business_id === '0') {
|
||||||
|
|
||||||
$data['business'] = [];
|
$data['business'] = [];
|
||||||
$data['page_name']="Add Branch";
|
$data['page_name']="Add Branch";
|
||||||
} else if ($business_id !== '0') {
|
} else if ($business_id !== '0') {
|
||||||
|
$business=$this->BusinessModel->getBusinessById($business_id);
|
||||||
$BusinessModel = new BusinessModel();
|
|
||||||
$business=$BusinessModel->getBusinessById($business_id);
|
|
||||||
$data['business']=$business;
|
$data['business']=$business;
|
||||||
$data['page_name']="Edit Branch" ;
|
$data['page_name']="Edit Branch" ;
|
||||||
}
|
}
|
||||||
$data['business_id'] = $business_id;
|
$data['business_id'] = $business_id;
|
||||||
|
|
||||||
return view('branch_form',$data);
|
return view('branch_form',$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function add_business()
|
public function add_business()
|
||||||
{
|
{
|
||||||
$BusinessModel = new BusinessModel();
|
|
||||||
|
|
||||||
|
|
||||||
$business_id = $this->request->getPost('business_id');
|
$business_id = $this->request->getPost('business_id');
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
|
|
||||||
|
|
||||||
if ($business_id != '') {
|
if ($business_id != '') {
|
||||||
|
$this->BusinessModel->update($business_id, $data);
|
||||||
$BusinessModel->update($business_id, $data);
|
|
||||||
return $this->response->setJSON(['success' => true ]);
|
return $this->response->setJSON(['success' => true ]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
$this->BusinessModel->insert($data);
|
||||||
$BusinessModel->insert($data);
|
|
||||||
return $this->response->setJSON(['success' => true ]);
|
return $this->response->setJSON(['success' => true ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete_business($business_id)
|
public function delete_business($business_id)
|
||||||
{
|
{
|
||||||
$model = new BusinessModel();
|
|
||||||
$where = ['business_id' => $business_id, 'isactive' => 1]; // Assuming 'isactive' is a column in your database
|
$where = ['business_id' => $business_id, 'isactive' => 1]; // Assuming 'isactive' is a column in your database
|
||||||
$existingBusiness = $model->where($where)->first();
|
$existingBusiness = $this->BusinessModel->where($where)->first();
|
||||||
|
|
||||||
if ($existingBusiness) {
|
if ($existingBusiness) {
|
||||||
$data['isactive'] = 0;
|
$data['isactive'] = 0;
|
||||||
|
if ($this->BusinessModel->update($business_id, $data)) {
|
||||||
if ($model->update($business_id, $data)) {
|
|
||||||
session()->setFlashdata('success', 'Deleted successfully.');
|
session()->setFlashdata('success', 'Deleted successfully.');
|
||||||
$this->logger->info("Users: has been Inactivated successfully. Inactivated ID = ".$business_id);
|
$this->logger->info("Users: has been Inactivated successfully. Inactivated ID = ".$business_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return redirect()->to('business_list');
|
return redirect()->to('business_list');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_business($business_id)
|
public function get_business($business_id)
|
||||||
{
|
{
|
||||||
if ($business_id) {
|
if ($business_id) {
|
||||||
$BusinessModel = new BusinessModel();
|
$business =$this->BusinessModel->where('business_id',$business_id)->first();
|
||||||
$business =$BusinessModel->where('business_id',$business_id)->first();
|
|
||||||
|
|
||||||
return json_encode($business);
|
return json_encode($business);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function business()
|
public function business()
|
||||||
{
|
{
|
||||||
$branch_id =session()->get("logged_in_staff_branch_id");
|
$branch_id =session()->get("logged_in_staff_branch_id");
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
if ($branch_id) {
|
if ($branch_id) {
|
||||||
// $BusinessModel = new BusinessModel();
|
$data['branch'] =$this->BranchModel->select('branches.*, business.*')
|
||||||
$BranchModel = new BranchModel();
|
|
||||||
$data['branch'] =$BranchModel->select('branches.*, business.*')
|
|
||||||
->join('business', 'business.business_id = branches.business_id')
|
->join('business', 'business.business_id = branches.business_id')
|
||||||
->where('branches.branch_id',$branch_id)
|
->where('branches.branch_id',$branch_id)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
echo view('business',$data);
|
echo view('business',$data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function business_edit()
|
public function business_edit()
|
||||||
{
|
{
|
||||||
$uploadFilePath = ROOTPATH . 'public/uploads/';
|
$uploadFilePath = ROOTPATH . 'public/uploads/';
|
||||||
$file_name = $this->file_Upload($this->request->getFile('business_logo'), $uploadFilePath);
|
$file_name = $this->file_Upload($this->request->getFile('business_logo'), $uploadFilePath);
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
$data['logo'] = $file_name;
|
$data['logo'] = $file_name;
|
||||||
|
|
||||||
$business_id = $this->request->getPost('business_id');
|
$business_id = $this->request->getPost('business_id');
|
||||||
|
|
||||||
if($business_id){
|
if($business_id){
|
||||||
$update = $this->BusinessModel->update($business_id, $data);
|
$update = $this->BusinessModel->update($business_id, $data);
|
||||||
}else{
|
}else{
|
||||||
$insert = $this->BusinessModel->insert($data);
|
$insert = $this->BusinessModel->insert($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return json_encode(true);
|
return json_encode(true);
|
||||||
|
|
||||||
// if($insert){
|
|
||||||
// $client_data = $this->clientModel->where(['id' => $insert, 'is_active' => 1])->first();
|
|
||||||
// return $this->respond(['status' => true,'code' => 200,'data' => $client_data], 200);
|
|
||||||
|
|
||||||
// }else{
|
|
||||||
// return $this->respond(['status' => false,'code' => 404,'message' => 'no data found'], 200);
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function file_Upload($fileToUpload, $filepath)
|
public function file_Upload($fileToUpload, $filepath)
|
||||||
{
|
{
|
||||||
if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) {
|
if ($fileToUpload !== null && $fileToUpload->isValid() && !$fileToUpload->hasMoved()) {
|
||||||
@ -198,14 +143,12 @@ class BusinessController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function status_business()
|
public function status_business()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$business_id = $this->request->getPost('business_id');
|
$business_id = $this->request->getPost('business_id');
|
||||||
$isactive = $this->request->getPost('isactive');
|
$isactive = $this->request->getPost('isactive');
|
||||||
$data = ['isactive' => $isactive];
|
$data = ['isactive' => $isactive];
|
||||||
|
|
||||||
$updated = $this->BusinessModel->update($business_id, $data);
|
$updated = $this->BusinessModel->update($business_id, $data);
|
||||||
if ($updated) {
|
if ($updated) {
|
||||||
$BranchList = $this->BranchModel->where('business_id', $business_id)->findAll();
|
$BranchList = $this->BranchModel->where('business_id', $business_id)->findAll();
|
||||||
@ -221,5 +164,4 @@ class BusinessController extends BaseController
|
|||||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500);
|
return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,6 @@ class ClientController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function login()
|
public function login()
|
||||||
{
|
{
|
||||||
if($this->session->has('is_client_logged_in')){ return redirect()->to(base_url().'client_home'); }
|
if($this->session->has('is_client_logged_in')){ return redirect()->to(base_url().'client_home'); }
|
||||||
@ -53,7 +52,6 @@ class ClientController extends BaseController
|
|||||||
{
|
{
|
||||||
$gst_no = $this->request->getPost('gst_no');
|
$gst_no = $this->request->getPost('gst_no');
|
||||||
$client_branch_data = $this->ClientBranchModel->where('gst_no', $gst_no)->first();
|
$client_branch_data = $this->ClientBranchModel->where('gst_no', $gst_no)->first();
|
||||||
|
|
||||||
if($client_branch_data)
|
if($client_branch_data)
|
||||||
{
|
{
|
||||||
if($client_branch_data['is_active'] == 0)
|
if($client_branch_data['is_active'] == 0)
|
||||||
@ -61,21 +59,14 @@ class ClientController extends BaseController
|
|||||||
$this->session->setTempdata('error','Client Deactivated',3);
|
$this->session->setTempdata('error','Client Deactivated',3);
|
||||||
return redirect()->to(base_url());
|
return redirect()->to(base_url());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->session->set('is_client_logged_in',$client_branch_data['id']);
|
$this->session->set('is_client_logged_in',$client_branch_data['id']);
|
||||||
// $this->session->set('logged_in_client_name',$clientdata['org_name']);
|
// $this->session->set('logged_in_client_name',$clientdata['org_name']);
|
||||||
|
|
||||||
return redirect()->to(base_url().'client_home');
|
return redirect()->to(base_url().'client_home');
|
||||||
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$this->session->setTempdata('error','Email or Password is invalid',3);
|
$this->session->setTempdata('error','Email or Password is invalid',3);
|
||||||
return redirect()->to(base_url());
|
return redirect()->to(base_url());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//get method
|
|
||||||
return view('client_login');
|
return view('client_login');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,16 +77,10 @@ class ClientController extends BaseController
|
|||||||
return redirect()->to(base_url());
|
return redirect()->to(base_url());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function client_home(){
|
public function client_home(){
|
||||||
$client_id =$this->session->get('is_client_logged_in');
|
$client_id =$this->session->get('is_client_logged_in');
|
||||||
|
|
||||||
$data['doc_list'] = $this->ClientDocsModel->getTemplate($client_id);
|
$data['doc_list'] = $this->ClientDocsModel->getTemplate($client_id);
|
||||||
// print_r($client_id);die;
|
|
||||||
// print_r($data['doc_list']);die;
|
|
||||||
|
|
||||||
$clientdata = $this->ClientBranchModel->where('id', $client_id)->get()->getRow();
|
$clientdata = $this->ClientBranchModel->where('id', $client_id)->get()->getRow();
|
||||||
|
|
||||||
if($clientdata){
|
if($clientdata){
|
||||||
echo view('layout/header', ['Data'=>$clientdata]);
|
echo view('layout/header', ['Data'=>$clientdata]);
|
||||||
echo view('client_home',$data);
|
echo view('client_home',$data);
|
||||||
@ -103,7 +88,6 @@ class ClientController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function client_profile()
|
public function client_profile()
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_client_logged_in')){ return redirect()->to(base_url()); }
|
if(!$this->session->has('is_client_logged_in')){ return redirect()->to(base_url()); }
|
||||||
@ -111,11 +95,9 @@ class ClientController extends BaseController
|
|||||||
{
|
{
|
||||||
//update client profile
|
//update client profile
|
||||||
$clientData = $this->request->getVar();
|
$clientData = $this->request->getVar();
|
||||||
|
|
||||||
$clientData['updated_by'] = $this->session->get('is_client_logged_in');
|
$clientData['updated_by'] = $this->session->get('is_client_logged_in');
|
||||||
$client_id = $this->request->getVar('client_id');
|
$client_id = $this->request->getVar('client_id');
|
||||||
$this->ClientModel->where('client_id', $client_id )->set($clientData)->update();
|
$this->ClientModel->where('client_id', $client_id )->set($clientData)->update();
|
||||||
|
|
||||||
echo true;
|
echo true;
|
||||||
}else{
|
}else{
|
||||||
$clientdata = $this->ClientModel->where('client_id',$this->session->get('is_client_logged_in'))->get()->getRow();
|
$clientdata = $this->ClientModel->where('client_id',$this->session->get('is_client_logged_in'))->get()->getRow();
|
||||||
@ -130,11 +112,8 @@ class ClientController extends BaseController
|
|||||||
$old_password =$this->request->getVar('old_password');
|
$old_password =$this->request->getVar('old_password');
|
||||||
$new_password =$this->request->getVar('new_password');
|
$new_password =$this->request->getVar('new_password');
|
||||||
$confirm_password =$this->request->getVar('confirm_password');
|
$confirm_password =$this->request->getVar('confirm_password');
|
||||||
|
|
||||||
|
|
||||||
$client = $this->ClientModel->where('client_id',$client_id)->first();
|
$client = $this->ClientModel->where('client_id',$client_id)->first();
|
||||||
$data_old_password = $client['password'];
|
$data_old_password = $client['password'];
|
||||||
|
|
||||||
if (!password_verify($old_password, $data_old_password)) {
|
if (!password_verify($old_password, $data_old_password)) {
|
||||||
$response = array(
|
$response = array(
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
@ -142,7 +121,6 @@ class ClientController extends BaseController
|
|||||||
);
|
);
|
||||||
return json_encode($response);
|
return json_encode($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($new_password != $confirm_password){
|
if($new_password != $confirm_password){
|
||||||
$response = array(
|
$response = array(
|
||||||
'status' => 'error',
|
'status' => 'error',
|
||||||
@ -150,10 +128,7 @@ class ClientController extends BaseController
|
|||||||
);
|
);
|
||||||
return json_encode($response);
|
return json_encode($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
//$hashedPassword = password_hash($new_password, PASSWORD_DEFAULT);
|
|
||||||
$data['password'] = $new_password;
|
$data['password'] = $new_password;
|
||||||
|
|
||||||
if ($this->ClientModel->update($client_id, $data)) {
|
if ($this->ClientModel->update($client_id, $data)) {
|
||||||
$response = array(
|
$response = array(
|
||||||
'status' => 'success',
|
'status' => 'success',
|
||||||
@ -161,38 +136,29 @@ class ClientController extends BaseController
|
|||||||
);
|
);
|
||||||
return json_encode($response);
|
return json_encode($response);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function generate_otp()
|
public function generate_otp()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$gst_no = $this->request->getPost('gst_no');
|
$gst_no = $this->request->getPost('gst_no');
|
||||||
|
|
||||||
if (empty($gst_no)) {
|
if (empty($gst_no)) {
|
||||||
throw new \Exception('GST number is required');
|
throw new \Exception('GST number is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
$client_branch_data = $this->ClientBranchModel->where('gst_no', $gst_no)->first();
|
$client_branch_data = $this->ClientBranchModel->where('gst_no', $gst_no)->first();
|
||||||
|
|
||||||
if (!$client_branch_data) {
|
if (!$client_branch_data) {
|
||||||
throw new \Exception('Client branch not found for GST number: ' . $gst_no);
|
throw new \Exception('Client branch not found for GST number: ' . $gst_no);
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = $client_branch_data['id'];
|
$id = $client_branch_data['id'];
|
||||||
|
|
||||||
$otp = mt_rand(100000, 999999);
|
$otp = mt_rand(100000, 999999);
|
||||||
$data = ['otp' => $otp];
|
$data = ['otp' => $otp];
|
||||||
$update = $this->ClientBranchModel->update($id, $data);
|
$update = $this->ClientBranchModel->update($id, $data);
|
||||||
|
|
||||||
if (!$update) {
|
if (!$update) {
|
||||||
throw new \Exception('Failed to update OTP in database');
|
throw new \Exception('Failed to update OTP in database');
|
||||||
}
|
}
|
||||||
$notificationHelper = new NotificationHelper();
|
$notificationHelper = new NotificationHelper();
|
||||||
$number = '91'. $client_branch_data['mobile_no']; // Replace with dynamic recipient number
|
$number = '91'. $client_branch_data['mobile_no']; // Replace with dynamic recipient number
|
||||||
$message = 'Login OTP is: ' . $otp;
|
$message = 'Login OTP is: ' . $otp;
|
||||||
|
|
||||||
if($client_branch_data['whatsapp'] == 1){
|
if($client_branch_data['whatsapp'] == 1){
|
||||||
try {
|
try {
|
||||||
$notificationHelper->sendWhatsAppMessage($number, $message);
|
$notificationHelper->sendWhatsAppMessage($number, $message);
|
||||||
@ -201,7 +167,6 @@ class ClientController extends BaseController
|
|||||||
return $this->respond(['Error' => $e->getMessage()]);
|
return $this->respond(['Error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($client_branch_data['sms'] == 1){
|
if($client_branch_data['sms'] == 1){
|
||||||
try {
|
try {
|
||||||
$notificationHelper->sendSms('91'. $client_branch_data['mobile_no'], $client_branch_data['name'], $otp, '', 'login_otp','');
|
$notificationHelper->sendSms('91'. $client_branch_data['mobile_no'], $client_branch_data['name'], $otp, '', 'login_otp','');
|
||||||
@ -210,13 +175,8 @@ class ClientController extends BaseController
|
|||||||
return $this->respond(['Error' => $e->getMessage()]);
|
return $this->respond(['Error' => $e->getMessage()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return $this->respond(['success' => true, 'otp' => '']);
|
||||||
|
|
||||||
return $this->respond(['success' => true, 'otp' => $otp]);
|
|
||||||
|
|
||||||
|
|
||||||
// Return success response with OTP
|
// Return success response with OTP
|
||||||
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Log the exception
|
// Log the exception
|
||||||
error_log('Error generating OTP: ' . $e->getMessage());
|
error_log('Error generating OTP: ' . $e->getMessage());
|
||||||
@ -226,18 +186,13 @@ class ClientController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function verify_otp()
|
public function verify_otp()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$gst_no = $this->request->getPost('gst_no');
|
$gst_no = $this->request->getPost('gst_no');
|
||||||
$otp = $this->request->getPost('otp');
|
$otp = $this->request->getPost('otp');
|
||||||
|
|
||||||
$client_branch_data = $this->ClientBranchModel->where('gst_no', $gst_no )->where('otp', $otp)->first();
|
$client_branch_data = $this->ClientBranchModel->where('gst_no', $gst_no )->where('otp', $otp)->first();
|
||||||
$data = ['otp' =>''];
|
$data = ['otp' =>''];
|
||||||
|
|
||||||
if($client_branch_data){
|
if($client_branch_data){
|
||||||
$id = $client_branch_data['id'];
|
$id = $client_branch_data['id'];
|
||||||
$update = $this->ClientBranchModel->update($id , $data);
|
$update = $this->ClientBranchModel->update($id , $data);
|
||||||
@ -245,19 +200,13 @@ class ClientController extends BaseController
|
|||||||
return json_encode(true);
|
return json_encode(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
// Handle any exceptions that occur during execution
|
|
||||||
return $this->respond(['status' => 'error', 'code' => 500, 'message' => $e->getMessage()], 500);
|
return $this->respond(['status' => 'error', 'code' => 500, 'message' => $e->getMessage()], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function status_client()
|
public function status_client()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -266,18 +215,12 @@ class ClientController extends BaseController
|
|||||||
$data = [
|
$data = [
|
||||||
'is_active' => $is_active
|
'is_active' => $is_active
|
||||||
];
|
];
|
||||||
|
|
||||||
$updated = $this->ClientModel->update($client_id, $data);
|
$updated = $this->ClientModel->update($client_id, $data);
|
||||||
|
|
||||||
if ($updated) {
|
if ($updated) {
|
||||||
|
|
||||||
$client_branch_list = $this->ClientBranchModel->where('client_id', $client_id)->findAll();
|
$client_branch_list = $this->ClientBranchModel->where('client_id', $client_id)->findAll();
|
||||||
|
|
||||||
foreach($client_branch_list as $key=> $value){
|
foreach($client_branch_list as $key=> $value){
|
||||||
$this->ClientBranchModel->update($value['id'], $data);
|
$this->ClientBranchModel->update($value['id'], $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => true],200);
|
return $this->respond(['status' => 'success','code' => 200,'data' => true],200);
|
||||||
} else {
|
} else {
|
||||||
$result = "No Match's";
|
$result = "No Match's";
|
||||||
@ -288,7 +231,6 @@ class ClientController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function doc_rejection()
|
public function doc_rejection()
|
||||||
{
|
{
|
||||||
$id = $this->request->getPost('doc_id');
|
$id = $this->request->getPost('doc_id');
|
||||||
@ -296,10 +238,8 @@ class ClientController extends BaseController
|
|||||||
'rejection_reason' => $this->request->getPost('rejection_reason'),
|
'rejection_reason' => $this->request->getPost('rejection_reason'),
|
||||||
'is_approved' => $this->request->getPost('is_approved')
|
'is_approved' => $this->request->getPost('is_approved')
|
||||||
];
|
];
|
||||||
|
|
||||||
if($id){
|
if($id){
|
||||||
$update =$this->ClientDocsModel->update($id, $data);
|
$update =$this->ClientDocsModel->update($id, $data);
|
||||||
|
|
||||||
if($this->session->has('is_client_logged_in')){
|
if($this->session->has('is_client_logged_in')){
|
||||||
$logged_user = $this->session->get('is_client_logged_in');
|
$logged_user = $this->session->get('is_client_logged_in');
|
||||||
$statusData['is_staff'] = 0;
|
$statusData['is_staff'] = 0;
|
||||||
@ -312,31 +252,22 @@ class ClientController extends BaseController
|
|||||||
$statusData['status'] = 'Rejected';
|
$statusData['status'] = 'Rejected';
|
||||||
$statusData['note'] = $this->request->getPost('rejection_reason');
|
$statusData['note'] = $this->request->getPost('rejection_reason');
|
||||||
$this->DocsStatusModel->insert($statusData);
|
$this->DocsStatusModel->insert($statusData);
|
||||||
|
|
||||||
if ($update) {
|
if ($update) {
|
||||||
return json_encode(true);
|
return json_encode(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function client_branch_list()
|
public function client_branch_list()
|
||||||
{
|
{
|
||||||
// if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
// if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
|
|
||||||
|
|
||||||
// $data['clientBranchList'] = $this->ClientBranchModel->select('client.* , COUNT(client_docs.id) as docs_count')
|
|
||||||
$data['clientBranchList'] = $this->ClientBranchModel->select('client_branch.*, client.name as client_name')
|
$data['clientBranchList'] = $this->ClientBranchModel->select('client_branch.*, client.name as client_name')
|
||||||
->join('client', 'client.client_id = client_branch.client_id', 'left')
|
->join('client', 'client.client_id = client_branch.client_id', 'left')
|
||||||
// ->where('client.branch_id',$this->session->get('logged_in_staff_branch_id'))
|
// ->where('client.branch_id',$this->session->get('logged_in_staff_branch_id'))
|
||||||
// ->groupBy('client_branch.client_id')
|
// ->groupBy('client_branch.client_id')
|
||||||
->findAll();
|
->findAll();
|
||||||
$data['client_list'] = $this->ClientModel->select('client_id, name')->where('is_active', 1)->findAll();
|
$data['client_list'] = $this->ClientModel->select('client_id, name')->where('is_active', 1)->findAll();
|
||||||
// echo"<pre>";
|
|
||||||
// print_r($data);die;
|
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
foreach (json_decode($staffdata->business_id) as $key => $value) {
|
foreach (json_decode($staffdata->business_id) as $key => $value) {
|
||||||
$business = $this->BusinessModel->where('business_id', $value)->first();
|
$business = $this->BusinessModel->where('business_id', $value)->first();
|
||||||
@ -345,13 +276,10 @@ class ClientController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
// echo view('layout/header');
|
|
||||||
echo view('client_branch_list',$data);
|
echo view('client_branch_list',$data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function add_client_branch()
|
public function add_client_branch()
|
||||||
{
|
{
|
||||||
$gst = $this->request->getPost('gst_no');
|
$gst = $this->request->getPost('gst_no');
|
||||||
@ -360,7 +288,6 @@ class ClientController extends BaseController
|
|||||||
return json_encode(false);
|
return json_encode(false);
|
||||||
}else{
|
}else{
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
// print_r($data);die;
|
|
||||||
$this->ClientBranchModel->insert($data);
|
$this->ClientBranchModel->insert($data);
|
||||||
return json_encode(true);
|
return json_encode(true);
|
||||||
}
|
}
|
||||||
@ -369,28 +296,19 @@ class ClientController extends BaseController
|
|||||||
public function edit_client_branch()
|
public function edit_client_branch()
|
||||||
{
|
{
|
||||||
$id = $this->request->getPost('id');
|
$id = $this->request->getPost('id');
|
||||||
|
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
|
|
||||||
$this->ClientBranchModel->update($id, $data);
|
$this->ClientBranchModel->update($id, $data);
|
||||||
|
|
||||||
return json_encode('update');
|
return json_encode('update');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function get_client_branch($branch_id)
|
public function get_client_branch($branch_id)
|
||||||
{
|
{
|
||||||
if ($branch_id) {
|
if ($branch_id) {
|
||||||
$branch =$this->ClientBranchModel->where('id',$branch_id)->first();
|
$branch =$this->ClientBranchModel->where('id',$branch_id)->first();
|
||||||
|
|
||||||
return json_encode($branch);
|
return json_encode($branch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function status_client_branch()
|
public function status_client_branch()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -399,9 +317,7 @@ class ClientController extends BaseController
|
|||||||
$data = [
|
$data = [
|
||||||
'is_active' => $is_active
|
'is_active' => $is_active
|
||||||
];
|
];
|
||||||
|
|
||||||
$updated = $this->ClientBranchModel->update($client_branch_id, $data);
|
$updated = $this->ClientBranchModel->update($client_branch_id, $data);
|
||||||
|
|
||||||
if ($updated) {
|
if ($updated) {
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => true],200);
|
return $this->respond(['status' => 'success','code' => 200,'data' => true],200);
|
||||||
} else {
|
} else {
|
||||||
@ -413,41 +329,33 @@ class ClientController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function client_upload()
|
public function client_upload()
|
||||||
{
|
{
|
||||||
if ($_FILES['file']['name']) {
|
if ($_FILES['file']['name']) {
|
||||||
$allowed_extension = ['xls', 'xlsx'];
|
$allowed_extension = ['xls', 'xlsx'];
|
||||||
$file_array = explode(".", $_FILES['file']['name']);
|
$file_array = explode(".", $_FILES['file']['name']);
|
||||||
$file_extension = end($file_array);
|
$file_extension = end($file_array);
|
||||||
|
|
||||||
if (in_array($file_extension, $allowed_extension)) {
|
if (in_array($file_extension, $allowed_extension)) {
|
||||||
$file_name = $_FILES['file']['tmp_name'];
|
$file_name = $_FILES['file']['tmp_name'];
|
||||||
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name);
|
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($file_name);
|
||||||
$data = $spreadsheet->getActiveSheet()->toArray();
|
$data = $spreadsheet->getActiveSheet()->toArray();
|
||||||
|
|
||||||
// Extract headers and data
|
// Extract headers and data
|
||||||
$headers = array_shift($data);
|
$headers = array_shift($data);
|
||||||
$nameIndex = array_search('Name', $headers);
|
$nameIndex = array_search('Name', $headers);
|
||||||
$panNoIndex = array_search('PAN No', $headers);
|
$panNoIndex = array_search('PAN No', $headers);
|
||||||
$emailIndex = array_search('Email', $headers);
|
$emailIndex = array_search('Email', $headers);
|
||||||
$mobileNoIndex = array_search('Mobile No', $headers);
|
$mobileNoIndex = array_search('Mobile No', $headers);
|
||||||
|
|
||||||
if ($nameIndex === false || $panNoIndex === false || $emailIndex === false || $mobileNoIndex === false) {
|
if ($nameIndex === false || $panNoIndex === false || $emailIndex === false || $mobileNoIndex === false) {
|
||||||
echo "Required columns (Name, PAN No, Email, Mobile No) not found in the spreadsheet.";
|
echo "Required columns (Name, PAN No, Email, Mobile No) not found in the spreadsheet.";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$groupedData = [];
|
$groupedData = [];
|
||||||
|
|
||||||
// Group data by the "Name" field
|
// Group data by the "Name" field
|
||||||
foreach ($data as $row) {
|
foreach ($data as $row) {
|
||||||
$name = $row[$nameIndex];
|
$name = $row[$nameIndex];
|
||||||
$panNo = $row[$panNoIndex];
|
$panNo = $row[$panNoIndex];
|
||||||
$email = $row[$emailIndex];
|
$email = $row[$emailIndex];
|
||||||
$mobileNo = $row[$mobileNoIndex];
|
$mobileNo = $row[$mobileNoIndex];
|
||||||
|
|
||||||
if (!isset($groupedData[$name])) {
|
if (!isset($groupedData[$name])) {
|
||||||
$groupedData[$name] = [
|
$groupedData[$name] = [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
@ -457,7 +365,6 @@ class ClientController extends BaseController
|
|||||||
'branches' => []
|
'branches' => []
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$branch = [];
|
$branch = [];
|
||||||
foreach ($headers as $index => $header) {
|
foreach ($headers as $index => $header) {
|
||||||
// print_r($header);die;
|
// print_r($header);die;
|
||||||
@ -491,10 +398,8 @@ class ClientController extends BaseController
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$groupedData[$name]['branches'][] = $branch;
|
$groupedData[$name]['branches'][] = $branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($groupedData as $key => $value) {
|
foreach ($groupedData as $key => $value) {
|
||||||
// print_r($value);
|
// print_r($value);
|
||||||
$created_by = $this->session->get('is_staff_logged_in');
|
$created_by = $this->session->get('is_staff_logged_in');
|
||||||
@ -504,7 +409,6 @@ class ClientController extends BaseController
|
|||||||
->where('branches.branch_id ',$branch_id)
|
->where('branches.branch_id ',$branch_id)
|
||||||
->first();
|
->first();
|
||||||
$business_id = $business['business_id'];
|
$business_id = $business['business_id'];
|
||||||
|
|
||||||
$insertData = [
|
$insertData = [
|
||||||
"name" => $value['name'],
|
"name" => $value['name'],
|
||||||
"pan_no" => $value['pan_no'],
|
"pan_no" => $value['pan_no'],
|
||||||
@ -514,9 +418,7 @@ class ClientController extends BaseController
|
|||||||
"branch_id" => $branch_id,
|
"branch_id" => $branch_id,
|
||||||
"business_id" => $business_id
|
"business_id" => $business_id
|
||||||
];
|
];
|
||||||
|
|
||||||
$client = $this->ClientModel->insert($insertData);
|
$client = $this->ClientModel->insert($insertData);
|
||||||
|
|
||||||
if($client){
|
if($client){
|
||||||
if($value['branches']){
|
if($value['branches']){
|
||||||
foreach ($value['branches'] as $key => $branch) {
|
foreach ($value['branches'] as $key => $branch) {
|
||||||
@ -534,10 +436,8 @@ class ClientController extends BaseController
|
|||||||
];
|
];
|
||||||
$clientBranch = $this->ClientBranchModel->insert($insertBranchData);
|
$clientBranch = $this->ClientBranchModel->insert($insertBranchData);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return json_encode(true);
|
return json_encode(true);
|
||||||
} else {
|
} else {
|
||||||
@ -547,11 +447,6 @@ class ClientController extends BaseController
|
|||||||
echo "No file uploaded.";
|
echo "No file uploaded.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -38,8 +38,6 @@ class MasterController extends BaseController
|
|||||||
|
|
||||||
use ResponseTrait;
|
use ResponseTrait;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->session = session();
|
$this->session = session();
|
||||||
@ -55,13 +53,9 @@ class MasterController extends BaseController
|
|||||||
$this->DocsStatusModel = new DocsStatusModel();
|
$this->DocsStatusModel = new DocsStatusModel();
|
||||||
|
|
||||||
$this->db = \Config\Database::connect();
|
$this->db = \Config\Database::connect();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBusinessDetails($businessIds) {
|
function getBusinessDetails($businessIds) {
|
||||||
// This is just a placeholder for your actual database call
|
|
||||||
// Replace this with your actual query logic
|
|
||||||
$businessDetails = [];
|
$businessDetails = [];
|
||||||
foreach ($businessIds as $businessId) {
|
foreach ($businessIds as $businessId) {
|
||||||
// Example data fetched from the database
|
// Example data fetched from the database
|
||||||
@ -70,24 +64,17 @@ class MasterController extends BaseController
|
|||||||
return $businessDetails;
|
return $businessDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function service_group_list()
|
public function service_group_list()
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
|
$serviceGroups = $this->ServiceGroupModel->select('service_group.*')->findAll();
|
||||||
// Fetch all service groups
|
|
||||||
$serviceGroups = $this->ServiceGroupModel->select('service_group.*')
|
|
||||||
->findAll();
|
|
||||||
|
|
||||||
// Fetch services grouped by service_group_id
|
// 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, services.service_name')
|
||||||
->join('services', 'service_group.service_group_id = services.service_group_id', 'left')
|
->join('services', 'service_group.service_group_id = services.service_group_id', 'left')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
// Initialize an array to store service counts and service names by group
|
// Initialize an array to store service counts and service names by group
|
||||||
$serviceCounts = [];
|
$serviceCounts = [];
|
||||||
$serviceNamesByGroup = [];
|
$serviceNamesByGroup = [];
|
||||||
|
|
||||||
// Group services by service group id and count services
|
// Group services by service group id and count services
|
||||||
foreach ($services as $service) {
|
foreach ($services as $service) {
|
||||||
$serviceGroupId = $service['service_group_id'];
|
$serviceGroupId = $service['service_group_id'];
|
||||||
@ -100,104 +87,71 @@ class MasterController extends BaseController
|
|||||||
$serviceNamesByGroup[$serviceGroupId][] = $service['service_name'];
|
$serviceNamesByGroup[$serviceGroupId][] = $service['service_name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign service counts and names to service groups
|
// Assign service counts and names to service groups
|
||||||
foreach ($serviceGroups as &$group) {
|
foreach ($serviceGroups as &$group) {
|
||||||
$groupId = $group['service_group_id'];
|
$groupId = $group['service_group_id'];
|
||||||
$group['service_count'] = isset($serviceCounts[$groupId]) ? $serviceCounts[$groupId] : 0;
|
$group['service_count'] = isset($serviceCounts[$groupId]) ? $serviceCounts[$groupId] : 0;
|
||||||
$group['service_list'] = isset($serviceNamesByGroup[$groupId]) ? $serviceNamesByGroup[$groupId] : [];
|
$group['service_list'] = isset($serviceNamesByGroup[$groupId]) ? $serviceNamesByGroup[$groupId] : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the modified service groups to the data array
|
// Set the modified service groups to the data array
|
||||||
$data['serviceGroupList'] = $serviceGroups;
|
$data['serviceGroupList'] = $serviceGroups;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
foreach ($serviceGroups as &$group) {
|
foreach ($serviceGroups as &$group) {
|
||||||
$groupId = $group['service_group_id'];
|
$groupId = $group['service_group_id'];
|
||||||
$group['service_count'] = isset($serviceNamesByGroup[$groupId]) ? count($serviceNamesByGroup[$groupId]) : 0;
|
$group['service_count'] = isset($serviceNamesByGroup[$groupId]) ? count($serviceNamesByGroup[$groupId]) : 0;
|
||||||
$group['service_list'] = isset($serviceNamesByGroup[$groupId]) ? $serviceNamesByGroup[$groupId] : [];
|
$group['service_list'] = isset($serviceNamesByGroup[$groupId]) ? $serviceNamesByGroup[$groupId] : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the modified service groups to the data array
|
// Set the modified service groups to the data array
|
||||||
$data['serviceGroupList'] = $serviceGroups;
|
$data['serviceGroupList'] = $serviceGroups;
|
||||||
|
|
||||||
|
|
||||||
$data['business_list'] = $this->BusinessModel->findAll();
|
$data['business_list'] = $this->BusinessModel->findAll();
|
||||||
|
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
|
|
||||||
|
|
||||||
foreach ($data['serviceGroupList'] as $key => $value) {
|
foreach ($data['serviceGroupList'] as $key => $value) {
|
||||||
// Decode the JSON encoded business_id
|
// Decode the JSON encoded business_id
|
||||||
$businessIds = json_decode($value['business_id'], true);
|
$businessIds = json_decode($value['business_id'], true);
|
||||||
|
|
||||||
// Find the business details
|
// Find the business details
|
||||||
$businessDetails = $this->getBusinessDetails($businessIds);
|
$businessDetails = $this->getBusinessDetails($businessIds);
|
||||||
|
|
||||||
// Add business count
|
// Add business count
|
||||||
$value['business_count'] = count($businessIds);
|
$value['business_count'] = count($businessIds);
|
||||||
|
|
||||||
// Add business details to the service group
|
// Add business details to the service group
|
||||||
$value['business_list'] = $businessDetails;
|
$value['business_list'] = $businessDetails;
|
||||||
|
|
||||||
// Update the serviceGroupList array with the new data
|
// Update the serviceGroupList array with the new data
|
||||||
$data['serviceGroupList'][$key] = $value;
|
$data['serviceGroupList'][$key] = $value;
|
||||||
}
|
}
|
||||||
// echo "<pre>";
|
|
||||||
// print_r($data);die;
|
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
echo view('service_group_list',$data);
|
echo view('service_group_list',$data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function service_group_create()
|
public function service_group_create()
|
||||||
|
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
|
|
||||||
if($this->request->getmethod() == 'POST')
|
if($this->request->getmethod() == 'POST')
|
||||||
{
|
{
|
||||||
|
|
||||||
$serviceGroupData = $this->request->getVar();
|
$serviceGroupData = $this->request->getVar();
|
||||||
if( isset($serviceGroupData['service_group_id']) ){
|
if( isset($serviceGroupData['service_group_id']) ){
|
||||||
$serviceGroupData['business_id'] = json_encode($serviceGroupData['business']);
|
$serviceGroupData['business_id'] = json_encode($serviceGroupData['business']);
|
||||||
$this->ServiceGroupModel->where('service_group_id', $this->request->getVar('service_group_id') )->set($serviceGroupData)->update();
|
$this->ServiceGroupModel->where('service_group_id', $this->request->getVar('service_group_id') )->set($serviceGroupData)
|
||||||
|
->update();
|
||||||
}else{
|
}else{
|
||||||
$serviceGroupData = $this->request->getVar();
|
$serviceGroupData = $this->request->getVar();
|
||||||
$serviceGroupData['business_id'] = json_encode($this->request->getPost('business'));
|
$serviceGroupData['business_id'] = json_encode($this->request->getPost('business'));
|
||||||
// $serviceGroupData['business_id'] = $this->session->get('logged_in_staff_business_id');
|
|
||||||
$serviceGroupData['branch_id'] = $this->session->get('logged_in_staff_branch_id');
|
$serviceGroupData['branch_id'] = $this->session->get('logged_in_staff_branch_id');
|
||||||
|
|
||||||
$this->ServiceGroupModel->insert($serviceGroupData);
|
$this->ServiceGroupModel->insert($serviceGroupData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->to(base_url()."service_group_list");
|
return redirect()->to(base_url()."service_group_list");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function service_group_edit()
|
public function service_group_edit()
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
|
|
||||||
$service_group_id = $this->request->getVar('service_group_id');
|
$service_group_id = $this->request->getVar('service_group_id');
|
||||||
$data = $this->ServiceGroupModel->where('service_group_id',$service_group_id)->get()->getRow();
|
$data = $this->ServiceGroupModel->where('service_group_id',$service_group_id)->get()->getRow();
|
||||||
return $this->response->setJSON(['success' => true , 'data' =>$data]);
|
return $this->response->setJSON(['success' => true , 'data' =>$data]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function service_list()
|
public function service_list()
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
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.group_name ,COUNT(template.template_id) as template_count')
|
||||||
->join('template', 'services.service_id = template.service_id', 'left')
|
->join('template', 'services.service_id = template.service_id', 'left')
|
||||||
->join('service_group', 'services.service_group_id = service_group.service_group_id', 'left')
|
->join('service_group', 'services.service_group_id = service_group.service_group_id', 'left')
|
||||||
@ -216,33 +170,23 @@ class MasterController extends BaseController
|
|||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
echo view('service_list',$data);
|
echo view('service_list',$data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function service_create()
|
public function service_create()
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
|
|
||||||
if($this->request->getmethod() == 'POST')
|
if($this->request->getmethod() == 'POST')
|
||||||
{
|
{
|
||||||
|
|
||||||
$serviceData = $this->request->getVar();
|
$serviceData = $this->request->getVar();
|
||||||
if( isset($serviceData['service_id']) ){
|
if( isset($serviceData['service_id']) ){
|
||||||
|
|
||||||
$this->ServiceModel->where('service_id', $this->request->getVar('service_id') )->set($serviceData)->update();
|
$this->ServiceModel->where('service_id', $this->request->getVar('service_id') )->set($serviceData)->update();
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$serviceData = $this->request->getVar();
|
$serviceData = $this->request->getVar();
|
||||||
$serviceData['branch_id'] = $this->session->get('logged_in_staff_branch_id');
|
$serviceData['branch_id'] = $this->session->get('logged_in_staff_branch_id');
|
||||||
|
|
||||||
$this->ServiceModel->insert($serviceData);
|
$this->ServiceModel->insert($serviceData);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->to(base_url()."service_list");
|
return redirect()->to(base_url()."service_list");
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
echo view('service_form');
|
echo view('service_form');
|
||||||
@ -253,30 +197,18 @@ class MasterController extends BaseController
|
|||||||
public function service_edit()
|
public function service_edit()
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
|
|
||||||
$service_id = $this->request->getVar('service_id');
|
$service_id = $this->request->getVar('service_id');
|
||||||
$data = $this->ServiceModel->where('service_id',$service_id)->get()->getRow();
|
$data = $this->ServiceModel->where('service_id',$service_id)->get()->getRow();
|
||||||
|
|
||||||
return $this->response->setJSON(['success' => true , 'data' =>$data]);
|
return $this->response->setJSON(['success' => true , 'data' =>$data]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function template_list()
|
public function template_list()
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
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')
|
||||||
->join('services', 'services.service_id = template.service_id', 'left')
|
->join('services', 'services.service_id = template.service_id', 'left')
|
||||||
->join('service_group', 'template.service_group_id = service_group.service_group_id', 'left')
|
->join('service_group', 'template.service_group_id = service_group.service_group_id', 'left')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
foreach (json_decode($staffdata->business_id) as $key => $value) {
|
foreach (json_decode($staffdata->business_id) as $key => $value) {
|
||||||
$business = $this->BusinessModel->where('business_id', $value)->first();
|
$business = $this->BusinessModel->where('business_id', $value)->first();
|
||||||
@ -287,17 +219,14 @@ class MasterController extends BaseController
|
|||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
echo view('template_list',$data);
|
echo view('template_list',$data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function template_create()
|
public function template_create()
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
|
|
||||||
if($this->request->getmethod() == 'POST')
|
if($this->request->getmethod() == 'POST')
|
||||||
{
|
{
|
||||||
$templateData = $this->request->getVar();
|
$templateData = $this->request->getVar();
|
||||||
|
|
||||||
if($this->request->getVar('template_id') != 'null'){
|
if($this->request->getVar('template_id') != 'null'){
|
||||||
$id = $this->request->getVar('template_id');
|
$id = $this->request->getVar('template_id');
|
||||||
unset($templateData['template_id']);
|
unset($templateData['template_id']);
|
||||||
@ -308,15 +237,10 @@ class MasterController extends BaseController
|
|||||||
$this->TemplateModel->insert($templateData);
|
$this->TemplateModel->insert($templateData);
|
||||||
return $this->response->setJSON(['success' => true , 'service_id' =>$this->request->getVar('service_id')]);
|
return $this->response->setJSON(['success' => true , 'service_id' =>$this->request->getVar('service_id')]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
$id = $this->request->getVar('service_id');
|
$id = $this->request->getVar('service_id');
|
||||||
$data['AllServiceGroupData'] = $this->ServiceGroupModel->findAll();
|
$data['AllServiceGroupData'] = $this->ServiceGroupModel->findAll();
|
||||||
$data['AllBusinessData'] = $this->BusinessModel->where('isactive',1)->findAll();
|
$data['AllBusinessData'] = $this->BusinessModel->where('isactive',1)->findAll();
|
||||||
|
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
foreach (json_decode($staffdata->business_id) as $key => $value) {
|
foreach (json_decode($staffdata->business_id) as $key => $value) {
|
||||||
$business = $this->BusinessModel->where('business_id', $value)->first();
|
$business = $this->BusinessModel->where('business_id', $value)->first();
|
||||||
@ -330,59 +254,46 @@ class MasterController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function template_edit()
|
public function template_edit()
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
|
|
||||||
$id = $this->request->getVar('template_id');
|
$id = $this->request->getVar('template_id');
|
||||||
$data['templateData'] = $this->TemplateModel->where('md5(template_id)',$id)->get()->getRow();
|
$data['templateData'] = $this->TemplateModel->where('md5(template_id)',$id)->get()->getRow();
|
||||||
|
|
||||||
$data['serviceData'] = $this->ServiceModel->where('service_id',$data['templateData']->service_id)->get()->getRow();
|
$data['serviceData'] = $this->ServiceModel->where('service_id',$data['templateData']->service_id)->get()->getRow();
|
||||||
// $data['AllServiceData'] = $this->ServiceModel->where('branch_id',$this->session->get('logged_in_staff_branch_id'))->findAll();
|
|
||||||
$data['AllServiceData'] = $this->ServiceModel->findAll();
|
$data['AllServiceData'] = $this->ServiceModel->findAll();
|
||||||
|
$data['serviceGroupData'] = $this->ServiceGroupModel->where('service_group_id',$data['templateData']->service_group_id)
|
||||||
$data['serviceGroupData'] = $this->ServiceGroupModel->where('service_group_id',$data['templateData']->service_group_id)->get()->getRow();
|
->get()
|
||||||
// $data['AllServiceGroupData'] = $this->ServiceGroupModel->where('branch_id',$this->session->get('logged_in_staff_branch_id'))->findAll();
|
->getRow();
|
||||||
$data['AllServiceGroupData'] = $this->ServiceGroupModel->findAll();
|
$data['AllServiceGroupData'] = $this->ServiceGroupModel->findAll();
|
||||||
|
$data['BusinessData'] = $this->BusinessModel->where('business_id',$data['templateData']->template_header_business)
|
||||||
$data['BusinessData'] = $this->BusinessModel->where('business_id',$data['templateData']->template_header_business)->where('isactive',1)->get()->getRow();
|
->where('isactive',1)
|
||||||
|
->get()
|
||||||
|
->getRow();
|
||||||
$data['AllBusinessData'] = $this->BusinessModel->where('isactive',1)->findAll();
|
$data['AllBusinessData'] = $this->BusinessModel->where('isactive',1)->findAll();
|
||||||
|
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
echo view('template_form',$data);
|
echo view('template_form',$data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function template_preview()
|
public function template_preview()
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
|
|
||||||
$id = $this->request->getVar('template_id');
|
$id = $this->request->getVar('template_id');
|
||||||
$data['templateData'] = $this->TemplateModel->where('md5(template_id)',$id)->get()->getRow();
|
$data['templateData'] = $this->TemplateModel->where('md5(template_id)',$id)->get()->getRow();
|
||||||
$data['serviceData'] = $this->ServiceModel->where('service_id',$data['templateData']->service_id)->get()->getRow();
|
$data['serviceData'] = $this->ServiceModel->where('service_id',$data['templateData']->service_id)->get()->getRow();
|
||||||
$data['businessData'] = $this->BusinessModel->where('business_id',$data['templateData']->template_header_business)->get()->getRow();
|
$data['businessData'] = $this->BusinessModel->where('business_id',$data['templateData']->template_header_business)
|
||||||
|
->get()
|
||||||
|
->getRow();
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
$data['body_html'] = $data['templateData']->body_html;
|
$data['body_html'] = $data['templateData']->body_html;
|
||||||
// echo view('layout/header', ['Data'=>$staffdata]);
|
|
||||||
echo view('template_preview',$data);
|
echo view('template_preview',$data);
|
||||||
// echo view('layout/footer');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function shared_docs_list()
|
public function shared_docs_list()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
$currentDate = new \DateTime();
|
$currentDate = new \DateTime();
|
||||||
|
|
||||||
// Determine the start and end dates of the current financial year
|
// Determine the start and end dates of the current financial year
|
||||||
if ($currentDate->format('n') >= 4) {
|
if ($currentDate->format('n') >= 4) {
|
||||||
// If the current month is April (4) or later, the financial year started this year
|
// If the current month is April (4) or later, the financial year started this year
|
||||||
@ -393,46 +304,11 @@ class MasterController extends BaseController
|
|||||||
$financialYearStart = new \DateTime(($currentDate->format('Y') - 1) . '-04-01');
|
$financialYearStart = new \DateTime(($currentDate->format('Y') - 1) . '-04-01');
|
||||||
$financialYearEnd = new \DateTime($currentDate->format('Y') . '-03-31');
|
$financialYearEnd = new \DateTime($currentDate->format('Y') . '-03-31');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert to the format suitable for your database (assuming MySQL)
|
// Convert to the format suitable for your database (assuming MySQL)
|
||||||
$financialYearStart = $financialYearStart->format('Y-m-d');
|
$financialYearStart = $financialYearStart->format('Y-m-d');
|
||||||
$financialYearEnd = $financialYearEnd->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();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
|
|
||||||
if($this->session->get('logged_in_staff_role') == 'Admin'){
|
|
||||||
$includeArchived = $this->session->get('include_archived');
|
|
||||||
if (isset($includeArchived) && $includeArchived == 'false') {
|
|
||||||
$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')
|
|
||||||
->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')
|
|
||||||
->orderBy('client_docs.id','DESC')
|
|
||||||
->findAll();
|
|
||||||
}else{
|
|
||||||
$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')
|
|
||||||
->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_docs.created_at >=', $financialYearStart)
|
|
||||||
->where('client_docs.created_at <=', $financialYearEnd)
|
|
||||||
->orderBy('client_docs.id','DESC')
|
|
||||||
->findAll();
|
|
||||||
|
|
||||||
}
|
|
||||||
// print_r($data['doc_list']);die;
|
|
||||||
$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();
|
|
||||||
|
|
||||||
}else{
|
|
||||||
$business_id = $this->session->get('logged_in_staff_business_id');
|
$business_id = $this->session->get('logged_in_staff_business_id');
|
||||||
// print_r($business_id);die;
|
|
||||||
$data['doc_list'] = $this->ClientDocsModel->select('client_docs.*,
|
$data['doc_list'] = $this->ClientDocsModel->select('client_docs.*,
|
||||||
services.service_name,
|
services.service_name,
|
||||||
service_group.group_name,
|
service_group.group_name,
|
||||||
@ -451,9 +327,6 @@ class MasterController extends BaseController
|
|||||||
->get()
|
->get()
|
||||||
->getResultArray();
|
->getResultArray();
|
||||||
$business_id_check = 0;
|
$business_id_check = 0;
|
||||||
// echo "<pre>";
|
|
||||||
// print_r($data['doc_list']);die;
|
|
||||||
|
|
||||||
foreach ($data['doc_list'] as $index => $value) {
|
foreach ($data['doc_list'] as $index => $value) {
|
||||||
foreach (json_decode($value['business_id']) as $key => $values) {
|
foreach (json_decode($value['business_id']) as $key => $values) {
|
||||||
if($values == $business_id){
|
if($values == $business_id){
|
||||||
@ -461,30 +334,19 @@ class MasterController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($business_id_check != 0){
|
if($business_id_check != 0){
|
||||||
// print_r($value);die;
|
|
||||||
$data['doc_list'][$index] =$value;
|
$data['doc_list'][$index] =$value;
|
||||||
}else{
|
}else{
|
||||||
unset($data['doc_list'][$index]); // Remove the element completely
|
unset($data['doc_list'][$index]); // Remove the element completely
|
||||||
}
|
}
|
||||||
$business_id_check = 0;
|
$business_id_check = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// echo "<pre>";
|
|
||||||
// print_r($data['doc_list']);die;
|
|
||||||
$docStatusByClientId = [];
|
$docStatusByClientId = [];
|
||||||
|
|
||||||
|
|
||||||
// Fetch all doc_status entries and group them by client_docs_id
|
// 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')
|
$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')
|
->join('client', 'client_branch.client_id = client.client_id', 'left')
|
||||||
// ->where('client.business_id',$this->session->get('logged_in_staff_business_id'))
|
// ->where('client.business_id',$this->session->get('logged_in_staff_business_id'))
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
$data['serviceGroupData'] = $this->ServiceGroupModel->findAll();
|
$data['serviceGroupData'] = $this->ServiceGroupModel->findAll();
|
||||||
|
|
||||||
foreach ($data['serviceGroupData'] as $key => $value) {
|
foreach ($data['serviceGroupData'] as $key => $value) {
|
||||||
$check_its_okay = 0;
|
$check_its_okay = 0;
|
||||||
foreach (json_decode($value['business_id']) as $values) {
|
foreach (json_decode($value['business_id']) as $values) {
|
||||||
@ -492,16 +354,12 @@ class MasterController extends BaseController
|
|||||||
$check_its_okay =1;
|
$check_its_okay =1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($check_its_okay == 0){
|
if($check_its_okay == 0){
|
||||||
unset($data['serviceGroupData'][$key]);
|
unset($data['serviceGroupData'][$key]);
|
||||||
}
|
}
|
||||||
$check_its_okay = 0;
|
$check_its_okay = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
foreach ($data['doc_list'] as $doc) {
|
foreach ($data['doc_list'] as $doc) {
|
||||||
// print_r($doc['id']);die;
|
|
||||||
$doc_id_temp = $doc['id'];
|
$doc_id_temp = $doc['id'];
|
||||||
$docStatusByClientId[$doc_id_temp] = $this->db->table('docs_status')
|
$docStatusByClientId[$doc_id_temp] = $this->db->table('docs_status')
|
||||||
->select('created_at as doc_created_date')
|
->select('created_at as doc_created_date')
|
||||||
@ -521,16 +379,12 @@ class MasterController extends BaseController
|
|||||||
$data['business_list'][] = $business;
|
$data['business_list'][] = $business;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// echo"<pre>";
|
|
||||||
// print_r($data);die;
|
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
echo view('share_docs',$data);
|
echo view('share_docs',$data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function set_include_archived_session($checked_or_not) {
|
public function set_include_archived_session($checked_or_not) {
|
||||||
// print_r($checked_or_not);die;
|
|
||||||
if($checked_or_not == true){
|
if($checked_or_not == true){
|
||||||
// $includeArchived = $this->request->getGet('include_archived');
|
// $includeArchived = $this->request->getGet('include_archived');
|
||||||
$this->session->set('include_archived', $checked_or_not);
|
$this->session->set('include_archived', $checked_or_not);
|
||||||
@ -541,11 +395,9 @@ class MasterController extends BaseController
|
|||||||
return $this->response->setJSON(['status' => 'success']);
|
return $this->response->setJSON(['status' => 'success']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function shared_doc_non_financial_year_to(){
|
public function shared_doc_non_financial_year_to(){
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
$currentDate = new \DateTime();
|
$currentDate = new \DateTime();
|
||||||
|
|
||||||
// Determine the start and end dates of the current financial year
|
// Determine the start and end dates of the current financial year
|
||||||
if ($currentDate->format('n') >= 4) {
|
if ($currentDate->format('n') >= 4) {
|
||||||
// If the current month is April (4) or later, the financial year started this year
|
// If the current month is April (4) or later, the financial year started this year
|
||||||
@ -556,7 +408,6 @@ class MasterController extends BaseController
|
|||||||
$financialYearStart = new \DateTime(($currentDate->format('Y') - 1) . '-04-01');
|
$financialYearStart = new \DateTime(($currentDate->format('Y') - 1) . '-04-01');
|
||||||
$financialYearEnd = new \DateTime($currentDate->format('Y') . '-03-31');
|
$financialYearEnd = new \DateTime($currentDate->format('Y') . '-03-31');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert to the format suitable for your database (assuming MySQL)
|
// Convert to the format suitable for your database (assuming MySQL)
|
||||||
$financialYearStart = $financialYearStart->format('Y-m-d');
|
$financialYearStart = $financialYearStart->format('Y-m-d');
|
||||||
$financialYearEnd = $financialYearEnd->format('Y-m-d');
|
$financialYearEnd = $financialYearEnd->format('Y-m-d');
|
||||||
@ -570,18 +421,13 @@ class MasterController extends BaseController
|
|||||||
->join('client', 'client.client_id = client_branch.client_id', 'left')
|
->join('client', 'client.client_id = client_branch.client_id', 'left')
|
||||||
->orderBy('client_docs.id','DESC')
|
->orderBy('client_docs.id','DESC')
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
|
|
||||||
// print_r($data['doc_list']);die;
|
|
||||||
$data['clientdata'] = $this->ClientBranchModel->select('client.name as client_name , client_branch.name as client_branch_name , client_branch.id as client_branch_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')
|
->join('client', 'client_branch.client_id = client.client_id', 'left')
|
||||||
// ->where('client.business_id',$this->session->get('logged_in_staff_business_id'))
|
// ->where('client.business_id',$this->session->get('logged_in_staff_business_id'))
|
||||||
->findAll();
|
->findAll();
|
||||||
$data['serviceGroupData'] = $this->ServiceGroupModel->findAll();
|
$data['serviceGroupData'] = $this->ServiceGroupModel->findAll();
|
||||||
|
|
||||||
}
|
}
|
||||||
foreach ($data['doc_list'] as $doc) {
|
foreach ($data['doc_list'] as $doc) {
|
||||||
// print_r($doc['id']);die;
|
|
||||||
$doc_id_temp = $doc['id'];
|
$doc_id_temp = $doc['id'];
|
||||||
$docStatusByClientId[$doc_id_temp] = $this->db->table('docs_status')
|
$docStatusByClientId[$doc_id_temp] = $this->db->table('docs_status')
|
||||||
->select('created_at as doc_created_date')
|
->select('created_at as doc_created_date')
|
||||||
@ -601,8 +447,6 @@ class MasterController extends BaseController
|
|||||||
$data['business_list'][] = $business;
|
$data['business_list'][] = $business;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// echo"<pre>";
|
|
||||||
// print_r($data);die;
|
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
echo view('share_docs',$data);
|
echo view('share_docs',$data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
@ -618,17 +462,13 @@ class MasterController extends BaseController
|
|||||||
unset($data['id']);
|
unset($data['id']);
|
||||||
$this->ClientDocsModel->where('id', $id )->set($data)->update();
|
$this->ClientDocsModel->where('id', $id )->set($data)->update();
|
||||||
return $this->response->setJSON(['success' => true ]);
|
return $this->response->setJSON(['success' => true ]);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
$id = $this->request->getVar('doc_id');
|
$id = $this->request->getVar('doc_id');
|
||||||
$data['templateData'] = $this->ClientDocsModel->where('md5(id)',$id)->get()->getRow();
|
$data['templateData'] = $this->ClientDocsModel->where('md5(id)',$id)->get()->getRow();
|
||||||
|
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
echo view('edit_shared_doc',$data);
|
echo view('edit_shared_doc',$data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -636,33 +476,24 @@ class MasterController extends BaseController
|
|||||||
|
|
||||||
public function get_service_data()
|
public function get_service_data()
|
||||||
{
|
{
|
||||||
|
|
||||||
$service_group_id = $this->request->getVar('service_group_id');
|
$service_group_id = $this->request->getVar('service_group_id');
|
||||||
$result = $this->ServiceModel->where('service_group_id',$service_group_id)->findAll();
|
$result = $this->ServiceModel->where('service_group_id',$service_group_id)->findAll();
|
||||||
|
|
||||||
return $this->response->setJSON(['count'=>count($result) , 'data'=>$result ]);
|
return $this->response->setJSON(['count'=>count($result) , 'data'=>$result ]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_templates()
|
public function get_templates()
|
||||||
{
|
{
|
||||||
|
|
||||||
$result = $this->TemplateModel->where('service_id',$this->request->getVar('service_id'))->findAll();
|
$result = $this->TemplateModel->where('service_id',$this->request->getVar('service_id'))->findAll();
|
||||||
|
|
||||||
return $this->response->setJSON(['count'=>count($result) , 'data'=>$result ]);
|
return $this->response->setJSON(['count'=>count($result) , 'data'=>$result ]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function create_docs()
|
public function create_docs()
|
||||||
{
|
{
|
||||||
|
|
||||||
$docData = $this->request->getVar();
|
$docData = $this->request->getVar();
|
||||||
$docData['created_by'] = $this->session->has('is_staff_logged_in');
|
$docData['created_by'] = $this->session->has('is_staff_logged_in');
|
||||||
$docData['body_html'] = $this->TemplateModel->where('template_id',$this->request->getVar('template_id'))->get()->getRow()->body_html;
|
$docData['body_html'] = $this->TemplateModel->where('template_id',$this->request->getVar('template_id'))->get()->getRow()->body_html;
|
||||||
$insert = $this->ClientDocsModel->insert($docData);
|
$insert = $this->ClientDocsModel->insert($docData);
|
||||||
|
|
||||||
if($insert){
|
if($insert){
|
||||||
|
|
||||||
$data['client_docs_id'] = $insert;
|
$data['client_docs_id'] = $insert;
|
||||||
$data['is_staff'] = 1;
|
$data['is_staff'] = 1;
|
||||||
$data['created_by'] = $this->session->get('is_staff_logged_in');
|
$data['created_by'] = $this->session->get('is_staff_logged_in');
|
||||||
@ -672,8 +503,6 @@ class MasterController extends BaseController
|
|||||||
} else {
|
} else {
|
||||||
echo false;
|
echo false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function client_docs_preview()
|
public function client_docs_preview()
|
||||||
@ -683,18 +512,16 @@ class MasterController extends BaseController
|
|||||||
}else if($this->session->has('is_client_logged_in')){
|
}else if($this->session->has('is_client_logged_in')){
|
||||||
$userData = $this->ClientBranchModel->where('id',$this->session->get('is_client_logged_in'))->get()->getRow();
|
$userData = $this->ClientBranchModel->where('id',$this->session->get('is_client_logged_in'))->get()->getRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
$doc_id = $this->request->getVar('doc_id');
|
$doc_id = $this->request->getVar('doc_id');
|
||||||
$data['docData'] = $this->ClientDocsModel->docPreview($doc_id);
|
$data['docData'] = $this->ClientDocsModel->docPreview($doc_id);
|
||||||
|
$data['clientData'] = $this->ClientBranchModel->select('client.name , client.pan_no ,
|
||||||
$data['clientData'] = $this->ClientBranchModel->select('client.name , client.pan_no ,client_branch.gst_no , client_branch.mobile_no , client_branch.email , client_branch.address , client_branch.country , client_branch.state , client_branch.city , client_branch.pin_code ')
|
client_branch.gst_no , client_branch.mobile_no ,
|
||||||
|
client_branch.email , client_branch.address ,
|
||||||
|
client_branch.country , client_branch.state ,
|
||||||
|
client_branch.city , client_branch.pin_code ')
|
||||||
->join('client', 'client_branch.client_id = client.client_id', 'left')
|
->join('client', 'client_branch.client_id = client.client_id', 'left')
|
||||||
->where('client_branch.id',$data['docData']->client_branch_id)
|
->where('client_branch.id',$data['docData']->client_branch_id)
|
||||||
->get()->getRow();
|
->get()->getRow();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$data['header_html'] = $data['docData']->header_html;
|
$data['header_html'] = $data['docData']->header_html;
|
||||||
$data['footer_html'] = $data['docData']->footer_html;
|
$data['footer_html'] = $data['docData']->footer_html;
|
||||||
$data['body_html'] = $data['docData']->body_html;
|
$data['body_html'] = $data['docData']->body_html;
|
||||||
@ -703,25 +530,19 @@ class MasterController extends BaseController
|
|||||||
$placeHolder = '%'.$key.'%';
|
$placeHolder = '%'.$key.'%';
|
||||||
$data['body_html'] = str_replace($placeHolder,$value,$data['body_html']);
|
$data['body_html'] = str_replace($placeHolder,$value,$data['body_html']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($data['docData']->is_active == 1){
|
if($data['docData']->is_active == 1){
|
||||||
$DateAndYears = $data['docData']->place_holder_object;
|
$DateAndYears = $data['docData']->place_holder_object;
|
||||||
}else{
|
}else{
|
||||||
$DateAndYears = $this->dateAndYearPlaceholder();
|
$DateAndYears = $this->dateAndYearPlaceholder();
|
||||||
}
|
}
|
||||||
//replace Date and Year values in template content
|
//replace Date and Year values in template content
|
||||||
// print_r($DateAndYears);die;
|
|
||||||
foreach (json_decode($DateAndYears,true) as $key => $value) {
|
foreach (json_decode($DateAndYears,true) as $key => $value) {
|
||||||
$placeHolder = '%'.$key.'%';
|
$placeHolder = '%'.$key.'%';
|
||||||
$data['body_html'] = str_replace($placeHolder,$value,$data['body_html']);
|
$data['body_html'] = str_replace($placeHolder,$value,$data['body_html']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
echo view('layout/header', ['Data'=>$userData]);
|
echo view('layout/header', ['Data'=>$userData]);
|
||||||
echo view('client_docs_preview',$data);
|
echo view('client_docs_preview',$data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dateAndYearPlaceholder()
|
public function dateAndYearPlaceholder()
|
||||||
@ -729,8 +550,6 @@ class MasterController extends BaseController
|
|||||||
$currentDate = date('d-m-Y');
|
$currentDate = date('d-m-Y');
|
||||||
$currentYear = date('Y');
|
$currentYear = date('Y');
|
||||||
$currentMonth = date('m');
|
$currentMonth = date('m');
|
||||||
|
|
||||||
|
|
||||||
if ($currentMonth >= 4) {
|
if ($currentMonth >= 4) {
|
||||||
$financialYearStart = $currentYear . '-04-01';
|
$financialYearStart = $currentYear . '-04-01';
|
||||||
$financialYearEnd = ($currentYear + 1) . '-03-31';
|
$financialYearEnd = ($currentYear + 1) . '-03-31';
|
||||||
@ -740,7 +559,6 @@ class MasterController extends BaseController
|
|||||||
$q2 = '01-07-' . $currentYear . ' to ' . '30-09-' . $currentYear;
|
$q2 = '01-07-' . $currentYear . ' to ' . '30-09-' . $currentYear;
|
||||||
$q3 = '01-10-' . $currentYear . ' to ' . '31-12-' . $currentYear;
|
$q3 = '01-10-' . $currentYear . ' to ' . '31-12-' . $currentYear;
|
||||||
$q4 = '01-01-' . ($currentYear + 1) . ' to ' . '31-03-' . ($currentYear + 1);
|
$q4 = '01-01-' . ($currentYear + 1) . ' to ' . '31-03-' . ($currentYear + 1);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$financialYearStart = ($currentYear - 1) . '-04-01';
|
$financialYearStart = ($currentYear - 1) . '-04-01';
|
||||||
$financialYearEnd = $currentYear . '-03-31';
|
$financialYearEnd = $currentYear . '-03-31';
|
||||||
@ -751,7 +569,6 @@ class MasterController extends BaseController
|
|||||||
$q3 = '01-10-' . ($currentYear - 1) . ' to ' . '31-12-' . ($currentYear - 1);
|
$q3 = '01-10-' . ($currentYear - 1) . ' to ' . '31-12-' . ($currentYear - 1);
|
||||||
$q4 = '01-01-' . $currentYear . ' to ' . '31-03-' . $currentYear;
|
$q4 = '01-01-' . $currentYear . ' to ' . '31-03-' . $currentYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
$DateAndYears = [
|
$DateAndYears = [
|
||||||
"CD" => $currentDate,
|
"CD" => $currentDate,
|
||||||
"CY" => $currentYear,
|
"CY" => $currentYear,
|
||||||
@ -762,9 +579,7 @@ class MasterController extends BaseController
|
|||||||
"Q3" => $q3,
|
"Q3" => $q3,
|
||||||
"Q4" => $q4,
|
"Q4" => $q4,
|
||||||
];
|
];
|
||||||
|
|
||||||
return json_encode($DateAndYears);
|
return json_encode($DateAndYears);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function client_docs_histroy($doc_id)
|
public function client_docs_histroy($doc_id)
|
||||||
@ -774,18 +589,14 @@ class MasterController extends BaseController
|
|||||||
}else if($this->session->has('is_client_logged_in')){
|
}else if($this->session->has('is_client_logged_in')){
|
||||||
$userData = $this->ClientBranchModel->where('id',$this->session->get('is_client_logged_in'))->get()->getRow();
|
$userData = $this->ClientBranchModel->where('id',$this->session->get('is_client_logged_in'))->get()->getRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['docData'] = $this->ClientDocsModel->docPreview($doc_id);
|
$data['docData'] = $this->ClientDocsModel->docPreview($doc_id);
|
||||||
|
|
||||||
// Fetch the document history
|
// Fetch the document history
|
||||||
$clientDocHistory = $this->DocsStatusModel->select('*')
|
$clientDocHistory = $this->DocsStatusModel->select('*')
|
||||||
->where('client_docs_id', $doc_id)
|
->where('client_docs_id', $doc_id)
|
||||||
->get()
|
->get()
|
||||||
->getResult();
|
->getResult();
|
||||||
|
|
||||||
// Initialize an array to store the augmented results
|
// Initialize an array to store the augmented results
|
||||||
$augmentedHistory = [];
|
$augmentedHistory = [];
|
||||||
|
|
||||||
foreach ($clientDocHistory as $history) {
|
foreach ($clientDocHistory as $history) {
|
||||||
if ($history->is_staff == 1) {
|
if ($history->is_staff == 1) {
|
||||||
// Fetch staff details
|
// Fetch staff details
|
||||||
@ -804,75 +615,45 @@ class MasterController extends BaseController
|
|||||||
$history->creator_details = $clientDetails;
|
$history->creator_details = $clientDetails;
|
||||||
$history->creator_type = 'client';
|
$history->creator_type = 'client';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the augmented history to the array
|
// Add the augmented history to the array
|
||||||
$augmentedHistory[] = $history;
|
$augmentedHistory[] = $history;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign the augmented history to the data array
|
// Assign the augmented history to the data array
|
||||||
$data['client_doc_history'] = $augmentedHistory;
|
$data['client_doc_history'] = $augmentedHistory;
|
||||||
|
|
||||||
// Debug output
|
// Debug output
|
||||||
// echo "<pre>";
|
|
||||||
// print_r($data['client_doc_history']);
|
|
||||||
// die;
|
|
||||||
return json_encode($data);
|
return json_encode($data);
|
||||||
|
|
||||||
// echo view('layout/header', ['Data'=>$userData]);
|
|
||||||
// echo view('doc_history',$data);
|
|
||||||
// echo view('layout/footer');
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function change_doc_status()
|
public function change_doc_status()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$doc_id = $this->request->getPost('doc_id');
|
$doc_id = $this->request->getPost('doc_id');
|
||||||
$is_active = $this->request->getPost('is_active');
|
$is_active = $this->request->getPost('is_active');
|
||||||
$data['is_active'] = $is_active;
|
$data['is_active'] = $is_active;
|
||||||
|
|
||||||
if($is_active == 1){
|
if($is_active == 1){
|
||||||
|
|
||||||
$DateAndYears = $this->dateAndYearPlaceholder();
|
$DateAndYears = $this->dateAndYearPlaceholder();
|
||||||
$data['place_holder_object'] = $DateAndYears;
|
$data['place_holder_object'] = $DateAndYears;
|
||||||
|
|
||||||
$MailHelper = new MailHelper();
|
$MailHelper = new MailHelper();
|
||||||
|
|
||||||
$clientData = $this->ClientDocsModel->select('client.name , client_branch.email, client_branch.*')
|
$clientData = $this->ClientDocsModel->select('client.name , client_branch.email, client_branch.*')
|
||||||
->join('client_branch', 'client_docs.client_branch_id = client_branch.id', 'left')
|
->join('client_branch', 'client_docs.client_branch_id = client_branch.id', 'left')
|
||||||
->join('client', 'client_branch.client_id = client.client_id', 'left')
|
->join('client', 'client_branch.client_id = client.client_id', 'left')
|
||||||
->where('client_docs.id', $doc_id)->get()->getRow();
|
->where('client_docs.id', $doc_id)->get()->getRow();
|
||||||
|
|
||||||
$documentUrl = base_url();
|
$documentUrl = base_url();
|
||||||
helper('url');
|
helper('url');
|
||||||
$url ='<a href="' . generate_signed_url('preview', ['doc_id'=> md5($doc_id)], 36000) . '">Preview and Approve Document</a>';
|
$url ='<a href="' . generate_signed_url('preview', ['doc_id'=> md5($doc_id)], 36000) . '">Preview and Approve Document</a>';
|
||||||
// $url = '<a href="' . $documentUrl . '">Preview and Approve Document</a>';
|
|
||||||
|
|
||||||
$businessData = $this->BranchModel->select('branches.* , business.business_name ')
|
$businessData = $this->BranchModel->select('branches.* , business.business_name ')
|
||||||
->join('business', 'branches.business_id = business.business_id', 'left')
|
->join('business', 'branches.business_id = business.business_id', 'left')
|
||||||
// ->where('branches.branch_id',$this->session->get('logged_in_staff_branch_id'))
|
->where('branches.branch_id',$this->session->get('logged_in_staff_branch_id'))
|
||||||
->where('branches.branch_id',1)
|
|
||||||
->get()->getRow();
|
->get()->getRow();
|
||||||
$subject = 'BB-Sign Verify Document';
|
$subject = 'BB-Sign Verify Document';
|
||||||
$message = "Dear " . $clientData->name . ",<br>" . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve.<br><br>" . $url;
|
$message = "Dear " . $clientData->name . ",<br>" . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve.<br><br>" . $url;
|
||||||
|
|
||||||
$mail_send = $MailHelper->send_url_email($clientData->email , $businessData->email, $subject, $message);
|
$mail_send = $MailHelper->send_url_email($clientData->email , $businessData->email, $subject, $message);
|
||||||
|
|
||||||
$notificationHelper = new NotificationHelper();
|
$notificationHelper = new NotificationHelper();
|
||||||
$number = '91'.$clientData->mobile_no; // Replace with dynamic recipient number
|
$number = '91'.$clientData->mobile_no; // Replace with dynamic recipient number
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if($clientData->whatsapp == 1){
|
if($clientData->whatsapp == 1){
|
||||||
$whatsApp_message = "Dear " . $clientData->name . "," . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve." ;
|
$whatsApp_message = "Dear " . $clientData->name . "," . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve." ;
|
||||||
$notificationHelper->sendWhatsAppMessage($number, $whatsApp_message, $url);
|
$notificationHelper->sendWhatsAppMessage($number, $whatsApp_message, $url);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$statusData['client_docs_id'] = $doc_id;
|
$statusData['client_docs_id'] = $doc_id;
|
||||||
$statusData['is_staff'] = 1;
|
$statusData['is_staff'] = 1;
|
||||||
$statusData['created_by'] = $this->session->get('is_staff_logged_in');
|
$statusData['created_by'] = $this->session->get('is_staff_logged_in');
|
||||||
@ -885,9 +666,7 @@ class MasterController extends BaseController
|
|||||||
$statusData['status'] = 'Revert';
|
$statusData['status'] = 'Revert';
|
||||||
$this->DocsStatusModel->insert($statusData);
|
$this->DocsStatusModel->insert($statusData);
|
||||||
}
|
}
|
||||||
|
|
||||||
$updated = $this->ClientDocsModel->update($doc_id, $data);
|
$updated = $this->ClientDocsModel->update($doc_id, $data);
|
||||||
|
|
||||||
if ($updated) {
|
if ($updated) {
|
||||||
return $this->response->setJSON(['status' => 'success','code' => 200,'data' => true],200);
|
return $this->response->setJSON(['status' => 'success','code' => 200,'data' => true],200);
|
||||||
} else {
|
} else {
|
||||||
@ -899,60 +678,42 @@ class MasterController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function rememeber_notification()
|
public function rememeber_notification()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$doc_id = $this->request->getPost('doc_id');
|
$doc_id = $this->request->getPost('doc_id');
|
||||||
|
|
||||||
$MailHelper = new MailHelper();
|
$MailHelper = new MailHelper();
|
||||||
|
|
||||||
$clientData = $this->ClientDocsModel->select('client.name , client_branch.email, client_branch.mobile_no')
|
$clientData = $this->ClientDocsModel->select('client.name , client_branch.email, client_branch.mobile_no')
|
||||||
->join('client_branch', 'client_docs.client_branch_id = client_branch.id', 'left')
|
->join('client_branch', 'client_docs.client_branch_id = client_branch.id', 'left')
|
||||||
->join('client', 'client_branch.client_id = client.client_id', 'left')
|
->join('client', 'client_branch.client_id = client.client_id', 'left')
|
||||||
->where('client_docs.id', $doc_id)->get()->getRow();
|
->where('client_docs.id', $doc_id)->get()->getRow();
|
||||||
|
|
||||||
helper('url');
|
helper('url');
|
||||||
$url ='<a href="' . generate_signed_url('preview', ['doc_id'=>md5($doc_id)], 100) . '">Preview and Approve Document</a>';
|
$url ='<a href="' . generate_signed_url('preview', ['doc_id'=>md5($doc_id)], 100) . '">Preview and Approve Document</a>';
|
||||||
|
|
||||||
// $url = '<a href="'.base_url().'">Click here</a>';
|
|
||||||
|
|
||||||
$businessData = $this->BranchModel->select('branches.* , business.business_name ')
|
$businessData = $this->BranchModel->select('branches.* , business.business_name ')
|
||||||
->join('business', 'branches.business_id = business.business_id', 'left')
|
->join('business', 'branches.business_id = business.business_id', 'left')
|
||||||
->where('branches.branch_id',$this->session->get('logged_in_staff_branch_id'))
|
->where('branches.branch_id',$this->session->get('logged_in_staff_branch_id'))
|
||||||
->get()->getRow();
|
->get()->getRow();
|
||||||
$subject = 'BB-Sign Verify Document';
|
$subject = 'BB-Sign Verify Document';
|
||||||
$message = "Dear " . $clientData->name . ",<br>" . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve.<br><br>" . $url;
|
$message = "Dear " . $clientData->name . ",<br>" . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve.<br><br>" . $url;
|
||||||
|
|
||||||
$MailHelper->send_url_email($clientData->email , $businessData->email, $subject, $message);
|
$MailHelper->send_url_email($clientData->email , $businessData->email, $subject, $message);
|
||||||
|
|
||||||
$notificationHelper = new NotificationHelper();
|
$notificationHelper = new NotificationHelper();
|
||||||
$number = '91'.$clientData->mobile_no; // Replace with dynamic recipient number
|
$number = '91'.$clientData->mobile_no; // Replace with dynamic recipient number
|
||||||
|
|
||||||
if($clientData->whatsapp == 1){
|
if($clientData->whatsapp == 1){
|
||||||
$whatsApp_message = "Dear " . $clientData->name . "," . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve." ;
|
$whatsApp_message = "Dear " . $clientData->name . "," . $businessData->business_name . " has requested your approval for a document. Please click the link below to preview and approve." ;
|
||||||
$notificationHelper->sendWhatsAppMessage($number, $whatsApp_message, $url);
|
$notificationHelper->sendWhatsAppMessage($number, $whatsApp_message, $url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return $this->respond(['success' => true, 'data' => 'Remember Send Successfully']);
|
return $this->respond(['success' => true, 'data' => 'Remember Send Successfully']);
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
return $this->response->setJSON(['status' => 'failed','code' => 500,'data' => $exception],500);
|
return $this->response->setJSON(['status' => 'failed','code' => 500,'data' => $exception],500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function doc_generate_otp()
|
public function doc_generate_otp()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$mobile_no = $this->request->getPost('mobile_no');
|
$mobile_no = $this->request->getPost('mobile_no');
|
||||||
|
|
||||||
$client_data = $this->ClientBranchModel->where('mobile_no', $mobile_no )->first();
|
$client_data = $this->ClientBranchModel->where('mobile_no', $mobile_no )->first();
|
||||||
|
|
||||||
|
|
||||||
if($client_data){
|
if($client_data){
|
||||||
|
|
||||||
$id = $this->request->getPost('doc_id');
|
$id = $this->request->getPost('doc_id');
|
||||||
$otp = mt_rand(100000, 999999);
|
$otp = mt_rand(100000, 999999);
|
||||||
$data = ['otp' => $otp];
|
$data = ['otp' => $otp];
|
||||||
@ -964,25 +725,18 @@ class MasterController extends BaseController
|
|||||||
->join('client', 'client.client_id = client_branch.client_id', 'left')
|
->join('client', 'client.client_id = client_branch.client_id', 'left')
|
||||||
->where('client_docs.id', $id)
|
->where('client_docs.id', $id)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
|
|
||||||
$update = $this->ClientDocsModel->update($id, $data);
|
$update = $this->ClientDocsModel->update($id, $data);
|
||||||
|
|
||||||
if($update){
|
if($update){
|
||||||
$notificationHelper = new NotificationHelper();
|
$notificationHelper = new NotificationHelper();
|
||||||
$number = '91'.$mobile_no; // Replace with dynamic recipient number
|
$number = '91'.$mobile_no; // Replace with dynamic recipient number
|
||||||
$message = 'Document Verification OTP : ' . $otp;
|
$message = 'Document Verification OTP : ' . $otp;
|
||||||
|
|
||||||
|
|
||||||
if($client_data['whatsapp'] == 1){
|
if($client_data['whatsapp'] == 1){
|
||||||
$notificationHelper->sendWhatsAppMessage($number, $message);
|
$notificationHelper->sendWhatsAppMessage($number, $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($client_data['sms'] == 1){
|
if($client_data['sms'] == 1){
|
||||||
$notificationHelper->sendSms($number, $client_data['name'] , $otp, '', 'doc_verify',$clint_full_data);
|
$notificationHelper->sendSms($number, $client_data['name'] , $otp, '', 'doc_verify',$clint_full_data);
|
||||||
}
|
}
|
||||||
return $this->respond(['success' => true, 'otp' => $otp]);
|
return $this->respond(['success' => true, 'otp' => $otp]);
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -993,23 +747,17 @@ class MasterController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function doc_verify_otp()
|
public function doc_verify_otp()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$id = $this->request->getPost('doc_id');
|
$id = $this->request->getPost('doc_id');
|
||||||
$otp = $this->request->getPost('otp');
|
$otp = $this->request->getPost('otp');
|
||||||
|
|
||||||
$client_doc_data = $this->ClientDocsModel->where('id', $id )->where('otp', $otp)->first();
|
$client_doc_data = $this->ClientDocsModel->where('id', $id )->where('otp', $otp)->first();
|
||||||
$data = ['otp' =>'' ,'rejection_reason' =>''];
|
$data = ['otp' =>'' ,'rejection_reason' =>''];
|
||||||
|
|
||||||
if($client_doc_data){
|
if($client_doc_data){
|
||||||
|
|
||||||
$data['is_approved'] = $this->request->getPost('is_approved');
|
$data['is_approved'] = $this->request->getPost('is_approved');
|
||||||
$data['ip_address'] = $this->request->getPost('clientIp');
|
$data['ip_address'] = $this->request->getPost('clientIp');
|
||||||
|
|
||||||
$update = $this->ClientDocsModel->update($id , $data);
|
$update = $this->ClientDocsModel->update($id , $data);
|
||||||
|
|
||||||
if($this->session->has('is_client_logged_in')){
|
if($this->session->has('is_client_logged_in')){
|
||||||
$logged_user = $this->session->get('is_client_logged_in');
|
$logged_user = $this->session->get('is_client_logged_in');
|
||||||
$statusData['is_staff'] = 0;
|
$statusData['is_staff'] = 0;
|
||||||
@ -1022,13 +770,10 @@ class MasterController extends BaseController
|
|||||||
$statusData['status'] = 'Approved';
|
$statusData['status'] = 'Approved';
|
||||||
$statusData['note'] = $this->request->getPost('clientIp');
|
$statusData['note'] = $this->request->getPost('clientIp');
|
||||||
$this->DocsStatusModel->insert($statusData);
|
$this->DocsStatusModel->insert($statusData);
|
||||||
|
|
||||||
if($update){
|
if($update){
|
||||||
return json_encode(true);
|
return json_encode(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
|
||||||
return json_encode('');
|
return json_encode('');
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -1037,16 +782,12 @@ class MasterController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function status_service()
|
public function status_service()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$service_id = $this->request->getPost('service_id');
|
$service_id = $this->request->getPost('service_id');
|
||||||
$is_active = $this->request->getPost('is_active');
|
$is_active = $this->request->getPost('is_active');
|
||||||
$data = ['is_active' => $is_active];
|
$data = ['is_active' => $is_active];
|
||||||
|
|
||||||
$updated = $this->ServiceModel->update($service_id, $data);
|
$updated = $this->ServiceModel->update($service_id, $data);
|
||||||
if ($updated) {
|
if ($updated) {
|
||||||
return $this->respond(['status' => 'success','code' => 200,'data' => true],200);
|
return $this->respond(['status' => 'success','code' => 200,'data' => true],200);
|
||||||
@ -1059,24 +800,18 @@ class MasterController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function download_doc(){
|
public function download_doc(){
|
||||||
if ($this->request->getMethod() === 'POST') {
|
if ($this->request->getMethod() === 'POST') {
|
||||||
// Get the HTML content from the POST request
|
// Get the HTML content from the POST request
|
||||||
$htmlContent = $this->request->getPost('htmlContent');
|
$htmlContent = $this->request->getPost('htmlContent');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Create new PDF document
|
// Create new PDF document
|
||||||
$mpdf = new Mpdf();
|
$mpdf = new Mpdf();
|
||||||
$mpdf->WriteHTML($htmlContent);
|
$mpdf->WriteHTML($htmlContent);
|
||||||
|
|
||||||
// Output PDF to a string
|
// Output PDF to a string
|
||||||
$pdfContent = $mpdf->Output('', 'S');
|
$pdfContent = $mpdf->Output('', 'S');
|
||||||
|
|
||||||
// Encode PDF content to base64
|
// Encode PDF content to base64
|
||||||
$base64Pdf = base64_encode($pdfContent);
|
$base64Pdf = base64_encode($pdfContent);
|
||||||
// print_r("hello");die;
|
|
||||||
|
|
||||||
// Set response headers
|
// Set response headers
|
||||||
return $this->respond(['pdf' => $base64Pdf], 200);
|
return $this->respond(['pdf' => $base64Pdf], 200);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@ -1088,6 +823,4 @@ class MasterController extends BaseController
|
|||||||
return $this->fail('Invalid request method', 405);
|
return $this->fail('Invalid request method', 405);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,6 @@ use App\Models\TemplateModel;
|
|||||||
|
|
||||||
use CodeIgniter\API\ResponseTrait;
|
use CodeIgniter\API\ResponseTrait;
|
||||||
|
|
||||||
|
|
||||||
class StaffController extends BaseController
|
class StaffController extends BaseController
|
||||||
{
|
{
|
||||||
public $session;
|
public $session;
|
||||||
@ -39,17 +38,13 @@ class StaffController extends BaseController
|
|||||||
$this->TemplateModel = new TemplateModel();
|
$this->TemplateModel = new TemplateModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function set_business_in_session($business_id){
|
public function set_business_in_session($business_id){
|
||||||
$this->session->set('logged_in_staff_business_id', $business_id);
|
$this->session->set('logged_in_staff_business_id', $business_id);
|
||||||
|
|
||||||
return json_encode(true);
|
return json_encode(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function login()
|
public function login()
|
||||||
{
|
{
|
||||||
|
|
||||||
// if($this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff_home'); }
|
|
||||||
if($this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff_list'); }
|
if($this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff_list'); }
|
||||||
if($this->request->getmethod() == 'POST')
|
if($this->request->getmethod() == 'POST')
|
||||||
{
|
{
|
||||||
@ -63,21 +58,17 @@ class StaffController extends BaseController
|
|||||||
$this->session->setTempdata('error','Staff Deactivated',3);
|
$this->session->setTempdata('error','Staff Deactivated',3);
|
||||||
return redirect()->to(base_url()."staff");
|
return redirect()->to(base_url()."staff");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (password_verify($password, $staffdata['password']))
|
if (password_verify($password, $staffdata['password']))
|
||||||
{
|
{
|
||||||
$this->session->set('is_staff_logged_in',$staffdata['staff_id']);
|
$this->session->set('is_staff_logged_in',$staffdata['staff_id']);
|
||||||
$this->session->set('logged_in_staff_role',$staffdata['role']);
|
$this->session->set('logged_in_staff_role',$staffdata['role']);
|
||||||
$this->session->set('logged_in_staff_name',$staffdata['name']);
|
$this->session->set('logged_in_staff_name',$staffdata['name']);
|
||||||
// $this->session->set('logged_in_staff_branch_id',$staffdata['branch_id']);
|
// $this->session->set('logged_in_staff_branch_id',$staffdata['branch_id']);
|
||||||
|
|
||||||
|
|
||||||
if($staffdata['role'] == 'Admin'){
|
if($staffdata['role'] == 'Admin'){
|
||||||
$this->session->set('logged_in_staff_business_id', 0);
|
$this->session->set('logged_in_staff_business_id', 0);
|
||||||
}else{
|
}else{
|
||||||
$this->session->set('logged_in_staff_business_id',json_decode($staffdata['business_id'])[0]);
|
$this->session->set('logged_in_staff_business_id',json_decode($staffdata['business_id'])[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect()->to(base_url().'shared_docs_list');
|
return redirect()->to(base_url().'shared_docs_list');
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@ -88,10 +79,7 @@ class StaffController extends BaseController
|
|||||||
$this->session->setTempdata('error','Email or Password is invalid',3);
|
$this->session->setTempdata('error','Email or Password is invalid',3);
|
||||||
return redirect()->to(base_url()."staff");
|
return redirect()->to(base_url()."staff");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//get method
|
//get method
|
||||||
return view('staff_login');
|
return view('staff_login');
|
||||||
}
|
}
|
||||||
@ -103,18 +91,10 @@ class StaffController extends BaseController
|
|||||||
return redirect()->to(base_url()."staff");
|
return redirect()->to(base_url()."staff");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// staff crud
|
// staff crud
|
||||||
public function staff_list()
|
public function staff_list()
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
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'));
|
$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();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
@ -123,81 +103,60 @@ class StaffController extends BaseController
|
|||||||
}
|
}
|
||||||
public function staff_create()
|
public function staff_create()
|
||||||
{
|
{
|
||||||
|
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
|
|
||||||
if($this->request->getmethod() == 'POST')
|
if($this->request->getmethod() == 'POST')
|
||||||
{
|
{
|
||||||
$email = $this->request->getVar('email');
|
$email = $this->request->getVar('email');
|
||||||
$staff = $this->StaffModel->where('email', $email)->first();
|
$staff = $this->StaffModel->where('email', $email)->first();
|
||||||
|
|
||||||
if($staff){
|
if($staff){
|
||||||
return json_encode('mail_exists');
|
return json_encode('mail_exists');
|
||||||
}else{
|
}else{
|
||||||
$staffData = $this->request->getVar();
|
$staffData = $this->request->getVar();
|
||||||
$staffData['created_by'] = $this->session->get('is_staff_logged_in');
|
$staffData['created_by'] = $this->session->get('is_staff_logged_in');
|
||||||
// $staffData['branch_id'] = $this->session->get('logged_in_staff_branch_id');
|
|
||||||
|
|
||||||
$staffData['business_id'] = json_encode($this->request->getVar('business_id'));
|
$staffData['business_id'] = json_encode($this->request->getVar('business_id'));
|
||||||
|
|
||||||
$insert = $this->StaffModel->save($staffData);
|
$insert = $this->StaffModel->save($staffData);
|
||||||
if($insert)
|
if($insert)
|
||||||
{
|
{
|
||||||
return json_encode('staff_created');
|
return json_encode('staff_created');
|
||||||
// return redirect()->to(base_url()."staff_list");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
$data['business'] = $this->BusinessModel->where('isactive', 1)->findAll();
|
$data['business'] = $this->BusinessModel->where('isactive', 1)->findAll();
|
||||||
// $data['branch'] = $this->BranchModel->where('isactive', 1)->findAll();
|
|
||||||
$data['page_heading'] = "Create Staff";
|
$data['page_heading'] = "Create Staff";
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
echo view('staff_form', $data);
|
echo view('staff_form', $data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function staff_edit($staff_id = null)
|
public function staff_edit($staff_id = null)
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
if($this->request->getmethod() == 'POST')
|
if($this->request->getmethod() == 'POST')
|
||||||
{
|
{
|
||||||
//update staff details
|
|
||||||
$staffData = $this->request->getVar();
|
$staffData = $this->request->getVar();
|
||||||
$staffData['updated_by'] = $this->session->get('is_staff_logged_in');
|
$staffData['updated_by'] = $this->session->get('is_staff_logged_in');
|
||||||
|
|
||||||
$staff_id = $this->request->getVar('id');
|
$staff_id = $this->request->getVar('id');
|
||||||
$staffData['business_id'] = json_encode($this->request->getVar('business_id'));
|
$staffData['business_id'] = json_encode($this->request->getVar('business_id'));
|
||||||
|
|
||||||
$this->StaffModel->where('staff_id', $staff_id )->set($staffData)->update();
|
$this->StaffModel->where('staff_id', $staff_id )->set($staffData)->update();
|
||||||
|
|
||||||
return json_encode('edit_success');
|
return json_encode('edit_success');
|
||||||
// return redirect()->to(base_url()."staff_list");
|
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
$data['staffData'] = $this->StaffModel->where('md5(staff.staff_id)', $this->request->getVar('staff_id') )->get()->getRow();
|
$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();
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
||||||
$data['business'] = $this->BusinessModel->where('isactive', 1)->findAll();
|
$data['business'] = $this->BusinessModel->where('isactive', 1)->findAll();
|
||||||
// $data['branch'] = $this->BranchModel->where('isactive', 1)->findAll();
|
|
||||||
// print_r($data['staffData']->business_id);die;
|
|
||||||
$data['page_heading'] = "Edit Staff";
|
$data['page_heading'] = "Edit Staff";
|
||||||
echo view('layout/header', ['Data'=>$staffdata]);
|
echo view('layout/header', ['Data'=>$staffdata]);
|
||||||
echo view('staff_form',$data);
|
echo view('staff_form',$data);
|
||||||
echo view('layout/footer');
|
echo view('layout/footer');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
public function business_view($staff_id)
|
||||||
|
{
|
||||||
|
|
||||||
public function business_view($staff_id){
|
|
||||||
|
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$staff_id)->first();
|
$staffdata = $this->StaffModel->where('staff_id',$staff_id)->first();
|
||||||
$businessData =[];
|
$businessData =[];
|
||||||
$businessIds = json_decode($staffdata['business_id']);
|
$businessIds = json_decode($staffdata['business_id']);
|
||||||
|
|
||||||
if (isset($businessIds) && is_array($businessIds)) {
|
if (isset($businessIds) && is_array($businessIds)) {
|
||||||
foreach ($businessIds as $key => $value) {
|
foreach ($businessIds as $key => $value) {
|
||||||
$businessData[] = $this->BusinessModel->where('business_id', $value)->first();
|
$businessData[] = $this->BusinessModel->where('business_id', $value)->first();
|
||||||
@ -205,21 +164,17 @@ class StaffController extends BaseController
|
|||||||
}else{
|
}else{
|
||||||
$businessData[] = $this->BusinessModel->where('business_id', $businessIds)->first();
|
$businessData[] = $this->BusinessModel->where('business_id', $businessIds)->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
return json_encode($businessData);
|
return json_encode($businessData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// client crud
|
// client crud
|
||||||
public function client_list()
|
public function client_list()
|
||||||
{
|
{
|
||||||
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
|
||||||
|
|
||||||
|
|
||||||
$data['clientList'] = $this->ClientModel->findAll();
|
$data['clientList'] = $this->ClientModel->findAll();
|
||||||
|
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))
|
||||||
$staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
|
->get()
|
||||||
|
->getRow();
|
||||||
foreach (json_decode($staffdata->business_id) as $key => $value) {
|
foreach (json_decode($staffdata->business_id) as $key => $value) {
|
||||||
$business = $this->BusinessModel->where('business_id', $value)->first();
|
$business = $this->BusinessModel->where('business_id', $value)->first();
|
||||||
if ($business) {
|
if ($business) {
|
||||||
|
|||||||
@ -180,7 +180,6 @@
|
|||||||
<ul class="list-unstyled topnav-menu float-right mb-0">
|
<ul class="list-unstyled topnav-menu float-right mb-0">
|
||||||
|
|
||||||
<li class="nav-item dropdown" >
|
<li class="nav-item dropdown" >
|
||||||
<?php if(isset($_SESSION['logged_in_staff_business_id']) && $_SESSION['logged_in_staff_business_id']) { ?>
|
|
||||||
|
|
||||||
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-Service" role="button"
|
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-Service" role="button"
|
||||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
@ -189,7 +188,6 @@
|
|||||||
<div class="dropdown-menu busines_menu_header_staff_view" aria-labelledby="topnav-Service">
|
<div class="dropdown-menu busines_menu_header_staff_view" aria-labelledby="topnav-Service">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<?php if(isset($_SESSION['logged_in_staff_business_id']) && $_SESSION['logged_in_staff_business_id']) { ?>
|
<?php if(isset($_SESSION['logged_in_staff_business_id']) && $_SESSION['logged_in_staff_business_id']) { ?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user