75 lines
2.3 KiB
PHP
75 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
use App\Models\PolicyGridModel;
|
|
use App\Models\PolicyPremium1Model;
|
|
use App\Models\PolicyPremium2Model;
|
|
|
|
class PolicesModel extends Model
|
|
{
|
|
protected $table = 'policies';
|
|
protected $primaryKey = 'id';
|
|
protected $allowedFields = [
|
|
"id",
|
|
"insurer_id",
|
|
"policy_type_id",
|
|
"name",
|
|
"created_by",
|
|
"updated_by",
|
|
"is_active",
|
|
];
|
|
|
|
public function getPolicyPremium($policy_id){
|
|
|
|
return $this->db->table('policies')
|
|
->select('policy_type.*')
|
|
->select('policies.name as policy_name')
|
|
->join('policy_type', 'policy_type.id = policies.policy_type_id')
|
|
->where('policies.id', $policy_id)
|
|
->get()
|
|
->getResult();
|
|
}
|
|
|
|
|
|
public function getPolicySlabRatesForEmpOnboard($policy_id,$client_id){
|
|
|
|
|
|
// $data = $this->getPolicyPremium($policy_id);
|
|
// $pattern = '/gmc/i';
|
|
// $subject = $data[0]->policy_type;
|
|
// if (preg_match($pattern, $subject)) {
|
|
// $search_term = 'GMC';
|
|
// } else {
|
|
// $search_term = 'GPA';
|
|
// }
|
|
|
|
|
|
$premium_slab_data = null;
|
|
// echo !isset($premium_slab_data);die();
|
|
// if($search_term === 'GPA'){
|
|
$policyPremium1Model = new PolicyPremium1Model();
|
|
$premium_slab_data = $policyPremium1Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll();
|
|
// dd($premium_slab_data);
|
|
if(is_array($premium_slab_data) && !count($premium_slab_data))
|
|
{
|
|
// echo '2';
|
|
$policyPremium2Model = new PolicyPremium2Model();
|
|
$premium_slab_data = $policyPremium2Model->where(['client_id' => $client_id, 'client_policy_id' => $policy_id, 'is_active' => 1])->findAll();
|
|
}
|
|
// }else{
|
|
;
|
|
// }
|
|
// dd($premium_slab_data);
|
|
// dd($policyPremium1Model->getLastQuery());
|
|
//get policy id
|
|
$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];
|
|
}
|
|
|
|
|
|
}
|