From 8308a9176c5aec4fcedd6170ef958e1df81eb0d8 Mon Sep 17 00:00:00 2001 From: velz Date: Thu, 8 Nov 2018 17:15:23 +0530 Subject: [PATCH] GROUP REVERTED TEMPLATE FORMS ARRAY INCLUDED SMS MODIFIED --- api/application/config/constants.php | 7 +- api/application/controllers/PD_Controller.php | 176 ++++++++++++++---- .../Template_Management_Controller.php | 40 ++-- api/application/helpers/pdalerts_helper.php | 162 +++++++--------- api/application/models/PD_Model.php | 27 ++- .../models/Question_Management_Model.php | 6 +- .../models/Template_Management_Model.php | 34 ++-- 7 files changed, 271 insertions(+), 181 deletions(-) diff --git a/api/application/config/constants.php b/api/application/config/constants.php index 76ee99ca..07a9a749 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', 'getPDFormDetails'); // no errors +defined('ROUTE_LOGIN') OR define('ROUTE_LOGIN', 'loadFullTemplate'); // no errors /*********************AWS resources Constants*************************************************/ defined('PROFILE_PICTURE_BUCKET_NAME') OR define('PROFILE_PICTURE_BUCKET_NAME','sineedgedevprofilepic'); @@ -328,10 +328,13 @@ defined('TEMPLATEGROUP') OR define('TEMPLATEGROUP','m_template_group'); defined('TEMPLATEGROUPID') OR define('TEMPLATEGROUPID','template_group_id'); defined('PDFORMS') OR define('PDFORMS','m_pd_forms'); -defined('PDFORMSID') OR define('PDFORMSID','pd_form_id'); +defined('PDFORMSID') OR define('PDFORMSID','form_id'); defined('PDFORMDETAILS') OR define('PDFORMDETAILS','t_pd_form_details'); defined('PDFORMDETAILSID') OR define('PDFORMDETAILSID','pd_form_detail_id'); +defined('TEMPLATEFORMS') OR define('TEMPLATEFORMS','m_template_forms'); +defined('TEMPLATEFORMSID') OR define('TEMPLATEFORMSID','template_form_id'); + diff --git a/api/application/controllers/PD_Controller.php b/api/application/controllers/PD_Controller.php index e83ae913..70c6aff4 100644 --- a/api/application/controllers/PD_Controller.php +++ b/api/application/controllers/PD_Controller.php @@ -1490,6 +1490,7 @@ class PD_Controller extends REST_Controller { $pd_id = $this->post('pd_id'); $pd_form_id = $this->post('pd_form_id'); $result_array = $this->PD_Model->getPDFormDetails($pd_id,$pd_form_id); + $final_data = array(); @@ -1498,39 +1499,69 @@ class PD_Controller extends REST_Controller { $overall = array(); $pre_group = ""; + $pre_sub_group = ""; $pre_iter = ""; $t1 = array(); $t2 = array(); $group = array(); + $sub_group = array(); foreach($result_array as $rkey => $result) { if($result['iteration'] != "" || $result['iteration'] != null) { - - if($result['iter_column_name'] != $pre_group && $result['iter_column_name'] != $pre_iter) - { - - $t1 = array(); - $t2 = array(); - $group = array(); - // echo "New-".$result['iter_column_name']; - // print_r(array($result['column_name']=>$result['column_value'])); - $t1 = array_merge($t1,array($result['column_name']=>$result['column_value'])); - $group[$result['iter_column_name']][$result['iteration']] = $t1; - $pre_group = $result['iter_column_name']; - $pre_iter = $result['iteration']; - } - else - { - - // echo "old-".$result['iter_column_name']; - // print_r(array($result['column_name']=>$result['column_value'])); - $t1 = array_merge($t1,array($result['column_name']=>$result['column_value'])); - $group[$result['iter_column_name']][$result['iteration']] = $t1; - $pre_group = $result['iter_column_name']; - $pre_iter = $result['iteration']; - } + if($result['iter_sub_column_name'] == "" || $result['iter_sub_column_name'] == null) + { + if($result['iter_column_name'] != $pre_group && $result['iteration'] != $pre_iter) + { + + $t1 = array(); + $group = array(); + // echo "New-".$result['iter_column_name']; + // print_r(array($result['column_name']=>$result['column_value'])); + $t1 = array_merge($t1,array($result['column_name']=>$result['column_value'])); + $group[$result['iter_column_name']][$result['iteration']] = $t1; + $pre_group = $result['iter_column_name']; + $pre_iter = $result['iteration']; + } + else + { + + // echo "old-".$result['iter_column_name']; + // print_r(array($result['column_name']=>$result['column_value'])); + $t1 = array_merge($t1,array($result['column_name']=>$result['column_value'])); + $group[$result['iter_column_name']][$result['iteration']] = $t1; + $pre_group = $result['iter_column_name']; + $pre_iter = $result['iteration']; + } + } + else// Handle child group + { + if($result['iter_sub_column_name'] != $pre_group && $result['iteration'] != $pre_iter) + { + + $t2 = array(); + $sub_group = array(); + // echo "New-".$result['iter_column_name']; + // print_r(array($result['column_name']=>$result['column_value'])); + $t2 = array_merge($t2,array($result['column_name']=>$result['column_value'])); + $sub_group[$result['iter_sub_column_name']][$result['iteration']] = $t2; + $pre_sub_group = $result['iter_sub_column_name']; + $pre_iter = $result['iteration']; + } + else + { + + // echo "old-".$result['iter_column_name']; + // print_r(array($result['column_name']=>$result['column_value'])); + $t2 = array_merge($t2,array($result['column_name']=>$result['column_value'])); + $sub_group[$result['iter_sub_column_name']][$result['iteration']] = $t2; + $pre_sub_group = $result['iter_sub_column_name']; + $pre_iter = $result['iteration']; + } + + + } } else { @@ -1540,10 +1571,43 @@ class PD_Controller extends REST_Controller { } - + $final_data = array_merge($final_data,$group); } + //print_r($sub_group); + // Merge subgroup into main group + $i = 0; + if(count($sub_group)) + { + foreach($sub_group as $key => $value) + { + //echo $key; + //print_r($value); + foreach($value as $vkey =>$final_value) + { + //echo $vkey; + // print_r($final_value); + $temp_array = array($key=>$final_value); + //print_r($temp_array); + + foreach($final_data as $fkey => $fdata) + { + + $i++; + //echo $vkey.'-'.$i; + if($i == $vkey) + { + + $final_data[$fkey][$vkey] = array_merge($final_data[$fkey][$vkey],$temp_array); + } + //$fdata[$i] + } + + } + } + + } //$final_data = array_merge($final_data,$group); $result_array = $final_data; @@ -1587,13 +1651,10 @@ class PD_Controller extends REST_Controller { { $i++; - //****************handle supplier form details logic***************// - // if($pd_form_id == 1) - // { if($rec_key !='pdid' && $rec_key != 'formid' && $rec_key != 'fk_createdby') { - //echo $rec_key;print_r($record);echo "\n\n\n"; - if(!is_array($record))//sine key and value pair + + if(!is_array($record))//check key and value pair is not an array { $temp_array = array('fk_pd_id'=>$pd_id,'fk_form_id'=>$pd_form_id,'column_name'=>$rec_key,'column_value'=>$record,'fk_createdby'=>$fk_createdby); $id = $this->PD_Model->saveRecords($temp_array,PDFORMDETAILS); @@ -1603,17 +1664,60 @@ class PD_Controller extends REST_Controller { $iter=0; foreach($record as $mkey => $rec) { + //print_r($rec); $iter++; - foreach($rec as $rkey => $r) - { - $temp_array = array(''); - if($r != "" && $r != null) + if(!is_array($rec)) + { + + foreach($rec as $rkey => $r) { + $temp_array = array(''); + if($r != "" && $r != null) + { + + $temp_array = array('fk_pd_id'=>$pd_id,'fk_form_id'=>$pd_form_id,'iter_column_name'=>$rec_key,'column_name'=>$rkey,'column_value'=>$r,'fk_createdby'=>$fk_createdby,'iteration'=>$iter); + $id = $this->PD_Model->saveRecords($temp_array,PDFORMDETAILS); + } - $temp_array = array('fk_pd_id'=>$pd_id,'fk_form_id'=>$pd_form_id,'iter_column_name'=>$rec_key,'column_name'=>$rkey,'column_value'=>$r,'fk_createdby'=>$fk_createdby,'iteration'=>$iter); - $id = $this->PD_Model->saveRecords($temp_array,PDFORMDETAILS); } + } + else + { + foreach($rec as $child_key => $child_data) + { + //print_r($child_data); + // echo "$child_key-\n\n\n"; + if(!is_array($child_data)) + { + //echo "not array\n\n"; + //print_r($child_data); + $temp_array = array('fk_pd_id'=>$pd_id,'fk_form_id'=>$pd_form_id,'column_name'=>$child_key,'column_value'=>$child_data,'iter_column_name'=>$rec_key,'fk_createdby'=>$fk_createdby,'iteration'=>$iter); + //print_r($temp_array); + $id = $this->PD_Model->saveRecords($temp_array,PDFORMDETAILS); + + + } + else + { + //echo "array"; + //print_r($child_data); + //echo "$child_key-\n\n\n"; + foreach($child_data as $last_key => $last_data) + { + foreach($last_data as $final_key => $final_data) + { + $temp_array = array('fk_pd_id'=>$pd_id,'fk_form_id'=>$pd_form_id,'column_name'=>$final_key,'column_value'=>$final_data,'iter_column_name'=>$rec_key,'iter_sub_column_name'=>$child_key,'fk_createdby'=>$fk_createdby,'iteration'=>$iter); + //print_r($temp_array); + $id = $this->PD_Model->saveRecords($temp_array,PDFORMDETAILS); + } + + } + + + + } + } } diff --git a/api/application/controllers/Template_Management_Controller.php b/api/application/controllers/Template_Management_Controller.php index 372b6632..933ef0c8 100644 --- a/api/application/controllers/Template_Management_Controller.php +++ b/api/application/controllers/Template_Management_Controller.php @@ -144,41 +144,41 @@ class Template_Management_Controller extends REST_Controller { { if($template_category_detail['template_category_weightage_id'] != null || $template_category_detail['template_category_weightage_id'] != "") { - $groups = $template_category_detail['groups']; - unset($template_category_detail['groups']); + //$groups = $template_category_detail['groups']; + //unset($template_category_detail['groups']); $where_condition_array = array('template_category_weightage_id'=>$template_category_detail['template_category_weightage_id']); $modified = $this->Template_Management_Model->updateRecords($template_category_detail,TEMPLATECATEGORYWEIGHTAGE,$where_condition_array); if($modified != "" || $modified != null){ $count++; } //Groups insert/update - foreach($groups as $group_key => $group) - { - if($group['template_group_id'] != null || $group['template_group_id'] != "") - { - $where_condition_array = array('template_group_id'=>$group['template_group_id']); - $modified = $this->Template_Management_Model->updateRecords($group,TEMPLATEGROUP,$where_condition_array); - } - else - { - $template_group_id = $this->Template_Management_Model->saveRecords($group,TEMPLATEGROUP); - } - } + // foreach($groups as $group_key => $group) + // { + // if($group['template_group_id'] != null || $group['template_group_id'] != "") + // { + // $where_condition_array = array('template_group_id'=>$group['template_group_id']); + // $modified = $this->Template_Management_Model->updateRecords($group,TEMPLATEGROUP,$where_condition_array); + // } + // else + // { + // $template_group_id = $this->Template_Management_Model->saveRecords($group,TEMPLATEGROUP); + // } + // } } //Insert Categories else { - $groups = $template_category_detail['groups']; - unset($template_category_detail['groups']); + // $groups = $template_category_detail['groups']; + // unset($template_category_detail['groups']); $id = $this->Template_Management_Model->saveRecords($template_category_detail,TEMPLATECATEGORYWEIGHTAGE); if($id != "" || $id != null){ $count++; } //Groups insert - foreach($groups as $group_key => $group) - { + // foreach($groups as $group_key => $group) + // { - $template_group_id = $this->Template_Management_Model->saveRecords($group,TEMPLATEGROUP); + // $template_group_id = $this->Template_Management_Model->saveRecords($group,TEMPLATEGROUP); - } + // } } } diff --git a/api/application/helpers/pdalerts_helper.php b/api/application/helpers/pdalerts_helper.php index e148a7ac..fc4478c6 100644 --- a/api/application/helpers/pdalerts_helper.php +++ b/api/application/helpers/pdalerts_helper.php @@ -33,60 +33,53 @@ class PDALERTS */ //1.Get Current Status and createdby , lenders info by pdid - $CI->db->SELECT("PDTRIGGER.fk_lender_id,PDTRIGGER.lender_applicant_id,PDTRIGGER.pd_status,PDSTATUS.pd_status_name,PDTRIGGER.fk_createdby,USERPROFILE.fk_entity_id as created_entity_type,USERPROFILE.email as created_mail,USERPROFILE.mobile_no as created_mobile_no,PDTRIGGER.fk_pd_allocated_to,ALLOCATED.email as allocated_email,ALLOCATED.mobile_no as allocated_mobile_no,ALLOCATED.fk_entity_id as allocated_entity_type,PDTRIGGER.pd_agency_id"); + $CI->db->SELECT("PDTRIGGER.fk_lender_id,PDTRIGGER.lender_applicant_id,PDTRIGGER.pd_status,PDTRIGGER.fk_createdby,CREATED.email as created_mail,CREATED.mobile_no as created_mobile_no,PDTRIGGER.fk_pd_allocated_to,ALLOCATED.email as allocated_email,ALLOCATED.mobile_no as allocated_mobile_no,PDTRIGGER.executive_id,EXECUTIVE.email as executive_email,EXECUTIVE.mobile_no as executive_mobile_no,PDTRIGGER.central_pd_officer_id,CENTRALPDOFFICER.mobile_no as centralpdofficer_mobile_no,CENTRALPDOFFICER.email as centralpdofficer_mail,PDTRIGGER.pd_agency_id,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno"); $CI->db->FROM(PDTRIGGER." as PDTRIGGER"); - $CI->db->JOIN(USERPROFILE." as USERPROFILE","PDTRIGGER.fk_createdby = USERPROFILE.userid"); - $CI->db->JOIN(USERPROFILE." as ALLOCATED","PDTRIGGER.fk_pd_allocated_to = ALLOCATED.userid"); - $CI->db->JOIN(PDSTATUS." as PDSTATUS","PDTRIGGER.pd_status = PDSTATUS.pd_status_id"); + $CI->db->JOIN(USERPROFILE." as CREATED","PDTRIGGER.fk_createdby = CREATED.userid",'LEFT'); + $CI->db->JOIN(USERPROFILE." as ALLOCATED","PDTRIGGER.fk_pd_allocated_to = ALLOCATED.userid",'LEFT'); + $CI->db->JOIN(USERPROFILE." as EXECUTIVE","PDTRIGGER.executive_id = EXECUTIVE.userid",'LEFT'); + $CI->db->JOIN(USERPROFILE." as CENTRALPDOFFICER","PDTRIGGER.central_pd_officer_id = CENTRALPDOFFICER.userid",'LEFT'); $CI->db->WHERE("PDTRIGGER.pd_id",$pdid); $core_details = $CI->db->GET()->result_array(); //print_r($core_details); + + + if(count($core_details)) { //2.Get Notification Configuration by using pd staus idate - $CI->db->SELECT("PDNOTIFICATION.pdnotification_id, PDNOTIFICATION.fk_pd_status_id, PDSTATUS.pd_status_name,PDNOTIFICATION.sms_lender, PDNOTIFICATION.sms_pdofficer, PDNOTIFICATION.sms_pdincharge, PDNOTIFICATION.mail_lender, PDNOTIFICATION.mail_pdincharge, PDNOTIFICATION.mail_pdofficer"); + $CI->db->SELECT("PDNOTIFICATION.pd_status,PDNOTIFICATION.sms_lender, PDNOTIFICATION.sms_pdofficer, PDNOTIFICATION.sms_pdincharge, PDNOTIFICATION.mail_lender, PDNOTIFICATION.mail_pdincharge, PDNOTIFICATION.mail_pdofficer"); $CI->db->FROM(PDNOTIFICATION." as PDNOTIFICATION"); - $CI->db->JOIN(PDSTATUS." as PDSTATUS","PDNOTIFICATION.fk_pd_status_id = PDSTATUS.pd_status_id AND PDSTATUS.isactive = 1"); - $CI->db->WHERE("PDNOTIFICATION.fk_pd_status_id",$core_details[0]['pd_status']); + $CI->db->WHERE("PDNOTIFICATION.pd_status",$core_details[0]['pd_status']); + $CI->db->WHERE("PDNOTIFICATION.isactive",1); $pd_notification_configs = $CI->db->GET()->result_array(); - //print_r($pd_notification_configs); + //print_r($pd_notification_configs);die(); + + + //sent sms to lender contacts - //pd cretaed entity type is 2 then sent sms only for that mobile no - if($core_details[0]['created_entity_type'] == 2) // 2 - Lender Type - { if($pd_notification_configs[0]['sms_lender'] == 1) { - array_push($mobile_nos_to_send_notification,$core_details[0]['created_mobile_no']); + array_push($mobile_nos_to_send_notification,$core_details[0]['pd_contact_mobileno']); } - } - else //sent sms to all lender contacts associated to lender id - { - // if($pd_notification_configs[0]['sms_lender'] == 1) - // { - - // $CI->db->SELECT("contact_mobile_no"); - // $CI->db->FROM(ENTITYBILLINGCONTACTINFO); - // $CI->db->WHERE("fk_entity_id",$core_details[0]['fk_lender_id']); - // $lender_mobile_nos = $CI->db->GET()->result_array(); - // //print_r($lender_mobile_nos); - // //print_r($lender_mobile_nos); - // if(count($lender_mobile_nos)) - // { - // foreach($lender_mobile_nos as $mobile) - // { - // array_push($mobile_nos_to_send_notification,$mobile['contact_mobile_no']); - // } - // } - // } - } + //add pd officer no if($pd_notification_configs[0]['sms_pdofficer'] == 1) { array_push($mobile_nos_to_send_notification,$core_details[0]['allocated_mobile_no']); + + if($core_details[0]['executive_mobile_no'] != "" || $core_details[0]['executive_mobile_no'] != null) + { + array_push($mobile_nos_to_send_notification,$core_details[0]['executive_mobile_no']); + } + if($core_details[0]['centralpdofficer_mobile_no'] != "" || $core_details[0]['centralpdofficer_mobile_no'] != null) + { + array_push($mobile_nos_to_send_notification,$core_details[0]['centralpdofficer_mobile_no']); + } } //add pd incharge mobile_no's @@ -95,8 +88,8 @@ class PDALERTS $CI->db->DISTINCT(); $CI->db->SELECT("mobile_no"); $CI->db->FROM(USERPROFILE." as USERPROFILE"); - $CI->db->JOIN(USERPROFILEROLES." as USERPROFILEROLES","USERPROFILE.userid = USERPROFILEROLES.fk_userid AND USERPROFILEROLES.isactive = 1"); - $CI->db->WHERE("USERPROFILEROLES.user_role",'PDINCHAGRE'); + $CI->db->JOIN(USERPROFILEROLES." as USERPROFILEROLES","USERPROFILE.userid = USERPROFILEROLES.fk_userid AND USERPROFILEROLES.isactive = 1 AND USERPROFILE.isactive = 1"); + $CI->db->WHERE("USERPROFILEROLES.user_role",3); $inchagre_mobile_nos = $CI->db->GET()->result_array(); if(count($inchagre_mobile_nos)) { @@ -107,7 +100,7 @@ class PDALERTS } } - $msg = "PD for Lender Applicant ID -:". $core_details[0]['lender_applicant_id'] ." has been ". $core_details[0]['pd_status_name']; // status base configurable + $msg = "PD for Lender Applicant ID -:". $core_details[0]['lender_applicant_id'] ." has been ". $core_details[0]['pd_status']; // status base configurable //print_r($mobile_nos_to_send_notification); foreach($mobile_nos_to_send_notification as $no) { @@ -126,70 +119,53 @@ class PDALERTS */ - // if(count($core_details)) - // { + if(count($core_details)) + { - // //pd cretaed entity type is 2 then sent mail only for that email - // if($core_details['created_entity_type'] == 2) // 2 - Lender Type - // { - // if($pd_notification_configs['mail_lender'] == 1) - // { - // array_push($email_ids_to_send_notification,$core_details['created_mail']); - // } - // } - // else //sent email to all lender contacts associated to lender id - // { - // if($pd_notification_configs['mail_lender'] == 1) - // { - - // $CI->db->SELECT("contact_email"); - // $CI->db->FROM(ENTITYCHILD); - // $CI->db->WHERE("fk_entity_id",$core_details['fk_lender_id']); - // $lender_emails = $CI->db->GET()->result_array(); - // if(count($lender_mobile_nos)) - // { - // foreach($lender_emails as $lender_email) - // { - // array_push($email_ids_to_send_notification,$lender_email); - // } - // } - // } - // } - // //add pd officer email - // if($pd_notification_configs['mail_pdofficer'] == 1) - // { - // array_push($email_ids_to_send_notification,$core_details['allocated_email']); - // } - // //add pd incharge emails - // if($pd_notification_configs['mail_pdincharge'] == 1) - // { - // $CI->db->DISTINCT(); - // $CI->db->SELECT("email"); - // $CI->db->FROM(USERPROFILE." as USERPROFILE"); - // $CI->db->JOIN(USERPROFILEROLES." as USERPROFILEROLES","USERPROFILE.userid = USERPROFILEROLES.fk_userid AND USERPROFILEROLES.isactive = 1"); - // $CI->db->WHERE("USERPROFILEROLES.user_role",'PDINCHAGRE'); - // $inchagre_email = $CI->db->GET()->result_array(); - // if(count($inchagre_email)) - // { - // foreach($inchagre_email as $email) - // { - // array_push($email_ids_to_send_notification,$email); - // } - // } - // } + //add pd officer email + if($pd_notification_configs[0]['mail_pdofficer'] == 1) + { + array_push($email_ids_to_send_notification,$core_details[0]['allocated_email']); + if($core_details[0]['executive_email'] != "" || $core_details[0]['executive_email'] != null) + { + array_push($email_ids_to_send_notification,$core_details[0]['executive_email']); + } + if($core_details[0]['centralpdofficer_mail'] != "" || $core_details[0]['centralpdofficer_mail'] != null) + { + array_push($email_ids_to_send_notification,$core_details[0]['centralpdofficer_mail']); + } + } - // //$msg = "PD for Lender Applicant ID:".$core_details['lender_applicant_id']."has been".$core_details['pd_status_name']; // status base configurable - // foreach($email_ids_to_send_notification as $email) - // { + //add pd incharge emails + if($pd_notification_configs[0]['mail_pdincharge'] == 1) + { + $CI->db->DISTINCT(); + $CI->db->SELECT("email"); + $CI->db->FROM(USERPROFILE." as USERPROFILE"); + $CI->db->JOIN(USERPROFILEROLES." as USERPROFILEROLES","USERPROFILE.userid = USERPROFILEROLES.fk_userid AND USERPROFILEROLES.isactive = 1 AND USERPROFILE.isactive = 1"); + $CI->db->WHERE("USERPROFILEROLES.user_role",3); + $inchagre_email = $CI->db->GET()->result_array(); + if(count($inchagre_email)) + { + foreach($inchagre_email as $email) + { + array_push($email_ids_to_send_notification,$email); + } + } + } + + //$msg = "PD for Lender Applicant ID:".$core_details['lender_applicant_id']."has been".$core_details['pd_status_name']; // status base configurable + foreach($email_ids_to_send_notification as $email) + { - // //email SES have to config - // //$CI->aws_ses->sendMail($email); - // } + //email SES have to config + //$CI->aws_ses->sendMail($email); + } - // } + } /*End of Email Functionality*/ } diff --git a/api/application/models/PD_Model.php b/api/application/models/PD_Model.php index 089a5243..ed4d8a63 100644 --- a/api/application/models/PD_Model.php +++ b/api/application/models/PD_Model.php @@ -14,7 +14,7 @@ class PD_Model extends SPARQ_Model { public function listLessPDDetails($page,$limit,$sort,$pdofficerid,$datetype,$fdate,$tdate,$lenderid,$status)// $page represents mysql offset { //echo $status;die(); - $this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name, PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDSTATUS.pd_status_name, PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i:%s") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks'); + $this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name,PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name, PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDSTATUS.pd_status_name, PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i:%s") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.executive_id,concat(EXECUTIVE.first_name," ",EXECUTIVE.last_name) as executive_name,PDTRIGGER.central_pd_officer_id,concat(CENTRALOFFICER.first_name," ",CENTRALOFFICER.last_name) as centralofficer,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks'); $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id','LEFT'); $this->db->JOIN(ENTITYBILLING.' as ENTITYBILLING','PDTRIGGER.fk_entity_billing_id = ENTITYBILLING.entity_billing_id','LEFT'); @@ -26,6 +26,8 @@ class PD_Model extends SPARQ_Model { $this->db->JOIN(USERPROFILE.' as USERPROFILE1','PDTRIGGER.fk_updatedby = USERPROFILE1.userid','LEFT'); $this->db->JOIN(PDALLOCATIONTYPE.' as PDALLOCATIONTYPE','PDTRIGGER.fk_pd_allocation_type = PDALLOCATIONTYPE.pd_allocation_type_id','LEFT'); $this->db->JOIN(USERPROFILE.' as USERPROFILE2','PDTRIGGER.fk_pd_allocated_to = USERPROFILE2.userid','LEFT'); + $this->db->JOIN(USERPROFILE.' as EXECUTIVE','PDTRIGGER.executive_id = EXECUTIVE.userid','LEFT'); + $this->db->JOIN(USERPROFILE.' as CENTRALOFFICER','PDTRIGGER.central_pd_officer_id = CENTRALOFFICER.userid','LEFT'); $this->db->JOIN(TEMPLATE.' as TEMPLATE','PDTRIGGER.fk_pd_template_id = TEMPLATE.template_id','LEFT'); $this->db->JOIN(CUSTOMERSEGMENT.' as CUSTOMERSEGMENT','PDTRIGGER.fk_customer_segment = CUSTOMERSEGMENT.customer_segment_id','LEFT'); $this->db->JOIN(ENTITY.' as AGENCY','PDTRIGGER.pd_agency_id = AGENCY.entity_id','LEFT'); @@ -403,7 +405,7 @@ class PD_Model extends SPARQ_Model { */ public function getPDMasterDetails($pdid) { - $this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name, PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name,PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDSTATUS.pd_status_name, PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i:%s") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,concat(USERPROFILE3.first_name," ",USERPROFILE3.last_name) as pd_executive,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks'); + $this->db->SELECT('PDTRIGGER.pd_id, PDTRIGGER.fk_lender_id,ENTITY.full_name as lender_full_name,ENTITY.short_name as lender_short_name, PDTRIGGER.fk_entity_billing_id,ENTITYBILLING.billing_name,PDTRIGGER.lender_applicant_id, DATE_FORMAT(PDTRIGGER.pd_date_of_initiation, "%d/%m/%Y") as pd_date_of_initiation, PDTRIGGER.fk_product_id,PRODUCTS.name as product_name,PRODUCTS.abbr as product_abbr, PDTRIGGER.fk_subproduct_id,SUBPRODUCTS.name as subproduct_name,SUBPRODUCTS.abbr as subproduct_abbr, PDTRIGGER.fk_pd_type,PDTYPE.type_name as pd_type_name, PDTRIGGER.pd_status,PDSTATUS.pd_status_name, PDTRIGGER.pd_specific_clarification, DATE_FORMAT(PDTRIGGER.createdon,"%d/%m/%Y %H:%i:%s") as createdon, PDTRIGGER.fk_createdby, DATE_FORMAT(PDTRIGGER.updatedon,"%d/%m/%Y %H:%i:%s") as updatedon, PDTRIGGER.fk_updatedby,concat(USERPROFILE.first_name," ",USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby, PDTRIGGER.fk_pd_allocation_type,,PDALLOCATIONTYPE.pd_allocation_type_name, PDTRIGGER.fk_pd_allocated_to,concat(USERPROFILE2.first_name," ",USERPROFILE2.last_name) as pd_allocated_to,PDTRIGGER.executive_id,concat(EXECUTIVE.first_name," ",EXECUTIVE.last_name) as executive_name,PDTRIGGER.central_pd_officer_id,concat(CENTRALOFFICER.first_name," ",CENTRALOFFICER.last_name) as centralofficer,PDTRIGGER.fk_pd_template_id,TEMPLATE.template_name, PDTRIGGER.fk_customer_segment,CUSTOMERSEGMENT.name as customer_segment_name,CUSTOMERSEGMENT.abbr as customer_segment_abbr, PDTRIGGER.pd_officier_final_judgement, PDTRIGGER.pd_agency_id,AGENCY.full_name as agency_name, PDTRIGGER.loan_amount,PDTRIGGER.addressline1,PDTRIGGER.addressline2,PDTRIGGER.addressline3,PDTRIGGER.fk_city,CITY.name as city_name,PDTRIGGER.fk_state,STATE.name as state_name,PDTRIGGER.pincode,PDTRIGGER.pd_contact_person,PDTRIGGER.pd_contact_mobileno,DATE_FORMAT(PDTRIGGER.scheduled_on,"%d/%m/%Y %h:%i %p") as scheduled_on,DATE_FORMAT(PDTRIGGER.completed_on,"%d/%m/%Y %h:%i:%s %p") as completed_on,PDTRIGGER.remarks'); $this->db->FROM(PDTRIGGER.' as PDTRIGGER'); $this->db->JOIN(ENTITY.' as ENTITY','PDTRIGGER.fk_lender_id = ENTITY.entity_id ','LEFT'); $this->db->JOIN(ENTITYBILLING.' as ENTITYBILLING','PDTRIGGER.fk_entity_billing_id = ENTITYBILLING.entity_billing_id','LEFT'); @@ -416,6 +418,8 @@ class PD_Model extends SPARQ_Model { $this->db->JOIN(PDALLOCATIONTYPE.' as PDALLOCATIONTYPE','PDTRIGGER.fk_pd_allocation_type = PDALLOCATIONTYPE.pd_allocation_type_id','LEFT'); $this->db->JOIN(USERPROFILE.' as USERPROFILE2','PDTRIGGER.fk_pd_allocated_to = USERPROFILE2.userid','LEFT'); $this->db->JOIN(USERPROFILE.' as USERPROFILE3','PDTRIGGER.executive_id = USERPROFILE3.userid','LEFT'); + $this->db->JOIN(USERPROFILE.' as EXECUTIVE','PDTRIGGER.executive_id = EXECUTIVE.userid','LEFT'); + $this->db->JOIN(USERPROFILE.' as CENTRALOFFICER','PDTRIGGER.central_pd_officer_id = CENTRALOFFICER.userid','LEFT'); $this->db->JOIN(TEMPLATE.' as TEMPLATE','PDTRIGGER.fk_pd_template_id = TEMPLATE.template_id','LEFT'); $this->db->JOIN(CUSTOMERSEGMENT.' as CUSTOMERSEGMENT','PDTRIGGER.fk_customer_segment = CUSTOMERSEGMENT.customer_segment_id','LEFT'); $this->db->JOIN(ENTITY.' as AGENCY','PDTRIGGER.pd_agency_id = AGENCY.entity_id','LEFT'); @@ -521,7 +525,7 @@ class PD_Model extends SPARQ_Model { foreach($questions as $answer_key => $question) { - $this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer,TEMPLATEANSWERWEIGHTAGE.template_answer_weightage_id, TEMPLATEANSWERWEIGHTAGE.fk_template_question_id, TEMPLATEANSWERWEIGHTAGE.fk_question_answer_id, TEMPLATEANSWERWEIGHTAGE.template_answer_weightage,PDANSWER.isactive,PDANSWER.pd_detail_answer_id,PDANSWER.fk_pd_detail_id'); + $this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer,PDANSWER.pd_answer,TEMPLATEANSWERWEIGHTAGE.template_answer_weightage_id, TEMPLATEANSWERWEIGHTAGE.fk_template_question_id, TEMPLATEANSWERWEIGHTAGE.fk_question_answer_id, TEMPLATEANSWERWEIGHTAGE.template_answer_weightage,PDANSWER.isactive,PDANSWER.pd_detail_answer_id,PDANSWER.fk_pd_detail_id'); $this->db->FROM(TEMPLATEANSWERWEIGHTAGE.' as TEMPLATEANSWERWEIGHTAGE'); $this->db->JOIN(QUESTIONANSWERS.' as QUESTIONANSWERS','TEMPLATEANSWERWEIGHTAGE.fk_question_answer_id = QUESTIONANSWERS.question_answer_id','LEFT'); $this->db->JOIN(PDANSWER." as PDANSWER","QUESTIONANSWERS.question_answer_id = PDANSWER.pd_answer_id AND TEMPLATEANSWERWEIGHTAGE.fk_question_answer_id = PDANSWER.pd_answer_id AND PDANSWER.isactive = 1 AND PDANSWER.fk_pd_id = $pdid",'LEFT'); @@ -539,11 +543,20 @@ class PD_Model extends SPARQ_Model { } } + + //Get Forms details + $this->db->SELECT('TEMPLATEFORMS.form_id,PDFORMS.pd_form_name as form_name'); + $this->db->FROM(TEMPLATEFORMS.' as TEMPLATEFORMS'); + $this->db->JOIN(PDFORMS.' as PDFORMS','TEMPLATEFORMS.form_id = PDFORMS.pd_form_id'); + $this->db->WHERE('TEMPLATEFORMS.fk_template_id',$template_id); + $template_forms = $this->db->GET()->result_array(); + $result_data['question_answers'] = $categories; $result_data['counts'] = array('overall_answered_count'=>$overall_answered_count,'overall_question_count'=>$overall_question_count); $result_data['pdmaster_details'] = $pd_master_detials[0]; $result_data['pdapplicants_detials'] = $pd_applicants_detials; $result_data['assessed_income'] = ""; + $result_data['template_forms'] = $template_forms; return $result_data; } @@ -735,19 +748,15 @@ class PD_Model extends SPARQ_Model { public function getPDFormDetails($pd_id,$pd_form_id) { - //echo $pd_id.'-'.$pd_form_id; - $this->db->SELECT('PDFORMDETAILS.iter_column_name,PDFORMDETAILS.iteration, PDFORMDETAILS.column_name, PDFORMDETAILS.column_id, PDFORMDETAILS.column_value, PDFORMDETAILS.createdon, PDFORMDETAILS.fk_createdby,USERPROFILE.first_name,USERPROFILE.last_name'); + + $this->db->SELECT('PDFORMDETAILS.iter_column_name,PDFORMDETAILS.iter_sub_column_name,PDFORMDETAILS.iteration, PDFORMDETAILS.column_name, PDFORMDETAILS.column_id, PDFORMDETAILS.column_value, PDFORMDETAILS.createdon, PDFORMDETAILS.fk_createdby,USERPROFILE.first_name,USERPROFILE.last_name'); $this->db->FROM(PDFORMDETAILS.' as PDFORMDETAILS'); $this->db->JOIN(USERPROFILE.' as USERPROFILE','PDFORMDETAILS.fk_createdby = USERPROFILE.userid','LEFT'); $this->db->WHERE('PDFORMDETAILS.fk_pd_id',$pd_id); $this->db->WHERE('PDFORMDETAILS.fk_form_id',$pd_form_id); $this->db->WHERE('PDFORMDETAILS.isactive',1); - //$this->db->ORDER_BY('PDFORMDETAILS.iteration'); $form_details = $this->db->GET()->result_array(); - //print_r($this->db->last_query()); - //print_r($form_details);die(); return $form_details; - } } \ No newline at end of file diff --git a/api/application/models/Question_Management_Model.php b/api/application/models/Question_Management_Model.php index c532f0bf..412474e0 100644 --- a/api/application/models/Question_Management_Model.php +++ b/api/application/models/Question_Management_Model.php @@ -14,11 +14,11 @@ class Question_Management_Model extends SPARQ_Model { { - $this->db->SELECT('QUESTIONS.question_id,QUESTIONS.fk_question_group_id,QUESTIONGROUP.group_name, QUESTIONS.question, QUESTIONS.description, QUESTIONS.fk_question_category,QUESTIONCATEGORY.category_name, QUESTIONS.fk_question_answertype,QUESTIONANSWERTYPE.answer_type_name,QUESTIONS.isactive, QUESTIONS.createdon, QUESTIONS.fk_createdby, QUESTIONS.updatedon, QUESTIONS.fk_updatedby,concat(USERPROFILE.first_name," " ,USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby'); + $this->db->SELECT('QUESTIONS.question_id,QUESTIONS.question, QUESTIONS.description, QUESTIONS.fk_question_category,QUESTIONCATEGORY.category_name, QUESTIONS.fk_question_answertype,QUESTIONANSWERTYPE.answer_type_name,QUESTIONS.isactive, QUESTIONS.createdon, QUESTIONS.fk_createdby, QUESTIONS.updatedon, QUESTIONS.fk_updatedby,concat(USERPROFILE.first_name," " ,USERPROFILE.last_name) as createdby,concat(USERPROFILE1.first_name," ",USERPROFILE1.last_name) as updatedby'); $this->db->FROM(QUESTIONS.' as QUESTIONS'); $this->db->JOIN(QUESTIONANSWERTYPE.' as QUESTIONANSWERTYPE','QUESTIONS.fk_question_answertype = QUESTIONANSWERTYPE.question_answer_type_id'); $this->db->JOIN(QUESTIONCATEGORY.' as QUESTIONCATEGORY','QUESTIONS.fk_question_category = QUESTIONCATEGORY.question_category_id'); - $this->db->JOIN(QUESTIONGROUP.' as QUESTIONGROUP','QUESTIONS.fk_question_group_id = QUESTIONGROUP.question_group_id','LEFT'); + // $this->db->JOIN(QUESTIONGROUP.' as QUESTIONGROUP','QUESTIONS.fk_question_group_id = QUESTIONGROUP.question_group_id','LEFT'); $this->db->JOIN(USERPROFILE.' as USERPROFILE','QUESTIONS.fk_createdby = USERPROFILE.userid'); $this->db->JOIN(USERPROFILE.' as USERPROFILE1','QUESTIONS.fk_updatedby = USERPROFILE1.userid','LEFT'); if($category_id != null || $category_id != '') @@ -32,7 +32,7 @@ class Question_Management_Model extends SPARQ_Model { foreach($result as $key => $r) { - $this->db->SELECT('QUESTIONANSWERS.question_answer_id, QUESTIONANSWERS.fk_question_id, QUESTIONANSWERS.fk_question_group_id,QUESTIONANSWERS.answer, QUESTIONANSWERS.createdon, QUESTIONANSWERS.fk_createdby, QUESTIONANSWERS.updatedon, QUESTIONANSWERS.fk_updatedby, QUESTIONANSWERS.isactive'); + $this->db->SELECT('QUESTIONANSWERS.question_answer_id, QUESTIONANSWERS.fk_question_id, QUESTIONANSWERS.answer, QUESTIONANSWERS.createdon, QUESTIONANSWERS.fk_createdby, QUESTIONANSWERS.updatedon, QUESTIONANSWERS.fk_updatedby, QUESTIONANSWERS.isactive'); $this->db->FROM(QUESTIONANSWERS.' as QUESTIONANSWERS'); $this->db->JOIN(QUESTIONS.' as QUESTIONS','QUESTIONANSWERS.fk_question_id = QUESTIONS.question_id'); $this->db->JOIN(USERPROFILE.' as USERPROFILE','QUESTIONANSWERS.fk_createdby = USERPROFILE.userid '); diff --git a/api/application/models/Template_Management_Model.php b/api/application/models/Template_Management_Model.php index 916fa292..b3ceca78 100644 --- a/api/application/models/Template_Management_Model.php +++ b/api/application/models/Template_Management_Model.php @@ -86,17 +86,17 @@ class Template_Management_Model extends SPARQ_Model { //$this->db->JOIN(USERPROFILE.' as USERPROFILE1','TEMPLATECATEGORYWEIGHTAGE.fk_updatedby = USERPROFILE1.userid','LEFT'); $this->db->WHERE('TEMPLATECATEGORYWEIGHTAGE.fk_template_id',$template_id); $categories = $this->db->GET()->result_array(); - if(count($categories)) - { - foreach($categories as $ckey => $category) - { - $this->db->SELECT('template_group_id,fk_question_group_id'); - $this->db->FROM(TEMPLATEGROUP); - $this->db->WHERE(TEMPLATEGROUP.'.fk_template_category_weightage_id',$category['template_category_weightage_id']); - $groups = $this->db->GET()->result_array(); - $categories[$ckey]['groups'] = $groups; - } - } + // if(count($categories)) + // { + // foreach($categories as $ckey => $category) + // { + // $this->db->SELECT('template_group_id,fk_question_group_id'); + // $this->db->FROM(TEMPLATEGROUP); + // $this->db->WHERE(TEMPLATEGROUP.'.fk_template_category_weightage_id',$category['template_category_weightage_id']); + // $groups = $this->db->GET()->result_array(); + // $categories[$ckey]['groups'] = $groups; + // } + // } return $categories; } @@ -159,13 +159,13 @@ class Template_Management_Model extends SPARQ_Model { } - public function getListOfQuestions($template_id,$category_id,$group_id) + public function getListOfQuestions($template_id,$category_id) { $questions = array(); if(($template_id != "" || $template_id != null) && ($category_id != "" || $category_id != null)) { $fields = array('fk_question_id'); - $where_condition_array = array('fk_template_question_category_id' => $category_id,'fk_template_id' => $template_id,'fk_question_group_id'=>$group_id); + $where_condition_array = array('fk_template_question_category_id' => $category_id,'fk_template_id' => $template_id); $result_data = $this->selectCustomRecords($fields,$where_condition_array,TEMPLATEQUESTION); if(count($result_data)) @@ -180,7 +180,6 @@ class Template_Management_Model extends SPARQ_Model { $this->db->SELECT('QUESTIONS.question_id,QUESTIONS.question'); $this->db->FROM(QUESTIONS.' as QUESTIONS'); $this->db->WHERE('QUESTIONS.fk_question_category',$category_id); - $this->db->WHERE('QUESTIONS.fk_question_group_id',$group_id); $this->db->WHERE('QUESTIONS.isactive',1); $this->db->WHERE_NOT_IN('QUESTIONS.question_id',$temp_array); $questions = $this->db->GET()->result_array(); @@ -191,10 +190,9 @@ class Template_Management_Model extends SPARQ_Model { foreach($questions as $answer_key => $question) { - $this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer,QUESTIONANSWERS.fk_question_group_id'); + $this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer'); $this->db->FROM(QUESTIONANSWERS.' as QUESTIONANSWERS'); $this->db->WHERE('QUESTIONANSWERS.fk_question_id',$question['question_id']); - $this->db->WHERE('QUESTIONANSWERS.isactive',1); $answers = $this->db->GET()->result_array(); // Attach TEMPLATEANSWERWEIGHTAGE table keys for front purpose @@ -221,7 +219,6 @@ class Template_Management_Model extends SPARQ_Model { $this->db->SELECT('QUESTIONS.question_id,QUESTIONS.question'); $this->db->FROM(QUESTIONS.' as QUESTIONS'); $this->db->WHERE('QUESTIONS.fk_question_category',$category_id); - $this->db->WHERE('QUESTIONS.fk_question_group_id',$group_id); $this->db->WHERE('QUESTIONS.isactive',1); $questions = $this->db->GET()->result_array(); @@ -232,7 +229,7 @@ class Template_Management_Model extends SPARQ_Model { foreach($questions as $answer_key => $question) { - $this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer,QUESTIONANSWERS.fk_question_group_id'); + $this->db->SELECT('QUESTIONANSWERS.question_answer_id,QUESTIONANSWERS.answer'); $this->db->FROM(QUESTIONANSWERS.' as QUESTIONANSWERS'); $this->db->WHERE('QUESTIONANSWERS.fk_question_id',$question['question_id']); $answers = $this->db->GET()->result_array(); @@ -266,6 +263,7 @@ class Template_Management_Model extends SPARQ_Model { return $questions; } + public function getCategoryGroupCombinations($question_category_id)