diff --git a/.env b/.env index 5d9257e..7e3bd14 100644 --- a/.env +++ b/.env @@ -23,7 +23,7 @@ CI_ENVIRONMENT = development #-------------------------------------------------------------------- -# app.baseURL = 'https://localhost/docs/' +# app.baseURL = 'https://localhost/bb_sign/' # If you have trouble with `.`, you could also use `_`. # app_baseURL = '' # app.forceGlobalSecureRequests = false diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 4be1309..f1b0d84 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -19,19 +19,20 @@ use CodeIgniter\Router\RouteCollection; $routes->match(['get','post'],'/forgot_password','StaffController::forgot_password'); $routes->match(['get','post'],'/verify_otp','StaffController::verify_otp'); $routes->match(['get','post'],'/change_password','StaffController::change_password'); + $routes->post('status_staff','StaffController::status_staff'); $routes->match(['get','post'],'/','ClientController::login'); $routes->get('/client_logout','ClientController::client_logout'); $routes->match(['get','post'],'/client_profile','ClientController::client_profile'); $routes->post("change_client_password/(:any)", "ClientController::change_client_password/$1"); + $routes->post('generate_otp','ClientController::generate_otp'); + $routes->post('verify_otp_client','ClientController::verify_otp'); + $routes->get('client_home','ClientController::client_home'); + $routes->post('status_client','ClientController::status_client'); - - - - - + $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'); @@ -43,4 +44,9 @@ use CodeIgniter\Router\RouteCollection; $routes->match(['get','post'],'/template_preview','MasterController::template_preview'); $routes->match(['get','post'],'/test','MasterController::test'); + + + + + \ No newline at end of file diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 6e64b3f..368bf19 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -2,30 +2,35 @@ namespace App\Controllers; use App\Models\ClientModel; +use App\Models\ClientDocsModel; + +use CodeIgniter\API\ResponseTrait; class ClientController extends BaseController { public $session; protected $ClientModel; + protected $ClientDocsModel; + use ResponseTrait; + public function __construct() { $this->session = session(); $this->ClientModel = new ClientModel(); + $this->ClientDocsModel = new ClientDocsModel(); } - + public function login() { - if($this->session->has('is_client_logged_in')){ return redirect()->to(base_url().'client_home'); } if($this->request->getmethod() == 'POST') { - $user_name = $this->request->getVar('user_name'); - $password = $this->request->getVar('password'); - $clientdata = $this->ClientModel->verifyUserName($user_name); + $pan_no = $this->request->getPost('pan_no'); + $clientdata = $this->ClientModel->where('pan_no', $pan_no)->first(); if($clientdata) { @@ -35,17 +40,12 @@ class ClientController extends BaseController return redirect()->to(base_url()); } - if (password_verify($password, $clientdata['password'])) - { + $this->session->set('is_client_logged_in',$clientdata['client_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'); - } - else{ - $this->session->setTempdata('error','Email or Password is invalid',3); - return redirect()->to(base_url()); - } + }else{ $this->session->setTempdata('error','Email or Password is invalid',3); @@ -53,8 +53,6 @@ class ClientController extends BaseController } } - - //get method return view('client_login'); } @@ -67,7 +65,20 @@ class ClientController extends BaseController } + public function client_home(){ + $client_id =$this->session->get('is_client_logged_in'); + + $data['doc_list'] = $this->ClientDocsModel->getTemplate($client_id); + // print_r($data['doc_list']);die; + $clientdata = $this->ClientModel->where('client_id', $client_id)->get()->getRow(); + + if($clientdata){ + echo view('layout/header', ['Data'=>$clientdata]); + echo view('client_home',$data); + echo view('layout/footer'); + } + } public function client_profile() @@ -131,16 +142,90 @@ class ClientController extends BaseController } - - - - - - + public function generate_otp() + { + try { + $pan_no = $this->request->getPost('pan_no'); + + $client_data = $this->ClientModel->where('pan_no', $pan_no )->first(); + + if($client_data){ + + $id = $client_data['client_id']; + + $data = [ + 'otp' => '123456' + ]; + $update = $this->ClientModel->update($id , $data); + + if($update){ + return json_encode(true); + } + } else { + return false; + } + } catch (\Exception $e) { + // Handle any exceptions that occur during execution + return $this->respond(['status' => 'error', 'code' => 500, 'message' => $e->getMessage()], 500); + } + } + + + + public function verify_otp() + { + try { + $pan_no = $this->request->getPost('pan_no'); + $otp = $this->request->getPost('otp'); + + $client_data = $this->ClientModel->where('pan_no', $pan_no )->where('otp', $otp)->first(); + $data = ['otp' =>'']; + + if($client_data){ + $id = $client_data['client_id']; + $update = $this->ClientModel->update($id , $data); + if($update){ + return json_encode(true); + } + } else { + $client_data = $this->ClientModel->where('pan_no', $pan_no )->first(); + $id = $client_data['client_id']; + + $update = $this->ClientModel->update($id , $data); + + + return false; + } + } catch (\Exception $e) { + // Handle any exceptions that occur during execution + return $this->respond(['status' => 'error', 'code' => 500, 'message' => $e->getMessage()], 500); + } + } + + public function status_client() + { + try { + $client_id = $this->request->getPost('client_id'); + $is_active = $this->request->getPost('is_active'); + $data = [ + 'is_active' => $is_active + ]; + + $updated = $this->ClientModel->update($client_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); + } + } diff --git a/app/Controllers/StaffController.php b/app/Controllers/StaffController.php index 28d40ee..7789d82 100644 --- a/app/Controllers/StaffController.php +++ b/app/Controllers/StaffController.php @@ -7,6 +7,8 @@ use App\Models\ClientModel; use App\Models\ServiceModel; use App\Models\TemplateModel; +use CodeIgniter\API\ResponseTrait; + class StaffController extends BaseController { @@ -15,6 +17,9 @@ class StaffController extends BaseController protected $ClientModel; protected $ServiceModel; protected $TemplateModel; + + use ResponseTrait; + public function __construct() { $this->session = session(); @@ -30,7 +35,8 @@ class StaffController extends BaseController 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_home'); } + if($this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff_list'); } if($this->request->getmethod() == 'POST') { $email = $this->request->getVar('email'); @@ -338,12 +344,26 @@ class StaffController extends BaseController } } + public function status_staff() + { + try { + $staff_id = $this->request->getPost('staff_id'); + $is_active = $this->request->getPost('is_active'); + $data = [ + 'is_active' => $is_active + ]; + + $updated = $this->StaffModel->update($staff_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); + } + } } diff --git a/app/Models/ClientDocsModel.php b/app/Models/ClientDocsModel.php new file mode 100644 index 0000000..c597563 --- /dev/null +++ b/app/Models/ClientDocsModel.php @@ -0,0 +1,25 @@ +select('template.*,client_docs.is_approved'); + $this->join('template', 'template.template_id = client_docs.template_id'); + $this->where('client_docs.is_active', 1); + $this->where('client_docs.client_id', $client_id); + return $this->findAll(); + + } + +} \ No newline at end of file diff --git a/app/Views/client_home.php b/app/Views/client_home.php new file mode 100644 index 0000000..b1e7003 --- /dev/null +++ b/app/Views/client_home.php @@ -0,0 +1,95 @@ + + + + +
+ +
+ + +
+
+
+

Shared Docs

+
+
+
+ + + +
+
+
+
+ + + + + + + + + + + + + + + $value) { ?> + + + + + + + + + + + +
TemplateStatusAction
+ + Approved + + Pending Approval + + Rejected + + + Preview
+ +
+
+
+
+ + + +
+ +
+ + + + + + + + + + + \ No newline at end of file diff --git a/app/Views/client_list.php b/app/Views/client_list.php index 4d6558d..3497b1a 100644 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -35,6 +35,7 @@ PAN Mobile Email + Status Action @@ -49,8 +50,27 @@ - - Edit + + + Active + + Inactive + + + + + + @@ -87,4 +107,39 @@ "ordering": false }); }); + + function statusChange(params) { + console.log(params); + var status = params.getAttribute('data-isactive'); + var client_id = params.getAttribute('data-id'); + if(status == 1){ + var is_active= 0; + }else{ + var is_active= 1; + } + + var formData = { + client_id: client_id, + is_active: is_active + }; + $.ajax({ + type: 'POST', + url: '', + data: formData, + dataType: 'json', + success: function(response) { + if (response.data) { + window.location.reload(); + } + }, + error: function(xhr, status, error) { + // Handle error response here + console.error(xhr.responseText); + } + }); + + + } + + \ No newline at end of file diff --git a/app/Views/client_login.php b/app/Views/client_login.php index 2bc3243..de013f5 100644 --- a/app/Views/client_login.php +++ b/app/Views/client_login.php @@ -19,7 +19,19 @@ /assets/css/icons.min.css" rel="stylesheet" type="text/css" /> + +