From 591071ec5d4cf60db9a6c48f02b75ef8c4e35200 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Tue, 19 Dec 2023 19:32:34 +0530 Subject: [PATCH] Issues fixes : ps --- app/Controllers/ApiIntegration.php | 4 +- app/Controllers/Business.php | 93 ++++++++++++++++++---------- app/Controllers/Notifications.php | 5 +- app/Controllers/Users.php | 1 - app/Models/InvoiceModel.php | 19 +++--- app/Models/NotificationModel.php | 2 + app/Models/SubscriptionModel.php | 2 +- app/Views/business_form.php | 91 ++++++++++++++++++++++----- app/Views/business_list.php | 18 +++++- app/Views/customer_form.php | 1 - app/Views/invoice_form.php | 6 +- app/Views/report_general_invoice.php | 7 ++- app/Views/report_itemwise.php | 2 + app/Views/report_mem_invoice.php | 6 +- app/Views/setting_form.php | 4 +- app/Views/subscribers_list.php | 6 +- app/Views/user_form.php | 4 +- app/Views/user_list.php | 4 +- 18 files changed, 191 insertions(+), 84 deletions(-) diff --git a/app/Controllers/ApiIntegration.php b/app/Controllers/ApiIntegration.php index 5205c035..1fa5d1b3 100644 --- a/app/Controllers/ApiIntegration.php +++ b/app/Controllers/ApiIntegration.php @@ -22,7 +22,7 @@ class ApiIntegration extends ResourceController $this->global_variable_role = "Online"; $api_model = new ApiIntegrationModel(); $table = 'users'; - $where = ['role'=>$this->global_variable_role,'business_id'=>(int)$this->global_variable_business_id]; + $where = ['LOWER(role)'=>strtolower($this->global_variable_role),'business_id'=>(int)$this->global_variable_business_id]; $existing_data = $api_model->getData($table, $where); $this->global_variable_user_id = isset($existing_data[0]->user_id) ? (int)$existing_data[0]->user_id : NULL; $this->global_variable_user_name = isset($existing_data[0]->user_id) ? $existing_data[0]->first_name." ".$existing_data[0]->last_name : NULL; @@ -385,7 +385,7 @@ class ApiIntegration extends ResourceController $this->logger->info("Api SaveBookDetails : total master categories count = ".count($master_categories)); $where = ['book_id' => (int)$last_insert_book_id, 'isactive' => 1 ]; $existing_categories = $api_model->getData('book_categories', $where); - $this->logger->info("Api SaveBookDetails : existing categories count = ".count($existing_categories)); + $this->logger->info("Api SaveBookDetails : existing book categories count = ".count($existing_categories)." Book_id = ".$last_insert_book_id); $request_categories = (array)$categories; $filtering_existing_categories_wpApiId = []; $filtering_requested_categories_wpApiId = []; diff --git a/app/Controllers/Business.php b/app/Controllers/Business.php index e94afc9c..5501754c 100644 --- a/app/Controllers/Business.php +++ b/app/Controllers/Business.php @@ -14,14 +14,14 @@ class Business extends BaseController if (is_session_active()) { $session_role = get_user_role(); if (!empty($session_role) && $session_role !== "sadmin") { - $this->logger->info("Buiness: Listing In admin role ."); + $this->logger->info("Business: Listing In admin role ."); $where = ['business_id' => (int)get_business_id(), 'isactive' => 1]; } else { - $this->logger->info("Buiness: Listing In Super-admin role ."); + $this->logger->info("Business: Listing In Super-admin role ."); $where = ['isactive !=' => NULL]; } $BusinessModel = new BusinessModel(); - $data['page_name'] = 'Buiness Details'; + $data['page_name'] = 'Business Details'; $data['businesses'] = $BusinessModel->where($where)->findAll(); // $data['lastQuery'] = $BusinessModel->getLastQuery(); // print_r($data);die; @@ -56,42 +56,73 @@ class Business extends BaseController helper('session'); $session_uid = get_logged_user_id(); $session_role = get_user_role(); - $validationRule = [ - 'user' => [ - 'label' => 'Image File', - 'rules' => [ - 'uploaded[bfile]', - 'is_image[bfile]', - 'mime_in[bfile,image/jpg,image/jpeg,image/gif,image/png,image/webp]', - ], - ], + ## CI validation rule for bfile + $validationRule = [ + 'bfile' => [ + 'label' => 'Image File', + 'rules' => 'uploaded[bfile]|is_image[bfile]|mime_in[bfile,image/jpg,image/jpeg,image/gif,image/png,image/webp]' + ] ]; - if (!$this->validate($validationRule) && $this->request->getPost('bfile') === '') { - $data = ['errors' => $this->validator->getErrors()]; - print_r($data); - return 'hello'; - } + $img = $this->request->getFile('bfile'); $business_id = $this->request->getPost('business_id'); - $filePath = 'public/uploads/' . $this->request->getPost('bfile'); + + $img_details = $this->request->getFile('bfile'); // Here I Have Image details ; + $final_img_name = NULL;//Just flag + $existing_img_name = $this->request->getPost('existing_business_logo_name'); // HiddenField for if have any pic name means; + $img_path = 'public/uploads/'; ## File Already Existing or not - if ($img->isValid() && !$img->hasMoved()) { - $fileName = $img->getName(); - $img->move('public/uploads/', $fileName); - - - // Delete the previous image file if it exists - if ($business_id) { - $previousFileName = $this->request->getPost('previous_bfile'); - if ($previousFileName && is_file('public/uploads/' . $previousFileName)) { - link('public/uploads/' . $previousFileName); + ##Step 1 : image details available + if($img_details){ + $this->logger->info("Business: image details avaiable"); + ##Step 2 : i have image details .
+ if ($img_details->isValid()) { + ##Step 3 : image Name.$new_img_name."
"; + $new_img_name = $img_details->getName(); // before movement name + $this->logger->info("Business: Image Name B4 Upload".$new_img_name); + ##Step 4 : Validation Rule Apply here.if not throw the error"
"; + if (!$this->validate($validationRule)) { + if($new_img_name !== ''){ + + $error = $this->validator->getErrors(); + // echo "Error : ".(string)$error."
"; + $this->logger->error("Business: Err on image upload".$error['bfile']); + throw new \Exception((string)$error['bfile']); + } } + ##Step 5 : Check Existing and New Image Name Same Or not same no use to move on target folder + if($new_img_name !== $existing_img_name){ + $this->logger->info("Business: Image Name are Differ".$new_img_name." & ".$existing_img_name); + ## Step 6 : Different Image Name means removed on target folder using Unlink; + if ($existing_img_name && is_file($img_path.$existing_img_name)) { + $this->logger->info("Business: already Image Available on target Folder Path : ".$img_path.$existing_img_name." So, Deleted."); + // echo "Deleted_file : ".(string)$img_path.$existing_img_name."
"; + unlink($img_path.$existing_img_name); + } + ## Step 7 : Moved to target; + $img_details->move($img_path, $new_img_name); + $final_img_name = $img_details->getName(); // after movement name + $this->logger->info("Business: Image Name After Upload".$final_img_name); + }else{ + $final_img_name = $existing_img_name; + $this->logger->info("Business: Image Name are same".$new_img_name." & ".$existing_img_name." Can't Upload"); + } + } + else{ + ## Step 8 : Not a Vaild Image File so replace Existing file name; + $final_img_name = $existing_img_name; + $this->logger->info("Business: Not a Vaild Image File Nothing To Update/Upload"); + // throw new \Exception("Not a Vaild Image File"); } - } else { - $fileName = $this->request->getPost('previous_bfile', ''); // Use the previous filename if no new image is provided + } + else{ + ## Step 9 : Testing Purpose File Details Not Available. so i can't move it.; + $this->logger->info("Business: Testing Purpose Image Details Not Available. so i can't move it."); + $final_img_name = $existing_img_name; + //throw new \Exception("Testing Purpose File Details Not Available so i can't move it if you have existing filee means save it or your choice"); } @@ -105,7 +136,7 @@ class Business extends BaseController 'state' => $this->request->getPost('bstate'), 'postal_code' => $this->request->getPost('bzip'), 'terms'=>$this->request->getPost('bterms'), - 'business_logo' => $fileName + 'business_logo' => $final_img_name ]; $business_id = $this->request->getPost('business_id'); // Get the business ID for update diff --git a/app/Controllers/Notifications.php b/app/Controllers/Notifications.php index c6848e74..9e77730c 100755 --- a/app/Controllers/Notifications.php +++ b/app/Controllers/Notifications.php @@ -222,7 +222,10 @@ class Notifications extends BaseController { $model = new NotificationModel(); $model->setTable('templates'); - $details = $model->where(['isactive' => 1,'template_name not like "%EXPIRAY_NOTIFY_TEMPLATE%"'])->orderBy('template_id', 'ASC')->findAll(); + $details = $model + ->where(['templates.isactive' => 1]) + ->whereNotIn('templates.template_name',array('EXPIRAY_NOTIFY_TEMPLATE_EMAIL','EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP')) + ->orderBy('templates.template_id', 'ASC')->findAll(); return $details; } diff --git a/app/Controllers/Users.php b/app/Controllers/Users.php index 71d2b7d1..b452fb1d 100755 --- a/app/Controllers/Users.php +++ b/app/Controllers/Users.php @@ -107,7 +107,6 @@ class Users extends BaseController } $data['details'] = $edit_user_details; } - echo count($data['details']);die; $data['business_details'] = $business_details; $data['session_bid'] = $session_bid; $data['session_role'] = $session_role; diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index 3e8aba8d..2309c842 100644 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -47,24 +47,17 @@ public function updateData($table, $data, $where) public function getSubscriptionInvoiceDetail($where) { $result = $this->getJoinedData($where); - // print_r($result);die; if(!empty($result)){ foreach ($result as $i => $item) { $invoiceId = $item['invoice_id']; $scheme_name = []; - $from_subscription = []; - $to_subscription = []; $invoiceItems = $this->getInvoiceItems($invoiceId,''); foreach ($invoiceItems as $j => $child) { if ($child->category_name == 'Membership') { $scheme_name[] = $child->title; - $from_subscription[] = ($j == 0 && !empty($child->from_subscription) && $child->from_subscription !== null) ? date('d/m/Y', strtotime($child->from_subscription)) : ""; - $to_subscription[] = ($j == 0 && !empty($child->to_subscription) && $child->from_subscription !== null ) ? date('d/m/Y', strtotime($child->to_subscription)) : ""; } } $result[$i]['scheme_name'] = !empty($scheme_name) ? implode(", ", $scheme_name) : ''; - $result[$i]['from_subscription'] = !empty($from_subscription) ? implode(" ", $from_subscription) : ''; - $result[$i]['to_subscription'] = !empty($to_subscription) ? implode(" ", $to_subscription) : ''; $result[$i]['invoice_items_details'] = $invoiceItems; } } @@ -75,15 +68,16 @@ public function updateData($table, $data, $where) { return $this->db->table($this->table.' as I' ) - ->join('customers as C', 'C.customer_id = I.customer_id', 'left') + ->join('subscription as S', 'S.invoice_id = I.invoice_id', 'left') ->join('events as E', 'E.event_id = I.event_id', 'left') ->join('business as B', 'B.business_id = I.business_id', 'left') ->join('users as U1', 'U1.user_id = I.created_by', 'left') ->join('users as U2', 'U2.user_id = I.updated_by', 'left') - ->select('I.invoice_id, I.invoice_number, I.customer_id,concat(C.first_name," ",C.last_name) as customer_name , I.invoice_date, I.due_date, I.subtotal, I.tax, I.discount, I.total_amount,I.status, I.payment_status, I.order_number, I.payment_method,I.invoice_type, I.event_id,E.event_name, I.business_id,B.title as business_name, I.created_on, I.created_by,concat(U1.first_name," ",U1.last_name) as created_by_name, I.updated_on, I.updated_by,concat(U2.first_name," ",U2.last_name) as updated_by_name, I.isactive,C.email as customer_email,C.mobile_no as customer_mobile,I.shipping_address_id,I.shipping_address,I.billing_address_id,I.billing_address,B.address as business_address,B.city as business_city,B.state as business_state,B.postal_code as business_postal_code,B.email as business_email,B.mobile_no as business_mobile_no') + ->select('I.invoice_id, I.invoice_number, I.customer_id,concat(C.first_name," ",C.last_name) as customer_name , I.invoice_date, I.due_date, I.subtotal, I.tax, I.discount, I.total_amount,I.status, I.payment_status, I.order_number, I.payment_method,I.invoice_type, I.event_id,E.event_name, I.business_id,B.title as business_name, I.created_on, I.created_by,concat(U1.first_name," ",U1.last_name) as created_by_name, I.updated_on, I.updated_by,concat(U2.first_name," ",U2.last_name) as updated_by_name, I.isactive,C.email as customer_email,C.mobile_no as customer_mobile,I.shipping_address_id,I.shipping_address,I.billing_address_id,I.billing_address,B.address as business_address,B.city as business_city,B.state as business_state,B.postal_code as business_postal_code,B.email as business_email,B.mobile_no as business_mobile_no,S.from_subscription,S.to_subscription') ->where($where) - ->orderBy('invoice_id', 'DESC') + ->orderBy('I.invoice_id', 'DESC') + ->groupBy('I.invoice_id') ->get() ->getResultArray(); // print_r($this->db->getLastQuery());die; @@ -229,7 +223,7 @@ public function get_general_invoice_data($f_date = null, $t_date = null) { // Fetch invoice data $query = $this->db->table('invoice') - ->select('invoice.*, customers.*, COUNT(invoiceitems.product) as item_count') + ->select('invoice.*,DATE_FORMAT(invoice.invoice_date, "%d/%m/%Y") AS formatted_invoice_date, customers.*, COUNT(invoiceitems.product) as item_count') ->where('invoice.isactive', 1) ->where('invoice.invoice_type', 1) ->where('invoiceitems.isactive', 1); @@ -255,7 +249,8 @@ public function get_mem_invoice_data($f_date = null, $t_date = null) { // Fetch invoice data $query = $this->db->table('invoice') - ->select('invoice.*, customers.*, COUNT(invoiceitems.product) as item_count') + ->select('invoice.*, customers.*, COUNT(invoiceitems.product) as item_count,DATE_FORMAT(invoice.invoice_date, "%d/%m/%Y") AS formatted_invoice_date,subscription.from_subscription,subscription.to_subscription,DATE_FORMAT(subscription.from_subscription, "%d/%m/%Y") AS formatted_from_date,DATE_FORMAT(subscription.to_subscription, "%d/%m/%Y") AS formatted_to_date') + ->join('subscription', 'subscription.invoice_id = invoice.invoice_id', 'left') ->where('invoice.isactive', 1) ->where('invoice.invoice_type', 2) ->where('invoiceitems.isactive', 1); diff --git a/app/Models/NotificationModel.php b/app/Models/NotificationModel.php index 61f9b096..cb66ae9f 100644 --- a/app/Models/NotificationModel.php +++ b/app/Models/NotificationModel.php @@ -42,6 +42,7 @@ class NotificationModel extends Model ->join('users as U1', 'U1.user_id = T.created_by', 'left') ->join('users as U2', 'U2.user_id = T.updated_by', 'left') ->select('T.template_id,T.template_name,T.mode,T.created_on,T.created_by,T.updated_on,T.updated_by,DATE_FORMAT(T.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,T.isactive') + ->whereNotIn('T.template_name',array('EXPIRAY_NOTIFY_TEMPLATE_EMAIL','EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP')) ->get()->getResultArray(); } @@ -83,6 +84,7 @@ public function getCampaignDetails(){ ->join('users as U2', 'U2.user_id = NC.updated_by', 'left') ->join('templates as T', 'T.template_id = NC.template_id', 'left') ->select('NC.campaign_id,NC.campaign_name,T.template_id,T.template_name,NC.mode,NC.created_on,NC.created_by,NC.updated_on,NC.updated_by,DATE_FORMAT(NC.created_on, "%d/%m/%Y %h:%i %p") AS formatted_created_on,concat(U1.first_name," ",U1.last_name) as created_by_name,concat(U2.first_name," ",U2.last_name) as updated_by_name,NC.isactive,NC.group_id,NC.scheduled_date,if(NC.scheduled_time IS NULL ,"",NC.scheduled_time) as scheduled_time') + ->whereNotIn('T.template_name',array('EXPIRAY_NOTIFY_TEMPLATE_EMAIL','EXPIRAY_NOTIFY_TEMPLATE_WHATSAPP')) ->get()->getResultArray(); if (!empty($result)) { diff --git a/app/Models/SubscriptionModel.php b/app/Models/SubscriptionModel.php index 581c62ce..451d8b3c 100644 --- a/app/Models/SubscriptionModel.php +++ b/app/Models/SubscriptionModel.php @@ -15,7 +15,7 @@ public function getAllSubscribersWithNames($where) { $builder = $this->db->table('subscription'); - $builder->select('subscription.*, books.title, CONCAT(customers.first_name, " ", customers.last_name) as customer_name'); + $builder->select('subscription.*, books.title, books.isactive, CONCAT(customers.first_name, " ", customers.last_name) as customer_name'); $builder->join('books', 'books.book_id = subscription.scheme_id'); $builder->join('customers', 'customers.customer_id = subscription.customer_id'); $builder->where($where); diff --git a/app/Views/business_form.php b/app/Views/business_form.php index d041e018..bac6d82c 100644 --- a/app/Views/business_form.php +++ b/app/Views/business_form.php @@ -42,14 +42,15 @@
- +
Please provide.
+
- +
Please provide.
@@ -87,21 +88,22 @@
-
- - Business Logo +
+
+ Business Logo +
+
Existing Logo
+

+ +
+
+
+ +
+ + +
- -
-
- - - -
- - - -
@@ -140,4 +142,61 @@ $('#submitBtn').prop('disabled', true); } }); + + \ No newline at end of file diff --git a/app/Views/business_list.php b/app/Views/business_list.php index d8665792..af07df0f 100644 --- a/app/Views/business_list.php +++ b/app/Views/business_list.php @@ -4,7 +4,7 @@

@@ -22,13 +22,22 @@ State Zip File + Status Action - + @@ -38,9 +47,12 @@ + + + " class="edit-button" title="Click to Edit Business"> - + " class="delete-button" title="Click to Delete Business"> diff --git a/app/Views/customer_form.php b/app/Views/customer_form.php index 4e1726ba..67a0de75 100644 --- a/app/Views/customer_form.php +++ b/app/Views/customer_form.php @@ -518,7 +518,6 @@ event.preventDefault(); // Prevent form submission if it's not valid $('#submitBtn').prop('disabled', false); } else { -alert("i am true"); $('#submitBtn').prop('disabled', true); } }); diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index e09df2de..14f2521f 100644 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -118,9 +118,9 @@ " name="quantity[]" oninput="calculateInvoice(this,)" value="" min="1" /> diff --git a/app/Views/report_general_invoice.php b/app/Views/report_general_invoice.php index e5130d67..6ca659c0 100644 --- a/app/Views/report_general_invoice.php +++ b/app/Views/report_general_invoice.php @@ -31,7 +31,7 @@
- +
@@ -55,7 +55,7 @@ - + @@ -68,7 +68,7 @@
invoice_number;?>invoice_date;?>formatted_invoice_date;?> first_name." ".$row->last_name;?> tax . '%'; ?> discount, 2, '.', ','); ?>
- +
@@ -158,6 +158,7 @@ $(document).ready(function() { .daterangepicker({ autoUpdateInput: false, locale: { + format: 'DD/MM/YYYY', cancelLabel: 'Clear' } }) diff --git a/app/Views/report_itemwise.php b/app/Views/report_itemwise.php index 3ca33290..97261ba0 100644 --- a/app/Views/report_itemwise.php +++ b/app/Views/report_itemwise.php @@ -34,6 +34,7 @@
+
@@ -53,6 +54,7 @@
+
diff --git a/app/Views/report_mem_invoice.php b/app/Views/report_mem_invoice.php index f5af2b8a..e747c9bb 100644 --- a/app/Views/report_mem_invoice.php +++ b/app/Views/report_mem_invoice.php @@ -26,7 +26,7 @@
- +
@@ -51,7 +51,7 @@ - + @@ -65,7 +65,7 @@
invoice_number;?>invoice_date;?>formatted_invoice_date;?> first_name." ".$row->last_name;?> tax . '%'; ?>
- +
diff --git a/app/Views/setting_form.php b/app/Views/setting_form.php index 9d9ba00d..090ecfea 100644 --- a/app/Views/setting_form.php +++ b/app/Views/setting_form.php @@ -212,10 +212,10 @@
- - + diff --git a/app/Views/user_list.php b/app/Views/user_list.php index 7226be3c..d8071d39 100644 --- a/app/Views/user_list.php +++ b/app/Views/user_list.php @@ -73,7 +73,9 @@ - " class="delete-button" title="Click to Delete User" > + + " class="delete-button" title="Click to Delete User" > +