diff --git a/app/Controllers/Customer.php b/app/Controllers/Customer.php index a9a6f1e3..fd173e58 100644 --- a/app/Controllers/Customer.php +++ b/app/Controllers/Customer.php @@ -99,6 +99,7 @@ class Customer extends BaseController 'mobile_no' => $this->request->getPost('cmobile'), 'email' => $this->request->getPost('cmail'), 'date_of_birth' => $dob, + 'type' => "customer", 'mode' => "Offline", 'business_id' => $this->request->getPost('business_id') ]; @@ -354,6 +355,7 @@ class Customer extends BaseController $result = $model->where($where)->findAll(); $db = \Config\Database::connect(); $sql = (string)$result[0]['group_query']; + // print_r($sql);die; if($sql){ $query = $db->query($sql); $results = $query->getResultArray(); @@ -490,7 +492,8 @@ class Customer extends BaseController LEFT JOIN invoice I on I.customer_id = C.customer_id and I.isactive = 1 LEFT JOIN customer_addresses CA on CA.customer_id = C.customer_id and CA.address_type = 1 and CA.isactive = 1 LEFT JOIN subscription S on S.customer_id = C.customer_id - LEFT JOIN category CM on CM.id = S.scheme_id + LEFT JOIN book_categories BC on BC.book_id = S.scheme_id + LEFT JOIN category CM on CM.id = BC.category_id WHERE C.isactive = 1 AND ".$whereCondition." GROUP BY C.customer_id"; $this->logger->info("Customer Group: SQL = ".$sql); // Execute the query diff --git a/app/Controllers/Subscription.php b/app/Controllers/Subscription.php index e173d3bb..d77b3abf 100644 --- a/app/Controllers/Subscription.php +++ b/app/Controllers/Subscription.php @@ -71,11 +71,12 @@ public function add_subscription() { $SubscriptionModel = new SubscriptionModel(); $data = [ - 'scheme_id' =>$this->request->getPost('scheme'), 'customer_id' =>$this->request->getPost('customer'), 'from_subscription' => $this->request->getPost('from_date'), 'to_subscription' => $this->request->getPost('to_date'), + // 'type' => "subscribed customer", + 'type' => "customer", 'mode' => $this->request->getPost('mode'), 'business_id'=>$session_bid ]; diff --git a/app/Models/HomeModel.php b/app/Models/HomeModel.php index ea9f9719..d6d91c2f 100644 --- a/app/Models/HomeModel.php +++ b/app/Models/HomeModel.php @@ -65,11 +65,12 @@ class HomeModel extends Model ->join('books as BK', 'BK.book_id = S.scheme_id', 'left') ->join('book_categories as BC', 'BC.book_id = S.scheme_id', 'left') ->join('category as CM', 'CM.id = BC.category_id', 'left') - ->select('CM.name, CONCAT(C.first_name, " ", C.last_name) as customer_name, C.email as customer_email, C.mobile_no as customer_mobile, S.sub_id, S.scheme_id, S.customer_id, S.business_id, S.to_subscription, S.from_subscription, BK.title, BK.book_id,DATEDIFF(S.to_subscription, CURDATE()) as countdays') + ->select('CM.name, CONCAT(C.first_name, " ", C.last_name) as customer_name, C.email as customer_email, C.mobile_no as customer_mobile, S.sub_id, S.scheme_id, S.customer_id, S.business_id, S.to_subscription, S.from_subscription, BK.title, BK.book_id,DATEDIFF(S.to_subscription, CURDATE()) as countdays,DATE_FORMAT(S.to_subscription, "%d-%m-%Y") as to_subscription_date_format') ->where('S.to_subscription >=', $now) ->where('S.to_subscription <=', $last30days) // ->where('BC.category_id', 5) ->where('LOWER(CM.name)', strtolower("Membership")) + ->orderBy('S.to_subscription', 'ASC') ->groupBy('S.sub_id') ->get() ->getResultArray(); @@ -86,6 +87,7 @@ class HomeModel extends Model ->where('B.created_on >=', $oneMonthAgo) ->where('B.created_on <=', $now) ->where('B.isactive', 1) + ->orderBy('B.publication_date', 'DESC') ->groupBy('B.book_id') ->get() ->getResultArray(); diff --git a/app/Views/dashboard.php b/app/Views/dashboard.php index e8058945..ffda2a57 100644 --- a/app/Views/dashboard.php +++ b/app/Views/dashboard.php @@ -222,15 +222,20 @@ // print "
";
                                     // print_r($expiring_membership);
                                     //  print "
"; - foreach ($expiring_membership as $e) : ?> + $tempinx = 0; + foreach ($expiring_membership as $e) : + $daysincount = (int)$e['countdays'] ; + $daysincountstring = ($daysincount == 0 ? 'Today' : ($daysincount == 1 ? 'Tomorrow' : $daysincount.' days')); + ?> - + +
- days +