diff --git a/api/application/config/api_user_auth_config.php b/api/application/config/api_user_auth_config.php
new file mode 100644
index 00000000..ddf91640
--- /dev/null
+++ b/api/application/config/api_user_auth_config.php
@@ -0,0 +1,58 @@
+ array('role_name' => 'Central Manager','allowed_api_routes' => array()),
+'2' => array('role_name' => 'Central PD Officer','allowed_api_routes' => array())
+'3' => array('role_name' => 'PD Manager','allowed_api_routes' => array())
+'4' => array('role_name' => 'PD Executive','allowed_api_routes' => array())
+'5' => array('role_name' => 'PD Officer','allowed_api_routes' => array())
+'6' => array('role_name' => 'QC Manager','allowed_api_routes' => array())
+'7' => array('role_name' => 'QC Officer','allowed_api_routes' => array())
+'8' => array('role_name' => 'Billing Manager','allowed_api_routes' => array())
+'9' => array('role_name' => 'Billing Staff','allowed_api_routes' => array())
+'10' => array('role_name' => 'System Admin','allowed_api_routes' => array())
+'11' => array('role_name' => 'National Sales Head','allowed_api_routes' => array())
+'12' => array('role_name' => 'National Credit Head','allowed_api_routes' => array())
+'13' => array('role_name' => 'Zonal Sales Head','allowed_api_routes' => array())
+'14' => array('role_name' => 'Zonal Credit Head','allowed_api_routes' => array())
+'15' => array('role_name' => 'Area Sales Head','allowed_api_routes' => array())
+'16' => array('role_name' => 'Area Credit Head','allowed_api_routes' => array())
+'17' => array('role_name' => 'City Sales Head','allowed_api_routes' => array())
+'18' => array('role_name' => 'City Credit Head','allowed_api_routes' => array())
+'19' => array('role_name' => 'Branch Sales','allowed_api_routes' => array())
+'20' => array('role_name' => 'Branch Credit','allowed_api_routes' => array())
+'21' => array('role_name' => 'PD Manager Vendor','allowed_api_routes' => array())
+'22' => array('role_name' => 'PD Officer Vendor','allowed_api_routes' => array())
+
+);
+
+$api_user_auth_info = array(
+
+'saveNewUser' => array(10),
+'updateExistUser' => array(10),//doubt
+'getUsersDetails' => array(),
+//PD RELATED
+'triggerNewPD' = array(),
+'updatePDMaster' = array(),
+'(listLessPDDetails/:any)' = array(),
+'updatePDDocs' = array(),
+'updatePDApplicants' = array(),
+'allocatePD' = array(),
+'schdulePD' = array(),
+'getListPDOfficers' = array(),
+'loadFullTemplate' = array(),
+'generatePDReport' = array(),
+'savePDPhotos' = array(),
+'savePDFormDetails' = array(),
+//ENTITY
+'saveNewEntity' = array(),
+
+
+);
+
+?>
\ No newline at end of file
diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php
index 42821c68..59778f65 100644
--- a/api/application/controllers/PD_Controller.php
+++ b/api/application/controllers/PD_Controller.php
@@ -21,14 +21,14 @@ class PD_Controller extends REST_Controller {
{
// Construct the parent class
parent::__construct();
- $this->load->model('PD_Model');
+ $this->load->model('PD_Model');
$this->load->library('AWS_S3');
$this->load->library('AWS_SNS');
$this->load->helper('GETPDFORMDETAILS');
$this->load->helper('GETPROCESSEDJSON');
$this->load->helper('MYUTIL');
- $this->load->library('pdfgenerator');
- $this->load->library('excel');
+ $this->load->library('pdfgenerator');
+ //$this->load->library('excel');
$this->load->library('phpmailer_library');
}
@@ -434,6 +434,7 @@ class PD_Controller extends REST_Controller {
//die();
+ $pd_details['parent_pd_id'] = isset($pd_details['parent_pd_id']) ? $pd_details['parent_pd_id'] : NULL;
$pd_id = $this->PD_Model->saveRecords($pd_details,PDTRIGGER);
@@ -546,13 +547,28 @@ class PD_Controller extends REST_Controller {
if(count($addresses))
{
-
+ $temp_address_id = 0;
foreach($addresses as $address_key => $address)
{
$address['fk_pd_id'] = $pd_id;
$address['is_primary'] = count($addresses) == 1 ? 1:0;
- $this->PD_Model->saveRecords($address,PDADDRESS);
+ $address_id = $this->PD_Model->saveRecords($address,PDADDRESS);
+ if($address_key == 0)
+ {
+ $temp_address_id = $address_id;
+ }
}
+
+ $temp = array('parent_pd_id' => $pd_id);
+ if(count($addresses) == 1)
+ {
+ $temp['fk_primary_address_id'] = $temp_address_id;
+ $temp['fk_address_id'] = $temp_address_id;
+ }
+ $where_condition_array = array('pd_id' => $pd_id);
+ $this->PD_Model->updateRecords($temp,PDTRIGGER,$where_condition_array);
+
+
}
if(count($company))
@@ -697,11 +713,39 @@ class PD_Controller extends REST_Controller {
if(isset($pd_details['pd_status']) && $pd_details['pd_status'] == COMPLETED)
{
+ //echo "completed";
if(array_key_exists('link',$pd_details))
{
- $pd_details['complete_location'] = $pd_details['link'];
- unset($pd_details['link']);
+ $pd_details['complete_location'] = $pd_details['link'];
+ unset($pd_details['link']);
}
+
+ //If it is Addtional PD ,then update 'COMPLETE' status for primary and all other addtional PD's
+ if($exist_pd_details[0]['is_child'] == 1)
+ {
+ //echo "child";
+ $all_pd_id = array();
+ //get all associated PD ID's from address table
+ $all_associated_addresses = $this->PD_Model->getPDAddress($exist_pd_details[0]['parent_pd_id']);
+ //print_r($all_associated_addresses);
+ if(count($all_associated_addresses))
+ {
+ foreach($all_associated_addresses as $address)
+ {
+ if($address['assigned_pd'] != $pd_details['pd_id'])
+ {
+ $all_pd_id[] = array('pd_id' => $address['assigned_pd'],'pd_status' => COMPLETED, 'fk_updatedby' => $pd_details['fk_updatedby']);
+ }
+ }
+ }
+ //print_r($all_pd_id);
+ foreach($all_pd_id as $single_pd)
+ {
+ $this->PD_Model->updateRecords($single_pd,PDTRIGGER,array('pd_id' => $single_pd['pd_id']));
+ }
+
+ }
+
}
@@ -735,7 +779,7 @@ class PD_Controller extends REST_Controller {
// {
// $pd_details['parent_pd_id'] = isset($pd_details['parent_pd_id']) ? $pd_details['parent_pd_id'] : null;
// }
- if( $exist_pd_details[0]['is_child'] == 0 && $exist_pd_details[0]['parent_pd_id'] == null)
+ if( $exist_pd_details[0]['is_child'] == 0 && ($exist_pd_details[0]['parent_pd_id'] == null || $exist_pd_details[0]['parent_pd_id'] == 0))
{
$pd_details['parent_pd_id'] = $pd_details['pd_id'];
}
@@ -774,7 +818,7 @@ class PD_Controller extends REST_Controller {
}//end of normal PD
else//#################### Handle Addtional PD
{
-
+ //echo 'else';
if(($pd_details['parent_pd_id'] != "" || $pd_details['parent_pd_id'] != null) &&
(($pd_details['fk_customer_segment'] != "" || $pd_details['fk_customer_segment'] != null)) &&
(($pd_details['fk_address_id'] != "" || $pd_details['fk_address_id'] != null)) &&
@@ -783,10 +827,11 @@ class PD_Controller extends REST_Controller {
{
//GET PArent PD Details
$parent_pd_details = $this->PD_Model->getPDMasterDetails($pd_details['parent_pd_id']);
+ //echo date_format(date_create($parent_pd_details[0]['pd_date_of_initiation']),'Y-m-d');die();
if(count($parent_pd_details))
{
$newpd['fk_lender_id'] = $parent_pd_details[0]['fk_lender_id'];
- $newpd['pd_date_of_initiation'] = $parent_pd_details[0]['pd_date_of_initiation'];
+ $newpd['pd_date_of_initiation'] = date_format(date_create($parent_pd_details[0]['pd_date_of_initiation']),'Y-m-d');
$newpd['fk_entity_billing_id'] = $parent_pd_details[0]['fk_entity_billing_id'];
$newpd['lender_applicant_id'] = $parent_pd_details[0]['lender_applicant_id'];
$newpd['fk_product_id'] = $parent_pd_details[0]['fk_product_id'];
@@ -802,7 +847,7 @@ class PD_Controller extends REST_Controller {
$newpd['parent_pd_id'] = $pd_details['parent_pd_id'];
//$newpd['fk_pd_allocated_to'] = $pd_details['fk_pd_allocated_to'] ? $pd_details['fk_pd_allocated_to'] : null;
//$newpd['scheduled_on'] = $pd_details['scheduled_on'] ? $pd_details['scheduled_on'] : null;
-
+ //print_r($newpd);//die();
$newpd['fk_pd_template_id'] = $this->assignPDTempalate(array('lender' => $newpd['fk_lender_id'],'product' => $newpd['fk_product_id'],'customer_segment' => $newpd['fk_customer_segment']));
@@ -982,7 +1027,11 @@ class PD_Controller extends REST_Controller {
$count = 0;
foreach($records as $key => $value)
{
- $value['is_primary'] = count($records) == 1 ? 1:0;
+ if(count($records) == 1)
+ {
+ $value['is_primary'] = 1;
+ }
+
if($value['pd_address_id'] != "" || $value['pd_address_id'] != null)
{
$where_condition_array = array('pd_address_id' => $value['pd_address_id']);
@@ -3295,21 +3344,22 @@ class PD_Controller extends REST_Controller {
if($purchases_flag != 0)
{
- if($gross_profit_calculation_type[0]['purchase_type'] == 1)
+ if($gross_profit_calculation_type[0]['mode'] == 1 && $gross_profit_calculation_type[0]['purchase_type'] == 1)//purchase item wise
{
- foreach($purchase_billwise as $purchase_billwise_key => $bill)
- {
- $overall_purchase_total = $overall_purchase_total + $bill['annual_purchase_value'];
- }
-
- }
- else
- {
- foreach($purchases as $purchase_key => $purchase)
+ foreach($purchases as $purchase_key => $purchase)
{
$overall_purchase_total = $overall_purchase_total + $purchase['annual_purchase_value'];
}
}
+ 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)
+ {
+
+ $overall_purchase_total = $overall_purchase_total + ($bill['annual_purchase_value'] * (12/ count($bill['items'])) );
+ }
+ }
}
@@ -3327,7 +3377,7 @@ class PD_Controller extends REST_Controller {
}
//calculatin part
- if($purchases_flag != 0)
+ if($gross_profit_calculation_type[0]['mode'] == 1)
{
$temp_purchases = $overall_purchase_total;
$temp_grossprofit = $total_sales_itemwise - $temp_purchases;
@@ -3345,7 +3395,7 @@ class PD_Controller extends REST_Controller {
}
$overall_summary_report['sales_calculated_by_itemwise']['sales_revenue'] = round($total_sales_itemwise);
- $purchases_flag ? $overall_summary_report['sales_calculated_by_itemwise']['purchases'] = round($temp_purchases,2) : $overall_summary_report['sales_calculated_by_itemwise']['cost_of_goods_sold'] = round($temp_purchases);
+ ($gross_profit_calculation_type[0]['mode'] == 1) ? $overall_summary_report['sales_calculated_by_itemwise']['purchases'] = round($temp_purchases,2) : $overall_summary_report['sales_calculated_by_itemwise']['cost_of_goods_sold'] = round($temp_purchases);
$overall_summary_report['sales_calculated_by_itemwise']['grossprofit'] = round($temp_grossprofit);
$overall_summary_report['sales_calculated_by_itemwise']['business_expenses'] = round($overall_business_expenses_total);
$overall_summary_report['sales_calculated_by_itemwise']['netprofit'] = round($temp_netprofit);
@@ -3398,7 +3448,7 @@ class PD_Controller extends REST_Controller {
//calculation part
//calculatin part
- if($purchases_flag != 0)
+ if($gross_profit_calculation_type[0]['mode'] == 1)
{
$temp_purchases = $overall_purchase_total;
$temp_grossprofit = $total_sales_monthwise - $temp_purchases;
@@ -3414,7 +3464,7 @@ class PD_Controller extends REST_Controller {
}
$overall_summary_report['sales_calculated_by_monthwise']['sales_revenue'] = round($total_sales_monthwise);
- $purchases_flag ? $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);
+ ($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);
@@ -3437,7 +3487,7 @@ class PD_Controller extends REST_Controller {
$total_sales_declared_by_customer = $sales_declared_by_customer[0]['sales_declared_by_customer'];
$temp_netprofit = $sales_declared_by_customer[0]['margin_value'];
- if($purchases_flag != 0)
+ if($gross_profit_calculation_type[0]['mode'] == 1)
{
$temp_purchases = $overall_purchase_total;
$temp_grossprofit = $total_sales_declared_by_customer - $temp_purchases;
@@ -3453,7 +3503,7 @@ class PD_Controller extends REST_Controller {
$overall_summary_report['sales_declared_by_customer']['sales_revenue'] = round($total_sales_declared_by_customer);
- $purchases_flag ? $overall_summary_report['sales_declared_by_customer']['purchases'] = round($temp_purchases) : $overall_summary_report['sales_declared_by_customer']['cost_of_goods_sold'] = round($temp_purchases);
+ ($gross_profit_calculation_type[0]['mode'] == 1) ? $overall_summary_report['sales_declared_by_customer']['purchases'] = round($temp_purchases) : $overall_summary_report['sales_declared_by_customer']['cost_of_goods_sold'] = round($temp_purchases);
$overall_summary_report['sales_declared_by_customer']['grossprofit'] = round($temp_grossprofit);
$overall_summary_report['sales_declared_by_customer']['business_expenses'] = round($overall_business_expenses_total);
$overall_summary_report['sales_declared_by_customer']['netprofit'] = round($temp_netprofit);
@@ -4334,8 +4384,8 @@ class PD_Controller extends REST_Controller {
public function codeigniterViewTest_post()
{
- echo MYUTIL::customIndianNumberFormat(4589621);
- die();
+ // echo MYUTIL::customIndianNumberFormat(4589621);
+ // die();
$records = $this->post('records');
$pdid = $records['pd_id'];
$is_regenerate = 0;
@@ -4349,7 +4399,7 @@ class PD_Controller extends REST_Controller {
$data['pd_additional_requirements'] = $this->PD_Model->getPDAdditionalRequirements($pdid);
$data['score_questions_display'] = $this->PD_Model->getScoreableQuestionToDispaly();
$data['pd_score'] = $this->calculateScore($pdid);
- //print_r($data['pd_score']['business']);
+ //print_r($data['pd_score']['business']);//die();
$score_for_chart = $data['pd_score']['score_summary']['overall_score']['final_score'] ? round($data['pd_score']['score_summary']['overall_score']['final_score'],2) : 0;
//echo $score_for_chart;
$chart = null;
@@ -4831,7 +4881,7 @@ class PD_Controller extends REST_Controller {
if(count($general_data))
{
$json = json_decode($general_data[0]['json'],true);
- //print_r($json);
+ //print_r($json);die();
if(array_key_exists('persons_with_relationships',$json))
{
@@ -4839,10 +4889,16 @@ class PD_Controller extends REST_Controller {
{
foreach($json['individuals'] as $ind)
{
- if($relation['pd_co_applicant_id'] == $ind['pd_co_applicant_id'])
+ // if($relation['pd_co_applicant_id'] == $ind['pd_co_applicant_id'])
+ // {
+ // $relation['age'] = $ind['age'];
+ // }
+ //else
+ if($relation['applicant_name'] == $ind['applicant_name'])
{
$relation['age'] = $ind['age'];
- }
+ }
+
}
$temp_array = array_merge($temp_array,array($relation));
}
@@ -5553,7 +5609,7 @@ class PD_Controller extends REST_Controller {
#####Business Form Questions########
$business_form = (json_decode($form_data[13][0]['processed_json'],true));
- //print_r($business_form);die();
+ //print_r($business_form);
// 10 - QNO(1.6) - was_the_company_name_board_sighted
$score_questions['general']['was_the_company_name_board_sighted'] = isset($business_form['was_the_company_name_board_sighted']) ? $business_form['was_the_company_name_board_sighted'] : 'No';
diff --git a/api/application/docs/sample.pdf b/api/application/docs/sample.pdf
index 28bb5e79..e7980b27 100644
Binary files a/api/application/docs/sample.pdf and b/api/application/docs/sample.pdf differ
diff --git a/api/application/helpers/assetsform_helper.php b/api/application/helpers/assetsform_helper.php
index d226cf12..a0a01f97 100644
--- a/api/application/helpers/assetsform_helper.php
+++ b/api/application/helpers/assetsform_helper.php
@@ -103,8 +103,8 @@ public static function getOthersAssetsDetails($values){
public static function getBusinessAssetsDetails($values){
$mergeResult=array();
foreach($values as $fetchVal){
- echo "helper";
- print_r($fetchVal);
+ // echo "helper";
+ // print_r($fetchVal);
$storeValue=array();
$storeValue['business_assets_mode'] = $fetchVal['business_assets_mode'];
// this is machinaries
diff --git a/api/application/helpers/authorization_helper.php b/api/application/helpers/authorization_helper.php
index 096b26a4..92f955d7 100644
--- a/api/application/helpers/authorization_helper.php
+++ b/api/application/helpers/authorization_helper.php
@@ -57,6 +57,10 @@ class AUTHORIZATION
public static function checkAuthorizationUser($routingName){
$CI =& get_instance();
$headersData = getallheaders();
+ //print_r($headersData);
+
+ //print_r($CI->uri->uri_string);
+ //die();
if (!array_key_exists("Authorization",$headersData) OR $headersData['Authorization']!=$CI->config->item('authorization_key'))
{
set_status_header(REST_CONTROLLER::HTTP_UNAUTHORIZED,"Unauthorized");
@@ -84,6 +88,9 @@ class AUTHORIZATION
else{
return true;
}
+
+
+
}
-
+
}
\ No newline at end of file
diff --git a/api/application/helpers/pdscore_helper.php b/api/application/helpers/pdscore_helper.php
index a1e4ffe5..611bf126 100644
--- a/api/application/helpers/pdscore_helper.php
+++ b/api/application/helpers/pdscore_helper.php
@@ -330,19 +330,23 @@ class PDSCORE
//find out no of not applicable cases
$business_certificates_distribution_count = 0;
+
foreach($score_questions['business']['cerificates'] as $value)
{
+
if(strcasecmp($value,'not applicable'))
{
$business_certificates_distribution_count++;
-
+ //echo $value;
}
}
-
+ $business_certificates_distribution_count;
$business_certificates_distribution = $cerificates_L2 / $business_certificates_distribution_count;
- // echo $cerificates_L2.'---';echo $business_certificates_distribution_count;
- // echo $business_certificates_distribution;
+
+
+ // echo $cerificates_L2.'---';echo $business_certificates_distribution_count;
+ // echo $business_certificates_distribution;die();
$certificate_actual_score = 0;
$certificate_max_score = 0;
@@ -364,14 +368,14 @@ class PDSCORE
}
$score_questions['business']['cerificates']['l1_weightage'] = $l1_business;
- $score_questions['business']['cerificates']['l2_weightage'] = round($business_certificates_distribution,2);
+ $score_questions['business']['cerificates']['l2_weightage'] = round(($business_certificates_distribution * $business_certificates_distribution_count),2);
$score_questions['business']['cerificates']['distributed_weightage'] = $business_distribute_level_weightage;
$score_questions['business']['cerificates']['max_score'] = round($certificate_max_score,2);
$score_questions['business']['cerificates']['attributed_score'] = round($certificate_actual_score,2);
$score_questions['business']['cerificates']['score_band'] = 'Derived';
$score_questions['business']['cerificates']['max_score_band'] = 'Derived';
- //echo $business_certificates_distribution;die();
+ //print_r($score_questions['business']['cerificates']);die();
//######2.1 no_of_years_business_run
$no_of_years_business_run_actual_score = 0;
diff --git a/api/application/libraries/excel.php b/api/application/libraries/excel.php
index 62264cce..0244da6b 100644
--- a/api/application/libraries/excel.php
+++ b/api/application/libraries/excel.php
@@ -11,4 +11,4 @@ class Excel extends PHPExcel {
parent::__construct();
}
}
-// END Smartie Class
+
diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php
index db459d16..3d81a2c4 100644
--- a/api/application/models/PD_Model.php
+++ b/api/application/models/PD_Model.php
@@ -264,6 +264,20 @@ class PD_Model extends SPARQ_Model {
*/
public function getApplicantsDetails($pdid)
{
+
+ $pdmaster_details = $this->getPDMasterDetails($pdid);
+ $parent_pd_id = $pdmaster_details[0]['parent_pd_id'];
+
+ //Get all AddtionalPD's ID
+ $addtional_pd_ids = $this->getAddtionalPDIDs($parent_pd_id);
+ $addtional_pd_ids_string = array();
+ if(count($addtional_pd_ids))
+ {
+ foreach($addtional_pd_ids as $addtional){ array_push($addtional_pd_ids_string,$addtional['pd_id']); }
+ }
+
+ //print_r($addtional_pd_ids_string);die();
+
$this->db->SELECT('PDAPPLICANTSDETAILS.pd_co_applicant_id, PDAPPLICANTSDETAILS.fk_pd_id, PDAPPLICANTSDETAILS.applicant_name, PDAPPLICANTSDETAILS.applicant_type, PDAPPLICANTSDETAILS.mobile_no, PDAPPLICANTSDETAILS.email, PDAPPLICANTSDETAILS.addressline1, PDAPPLICANTSDETAILS.addressline2, PDAPPLICANTSDETAILS.addressline3, PDAPPLICANTSDETAILS.fk_city, PDAPPLICANTSDETAILS.fk_state, PDAPPLICANTSDETAILS.pincode,PDAPPLICANTSDETAILS.relation,RELATIONSHIPS.name as relation_name,PDAPPLICANTSDETAILS.landline,PDAPPLICANTSDETAILS.company_name,PDAPPLICANTSDETAILS.applicant_title_name,TITLES.name as title_name');
$this->db->FROM(PDAPPLICANTSDETAILS.' as PDAPPLICANTSDETAILS');
$this->db->JOIN(STATE.' as STATE','PDAPPLICANTSDETAILS.fk_state = STATE.state_id','LEFT');
@@ -272,6 +286,10 @@ class PD_Model extends SPARQ_Model {
$this->db->JOIN(TITLES.' as TITLES','PDAPPLICANTSDETAILS.applicant_title_name = TITLES.title_id','LEFT');
$this->db->WHERE('PDAPPLICANTSDETAILS.fk_pd_id ',$pdid);
+ if(count($addtional_pd_ids_string))
+ {
+ $this->db->OR_WHERE_IN('PDAPPLICANTSDETAILS.fk_pd_id',$addtional_pd_ids_string);
+ }
$this->db->ORDER_BY('PDAPPLICANTSDETAILS.pd_co_applicant_id');
$result_child_array = $this->db->GET()->result_array();
@@ -285,7 +303,13 @@ class PD_Model extends SPARQ_Model {
}
}
-
+ public function getAddtionalPDIDs($pdid)
+ {
+ $data = $this->db->SELECT('pd_id')->FROM(PDTRIGGER)->WHERE('parent_pd_id',$pdid)->GET()->result_array();
+ //print_r($this->db->last_query());
+ return $data;
+ //
+ }
public function getPDAddress($temp_pdid)
{
@@ -828,6 +852,20 @@ class PD_Model extends SPARQ_Model {
// $overall_question_count = 0;
//Get PD Master Details including Template id @param $pd_id
$pd_master_detials = $this->getPDMasterDetails($pdid);
+
+ // $addtional_pd_ids = $this->PD_Model->getAddtioonalPDIDs($pdid);
+
+ // $addtional_pd_ids_string = null;
+
+ // if($pd_master_detials[0]['parent_pd_id'] == $pdid)
+ // {
+ // $addtional_pd_ids_string = array();
+ // }
+ // if(count($addtional_pd_ids))
+ // {
+ // foreach($addtional_pd_ids as $addtional){ array_push($addtional_pd_ids_string,$addtional['pd_id']); }
+ // }
+
$pd_applicants_detials = $this->getApplicantsDetails($pdid);
//print_r($pd_master_detials);die();
if(count($pd_master_detials)){
@@ -956,7 +994,8 @@ class PD_Model extends SPARQ_Model {
$this->db->WHERE('PDFORMDETAILSJSON.isactive',1);
$template_forms_count = 0;
$template_forms_count = $this->db->GET()->result_array();
- //print_r($template_forms_count);die();
+ //if($value['form_id'] == 4){print_r($template_forms_count);}
+
if(count($template_forms_count) && $template_forms_count[0]['count'] != 0)
{
$template_forms[$template_key]['isAnswered'] = true;
@@ -1001,10 +1040,12 @@ class PD_Model extends SPARQ_Model {
}
else // FOr addtional PD
{
-
+ //echo "child";
$parent_forms = $this->config->item('parent_forms');
+
foreach($template_forms as $template_key => $value)
{
+ $is_answered = 0;
$this->db->SELECT('count(*) as count');
$this->db->FROM(PDFORMDETAILSJSON.' as PDFORMDETAILSJSON');
$this->db->WHERE('PDFORMDETAILSJSON.fk_pd_id',$pdid);
@@ -1012,9 +1053,11 @@ class PD_Model extends SPARQ_Model {
$this->db->WHERE('PDFORMDETAILSJSON.isactive',1);
$template_forms_count = 0;
$template_forms_count = $this->db->GET()->result_array();
- //print_r($template_forms_count);die();
+ //if($value['form_id'] == 19){ print_r($template_forms_count); }//die();
if(count($template_forms_count) && $template_forms_count[0]['count'] != 0)
{
+ //echo $value['form_id'];
+ $is_answered = 1;
$template_forms[$template_key]['isAnswered'] = true;
if($value['pd_form_level_order'] == 1){
$level_one_status++;
@@ -1023,11 +1066,9 @@ class PD_Model extends SPARQ_Model {
}
else
{
+
$template_forms[$template_key]['isAnswered'] = false;
- if( array_search($value['form_id'],$parent_forms) )
- {
- $template_forms[$template_key]['isAnswered'] = true;
- }
+
if($value['pd_form_level_order'] == 1){ $level_one_total++;}
else if($value['pd_form_level_order'] == 2){$level_two_total++;}
}
@@ -1049,15 +1090,40 @@ class PD_Model extends SPARQ_Model {
}
else if($value['pd_form_level_order'] == 3)
{
+
if($level_two_status != $level_two_total)
{
$template_forms[$template_key]['isAnswerable'] = false;
+
}
else
{
$template_forms[$template_key]['isAnswerable'] = true;
+
}
}
+
+ if( array_search($value['form_id'],$parent_forms) )
+ {
+
+ $template_forms[$template_key]['isAnswered'] = true;
+ $template_forms[$template_key]['isAnswerable'] = true;
+ }
+ else
+ {
+
+ if($is_answered == 0)
+ {
+ //echo $value['form_id'];
+ $template_forms[$template_key]['isAnswered'] = false;
+ $template_forms[$template_key]['isAnswerable'] = true;
+ }
+ else
+ {
+ //$template_forms[$template_key]['isAnswered'] = false;
+ $template_forms[$template_key]['isAnswerable'] = true;
+ }
+ }
}
}
@@ -1367,9 +1433,10 @@ class PD_Model extends SPARQ_Model {
$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 Gross Profit calculatio Mode details
$fields = array('calc_type_id','mode','margin','purchase_type');
- $where_condition_array = array('fk_pd_id'=>$pdid);
+ $where_condition_array = array('fk_pd_id'=>$pdid,'company_id'=>$company_id);
$gross_profit_calculation_type = $this->selectCustomRecords($fields,$where_condition_array,PDASSESSEDINCOMEESTIMATIONOFGROSSPROFITTYPE);
//print_r($gross_profit_calculation_type);die();
@@ -1462,7 +1529,8 @@ 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();
+ // print_r($this->db->last_query());
+ // print_r($purchase_details);die();
//get purchase bill details
diff --git a/api/application/views/report_templates/JSONTOREPORT.php b/api/application/views/report_templates/JSONTOREPORT.php
index 1f7835a7..78a89663 100644
--- a/api/application/views/report_templates/JSONTOREPORT.php
+++ b/api/application/views/report_templates/JSONTOREPORT.php
@@ -218,10 +218,10 @@ defined('BASEPATH') OR exit('No direct script access allowed');
echo '
'.$company_with_relationship['company_relationship_master'] .' Of '.$company_with_relationship['company_name'] . '
';
}
}
-
+ //print_r($general_form['persons_with_relationships']);die();
foreach($general_form['persons_with_relationships'] as $persons_with_relationship)
{
- if($individual['pd_co_applicant_id'] == $persons_with_relationship['pd_co_applicant_id'] && $persons_with_relationship['relationship'] != null)
+ if($individual['pd_co_applicant_id'] == $persons_with_relationship['pd_co_applicant_id'] && isset($persons_with_relationship['relationship']))
{
//echo '
'. isset($persons_with_relationship['relationship_master']) ? $persons_with_relationship['relationship_master'] : " Could Not Find" .' Of '.$persons_with_relationship['relation_to_master'] . '
';
//print_r($persons_with_relationship);
@@ -268,7 +268,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
foreach($general_form['persons_with_relationships'] as $persons_with_relationship)
{
//print_r($persons_with_relationship);
- if($individual['pd_co_applicant_id'] == $persons_with_relationship['pd_co_applicant_id'] && $persons_with_relationship['relationship'] != null)
+ if($individual['pd_co_applicant_id'] == $persons_with_relationship['pd_co_applicant_id'] && isset($persons_with_relationship['relationship']))
{
echo "
";
$RSNA = isset($persons_with_relationship['relation_to_master']) ? $persons_with_relationship['relation_to_master'] : " Could Not Find";
@@ -1244,7 +1244,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
?>
| Business Certificates | Answer | Score | Attributed Score | Max Score |
|---|