load->model('Common_Masters_Model'); $this->load->model('PD_Model'); $this->load->library('AWS_S3'); } /* For Save,Update and Retrieve all Master Tables*/ public function getListOfMaster_post() { $table_name = $this->post('master_name'); //echo $table_name; //$result = $this->Common_Masters_Model->selectRecords(constant($table_name)); $result = $this->Common_Masters_Model->selectCustomMasterRecords($table_name); //print_r($result); //die(); if(count($result) > 0) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } public function saveMaster_post() { $records = $this->post('records'); $table_name = $this->post('master_name'); if(false !== array_key_exists(constant($table_name.'ID'),$records)) //Update Record { $where_condition_array = array(constant($table_name.'ID') => $records[constant($table_name.'ID')]); $result = $this->Common_Masters_Model->updateRecords($records,constant($table_name),$where_condition_array); if($result) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $this->response($data,REST_Controller::HTTP_OK); } } else // Insert Record { $result = $this->Common_Masters_Model->saveRecords($records,constant($table_name)); if($result) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; $this->response($data,REST_Controller::HTTP_OK); } } } /* End Of Save,Update and Retrieve all Master Tables */ /* For Branch Listing */ public function getListOfBranches_get(){ $columns = array('m_city.name as city_name','BRANCH.*'); $table = BRANCH.' as BRANCH'; $joins = array( array( 'table' => 'm_city', 'condition' => 'BRANCH.fk_city_id = m_city.city_id ', 'jointype' => 'INNER' ) ); $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins); if(count($result) > 0) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } /* End Of Branch Master */ /* For Company Listing */ public function getListOfCompany_get(){ $columns = array('m_city.name as city_name','m_states.name as state_name','COMPANY.*'); $table = COMPANY.' as COMPANY'; $joins = array( array( 'table' => 'm_city', 'condition' => 'COMPANY.city = m_city.city_id ', 'jointype' => 'INNER' ), array( 'table' => 'm_states', 'condition' => 'COMPANY.state = m_states.state_id', 'jointype' => 'INNER' ) ); $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins); if(count($result) > 0) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } /* End of Company Listing */ /* For Product Listing */ public function getListOfSubProduct_get(){ $columns = array('m_products.name as product_name','SUBPRODUCTS.*'); $table = SUBPRODUCTS.' as SUBPRODUCTS'; $joins = array( array( 'table' => 'm_products', 'condition' => 'SUBPRODUCTS.fk_product_id = m_products.product_id', 'jointype' => 'INNER' ) ); $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins); if(count($result) > 0) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } /* End of Product Listing */ /* For State Listing */ public function getListOfState_get(){ $columns = array('m_regions.name as region_name','STATE.*'); $table = STATE.' as STATE'; $joins = array( array( 'table' => 'm_regions', 'condition' => 'STATE.fk_region_id = m_regions.region_id ', 'jointype' => 'INNER' ) ); $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins); if(count($result) > 0) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } /* End of State Listing */ /* For City Listing */ /** * Get PD Manage Function * sriram */ public function getPdManage_get() { $columns = array("PDTEAM.pdteam_id","PDTEAM.team_name","ENTITY.short_name"); $table = PDTEAM. ' as PDTEAM'; $joins = array( array('table'=>ENTITY.' as ENTITY', 'condition'=>'ENTITY.entity_id = PDTEAM.fk_lender_id and PDTEAM.isactive =1','jointype'=>'JOIN'), ); $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins); if(count($result) !=0){ foreach($result as $index=>$res){ /**CUSTOMERSEGMENT */ $columns = array("CUSTOMERSEGMENT.abbr"); $table = PDTEAMCUSTOMERSEGMENT. ' as PDTEAMCUSTOMERSEGMENT'; $joins = array( array('table'=>CUSTOMERSEGMENT.' as CUSTOMERSEGMENT', 'condition'=>'PDTEAMCUSTOMERSEGMENT.fk_cs_id = CUSTOMERSEGMENT.customer_segment_id and CUSTOMERSEGMENT.isactive =1','jointype'=>'LEFT'), ); $where_condition_array = array('PDTEAMCUSTOMERSEGMENT.fk_pdteam_id'=>$res['pdteam_id']); $result[$index]['CUSTOMERSEGMENT'] = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); /**CITY */ $columns = array("CITY.name"); $table = PDTEAMCITY.' as PDTEAMCITY'; $joins = array( array('table'=>CITY.' as CITY','condition'=>'PDTEAMCITY.fk_city_id = CITY.city_id and CITY.isactive = 1','jointype'=>'LEFT') ); $where_condition_array = array('PDTEAMCITY.fk_pdteam_id'=>$res['pdteam_id']); $result[$index]['CITYMAP'] = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); /**PRODUCT */ $columns = array("PRODUCTS.name","PRODUCTS.abbr"); $table = PDTEAMPRODUCT.' as PDTEAMPRODUCT'; $joins = array( array('table'=>PRODUCTS.' as PRODUCTS', 'condition'=>'PDTEAMPRODUCT.fk_product_id = PRODUCTS.product_id and PRODUCTS.isactive =1','jointype'=>'LEFT') ); $where_condition_array = array('PDTEAMPRODUCT.fk_pdteam_id'=>$res['pdteam_id']); $result[$index]['PRODUCTS'] = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); /**USERPROFILE */ $columns = array("USERPROFILE.userid,concat(USERPROFILE.first_name,' ',USERPROFILE.last_name)as user_full_name"); $table = USERPROFILE.' as USERPROFILE'; $joins = array( array('table'=>PDOFFICIERSDETAILS.' as PDOFFICIERSDETAILS','condition'=>'USERPROFILE.userid = PDOFFICIERSDETAILS.fk_user_id and USERPROFILE.isactive =1','jointype'=>'LEFT') ); $where_condition_array = array('PDOFFICIERSDETAILS.fk_team_id'=>$res['pdteam_id']); $result[$index]['USERPROFILE'] = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); } } //print_r($result);die; foreach($result as $parent_key=> $records) { //print_r($records['CITYMAP']); //print_r($result[$index]['CITYMAP']); $city_str = ""; $product_str =""; $cs_str = ""; foreach($records['CITYMAP'] as $CITY) { $city_str .= $CITY['name'].','; } foreach($records['PRODUCTS'] as $PRO) { $product_str .= $PRO['abbr'].','; } foreach($records['CUSTOMERSEGMENT'] as $CS) { $cs_str .= $CS['abbr'].','; } $result[$parent_key]['CITYMAP'] = $city_str; $result[$parent_key]['PRODUCTS'] = $product_str; $result[$parent_key]['CUSTOMERSEGMENT'] = $cs_str; } //print_r($result);die; if(count($result) > 0) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } /** * Save PD Team Manage * by sriram */ public function savePdTeamManage_post() { $records = $this->post('records'); // print_r($records); $result = array(); if(!empty($records)) { foreach($records['teamDetails'] as $users) { $record['fk_user_id'] = $users['userid']; $record['fk_team_id'] = $users['newTeamName']; $record['updatedon'] = $records['updatedon']; $record['fk_updatedby'] = $records['fk_updatedby']; $where_condition_array = array('fk_user_id' => $record['fk_user_id']); $result = $this->Common_Masters_Model->updateRecords($record,PDOFFICIERSDETAILS,$where_condition_array); //print_r($result); } } if(count($result)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } /** * End of the Function */ public function getListOfCity_get(){ $columns = array('m_states.name as state_name','CITY.*'); $table = CITY.' as CITY'; $joins = array( array( 'table' => 'm_states', 'condition' => 'CITY.fk_state_id = m_states.state_id ', 'jointype' => 'INNER' ) ); $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins); if(count($result) > 0) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } /* End of City Listing */ /* For only update PDAllocationType */ public function savePDAllocationType_post() { $records = $this->post('records'); $count = 0; foreach( $records as $record){ $where_condition_array = array('pd_allocation_type_id' => $record['pd_allocation_type_id']); $result = $this->Common_Masters_Model->updateRecords($record,PDALLOCATIONTYPE,$where_condition_array); if($result == 1) { $count++; } } if($count == count($records)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $this->response($data,REST_Controller::HTTP_OK); } } /**End of PD-Allocation-Type */ /** For Save Pd-Team-Details */ public function savePdTeam_post() { $records = $this->post('records'); if(false !== array_key_exists(PDTEAMID,$records)) //Update Record { $where_condition_array = array(PDTEAMID => $records[PDTEAMID]); //$pdTeamMaster = array('team_name'=>$records['team_name'],'updatedon'=>$records['updatedon'],'fk_updatedby'=>$records['fk_updatedby']); //pdteam_id, team_name, createdon, fk_createdby, updatedon, fk_updatedby, isactive $pdTeamMaster = array('team_name'=>$records['team_name'], 'updatedon'=>$records['updatedon'], 'fk_updatedby'=>$records['fk_updatedby'], 'fk_lender_id'=>$records['fk_lender']); $result = $this->Common_Masters_Model->updateRecords($pdTeamMaster,PDTEAM,$where_condition_array); //print_r($pdTeamMaster); if($result == true){ //$root_array = $records['temp_array']; $root_array_city = $records['fk_city']; $root_array_product = $records['fk_product']; $root_array_customersegment = $records['fk_customer_segment']; if(!empty($root_array_city)){ // foreach($root_array_city as $key => $value){ // $pdTeamForCity= array( // 'fk_city_id'=>$value, // 'fk_pdteam_id'=>$result); // $this->Common_Masters_Model->saveRecords($pdTeamForCity,PDTEAMCITY); // } // $fields = array('fk_city_id','fk_pdteam_id'); // $where_condition_array = array('fk_pdteam_id' => $records[PDTEAMID]); // $existing_city_data = $this->Common_Masters_Model->selectCustomRecords($fields,$where_condition_array,PDTEAMCITY); foreach($root_array_city as $city) { $result1 = $this->Common_Masters_Model->checkCityData($city,$records[PDTEAMID]); } } if(!empty($root_array_product)){ // foreach($root_array_product as $key => $value){ // $pdTeamForProduct = array( // 'fk_product_id'=>$value, // 'fk_pdteam_id'=>$result); // $this->Common_Masters_Model->saveRecords($pdTeamForProduct,PDTEAMPRODUCT); // } foreach($root_array_product as $product) { $result2 = $this->Common_Masters_Model->checkProductData($product,$records[PDTEAMID]); } } if(!empty($root_array_customersegment)){ // foreach($root_array_customersegment as $key => $value){ // $pdTeamForCS = array( // 'fk_cs_id'=>$value, // 'fk_pdteam_id'=>$result); // $this->Common_Masters_Model->saveRecords($pdTeamForCS,PDTEAMCUSTOMERSEGMENT); // } foreach($root_array_customersegment as $customersegment) { $result3 = $this->Common_Masters_Model->checkCustomerSegmentData($customersegment,$records[PDTEAMID]); } } // if(!empty($root_array)){ // foreach($root_array as $key => $value){ // $pdTeamChild = array( // 'fk_city_id'=>$value['cityid']['city_id'], // 'fk_team_id'=>$records['pdteam_id'], // 'team_type' => 1, // 'fk_lender_id' =>$value['lenderid']['entity_id']); // $this->Common_Masters_Model->saveRecords($pdTeamChild,PDTEAMMAP); // }} } if($result) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $this->response($data,REST_Controller::HTTP_OK); } } else // Insert Record { //$pdTeamMaster = array('team_name'=>$records['team_name'],'fk_createdby'=>$records['fk_createdby'],'createdon'=>$records['createdon']); $pdTeamMaster = array('team_name'=>$records['team_name'], 'fk_createdby'=>$records['fk_createdby'], 'createdon'=>$records['createdon'], 'fk_lender_id'=>$records['fk_lender'], 'team_type' => 1 ); $result = $this->Common_Masters_Model->saveRecords($pdTeamMaster,PDTEAM); if(!empty($result)){ //$root_array = $records['temp_array']; $root_array_city = $records['fk_city']; $root_array_product = $records['fk_product']; $root_array_customersegment = $records['fk_customer_segment']; // foreach($root_array as $key => $value){ // $pdTeamChild = array( // 'fk_city_id'=>$value['cityid']['city_id'], // 'fk_team_id'=>$result, // 'team_type' => 1, // 'fk_lender_id' =>$value['lenderid']['entity_id']); // $this->Common_Masters_Model->saveRecords($pdTeamChild,PDTEAMMAP); // } foreach($root_array_city as $key => $value){ $pdTeamForCity= array( 'fk_city_id'=>$value, 'fk_pdteam_id'=>$result); $this->Common_Masters_Model->saveRecords($pdTeamForCity,PDTEAMCITY); } foreach($root_array_product as $key => $value){ $pdTeamForProduct = array( 'fk_product_id'=>$value, 'fk_pdteam_id'=>$result); $this->Common_Masters_Model->saveRecords($pdTeamForProduct,PDTEAMPRODUCT); } foreach($root_array_customersegment as $key => $value){ $pdTeamForCS = array( 'fk_cs_id'=>$value, 'fk_pdteam_id'=>$result); $this->Common_Masters_Model->saveRecords($pdTeamForCS,PDTEAMCUSTOMERSEGMENT); } } if(!empty($result)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_SERVICE_UNAVAILABLE; $this->response($data,REST_Controller::HTTP_OK); } } } /** End Of Save PD-Team-Detail-Function */ /** For Of Delete PD-Team-Mapping-Detail-Function */ // public function deletePdTeamMapping_post() // { // $records = $this->post('records'); // foreach($records as $key => $value){ // //In Master - Have To The Record ( Updated on and Updated By ) // $where_condition_array1 = array(PDTEAMID => $value['fk_team_id']); // $pdTeamMaster = array( // 'fk_updatedby'=>$value['fk_updatedby'], // 'updatedon' =>$value['updatedon']); // $result1 = $this->Common_Masters_Model->updateRecords($pdTeamMaster,PDTEAM,$where_condition_array1); // //In child - Have To Delete The Record // $where_condition_array2 = array('pdteam_map_id'=>$value['pdteam_map_id']); // $pdTeamChild = array( // 'pdteam_map_id'=>$value['pdteam_map_id']); // $result2 = $this->Common_Masters_Model->deleteRecords($pdTeamChild,PDTEAMMAP,$where_condition_array2); // } // if($result1 == 1 && $result2 == 1) // { // $data['dataStatus'] = true; // $data['status'] = REST_Controller::HTTP_OK; // // $data['records'] = $result1; // $this->response($data,REST_Controller::HTTP_OK); // } // else // { // $data['dataStatus'] = false; // $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; // $this->response($data,REST_Controller::HTTP_OK); // } // } public function deletePdTeamMapping_post() { $where_condition_array = array('pdteam_city_id'=>$this->post('pdteam_city_id')); $pdTeamChild = array( 'pdteam_city_id'=>$this->post('pdteam_city_id')); $result = $this->Common_Masters_Model->deleteRecords($pdTeamChild,PDTEAMCITY,$where_condition_array); if($result == 1) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; // $data['records'] = $result1; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $this->response($data,REST_Controller::HTTP_OK); } } /**End of Delete PD-TEAM-MAPPING */ /* For Get List PD Notifications config's */ public function getPDNotificationsList_get() { $columns = array('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', 'PDNOTIFICATION.isactive'); $table = PDNOTIFICATION." as PDNOTIFICATION"; $joins = array( array('table' => PDSTATUS.' as PDSTATUS', 'condition' => 'PDNOTIFICATION.fk_pd_status_id = PDSTATUS.pd_status_id ', 'jointype' => 'INNER') ); $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins); if(count($result)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $this->response($data,REST_Controller::HTTP_OK); } } /* For Get PD Team Details (Master Table info)*/ // public function getListOfPDTeam_get() // { // $result = $this->Common_Masters_Model->pdteamlist(); // if(count($result) > 0) // { // $data['dataStatus'] = true; // $data['status'] = REST_Controller::HTTP_OK; // $data['records'] = $result; // $this->response($data,REST_Controller::HTTP_OK); // } // else // { // $data['dataStatus'] = false; // $data['status'] = REST_Controller::HTTP_NO_CONTENT; // $this->response($data,REST_Controller::HTTP_OK); // } // } /* End Of Get PD Team Details (Master Table info)*/ public function getListOfPDTeam_post(){ if(!empty($this->post())){ $PK = $this->post('primary_key') ; } else{ $PK = ''; } $columns = array('m_entity.full_name as lender_name','PDTEAM.*'); $table = PDTEAM.' as PDTEAM'; $joins = array( array( 'table' => 'm_entity', 'condition' => 'PDTEAM.fk_lender_id = m_entity.entity_id', 'jointype' => 'INNER' ) ); if($PK != '') { $where_condition_array = array('PDTEAM.pdteam_id'=>$PK); $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); if(count($result) !=0){ foreach($result as $index=>$res){ /**CUSTOMERSEGMENT */ $columns = array("CUSTOMERSEGMENT.*"); $table = PDTEAMCUSTOMERSEGMENT. ' as PDTEAMCUSTOMERSEGMENT'; $joins = array( array( 'table'=>CUSTOMERSEGMENT.' as CUSTOMERSEGMENT', 'condition'=>'PDTEAMCUSTOMERSEGMENT.fk_cs_id = CUSTOMERSEGMENT.customer_segment_id and CUSTOMERSEGMENT.isactive =1', 'jointype'=>'JOIN'), ); $where_condition_array = array('PDTEAMCUSTOMERSEGMENT.fk_pdteam_id'=>$PK); $result[$index]['CUSTOMERSEGMENT'] = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); /**CITY */ $columns = array("CITY.*"); $table = PDTEAMCITY.' as PDTEAMCITY'; $joins = array( array('table'=>CITY.' as CITY', 'condition'=>'PDTEAMCITY.fk_city_id = CITY.city_id and CITY.isactive = 1', 'jointype'=>'JOIN') ); $where_condition_array = array('PDTEAMCITY.fk_pdteam_id'=>$PK); $result[$index]['CITYMAP'] = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); /**PRODUCT */ $columns = array("PRODUCTS.*"); $table = PDTEAMPRODUCT.' as PDTEAMPRODUCT'; $joins = array( array('table'=>PRODUCTS.' as PRODUCTS', 'condition'=>'PDTEAMPRODUCT.fk_product_id = PRODUCTS.product_id and PRODUCTS.isactive =1', 'jointype'=>'JOIN') ); $where_condition_array = array('PDTEAMPRODUCT.fk_pdteam_id'=>$PK); $result[$index]['PRODUCTS'] = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); } } } else{ $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins); } if(count($result) > 0){ $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else{ $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } /** For validation purpose To Check duplication for Team*/ public function getListOfPDTeamCityMapping_get() { $columns = array('m_entity.full_name as lender_name','PDTEAM.*'); $table = PDTEAM.' as PDTEAM'; $joins = array( array( 'table' => 'm_entity', 'condition' => 'PDTEAM.fk_lender_id = m_entity.entity_id', 'jointype' => 'INNER' ) ); $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins); if(count($result) !=0){ foreach($result as $index=>$res){ /**CITY */ $columns = array("CITY.*"); $table = PDTEAMCITY.' as PDTEAMCITY'; $joins = array( array('table'=>CITY.' as CITY','condition'=>'PDTEAMCITY.fk_city_id = CITY.city_id and CITY.isactive = 1','jointype'=>'JOIN') ); $where_condition_array = array('PDTEAMCITY.fk_pdteam_id'=>$res['pdteam_id']); $result[$index]['CITYMAP'] = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); } } if(count($result) > 0){ $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else{ $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } /* For Get PD Team Mapping Details (Child Table info)*/ public function getListOfPDTeamMap_post(){ if(!empty($this->post())){ $PK = $this->post('primary_key'); } else{ $PK = ''; } $columns = array('m_city.name as city_name', 'm_entities.full_name as lender_name', 'm_pdteam.team_name as team_name', 'PDTEAMMAP.pdteam_map_id as pdteam_map_id', 'PDTEAMMAP.fk_city_id as fk_city_id', 'PDTEAMMAP.fk_team_id as fk_team_id', 'PDTEAMMAP.isactive as isactive', 'PDTEAMMAP.team_type as team_type', 'PDTEAMMAP.fk_lender_id as fk_lender_id'); $table = PDTEAMMAP.' as PDTEAMMAP'; $joins = array( array( 'table' => 'm_city', 'condition' => 'PDTEAMMAP.fk_city_id = m_city.city_id ', 'jointype' => 'INNER' ), array( 'table' => 'm_entities', 'condition' => 'PDTEAMMAP.fk_lender_id = m_entities.entity_id', 'jointype' => 'INNER' ), array( 'table' => 'm_pdteam', 'condition' => 'PDTEAMMAP.fk_team_id = m_pdteam.pdteam_id', 'jointype' => 'INNER' ) ); if($PK != '') { $where_condition_array = array('PDTEAMMAP.fk_team_id'=> $PK); $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); } else{ $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins); } if(count($result) > 0) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } /* End of Get PD Team Mapping Details (Child Table info)*/ /** * Company File Upload */ public function saveCompany_post(){ $records = json_decode($this->post('records'),true); if(!empty($_FILES['logo']['tmp_name'])) { $logo = $_FILES['logo']['tmp_name']; $logoname = $_FILES['logo']['name']; $logoname = strtolower($logoname); //$logos3path = ""; $logos3path = 'sineedge/'.$logoname; $bucketname = PROFILE_PICTURE_BUCKET_NAME; $key = $logos3path; $sourcefile = $logo; $bucket_data = array('bucket_name'=>$bucketname,'key'=>$key,'sourcefile'=>$sourcefile); $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); // print_r($s3result); if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { $records['logo'] = $logoname; } else { $records['logo'] = null; } } $result = $this->Common_Masters_Model->saveRecords($records,COMPANY); if($result != "" || $result != null) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } /** End Of CompanyDetail */ /* For Update PD Notification Details*/ public function savePDNotification_post(){ $records = $this->post('records'); //$count = 0; foreach( $records as $record){ $where_condition_array = array(PDNOTIFICATIONID => $record[PDNOTIFICATIONID]); $result = $this->Common_Masters_Model->updateRecords($record,PDNOTIFICATION,$where_condition_array); // if($result == 1) // { // $count++; // } } if($result) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $this->response($data,REST_Controller::HTTP_OK); } } /* End of Update PD Notification Details*/ public function getLender_post(){ $lender_id = $this->post('lender_id'); $columns = array('m_pdteam_city.*','PDTEAM.team_name as team_name','m_city.name as city_name'); $table = PDTEAM.' as PDTEAM'; $joins = array( array( 'table' => 'm_pdteam_city', 'condition' => 'PDTEAM.pdteam_id = m_pdteam_city.fk_pdteam_id', 'jointype' => 'INNER' ), array( 'table' => 'm_city', 'condition' => 'm_pdteam_city.fk_city_id = m_city.city_id ', 'jointype' => 'INNER' ) ); $where_condition_array = array('PDTEAM.fk_lender_id'=>$lender_id); $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); if(count($result) > 0) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } public function getProduct_post(){ $team_id = $this->post('team_id'); $columns = array('PRODUCTS.name as name','m_pdteam_product.*'); $table = PRODUCTS.' as PRODUCTS'; $joins = array( array( 'table' => 'm_pdteam_product', 'condition' => 'PRODUCTS.product_id = m_pdteam_product.fk_product_id and m_pdteam_product.isactive = 1', 'jointype' => 'INNER' ), ); $where_condition_array = array('m_pdteam_product.fk_pdteam_id'=>$team_id); $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); if(count($result) > 0) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } public function getCustomerSegment_post(){ $team_id = $this->post('team_id'); $columns = array('CUSTOMERSEGMENT.*','m_pdteam_customer_segment.*'); $table = CUSTOMERSEGMENT.' as CUSTOMERSEGMENT'; $joins = array( array( 'table' => 'm_pdteam_customer_segment', 'condition' => 'CUSTOMERSEGMENT.customer_segment_id = m_pdteam_customer_segment.fk_cs_id and m_pdteam_customer_segment.isactive = 1', 'jointype' => 'INNER' ), ); $where_condition_array = array('m_pdteam_customer_segment.fk_pdteam_id'=>$team_id); $result = $this->Common_Masters_Model->getJoinRecords($columns,$table,$joins,$where_condition_array); if(count($result) > 0) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $this->response($data,REST_Controller::HTTP_OK); } } public function getListOfPdTeamCityMapping(){ $records = $this->post('records'); //$count = 0; foreach( $records as $record){ $where_condition_array = array(PDNOTIFICATIONID => $record[PDNOTIFICATIONID]); $result = $this->Common_Masters_Model->updateRecords($record,PDNOTIFICATION,$where_condition_array); // if($result == 1) // { // $count++; // } } if($result) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $result; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $this->response($data,REST_Controller::HTTP_OK); } } public function checkAppVersion_get() { $client = $this->get('client'); $headersData = getallheaders(); $td = jwt::decode($headersData['Token']); $version_data = array(); //print_r($d);die(); $td = (array)($td); if($td['aud'] == '5dvpr90r2na4te5k0qrint0m5i' || $td['aud'] == '5kv697clegac0bcmd49o9di2t2' && ($td['custom:role_id'] == 21 || $td['custom:role_id'] == 22)) { $version_data = array("version_info_id" => "1","version" => "0.0.4","release_notes" => "Filed Visit"); } else { $version_data = $this->Common_Masters_Model-> getAppVersion($client); } if($version_data) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $version_data; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_MODIFIED; $this->response($data,REST_Controller::HTTP_OK); } } public function getCommonConfig_post() { $config['default_pd_list_count']['count'] = '60'; $config['default_pd_list_count']['factor'] = 'Days'; //Sales PD section to be fetch in SMC Credit PD section_id section_name $section_names = array(array('section_id' => '1','section_name' => 'General Section'),array('section_id' => '2', 'section_name'=> 'Fund Requirement'),array('section_id' => '3', 'section_name'=> 'stakeholders'),array('section_id' => '4', 'section_name' => 'Brief of business'),array('section_id' => '5', 'section_name' => 'Financial'),array('section_id' => '6', 'section_name' => 'Property Details'),array('section_id' => '7', 'section_name' => 'Final Remraks'),array('section_id' => '8', 'section_name' => 'Officer Details'),array('section_id' => '9', 'section_name' => 'Photography')); $config['sales_pd_section_to_fetch'] = $section_names; $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $config; $this->response($data,REST_Controller::HTTP_OK); } public function getServerInfo_get() { $this->load->library('Twlio'); $d = $this->twlio->getServerInfo(); if($d) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $d; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NO_CONTENT; $data['msg'] = 'Something went wrong!'; $this->response($data,REST_Controller::HTTP_OK); } } public function getVideoChatAccessKey_post() { $pd_id = $this->post('pd_id'); $random_key = $this->post('random_key'); $user_type = $this->post('user_type'); //echo $pd_id,$random_key,$user_type; $this->load->library('Twlio'); // $this->twlio->listOfRoomsByRoomName($roomName = 'Vp9F4o3thl2ZA9361233'); // $this->twlio->getRoomDataByRoomID($roomID = 'RM23b8d502434e46e696d1fbd5d64c59c8'); //$this->twlio->startComposistion($roomID = 'RM23b8d502434e46e696d1fbd5d64c59c8'); //die(); // $apiKeySecret = $this->twlio->getAPIKey(); // echo $apiKeySecret;die(); //if get API key sucessfully from twlio // if($apiKeySecret && is_array($apiKeySecret)) // { $roomName = $random_key.$pd_id; $temp = 0; if (is_numeric($user_type)){ // echo 'B4 '.gettype($user_type); $this->load->model('User_Management_Model'); $user_type = (int)$user_type; $userDetails = $this->User_Management_Model->getUserDetails($user_type); $creditManagerRoleId = (ENVIRONMENT == 'production' ? 26 : 26); $userRoleId = $userDetails["data"][0]['user_role']; $name = $userDetails["data"][0]['user_first_name'].$userDetails["data"][0]['user_last_name']; $officerName = strtoupper(preg_replace('/\s+/', '', $name)); $temp = ($userRoleId == $creditManagerRoleId) ? 0 : 1; }else{ $officerName = $user_type == 'PDOFFICER' ? 'PDOFFICER' : 'CUSTOMER'; $temp = 1; } if($temp == 1){ $videoAccessToken = $this->twlio->getVideoAccessJWTToken(TWILIO_API_KEY,TWILIO_API_KEY_SECRET,$roomName,$officerName); } if(!empty($videoAccessToken)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $videoAccessToken; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_INTERNAL_SERVER_ERROR; $data['msg'] = 'Couldn`t get access Token from Twlio '; $this->response($data,REST_Controller::HTTP_INTERNAL_SERVER_ERROR); } // } // else // { // $data['dataStatus'] = false; // $data['status'] = REST_Controller::HTTP_INTERNAL_SERVER_ERROR; // $data['msg'] = ' Couldn`t get API secret Key from Twlio '; // $this->response($data,REST_Controller::HTTP_INTERNAL_SERVER_ERROR); // } } public function uploadSMCDataFile_post() { $records = json_decode($this->post('records'),true); // print_r($records); $is_bucket_upload_sucess = false; $id = null; // echo date('Y-m-d_h:i:s'); // die(); if(!empty($_FILES['pd_excel_data'])) { $folder_to_check = XLPATH.'/tmp'; // $modified_fname = $records['rand_key'].'~'.str_replace(' ','_',($_FILES['pd_excel_data']['name'])); $modified_fname = str_replace(' ','_',($_FILES['pd_excel_data']['name'])); $modified_fname = (explode('.',$modified_fname)); // print_r($modified_fname);die(); $modified_fname = $modified_fname[0].'_'.date('Y-m-d_h-i-s').'.'.$modified_fname[1]; // echo $modified_fname; // die(); // #TEMP // $sourcefile = $folder_to_check.'/'.$modified_fname; // $result_data = readexceldata::getExcelSectionData($sourcefile); // print_r($result_data); // ##TEMP // die(); // var_dump($_FILES['pd_excel_data']);die(); $config = array('upload_path' => $folder_to_check,'overwrite' => TRUE,'allowed_types' => '*','file_name' => $modified_fname); $this->load->library('upload', $config); if($this->upload->do_upload('pd_excel_data')) { // print_r($_FILES['pd_excel_data']);//SMC_EXCEL_FILELIST // die(); $lender_id = ENVIRONMENT == 'production' ? 7 : 35; // $sourcefile = $folder_to_check.'/'.$modified_fname; $sourcefile = $folder_to_check.'/'.$modified_fname; // echo $sourcefile; $key = 'tmp/'.$modified_fname; $bucket_name = LENDER_BUCKET_NAME_PREFIX.$lender_id; //echo $modified_fname;die(); $bucket_data = array('bucket_name'=>$bucket_name,'key'=>$key,'sourcefile'=>$sourcefile); $s3result= $this->aws_s3->uploadFileToS3Bucket($bucket_data); // print_r($s3result); if(is_object($s3result) && $s3result['ObjectURL'] != '' && $s3result['@metadata']['statusCode'] == 200) { $fields_to_insert = array('file_name' => $_FILES['pd_excel_data']['name'],'modified_fname' => $modified_fname); if(isset($records['fk_pd_id']) && $records['fk_pd_id'] != '') { //update fk_pd_id in excel file list table $fields_to_insert['fk_pd_id'] = $records['fk_pd_id']; // disable old entries $this->Common_Masters_Model->updateRecords(array('isactive' => 0),SMC_EXCEL_FILELIST,array('fk_pd_id' => $records['fk_pd_id'])); //have to do disable key 'is_reupload_data_fetched' to 0 in section data table $this->Common_Masters_Model->updateRecords(array('is_reupload_data_fetched' => 0),SMC_CREDIT_PD_SECTION_DATA,array('fk_pd_id' => $records['fk_pd_id'])); } $is_bucket_upload_sucess = 1; //insert new records $id = $this->Common_Masters_Model->saveRecords($fields_to_insert,SMC_EXCEL_FILELIST); if(!isset($records['fk_pd_id'])) { //read excel file get trigger data $result_data = readexceldata::getExcelSectionData($sourcefile,null,null,$id); } unlink($sourcefile); } } else { log_message('ERROR','###File Upload Failed'.$modified_fname); } if($is_bucket_upload_sucess && $id) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['msg'] = 'File Uploaded Successfully'; $data['excel_file_id'] = $id; $data['records'] = isset($result_data) ? $result_data : array(); $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_FOUND; $data['msg'] = 'Something Wrong. Try Later!'; $this->response($data,REST_Controller::HTTP_OK); } } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_FOUND; $data['msg'] = 'No Data File Found!'; $this->response($data,REST_Controller::HTTP_OK); } } public function getSMCTempAddresses_get() { $pdid = $this->get('pdid'); if($pdid) { $pd_master_details = $this->PD_Model->getPDMasterDetails($pdid); // print_r($pd_master_details);die(); $file_id = isset($pd_master_details[0]['excel_file_id']) && $pd_master_details[0]['excel_file_id'] != '' ? $pd_master_details[0]['excel_file_id'] : $pdid; $addresses = $this->Common_Masters_Model->getSMCTempAddresses($file_id); $addresses[] = array('id' => null,'display' => 'Add New Address', 'is_others' => -1); if(count($addresses)) { $data['dataStatus'] = true; $data['status'] = REST_Controller::HTTP_OK; $data['records'] = $addresses; $this->response($data,REST_Controller::HTTP_OK); } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_FOUND; $data['msg'] = 'No Data Found!'; $this->response($data,REST_Controller::HTTP_OK); } } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_NOT_FOUND; $data['msg'] = 'No Data Found!'; $this->response($data,REST_Controller::HTTP_OK); } } public function saveNewSMCTempAddresses_post() { $records = $this->post('records'); // print_r($records); if(isset($records['pd_id'])) { $pd_master_details = $this->PD_Model->getPDMasterDetails($records['pd_id']); if(isset($pd_master_details[0]['excel_file_id']) && $pd_master_details[0]['excel_file_id'] != '') { $records['file_id'] = $pd_master_details[0]['excel_file_id']; } else { $records['file_id'] = $records['pd_id']; } unset($records['pd_id']); $id = $this->Common_Masters_Model->saveRecords($records,SMC_TEMP_ADDRESS); 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_FOUND; $data['msg'] = 'Something went wrong! Try Later !'; $this->response($data,REST_Controller::HTTP_OK); } } else { $data['dataStatus'] = false; $data['status'] = REST_Controller::HTTP_PARTIAL_CONTENT; $data['msg'] = 'Param missing..!'; $this->response($data,REST_Controller::HTTP_PARTIAL_CONTENT); } } } ?>