diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php index 83ce4f5b..4e7cd7bf 100644 --- a/app/Controllers/Invoice.php +++ b/app/Controllers/Invoice.php @@ -105,6 +105,7 @@ class Invoice extends BaseController $select = ["customer_address_id", "CONCAT(address_1,' ',address_2) as address"]; $where['address_type'] = 2; $data['customer_shipping'] = $this->get_customer_address($where, $select); + $data['customer_membership'] = $this->get_customer_membership("membership",(int)$id); return $this->response->setJSON(['data' => $data]); } @@ -131,6 +132,12 @@ class Invoice extends BaseController return $address_details; } + public function get_customer_membership($category,$id){ + $model = new InvoiceModel(); + $result = $model->getMembershipListForCustomer($category,$id); + return $result; + } + ## To insert or update the details of the invoice public function save_invoice() { diff --git a/app/Models/HomeModel.php b/app/Models/HomeModel.php index 4135c532..12ed53b2 100644 --- a/app/Models/HomeModel.php +++ b/app/Models/HomeModel.php @@ -69,7 +69,8 @@ class HomeModel extends Model ->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.from_subscription, S.to_subscription, S.business_id, S.to_subscription, S.from_subscription, BK.title, BK.book_id,DATEDIFF(S.to_subscription, CURDATE()) as countdays') ->where('S.to_subscription >=', $now) ->where('S.to_subscription <=', $last30days) - ->where('BC.category_id', 5) + // ->where('BC.category_id', 5) + ->where('LOWER(BC.category_name)', strtolower('Membership'), FALSE) ->groupBy('S.sub_id') ->get() ->getResultArray(); diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index 7705cefe..2b7190f4 100644 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -171,6 +171,25 @@ public function updateData($table, $data, $where) return $data; } + + public function getMembershipListForCustomer($category,$id) + { + $data = $this->db->table('subscription as S') + ->join('customers as C','C.customer_id = S.customer_id','left') + ->join('category as CM', 'CM.id = S.scheme_id', 'left') + ->join('book_categories as BC', 'BC.category_id = S.scheme_id', 'left') + ->join('books as BK', 'BC.book_id = BK.book_id', 'left') + ->select('S.customer_id,concat(C.first_name, " ", C.last_name) as customer_name,S.sub_id,S.scheme_id,DATE_FORMAT(S.from_subscription, "%d/%m/%Y") AS formatted_from_subscription,DATE_FORMAT(S.to_subscription, "%d/%m/%Y") AS formatted_to_subscription,S.from_subscription,S.to_subscription,S.created_on,CM.name,BK.title,BK.book_id') + ->where('LOWER(CM.name)', strtolower("'".$category."'"), FALSE) + ->where('S.customer_id', $id) + ->groupBy('S.sub_id') + ->orderBy('S.created_on','ASC') + ->get() + ->getResultArray(); + // print_r($this->db->getLastQuery());die; + return $data; + } + public function getProductImgs($productId) { $data = $this->db->table('book_images') diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index 3aed934d..8b468560 100644 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -27,6 +27,70 @@ + +
+