From 51f4e11b3de27282d88b03e02577d032191a5fc8 Mon Sep 17 00:00:00 2001 From: velz Date: Wed, 21 Nov 2018 12:04:40 +0530 Subject: [PATCH] PD ASSESSED CHANGED --- api/application/config/constants.php | 2 +- api/application/models/PD_Model.php | 31 +++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index e9ae6ea6..096206d1 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -87,7 +87,7 @@ defined('EXIT__AUTO_MAX') OR define('EXIT__AUTO_MAX', 125); // highest auto // define login route name for token verification //defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listLessPDDetails/:any)'); // no errors //defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', '(listAllTemplates/:any)'); // no errors -defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'saveAssessedIncomeMonthwiseItems'); // no errors +defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getAssessedIncome'); // no errors /*********************AWS resources Constants*************************************************/ defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic'); diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index f869952f..db0635ca 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -810,7 +810,10 @@ class PD_Model extends SPARQ_Model { $sales_calculated_by_itemwise = $this->getJoinRecords($fields,$table,$joins,$where_condition_array); - //get sales_items_by_monthwise details + //get sales_items_by_monthwise details + + $sales_items_by_months = array(); + $this->db->SELECT('sim_id,sales_item'); $this->db->FROM(SALESITEMMONTHWISE.' as SALESITEMMONTHWISE'); $this->db->WHERE('SALESITEMMONTHWISE.fk_pd_id',$pdid); @@ -820,13 +823,31 @@ class PD_Model extends SPARQ_Model { { foreach($sales_items_by_monthwise as $key => $item) { - $this->db->SELECT('simc_id,sales_date,sales_value'); + $this->db->SELECT('month(sales_date) as month,year(sales_date) as year'); $this->db->FROM(SALESITEMMONTHWISECHILD.' as SALESITEMMONTHWISECHILD'); $this->db->WHERE('SALESITEMMONTHWISECHILD.fk_sim_id',$item['sim_id']); $this->db->WHERE('SALESITEMMONTHWISECHILD.isactive',1); - //$this->db->GROUP_BY('SALESITEMMONTHWISECHILD.sales_date'); - $sales_items_by_monthwise_child = $this->db->GET()->result_array(); - $sales_items_by_monthwise[$key]['items'] = $sales_items_by_monthwise_child; + $this->db->GROUP_BY('month(SALESITEMMONTHWISECHILD.sales_date)'); + $sales_items_by_month = $this->db->GET()->result_array(); + //print_r($this->db->last_query()); + + if(count($sales_items_by_month)) + { + foreach($sales_items_by_month as $month_key => $month) + { + $this->db->SELECT('simc_id,sales_date,sales_value'); + $this->db->FROM(SALESITEMMONTHWISECHILD.' as SALESITEMMONTHWISECHILD'); + $this->db->WHERE('SALESITEMMONTHWISECHILD.fk_sim_id',$item['sim_id']); + $this->db->WHERE('month(SALESITEMMONTHWISECHILD.sales_date)',$month['month']); + $this->db->WHERE('SALESITEMMONTHWISECHILD.isactive',1); + //$this->db->GROUP_BY('month(SALESITEMMONTHWISECHILD.sales_date)'); + $sales_items_by_month_child = $this->db->GET()->result_array(); + //print_r($this->db->last_query());die(); + $sales_items_by_months[date("M-Y", strtotime($month['year'].'-'.$month['month']))] = $sales_items_by_month_child; + } + } + $sales_items_by_monthwise[$key]['items'] = $sales_items_by_months; + //print_r($sales_items_by_months); } }