92 lines
2.6 KiB
PHP
Executable File
92 lines
2.6 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class BatchFileModel extends Model
|
|
{
|
|
protected $table = 'batch_files';
|
|
protected $primaryKey = 'id';
|
|
protected $allowedFields = [
|
|
'id',
|
|
'client_id',
|
|
'client_policy_id',
|
|
'batch_code',
|
|
'file_name',
|
|
'insurer_or_tpa',
|
|
'event_type',
|
|
'actions',
|
|
'count',
|
|
'created_by',
|
|
'updated_by',
|
|
'is_active',
|
|
'amount',
|
|
'status',
|
|
'error_data',
|
|
'client_branch_id',
|
|
'policy_issue_date',
|
|
// ICICI Lombard GPA batch fields
|
|
'icici_correlation_id',
|
|
'icici_batch_id',
|
|
'icici_status_flag',
|
|
'icici_status_message',
|
|
'icici_endorsement_policy_no',
|
|
'icici_uhid_status_flag',
|
|
];
|
|
|
|
// Callbacks
|
|
protected $allowCallbacks = true;
|
|
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
|
protected $afterInsert = [];
|
|
protected $beforeUpdate = ["checkAndUpdateUpdatedByValue"];
|
|
protected $afterUpdate = [];
|
|
protected $beforeFind = [];
|
|
protected $afterFind = [];
|
|
protected $beforeDelete = [];
|
|
protected $afterDelete = [];
|
|
|
|
protected function checkAndADDCreatedByValue(array $data)
|
|
{
|
|
// Check if 'updated_by' value is null or empty
|
|
if (empty($data['data']['created_by'])) {
|
|
// Set 'updated_by' value to the current session user ID
|
|
$data['data']['created_by'] = get_session_userid();
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
protected function checkAndUpdateUpdatedByValue(array $data)
|
|
{
|
|
// Check if 'updated_by' value is null or empty
|
|
if (empty($data['data']['updated_by'])) {
|
|
// Set 'updated_by' value to the current session user ID
|
|
$data['data']['updated_by'] = get_session_userid();
|
|
}
|
|
|
|
return $data;
|
|
}
|
|
|
|
public function getBatchFilesDataForDocumentSearch($policy_id, $policy_doc_name)
|
|
{
|
|
$this->select('
|
|
"Imported Insurer or TPA Files" as doc_name,
|
|
batch_files.file_name,
|
|
batch_files.client_id,
|
|
batch_files.client_policy_id,
|
|
"uploads" as file_type
|
|
')
|
|
->where('batch_files.client_policy_id', $policy_id)
|
|
->where('batch_files.is_active', 1);
|
|
|
|
if (!empty($policy_doc_name)) {
|
|
$this->like('batch_files.file_name', $policy_doc_name);
|
|
}
|
|
|
|
return $this->get()->getResultArray();
|
|
}
|
|
|
|
|
|
}
|