diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index 2b98eea0..046a54a1 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -24,14 +24,15 @@ class Home extends BaseController $model = new HomeModel(); $data['customer'] = $model->customers($where); $data['customer']['label'] = "Customer"; - $data['invoice'] = $model->invoice(); + $data['invoice'] = $model->invoice_dtls(); // $data['active_category'] = $model->schemes(); $data['active_schemes'] = $model->active_schemes(); $data['expiring_membership'] = $model->expiring_membership_list(); // $data['active_category'] = array_filter($model->schemes(), function ($element) { // return $element['count'] !== '0' ; // }); - $data['book_published'] = $model->book_published_list(); + $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; $this->render_page('dashboard', $data); diff --git a/app/Models/HomeModel.php b/app/Models/HomeModel.php index 1a19bc86..cdda3469 100644 --- a/app/Models/HomeModel.php +++ b/app/Models/HomeModel.php @@ -25,7 +25,7 @@ class HomeModel extends Model return $customer; } - public function invoice() { + public function invoice_dtls() { if (date('m') <= 3) { $invoice['financial_year'] = (date('Y')-1) . '-' . date('Y'); $start_date = (date('Y')-1).'-04-01'; @@ -92,20 +92,53 @@ class HomeModel extends Model ->getResultArray(); } - public function book_published_list(){ - $oneMonthAgo = date('Y-m-d', strtotime(' -30 days')); + public function book_published_dtls(){ - return $this->db->table('books as B') + if (date('m') <= 3) { + $start_date = (date('Y')-1).'-04-01'; + $end_date = date('Y').'-03-31'; + } else { + $start_date = date('Y').'-04-01'; + $end_date = (date('Y')+1).'-03-31'; + } + + $time = strtotime(date('Y-m-d')); + $one_month_ago = date('Y-m-d', strtotime("-1 month", $time)); + $one_month_ago_date = date("F d, Y", strtotime("-1 month", $time)); + $this_month_today_date = date("F d, Y", $time); + $this_month_name =date('M,Y', $time); + + $overall_where = ['isactive'=>1]; + $overall_query = $this->db->table('books')->where($overall_where)->countAllResults(); + $date_where = ['DATE(created_on)' => date('Y-m-d'),'isactive'=>1]; + $date_query = $this->db->table('books')->where($date_where)->countAllResults(); + $month_where = ['MONTH(created_on)' => date('m'),'isactive'=>1]; + $month_query = $this->db->table('books')->where($month_where)->countAllResults(); + $fin_year_where = ['DATE(created_on) >= ' => $start_date , 'DATE(created_on) <= ' => $end_date,'isactive'=>1]; + $fin_year_query = $this->db->table('books')->where($fin_year_where)->countAllResults(); + + $last_one_month_dtls = $this->db->table('books as B') ->select("B.book_id, B.title, B.created_on, B.publisher, B.author, B.publication_date, DATE_FORMAT(B.publication_date, '%d/%m/%Y') as publication_date_format, GROUP_CONCAT(CM.name, ',') as categories") ->join('book_categories as BC', 'BC.book_id = B.book_id and BC.isactive = 1', 'left') ->join('category as CM', 'BC.category_id = CM.id', 'left') - ->where('B.created_on >=', $oneMonthAgo) + ->where('B.created_on >=', $one_month_ago) ->where('B.created_on <= CURDATE() + INTERVAL 1 DAY') ->where('B.isactive', 1) ->orderBy('B.publication_date', 'DESC') ->groupBy('B.book_id') ->get() ->getResultArray(); - } + + $book_published['overall'] = $overall_query; + $book_published['today'] = $date_query; + $book_published['today_label'] = $this_month_today_date; + $book_published['month'] = $month_query; + $book_published['month_label'] = $this_month_name; + $book_published['year'] = $fin_year_query; + $book_published['book_published_label'] = $one_month_ago_date." - ".$this_month_today_date; + $book_published['book_published'] = $last_one_month_dtls; + + return $book_published; + } } diff --git a/app/Views/dashboard.php b/app/Views/dashboard.php index a70a769c..525d213e 100644 --- a/app/Views/dashboard.php +++ b/app/Views/dashboard.php @@ -188,82 +188,102 @@
| Book Details | -Category | -
|---|---|
| = $b['title']; ?>
-
- - = $b['author']; ?> - - - -- = $b['publisher']; ?> - - - -- = $b['publication_date_format']; ?> - - - |
- - - = str_replace(',', '', $splitted[$i]); ?> - - | -
Overall
+YTD
+MTD
+| Book Details | +Category | +
|---|---|
| = $b['title']; ?>
+
+ + = $b['author']; ?> + + + ++ = $b['publisher']; ?> + + + ++ = $b['publication_date_format']; ?> + + + |
+ + + = str_replace(',', '', $splitted[$i]); ?> + + | +