diff --git a/app/Config/App.php b/app/Config/App.php index a5228248..74b28bfe 100644 --- a/app/Config/App.php +++ b/app/Config/App.php @@ -19,8 +19,7 @@ class App extends BaseConfig * http://example.com/ */ // public string $baseURL = 'http://localhost:8080/'; - public string $baseURL = ''; - // public string $baseURL = 'http://localhost/vb_book/public/'; + public string $baseURL = 'http://localhost/vb_book/'; /** * Allowed Hostnames in the Site URL other than the hostname in the baseURL. diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php index 8af5a9fd..38b6033e 100644 --- a/app/Controllers/Invoice.php +++ b/app/Controllers/Invoice.php @@ -30,7 +30,7 @@ class Invoice extends BaseController $model = new InvoiceModel(); $data['page_name'] = 'Online Invoice Details'; - $data['invoice'] = $model->getJoinedData($where); + $data['invoice'] = $model->getJoinedData($where, ['I.invoice_date', 'DESC']); $this->logger->info("Invoice: Listing Count ." . count($data['invoice'])); $this->render_page('invoice_list', $data); } else { @@ -54,7 +54,7 @@ class Invoice extends BaseController $model = new InvoiceModel(); $data['page_name'] = 'Offline Invoice Details'; - $data['invoice'] = $model->getJoinedData($where); + $data['invoice'] = $model->getJoinedData($where, ['I.invoice_date', 'DESC']); $this->logger->info("Invoice: Listing Count ." . count($data['invoice'])); $this->render_page('offline_invoice_list', $data); } else { diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index 29e8b9e1..0f51a846 100644 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -120,8 +120,7 @@ public function getSubscriptionInvoiceDetail($where) return $result; } - -public function getJoinedData($where) +public function getJoinedData($where, $orderby = []) { $query = $this->db->table($this->table.' as I' ) ->join('customers as C', 'C.customer_id = I.customer_id', 'left') @@ -130,14 +129,16 @@ public function getJoinedData($where) ->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,DATE_FORMAT(I.created_on, "%d/%m/%Y") as created_on_format,I.created_on, I.created_by,concat(U1.first_name," ",U1.last_name) as created_by_name,DATE_FORMAT(I.updated_on, "%d/%m/%Y") as updated_on_format, 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,DATEDIFF(S.to_subscription, S.from_subscription) as subscription_in_days,S.scheme_id') - ->where($where) - // ->like('C.first_name',"%John%") - ->orderBy('I.invoice_id', 'DESC') - ->groupBy('I.invoice_id') - ->get(); - - $resultArray = $query->getResultArray(); + ->select('I.invoice_id,I.wp_api_order_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,DATE_FORMAT(I.created_on, "%d/%m/%Y") as created_on_format,I.created_on, I.created_by,concat(U1.first_name," ",U1.last_name) as created_by_name,DATE_FORMAT(I.updated_on, "%d/%m/%Y") as updated_on_format, 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,DATEDIFF(S.to_subscription, S.from_subscription) as subscription_in_days,S.scheme_id') + ->where($where); + if (!empty($orderby)) { + $query->orderBy($orderby[0], $orderby[1]); + } else { + $query->orderBy('invoice_id', 'DESC'); + } + $query->groupBy('I.invoice_id'); + $resultArray = $query->get()->getResultArray(); + // Print the last executed query // echo $this->db->getLastQuery();die; diff --git a/app/Views/invoice_list.php b/app/Views/invoice_list.php index aded8aeb..c9c07f58 100644 --- a/app/Views/invoice_list.php +++ b/app/Views/invoice_list.php @@ -1,5 +1,4 @@