diff --git a/app/Controllers/ApiIntegration.php b/app/Controllers/ApiIntegration.php index 83c390db..6a8c9c3f 100644 --- a/app/Controllers/ApiIntegration.php +++ b/app/Controllers/ApiIntegration.php @@ -730,6 +730,7 @@ class ApiIntegration extends ResourceController $extensive_correspondence = ""; $invoice_id = ""; if (count($records) > 0 && !empty($wordpress_order_id)) { + if($records['status'] == 'completed' || $records['status'] == 'processing'){ $where = ['wp_api_order_id' => $wordpress_order_id, 'isactive' => 1]; $invoice_details = $api_model->setTable('invoice')->where($where)->first(); if (isset($invoice_details['invoice_id']) && $invoice_details['invoice_id'] != "") { @@ -796,7 +797,29 @@ class ApiIntegration extends ResourceController $subtotal = (float)$lineitems_subtotal + (float)$records['shipping_total']; $tax = $lineitems_tax + (float)$records['shipping_tax']; $total = ($lineitems_total)+(float)$records['shipping_total'] + (float)$records['shipping_tax']; - + $final_status = ''; + + switch ($records['status']) { + case 'completed': + case 'processing': + $final_status = 'Approved'; + break; + case 'refunded': + $final_status = 'Refunded'; + break; + case 'failed': + case 'cancelled': + $final_status = 'Cancelled'; + break; + case 'checkout-draft': + case 'pending': + case 'on-hold': + $final_status = 'Inprogress'; + break; + default: + $final_status = 'Inprogress'; + } + $invoice_data['invoice_id']=$invoice_id; $invoice_data['invoice_number']=$records['number']; @@ -811,7 +834,7 @@ class ApiIntegration extends ResourceController $invoice_data['payment_status']=$records['status']; $invoice_data['order_number']=$records['order_key']; $invoice_data['payment_method']=$records['payment_method_title']; - $invoice_data['status']='Approved'; + $invoice_data['status']=$final_status; $invoice_data['event_id']=NULL; $invoice_data['business_id']=$this->global_variable_business_id; $invoice_data['shipping_address']=$shipping_addr; @@ -922,7 +945,7 @@ class ApiIntegration extends ResourceController // return $element['category_name'] === 'Membership' && $element['sku'] === $skuId; // }); $result_book_category = array_filter($get_book_category, function ($element) use ($skuId) { - return $element['category_name'] === 'Membership' && $element['sku'] === $skuId; + return strtolower($element['category_name']) === strtolower('Membership') && $element['sku'] === $skuId; }); $fromDate = NULL; $toDate = NULL; @@ -1088,6 +1111,10 @@ class ApiIntegration extends ResourceController // $this->logger->error("Api SaveSalesDetails : Err = Invoice items (Shipping) Data Not Found"); // } $response = ['status' => 200, 'message' => $basic_message ,'indetails' => $extensive_correspondence]; + }else{ + $this->logger->error("Api SaveSalesDetails : Err = Because Status from Request is ".$records['status']); + $response = ['status' => 204, 'message' => 'Data No Found Because Status from Request is '.$records['status']]; + } } else { $this->logger->error("Api SaveSalesDetails : Err = Data Not Found"); diff --git a/app/Controllers/BaseController.php b/app/Controllers/BaseController.php index c5780cfe..b91cb15e 100644 --- a/app/Controllers/BaseController.php +++ b/app/Controllers/BaseController.php @@ -65,14 +65,8 @@ abstract class BaseController extends Controller echo "This is a command-line request."; // echo $requestedRoute; } else { - - if ($uri->getSegment(1) != 'getExpCustomerDetail'&& $uri->getSegment(1) != 'download_invoice_pdf') { - $this->authData = $this->session_log(); - } - - $routesArr = ['login', 'authenticate', 'auth_confirm_mail', 'auth_reset_password', 'auth_reset_password_save']; - if (!in_array($requestedRoute, $routesArr)) { - $this->authData = $this->session_log(); + if ($requestedRoute !== '/login' && $requestedRoute !== '/authenticate' && $requestedRoute !== '/auth_confirm_mail' && $requestedRoute !== '/auth_reset_password' && $requestedRoute !== 'auth_reset_password_save' && $uri->getSegment(1) != 'getExpCustomerDetail'&& $uri->getSegment(1) != 'download_invoice_pdf') { + $this->authData = $this->session_log(); } } @@ -111,7 +105,7 @@ abstract class BaseController extends Controller $details = $auth_model->getheringDetailsForHeader($session_uid); // $data['company_name'] = $details[0]['site_name']; - $data['company_name'] = $details[0]['company_name']; + $data['company_name'] = $details[0]['company_name'] ? $details[0]['company_name'] : "ABD"; $data['company_short_name'] = $details[0]['site_short_name']; $data['company_address'] = $details[0]['company_address']; $data['company_mobile_no'] = $details[0]['company_mobile_no']; diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php index 38b6033e..87a77eec 100644 --- a/app/Controllers/Invoice.php +++ b/app/Controllers/Invoice.php @@ -923,33 +923,29 @@ $encodedUrl = urlencode($url); } } public function expired_customer_report() - { - - if($this->request->getmethod() == 'get') { $model = new InvoiceModel(); - $data['expired_customers'] = $model->getExpiredCustomers(); - $data['selected_data'] = ""; - $this->logger->info("'Membership Renewals Report'"); - $data['page_name'] = 'Membership Renewals Report'; - $this->render_page('report_expired_customers', $data); - } - else - { - $dateParts = explode(' - ', $this->request->getVar('date') ); - $fromDate = $dateParts[0]; - $toDate = $dateParts[1]; - - $dateTime = \DateTime::createFromFormat('d/m/Y', $fromDate); - $dateTime1 = \DateTime::createFromFormat('d/m/Y', $toDate); - $model = new InvoiceModel(); - $data['expired_customers'] = $model->getExpiredCustomers( $dateTime->format('Y-m-d') , $dateTime1->format('Y-m-d') ); - $data['selected_data'] = $this->request->getVar('date'); - $this->logger->info("Itemwise Report "); + if($this->request->getmethod() == 'get') + { + $data['expired_customers'] = $model->getExpiredCustomers(); + $data['selected_data'] = ""; + } + else + { + + $dateParts = explode(' - ', $this->request->getVar('date') ); + $fromDate = $dateParts[0]; + $toDate = $dateParts[1]; + $dateTime = \DateTime::createFromFormat('d/m/Y', $fromDate); + $dateTime1 = \DateTime::createFromFormat('d/m/Y', $toDate); + $model = new InvoiceModel(); + $data['expired_customers'] = $model->getExpiredCustomers( $dateTime->format('Y-m-d') , $dateTime1->format('Y-m-d') ); + $data['selected_data'] = $this->request->getVar('date'); + $this->logger->info("Itemwise Report "); + } $this->logger->info("'Membership Renewals Report'"); $data['page_name'] = 'Membership Renewals Report'; $this->render_page('report_expired_customers', $data); - } } public function itemwise_report() diff --git a/app/Controllers/Scheme.php b/app/Controllers/Scheme.php index 0aea6854..fbca1222 100644 --- a/app/Controllers/Scheme.php +++ b/app/Controllers/Scheme.php @@ -86,7 +86,7 @@ class Scheme extends BaseController $db = db_connect(); $category = $db->table('category') ->select('id') - ->where('name', $category_name) + ->where('Lower(name)', strtolower($category_name)) ->get() ->getRow(); // Check if the category exists diff --git a/app/Controllers/Subscription.php b/app/Controllers/Subscription.php index dde3724e..6bcbcf8e 100644 --- a/app/Controllers/Subscription.php +++ b/app/Controllers/Subscription.php @@ -29,7 +29,7 @@ class Subscription extends BaseController $model = new InvoiceModel(); $data['page_name'] = 'Subscription Invoice Details'; $data['invoice'] = $model->getSubscriptionInvoiceDetail($where); - + $this->logger->info("Invoice: Listing Count ." . count($data['invoice'])); diff --git a/app/Models/HomeModel.php b/app/Models/HomeModel.php index 2652e238..6c71c42e 100644 --- a/app/Models/HomeModel.php +++ b/app/Models/HomeModel.php @@ -154,7 +154,8 @@ class HomeModel extends Model ->groupBy('S.sub_id') ->get() ->getResultArray(); - + // print_r($membershipList); + // echo $this->db->getLastQuery(); die; foreach ($membershipList as &$membership) { $notifications = $this->getNotifications($membership['customer_id']); diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index dd6a8e4b..1b76c423 100644 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -104,10 +104,10 @@ public function getSubscriptionInvoiceDetail($where) $schemes = []; $invoiceItems = $this->getInvoiceItems($invoiceId, ''); foreach ($invoiceItems as $j => $child) { - if ($child->category_name == 'Membership') { + if (strtolower($child->category_name) == strtolower('Membership')) { $schemes[] = [ 'scheme_name' => $child->title, - 'scheme_code' => $child->short_code, // Update this line to use the correct property + 'scheme_code' => !empty($child->short_code)?$child->short_code:$child->title, ]; } } @@ -499,18 +499,20 @@ public function getExpiredCustomers($f_date = null, $t_date = null) if ($f_date !== null && $t_date !== null) { $query->where('S.to_subscription >=', $f_date) - ->where('S.to_subscription <=', $t_date); + ->where('S.to_subscription <=', $t_date); } $result = $query - ->select('S.customer_id,S.sub_id, S.from_subscription, S.to_subscription, C.first_name, C.last_name, C.email, C.mobile_no, S.scheme_id,books.short_code') + ->select('S.customer_id,S.sub_id, S.from_subscription, S.to_subscription, C.first_name, C.last_name, C.email, C.mobile_no, S.scheme_id,B.short_code') ->join('customers as C', 'C.customer_id = S.customer_id', 'left') - ->join('books', 'books.book_id = S.scheme_id', 'left') + ->join('books as B', 'B.book_id = S.scheme_id', 'left') ->where('S.isactive', 1) - ->where('S.to_subscription <=', $now) ->get() ->getResultArray(); - + // print_r($result); + // echo "
"; + // echo $this->db->getLastQuery(); + // echo "";die; return $result; } diff --git a/app/Models/SchemeModel.php b/app/Models/SchemeModel.php index 4a9fa130..96f71489 100644 --- a/app/Models/SchemeModel.php +++ b/app/Models/SchemeModel.php @@ -24,7 +24,7 @@ class SchemeModel extends Model $builder->join('book_categories', 'book_categories.book_id = books.book_id', 'left'); $builder->join('category', 'category.id = book_categories.category_id', 'left'); $builder->where('books.business_id', $business_id); - $builder->where('category.name', 'membership'); + $builder->where('LOWER(category.name)', 'membership'); $builder->where('books.isactive', 1); $query = $builder->get(); diff --git a/app/Models/SubscriptionModel.php b/app/Models/SubscriptionModel.php index 6408a3c2..992e12ce 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, books.isactive, CONCAT(customers.first_name, " ", customers.last_name) as customer_name'); + $builder->select('subscription.*, books.title,books.short_code, 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/book_list.php b/app/Views/book_list.php index 98249518..9b9515b6 100644 --- a/app/Views/book_list.php +++ b/app/Views/book_list.php @@ -38,7 +38,7 @@
Total Subscriber
-Total Subscriber
Total Subscribers
-New Subscribers
-Renewed
-Total Subscriber
-| Invoice Date | Total | Status | -Action | - - - - +Action | - -||||||
|---|---|---|---|---|---|---|---|---|---|---|
| = $row['invoice_id'] ?> | -= $row['customer_name']; ?> | -= $from_date; ?> | -= $to_date; ?> | -= $row['scheme_code']; ?> | -- | = $row['invoice_number']; ?> | -= $invoice_date; ?> | -= "₹ " . $row['total_amount']; ?> | -= $row['status']; ?> | - - - - -- " class="edit-button" title="Edit the Invoice"> - " class="download-pdf-button" title="Download the Invoice"> - " class="print-address-button" title="Print Address"> - | -
| = $row['invoice_date'] ?> | += $row['customer_name']; ?> | += $from_date; ?> | += $to_date; ?> | += $row['scheme_code']; ?> | ++ | = $row['invoice_number']; ?> | += $invoice_date; ?> | += "₹ " . $row['total_amount']; ?> | += $row['status']; ?> | ++ " class="edit-button" title="Edit the Invoice"> + " class="download-pdf-button" title="Download the Invoice"> + " class="print-address-button" title="Print Address"> + | +