From e0565c20fb0b21ddf3537b7e041d5920f652c5a3 Mon Sep 17 00:00:00 2001 From: Velz2020 Date: Fri, 9 Aug 2019 18:54:10 +0530 Subject: [PATCH] AI CHANGES --- api/application/config/constants.php | 3 +- api/application/config/routes.php | 1 + api/application/controllers/PD_Controller.php | 471 +++++++++++++----- api/application/models/PD_Model.php | 304 +++++++---- 4 files changed, 539 insertions(+), 240 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 2ea4372e..37ea2739 100644 --- a/api/application/config/constants.php +++ b/api/application/config/constants.php @@ -573,7 +573,8 @@ defined('T_PD_INLINE_PHOTO_FORM_STATUS') OR define('T_PD_INLINE_PHOTO_FORM_STATU defined('PDREMARKS') OR define('PDREMARKS','t_pd_remarks'); defined('PDREMARKSID') OR define('PDREMARKSID','pd_remark_id'); - +defined('PURCHASEDECLAREDBYCUSTOMER') OR define('PURCHASEDECLAREDBYCUSTOMER','t_purchase_declared_by_customer'); +defined('PURCHASEDECLAREDBYCUSTOMERID') OR define('PURCHASEDECLAREDBYCUSTOMERID','pdc_id'); diff --git a/api/application/config/routes.php b/api/application/config/routes.php index ff9c6d03..62d739d5 100644 --- a/api/application/config/routes.php +++ b/api/application/config/routes.php @@ -170,6 +170,7 @@ $route['checkOTP'] = 'PD_Controller/checkOTP'; $route['getAssessedIncome'] = 'PD_Controller/getAssessedIncome'; $route['saveAssessedIncomeSalesDeclaredByCustomer'] = 'PD_Controller/saveAssessedIncomeSalesDeclaredByCustomer'; $route['saveAssessedIncomeSalesCalculatedByItemwise'] = 'PD_Controller/saveAssessedIncomeSalesCalculatedByItemwise'; +$route['saveAssessedIncomePurchaseDeclaredByCustomer'] = 'PD_Controller/saveAssessedIncomePurchaseDeclaredByCustomer'; $route['saveAssessedIncomePurchaseDetails'] = 'PD_Controller/saveAssessedIncomePurchaseDetails'; $route['saveAssessedIncomeBusinessExpenses'] = 'PD_Controller/saveAssessedIncomeBusinessExpenses'; $route['saveAssessedIncomeHouseholdExpenses'] = 'PD_Controller/saveAssessedIncomeHouseholdExpenses'; diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index cb0dffa0..16805e39 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -3070,16 +3070,18 @@ class PD_Controller extends REST_Controller { //print_r($fine);die(); if($fine != null) { + $fine['purchase_declared_by_customer'] = $result_array['purchase_declared_by_customer']; $fine['sales_revenue_details'] = $result_array['sales_calculated_by_itemwise']; $fine['other_business_income_details'] = $result_array['othre_business_income']; $fine['purchase_details'] = $result_array['purchase_details']; - $fine['purchase_billwise'] = $result_array['purchase_billwise']; + //$fine['purchase_billwise'] = $result_array['purchase_billwise']; $fine['business_expense_details'] = $result_array['business_expenses']; $fine['house_hold_expense_details'] = $result_array['house_hold_expenses']; + $result_array['final_data'][] = $fine; } - if(count($result_array['sales_declared_by_customer']) == 0 && count($result_array['sales_calculated_by_itemwise']) == 0 && count($result_array['sales_items_by_monthwise']) == 0 && count($result_array['purchase_details']) == 0 && count($result_array['business_expenses']) == 0 && count($result_array['house_hold_expenses']) == 0 && count($result_array['gross_profit_calculation_type']) == 0) + if(count($result_array['sales_declared_by_customer']) == 0 && count($result_array['sales_calculated_by_itemwise']) == 0 && count($result_array['purchase_details']) == 0 && count($result_array['purchase_declared_by_customer']) == 0 && count($result_array['business_expenses']) == 0 && count($result_array['house_hold_expenses']) == 0 && count($result_array['gross_profit_calculation_type']) == 0) { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_OK; @@ -3126,6 +3128,38 @@ class PD_Controller extends REST_Controller { } } + + public function saveAssessedIncomePurchaseDeclaredByCustomer_post() + { + $records = $this->post('records'); + $pk = ""; + if($records['pdc_id'] != null || $records['pdc_id'] != "") + { + + $where_condition_array = array('pdc_id'=>$records['pdc_id']); + $pk = $this->PD_Model->updateRecords($records,PURCHASEDECLAREDBYCUSTOMER,$where_condition_array); + } + else + { + $pk = $this->PD_Model->saveRecords($records,PURCHASEDECLAREDBYCUSTOMER); + } + + if($pk != "" || $pk != null) + { + $data['dataStatus'] = true; + $data['status'] = REST_Controller::HTTP_OK; + $data['records'] = $pk; + $this->response($data,REST_Controller::HTTP_OK); + } + else + { + $data['dataStatus'] = false; + $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; + $data['msg'] = 'Something went wrong! Try Later'; + $this->response($data,REST_Controller::HTTP_OK); + } + + } public function saveOtherBusinessIncome_post() { @@ -3168,17 +3202,67 @@ class PD_Controller extends REST_Controller { $count = 0; foreach($records as $rec_key => $record) { - if($record['sci_id'] != null || $record['sci_id'] != "") + + $child_data = array(); + if(array_key_exists('child',$record)) { - $where_condition_array = array('sci_id'=>$record['sci_id']); - $id = $this->PD_Model->updateRecords($record,SALESCALCULATEDBYITEMWISE,$where_condition_array); - if($id != "" || $id != null){$count++;} - } - else - { - $id = $this->PD_Model->saveRecords($record,SALESCALCULATEDBYITEMWISE); - if($id != "" || $id != null){$count++;} + $child_data = $record['child']; + unset($record['child']); } + + + if($record['sci_id'] != null || $record['sci_id'] != "") + { + $where_condition_array = array('sci_id'=>$record['sci_id']); + $id = $this->PD_Model->updateRecords($record,SALESCALCULATEDBYITEMWISE,$where_condition_array); + if($id != "" || $id != null){$count++;} + if($record['sales_type'] == 3) + { + foreach($child_data as $ckey => $child) + { + if($child['simc_id'] != "" || $child['simc_id'] != null) + { + $where_condition_array = array('simc_id'=>$child['simc_id']); + $child_id = $this->PD_Model->updateRecords($child,SALESITEMMONTHWISECHILD,$where_condition_array); + } + else + { + if(($child['sales_date'] != null || $child['sales_date'] != "")) + { + $child['fk_sci_id'] = $record['sci_id']; + $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); + } + } + } + } + } + else + { + $id = $this->PD_Model->saveRecords($record,SALESCALCULATEDBYITEMWISE); + if($id != "" || $id != null){$count++;} + + if($record['sales_type'] == 3) + { + foreach($child_data as $ckey => $child) + { + if($child['simc_id'] != "" || $child['simc_id'] != null) + { + $where_condition_array = array('simc_id'=>$child['simc_id']); + $child_id = $this->PD_Model->updateRecords($child,SALESITEMMONTHWISECHILD,$where_condition_array); + } + else + { + if(($child['sales_date'] != null || $child['sales_date'] != "")) + { + $child['fk_sci_id'] = $record['sci_id']; + $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); + } + } + } + } + } + + } if($count == count($records)) { @@ -3202,16 +3286,64 @@ class PD_Controller extends REST_Controller { $count = 0; foreach($records as $rec_key => $record) { + $child_data = ""; + if(array_key_exists('child',$record)) + { + $child_data = $record['child']; + unset($record['child']); + } + if($record['purchase_id'] != null || $record['purchase_id'] != "") { $where_condition_array = array('purchase_id'=>$record['purchase_id']); $id = $this->PD_Model->updateRecords($record,PDPURCHASEDETAILS,$where_condition_array); if($id != "" || $id != null){$count++;} + if($record['purchase_type'] == 3) + { + if($id != "" || $id != null) + { + + foreach($child_data as $ckey => $child) + { + if($child['pbwc_id'] != "" || $child['pbwc_id'] != null) + { + $where_condition_array = array('pbwc_id'=>$child['pbwc_id']); + $child_id = $this->PD_Model->updateRecords($child,PDPURCHASEBILLWISECHILD,$where_condition_array); + } + else + { + $child['fk_purchase_id'] = $record['purchase_id']; + $child_id = $this->PD_Model->saveRecords($child,PDPURCHASEBILLWISECHILD); + } + } + } + } + } else { $id = $this->PD_Model->saveRecords($record,PDPURCHASEDETAILS); if($id != "" || $id != null){$count++;} + if($record['purchase_type'] == 3) + { + if($id != "" || $id != null) + { + + foreach($child_data as $ckey => $child) + { + if($child['pbwc_id'] != "" || $child['pbwc_id'] != null) + { + $where_condition_array = array('pbwc_id'=>$child['pbwc_id']); + $child_id = $this->PD_Model->updateRecords($child,PDPURCHASEBILLWISECHILD,$where_condition_array); + } + else + { + $child['fk_purchase_id'] = $id; + $child_id = $this->PD_Model->saveRecords($child,PDPURCHASEBILLWISECHILD); + } + } + } + } } } if($count == count($records)) @@ -3301,15 +3433,15 @@ class PD_Controller extends REST_Controller { } - /********************************************************************************************* - *********************************************************************************************/ - public function saveAssessedIncomeMonthwiseItems_post()//SALESITEMMONTHWISECHILD + /*************NOT IN USE***********NOT IN USE*************************NOT IN USE************ + *************NOT IN USE*********NOT IN USE*****************NOT IN USE***********************/ + public function saveAssessedIncomeMonthwiseItems($item)//SALESITEMMONTHWISECHILD - NOT IN USE { - $records = $this->post('records'); - + //$records = $this->post('records'); + $record = $item; $count = 0; - foreach($records as $key => $record) - { + //foreach($records as $key => $record) + //{ //$record['sales_type'] $child_data = array(); if(array_key_exists('child',$record)) @@ -3318,9 +3450,22 @@ class PD_Controller extends REST_Controller { unset($record['child']); } $id = ""; + + //Remove other than DB fields + if(array_key_exists('margin_final_value', $record) + { + $record['margin_value'] = $record['margin_final_value']; unset($record['margin_final_value']); + } + array_key_exists('sales_qty', $record) ? unset($record['sales_qty']) : ''; + array_key_exists('fk_uom_id', $record) ? unset($record['fk_uom_id']) : ''; + array_key_exists('rate_per_unit', $record) ? unset($record['rate_per_unit']) : ''; + array_key_exists('fk_frequency_id', $record) ? unset($record['fk_frequency_id']) : ''; + array_key_exists('annual_sale_value', $record) ? unset($record['annual_sale_value']) : ''; + array_key_exists('margin_per_uom', $record) ? unset($record['margin_per_uom']) : ''; + + // CURD Operations if($record['sim_id'] != null || $record['sim_id'] != "" ) { - $where_condition_array = array('sim_id'=>$record['sim_id']); $id = $this->PD_Model->updateRecords($record,SALESITEMMONTHWISE,$where_condition_array); if($id != "" || $id != null) @@ -3335,7 +3480,7 @@ class PD_Controller extends REST_Controller { } else { - if(($child['frequency_value'] != null || $child['frequency_value'] != "") || ($child['sales_date'] != null || $child['sales_date'] != "")) + if(($child['sales_date'] != null || $child['sales_date'] != "")) { $child['fk_sim_id'] = $record['sim_id']; $child_id = $this->PD_Model->saveRecords($child,SALESITEMMONTHWISECHILD); @@ -3355,7 +3500,7 @@ class PD_Controller extends REST_Controller { foreach($child_data as $ckey => $child) { - if(($child['frequency_value'] != null || $child['frequency_value'] != "") || ($child['sales_date'] != null || $child['sales_date'] != "")) + if((($child['sales_date'] != null || $child['sales_date'] != "")) { //echo 'true'; $child['fk_sim_id'] = $id; @@ -3365,26 +3510,16 @@ class PD_Controller extends REST_Controller { } } - } + //} - if($count == count($records)) + if($id != "") { - $data['dataStatus'] = true; - $data['status'] = REST_Controller::HTTP_OK; - $data['records'] = $id; - $this->response($data,REST_Controller::HTTP_OK); - } - else - { - $data['dataStatus'] = false; - $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; - $data['msg'] = 'Something went wrong! Try Later'; - $this->response($data,REST_Controller::HTTP_OK); + return 1; } } - //Save Purcahse Items billwise - public function saveAssessedIncomePurchaseBillwise_post()//SALESITEMMONTHWISECHILD + //Save Purcahse Items billwise - NOT IN USE + public function saveAssessedIncomePurchaseBillwise_post()//SALESITEMMONTHWISECHILD - NOT IN USE { $records = $this->post('records'); $count = 0; @@ -3641,7 +3776,7 @@ class PD_Controller extends REST_Controller { $overall_summary_report = array(); $overall_summary_report['sales_calculated_by_itemwise'] = null; - $overall_summary_report['sales_calculated_by_monthwise'] = null; + //$overall_summary_report['sales_calculated_by_monthwise'] = null; $overall_summary_report['sales_declared_by_customer'] = null; $sales_declared_by_customer = array(); @@ -3650,12 +3785,15 @@ class PD_Controller extends REST_Controller { $sales_calculated_by_itemwise = array(); $sales_calculated_by_itemwise_flag = 0; - $sales_by_item_monthwise = array(); - $sales_by_item_monthwise_flag = 0; - $margin_value_from_monthwise_data = array(); + // $sales_by_item_monthwise = array(); + // $sales_by_item_monthwise_flag = 0; + // $margin_value_from_monthwise_data = array(); $purchases = array(); $purchases_flag = 0; + + $purchase_declared_by_customer = array(); + $purchase_declared_by_customer_flag = 0; $business_expenses = array(); $business_expenses_flag = 0; @@ -3680,7 +3818,8 @@ class PD_Controller extends REST_Controller { $sales_calculated_by_itemwise = $result_array['sales_calculated_by_itemwise']; $sales_by_item_monthwise = $result_array['sales_items_by_monthwise']; $purchases = $result_array['purchase_details']; - $purchase_billwise = $result_array['purchase_billwise']; + $purchase_declared_by_customer = $result_array['purchase_declared_by_customer']; + //$purchase_billwise = $result_array['purchase_billwise']; $business_expenses = $result_array['business_expenses']; $other_business_income = $result_array['othre_business_income']; $household_expenses = $result_array['house_hold_expenses']; @@ -3688,14 +3827,15 @@ class PD_Controller extends REST_Controller { $othre_business_income = $result_array['othre_business_income']; if(count($sales_declared_by_customer)){$sales_declared_by_customer_flag = 1;} if(count($sales_calculated_by_itemwise)){$sales_calculated_by_itemwise_flag = 1;} - if(count($sales_by_item_monthwise)){$sales_by_item_monthwise_flag = 1;} - if(count($purchases) || count($purchase_billwise)){$purchases_flag = 1;} + //if(count($sales_by_item_monthwise)){$sales_by_item_monthwise_flag = 1;} + if(count($purchases)){ $purchases_flag = 1;} + if(count($purchase_declared_by_customer)){$purchase_declared_by_customer_flag = 1;} if(count($business_expenses)){$business_expenses_flag = 1;} if(count($household_expenses)){$household_expenses_flag = 1;} if(count($other_business_income)){$other_business_income_flag = 1;} - if(($business_expenses_flag == 1) && ($sales_declared_by_customer_flag == 1 || $sales_calculated_by_itemwise_flag == 1 || $sales_by_item_monthwise_flag == 1)) + if(($business_expenses_flag == 1) && ($sales_declared_by_customer_flag == 1 && $purchase_declared_by_customer_flag) || ($sales_calculated_by_itemwise_flag == 1 && $purchases_flag = 1)) { $total_sales_itemwise = 0; $sales_monthwise = array(); @@ -3723,45 +3863,103 @@ class PD_Controller extends REST_Controller { if($purchases_flag != 0) { - if($gross_profit_calculation_type[0]['mode'] == 1 && $gross_profit_calculation_type[0]['purchase_type'] == 1)//purchase item wise - { + // if($gross_profit_calculation_type[0]['mode'] == 1 && $gross_profit_calculation_type[0]['purchase_type'] == 1)//purchase item wise + // { foreach($purchases as $purchase_key => $purchase) { - $overall_purchase_total = $overall_purchase_total + $purchase['annual_purchase_value']; + + $overall_purchase_total += $purchase['sales_type'] != 3 ? $purchase['annual_purchase_value'] : ($purchase['annual_purchase_value'] * (12/ count($purchase['items'])) ); } - } - else if($gross_profit_calculation_type[0]['mode'] == 1 && $gross_profit_calculation_type[0]['purchase_type'] == 2)////purchase bill wise - { + // } + // else if($gross_profit_calculation_type[0]['mode'] == 1 && $gross_profit_calculation_type[0]['purchase_type'] == 2)////purchase bill wise + // { - foreach($purchase_billwise as $purchase_billwise_key => $bill) - { + // foreach($purchase_billwise as $purchase_billwise_key => $bill) + // { - $overall_purchase_total = $overall_purchase_total + ($bill['annual_purchase_value'] * (12/ count($bill['items'])) ); - } - } + // $overall_purchase_total = $overall_purchase_total + ($bill['annual_purchase_value'] * (12/ count($bill['items'])) ); + // } + //} } - if($sales_calculated_by_itemwise_flag == 1) + if($sales_calculated_by_itemwise_flag == 1 && $purchases_flag == 1) { + + $temp_purchases = 0; $temp_netprofit = 0; $temp_grossprofit = 0; $temp_netmargin = 0; foreach($sales_calculated_by_itemwise as $itemwise_key => $item) { - $total_sales_itemwise = $total_sales_itemwise + $item['annual_sale_value']; - $temp_netprofit = $temp_netprofit + $item['margin_final_value']; + if($item['sales_type'] != 3) + { + $total_sales_itemwise = $total_sales_itemwise + $item['annual_sale_value']; + $temp_netprofit = $temp_netprofit + $item['margin_final_value']; + } + else + { + //***************************** + foreach($sales_by_item_monthwise as $monthwise_key => $sales_by_item_month) + { + //print_r($sales_by_item_month['items']); + //echo isset($sales_by_item_month['items']);die(); + $month_total = 0; + $i = 0; + $temp_netprofit = $temp_netprofit + $sales_by_item_month['margin_value']; + if(isset($sales_by_item_month['items'])) + { + //echo 'insdie if'; + foreach($sales_by_item_month['items'] as $month_key => $month) + { + $temp = 0; + + $i++; + foreach($month as $key => $m) + { + $temp = $temp + $m['sales_value']; + } + $month_total = $month_total + $temp; + } + } + + //die(); + $sales_monthwise[] = array('total' => $month_total,'no_of_months' => $i,'sales_type' => $sales_by_item_month['sales_type']); + } + + + //print_r($sales_monthwise);die(); + $total_sales_monthwise = 0; + foreach($sales_monthwise as $sale) + { + + + $annual_multuplier = 12 / ( $sale['no_of_months'] ? $sale['no_of_months'] : 1); + + if($sale['sales_type'] == 1) + { + $total_sales_monthwise = $total_sales_monthwise + ($sale['total'] * $annual_multuplier); + } + else if($sale['sales_type'] == 2) + { + $total_sales_monthwise = $total_sales_monthwise + $sale['total']; + } + } + //***************************** + } } + + //calculatin part if($gross_profit_calculation_type[0]['mode'] == 1) { $temp_purchases = $overall_purchase_total; - $temp_grossprofit = $total_sales_itemwise - $temp_purchases; + $temp_grossprofit = ($total_sales_itemwise + $total_sales_monthwise) - $temp_purchases; $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total; - $temp_netmargin = ($temp_netprofit/$total_sales_itemwise) * 100; + $temp_netmargin = ($temp_netprofit/ ($total_sales_itemwise + $total_sales_monthwise) ? ($total_sales_itemwise + $total_sales_monthwise): 1) * 100; } else { @@ -3769,8 +3967,8 @@ class PD_Controller extends REST_Controller { // This one changes as per 15/03/2019 Excel Review changes $temp_grossprofit = $temp_netprofit;// + $overall_business_expenses_total; $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total; - $temp_purchases = $total_sales_itemwise - $temp_grossprofit; - $temp_netmargin = ($temp_netprofit/$total_sales_itemwise) * 100; + $temp_purchases = ($total_sales_itemwise + $total_sales_monthwise) - $temp_grossprofit; + $temp_netmargin = ($temp_netprofit/( $total_sales_itemwise + $total_sales_monthwise) * 100; } $overall_summary_report['sales_calculated_by_itemwise']['sales_revenue'] = round($total_sales_itemwise); @@ -3783,91 +3981,91 @@ class PD_Controller extends REST_Controller { $overall_summary_report['sales_calculated_by_itemwise']['netmargin'] = round($temp_netmargin,2); } - if($sales_by_item_monthwise_flag == 1) - { - $temp_purchases = 0; - $temp_netprofit = 0; - $temp_grossprofit = 0; - $temp_netmargin = 0; - //print_r($sales_by_item_monthwise);die(); - foreach($sales_by_item_monthwise as $monthwise_key => $sales_by_item_month) - { - //print_r($sales_by_item_month['items']); - //echo isset($sales_by_item_month['items']);die(); - $month_total = 0; - $i = 0; - $temp_netprofit = $temp_netprofit + $sales_by_item_month['margin_value']; - if(isset($sales_by_item_month['items'])) - { - //echo 'insdie if'; - foreach($sales_by_item_month['items'] as $month_key => $month) - { - $temp = 0; + // if($sales_by_item_monthwise_flag == 1) + // { + // $temp_purchases = 0; + // $temp_netprofit = 0; + // $temp_grossprofit = 0; + // $temp_netmargin = 0; + // //print_r($sales_by_item_monthwise);die(); + // foreach($sales_by_item_monthwise as $monthwise_key => $sales_by_item_month) + // { + // //print_r($sales_by_item_month['items']); + // //echo isset($sales_by_item_month['items']);die(); + // $month_total = 0; + // $i = 0; + // $temp_netprofit = $temp_netprofit + $sales_by_item_month['margin_value']; + // if(isset($sales_by_item_month['items'])) + // { + // //echo 'insdie if'; + // foreach($sales_by_item_month['items'] as $month_key => $month) + // { + // $temp = 0; - $i++; - foreach($month as $key => $m) - { - $temp = $temp + $m['sales_value']; - } - $month_total = $month_total + $temp; - } - } + // $i++; + // foreach($month as $key => $m) + // { + // $temp = $temp + $m['sales_value']; + // } + // $month_total = $month_total + $temp; + // } + // } - //die(); - $sales_monthwise[] = array('total' => $month_total,'no_of_months' => $i,'sales_type' => $sales_by_item_month['sales_type']); - } + // //die(); + // $sales_monthwise[] = array('total' => $month_total,'no_of_months' => $i,'sales_type' => $sales_by_item_month['sales_type']); + // } - //print_r($sales_monthwise);die(); - foreach($sales_monthwise as $sale) - { + // //print_r($sales_monthwise);die(); + // foreach($sales_monthwise as $sale) + // { - $annual_multuplier = 12 / ( $sale['no_of_months'] ? $sale['no_of_months'] : 1); + // $annual_multuplier = 12 / ( $sale['no_of_months'] ? $sale['no_of_months'] : 1); - if($sale['sales_type'] == 1) - { - $total_sales_monthwise = $total_sales_monthwise + ($sale['total'] * $annual_multuplier); - } - else if($sale['sales_type'] == 2) - { - $total_sales_monthwise = $total_sales_monthwise + $sale['total']; - } - } + // if($sale['sales_type'] == 1) + // { + // $total_sales_monthwise = $total_sales_monthwise + ($sale['total'] * $annual_multuplier); + // } + // else if($sale['sales_type'] == 2) + // { + // $total_sales_monthwise = $total_sales_monthwise + $sale['total']; + // } + // } - //calculation part - //calculatin part - if($gross_profit_calculation_type[0]['mode'] == 1) - { - $temp_purchases = $overall_purchase_total; - $temp_grossprofit = $total_sales_monthwise - $temp_purchases; - $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total; - $temp_netmargin = ($temp_netprofit/ ($total_sales_monthwise?$total_sales_monthwise:1) ) * 100; - } - else - { - $temp_grossprofit = $temp_netprofit ;//+ $overall_business_expenses_total; - $temp_purchases = $total_sales_monthwise - $temp_grossprofit; - $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total; - //echo $temp_netprofit.'-'.$total_sales_monthwise;die(); - $temp_netmargin = ($temp_netprofit/ ($total_sales_monthwise?$total_sales_monthwise:1) ) * 100; - } + // //calculation part + // //calculatin part + // if($gross_profit_calculation_type[0]['mode'] == 1) + // { + // $temp_purchases = $overall_purchase_total; + // $temp_grossprofit = $total_sales_monthwise - $temp_purchases; + // $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total; + // $temp_netmargin = ($temp_netprofit/ ($total_sales_monthwise?$total_sales_monthwise:1) ) * 100; + // } + // else + // { + // $temp_grossprofit = $temp_netprofit ;//+ $overall_business_expenses_total; + // $temp_purchases = $total_sales_monthwise - $temp_grossprofit; + // $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total; + // //echo $temp_netprofit.'-'.$total_sales_monthwise;die(); + // $temp_netmargin = ($temp_netprofit/ ($total_sales_monthwise?$total_sales_monthwise:1) ) * 100; + // } - $overall_summary_report['sales_calculated_by_monthwise']['sales_revenue'] = round($total_sales_monthwise); - ($gross_profit_calculation_type[0]['mode'] == 1) ? $overall_summary_report['sales_calculated_by_monthwise']['purchases'] = round($temp_purchases) : $overall_summary_report['sales_calculated_by_monthwise']['cost_of_goods_sold'] = round($temp_purchases); - $overall_summary_report['sales_calculated_by_monthwise']['grossprofit'] = round($temp_grossprofit); - $overall_summary_report['sales_calculated_by_monthwise']['business_expenses'] = round($overall_business_expenses_total); - $overall_summary_report['sales_calculated_by_monthwise']['netprofit'] = round($temp_netprofit); - $overall_summary_report['sales_calculated_by_monthwise']['house_hold_expenses'] = round($overall_household_total); - $overall_summary_report['sales_calculated_by_monthwise']['disposable_income'] = round($temp_netprofit - $overall_household_total); - $overall_summary_report['sales_calculated_by_monthwise']['netmargin'] = round($temp_netmargin,2); + // $overall_summary_report['sales_calculated_by_monthwise']['sales_revenue'] = round($total_sales_monthwise); + // ($gross_profit_calculation_type[0]['mode'] == 1) ? $overall_summary_report['sales_calculated_by_monthwise']['purchases'] = round($temp_purchases) : $overall_summary_report['sales_calculated_by_monthwise']['cost_of_goods_sold'] = round($temp_purchases); + // $overall_summary_report['sales_calculated_by_monthwise']['grossprofit'] = round($temp_grossprofit); + // $overall_summary_report['sales_calculated_by_monthwise']['business_expenses'] = round($overall_business_expenses_total); + // $overall_summary_report['sales_calculated_by_monthwise']['netprofit'] = round($temp_netprofit); + // $overall_summary_report['sales_calculated_by_monthwise']['house_hold_expenses'] = round($overall_household_total); + // $overall_summary_report['sales_calculated_by_monthwise']['disposable_income'] = round($temp_netprofit - $overall_household_total); + // $overall_summary_report['sales_calculated_by_monthwise']['netmargin'] = round($temp_netmargin,2); - } + // } - if($sales_declared_by_customer_flag == 1) + if($sales_declared_by_customer_flag == 1 && $purchase_declared_by_customer_flag == 1) { $temp_purchases = 0; @@ -3875,11 +4073,12 @@ class PD_Controller extends REST_Controller { $temp_grossprofit = 0; $temp_netmargin = 0; $total_sales_declared_by_customer = $sales_declared_by_customer[0]['sales_declared_by_customer']; + $total_purchase_declared_by_customer = $purchase_declared_by_customer[0]['purchase_declared_by_customer']; $temp_netprofit = $sales_declared_by_customer[0]['margin_value']; if($gross_profit_calculation_type[0]['mode'] == 1) { - $temp_purchases = $overall_purchase_total; + $temp_purchases = $total_purchase_declared_by_customer; $temp_grossprofit = $total_sales_declared_by_customer - $temp_purchases; $temp_netprofit = $temp_grossprofit - $overall_business_expenses_total; $temp_netmargin = $total_sales_declared_by_customer > 0 ?($temp_netprofit/$total_sales_declared_by_customer) * 100 : 0; @@ -3906,14 +4105,14 @@ class PD_Controller extends REST_Controller { $temp_sales_array = array(); if(isset($overall_summary_report['sales_declared_by_customer']['sales_revenue'])){ $temp_sales_array = array_merge($temp_sales_array,array($overall_summary_report['sales_declared_by_customer']['sales_revenue'])); } - if(isset($overall_summary_report['sales_calculated_by_monthwise']['sales_revenue'])){ $temp_sales_array = array_merge($temp_sales_array,array($overall_summary_report['sales_calculated_by_monthwise']['sales_revenue'])); } + //if(isset($overall_summary_report['sales_calculated_by_monthwise']['sales_revenue'])){ $temp_sales_array = array_merge($temp_sales_array,array($overall_summary_report['sales_calculated_by_monthwise']['sales_revenue'])); } if(isset($overall_summary_report['sales_calculated_by_itemwise']['sales_revenue'])){ $temp_sales_array = array_merge($temp_sales_array,array($overall_summary_report['sales_calculated_by_itemwise']['sales_revenue'])); } $temp_netmargin_array = array(); if(isset($overall_summary_report['sales_declared_by_customer']['netprofit'])){ $temp_netmargin_array = array_merge($temp_netmargin_array,array($overall_summary_report['sales_declared_by_customer']['netprofit'])); } - if(isset($overall_summary_report['sales_calculated_by_monthwise']['netprofit'])){ $temp_netmargin_array = array_merge($temp_netmargin_array,array($overall_summary_report['sales_calculated_by_monthwise']['netprofit'])); } + //if(isset($overall_summary_report['sales_calculated_by_monthwise']['netprofit'])){ $temp_netmargin_array = array_merge($temp_netmargin_array,array($overall_summary_report['sales_calculated_by_monthwise']['netprofit'])); } if(isset($overall_summary_report['sales_calculated_by_itemwise']['netprofit'])){ $temp_netmargin_array = array_merge($temp_netmargin_array,array($overall_summary_report['sales_calculated_by_itemwise']['netprofit'])); } $overall_summary_report['consolidated_report']['consolidated_sales_revenue'] = round(array_sum($temp_sales_array) / count($temp_sales_array)); diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index f6baa0cf..bd019970 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -1458,11 +1458,18 @@ class PD_Model extends SPARQ_Model { /********************************* Assessd Income Sections *****************************************/ $assessed_income = array(); //echo "getAssessedIncome" ; + //get sales_declared_by_customer details $fields = array('sdc_id','sales_declared_by_customer','margin_per','margin_value','comments'); $where_condition_array = array('fk_pd_id'=>$pdid,'isactive'=>1); $where_condition_array['company_id'] = $company_id ? $company_id : null; $sales_declared_by_customer = $this->selectCustomRecords($fields,$where_condition_array,SALESDECLAREDBYCUSTOMER); + + //get sales_purchased_by_customer details + $fields = array('pdc_id','purchase_declared_by_customer','comments'); + $where_condition_array = array('fk_pd_id'=>$pdid,'isactive'=>1); + $where_condition_array['company_id'] = $company_id ? $company_id : null; + $purchase_declared_by_customer = $this->selectCustomRecords($fields,$where_condition_array,SALESDECLAREDBYCUSTOMER); //get Gross Profit calculatio Mode details $fields = array('calc_type_id','mode','margin','purchase_type'); @@ -1482,67 +1489,116 @@ class PD_Model extends SPARQ_Model { array('table'=>FREQUENCY.' as FREQUENCY','condition'=>'SALESCALCULATEDBYITEMWISE.fk_frequency_id = FREQUENCY.frequency_id','jointype'=>'INNER JOIN'), array('table'=>UOM.' as UOM','condition'=>'SALESCALCULATEDBYITEMWISE.fk_uom_id = UOM.uom_id','jointype'=>'LEFT')); $sales_calculated_by_itemwise = $this->getJoinRecords($fields,$table,$joins,$where_condition_array); + + if(count($sales_calculated_by_itemwise)) + { + foreach($sales_calculated_by_itemwise as $key => $item) + { + if($item['sales_type'] == 3) + { + $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('month(SALESITEMMONTHWISECHILD.sales_date)'); + $sales_items_by_month = $this->db->GET()->result_array(); + //print_r($this->db->last_query()); + //print_r($sales_items_by_month); + + if(count($sales_items_by_month)) + { + $sales_items_by_months = array(); + foreach($sales_items_by_month as $month_key => $month) + { + + $this->db->SELECT('simc_id,sales_date,sales_value,fk_frequency_id,frequency_value,FREQUENCY.name as frequency_name,FREQUENCY.mutiple_factor'); + $this->db->FROM(SALESITEMMONTHWISECHILD.' as SALESITEMMONTHWISECHILD'); + $this->db->WHERE('SALESITEMMONTHWISECHILD.fk_sim_id',$item['sim_id']); + $this->db->JOIN(FREQUENCY.' as FREQUENCY','SALESITEMMONTHWISECHILD.fk_frequency_id = FREQUENCY.frequency_id','LEFT'); + $this->db->WHERE('month(SALESITEMMONTHWISECHILD.sales_date)',$month['month']); + //$this->db->WHERE('year(SALESITEMMONTHWISECHILD.sales_date)',$month['year']); + $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($sales_items_by_month_child); + if(count($sales_items_by_month_child)) + { + foreach($sales_items_by_month_child as $t_key => $child_item) + { + $sales_items_by_month_child[$t_key]['row_index'] = $t_key + 1; + } + } + $sales_items_by_months[date("M-Y", strtotime($month['year'].'-'.$month['month']))] = $sales_items_by_month_child; + } + $sales_calculated_by_itemwise[$key]['items'] = $sales_items_by_months; + } + + }//print_r($sales_items_by_months); + } + + } + //print_r($this->db->last_query()); //get sales_items_by_monthwise details - $sales_items_by_months = array(); + // $sales_items_by_months = array(); - $this->db->SELECT('sim_id,sales_item,margin_value,margin_per,comments,sales_type,other_sales_item'); - $this->db->FROM(SALESITEMMONTHWISE.' as SALESITEMMONTHWISE'); - $this->db->WHERE('SALESITEMMONTHWISE.fk_pd_id',$pdid); - $this->db->WHERE('SALESITEMMONTHWISE.isactive',1); - if($company_id != null) - { - $this->db->WHERE('SALESITEMMONTHWISE.company_id',$company_id); - } - $sales_items_by_monthwise = $this->db->GET()->result_array(); - //print_r($sales_items_by_monthwise); - if(count($sales_items_by_monthwise)) - { - foreach($sales_items_by_monthwise as $key => $item) - { - $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('month(SALESITEMMONTHWISECHILD.sales_date)'); - $sales_items_by_month = $this->db->GET()->result_array(); - //print_r($this->db->last_query()); - //print_r($sales_items_by_month); + // $this->db->SELECT('sim_id,sales_item,margin_value,margin_per,comments,sales_type,other_sales_item'); + // $this->db->FROM(SALESITEMMONTHWISE.' as SALESITEMMONTHWISE'); + // $this->db->WHERE('SALESITEMMONTHWISE.fk_pd_id',$pdid); + // $this->db->WHERE('SALESITEMMONTHWISE.isactive',1); + // if($company_id != null) + // { + // $this->db->WHERE('SALESITEMMONTHWISE.company_id',$company_id); + // } + // $sales_items_by_monthwise = $this->db->GET()->result_array(); + // //print_r($sales_items_by_monthwise); + // if(count($sales_items_by_monthwise)) + // { + // foreach($sales_items_by_monthwise as $key => $item) + // { + // $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('month(SALESITEMMONTHWISECHILD.sales_date)'); + // $sales_items_by_month = $this->db->GET()->result_array(); + // //print_r($this->db->last_query()); + // //print_r($sales_items_by_month); - if(count($sales_items_by_month)) - { - $sales_items_by_months = array(); - foreach($sales_items_by_month as $month_key => $month) - { + // if(count($sales_items_by_month)) + // { + // $sales_items_by_months = array(); + // foreach($sales_items_by_month as $month_key => $month) + // { - $this->db->SELECT('simc_id,sales_date,sales_value,fk_frequency_id,frequency_value,FREQUENCY.name as frequency_name,FREQUENCY.mutiple_factor'); - $this->db->FROM(SALESITEMMONTHWISECHILD.' as SALESITEMMONTHWISECHILD'); - $this->db->WHERE('SALESITEMMONTHWISECHILD.fk_sim_id',$item['sim_id']); - $this->db->JOIN(FREQUENCY.' as FREQUENCY','SALESITEMMONTHWISECHILD.fk_frequency_id = FREQUENCY.frequency_id','LEFT'); - $this->db->WHERE('month(SALESITEMMONTHWISECHILD.sales_date)',$month['month']); - //$this->db->WHERE('year(SALESITEMMONTHWISECHILD.sales_date)',$month['year']); - $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($sales_items_by_month_child); - if(count($sales_items_by_month_child)) - { - foreach($sales_items_by_month_child as $t_key => $child_item) - { - $sales_items_by_month_child[$t_key]['row_index'] = $t_key + 1; - } - } - $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; - } + // $this->db->SELECT('simc_id,sales_date,sales_value,fk_frequency_id,frequency_value,FREQUENCY.name as frequency_name,FREQUENCY.mutiple_factor'); + // $this->db->FROM(SALESITEMMONTHWISECHILD.' as SALESITEMMONTHWISECHILD'); + // $this->db->WHERE('SALESITEMMONTHWISECHILD.fk_sim_id',$item['sim_id']); + // $this->db->JOIN(FREQUENCY.' as FREQUENCY','SALESITEMMONTHWISECHILD.fk_frequency_id = FREQUENCY.frequency_id','LEFT'); + // $this->db->WHERE('month(SALESITEMMONTHWISECHILD.sales_date)',$month['month']); + // //$this->db->WHERE('year(SALESITEMMONTHWISECHILD.sales_date)',$month['year']); + // $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($sales_items_by_month_child); + // if(count($sales_items_by_month_child)) + // { + // foreach($sales_items_by_month_child as $t_key => $child_item) + // { + // $sales_items_by_month_child[$t_key]['row_index'] = $t_key + 1; + // } + // } + // $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); - } + // //print_r($sales_items_by_months); + // } - } + // } @@ -1559,66 +1615,108 @@ class PD_Model extends SPARQ_Model { array('table'=>FREQUENCY.' as FREQUENCY','condition'=>'PDPURCHASEDETAILS.fk_frequency_id = FREQUENCY.frequency_id','jointype'=>'LEFT'), array('table'=>UOM.' as UOM','condition'=>'PDPURCHASEDETAILS.fk_uom_id = UOM.uom_id','jointype'=>'LEFT')); $purchase_details = $this->getJoinRecords($fields,$table,$joins,$where_condition_array); - // print_r($this->db->last_query()); - // print_r($purchase_details);die(); + + if(count($purchase_details)) + { + foreach($purchase_details as $purchase_billwise_parent_key => $billwise) + { + $this->db->SELECT('month(purchase_date) as month,year(purchase_date) as year'); + $this->db->FROM(PDPURCHASEBILLWISECHILD.' as PDPURCHASEBILLWISECHILD'); + $this->db->WHERE('PDPURCHASEBILLWISECHILD.fk_pbw_id',$billwise['pbw_id']); + $this->db->WHERE('PDPURCHASEBILLWISECHILD.isactive',1); + $this->db->GROUP_BY('month(PDPURCHASEBILLWISECHILD.purchase_date)'); + $purchase_billwise_child_group = $this->db->GET()->result_array(); + //print_r($purchase_billwise_child_group); + + if(count($purchase_billwise_child_group)) + { + $purchase_billwise_data = array(); + foreach($purchase_billwise_child_group as $billwise_child_key => $child) + { + + $this->db->SELECT('pbwc_id,purchase_date,purchase_value,'); + $this->db->FROM(PDPURCHASEBILLWISECHILD.' as PDPURCHASEBILLWISECHILD'); + $this->db->WHERE('PDPURCHASEBILLWISECHILD.fk_pbw_id',$billwise['pbw_id']); + + $this->db->WHERE('month(PDPURCHASEBILLWISECHILD.purchase_date)',$child['month']); + $this->db->WHERE('PDPURCHASEBILLWISECHILD.isactive',1); + //$this->db->GROUP_BY('month(SALESITEMMONTHWISECHILD.sales_date)'); + $purchase_billwise_child = $this->db->GET()->result_array(); + if(count($purchase_billwise_child)) + { + foreach($purchase_billwise_child as $t_key => $child_item) + { + $purchase_billwise_child[$t_key]['row_index'] = $t_key + 1; + } + } + $purchase_billwise_data[$billwise_child_key][date("M-Y", strtotime($child['year'].'-'.$child['month']))] = $purchase_billwise_child; + } + $purchase_details[$purchase_billwise_parent_key]['items'] = $purchase_billwise_data; + } + + //print_r($sales_items_by_months); + } + + + } //get purchase bill details - $purchase_billwise_parent = array(); + // $purchase_billwise_parent = array(); - $this->db->SELECT('pbw_id,purchase_item,annual_purchase_value,comments,other_purchase_item'); - $this->db->FROM(PDPURCHASEBILLWISE.' as PDPURCHASEBILLWISE'); - $this->db->WHERE('PDPURCHASEBILLWISE.fk_pd_id',$pdid); - $this->db->WHERE('PDPURCHASEBILLWISE.isactive',1); - if($company_id != null) - { - $this->db->WHERE('PDPURCHASEBILLWISE.company_id',$company_id); - } - $purchase_billwise_parent = $this->db->GET()->result_array(); - //print_r($purchase_billwise_parent); - if(count($purchase_billwise_parent)) - { - foreach($purchase_billwise_parent as $purchase_billwise_parent_key => $billwise) - { - $this->db->SELECT('month(purchase_date) as month,year(purchase_date) as year'); - $this->db->FROM(PDPURCHASEBILLWISECHILD.' as PDPURCHASEBILLWISECHILD'); - $this->db->WHERE('PDPURCHASEBILLWISECHILD.fk_pbw_id',$billwise['pbw_id']); - $this->db->WHERE('PDPURCHASEBILLWISECHILD.isactive',1); - $this->db->GROUP_BY('month(PDPURCHASEBILLWISECHILD.purchase_date)'); - $purchase_billwise_child_group = $this->db->GET()->result_array(); - //print_r($purchase_billwise_child_group); + // $this->db->SELECT('pbw_id,purchase_item,annual_purchase_value,comments,other_purchase_item'); + // $this->db->FROM(PDPURCHASEBILLWISE.' as PDPURCHASEBILLWISE'); + // $this->db->WHERE('PDPURCHASEBILLWISE.fk_pd_id',$pdid); + // $this->db->WHERE('PDPURCHASEBILLWISE.isactive',1); + // if($company_id != null) + // { + // $this->db->WHERE('PDPURCHASEBILLWISE.company_id',$company_id); + // } + // $purchase_billwise_parent = $this->db->GET()->result_array(); + // //print_r($purchase_billwise_parent); + // if(count($purchase_billwise_parent)) + // { + // foreach($purchase_billwise_parent as $purchase_billwise_parent_key => $billwise) + // { + // $this->db->SELECT('month(purchase_date) as month,year(purchase_date) as year'); + // $this->db->FROM(PDPURCHASEBILLWISECHILD.' as PDPURCHASEBILLWISECHILD'); + // $this->db->WHERE('PDPURCHASEBILLWISECHILD.fk_pbw_id',$billwise['pbw_id']); + // $this->db->WHERE('PDPURCHASEBILLWISECHILD.isactive',1); + // $this->db->GROUP_BY('month(PDPURCHASEBILLWISECHILD.purchase_date)'); + // $purchase_billwise_child_group = $this->db->GET()->result_array(); + // //print_r($purchase_billwise_child_group); - if(count($purchase_billwise_child_group)) - { - $purchase_billwise_data = array(); - foreach($purchase_billwise_child_group as $billwise_child_key => $child) - { + // if(count($purchase_billwise_child_group)) + // { + // $purchase_billwise_data = array(); + // foreach($purchase_billwise_child_group as $billwise_child_key => $child) + // { - $this->db->SELECT('pbwc_id,purchase_date,purchase_value,'); - $this->db->FROM(PDPURCHASEBILLWISECHILD.' as PDPURCHASEBILLWISECHILD'); - $this->db->WHERE('PDPURCHASEBILLWISECHILD.fk_pbw_id',$billwise['pbw_id']); + // $this->db->SELECT('pbwc_id,purchase_date,purchase_value,'); + // $this->db->FROM(PDPURCHASEBILLWISECHILD.' as PDPURCHASEBILLWISECHILD'); + // $this->db->WHERE('PDPURCHASEBILLWISECHILD.fk_pbw_id',$billwise['pbw_id']); - $this->db->WHERE('month(PDPURCHASEBILLWISECHILD.purchase_date)',$child['month']); - $this->db->WHERE('PDPURCHASEBILLWISECHILD.isactive',1); - //$this->db->GROUP_BY('month(SALESITEMMONTHWISECHILD.sales_date)'); - $purchase_billwise_child = $this->db->GET()->result_array(); - if(count($purchase_billwise_child)) - { - foreach($purchase_billwise_child as $t_key => $child_item) - { - $purchase_billwise_child[$t_key]['row_index'] = $t_key + 1; - } - } - $purchase_billwise_data[$billwise_child_key][date("M-Y", strtotime($child['year'].'-'.$child['month']))] = $purchase_billwise_child; - } - $purchase_billwise_parent[$purchase_billwise_parent_key]['items'] = $purchase_billwise_data; - } + // $this->db->WHERE('month(PDPURCHASEBILLWISECHILD.purchase_date)',$child['month']); + // $this->db->WHERE('PDPURCHASEBILLWISECHILD.isactive',1); + // //$this->db->GROUP_BY('month(SALESITEMMONTHWISECHILD.sales_date)'); + // $purchase_billwise_child = $this->db->GET()->result_array(); + // if(count($purchase_billwise_child)) + // { + // foreach($purchase_billwise_child as $t_key => $child_item) + // { + // $purchase_billwise_child[$t_key]['row_index'] = $t_key + 1; + // } + // } + // $purchase_billwise_data[$billwise_child_key][date("M-Y", strtotime($child['year'].'-'.$child['month']))] = $purchase_billwise_child; + // } + // $purchase_billwise_parent[$purchase_billwise_parent_key]['items'] = $purchase_billwise_data; + // } - //print_r($sales_items_by_months); - } + // //print_r($sales_items_by_months); + // } - } + // } //echo "*****************************************"; //print_r($purchase_billwise_parent);die(); @@ -1656,7 +1754,7 @@ class PD_Model extends SPARQ_Model { /*********************************End of Assessd Income Sections *****************************************/ - $assessed_income= array('sales_declared_by_customer'=>$sales_declared_by_customer,'sales_calculated_by_itemwise'=>$sales_calculated_by_itemwise,'sales_items_by_monthwise'=>$sales_items_by_monthwise,'purchase_details'=>$purchase_details,'purchase_billwise' => $purchase_billwise_parent,'business_expenses'=>$business_expenses,'house_hold_expenses'=>$house_hold_expenses,'gross_profit_calculation_type' => $gross_profit_calculation_type,'othre_business_income' => $other_business_income); + $assessed_income= array('sales_declared_by_customer'=>$sales_declared_by_customer,'sales_calculated_by_itemwise'=>$sales_calculated_by_itemwise,'purchase_details'=>$purchase_details,'purchase_declared_by_customer' => $purchase_declared_by_customer,'business_expenses'=>$business_expenses,'house_hold_expenses'=>$house_hold_expenses,'gross_profit_calculation_type' => $gross_profit_calculation_type,'othre_business_income' => $other_business_income); return $assessed_income; }