diff --git a/app/Config/Routes.php b/app/Config/Routes.php
index 0c10a667..27b99fcc 100755
--- a/app/Config/Routes.php
+++ b/app/Config/Routes.php
@@ -123,7 +123,6 @@ $routes->get("new_subscription_invoice/(:any)", "Invoice::new_subscription_invoi
$routes->get("download_invoice_pdf/(:any)", 'Invoice::download_invoice_pdf/$1');
$routes->post('update_approval_subscription', 'Invoice::update_approval_subscription');
-
$routes->post("saveBook", "Invoice::saveBook");
$routes->post("updateInvoiceStatus", "Invoice::updateInvoiceStatus");
$routes->post("updateInvoiceCancelStatus", "Invoice::updateInvoiceCancelStatus");
diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php
index 363075f4..84898195 100755
--- a/app/Controllers/Home.php
+++ b/app/Controllers/Home.php
@@ -36,6 +36,9 @@ class Home extends BaseController
$data['financial_year'] = date('m') <= 3 ? (date('Y')-1) . '-' . date('Y') : date('Y') . '-' . (date('Y') + 1);
$data['book_published'] = $model->book_published_dtls();
$data['business_id'] = $session_bid;
+ // $lastquery = $model->getLastQuery();
+ // log_message('info','the last executed query - '.$lastquery);
+ // dd($data);
$this->render_page('dashboard', $data);
}
diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php
index 12f99567..88a78fe1 100755
--- a/app/Controllers/Invoice.php
+++ b/app/Controllers/Invoice.php
@@ -1219,10 +1219,10 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
if (empty($data['selected_data'])){
//dd($data['selected_data']);
- $data['page_name'] = 'Membership Renewals Report (30 days)';
+ $data['page_name'] = 'Membership Renewal Report (30 days)';
}else{
list($fromDate, $toDate) = explode(" - ", $data['selected_data']);
- $data['page_name'] = 'Membership Renewals Report -
(From '.$fromDate.' To '.$toDate.')';
+ $data['page_name'] = 'Membership Renewal Report -
(From '.$fromDate.' To '.$toDate.')';
}
$this->render_page('report_expired_customers', $data);
}
@@ -1653,4 +1653,6 @@ public function create_or_update_subscription($invoice_id,$invoice_status, $msg_
// log_message('error',json_encode($response));die();
return $this->response->setJSON($response);
}
+
+
}
diff --git a/app/Controllers/Payment.php b/app/Controllers/Payment.php
index 3807e553..96429a15 100644
--- a/app/Controllers/Payment.php
+++ b/app/Controllers/Payment.php
@@ -175,7 +175,8 @@ public function payment_success() {
$bookModel = new BooksModel();
$model = new InvoiceModel();
$db = \Config\Database::connect();
- $address = $db->table('customer_addresses')->select('address_1','customer_address_id')->where('customer_id',$customer_id)->get()->getRowArray();
+ $baddress = $db->table('customer_addresses')->select('address_1,customer_address_id')->where('customer_id',$customer_id)->where('address_type',1)->get()->getRowArray();
+ $saddress = $db->table('customer_addresses')->select('address_1,customer_address_id')->where('customer_id',$customer_id)->where('address_type',2)->get()->getRowArray();
$next_id_row = $db->table('invoice_number_formatting')->select('next_id, left_pad')->get()->getRowArray();
$filtered_data = [
@@ -204,8 +205,10 @@ public function payment_success() {
'grand_total' => $amount,
'total_amount' => $amount,
'invoice_date' => $currentDate,
- 'billing_address'=> $address['address_1'],
- 'billing_address_id' => isset($address['customer_address_id']) ? $address['customer_address_id'] : '',
+ 'shipping_address'=> $saddress['address_1'],
+ 'shipping_address_id' => isset($saddress['customer_address_id']) ? $saddress['customer_address_id'] : '',
+ 'billing_address'=> $baddress['address_1'],
+ 'billing_address_id' => isset($baddress['customer_address_id']) ? $baddress['customer_address_id'] : '',
'payment_method' => $payment_method,
'business_id' =>2
];
diff --git a/app/Controllers/Subscription.php b/app/Controllers/Subscription.php
index a23443f5..1a93ee2d 100755
--- a/app/Controllers/Subscription.php
+++ b/app/Controllers/Subscription.php
@@ -21,10 +21,10 @@ class Subscription extends BaseController
if (!empty($session_role) && $session_role !== "sadmin") {
$this->logger->info("Invoice: Listing In Admin BID = " . $session_bid);
- $where = ['I.business_id' => (int)$session_bid, 'I.isactive' => 1,'I.invoice_type'=>2,'S.invoice_id !='=>"",'S.sub_id !='=>""];
+ $where = ['I.business_id' => (int)$session_bid, 'I.isactive' => 1,'S.invoice_id !='=>"",'S.sub_id !='=>""];
} else {
$this->logger->info("Invoice: Listing In the Super-Admin ");
- $where = ['I.business_id != ' => NULL, 'I.isactive != ' => NULL,'I.invoice_type'=>2,'S.invoice_id !='=>"",'S.sub_id !='=>""];
+ $where = ['I.business_id != ' => NULL, 'I.isactive != ' => NULL,'S.invoice_id !='=>"",'S.sub_id !='=>""];
}
$model = new InvoiceModel();
@@ -271,6 +271,7 @@ public function download_details()
$subscriptionModel = new SubscriptionModel();
$customerDetails = $subscriptionModel->getSubscriptionDetailsBySchemeName($mergedBookids, $downloadType);
+ // dd($customerDetails);
if (!empty($customerDetails)) {
$html = view('print_addresses_form', ['customerDetails' => $customerDetails, 'action' => $action, 'pdf' => $pdf]);
diff --git a/app/Models/HomeModel.php b/app/Models/HomeModel.php
index 943d53c7..e9e46c6e 100755
--- a/app/Models/HomeModel.php
+++ b/app/Models/HomeModel.php
@@ -60,7 +60,7 @@ class HomeModel extends Model
// Today
$date_where = ['DATE(created_on)' => date('Y-m-d'), 'invoice_type' => 1, 'isactive' => 1];
$date_query = $this->db->table('invoice')->where($date_where)->countAllResults();
- $date_amount_query = $this->db->table('invoice')->selectSum('total_amount')->where($date_where)->get()->getRowArray();
+ $date_amount_query = $this->db->table('invoice')->selectSum('total_amount')->where($date_where)->where('status','Approved')->get()->getRowArray();
$invoice['today'] = [
'count' => $date_query,
'total_amount' => $date_amount_query['total_amount'] ?? 0,
@@ -101,21 +101,24 @@ class HomeModel extends Model
public function active_schemes()
{
- $query = $this->db->table('subscription AS S')
- ->select('S.business_id, BK.title as name, BK.short_code, BK.book_id as id, S.scheme_id, LEFT(BK.title, 1) AS first_letter, COUNT(S.customer_id) AS count, BI.wp_img_url')
- ->select('COUNT(S.customer_id) AS overall, COUNT(IF(S.isactive = 1, S.customer_id, NULL)) AS activeoverall, COUNT(IF(S.is_renew = 0 AND S.isactive = 1, S.customer_id, NULL)) AS nonrenewal, COUNT(IF(S.is_renew = 1 AND S.isactive = 1, S.customer_id, NULL)) AS renewal, SUM(CASE WHEN S.created_on >= NOW() - INTERVAL 30 DAY THEN 1 ELSE 0 END) AS new_subscribers')
- ->select('COUNT(IF(S.status = 1 and S.is_renew =0 ,S.customer_id, NULL)) AS active,COUNT(IF(S.status = 0, S.customer_id, NULL)) AS expired,COUNT(IF(S.is_renew > 0 AND S.status = 1, S.customer_id, NULL)) AS renew')
- ->join('customers AS C', 'C.customer_id = S.customer_id AND C.isactive = 1', 'left')
- ->join('books AS BK', 'BK.book_id = S.scheme_id', 'left')
- ->join('book_categories AS BC', 'BC.book_id = S.scheme_id AND BC.isactive = 1', 'left')
- ->join('category AS CM', 'CM.id = BC.category_id AND C.isactive = 1', 'left')
- ->join('book_images AS BI', 'BI.book_id = S.scheme_id AND BI.isactive = 1', 'left')
- ->where(['S.business_id' => 2, 'BK.isactive' => 1])
- ->groupBy('S.scheme_id');
+ $query = $this->db->table('subscription')
+ // ->select('S.business_id, BK.title as name, BK.short_code, BK.book_id as id, S.scheme_id, LEFT(BK.title, 1) AS first_letter, COUNT(S.customer_id) AS count, BI.wp_img_url')
+ // ->select('COUNT(S.customer_id) AS overall, COUNT(IF(S.isactive = 1, S.customer_id, NULL)) AS activeoverall, COUNT(IF(S.is_renew = 0 AND S.isactive = 1, S.customer_id, NULL)) AS nonrenewal, COUNT(IF(S.is_renew = 1 AND S.isactive = 1, S.customer_id, NULL)) AS renewal, SUM(CASE WHEN S.created_on >= NOW() - INTERVAL 30 DAY THEN 1 ELSE 0 END) AS new_subscribers')
+ // ->select('COUNT(IF(S.status = 1 and S.is_renew =0 ,S.customer_id, NULL)) AS active,COUNT(IF(S.status = 0, S.customer_id, NULL)) AS expired,COUNT(IF(S.is_renew > 0 AND S.status = 1, S.customer_id, NULL)) AS renew')
+ // ->join('customers AS C', 'C.customer_id = S.customer_id AND C.isactive = 1', 'left')
+ // ->join('books AS BK', 'BK.book_id = S.scheme_id', 'left')
+ // ->join('book_categories AS BC', 'BC.book_id = S.scheme_id AND BC.isactive = 1', 'left')
+ // ->join('category AS CM', 'CM.id = BC.category_id AND C.isactive = 1', 'left')
+ // ->join('book_images AS BI', 'BI.book_id = S.scheme_id AND BI.isactive = 1', 'left')
+ // ->where(['S.business_id' => 2, 'BK.isactive' => 1])
+ // ->groupBy('S.scheme_id');
// print_r($query);die;
- // echo $this->db->getLastQuery(); die;
+
+ ->select('books.business_id,books.title as name ,scheme_id, books.short_code, count(*) as overall')
+ ->join('books','books.book_id = subscription.scheme_id')
+ ->where('to_subscription>now()')
+ ->groupBy('scheme_id');
$results = $query->get()->getResultArray();
- // print_r($results);die;
return $results;
}
@@ -156,7 +159,7 @@ class HomeModel extends Model
->groupBy('S.sub_id')
->get()
->getResultArray();
- // print_r($membershipList);
+ // print_r($membershipList);
// echo $this->db->getLastQuery(); die;
foreach ($membershipList as &$membership) {
$notifications = $this->getNotifications($membership['customer_id']);
@@ -204,6 +207,7 @@ class HomeModel extends Model
->groupBy('S.sub_id')
->get()
->getResultArray();
+ // echo($this->db->getLastQuery());die();
return $membershipList;
}
diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php
index e68ac8d4..19a882a7 100755
--- a/app/Models/InvoiceModel.php
+++ b/app/Models/InvoiceModel.php
@@ -144,7 +144,7 @@ public function getJoinedData($where, $orderby = [])
// }
$query->orderBy('I.invoice_date', 'DESC');
$query->orderBy('I.invoice_id', 'DESC');
- $query->groupBy('I.invoice_id');
+ // $query->groupBy('I.invoice_id');
$resultArray = $query->get()->getResultArray();
@@ -646,6 +646,7 @@ public function userwise_eventwise_report($f_date = null, $t_date = null){
$builder->select([
'users.user_id',
'users.first_name',
+ 'users.role',
'events.event_name',
'COUNT(invoice.created_by) AS books_sold',
'ABS(SUM(invoice.exact_total_amount)) AS total_amount',
diff --git a/app/Models/SubscriptionModel.php b/app/Models/SubscriptionModel.php
index ba47bc6e..b852c951 100755
--- a/app/Models/SubscriptionModel.php
+++ b/app/Models/SubscriptionModel.php
@@ -250,7 +250,7 @@ public function getQueryforSubscriptionDetailsBySchemeName($flag,$condition, $va
$result = $query->getResultArray();
$lastQuery = $this->db->getLastQuery();
$finalQueryString = $lastQuery->getQuery();
- // echo $finalQueryString;die;
+ // echo(count($result));die;
return $result;
}
public function getSubscriptionDetailsBySchemeName($selectedScheme, $downloadType){
diff --git a/app/Views/dashboard.php b/app/Views/dashboard.php
index bb57989d..1c7abd2f 100755
--- a/app/Views/dashboard.php
+++ b/app/Views/dashboard.php
@@ -84,7 +84,7 @@