From 8f2667322a7f097b9558e5ab06101550c873a4e5 Mon Sep 17 00:00:00 2001 From: velz Date: Wed, 28 Nov 2018 18:51:25 +0530 Subject: [PATCH] GET QUES KEY CHANGED --- api/application/config/constants.php | 4 +- api/application/controllers/PD_Controller.php | 14 ++- .../Template_Management_Controller.php | 117 ++++++++++++++---- api/application/models/PD_Model.php | 7 +- 4 files changed, 116 insertions(+), 26 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index e64e0c30..59dd4da5 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', 'calculateAssessedIncome'); // no errors +defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'getFormAndQuestionKeys'); // no errors /*********************AWS resources Constants*************************************************/ defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic'); @@ -377,7 +377,7 @@ defined('SOURCEOFBALANCETRANSFER') OR define('SOURCEOFBALANCETRANSFER','m_source defined('STATUSOFCONSTRUCTION') OR define('STATUSOFCONSTRUCTION','m_status_of_construction'); -// Assessed Income related Tables +// Assessed Income related Tables Not added in test DB defined('SALESDECLAREDBYCUSTOMER') OR define('SALESDECLAREDBYCUSTOMER','t_pd_sales_declared_by_customer'); defined('SALESDECLAREDBYCUSTOMERID') OR define('SALESDECLAREDBYCUSTOMERID','sdc_id'); diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index f009a9bf..7d982202 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -2191,7 +2191,7 @@ class PD_Controller extends REST_Controller { $purchases = $result_array['purchase_details']; $business_expenses = $result_array['business_expenses']; $household_expenses = $result_array['house_hold_expenses']; - + $gross_profit_calculation_type = $result_array['gross_profit_calculation_type']; 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;} @@ -2281,6 +2281,18 @@ class PD_Controller extends REST_Controller { // echo "\n\n".$final_revenue; + /**************************Gross Profit calculation start***************/ + print_r($gross_profit_calculation_type); + if($gross_profit_calculation_type[0]['mode'] == 1) + { + //calculate overall purchase + } + else + { + + } + /**************************Gross Profit calculation end***************/ + } else diff --git a/api/application/controllers/Template_Management_Controller.php b/api/application/controllers/Template_Management_Controller.php index 751e6ee1..e001578a 100644 --- a/api/application/controllers/Template_Management_Controller.php +++ b/api/application/controllers/Template_Management_Controller.php @@ -534,34 +534,109 @@ class Template_Management_Controller extends REST_Controller { $master_tables_pkid = array('INDUSTRYCLASSIFICATION' => 'industry_classification_id','UOM' => 'uom_id','OCCUPATIONMEMBERS' => 'occupation_non_earning_member_id','EDUQUALIFICATION' => 'qualification_name', 'TYPEOFACTIVITY' => 'type_of_activity_id','RELATIONSHIPS' => 'relationship_id','FREQUENCY' => 'frequency_id', 'CUSTOMERBEHAVIOUR' => 'customer_behaviour_id', 'CUSTOMERSEGMENT' => 'customer_segment_id','DESIGNATION' => 'designation_id', 'EARNINGMEMBERSSTATUS' => 'earning_member_status_id','EDUQUALIFICATION' => 'qualification_id','ADDRESSTYPE' => 'address_type_id','LOCALITY' => 'locality_id','ASSETTYPE' => 'id','PROPERTIES' => 'id','INVESTMENTTYPE' => 'id','INSURANCETYPE' => 'id','PERSONSMET' => 'person_met_id','RESIDENCEOWNERSHIP' => 'id','PAYMENTMODE' => 'id','ACCOUNTTYPE' => 'id','SOURCEOFOTHERINCOME' => 'id','MORTAGEPROPERTYTYPE' => 'id','ENDUSEOFLOAN' => 'id','SOURCEOFBALANCETRANSFER' => 'id', 'STATUSOFCONSTRUCTION' => 'id'); //*******************INTERNAL PURPOSE*************************************************** - $fields = array('fk_form_id','question','key','ismaster','master_name'); - $where_condition_array = array(); - if($formid != "") + //get Alreday assigned ques and kys from template + $fields = array('fk_key'); + $where_condition_array = array('fk_template_id' =>$templateid,'isactive' => 1,'fk_form_id' =>$formid ); + $exits_questions = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,SCORECARDQUESTIONS); + $result_data = array(); + //print_r(); + if(!count($exits_questions)) { - $where_condition_array = array('isactive' => 1,'fk_form_id' => $formid); - } - else - { - $where_condition_array = array('isactive' => 1); - } - $result_data = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,QUESTIONKEYMAPPING); - - if(count($result_data)) - { - foreach($result_data as $res_key => $result) + + $fields = array('fk_form_id','question','key','ismaster','master_name'); + $where_condition_array = array(); + if($formid != 0) { - if($result['master_name'] != null || $result['master_name'] != "") + $where_condition_array = array('isactive' => 1,'fk_form_id' => $formid); + } + else + { + $where_condition_array = array('isactive' => 1); + } + $result_data = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,QUESTIONKEYMAPPING); + + if(count($result_data)) + { + foreach($result_data as $res_key => $result) { - //echo $result['master_name']; - $fields = array($master_tables_pkid[$result['master_name']].' as id',$master_tables_field_names[$result['master_name']].' as name'); - $table = constant($result['master_name']); - $where_condition_array = array('isactive' => 1); - $answers = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,$table); - $result_data[$res_key]['answers'] = $answers; + $result_data[$res_key]['score_question_id'] = null; + $result_data[$res_key]['fk_template_id'] = null; + $result_data[$res_key]['fk_key'] = null; + $result_data[$res_key]['weightage'] = null; + $result_data[$res_key]['calc_type'] = null; + if($result['master_name'] != null || $result['master_name'] != "") + { + //echo $result['master_name']; + $fields = array($master_tables_pkid[$result['master_name']].' as id',$master_tables_field_names[$result['master_name']].' as name'); + + $table = constant($result['master_name']); + $where_condition_array = array('isactive' => 1); + $answers = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,$table); + foreach($answers as $answer_key => $answer) + { + $answers[$answer_key]['answer'] = null; + $answers[$answer_key]['fk_score_question_id'] = null; + $answers[$answer_key]['score'] = null; + $answers[$answer_key]['score_answer_id'] = null; + } + $result_data[$res_key]['answers'] = $answers; + } } } } + else + { + + $temp_array = array(); + foreach($exits_questions as $res) + { + array_push($temp_array,$res['fk_key']); + } + //print_r($temp_array); + $this->db->SELECT('QUESTIONKEYMAPPING.fk_form_id,QUESTIONKEYMAPPING.question,QUESTIONKEYMAPPING.key,QUESTIONKEYMAPPING.master_name,SCORECARDQUESTIONS.score_question_id,SCORECARDQUESTIONS.fk_template_id,SCORECARDQUESTIONS.fk_form_id,SCORECARDQUESTIONS.fk_key,SCORECARDQUESTIONS.weightage,SCORECARDQUESTIONS.calc_type'); + $this->db->FROM(QUESTIONKEYMAPPING.' as QUESTIONKEYMAPPING'); + $this->db->JOIN(SCORECARDQUESTIONS.' as SCORECARDQUESTIONS','QUESTIONKEYMAPPING.fk_form_id = SCORECARDQUESTIONS.fk_form_id AND QUESTIONKEYMAPPING.key = SCORECARDQUESTIONS.fk_key AND SCORECARDQUESTIONS.isactive = 1','LEFT'); + + if($formid != 0) + { + $this->db->WHERE('QUESTIONKEYMAPPING.fk_form_id',$formid); + } + $this->db->WHERE_NOT_IN('QUESTIONKEYMAPPING.key',$temp_array); + $this->db->WHERE('QUESTIONKEYMAPPING.isactive',1); + //$this->db->WHERE('SCORECARDQUESTIONS.isactive',1); + + $result_data = $this->db->GET()->result_array(); + if(count($result_data)) + { + foreach($result_data as $res_key => $result) + { + if($result['master_name'] != null || $result['master_name'] != "") + { + //echo $result['master_name']; + $fields = array($master_tables_pkid[$result['master_name']].' as id',$master_tables_field_names[$result['master_name']].' as name'); + + $table = constant($result['master_name']); + $where_condition_array = array('isactive' => 1); + $answers = $this->Template_Management_Model->selectCustomRecords($fields,$where_condition_array,$table); + foreach($answers as $answer_key => $answer) + { + $answers[$answer_key]['answer'] = null; + $answers[$answer_key]['fk_score_question_id'] = null; + $answers[$answer_key]['score'] = null; + $answers[$answer_key]['score_answer_id'] = null; + } + $result_data[$res_key]['answers'] = $answers; + } + } + } + + + + + + } + if(count($result_data)) { $data['dataStatus'] = true; diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index f1d37985..a86fa4e8 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -823,7 +823,10 @@ class PD_Model extends SPARQ_Model { $fields = array('sdc_id','sales_declared_by_customer'); $where_condition_array = array('fk_pd_id'=>$pdid,'isactive'=>1); $sales_declared_by_customer = $this->selectCustomRecords($fields,$where_condition_array,SALESDECLAREDBYCUSTOMER); - + //get Gross Profit calculatio Mode details + $fields = array('calc_type_id','mode','margin'); + $where_condition_array = array('fk_pd_id'=>$pdid); + $gross_profit_calculation_type = $this->selectCustomRecords($fields,$where_condition_array,PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE); //get sales_calculated_by_itemwise details $fields = array('sci_id','sales_item','sales_qty','UOM.name as uom_name','fk_uom_id','FREQUENCY.name as frequency_name','rate_per_unit','fk_frequency_id','annual_sale_value'); @@ -921,7 +924,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,'business_expenses'=>$business_expenses,'house_hold_expenses'=>$house_hold_expenses); + $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,'business_expenses'=>$business_expenses,'house_hold_expenses'=>$house_hold_expenses,'gross_profit_calculation_type' => $gross_profit_calculation_type); return $assessed_income; }