diff --git a/app/Config/Routes.php b/app/Config/Routes.php index c757962c..a82a9776 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -228,6 +228,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get("id-card", "EmployeeController::viewECard/$1"); $routes->get("preview-card/(:any)", "EmployeeController::previewTemplate/$1"); $routes->get("export-import-error-list/(:any)", "EmployeeController::errorListExportImport/$1"); + $routes->get("has_policy_config_completed/(:any)", "EmployeeController::hasPolicyConfigCompleted/$1"); }); $routes->cli('cli/processjob', 'JobWorker::processJob'); diff --git a/app/Controllers/EmployeeController.php b/app/Controllers/EmployeeController.php index 2409f694..0e9b4a3f 100644 --- a/app/Controllers/EmployeeController.php +++ b/app/Controllers/EmployeeController.php @@ -11,6 +11,7 @@ use Psr\Log\LoggerInterface; use App\Models\EmployeeModel; use App\Models\EmployeePolicyModel; use App\Models\ClientModel; +use App\Models\PolicesModel; use App\Models\FileModel; use App\Models\BatchListModel; use App\Models\BatchFileModel; @@ -49,6 +50,7 @@ class EmployeeController extends AdminController protected $empEndorsementModel; protected $clientPolicyModel; protected $TPAModel; + protected $policiesModel; public function __construct() { @@ -64,6 +66,7 @@ class EmployeeController extends AdminController $this->empEndorsementModel = new EmpEndorsementModel(); $this->clientPolicyModel = new ClientPolicyModel(); $this->TPAModel = new TPAModel(); + $this->policiesModel = new PolicesModel(); } public function list() @@ -1141,4 +1144,29 @@ class EmployeeController extends AdminController echo view('export_import_error_list', $excelErrorData); } + public function hasPolicyConfigCompleted() + { + $client_policy_id = $this->request->uri->getSegment(3); + $policy_details = $this->clientPolicyModel->find($client_policy_id); + // print_r($policy_details);die(); + $policy_terms = isset($policy_details['policy_terms']) ? true : false; + + $slab_details = $this->policiesModel->getPolicySlabRatesForEmpOnboard($client_policy_id,$policy_details['client_id']); + + $message = null; + + if (!isset($policy_terms)) { + $message .= 'Policy terms'; + } + + if($slab_details['slab_rates'] == null && $slab_details['grid_master'] == null) + { + $message = isset($message) ? ($message . ' and rack rates ') : ($message . ' Rack rates'); + } + $message = isset($message) ? ($message . ' not defined for choosed policy') : null; + + return $this->respond(['dataStatus' => true, 'code' => 200, 'message' => $message], 200); + + } + } diff --git a/app/Controllers/Jobs/SubJob.php b/app/Controllers/Jobs/SubJob.php index be74f0b8..35d9f8fd 100644 --- a/app/Controllers/Jobs/SubJob.php +++ b/app/Controllers/Jobs/SubJob.php @@ -8,6 +8,8 @@ class SubJob extends PublicController { public function handle($payload) { + $log = \Config\Services::mylogger(); + $log->logme('error', 'handle called'); return $payload['a'] - $payload['b']; } diff --git a/app/Models/PolicesModel.php b/app/Models/PolicesModel.php index d6a8182e..a56af6bc 100644 --- a/app/Models/PolicesModel.php +++ b/app/Models/PolicesModel.php @@ -39,6 +39,7 @@ class PolicesModel extends Model { $premium_slab_data = null; + $grid_type = null; $policyPremium1Model = new PolicyPremium1Model(); $premium_slab_data = $policyPremium1Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll(); @@ -50,9 +51,13 @@ class PolicesModel extends Model $premium_slab_data = $policyPremium2Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll(); } - $grid_id = $premium_slab_data[0]['policy_grid_id']; - $policyGridModel = new PolicyGridModel(); - $results = $policyGridModel->find($grid_id); - return ['slab_rates' => $premium_slab_data,'grid_master' => $results]; + if(isset($premium_slab_data[0]['policy_grid_id'])) + { + $grid_id = $premium_slab_data[0]['policy_grid_id']; + $policyGridModel = new PolicyGridModel(); + $grid_type = $policyGridModel->find($grid_id); + } + + return ['slab_rates' => $premium_slab_data,'grid_master' => $grid_type]; } } diff --git a/app/Views/employee_upload.php b/app/Views/employee_upload.php index d729ab25..64cbca65 100644 --- a/app/Views/employee_upload.php +++ b/app/Views/employee_upload.php @@ -38,7 +38,7 @@ option:disabled {

-
@@ -727,10 +727,70 @@ $(document).ready(function() { } } }); + }) }) +function checkPolicyTermsAndRackRatesHasDefiend(event) +{ + console.log(event.target.id); + var policy_id = (event.target.value); + console.log('checkPolicyTermsAndRackRatesHasDefiend called ' + policy_id); + var apiURL = '' + 'util/has_policy_config_completed/' + policy_id; + console.log(apiURL); + + $('.loader').fadeIn(); + $('.loader-mask').fadeIn(); + + + $.ajax({ + url: apiURL, + method: 'GET', + headers: { + "Content-Type": "application/json", + "X-Requested-With": "XMLHttpRequest" + }, + success: function(response) { + + setTimeout(function() { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + }, 1000); + + console.log('check policy responce', response); + + if (response.code === 200 && response.dataStatus === true && response.message !== null) { + toastr.error(response.message, 'Error'); + $('#emp_form_submit_button').prop('disabled', true); + return false; + } + else if(response.code === 200 && response.dataStatus === true && response.message == null) + { + // toastr.error('Policy Terms or rack rate not defined!', 'Error'); + $('#emp_form_submit_button').prop('disabled', false); + return true; + } + else + { + toastr.error('Policy Terms or rack rate not defined!', 'Error'); + return false; + } + }, + error: function(xhr, status, error) { + setTimeout(function() { + $('.loader').fadeOut(); + $('.loader-mask').delay(350).fadeOut('slow'); + }, 1000); + toastr.error('Something went wrong! Try Later', 'Error'); + console.error('Error fetching data from checkPolicyTermsAndRackRatesHasDefiend API:', error); + return false; + } + }); + +} + + //--------------------------------------------------------------------------------------------------------- \ No newline at end of file