FEAT_CREATE_FUNCTION_FOR_POLICY_TERMS : RV
This commit is contained in:
parent
3aaee53da7
commit
b0a0c6e02e
@ -12,6 +12,8 @@ $routes->get('/swagger', 'SwaggerController::index', ['filter' => 'authMVC']);
|
|||||||
// Reminder Mail Notification
|
// Reminder Mail Notification
|
||||||
|
|
||||||
$routes->get("reminder_mail", "NotificationController::reminder_mail");
|
$routes->get("reminder_mail", "NotificationController::reminder_mail");
|
||||||
|
$routes->get("testing", "ClientController::Testing");
|
||||||
|
$routes->get("update-policy-terms-for-corrections", "ClientController::updatePolicyTermsForCorrections");
|
||||||
|
|
||||||
|
|
||||||
$routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image");
|
$routes->post("add_advertise_image", "AppContentManagementController::add_advertise_image");
|
||||||
|
|||||||
@ -106,7 +106,47 @@ class ClientController extends AdminController
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function Testing()
|
||||||
|
{
|
||||||
|
$results = $this->clientPolicyModel
|
||||||
|
->select('id, policy_terms')
|
||||||
|
->where('policy_terms IS NOT NULL')
|
||||||
|
->where('policy_terms <>', '')
|
||||||
|
->whereNotIn('policy_type_id', [1, 6, 7])
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get()
|
||||||
|
->getResultArray();
|
||||||
|
|
||||||
|
foreach ($results as $key => $result) {
|
||||||
|
$client_policy_id = $result['id'];
|
||||||
|
$policy_terms = json_decode($result['policy_terms'], true); // true to get associative array
|
||||||
|
|
||||||
|
if (isset($policy_terms['family_floaters'])) {
|
||||||
|
$family_floaters = $policy_terms['family_floaters'];
|
||||||
|
$parents = $family_floaters['parents'] ?? 0;
|
||||||
|
$parents_in_law = $family_floaters['parents-in-law'] ?? 0;
|
||||||
|
|
||||||
|
if ($parents == 1 && $parents_in_law == 1) {
|
||||||
|
$policy_terms['family_floaters']['parents'] = 0;
|
||||||
|
$policy_terms['family_floaters']['parents-in-law'] = 0;
|
||||||
|
$policy_terms['family_floaters']['either-parents-pil'] = 2;
|
||||||
|
|
||||||
|
|
||||||
|
$results[$key]['policy_terms'] = json_encode($policy_terms);
|
||||||
|
|
||||||
|
// Update the policy_terms in the database
|
||||||
|
$this->clientPolicyModel
|
||||||
|
->where('id', $client_policy_id)
|
||||||
|
->set('policy_terms', $results[$key]['policy_terms'])
|
||||||
|
->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dd($results);
|
||||||
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
$this->myLogger->logme('error','Client list function called');
|
$this->myLogger->logme('error','Client list function called');
|
||||||
@ -123,8 +163,8 @@ class ClientController extends AdminController
|
|||||||
// $this->loadLayout('client_onboarding', $data);
|
// $this->loadLayout('client_onboarding', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateEmpAndPolicyStatus()
|
||||||
public function updateEmpAndPolicyStatus(){
|
{
|
||||||
|
|
||||||
$return = $this->clientPolicyModel->updateStatus();
|
$return = $this->clientPolicyModel->updateStatus();
|
||||||
$this->myLogger->logme('error', 'Client Policy Status Update Count: {data}', ['data' => $return['client']]);
|
$this->myLogger->logme('error', 'Client Policy Status Update Count: {data}', ['data' => $return['client']]);
|
||||||
@ -133,6 +173,57 @@ class ClientController extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function updatePolicyTermsForCorrections(){
|
||||||
|
|
||||||
|
$results = $this->clientPolicyModel
|
||||||
|
->select('id, policy_terms')
|
||||||
|
->where('policy_terms IS NOT NULL')
|
||||||
|
->where('policy_terms <>', '')
|
||||||
|
->whereNotIn('policy_type_id', [1, 6, 7])
|
||||||
|
->orderBy('id', 'desc')
|
||||||
|
->get()
|
||||||
|
->getResultArray();
|
||||||
|
|
||||||
|
|
||||||
|
$updated_data = [];
|
||||||
|
foreach ($results as $key => $result) {
|
||||||
|
$client_policy_id = $result['id'];
|
||||||
|
$policy_terms = json_decode($result['policy_terms'], true); // true to get associative array
|
||||||
|
|
||||||
|
if (isset($policy_terms['family_floaters'])) {
|
||||||
|
$family_floaters = $policy_terms['family_floaters'];
|
||||||
|
$parents = $family_floaters['parents'] ?? 0;
|
||||||
|
$parents_in_law = $family_floaters['parents-in-law'] ?? 0;
|
||||||
|
|
||||||
|
if ($parents == 1 && $parents_in_law == 1) {
|
||||||
|
|
||||||
|
$updated_data[] = $client_policy_id;
|
||||||
|
|
||||||
|
$policy_terms['family_floaters']['parents'] = 0;
|
||||||
|
$policy_terms['family_floaters']['parents-in-law'] = 0;
|
||||||
|
$policy_terms['family_floaters']['either-parents-pil'] = 2;
|
||||||
|
|
||||||
|
|
||||||
|
$results[$key]['policy_terms'] = json_encode($policy_terms);
|
||||||
|
|
||||||
|
// Update the policy_terms in the database
|
||||||
|
$this->clientPolicyModel
|
||||||
|
->where('id', $client_policy_id)
|
||||||
|
->set('policy_terms', $results[$key]['policy_terms'])
|
||||||
|
->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(count($updated_data) > 0){
|
||||||
|
echo 'There are ' . count($updated_data) . ' records to be updated.';
|
||||||
|
}else{
|
||||||
|
echo 'There is no records to be update.';
|
||||||
|
}
|
||||||
|
// dd($results);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function removeClient($id = null)
|
public function removeClient($id = null)
|
||||||
{
|
{
|
||||||
$this->myLogger->logme('error','Client Remove function called');
|
$this->myLogger->logme('error','Client Remove function called');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user