From 0b1ca98138b31b64bcef878871659f7462e7d558 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Mon, 15 Jul 2024 11:59:42 +0530 Subject: [PATCH] CHANGE_DOC_LIST : AADHAVAN --- app/Config/Routes.php | 1 + app/Controllers/ClientController.php | 11 +++ app/Controllers/MasterController.php | 125 ++++++++------------------- app/Helpers/MailHelper.php | 10 --- app/Helpers/NotificationHelper.php | 2 + app/Views/client_list.php | 51 ++++++++++- app/Views/share_docs.php | 120 ++++++++++++------------- 7 files changed, 157 insertions(+), 163 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 890689b..a422ed1 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -46,6 +46,7 @@ use CodeIgniter\Router\RouteCollection; $routes->get('get_client_branch/(:any)','ClientController::get_client_branch/$1'); $routes->post('status_client_branch','ClientController::status_client_branch'); $routes->post('client_upload','ClientController::client_upload'); + $routes->get('check_gst','ClientController::check_gst'); diff --git a/app/Controllers/ClientController.php b/app/Controllers/ClientController.php index 393bcef..c45ef82 100644 --- a/app/Controllers/ClientController.php +++ b/app/Controllers/ClientController.php @@ -473,6 +473,17 @@ class ClientController extends BaseController echo "No file uploaded."; } } + + public function check_gst(){ + + $gst_no = $this->request->getVar('gst_no'); + $branch =$this->ClientBranchModel->where('gst_no',$gst_no)->first(); + if($branch){ + return json_encode(true); + }else{ + return ; + } + } } diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 50aa7ba..6b21c89 100644 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -170,6 +170,7 @@ class MasterController extends BaseController echo view('layout/footer'); } + public function service_create() { if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); } @@ -319,49 +320,21 @@ class MasterController extends BaseController ->join('service_group', 'service_group.service_group_id = template.service_group_id', 'left') ->join('client_branch', 'client_branch.id = client_docs.client_branch_id', 'left') ->join('client', 'client.client_id = client_branch.client_id ' , 'left') - // ->where('client.business_id', $business_id) + ->where('client_docs.business_id', $business_id) ->where('client_docs.created_at >=', $financialYearStart) ->where('client_docs.created_at <=', $financialYearEnd) // ->where("JSON_CONTAINS(service_group.business_id, '" . $business_id . "')") ->orderBy('client_docs.id', 'DESC') ->get() ->getResultArray(); - $business_id_check = 0; - foreach ($data['doc_list'] as $index => $value) { - foreach (json_decode($value['business_id']) as $key => $values) { - if($values == $business_id){ - $business_id_check = $business_id; - } - } - if($business_id_check != 0){ - $data['doc_list'][$index] =$value; - }else{ - unset($data['doc_list'][$index]); // Remove the element completely - } - $business_id_check = 0; - } + $docStatusByClientId = []; - // $data['clientdata'] = $this->ClientModel->select('client.*, client_branch.name as client_branch_name, client_branch.id as client_branch_id') - // ->join('client_branch', 'client.client_id = client_branch.client_id', 'left') - // ->findAll(); + $data['clientdata'] = $this->ClientBranchModel->select('client.*, client_branch.name as client_branch_name, client_branch.id as client_branch_id') ->join('client', 'client_branch.client_id = client.client_id', 'left') - // ->where('client.business_id',$this->session->get('logged_in_staff_business_id')) ->findAll(); $data['serviceGroupData'] = $this->ServiceGroupModel->findAll(); - // foreach ($data['serviceGroupData'] as $key => $value) { - // $check_its_okay = 0; - // foreach (json_decode($value['business_id']) as $values) { - // if($values == $business_id){ - // $check_its_okay =1; - // } - // } - // if($check_its_okay == 0){ - // unset($data['serviceGroupData'][$key]); - // } - // $check_its_okay = 0; - // } }else{ $business_id = $this->session->get('logged_in_staff_business_id'); @@ -375,47 +348,20 @@ class MasterController extends BaseController ->join('service_group', 'service_group.service_group_id = template.service_group_id', 'left') ->join('client_branch', 'client_branch.id = client_docs.client_branch_id', 'left') ->join('client', 'client.client_id = client_branch.client_id ' , 'left') - // ->where('client.business_id', $business_id) + ->where('client_docs.business_id', $business_id) ->where('client_docs.created_at >=', $financialYearStart) ->where('client_docs.created_at <=', $financialYearEnd) // ->where("JSON_CONTAINS(service_group.business_id, '" . $business_id . "')") ->orderBy('client_docs.id', 'DESC') ->get() - ->getResultArray(); - $business_id_check = 0; - foreach ($data['doc_list'] as $index => $value) { - foreach (json_decode($value['business_id']) as $key => $values) { - if($values == $business_id){ - $business_id_check = $business_id; - } - } - if($business_id_check != 0){ - $data['doc_list'][$index] =$value; - }else{ - unset($data['doc_list'][$index]); // Remove the element completely - } - $business_id_check = 0; - } + ->getResultArray(); $docStatusByClientId = []; // Fetch all doc_status entries and group them by client_docs_id $data['clientdata'] = $this->ClientBranchModel->select('client.*, client_branch.name as client_branch_name, client_branch.id as client_branch_id') ->join('client', 'client_branch.client_id = client.client_id', 'left') - // ->where('client.business_id',$this->session->get('logged_in_staff_business_id')) ->findAll(); - $data['serviceGroupData'] = $this->ServiceGroupModel->findAll(); - // foreach ($data['serviceGroupData'] as $key => $value) { - // $check_its_okay = 0; - // foreach (json_decode($value['business_id']) as $values) { - // if($values == $business_id){ - // $check_its_okay =1; - // } - // } - // if($check_its_okay == 0){ - // unset($data['serviceGroupData'][$key]); - // } - // $check_its_okay = 0; - // } + } foreach ($data['doc_list'] as $doc) { @@ -442,24 +388,11 @@ class MasterController extends BaseController }else{ $data['business_list'] = $this->BusinessModel->findAll(); } - // echo "
";
-                // print_r($data);die;
             echo view('layout/header', ['Data'=>$staffdata]);
             echo view('share_docs',$data);
             echo view('layout/footer');
     }
 
-    public function set_include_archived_session($checked_or_not) {
-        if($checked_or_not == true){
-                // $includeArchived = $this->request->getGet('include_archived');
-                $this->session->set('include_archived', $checked_or_not);
-        }else{
-            $this->session->set('include_archived', $checked_or_not);
-        }
-        // print_r($this->session->get('include_archived'));die;
-        return $this->response->setJSON(['status' => 'success']);
-    }
-
     public function shared_doc_non_financial_year_to(){
         if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
         $currentDate = new \DateTime();
@@ -477,6 +410,8 @@ class MasterController extends BaseController
         $financialYearStart = $financialYearStart->format('Y-m-d');
         $financialYearEnd = $financialYearEnd->format('Y-m-d');
         $staffdata = $this->StaffModel->where('staff_id',$this->session->get('is_staff_logged_in'))->get()->getRow();
+        $business_id = $this->session->get('logged_in_staff_business_id');
+
         if($this->session->get('logged_in_staff_role') == 'Admin'){           
             $data['doc_list'] =  $this->ClientDocsModel->select('client_docs.* , services.service_name , 
                                                                 service_group.group_name , client_branch.name as client_branch_name , 
@@ -486,9 +421,10 @@ class MasterController extends BaseController
                                                         ->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.business_id', $business_id)
                                                         ->orderBy('client_docs.id','DESC')
                                                         ->findAll();
-            $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.*, 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();
@@ -524,17 +460,24 @@ class MasterController extends BaseController
             $doc['doc_status'] = isset($docStatusByClientId[$doc['id']]) ? $docStatusByClientId[$doc['id']] : [];
         }
         $data['business_list'] = $this->BusinessModel->findAll();
-            // foreach (json_decode($staffdata->business_id) as $key => $value) {
-                // $business = $this->BusinessModel->where('business_id', $value)->first();
-                // if ($business) {
-                    // $data['business_list'][] = $business;
-                // }
-            // }     
+                
         echo view('layout/header', ['Data'=>$staffdata]);
         echo view('share_docs',$data);
         echo view('layout/footer');
     }
 
+    public function set_include_archived_session($checked_or_not) {
+        if($checked_or_not == true){
+                // $includeArchived = $this->request->getGet('include_archived');
+                $this->session->set('include_archived', $checked_or_not);
+        }else{
+            $this->session->set('include_archived', $checked_or_not);
+        }
+        // print_r($this->session->get('include_archived'));die;
+        return $this->response->setJSON(['status' => 'success']);
+    }
+
+
     public function shared_document_edit()
 	{   
 		if(!$this->session->has('is_staff_logged_in')){ return redirect()->to(base_url().'staff'); }
@@ -573,10 +516,10 @@ class MasterController extends BaseController
     public function create_docs()
     {
         $docData = $this->request->getVar();
-        $docData['created_by'] = $this->session->has('is_staff_logged_in');  
-        $docData['business_id'] = $this->session->has('logged_in_staff_business_id');  
+        $docData['created_by'] = $this->session->get('is_staff_logged_in');  
+        $docData['business_id'] = $this->session->get('logged_in_staff_business_id');  
         $docData['body_html'] = $this->TemplateModel->where('template_id',$this->request->getVar('template_id'))->get()->getRow()->body_html;
-        print_r($docData);die;
+        // print_r($docData);die;
         
         $insert = $this->ClientDocsModel->insert($docData);
         if($insert){
@@ -729,7 +672,8 @@ class MasterController extends BaseController
 
     public function change_doc_status()
     {
-        try {
+
+        // try {
             $doc_id = $this->request->getPost('doc_id');
             $is_active = $this->request->getPost('is_active'); 
             $data['is_active']  = $is_active;
@@ -776,10 +720,10 @@ class MasterController extends BaseController
                 ];
                 $MailHelper->send_url_email($clientData->email , '', $subject, $message, $mail_config);
                 $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){
                         $whatsApp_message = "Dear " . substr($clientData->client_name, 0, 20) . "," . $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;
@@ -802,9 +746,9 @@ class MasterController extends BaseController
                 $result = "No Match's";
                 return $this->response->setJSON(['status' => 'failed','code' => 404,'data' => $result],404);
             }
-        } catch (\Exception $exception) {
-            return $this->response->setJSON(['status' => 'failed','code' => 500,'data' => $exception],500);
-       }
+    //     } catch (\Exception $exception) {
+    //         return $this->response->setJSON(['status' => 'failed','code' => 500,'data' => $exception],500);
+    //    }
     }
 
     public function rememeber_notification()
@@ -826,6 +770,7 @@ class MasterController extends BaseController
                 ->join('client', 'client_branch.client_id = client.client_id', 'left')
                 ->where('client_docs.id', $doc_id)->get()->getRow();
             }
+            // print_r($clientData);die;
             // helper('url');
             $url ='Preview and Approve Document';
             // $businessData = $this->BranchModel->select('branches.* , business.business_name ')
diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php
index 3a32f20..7f28a0a 100644
--- a/app/Helpers/MailHelper.php
+++ b/app/Helpers/MailHelper.php
@@ -7,8 +7,6 @@ class MailHelper
     public static function send_otp_email($email_id, $otp)
     {
 
-        
-
         $subject = 'BB-Sign Verify Document';
         $message = "Hai,
                     
@@ -82,18 +80,10 @@ class MailHelper ]); $email->setFrom($config['sender_email'], $config['sender_name']); - // $email->setMailType('html'); - // $email->setFrom('bbone@venbait.in', 'BB-Sign'); $email->setTo($email_id); $email->setSubject($subject); $email->setMessage($message); - // $email->setMailType('html'); - // $email->setFrom('bbone@venbait.in', 'BB-Sign'); - // $email->setTo($email_id); - // $email->setSubject($subject); - // $email->setMessage($message); - // print_r($email);die; if ($email->send()) { return ['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...', 'data' => $email_id]; } else { diff --git a/app/Helpers/NotificationHelper.php b/app/Helpers/NotificationHelper.php index db23219..a44c223 100644 --- a/app/Helpers/NotificationHelper.php +++ b/app/Helpers/NotificationHelper.php @@ -55,6 +55,8 @@ class NotificationHelper 'Content-Type: application/json', 'Content-Length: ' . strlen($postdata) ]); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // Execute cURL session $response = curl_exec($ch); diff --git a/app/Views/client_list.php b/app/Views/client_list.php index 6d67705..aa324c3 100644 --- a/app/Views/client_list.php +++ b/app/Views/client_list.php @@ -254,7 +254,7 @@
- +
@@ -269,7 +269,6 @@ -