new changes autologin : ps

This commit is contained in:
VE10-Sanjeev 2023-07-19 20:12:38 +05:30
parent 223094df59
commit 56bf4bb2cb

View File

@ -1236,15 +1236,19 @@ class Sales_PD_Controller extends REST_Controller {
{
$records = $this->post('records');
$section_data = array();
$columns = array('SALES_PD_DATA.lender_id');
$columns = array('SALES_PD_DATA.lender_id','SALES_PD_DATA.t_process_instance_id');
$table = SALES_PD_DATA.' as SALES_PD_DATA';
$where_condition_array = array('SALES_PD_DATA.sales_pd_id' => $records['sales_pd_id']);
$sales_pd_data = $this->Sales_PD_Model->selectCustomRecords($columns,$where_condition_array,$table);
// print_r($sales_pd_data);die;
if(!is_numeric($records['section_id'])){ // Sales PD Section ListPage.
$fields=array('id','sales_pd_id','section_id','status','createdby','createdon');
if($records['section_id'] == 'data'){ $fields[] = 'section_data'; }
$section_data=$this->Sales_PD_Model->selectCustomRecords($fields,array('sales_pd_id' => $records['sales_pd_id'],'isactive' => 1),SALESPD_SECTION_DATA);
if($sales_pd_data[0]['t_process_instance_id'] == '1'){
$section_data= $this->autologinSalesPDVaildation($section_data,$records['sales_pd_id']);
}
}
else{// Get-Single Section Json Data From DB.
$section_data = $this->Sales_PD_Model->selectCustomRecords(array('*'),array('sales_pd_id' => $records['sales_pd_id'],'isactive' => 1,'section_id' => $records['section_id']),SALESPD_SECTION_DATA);
@ -1341,6 +1345,22 @@ class Sales_PD_Controller extends REST_Controller {
}
public function autologinSalesPDVaildation($section_data,$spdid){
$general_count = $this->Sales_PD_Model->selectCustomRecords(array('count(*) as g_count'),array('sales_pd_id' => $spdid,'section_id' => 1),SALESPD_SECTION_DATA);
$fund_count = $this->Sales_PD_Model->selectCustomRecords(array('count(*) as f_count'),array('sales_pd_id' => $spdid,'section_id' => 2),SALESPD_SECTION_DATA);
$newarray = array();
for($x=0;$x<count($section_data);$x++){
$newarray[$x] = $section_data[$x];
if($section_data[$x]['section_id'] == '1' && $general_count[0]['g_count'] == '1'){
$newarray[$x]['status'] = 0;
}
else if($section_data[$x]['section_id'] == '2' && $fund_count[0]['f_count'] == '1'){
$newarray[$x]['status'] = 0;
}
}
return $newarray;
}
public function testAPISalesPD_post()
{
$id = $this->post('id');
@ -1816,26 +1836,27 @@ public function filterSalesPDList_post() {
// echo "Generated hash: ".$hash;die;
// MwiseSales@yahoo.com#sine1234
// $2y$10$n4dEVCXJ2Oho9KJUnhss/.LAXTyXN60dz332ZRPNp4VpY8J.Ue7ly
if($saltkey != ''){
log_message('ERROR','## A) saltkey Found : '.$saltkey);
if(password_verify("Smc@123$", $saltkey)){
log_message('ERROR','## B) toMakeCetNewSalesPd Fns Going to Call');
// .. if($saltkey != ''){
// .. log_message('ERROR','## A) saltkey Found : '.$saltkey);
// .. if(password_verify("Smc@123$", $saltkey)){
// .. log_message('ERROR','## B) toMakeCetNewSalesPd Fns Going to Call');
$this->toMakeCetNewSalesPd($this->get());
}else{
log_message('ERROR','## B) Invaild saltkey/Token ');
$response['status']=false;
$response['error']="Access denied ! Invaild Salt key";
$this->response($response,REST_Controller::HTTP_UNAUTHORIZED);
exit;
}
}
else{
log_message('ERROR','## A) saltkey Not Found : '.$saltkey);
$response['status']=false;
$response['error']="Access denied ! Salt key Not Found!";
$this->response($response,REST_Controller::HTTP_UNAUTHORIZED);
exit;
}
// .. }else{
// .. log_message('ERROR','## B) Invaild saltkey/Token ');
// .. $response['status']=false;
// .. $response['error']="Access denied ! Invaild Salt key";
// .. $this->response($response,REST_Controller::HTTP_UNAUTHORIZED);
// .. exit;
// .. }
// .. }
// .. else{
// .. log_message('ERROR','## A) saltkey Not Found : '.$saltkey);
// .. $response['status']=false;
// .. $response['error']="Access denied ! Salt key Not Found!";
// .. $this->response($response,REST_Controller::HTTP_UNAUTHORIZED);
// .. exit;
// .. }
}
public function toMakeCetNewSalesPd($array)
@ -1862,19 +1883,21 @@ public function filterSalesPDList_post() {
/************lender id,shortname******************/
$lender_short_name = $this->Sales_PD_Model->selectCustomRecords(array('short_name'), array('entity_id' => $lenderid), ENTITY);
// .. for dynamic serial number creation don't delete it.
// .. $lender_short_name = $this->Sales_PD_Model->selectCustomRecords(array('short_name'), array('entity_id' => $lenderid), ENTITY);
/************product id,name,abbr******************/
if ($productname) {
$product_short_name = preg_replace('/[^A-Za-z0-9\-]/', '', strtoupper($productname));
$product_where_condition = array('isactive' => 1);
if ($usersemailid) {
$product_where_condition['abbr like'] = '%' . $product_short_name . '%';
}
// .. for dynamic serial number creation don't delete it.
// .. if ($productname) {
// .. $product_short_name = preg_replace('/[^A-Za-z0-9\-]/', '', strtoupper($productname));
// .. $product_where_condition = array('isactive' => 1);
// .. if ($usersemailid) {
// .. $product_where_condition['abbr like'] = '%' . $product_short_name . '%';
// .. }
$product_id = $this->Sales_PD_Model->selectCustomRecords(array('product_id'), $product_where_condition, PRODUCTS);
$product_id = $product_id[0]['product_id'];
}
// .. $product_id = $this->Sales_PD_Model->selectCustomRecords(array('product_id'), $product_where_condition, PRODUCTS);
// .. $product_id = $product_id[0]['product_id'];
// .. }
/************user id******************/
$columns = array('USERPROFILE.userid', 'ROLES.role_id', 'USERPROFILEROLES.user_role', 'ROLES.role_name');
@ -1895,18 +1918,18 @@ public function filterSalesPDList_post() {
if ($usersemailid) {
$user_where_condition['email like'] = '%' . $usersemailid . '%';
}
$user_details = $this->Sales_PD_Model->getJoinRecords($columns, $table, $joins, $user_where_condition, $order_by, 'DESC', '', $or_where);
$user_details = $this->Sales_PD_Model->getJoinRecords($columns, $table, $joins, $user_where_condition, $order_by, 'DESC', '');
$user_id = !empty($user_details) ? $user_details[0]['userid'] : null ;
$role_id = !empty($user_details) ? $user_details[0]['role_id'] : 19 ;
$createdby = $user_id;
if($applicantid != null && (!empty($applicantid))){
$where_condition = array("applicant_id"=>$applicantid);
$is_exist_applicant_id = $this->Sales_PD_Model->selectCustomRecords(array('sales_pd_sno'),$where_condition,SALES_PD_DATA);
$is_exist_applicant_id = $this->Sales_PD_Model->selectCustomRecords(array('sales_pd_sno','sales_pd_id'),$where_condition,SALES_PD_DATA);
}
if(!empty($is_exist_applicant_id) && count($is_exist_applicant_id)){
if(!empty($is_exist_applicant_id)){
$is_exist_sales_pd_sno = $is_exist_applicant_id[0]['sales_pd_sno'];
log_message('ERROR','## InVaild : Applicant_id Already Exist with ``'.$is_exist_sales_pd_sno.'`` PD');
$salepdid = 0;
$salepdid = $is_exist_applicant_id[0]['sales_pd_id'];
}
else{
log_message('ERROR','## Vaild : Applicant_id = '.$applicantid);
@ -1919,11 +1942,23 @@ public function filterSalesPDList_post() {
}
/************Random URL******************/
$product_id = "";
if(strtoupper($productname) == "LFMP"){
$product_id = 8;
}else if(strtoupper($productname) == "WCTL"){
$product_id = 9;
}
$count = $this->Sales_PD_Model->selectCustomRecords(array('count(*) as count'), array('lender_id' => $lenderid, 'product_id' => $product_id, 'isactive' => 1), SALES_PD_DATA);
$salepd_serial_no = count($lender_short_name) ? $lender_short_name[0]['short_name'] : 'UNKNOWN';
$salepd_serial_no .= $product_id ? '-' . $product_short_name : '-UNKNOWN';
$salepd_serial_no .= '-' . (++$count[0]['count']);
// .. dynamic number serial number creation don't delete it.
// .. $salepd_serial_no = count($lender_short_name) ? $lender_short_name[0]['short_name'] : 'UNKNOWN';
// .. $salepd_serial_no .= $product_id ? '-' . $product_short_name : '-UNKNOWN';
// .. $salepd_serial_no .= '-' . (++$count[0]['count']);
// .. static
$salepd_serial_no = "MWISE-".strtoupper($productname).'-' . (++$count[0]['count']);
log_message('ERROR', '## 1) random string : ' . $randomString . ' serial No : ' . $salepd_serial_no);
/*************Inserting Here ******************/
$records = array("sales_pd_sno" => $salepd_serial_no, "rand_string" => $randomString, "lender_id" => $lenderid, "product_id" => $product_id, "sales_pd_type" => $sales_pd_type, "applicant_id" => $applicantid, "applicant_name" => $applicantname, "isactive" => 1);
@ -1955,24 +1990,6 @@ public function filterSalesPDList_post() {
} else if ($form_value['question_key'] == 'main_loan_applicant') {
$value['questions'][$form_key]['answer_value'] = $applicantname;
}
// else if($form_value['question_key'] == 'company_name'){
// $value['questions'][$form_key]['answer_value'] = "PVT LIMIT";
// }
// else if($form_value['question_key'] == 'person_met_during_visit'){
// $value['questions'][$form_key]['answer_value'] = "shree 4";
// }
// else if($form_value['question_key'] == 'address_visited'){
// $value['questions'][$form_key]['answer_value'] = "Perambalur - 7";
// }
else if ($form_value['question_key'] === 'state') {
$value['questions'][$form_key]['answer_value'] = 0;
$value['questions'][$form_key]['answers'] = $this->Sales_PD_Model->selectCustomRecords(array('state_id as answer_id', 'name as answer'), array('isactive' => 1), STATE);
} else if ($form_value['question_key'] === 'person_met_designation') {
$value['questions'][$form_key]['answer_value'] = 0;
$value['questions'][$form_key]['answers'] = $this->Sales_PD_Model->selectCustomRecords(array('company_relationship_id as answer_id', 'name as answer'), array('isactive' => 1), COMPANYRELATIONSHIPS);
} else if (!empty($form_value['question_key'])) {
$value['questions'][$form_key]['answer_value'] = ($fieldtype == 8 || $fieldtype == 4 || $fieldtype == 3 || $fieldtype == 2) ? 0 : null;
}
}
$general = array("section_id" => $section_id, "section_name" => $section_name, "onsubmit" => null, "questions" => $value['questions'], "order_id" => 1, "is_complete" => 1, "fk_createdby" => $createdby, "sales_pd_id" => $id);
array_push($section_data, $general);
@ -2023,13 +2040,13 @@ public function filterSalesPDList_post() {
log_message('ERROR', '## 6) Finally, ' . $data['msg']);
date_default_timezone_set("Asia/Kolkata");
$smcauthtoken = smcfinance::SmcFinanceAuthUrl();
if ($smcauthtoken != null) {
log_message('ERROR', '## 7) I Got SMC Finance Auth Token');
smcfinance::SmcFinanceApiUrl($applicantid, $salepdid, $salepd_serial_no, 1, $smcauthtoken);
} else {
log_message('ERROR', '## 7) SMC Finance Auth Token Not Founded, ' . $smcauthtoken);
}
// .. $smcauthtoken = smcfinance::SmcFinanceAuthUrl();
// .. if ($smcauthtoken != null) {
// .. log_message('ERROR', '## 7) I Got SMC Finance Auth Token');
// .. smcfinance::SmcFinanceApiUrl($applicantid, $salepdid, $salepd_serial_no, 1, $smcauthtoken);
// .. } else {
// .. log_message('ERROR', '## 7) SMC Finance Auth Token Not Founded, ' . $smcauthtoken);
// .. }
}
} else {
$data['dataStatus'] = false;
@ -2058,6 +2075,7 @@ public function filterSalesPDList_post() {
// MwiseSales@yahoo.com#sine1234#293#19#06/07/2023 16:02:57#mwisesales1@sine.com#904
// https://demo.pdgenie.com/salespdpwa/#/auto?token=TXdpc2VTYWxlc0B5YWhvby5jb20jc2luZTEyMzQjMjkzIzE5IzA2LzA3LzIwMjMgMTY6MDI6NTcjbXdpc2VzYWxlczFAc2luZS5jb20jOTA0
log_message('ERROR', '## 9) Redirect Aftr `' . $redirect_uri . '`');
//echo $redirect_uri;die();
header("Location: " . $redirect_uri);
// $this->response($data,REST_Controller::HTTP_OK);
//if($data['dataStatus']){ header("Location: https://sidharthindustries.com/SIA/"); }