From 208364d806cffb7d21fb3ccc585625bde3d86561 Mon Sep 17 00:00:00 2001 From: Srinivas-Saravanan Date: Fri, 3 Jan 2025 12:05:21 +0530 Subject: [PATCH 1/2] FEAT_ZEPTO_MAIL_INTEGRATION --- app/Config/Routes.php | 2 + app/Controllers/MasterController.php | 30 +- app/Helpers/ExcelMergeHelper.php | 6 +- app/Helpers/GmailResponseHandler.php | 24 +- app/Helpers/MailHelper.php | 465 ++++++++++++++++++++------- composer.json | 6 +- 6 files changed, 404 insertions(+), 129 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 1b73489f..ba8c0f25 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -400,6 +400,7 @@ $routes->get("driveListFiles", "GoogleDriveController::listFiles"); $routes->post('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']); $routes->get('dmsSearch', 'PolicyTransactionController::dmsSearch', ['filter' => 'authMVC']); $routes->get('downloadGdriveFile', 'GoogleDriveController::downloadGdriveFile', ['filter' => 'authMVC']); +$routes->get('cli/sendZeptoMail', 'MasterController::testZeptoSMTP'); $routes->cli('cli/processjob', 'JobWorker::processJob'); $routes->cli('cli/processjobs', 'JobWorker::processJobs'); @@ -407,6 +408,7 @@ $routes->cli('cli/processjobs', 'JobWorker::processJobs'); $routes->get("processjob", "JobWorker::processJob"); $routes->cli('cli/new_gmail_token', 'MasterController::generateNewGmailAPIToken'); $routes->cli('cli/send_mail_cli', 'MasterController::testGmailAPIViaCLI'); +$routes->cli('cli/sendZeptoMail', 'MasterController::testZeptoSMTP'); $routes->cli('cli/check_bounce_mail_cli', 'MasterController::testCheckBounceMails'); $routes->cli('cli/app_check_list', 'MasterController::appCheckList'); $routes->cli('cli/new_gdrive_token', 'GoogleDriveController::generateNewGoogleDriveAccessToken'); diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index 6a81ebf5..d643952b 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -1641,7 +1641,35 @@ class MasterController extends AdminController print_r($res); } - + + public function testZeptoSMTP() { + $message = '

Request for Quotation (RFQ)

Dear {{RECIPIENT_NAME}},

We are reaching out to request a quotation for the following insurance coverage. Please review the details below and provide your quote at your earliest convenience.

RFQ Details

Client name{{CLIENT_NAME}}
Coverage Type{{POLICY_LONG_NAME}}
Policy Start Date{{POLICY_START_DATE}}
Policy Duration{{DURATION}}
Please note: Additional terms and details are included in the attachment for your reference.

Please feel free to reach out if you require any further information to prepare the quote. We look forward to receiving your proposal.

Best regards,

Nhance India Pvt Ltd

'; + $attachments = [ + ["filePath" => ROOTPATH."public/sample_excel/sample_addition.xls","fileName" => "sample_addition.xls"], + ["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"], + ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"] + ]; + $email_id = 'srinivas.saravanan@venbainfotech.com'; + $common = ['mail_type'=>'test_mail_cli']; + // Send email and get response + $result = MailHelper::send_email(['mail' => $email_id, 'subject' => 'Mail Via CLI', 'message' => $message,'attachments' => $attachments,'common'=>$common]); + + + log_message('error',json_encode($result)); + // Format the response for display/debugging + $response = [ + 'success' => $result['success'] ?? false, + 'smtp_data' => [ + 'last_reply' => $result['smtp_data']['last_reply'] ?? '', + 'error_info' => $result['smtp_data']['error_info'] ?? '' + ], + 'message_id' => $result['message_id'] ?? '', + 'timestamp' => $result['timestamp'] ?? '' + ]; + + // Return JSON response + return $this->response->setJSON($result); + } public function testCheckBounceMails() { $gmailapi = \Config\Services::gmailapi(); diff --git a/app/Helpers/ExcelMergeHelper.php b/app/Helpers/ExcelMergeHelper.php index fb593ec5..36306692 100644 --- a/app/Helpers/ExcelMergeHelper.php +++ b/app/Helpers/ExcelMergeHelper.php @@ -119,9 +119,9 @@ class ExcelMergeHelper { $newName = $sheetName; $counter = 1; - while ($mergedSpreadsheet->sheetNameExists($newName)) { - $newName = $sheetName . '_' . $counter++; - log_message('debug', "Sheet name already exists. Generating new name: {$newName}"); + while (in_array($newName, $mergedSpreadsheet->getSheetNames())) { + $newName = $sheetName . "_" . $counter++; + log_message('debug', "Sheet name already exists. Trying new name: {$newName}"); } // Clone the worksheet and set the new name diff --git a/app/Helpers/GmailResponseHandler.php b/app/Helpers/GmailResponseHandler.php index f2cb07f7..4a45f65c 100644 --- a/app/Helpers/GmailResponseHandler.php +++ b/app/Helpers/GmailResponseHandler.php @@ -77,17 +77,16 @@ class GmailResponseHandler{ } } } - if(isset($params['gmail_api']['status']) && $params['gmail_api']['status'] == 1 ){ - $data['gmail_api_status'] = isset($params['gmail_api']['status']) ? $params['gmail_api']['status'] : null; - $data['gmail_api_id'] = isset($params['gmail_api']['data']['id']) ? $params['gmail_api']['data']['id'] : null; - $data['received_message'] = isset($params['gmail_api']['data']['labelIds']) ? json_encode($params['gmail_api']['data']['labelIds']) : null; + if(isset($params['zepto_api']['data']) && $params['zepto_api']['message'] == 'OK' ){ + $data['gmail_api_status'] = isset($params['zepto_api']['data']) ? $params['zepto_api']['data'][0]['code'] : null; + $data['gmail_api_id'] = isset($params['zepto_api']['request_id']) ? $params['zepto_api']['request_id'] : null; + $data['received_message'] = isset($params['zepto_api']['data'][0]['message']) ? json_encode($params['zepto_api']['data'][0]['message']) : null; } - elseif(isset($params['gmail_api']['status']) && $params['gmail_api']['status'] == false ){ - $data['gmail_api_status'] = $params['gmail_api']['status']; - if(isset($params['gmail_api']['data'])){ - $data['received_message'] = json_encode($params['gmail_api']['data']); - } + elseif(isset($params['zepto_api']['error'])){ + $data['gmail_api_status'] = isset($params['zepto_api']['error']['code'])?$params['zepto_api']['error']['code']:null; + $data['received_message'] = json_encode($params['zepto_api']); + $data['gmail_api_id'] = isset($params['zepto_api']['error']['request_id']) ? $params['zepto_api']['error']['request_id'] : null; } $gmailModel = new GmailSentHistoryModel(); @@ -96,7 +95,9 @@ class GmailResponseHandler{ public function gmail_response_logger($params) { - $this->myLogger->logme('error',json_encode($params)); + if(isset($params['zepto_api']['error'])){ + $this->myLogger->logme('error',json_encode($params)); + } } public function client_id_flag_setter($params) @@ -119,7 +120,6 @@ class GmailResponseHandler{ $error = $e->getMessage(); $this->myLogger->logme('error','An Error Occured - '.$error); } - } - +} } \ No newline at end of file diff --git a/app/Helpers/MailHelper.php b/app/Helpers/MailHelper.php index 085c510f..91e955b0 100755 --- a/app/Helpers/MailHelper.php +++ b/app/Helpers/MailHelper.php @@ -1,177 +1,422 @@ setMailType('html'); +// $email->setFrom('bbone@venbait.in', 'Nhance'); + +// $email->setTo($emaill); + +// if (!empty($bcc)) { +// // Convert the comma-separated string into an array +// $bccList = explode(',', $bcc); +// // Trim whitespace from each email ID +// $bccList = array_map('trim', $bccList); +// // Set BCC recipients +// $email->setBCC($bccList); +// } + +// $email->setSubject($subject); + +// $email->setMessage($message); + +// if ($email->send()) { + +// return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...','data' => $emaill,],200); +// } else { +// $myLogger->logme('error', "mail sent failed - $emaill"); +// return json_encode(['status' => 'failed','code' => 404,'message'=>'Email Sent Failed...','data' => $emaill ],404); +// } + +// } catch (Exception $e) { +// $msg = $e->getMessage(); +// $myLogger->logme('error', "mail sent failed - $msg"); +// return json_encode(['status' => 'failed','code' => 500,'data' => $emaill],500); +// } +// } + +// public static function bulk_mail_smtp(array $mails = []) +// { +// // print_r();die; +// $model = new JobModel(); +// $start = microtime(true); +// $runtime= 0; +// try { +// foreach ( $mails as $index=>$mail) { +// $runtime = microtime(true) - $start; +// $send_mail = self::send_email($mail); +// } + +// return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200); + +// } catch (\Throwable $th) { +// return json_encode(['status' => 'failed','code' => 500],500); +// } +// } + +// //using GmailAPI +// public static function send_email($params) +// { + +// // print_r($params);die; +// $myLogger = \Config\Services::mylogger(); +// $gmailapi = \Config\Services::gmailapi(); + +// $emaill = $params['mail']; +// $subject = $params['subject']; +// $message = $params['message']; +// $attachments = isset($params['attachments']) && count($params['attachments']) ? $params['attachments'] : []; +// $common = isset($params['common'])?$params['common']:''; +// //check BCC mail +// if (isset($params['bcc'])) { +// $bcc = $params['bcc']; +// if(!is_array($bcc)){ +// $bcc = explode(',', $bcc); +// } +// }else{ +// $bcc = []; +// } + +// //check CC mail +// if (isset($params['cc'])) { +// $cc = $params['cc']; +// if(!is_array($cc)){ +// $cc = explode(',', $cc); +// } +// }else{ +// $cc = []; +// } + +// //check REPLY TO mail +// $reply_to = ""; +// if(isset($params['reply_to']) && !empty($params['reply_to'])){ +// $reply_to = $params['reply_to']; +// } +// $MailDataHelper = new GmailResponseHandler(); + +// $res['params'] = $params; +// try { + +// $res['gmail_api'] = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments); +// if($res['gmail_api']['status']) +// { +// $response = $res; +// $MailDataHelper->receive_and_distribute_param_to_functions($response); +// return json_encode(['status' => 'success','code' => 200, 'message'=>('Email Sent Successfully...'.$emaill),'data' => $res,],200); +// } +// else +// { +// $myLogger->logme('error', "mail sent failed - $emaill"); +// $response = $res; +// $MailDataHelper->receive_and_distribute_param_to_functions($response); +// return json_encode(['status' => 'failed','code' => 404,'message'=>( 'Email Sent Failed...' . $emaill ),'data' => $res ],404); +// } + +// } catch (Exception $e) { +// $msg['error'] = $e->getMessage(); +// $msg['params'] = $params; +// $myLogger->logme('error', "mail sent failed - $msg"); +// $response = $msg; +// $MailDataHelper->receive_and_distribute_param_to_functions($response); +// return json_encode(['status' => 'failed','code' => 500,'data' => $msg],500); +// } + + +// } + + +// public static function bulk_mail(array $mails = []) +// { +// // print_r($mails);die; +// $model = new JobModel(); +// $start = microtime(true); +// $runtime= 0; +// try { +// foreach ( $mails as $index=>$mail) { +// $runtime = microtime(true) - $start; +// $send_mail = self::send_email($mail); +// } + +// return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200); + +// } catch (\Throwable $th) { +// $error = $th->getMessage(); +// log_message('error',$error); +// return json_encode(['status' => 'failed','code' => 500,'error'=>$error],500); +// } +// } + +// } + + namespace App\Helpers; use Psr\Log\LoggerInterface; - use App\Controllers\BaseController; - -use PHPMailer\PHPMailer\PHPMailer; -use PHPMailer\PHPMailer\SMTP; -use PHPMailer\PHPMailer\Exception; - use App\Models\JobModel; class MailHelper { public static function send_email_smtp($params) { - - // print_r($params);die; $myLogger = \Config\Services::mylogger(); $emaill = $params['mail']; $subject = $params['subject']; $message = $params['message']; if (isset($params['bcc'])) { $bcc = $params['bcc']; - }else{ - $bcc= ''; + } else { + $bcc = ''; } + $from_address = getenv('email.fromEmail'); + + try { - - $email = \Config\Services::email(); - $email->setMailType('html'); - $email->setFrom('bbone@venbait.in', 'Nhance'); - - $email->setTo($emaill); + $curl = curl_init(); + $postData = [ + 'from' => [ + 'address' => $from_address + ], + 'to' => [ + [ + 'email_address' => [ + 'address' => $emaill + ] + ] + ], + 'subject' => $subject, + 'htmlbody' => $message + ]; + // Add BCC if present if (!empty($bcc)) { - // Convert the comma-separated string into an array $bccList = explode(',', $bcc); - // Trim whitespace from each email ID $bccList = array_map('trim', $bccList); - // Set BCC recipients - $email->setBCC($bccList); + $postData['bcc'] = array_map(function($email) { + return [ + 'email_address' => [ + 'address' => $email + ] + ]; + }, $bccList); } - $email->setSubject($subject); + curl_setopt_array($curl, [ + CURLOPT_URL => "https://api.zeptomail.in/v1.1/email", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => json_encode($postData), + CURLOPT_HTTPHEADER => [ + "accept: application/json", + "authorization: Zoho-enczapikey " . getenv('ZEPTO_API_KEY'), + "cache-control: no-cache", + "content-type: application/json", + ], + ]); - $email->setMessage($message); + $response = curl_exec($curl); + $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); + $err = curl_error($curl); - if ($email->send()) { + curl_close($curl); + if ($err) { + $myLogger->logme('error', "mail sent failed - $emaill"); + return json_encode(['status' => 'failed', 'code' => 404, 'message' => 'Email Sent Failed...', 'data' => $emaill], 404); + } - return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...','data' => $emaill,],200); + $apiResponse = json_decode($response, true); + + if ($httpCode === 200) { + return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...', 'data' => $emaill], 200); } else { $myLogger->logme('error', "mail sent failed - $emaill"); - return json_encode(['status' => 'failed','code' => 404,'message'=>'Email Sent Failed...','data' => $emaill ],404); + return json_encode(['status' => 'failed', 'code' => 404, 'message' => 'Email Sent Failed...', 'data' => $emaill], 404); } - - } catch (Exception $e) { + + } catch (\Exception $e) { $msg = $e->getMessage(); $myLogger->logme('error', "mail sent failed - $msg"); - return json_encode(['status' => 'failed','code' => 500,'data' => $emaill],500); - } + return json_encode(['status' => 'failed', 'code' => 500, 'data' => $emaill], 500); + } } public static function bulk_mail_smtp(array $mails = []) { - // print_r();die; $model = new JobModel(); $start = microtime(true); - $runtime= 0; - try { - foreach ( $mails as $index=>$mail) { + $runtime = 0; + try { + foreach ($mails as $index => $mail) { $runtime = microtime(true) - $start; $send_mail = self::send_email($mail); - } - - return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200); + } + + return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...'], 200); - } catch (\Throwable $th) { - return json_encode(['status' => 'failed','code' => 500],500); - } + } catch (\Throwable $th) { + return json_encode(['status' => 'failed', 'code' => 500], 500); + } } - //using GmailAPI - public static function send_email($params) + public static function send_email($params) { - - // print_r($params);die; $myLogger = \Config\Services::mylogger(); - $gmailapi = \Config\Services::gmailapi(); - + $emaill = $params['mail']; $subject = $params['subject']; $message = $params['message']; - $attachments = isset($params['attachments']) && count($params['attachments']) ? $params['attachments'] : []; - $common = isset($params['common'])?$params['common']:''; - //check BCC mail - if (isset($params['bcc'])) { - $bcc = $params['bcc']; - if(!is_array($bcc)){ - $bcc = explode(',', $bcc); - } - }else{ - $bcc = []; - } + $attachments = isset($params['attachments']) ? $params['attachments'] : []; + $common = isset($params['common']) ? $params['common'] : ''; - //check CC mail - if (isset($params['cc'])) { - $cc = $params['cc']; - if(!is_array($cc)){ - $cc = explode(',', $cc); - } - }else{ - $cc = []; - } - - //check REPLY TO mail - $reply_to = ""; - if(isset($params['reply_to']) && !empty($params['reply_to'])){ - $reply_to = $params['reply_to']; - } - $MailDataHelper = new GmailResponseHandler(); - - $res['params'] = $params; + $from_address = getenv('email.fromEmail'); try { - - $res['gmail_api'] = $gmailapi->sendMessage($emaill, $subject, $message, 'no-reply@nhanceindia.in', $reply_to, $cc, $bcc,$attachments); - if($res['gmail_api']['status']) - { - $response = $res; - $MailDataHelper->receive_and_distribute_param_to_functions($response); - return json_encode(['status' => 'success','code' => 200, 'message'=>('Email Sent Successfully...'.$emaill),'data' => $res,],200); - } - else - { - $myLogger->logme('error', "mail sent failed - $emaill"); - $response = $res; - $MailDataHelper->receive_and_distribute_param_to_functions($response); - return json_encode(['status' => 'failed','code' => 404,'message'=>( 'Email Sent Failed...' . $emaill ),'data' => $res ],404); - } - - } catch (Exception $e) { + $curl = curl_init(); + + $postData = [ + 'from' => [ + 'address' => $from_address + ], + 'to' => [ + [ + 'email_address' => [ + 'address' => $emaill + ] + ] + ], + 'subject' => $subject, + 'htmlbody' => $message + ]; + + // Handle attachments + if (!empty($attachments)) { + $postData['attachments'] = []; + foreach ($attachments as $attachment) { + if (isset($attachment['filePath']) && file_exists($attachment['filePath'])) { + // Determine MIME type dynamically + $fileMimeType = mime_content_type($attachment['filePath']); + + $postData['attachments'][] = [ + 'content' => base64_encode(file_get_contents($attachment['filePath'])), + 'name' => $attachment['fileName'], + 'mime_type' => $fileMimeType, // Add mime_type field + ]; + } + } + } + + + curl_setopt_array($curl, [ + CURLOPT_URL => "https://api.zeptomail.in/v1.1/email", + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 30, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "POST", + CURLOPT_POSTFIELDS => json_encode($postData), + CURLOPT_HTTPHEADER => [ + "accept: application/json", + "authorization: Zoho-enczapikey " . getenv('ZEPTO_API_KEY'), + "cache-control: no-cache", + "content-type: application/json", + ], + ]); + + $mail_result = curl_exec($curl); + $err = curl_error($curl); + curl_close($curl); + // log_message('error','inside mail helper'); + // log_message('error', $response.' error->'.$err);die(); + $res['params'] = $params; + $MailDataHelper = new GmailResponseHandler(); + $apiResponse = json_decode($mail_result, true); + $res['zepto_api'] = $apiResponse; + if (isset($apiResponse['error'])) { + $response = $res; + $MailDataHelper->receive_and_distribute_param_to_functions($response); + return json_encode([ + 'status' => 'failed', + 'code' => 404, + 'message' => 'Email Sent Failed...' . $emaill, + 'data' => $res + ], 404); + } + + // $apiResponse = json_decode($response, true); + + // Check if request_id exists in response (indicates success) + if (isset($apiResponse['data'])) { + $response = $res; + $MailDataHelper->receive_and_distribute_param_to_functions($response); + return json_encode([ + 'status' => 'success', + 'code' => 200, + 'message' => 'Email Sent Successfully...' . $emaill, + 'data' => $res + ], 200); + } + + } catch (\Exception $e) { $msg['error'] = $e->getMessage(); $msg['params'] = $params; - $myLogger->logme('error', "mail sent failed - $msg"); - $response = $msg; + $response = $res; $MailDataHelper->receive_and_distribute_param_to_functions($response); - return json_encode(['status' => 'failed','code' => 500,'data' => $msg],500); + return json_encode([ + 'status' => 'failed', + 'code' => 500, + 'data' => $msg + ], 500); } - - } - public static function bulk_mail(array $mails = []) { - // print_r($mails);die; $model = new JobModel(); $start = microtime(true); - $runtime= 0; - try { - foreach ( $mails as $index=>$mail) { + $runtime = 0; + try { + foreach ($mails as $index => $mail) { $runtime = microtime(true) - $start; $send_mail = self::send_email($mail); + } + + return json_encode(['status' => 'success', 'code' => 200, 'message' => 'Email Sent Successfully...'], 200); + + } catch (\Throwable $th) { + $error = $th->getMessage(); + log_message('error', $error); + return json_encode(['status' => 'failed', 'code' => 500, 'error' => $error], 500); } - - return json_encode(['status' => 'success','code' => 200, 'message'=>'Email Sent Successfully...'],200); - - } catch (\Throwable $th) { - $error = $th->getMessage(); - log_message('error',$error); - return json_encode(['status' => 'failed','code' => 500,'error'=>$error],500); - } } - } ?> \ No newline at end of file diff --git a/composer.json b/composer.json index 73453d9c..c456241c 100755 --- a/composer.json +++ b/composer.json @@ -17,15 +17,15 @@ "dompdf/dompdf": "^2.0", "firebase/php-jwt": "^6.10", "google/apiclient": "^2.15.0", + "kreait/firebase-php": "^7.0", "laminas/laminas-escaper": "^2.9", "php-amqplib/php-amqplib": "^2.8", "phpmailer/phpmailer": "^6.9", "phpoffice/phpspreadsheet": "^2.1", + "psr/http-message": "^1.0", "psr/log": "^1.1", "slim/slim": "^4.13", - "zircote/swagger-php": "^4.8", - "psr/http-message": "^1.0", - "kreait/firebase-php":"^7.0" + "zircote/swagger-php": "^4.8" }, "require-dev": { "codeigniter/coding-standard": "^1.7", From 9304e93928f5b66140085382cec79ec6d8243954 Mon Sep 17 00:00:00 2001 From: velz Date: Fri, 3 Jan 2025 13:52:33 +0530 Subject: [PATCH 2/2] CHNAGE_DELETION_HANDLED_IN_FILE --- app/Controllers/EmployeeServiceController.php | 12 +++++++++++- public/sample_excel/sample_deletion.xls | Bin 6656 -> 6656 bytes 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Controllers/EmployeeServiceController.php b/app/Controllers/EmployeeServiceController.php index ad476113..a924dd87 100755 --- a/app/Controllers/EmployeeServiceController.php +++ b/app/Controllers/EmployeeServiceController.php @@ -344,6 +344,15 @@ class EmployeeServiceController extends AdminController 'data_type' => 'str', 'format' => null, 'allowed_values' => null + ], + 'claim_status' => [ + 'col_idx' => 6, + 'col_cell_name' => 'G', + 'col_name' => 'Claim status', + 'is_mandatory' => ['D'], + 'data_type' => 'str', + 'format' => null, + 'allowed_values' => [0,1] ] ]; @@ -1334,6 +1343,7 @@ class EmployeeServiceController extends AdminController $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'date_of_exit','old_value' => $data['date_of_exit'],'new_value' => $row[4],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'reason_for_exit','old_value' => $data['reason_for_exit'],'new_value' => $row[5],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'status','old_value' => $data['status'],'new_value' => 'inactive','created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); + $this->empEndorsementModel->save(['pk' => (int)$data['emp_policy_id'],'emp_code' => $data['emp_code'],'table_name' => 'employee_polices','actions' => 'd','name' => $data['name'],'field_name' => 'claim_status','old_value' => $data['claim_status'],'new_value' => $row[6],'created_by' => $file['created_by'],'remarks' => 'general deletion','group_key' => $group_key,'file_id' => $file['id'],'status' => 'pending']); }; //iterate each row foreach ($excel_data as $col_key => $row) @@ -1368,7 +1378,7 @@ class EmployeeServiceController extends AdminController if(!in_array($employee['id'],$endorsement_data))//make entry in endorsement firsttime only with checking that PK of emp exisintg in variable $endorsement_data { $employee_policy = $this->employeePolicyModel->where('employee_id',$employee['id'])->where('client_policy_id',$file['policy_id'])->first(); - $data = ['emp_id' => $employee['id'],'name' => $employee['name'],'emp_status' => $employee['emp_status'],'emp_policy_id' => $employee_policy['id'],'emp_code' => $employee['emp_code'],'change_event' => $employee['change_event'],'date_of_exit' => $employee_policy['date_of_exit'],'reason_for_exit' => $employee_policy['reason_for_exit'],'status' => $employee_policy['status']]; + $data = ['emp_id' => $employee['id'],'name' => $employee['name'],'emp_status' => $employee['emp_status'],'emp_policy_id' => $employee_policy['id'],'emp_code' => $employee['emp_code'],'change_event' => $employee['change_event'],'date_of_exit' => $employee_policy['date_of_exit'],'reason_for_exit' => $employee_policy['reason_for_exit'],'status' => $employee_policy['status'],'claim_status' => $employee_policy['claim_status']]; $endorsement($data,$file,$row); $endorsement_data[] = $employee['id']; } diff --git a/public/sample_excel/sample_deletion.xls b/public/sample_excel/sample_deletion.xls index 8146a3df230fca6cce975ce70fcd7e1e1d0a4d1b..7bada1b5140593b51ff0f29dd17e8edc9c849496 100755 GIT binary patch delta 610 zcmZ8dL2DCH5dP-v=Iu7?W|K6HZ565X(AGA!mWm)^D}onKq995O23kRADzph$q$UMH zp%=-3=Nv3}Q`xJ99K3rGq4+oS;6dZevbf@Vyf^cG^L@jc*IDW;z3D&VkFA+9zfkd@O`zILSnSZEhYFy-wt@VLmE3Y zmT(F@43v@vQNkHX|K}X#*ekvWejzWp#V9Nv6elC?t{lk#;^(8{sc1;JXGS?IoZ(~9 zsY`Vx)di(YXHwl%X)+2@oqmY+yC*vRPVMI;I?JunYZ*|dONN29JXW6KId>>tDPN}i zB37h^D-S;N^Wh1iH~CuSCVz52{sEYxYZL$g delta 528 zcmZ9Iy-Nc@5XEQqF3EZM4(F*ch#`faQNaje5hElv8bKQoto$1c7({bc7B(Rx)>_yr z2UZFZgSCZP#Ln8n#==75?B$H$!S3w5`Mn2oR>sO)oO+YrtyXIk0A!UX&F=}fpOW=* zbslTlqj&=QSsTVgVWqIPusoo~;2eSg`TS)m8ClF?PfNp~8 zlnP}rU~h%|SngJBu`1v=Xm-pNOLv>!FfL{np3?nJaF z-0cgUS5d))`-X5_0zB-}sLH(V@^U>+a(RXM1T|MEulvE8nXVj4%46A1DV2;XW1!w8g+{F