diff --git a/app/Config/Routes.php b/app/Config/Routes.php index e1f2782..3437c08 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -51,6 +51,7 @@ use CodeIgniter\Router\RouteCollection; $routes->match(['get','post'],'/service_list','MasterController::service_list'); $routes->match(['get','post'],'/service_create','MasterController::service_create'); $routes->match(['get','post'],'/service_edit','MasterController::service_edit'); + $routes->post('status_service','MasterController::status_service'); $routes->match(['get','post'],'/template_list','MasterController::template_list'); @@ -68,6 +69,7 @@ use CodeIgniter\Router\RouteCollection; $routes->match(['get','post'],'/test','MasterController::test'); $routes->post('doc_generate_otp','MasterController::doc_generate_otp'); $routes->post('doc_verify_otp','MasterController::doc_verify_otp'); + $routes->post('download_doc','MasterController::download_doc'); @@ -78,15 +80,16 @@ use CodeIgniter\Router\RouteCollection; $routes->get('get_business/(:any)','BusinessController::get_business/$1'); $routes->get('business','BusinessController::business'); $routes->post('business_edit','BusinessController::business_edit'); - + $routes->post('status_business','BusinessController::status_business'); + $routes->get('branch_index','BranchController::branch_index'); $routes->get('new_business/(:any)','BranchController::new_business/$1'); - $routes->get('delete_branch/(:any)','BranchController::delete_branch/$1'); $routes->get('get_branch/(:any)','BranchController::get_branch/$1'); $routes->post('edit_branch/(:any)','BranchController::edit_branch/$1'); $routes->post('add_branch','BranchController::new_branch'); $routes->post('branch_edit','BranchController::branch_edit'); + $routes->post('status_branch','BranchController::status_branch'); \ No newline at end of file diff --git a/app/Controllers/BranchController.php b/app/Controllers/BranchController.php index e81708e..05405a6 100644 --- a/app/Controllers/BranchController.php +++ b/app/Controllers/BranchController.php @@ -7,17 +7,23 @@ use App\Models\BranchModel; use App\Models\BusinessModel; use App\Models\StaffModel; +use CodeIgniter\API\ResponseTrait; + class BranchController extends BaseController { public $session; + protected $BranchModel; protected $StaffModel; + use ResponseTrait; + public function __construct() { $this->session = session(); + $this->BranchModel = new BranchModel(); $this->StaffModel = new StaffModel(); } @@ -105,25 +111,24 @@ class BranchController extends BaseController } - - public function delete_branch($branch_id) + public function status_branch() { - $model = new BranchModel(); - $where = ['branch_id' => $branch_id]; // Assuming 'isactive' is a column in your database - $existingBranch = $model->where($where)->first(); - - if ($existingBranch) { - $data['isactive'] = 0; - - if ($model->update($branch_id, $data)) { - session()->setFlashdata('success', 'Deleted successfully.'); - $this->logger->info("Branch: has been Inactivated successfully. Inactivated ID = ".$branch_id); + try { + $branch_id = $this->request->getPost('branch_id'); + $isactive = $this->request->getPost('isactive'); + $data = ['isactive' => $isactive]; + + $updated = $this->BranchModel->update($branch_id, $data); + if ($updated) { + return $this->respond(['status' => 'success','code' => 200,'data' => true],200); + } else { + $result = "No Match's"; + return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); } + } catch (\Exception $exception) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500); } - - - return redirect()->to('branch_index'); } } \ No newline at end of file diff --git a/app/Controllers/BusinessController.php b/app/Controllers/BusinessController.php index 489142e..47b7ee4 100644 --- a/app/Controllers/BusinessController.php +++ b/app/Controllers/BusinessController.php @@ -6,6 +6,8 @@ use App\Models\BusinessModel; use App\Models\BranchModel; use App\Models\StaffModel; +use CodeIgniter\API\ResponseTrait; + class BusinessController extends BaseController @@ -15,6 +17,7 @@ class BusinessController extends BaseController protected $BranchModel; protected $StaffModel; + use ResponseTrait; public function __construct() { @@ -210,9 +213,27 @@ class BusinessController extends BaseController } - public function business_branch_list() + public function status_business() { - + try { + $business_id = $this->request->getPost('business_id'); + $isactive = $this->request->getPost('isactive'); + $data = ['isactive' => $isactive]; + + $updated = $this->BusinessModel->update($business_id, $data); + if ($updated) { + $BranchList = $this->BranchModel->where('business_id', $business_id)->findAll(); + foreach ($BranchList as $key => $value) { + $this->BranchModel->update($value['branch_id'], $data); + } + return $this->respond(['status' => 'success','code' => 200,'data' => true],200); + } else { + $result = "No Match's"; + return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); + } + } catch (\Exception $exception) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500); + } } } diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index e24dc17..dd333d0 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -227,6 +227,14 @@ class ClientController extends BaseController $updated = $this->ClientModel->update($client_id, $data); if ($updated) { + + $client_branch_list = $this->ClientBranchModel->where('client_id', $client_id)->findAll(); + + foreach($client_branch_list as $key=> $value){ + $this->ClientBranchModel->update($value['id'], $data); + } + + return $this->respond(['status' => 'success','code' => 200,'data' => true],200); } else { $result = "No Match's"; diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 7d6eb7a..3d03fb6 100644 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -14,6 +14,11 @@ use App\Models\ServiceGroupModel; use App\Models\ClientBranchModel; use App\Models\DocsStatusModel; +use \Mpdf\Mpdf; + + +use CodeIgniter\API\ResponseTrait; + class MasterController extends BaseController { public $session; @@ -28,6 +33,8 @@ class MasterController extends BaseController protected $ClientBranchModel; protected $DocsStatusModel; + use ResponseTrait; + public function __construct() { @@ -543,9 +550,54 @@ class MasterController extends BaseController + public function status_service() + { + try { + $service_id = $this->request->getPost('service_id'); + $is_active = $this->request->getPost('is_active'); + $data = ['is_active' => $is_active]; + + $updated = $this->ServiceModel->update($service_id, $data); + if ($updated) { + return $this->respond(['status' => 'success','code' => 200,'data' => true],200); + } else { + $result = "No Match's"; + return $this->respond(['status' => 'failed','code' => 404,'data' => $result],404); + } + } catch (\Exception $exception) { + return $this->respond(['status' => 'failed','code' => 500,'data' => $exception],500); + } + } + public function download_doc(){ + if ($this->request->getMethod() === 'POST') { + // Get the HTML content from the POST request + $htmlContent = $this->request->getPost('htmlContent'); + try { + // Create new PDF document + $mpdf = new Mpdf(); + $mpdf->WriteHTML($htmlContent); + + // Output PDF to a string + $pdfContent = $mpdf->Output('', 'S'); + + // Encode PDF content to base64 + $base64Pdf = base64_encode($pdfContent); + // print_r("hello");die; + + // Set response headers + return $this->respond(['pdf' => $base64Pdf], 200); + } catch (\Exception $e) { + // Log error + log_message('error', 'Error generating PDF: ' . $e->getMessage()); + return $this->failServerError('Error generating PDF'); + } + } else { + return $this->fail('Invalid request method', 405); + } + } } diff --git a/app/Views/branch_list.php b/app/Views/branch_list.php index f5137f6..a08bbb7 100644 --- a/app/Views/branch_list.php +++ b/app/Views/branch_list.php @@ -13,7 +13,7 @@

Branch List

@@ -40,8 +40,7 @@ State Postal Code Contact - Active - + Status Action @@ -73,11 +72,14 @@ @@ -101,7 +103,7 @@
-