diff --git a/app/Controllers/Books.php b/app/Controllers/Books.php index 35b5f80d..473bf145 100755 --- a/app/Controllers/Books.php +++ b/app/Controllers/Books.php @@ -65,6 +65,7 @@ class Books extends BaseController $session_bid = get_business_id(); $BooksModel = new BooksModel(); $book_id = $requested_details['book_id']; + $requested_details['publication_date'] = (isset($requested_details['publication_date']) && $requested_details['publication_date'] != "") ? $requested_details['publication_date'] : NULL ; if (empty($book_id )) { $requested_details['created_by'] = (int)$session_uid; if ($BooksModel->insert($requested_details)) { @@ -91,7 +92,7 @@ class Books extends BaseController ## book category section. $category_id = $requested_details['category_id']; - if ($category_id) { + if ($category_id != "") { $existingRecord = $BooksModel->db->table('book_categories') ->where(['book_id'=> $book_id,'category_id'=> $category_id]) diff --git a/app/Models/BooksModel.php b/app/Models/BooksModel.php index 945f3f2a..3e913a75 100644 --- a/app/Models/BooksModel.php +++ b/app/Models/BooksModel.php @@ -30,11 +30,11 @@ class BooksModel extends Model public function getnonMembershiplist($business_id) { $builder = $this->builder(); - $builder->select('books.book_id, books.wp_api_product_id, books.title, books.price, books.duration, books.isactive, books.publisher, books.genre, books.language, books.publication_date, GROUP_CONCAT(category.name SEPARATOR \',\') as name,category.id as category_id'); + $builder->select('books.book_id, books.wp_api_product_id, books.title, books.price, books.duration, books.isactive, books.publisher, books.genre, books.language, books.publication_date, CASE WHEN category.name THEN GROUP_CONCAT(category.name SEPARATOR \',\') ELSE \'\' END as name, category.id as category_id'); $builder->join('book_categories', 'book_categories.book_id = books.book_id and book_categories.isactive = 1', 'left'); $builder->join('category', 'category.id = book_categories.category_id', 'left'); $builder->where('books.business_id', $business_id); - $builder->where('category.name !=', 'membership'); // Exclude books with the category name "membership" + $builder->where("LOWER(category.name) != 'membership' OR category.id IS NULL"); $builder->groupBy('books.book_id'); $query = $builder->get(); diff --git a/app/Models/InvoiceModel.php b/app/Models/InvoiceModel.php index 4aa9346d..80f5a9d8 100644 --- a/app/Models/InvoiceModel.php +++ b/app/Models/InvoiceModel.php @@ -217,17 +217,34 @@ public function InactiveSubscriptionDraftDetails($where,$update_by_id) public function getCategoryBooks($type) { - $where = ($type == 1) ? ['LOWER(category.name) !=' => strtolower('Membership')] : ['LOWER(category.name)' => strtolower('Membership')]; + + // $where = ($type == 1) ? ['LOWER(category.name) !=' => strtolower('Membership')] : ['LOWER(category.name)' => strtolower('Membership')]; + // $data = $this->db->table('books') + // ->select('books.book_id,books.business_id,books.wp_api_product_id,books.title,books.publication_date,books.publisher,books.author,books.genre,books.language,books.description,books.short_description,books.page_count,books.price,books.isbn_code,books.tax,books.sku,books.category,books.isactive') + // ->join('book_categories', 'book_categories.book_id= books.book_id', 'left') + // ->join('category','category.id=book_categories.category_id') + // ->where($where) + // ->groupBy('books.book_id') + // ->get() + // ->getResult(); + // print_r($this->db->getLastQuery());die; $data = $this->db->table('books') - ->select('books.book_id,books.business_id,books.wp_api_product_id,books.title,books.publication_date,books.publisher,books.author,books.genre,books.language,books.description,books.short_description,books.page_count,books.price,books.isbn_code,books.tax,books.sku,books.category,books.isactive') - ->join('book_categories', 'book_categories.book_id= books.book_id', 'left') - ->join('category','category.id=book_categories.category_id') - ->where($where) - ->groupBy('books.book_id') - ->get() - ->getResult(); -// print_r($this->db->getLastQuery());die; + ->select('books.book_id,books.business_id,books.wp_api_product_id,books.title,books.publication_date,books.publisher,books.author,books.genre,books.language,books.description,books.short_description,books.page_count,books.price,books.isbn_code,books.tax,books.sku,books.category,books.isactive') + ->join('book_categories', 'book_categories.book_id = books.book_id and book_categories.isactive = 1', 'left') + ->join('category', 'category.id = book_categories.category_id', 'left'); + + if ($type == 1) { + $data->where("LOWER(category.name) != 'membership' OR category.id IS NULL"); + } else { + $data->where('LOWER(category.name)', 'membership'); + } + + $data = $data->groupBy('books.book_id') + ->get() + ->getResult(); + + return $data; return $data; } diff --git a/app/Models/NotificationModel.php b/app/Models/NotificationModel.php index 308ac1ee..b8a1b0ed 100644 --- a/app/Models/NotificationModel.php +++ b/app/Models/NotificationModel.php @@ -278,12 +278,14 @@ public function customerGroupQueryExecution($queries){ notification_history_children.receiving_status, notification_history_children.result, notification_history_children.sent_time, - DATE_FORMAT(notification_history_children.sent_time, "%d/%m/%Y %H:%i:%s") AS formatted_sent_time, + DATE_FORMAT(notification_history_children.sent_time, "%d/%m/%Y %h:%i %p") AS formatted_sent_date_time, + DATE_FORMAT(notification_history_children.sent_time, "%d/%m/%Y") AS formatted_sent_date, notification_history_parents.campaign_id, notification_campaign.campaign_name, notification_history_parents.status AS parents_status, notification_history_parents.start_date_time, - DATE_FORMAT(notification_history_parents.start_date_time, "%d/%m/%Y %H:%i:%s") AS formatted_start_date_time + DATE_FORMAT(notification_history_parents.start_date_time, "%d/%m/%Y %h:%i %p") AS formatted_start_date_time, + DATE_FORMAT(notification_history_parents.start_date_time, "%d/%m/%Y") AS formatted_start_date '); $query->join('notification_history_parents', 'notification_history_parents.id = notification_history_children.fkid', 'left'); diff --git a/app/Views/book_list.php b/app/Views/book_list.php index f3c840b5..e0fe1607 100644 --- a/app/Views/book_list.php +++ b/app/Views/book_list.php @@ -51,6 +51,7 @@ $message = 'In-Active'; } $edit_page_route = base_url() . "book_page/" . $row['book_id']; + $formattedPublicationYear = ($row['publication_date'] !== null && $row['publication_date'] != '') ? date('Y', strtotime($row['publication_date'])) : ""; ?>