883 lines
28 KiB
PHP
883 lines
28 KiB
PHP
<?php
|
|
/**
|
|
|
|
* User: velz
|
|
* This Controller deals with User Management CRUD Operations
|
|
*/
|
|
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
|
|
require_once APPPATH . '/libraries/REST_Controller.php';
|
|
|
|
|
|
class Entity_Management_Controller extends REST_Controller {
|
|
|
|
function __construct()
|
|
{
|
|
// Construct the parent class
|
|
parent::__construct();
|
|
$this->load->model('Entity_Management_Model');
|
|
$this->load->library('AWS_S3');
|
|
|
|
}
|
|
|
|
public function listAllEntites_get()
|
|
{
|
|
$page = 0;$limit = 0;$sort = 'ASC';$entity_type_id = '';$entity_id = '';
|
|
|
|
if($this->get('page')) { $page = $this->get('page'); }
|
|
if($this->get('limit')){ $limit = $this->get('limit'); }
|
|
if($this->get('sort')) { $sort = $this->get('sort'); }
|
|
if($this->get('etid')) { $entity_type_id = $this->get('etid'); }
|
|
|
|
$result = $this->Entity_Management_Model->listAllEntities($page,$limit,$sort,$entity_type_id,$entity_id);
|
|
if($result['data_status'])
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $result['data'];
|
|
$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 saveNewEntity_post()
|
|
{
|
|
$records = "";
|
|
$entity_id = "";
|
|
$bucket_status = "";
|
|
$cors_status = "";
|
|
|
|
if($this->post('records')){ $records = $this->post('records'); }
|
|
|
|
if(!isset($records['entity_id']))
|
|
{
|
|
$entity_id = $this->Entity_Management_Model->saveRecords($records,ENTITY);//insert user records and get entity_id
|
|
|
|
if($entity_id != '' || $entity_id != null)
|
|
{
|
|
|
|
// If New Entity is Lender(2) type, then create a S3 bucket for corresponding lender.
|
|
if($records['fk_entity_type_id'] == 2)
|
|
{
|
|
//echo "LENDER TYPE";
|
|
$bucket_name = LENDER_BUCKET_NAME_PREFIX.$entity_id;
|
|
$bucket_status = $this->aws_s3->createNewBucket($bucket_name);
|
|
if($bucket_status['Location'])
|
|
{
|
|
$cors_status = $this->aws_s3->setCors($bucket_name);
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
if($entity_id != '' || $entity_id != null)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['record'] = $entity_id;
|
|
$data['bucket_info'] = $bucket_status;
|
|
$data['cors_info'] = $cors_status;
|
|
$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
|
|
{
|
|
$where_condition_array = array('entity_id' => $records['entity_id']);
|
|
$entity_id = $this->Entity_Management_Model->updateRecords($records,ENTITY,$where_condition_array);
|
|
if($entity_id != '' || $entity_id != null)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['record'] = true;
|
|
$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);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
* Get Location Hierarchy as Region,state,city, and branch - wrapped as one array
|
|
*/
|
|
public function getLocationHierarchy_get()
|
|
{
|
|
$fields = array('region_id','name as region_name');
|
|
$where_condition_array = array('isactive' => 1);
|
|
$region_data = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,REGIONS);
|
|
|
|
if(count($region_data))
|
|
{
|
|
foreach($region_data as $region_key => $region)
|
|
{
|
|
$fields = array('state_id','name as state_name','code');
|
|
$where_condition_array = array('isactive' => 1,'fk_region_id'=>$region['region_id']);
|
|
$state_data = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,STATE);
|
|
|
|
|
|
if(count($state_data))
|
|
{
|
|
foreach($state_data as $state_key => $state)
|
|
{
|
|
$fields = array('city_id','name as city_name');
|
|
$where_condition_array = array('isactive' => 1,'fk_state_id' => $state['state_id']);
|
|
$city_data = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,CITY);
|
|
|
|
if(count($city_data))
|
|
{
|
|
foreach($city_data as $city_key => $city)
|
|
{
|
|
$fields = array('branch_id','name as branch_name');
|
|
$where_condition_array = array('isactive' => 1,'fk_city_id' => $city['city_id']);
|
|
$branch_data = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,BRANCH);
|
|
$city_data[$city_key]['branch_data'] = $branch_data;
|
|
}
|
|
$state_data[$state_key]['city_data'] = $city_data;
|
|
}
|
|
}
|
|
|
|
$region_data[$region_key]['state_data'] = $state_data;
|
|
}
|
|
}
|
|
}
|
|
|
|
if(count($region_data))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $region_data;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'Records Not Found';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
|
|
|
|
/****** Get All Entity Billing Info and it's contact info @param entity id******/
|
|
public function getEntityBillingInfo_get()
|
|
{
|
|
$entity_id = "";
|
|
if($this->get('eid')) { $entity_id = $this->get('eid'); }
|
|
|
|
if( $entity_id != "" || $entity_id != null)
|
|
{
|
|
|
|
$result = $this->Entity_Management_Model->getEntityBillingInfo($entity_id);
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public function getEntityMasterInfo_get()
|
|
{
|
|
$entity_id = "";
|
|
if($this->get('eid')) { $entity_id = $this->get('eid'); }
|
|
|
|
if( $entity_id != "" || $entity_id != null)
|
|
{
|
|
|
|
// $columns = array('ENTITY.entity_id, ENTITY.full_name, ENTITY.short_name');
|
|
// $table = array('');
|
|
// $joins = array();
|
|
// $where_condition_array = array();
|
|
$result = $this->Entity_Management_Model->listAllEntities(0,0,0,0,$entity_id);
|
|
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);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//entity_billing_id, fk_entity_id, billing_name, addressline1, addressline2, addressline3, pincode, email, mobileno, gstno, pan, gststatecode, isactive
|
|
public function saveEntityBillingInfo_post()
|
|
{
|
|
$records = "";
|
|
$child_records = "";
|
|
$count = "";
|
|
if($this->post('records')){ $records = $this->post('records'); }
|
|
//print_r($records);
|
|
if($records != "" || $records != null)
|
|
{
|
|
if($records['entity_billing_id'] != "" || $records['entity_billing_id'] != null)
|
|
{
|
|
//UPDATE
|
|
if(isset($records['contacts']))
|
|
{
|
|
$child_records = $records['contacts'];
|
|
unset($records['contacts']);
|
|
}
|
|
|
|
$where_condition_array = array('entity_billing_id' => $records['entity_billing_id']);
|
|
$entity_billing_id = $this->Entity_Management_Model->updateRecords($records,ENTITYBILLING,$where_condition_array);
|
|
|
|
if($entity_billing_id != "" || $entity_billing_id != null)
|
|
{
|
|
if($child_records != "" || $child_records != null)
|
|
{
|
|
foreach($child_records as $key => $child)
|
|
{
|
|
//print_r($child['entity_billing_contact_id']);
|
|
if($child['entity_billing_contact_id'] != "" ||$child['entity_billing_contact_id'] != null)
|
|
{
|
|
//echo "UPDATE";
|
|
$where_condition_array = array('entity_billing_contact_id' => $child['entity_billing_contact_id']);
|
|
$entity_billing_contact_id = $this->Entity_Management_Model->updateRecords($child,ENTITYBILLINGCONTACTINFO,$where_condition_array);
|
|
if($entity_billing_contact_id != "" || $entity_billing_contact_id != null){$count++;}
|
|
}
|
|
else
|
|
{
|
|
//echo "INSERT";
|
|
$child['fk_entity_billing_id'] = $records['entity_billing_id'];
|
|
$entity_billing_contact_id = $this->Entity_Management_Model->saveRecords($child,ENTITYBILLINGCONTACTINFO);
|
|
if($entity_billing_contact_id != "" || $entity_billing_contact_id != null){$count++;}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
if(($entity_billing_id != "" || $entity_billing_id != null) && $count == count($child_records))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = true;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = "Some Thing Went Wrong! Try Later";
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
//INSERT
|
|
if(isset($records['contacts']))
|
|
{
|
|
$child_records = $records['contacts'];
|
|
unset($records['contacts']);
|
|
}
|
|
$entity_billing_id = $this->Entity_Management_Model->saveRecords($records,ENTITYBILLING);
|
|
if($entity_billing_id != "" || $entity_billing_id != null)
|
|
{
|
|
if($child_records != "" || $child_records != null)
|
|
{
|
|
foreach($child_records as $key => $child)
|
|
{
|
|
$child['fk_entity_billing_id'] = $entity_billing_id;
|
|
$entity_billing_contact_id = $this->Entity_Management_Model->saveRecords($child,ENTITYBILLINGCONTACTINFO);
|
|
if($entity_billing_contact_id != "" || $entity_billing_contact_id != null){$count++;}
|
|
}
|
|
}
|
|
}
|
|
|
|
if(($entity_billing_id != "" || $entity_billing_id != null) && $count == count($child_records))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $entity_billing_id;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = "Some Thing Went Wrong! Try Later";
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
* Get Location Hierarchy as city and state - wrapped as one array for Lender Regions Mapping
|
|
*/
|
|
public function getCityHierarchy_get()
|
|
{
|
|
|
|
$cities = $this->Entity_Management_Model->getCityHierarchy();
|
|
|
|
if(count($cities))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $cities;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'Records Not Found';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
* Save Entity Regions Mapping
|
|
*/
|
|
public function saveEntityRegionMapping_post()
|
|
{
|
|
$count = 0;
|
|
$records = $this->post('records');
|
|
|
|
foreach($records as $key => $record)
|
|
{
|
|
|
|
if($record['entity_region_map_id'] != null || $record['entity_region_map_id'] != "")
|
|
{
|
|
|
|
$where_condition_array = array('entity_region_map_id' => $record['entity_region_map_id']);
|
|
$entity_region_map_id = $this->Entity_Management_Model->updateRecords($record,ENTITYREGION,$where_condition_array);
|
|
if($entity_region_map_id != "" || $entity_region_map_id != null){ $count++; }
|
|
}
|
|
else
|
|
{
|
|
|
|
$entity_region_map_id = $this->Entity_Management_Model->saveRecords($record,ENTITYREGION);
|
|
if($entity_region_map_id != "" || $entity_region_map_id != null){ $count++; }
|
|
}
|
|
}
|
|
|
|
if(count($records) == $count)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = true;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'Records Not Found';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/*Get Exist Mapped Region and City For Entity Edit Page*/
|
|
public function getEntityRegionCityMap_get()
|
|
{
|
|
$entity_id = $this->get('entityid');
|
|
$fields = array('fk_region_id','fk_city_id','fk_entity_id','entity_region_map_id','isactive');
|
|
$where_condition_array = array('fk_entity_id' => $entity_id);
|
|
$records = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,ENTITYREGION);
|
|
if($records != null || $records != "")
|
|
{
|
|
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $records;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'Records Not Found';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
* Save Vendor City Mapping
|
|
*/
|
|
public function saveVendorCityMapping_post()
|
|
{
|
|
$count = 0;
|
|
$records = $this->post('records');
|
|
|
|
// foreach($records as $key => $record)
|
|
// {
|
|
|
|
if($records['vendor_city_map_id'] != null || $records['vendor_city_map_id'] != "")
|
|
{
|
|
|
|
|
|
$where_condition_array = array('vendor_city_map_id' => $records['vendor_city_map_id']);
|
|
$vendor_city_map_id = $this->Entity_Management_Model->updateRecords($records,VENDORCITYMAP,$where_condition_array);
|
|
if($vendor_city_map_id != "" || $vendor_city_map_id != null){ $count++; }
|
|
}
|
|
else
|
|
{
|
|
|
|
$vendor_city_map_id = $this->Entity_Management_Model->saveRecords($records,VENDORCITYMAP);
|
|
if($vendor_city_map_id != "" || $vendor_city_map_id != null){ $count++; }
|
|
}
|
|
// }
|
|
|
|
if($vendor_city_map_id != "" || $vendor_city_map_id != null)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $vendor_city_map_id;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'Records Not Found';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/*Get Exist Mapped Vendor and City For Entity Edit Page*/
|
|
public function getVendorCityMap_get()
|
|
{
|
|
$entity_id = $this->get('entityid');
|
|
$fields = array('vendor_city_map_id', 'fk_vendor_id', 'fk_city_id', 'isactive');
|
|
$where_condition_array = array('fk_vendor_id' => $entity_id);
|
|
$records = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,VENDORCITYMAP);
|
|
if($records != null || $records != "")
|
|
{
|
|
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $records;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'Records Not Found';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//Save Branches Againest Lender - these branches used while PD Initation Screen
|
|
public function saveLenderBranches_post()
|
|
{
|
|
//entity_lender_branch_id, branch_name, isactive, createdon, updatedon, fk_createdby, fk_updatedby
|
|
|
|
$records = $this->post('records');
|
|
$count = 0;
|
|
//print_r($records);
|
|
foreach($records as $key => $record)
|
|
{
|
|
if($record['entity_lender_branch_id'] != null || $record['entity_lender_branch_id'] != "")
|
|
{
|
|
$where_condition_array = array('entity_lender_branch_id' => $record['entity_lender_branch_id']);
|
|
$id = $this->Entity_Management_Model->updateRecords($record,ENTITYLENDERBRANCH,$where_condition_array);
|
|
if($id != null || $id != ""){ $count++; }
|
|
}
|
|
else
|
|
{
|
|
$id = $this->Entity_Management_Model->saveRecords($record,ENTITYLENDERBRANCH);
|
|
if($id != null || $id != ""){ $count++; }
|
|
}
|
|
}
|
|
|
|
if($count != 0 && (count($records) == $count))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = true;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = "Something Went Wrong!Try Later";
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
|
|
|
|
public function listLenderBranches_get()
|
|
{
|
|
$entity_id = $this->get('entityid');
|
|
|
|
//Get Mapped Cities
|
|
$fields = array('fk_city_id', 'branch_name','isactive','fk_createdby','fk_entity_id','fk_updatedby','fk_city_id');
|
|
$where_condition_array = array('fk_entity_id' => $entity_id,'isactive'=>1);
|
|
$records = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,ENTITYLENDERBRANCH);
|
|
|
|
$columns = array('ENTITYREGION.fk_city_id','CITY.name');
|
|
$table = ENTITYREGION.' as ENTITYREGION';
|
|
$joins = array(array('table' => CITY. ' as CITY',
|
|
'condition' =>'ENTITYREGION.fk_city_id = CITY.city_id',
|
|
'jointype' => 'INNER'));
|
|
$where_condition_array = array('ENTITYREGION.isactive' => 1,'ENTITYREGION.fk_entity_id' => $entity_id);
|
|
$entity_city_details = $this->Entity_Management_Model->getJoinRecords($columns,$table,$joins,$where_condition_array);
|
|
//print_r($entity_city_details);
|
|
|
|
|
|
$fields = array('entity_lender_branch_id', 'branch_name','isactive','fk_createdby','fk_entity_id','fk_updatedby','fk_city_id');
|
|
$where_condition_array = array('fk_entity_id' => $entity_id,'isactive'=>1);
|
|
$records = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,ENTITYLENDERBRANCH);
|
|
|
|
|
|
|
|
|
|
|
|
if(count($entity_city_details))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = array('branch_details' => $records,'city_master' =>$entity_city_details);
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = "No Data Available";
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
|
|
|
|
public function getFullTATInfo_post()
|
|
{
|
|
//echo "dssd";
|
|
$records = $this->post('records');
|
|
$entity_id = $records['fk_entity_id'];
|
|
//$entity_tat_master_id = $records['entity_tat_master_id'];
|
|
//print_r($this->post('records'));
|
|
$fields = array('entity_tat_master_id', 'fk_entity_id', 'tat1', 'tat2');
|
|
$where_condition_array = array('fk_entity_id' => $entity_id,'isactive'=>1);
|
|
$tat_master_records = $this->Entity_Management_Model->selectCustomRecords($fields,$where_condition_array,ENTITYTAT);
|
|
|
|
if(count($tat_master_records))
|
|
{
|
|
foreach($tat_master_records as $tat_key => $tat)
|
|
{
|
|
$columns = array('entity_tat_child_id', 'fk_city_id','CITY.name as city_name','fk_pd_type_id','PDTYPE.type_name as pd_type_name','fk_product_id','PRODUCTS.name as prodcut_name' , 'fk_tat_master_id');
|
|
$table = ENTITYTATCHILD.' as ENTITYTATCHILD';
|
|
$joins = array(
|
|
array('table' => CITY. ' as CITY',
|
|
'condition' =>'ENTITYTATCHILD.fk_city_id = CITY.city_id',
|
|
'jointype' => 'INNER'),
|
|
array('table' => PRODUCTS. ' as PRODUCTS',
|
|
'condition' =>'ENTITYTATCHILD.fk_product_id = PRODUCTS.product_id',
|
|
'jointype' => 'INNER'),
|
|
array('table' => PDTYPE. ' as PDTYPE',
|
|
'condition' =>'ENTITYTATCHILD.fk_pd_type_id = PDTYPE.pd_type_id',
|
|
'jointype' => 'INNER')
|
|
|
|
);
|
|
$where_condition_array = array('ENTITYTATCHILD.isactive' => 1,'ENTITYTATCHILD.fk_tat_master_id' => $tat['entity_tat_master_id']);
|
|
$entity_tat_child = $this->Entity_Management_Model->getJoinRecords($columns,$table,$joins,$where_condition_array);
|
|
|
|
$final_child = array();
|
|
foreach($entity_tat_child as $child_key => $child)
|
|
{
|
|
$temp = array();
|
|
$temp['entity_tat_child_id'] = $child['entity_tat_child_id'];
|
|
$temp['city'] = array('id' => $child['fk_city_id'],'name' => $child['city_name']);
|
|
$temp['product'] = array('id' => $child['fk_product_id'],'name' => $child['prodcut_name']);
|
|
$temp['pd_type'] = array('id' => $child['fk_pd_type_id'],'name' => $child['pd_type_name']);
|
|
$final_child[] = $temp;
|
|
}
|
|
$tat_master_records[$tat_key]['child'] = $final_child;
|
|
|
|
}
|
|
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $tat_master_records;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = "No Data Available";
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public function saveTATInfo_post()
|
|
{
|
|
$records = $this->post('records');
|
|
$count = 0;
|
|
if($records['entity_tat_master_id'] == "" || $records['entity_tat_master_id'] == null)
|
|
{
|
|
$temp = array('fk_entity_id'=>$records['fk_entity_id'],'tat1'=>$records['tat1'],'tat2'=>$records['tat2'],'fk_createdby'=>$records['fk_createdby']);
|
|
$id = $this->Entity_Management_Model->saveRecords($temp,ENTITYTAT);
|
|
if($id != null || $id != "")
|
|
{
|
|
foreach($records['child'] as $key => $child)
|
|
{
|
|
$temp = array('fk_city_id'=>substr($child,0,1),'fk_product_id'=>substr($child,1,1),'fk_pd_type_id'=>substr($child,2,1),'fk_tat_master_id'=>$id);
|
|
$cid = $this->Entity_Management_Model->saveRecords($temp,ENTITYTATCHILD);
|
|
if($cid != "" || $cid != null) { $count++; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($count != 0 && ($count == count($records['child'])))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $count;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
$temp = array('fk_entity_id'=>$records['fk_entity_id'],'tat1'=>$records['tat1'],'tat2'=>$records['tat2'],'fk_updatedby'=>$records['fk_updatedby']);
|
|
$where_condition_array = array('entity_tat_master_id' => $records['entity_tat_master_id']);
|
|
$id = $this->Entity_Management_Model->updateRecords($temp,ENTITYTAT,$where_condition_array);
|
|
if($id != null || $id != "")
|
|
{
|
|
foreach($records['child'] as $key => $child)
|
|
{
|
|
$temp = array('fk_city_id'=>substr($child,0,1),'fk_product_id'=>substr($child,1,1),'fk_pd_type_id'=>substr($child,2,1),'fk_tat_master_id'=>$records['entity_tat_master_id']);
|
|
|
|
$cid = $this->Entity_Management_Model->saveRecords($temp,ENTITYTATCHILD);
|
|
if($cid != "" || $cid != null) { $count++; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($count != 0 && ($count == count($records['child'])))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $count;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
public function deleteTATCombimaion_post()
|
|
{
|
|
$records = $this->post('records');
|
|
|
|
$entity_tat_master_id = $records['entity_tat_master_id'];
|
|
$fk_entity_id = $records['fk_entity_id'];
|
|
$entity_tat_child_id_details = $records['entity_tat_child_id_details'];
|
|
|
|
$this->db->SET('isactive',0);
|
|
//$this->db->SET('fk_updatedby',$records['fk_updatedby']);
|
|
$this->db->where('fk_tat_master_id',$entity_tat_master_id);
|
|
//$this->db->where('fk_entity_id',$fk_entity_id);
|
|
$this->db->where_in('entity_tat_child_id',$entity_tat_child_id_details);
|
|
$this->db->update(ENTITYTATCHILD);
|
|
|
|
|
|
//print_r($this->db->last_query());
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = true;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
|
|
}
|
|
|
|
|
|
public function saveEntityPricingInfo_post()
|
|
{
|
|
$records = $this->post('records');
|
|
$count = 0;
|
|
foreach($records as $key => $record)
|
|
{
|
|
if($record['pricing_info_id'] != "" || $record['pricing_info_id'] != null)
|
|
{
|
|
|
|
$where_condition_array = array('pricing_info_id' => $record['pricing_info_id']);
|
|
$id = $this->Entity_Management_Model->updateRecords($temp,PRICINGINFO,$where_condition_array);
|
|
if($id != null || $id != "")
|
|
{
|
|
$count++;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$id = $this->Entity_Management_Model->saveRecords($record,PRICINGINFO);
|
|
if($id != null || $id != "")
|
|
{
|
|
$count++;
|
|
}
|
|
}
|
|
}
|
|
|
|
if($count != 0 && count($records) == $count)
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $count;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NOT_MODIFIED;
|
|
$data['msg'] = 'Something Went Wrong! Try Later...';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
|
|
|
|
public function listEntityPricingInfo_post()
|
|
{
|
|
$records = $this->post('records');
|
|
echo 'called';
|
|
$logger = MYLOG::logFunction();
|
|
$logger->info("CUSTOM SPECIFIC TEMPLATE ",array('PDID' => "sdfkhs"));
|
|
die();
|
|
|
|
$columns = array('ENTITY.short_name as lender_name', 'pricing_info_id', 'fk_lender_id', 'slab_name', 'from', 'to', 'full_pd_di', 'full_pd_ai', 'smart_pd', 'tele_pd', 'PRICINGINFO.isactive', 'PRICINGINFO.createdon', 'PRICINGINFO.updateon', 'PRICINGINFO.fk_createdby',' PRICINGINFO.fk_updatedby');
|
|
$table = PRICINGINFO.' as PRICINGINFO';
|
|
$joins = array(array('table' => ENTITY. ' as ENTITY',
|
|
'condition' =>'PRICINGINFO.fk_lender_id = ENTITY.entity_id',
|
|
'jointype' => 'INNER'));
|
|
$where_condition_array = array('PRICINGINFO.isactive' => 1,'PRICINGINFO.fk_lender_id' => $records['entity_id']);
|
|
$pricing_details = $this->Entity_Management_Model->getJoinRecords($columns,$table,$joins,$where_condition_array);
|
|
// print_r($this->db->last_query());
|
|
if(count($pricing_details))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $pricing_details;
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = 'No Records Found';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
|
|
public function saveEntityDisclaimer_post()
|
|
{
|
|
$records = $this->post('records');
|
|
$id = null;
|
|
if($records['entity_disclaimer_id'])
|
|
{
|
|
$id = $this->Entity_Management_Model->updateRecords($records,ENTITYDISCLAIMER,array('entity_disclaimer_id' => $records['entity_disclaimer_id']));
|
|
}
|
|
else
|
|
{
|
|
|
|
$id = $this->Entity_Management_Model->saveRecords($records,ENTITYDISCLAIMER);
|
|
}
|
|
|
|
if($id != null)
|
|
{
|
|
$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_NO_CONTENT;
|
|
$data['msg'] = 'Something Went Wrong! Try Later';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
}
|
|
|
|
public function getEntityDisclaimer_get()
|
|
{
|
|
$entity_id = $this->get('eid');
|
|
|
|
$res = $this->Entity_Management_Model->selectRecords(ENTITYDISCLAIMER,array('fk_entity_id' => $entity_id));
|
|
if(count($res))
|
|
{
|
|
$data['dataStatus'] = true;
|
|
$data['status'] = REST_Controller::HTTP_OK;
|
|
$data['records'] = $res[0];
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
else
|
|
{
|
|
$data['dataStatus'] = false;
|
|
$data['status'] = REST_Controller::HTTP_NO_CONTENT;
|
|
$data['msg'] = 'No Records Found';
|
|
$this->response($data,REST_Controller::HTTP_OK);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
} |