MERGE_DEV_TO_TEST_ISSUES_CD_CHANGES

This commit is contained in:
Venba 2024-06-13 09:13:33 +00:00
commit aa43f7b556
17 changed files with 768 additions and 65 deletions

View File

@ -36,6 +36,24 @@ Options -Indexes
# Ensure Authorization header is passed along
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/js "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
<IfModule !mod_rewrite.c>

View File

@ -42,6 +42,9 @@ class App extends BaseConfig
*/
public string $indexPage = 'index.php';
public $compressOutput = true;
/**
* --------------------------------------------------------------------------
* URI PROTOCOL

View File

@ -206,6 +206,14 @@ $routes->group("/master", ["filter" => "authMVC"], function ($routes) {
$routes->get("remove/(:any)", "MasterController::removePolicyPolicies/$1");
});
});
$routes->group("cash_deposite", ["filter" => "authMVC"], function ($routes) {
$routes->get("list", "MasterController::CDMasterList");
$routes->post("create", "MasterController::createCDMasterData");
$routes->post("edit", "MasterController::editCDMasterData");
$routes->get("list/(:any)", "MasterController::getCDMasterDataByID/$1");
// $routes->get("remove/(:any)", "MasterController::policyTypeRemove/$1");
});
});
@ -234,6 +242,8 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get("get-client-branch/(:any)", "ClientController::getClientBranch/$1");
$routes->get("get-client-details/(:any)", "ClientController::getClientAllDetailsByUsingClientID/$1");
$routes->get("delete-additional-rack-rate/(:any)", "ClientController::deleteAdditionalRackRate/$1");
$routes->get("check_cd_ac_no/(:any)", "MasterController::checkUniqueCDAccountNumber/$1");
$routes->get("get_cd_ac/(:any)", "ClientController::get_cd_ac/$1");
});
$routes->cli('cli/processjob', 'JobWorker::processJob');

View File

@ -31,6 +31,8 @@ use App\Models\PolicyPremium2Model;
use App\Models\EmployeeModel;
use App\Models\EmployeePolicyModel;
use App\Models\NotificationModel;
use App\Models\CDMasterModel;
@ -62,6 +64,8 @@ class ClientController extends AdminController
protected $employeeModel;
protected $employeePolicyModel;
protected $notificationModel;
protected $CDMasterModel;
public function __construct()
{
@ -90,6 +94,8 @@ class ClientController extends AdminController
$this->employeeModel = new EmployeeModel();
$this->employeePolicyModel = new EmployeePolicyModel();
$this->notificationModel = new NotificationModel();
$this->CDMasterModel = new CDMasterModel();
@ -200,13 +206,19 @@ class ClientController extends AdminController
public function view_Deposit($insurerId)
{
// Load your model to fetch data based on $clientId and $insurerId
// $subTypeOptions = [
// 1 => 'Deposit',
// 2 => 'Adjustment',
// 3 => 'Refund',
// 4 => 'Debit',
// ];
$subTypeOptions = [
1 => 'Deposit',
1 => 'Replenishment',
2 => 'Adjustment',
3 => 'Refund',
3 => 'Refund From Deletion',
4 => 'Debit',
// Add more options as needed
];
$data['subTypeOptions'] = $subTypeOptions;
$headerData['page_name'] = 'Client Deposit';
$data['insurerName']= $this->insurerModel->getInsurerName($insurerId);
@ -231,20 +243,33 @@ class ClientController extends AdminController
// Retrieve form data from POST request
$loggedInUserID = get_session_userid();
$client_id = $this->request->getPost('client_id');
$insurer_id = $this->request->getPost('insurer_id');
$CD_Account_Number = $this->CDMasterModel
->where('client_id', $client_id)
->where('insurer_id', $insurer_id)
->first();
// Prepare the array with data
$data = [
'amount' => $this->request->getPost('amount'),
'sub_type_id' => $this->request->getPost('sub_type_id'),
'client_id' => $this->request->getPost('client_id'),
'client_policy_id' => null,
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
'endorsement_no' => null,
'insurer_id' => $this->request->getPost('insurer_id'),
'description' => $this->request->getPost('description'),
'transaction_type' => $this->request->getPost('transaction_type') ?: 'Credit',
'updated_by' => 1, // You need to set the correct value for updated_by
'updated_by' => 1,
];
// Call the saveDeposit function from DepositHelper
$response = DepositHelper::saveDeposit($data, $loggedInUserID);
// Return a boolean value based on success
return $this->response->setJSON(['success' => $response['success']]);
}
@ -638,7 +663,8 @@ class ClientController extends AdminController
$data['base_policy'] = $this->request->getPost('base_policy');
$data['policy_status'] = 1;
$data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1;
$data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no');
@ -733,7 +759,8 @@ class ClientController extends AdminController
$data['base_policy'] = $this->request->getPost('base_policy');
$data['policy_status'] = 1;
$data['inception_type'] = $this->request->getPost('inception_type') ? 2 : 1;
$data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['client_branch_id'] = $this->request->getPost('client_branch_id');
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no');
@ -1140,9 +1167,10 @@ class ClientController extends AdminController
$client_id = $client_policy_data['client_id'];
$polices = $this->policesModel->where(['insurer_id' => $insurer_id, 'is_active' => 1])->findAll();
$client_policy_list = $this->clientPolicyModel->getpolicyWithPattern( $client_id );
$cd_data = $this->CDMasterModel->where('client_id', $client_id)->where('insurer_id', $insurer_id)->findAll();
return $this->respond(['status' => true,'code' => 200, 'client_policy_list' => $client_policy_list, 'data' => $client_policy_data, "insurer_id" => $client_policy_data['insurer_id'], 'policy' => $polices], 200);
return $this->respond(['status' => true,'code' => 200, 'client_policy_list' => $client_policy_list, 'data' => $client_policy_data, 'cd_data' => $cd_data, "insurer_id" => $client_policy_data['insurer_id'], 'policy' => $polices], 200);
}else{
return $this->respond(['status' => false,'code' => 404, 'message' => 'no data found'], 200);
}
@ -1942,10 +1970,6 @@ class ClientController extends AdminController
$data['client_policy'] = $client_policy;
$data['client_branch'] = $this->clientModel
->select('
@ -2120,5 +2144,17 @@ class ClientController extends AdminController
public function get_cd_ac($client_id, $insurer_id){
$cd_data = $this->CDMasterModel->where('client_id', $client_id)->where('insurer_id', $insurer_id)->findAll();
if($cd_data){
return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data], 200);
}else{
return $this->respond(['status' => false, 'code' => 404, 'insurer_id' => $insurer_id, 'client_id' => $client_id], 200);
}
}
}

View File

@ -24,6 +24,7 @@ use App\Models\ClientDepositModel;
use App\Models\NotificationModel;
use App\Models\MessageModel;
use App\Models\UserMessageModel;
use App\Models\CDMasterModel;
use App\Controllers\Jobs;
use App\Controllers\JobWorker;
@ -52,6 +53,8 @@ class EmpDataServiceController extends BaseController
protected $notificationModel;
protected $messageModel;
protected $userMessageModel;
protected $CDMasterModel;
public function __construct()
{
@ -70,6 +73,8 @@ class EmpDataServiceController extends BaseController
$this->notificationModel = new NotificationModel();
$this->messageModel = new MessageModel();
$this->userMessageModel = new UserMessageModel();
$this->CDMasterModel = new CDMasterModel();
}
@ -138,6 +143,11 @@ class EmpDataServiceController extends BaseController
$insurer_id = $this->clientPolicyModel->where('id', $export_data['client_policy_id'])->first();
$cash_balance = $this->clientDepositModel->where('client_id', $export_data['client_id'])->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first();
if($cash_balance == null){
$cash_balance = $this->CDMasterModel->where('client_id', $export_data['client_id'])->where('insurer_id', $insurer_id['insurer_id'])->orderBy('id', 'DESC')->first();
}
// Calculate the total amount from the objects
$totals = array_reduce($objects, function ($carry, $item) {
@ -1083,6 +1093,13 @@ class EmpDataServiceController extends BaseController
$batch_code = $file['batch_code'];
$user_id = $file['created_by'];
$insurer_id = $this->clientPolicyModel->where('id', $client_policy_id)->first();
$CD_Account_Number = $this->CDMasterModel
->where('client_id', $client_id)
->where('insurer_id', $insurer_id['insurer_id'])
->first();
$get_policy_type = $this->clientPolicyModel
->select('policy_type.policy_type, policies.policy_type_id as policy_type_id')
@ -1192,6 +1209,8 @@ class EmpDataServiceController extends BaseController
'employeeIds' => $emp_policy_ids,
'client_id' => $client_id,
'client_policy_id' => $client_policy_id,
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
'endorsement_no' => null,
'client_branch_id' => $client_branch_id,
'count' => $emp_count,
'event' => $file['event_type'],
@ -2095,6 +2114,13 @@ class EmpDataServiceController extends BaseController
$batch_code = $file['batch_code'];
$user_id = $file['created_by'];
$insurer_id = $this->clientPolicyModel->where('id', $client_policy_id)->first();
$CD_Account_Number = $this->CDMasterModel
->where('client_id', $client_id)
->where('insurer_id', $insurer_id['insurer_id'])
->first();
$status_val = 'success';
if ($status == 'in-progress-partially') {
@ -2113,7 +2139,7 @@ class EmpDataServiceController extends BaseController
$emp_policy_ids = [];
$employeeIds = [];
$emp_details = [];
$endorsement_id = [];
$endorsement_id = '';
$endorsement_details = [];
$totals = 0;
@ -2121,7 +2147,7 @@ class EmpDataServiceController extends BaseController
$emp_name = $value[1];
$emp_code = $value[2];
$endorsement_id[] = $value[19];
$endorsement_id = $value[19];
$totals += $value[18];
@ -2229,6 +2255,8 @@ class EmpDataServiceController extends BaseController
'client_id' => $client_id,
'client_policy_id' => $client_policy_id,
'client_branch_id' => $client_branch_id,
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
'endorsement_no' => $endorsement_id ?? null,
'count' => $emp_count,
'event' => $file['event_type'],
'policy_name' => $policy_name['policy_name'],
@ -2633,6 +2661,13 @@ class EmpDataServiceController extends BaseController
$batch_code = $file['batch_code'];
$user_id = $file['created_by'];
$insurer_id = $this->clientPolicyModel->where('id', $client_policy_id)->first();
$CD_Account_Number = $this->CDMasterModel
->where('client_id', $client_id)
->where('insurer_id', $insurer_id['insurer_id'])
->first();
$status_val = 'success';
if ($status == 'in-progress-partially') {
@ -2653,6 +2688,7 @@ class EmpDataServiceController extends BaseController
$emp_endorsement_table_data = [];
$employee_policy_table_data = [];
$employee_policy_table_primaryKey = [];
$endorsement_id = '';
$totals = 0;
@ -2662,6 +2698,7 @@ class EmpDataServiceController extends BaseController
$emp_name = $value[2]; //employee name
$emp_code = $value[1]; //employee code
$totals = $totals + $value[13];
$endorsement_id = $value[15];
$fetch_data = [
@ -2733,6 +2770,8 @@ class EmpDataServiceController extends BaseController
'client_id' => $client_id,
'client_policy_id' => $client_policy_id,
'client_branch_id' => $client_branch_id,
'cd_ac_no' => $CD_Account_Number['cd_ac_no'] ?? null,
'endorsement_no' => $endorsement_id ?? null,
'count' => $emp_count,
'event' => $file['event_type'],
'policy_name' => $policy_name['policy_name'],
@ -3176,6 +3215,9 @@ class EmpDataServiceController extends BaseController
'amount' => $amount->total_sum ?? 0,
'sub_type_id' => 4,
'client_id' => $arrayData['client_id'],
'client_policy_id' => $arrayData['client_policy_id'],
'endorsement_no' => $arrayData['endorsement_no'] ?? null,
'cd_ac_no' => $arrayData['cd_ac_no'] ?? null,
'insurer_id' => $insurer_id['insurer_id'],
'description' => $description,
'transaction_type' => 'Debit',
@ -3214,6 +3256,9 @@ class EmpDataServiceController extends BaseController
'amount' => $amount->total_sum,
'sub_type_id' => 4,
'client_id' => $arrayData['client_id'],
'client_policy_id' => $arrayData['client_policy_id'],
'endorsement_no' => $arrayData['endorsement_no'] ?? null,
'cd_ac_no' => $arrayData['cd_ac_no'] ?? null,
'insurer_id' => $insurer_id['insurer_id'],
'description' => $description,
'transaction_type' => 'Debit',
@ -3254,6 +3299,9 @@ class EmpDataServiceController extends BaseController
'amount' => $amount->total_sum,
'sub_type_id' => 3,
'client_id' => $arrayData['client_id'],
'client_policy_id' => $arrayData['client_policy_id'],
'endorsement_no' => $arrayData['endorsement_no'] ?? null,
'cd_ac_no' => $arrayData['cd_ac_no'] ?? null,
'insurer_id' => $insurer_id['insurer_id'],
'description' => $description,
'transaction_type' => 'Credit',

View File

@ -487,7 +487,7 @@ class EmployeeRestController extends AdminController
{
try {
$empData = $this->employeePolicyModel->getEmployeePolicy( client_id:$this->request->getGet('client_id'),policy_id: $this->request->getGet('client_policy_id'),status:0,branch_id:$this->request->getGet('client_branch_id'));
if ($empData) {
return $this->respond(['status' => 'success', 'code' => 200, 'data' => $empData], 200);
} else {

View File

@ -25,6 +25,7 @@ use App\Models\TPABranchModel;
use App\Models\TPAModel;
use App\Models\StateModel;
use App\Models\PolicyTypeModel;
use App\Models\CDMasterModel;
class MasterController extends AdminController
{
@ -45,6 +46,9 @@ class MasterController extends AdminController
protected $tpaModel;
protected $stateModel;
protected $policyTypeModel;
protected $CDMasterModel;
protected $clientModel;
public function __construct()
@ -68,6 +72,9 @@ class MasterController extends AdminController
$this->tpaModel = new TPAModel();
$this->stateModel = new StateModel();
$this->policyTypeModel = new PolicyTypeModel();
$this->CDMasterModel = new CDMasterModel();
$this->clientModel = new ClientModel();
}
public function insurerList()
@ -1111,4 +1118,103 @@ class MasterController extends AdminController
}
}
public function CDMasterList()
{
$data['CD_Master_Data'] = $this->CDMasterModel
->select('cd_master.*, clients.client_name, clients.short_name, insurers.name as insurer_name, user_profiles.first_name as user_name')
->join('clients', 'clients.id = cd_master.client_id')
->join('insurers', 'insurers.id = cd_master.insurer_id')
->join('user_profiles', 'user_profiles.id = cd_master.created_by')
->where('cd_master.is_active', 1)
->findAll();
$data['insurers'] = $this->insurerModel->findAll();
$data['clients'] = $this->clientModel->findAll();
$this->loadLayout('cd_master_list', $data);
}
public function createCDMasterData()
{
$data = $this->request->getPost();
$date = (string) $this->request->getPost('opening_date');
$data['opening_date'] = date('Y-m-d', strtotime($date));
if ($data) {
$insert = $this->CDMasterModel->insert($data);
if ($insert) {
session()->setFlashdata('success', "Cash Deposite Master Added Successfully");
return redirect()->to(base_url('/master/cash_deposite/list'));
} else {
session()->setFlashdata('error', "Cash Deposite Master Added Failed");
return redirect()->to(base_url('/master/cash_deposite/list'));
}
} else {
session()->setFlashdata('error', "Cash Deposite Master Added Failed. Data Not Found");
return redirect()->to(base_url('/master/cash_deposite/list'));
}
}
public function editCDMasterData($id = null)
{
$id = $this->request->getPost('PrimaryKey');
$date = (string) $this->request->getPost('opening_date');
$data = $this->request->getPost();
$data['opening_date'] = date('Y-m-d', strtotime($date));
if ($data) {
$insert = $this->CDMasterModel->where('id', $id)->set($data)->update();
if ($insert) {
session()->setFlashdata('success', "Cash Deposite Master Updated Successfully");
return redirect()->to(base_url('/master/cash_deposite/list'));
} else {
session()->setFlashdata('error', "Cash Deposite Master Update Failed");
return redirect()->to(base_url('/master/cash_deposite/list'));
}
} else {
session()->setFlashdata('error', "Cash Deposite Master Update Failed. Data Not Found");
return redirect()->to(base_url('/master/cash_deposite/list'));
}
}
public function getCDMasterDataByID($id = null)
{
$cd_data = $this->CDMasterModel->where('id', $id)->first();
$cd_data['opening_date'] = date('d-m-Y', strtotime($cd_data['opening_date']));
if ($cd_data) {
return $this->respond(['status' => true, 'code' => 200, 'data' => $cd_data], 200);
} else {
return $this->respond(['status' => false, 'code' => 404], 200);
}
}
public function checkUniqueCDAccountNumber($AccountNumber)
{
$uniqueAC = $this->CDMasterModel->where('cd_ac_no', $AccountNumber)->findAll();
if($uniqueAC != null){
return $this->respond(['status' => true, 'message' => 'The CD Account Number is Already Exist', 'code' => 200], 200);
}else{
return $this->respond(['status' => false, 'code' => 404], 200);
}
}
}

View File

@ -4,6 +4,7 @@
namespace App\Helpers;
use App\Models\ClientDepositModel;
use App\Models\CDMasterModel;
class DepositHelper
{
@ -49,6 +50,9 @@ class DepositHelper
'amount' => $data['amount'],
'sub_type' => $data['sub_type_id'],
'client_id' => $data['client_id'],
'client_policy_id' => $data['client_policy_id'],
'cd_ac_no' => $data['cd_ac_no'],
'endorsement_no' => $data['endorsement_no'],
'insurer_id' => $data['insurer_id'],
'description' => $data['description'],
'transaction_type' => $data['transaction_type'],
@ -90,7 +94,18 @@ class DepositHelper
$getLastBalanceQuery = "SELECT balance FROM cash_deposit WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
$getLastBalanceParams = [$clientId, $insurerId];
$lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance ?? 0;
$lastBalance = $model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->balance;
if(!$lastBalance){
$cd_model = new ClientDepositModel();
$getLastBalanceQuery = "SELECT opening_bal FROM cd_master WHERE client_id = ? AND insurer_id = ? ORDER BY created_at DESC LIMIT 1";
$getLastBalanceParams = [$clientId, $insurerId];
$lastBalance = $cd_model->query($getLastBalanceQuery, $getLastBalanceParams)->getRow()->opening_bal ?? 0;
}
return $lastBalance;
}

View File

@ -0,0 +1,64 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class CDMasterModel extends Model
{
protected $table = 'cd_master';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = [
'id',
'client_id',
'insurer_id',
'cd_ac_no',
'opening_bal',
'opening_date',
'created_at',
'updated_at',
'created_by',
'updated_by',
'is_active',
];
// 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;
}
}

View File

@ -22,6 +22,9 @@ class ClientDepositModel extends Model
"updated_at",
"description",
"balance",
"client_policy_id",
"cd_ac_no",
"endorsement_no",
];

View File

@ -42,7 +42,8 @@ class ClientPolicyModel extends Model
"date_of_exit",
"reason_for_exit",
"policy_no",
"client_branch_id"
"client_branch_id",
"cd_ac_no"
];
public function getClientPolicyById($id){
@ -182,18 +183,21 @@ class ClientPolicyModel extends Model
->select('cash_deposit.*')
->select('insurers.name as insurer_name, insurers.short_name as insurer_short')
->select('clients.client_name as clientname, clients.short_name as clientshort')
->select('policies.name as policy_name')
->select('user_profiles.first_name as username')
->join('user_profiles','user_profiles.id=cash_deposit.created_by')
->join('insurers', 'insurers.id = cash_deposit.insurer_id')
->join('clients', 'clients.id = cash_deposit.client_id')
->join('user_profiles', 'user_profiles.id = cash_deposit.created_by', 'left')
->join('insurers', 'insurers.id = cash_deposit.insurer_id', 'left')
->join('clients', 'clients.id = cash_deposit.client_id', 'left')
->join('client_policy', 'client_policy.id = cash_deposit.client_policy_id', 'left')
->join('policies', 'policies.id = client_policy.policy_id', 'left')
->where('cash_deposit.client_id', $clientId)
->where('cash_deposit.insurer_id', $insurerId) // Add this line to filter by insurer_id
->where('cash_deposit.insurer_id', $insurerId)
->orderBy('cash_deposit.id', 'DESC')
->get()
->getResult();
}
public function getDepositSummary($clientId, $insurerId)
{
// Fetch the sum of credit and debit transactions and calculate the balance

View File

@ -84,8 +84,8 @@ class EmployeePolicyModel extends Model
->join('policies pm', 'cp.policy_id = pm.id') //pm - policy master
->join('insurers im', 'cp.insurer_id = im.id') //im - insurar master
->join('insurer_branch ib', 'cp.insurer_branch_id = ib.id') //ib - insurar branch
->join('tpa tpam', 'cp.tpa_id = tpam.id') //tpam - tpa master
->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id') //tpab - tpa brach
->join('tpa tpam', 'cp.tpa_id = tpam.id','left') //tpam - tpa master
->join('tpa_branch tpab', 'cp.tpa_branch_id = tpab.id','left') //tpab - tpa brach
->join('clients cm', 'cp.client_id = cm.id') //cm - client master
->where('emp.client_id',$client_id)
->where('emp.client_branch_id',$branch_id)

View File

@ -0,0 +1,293 @@
<style>
.table th,
.table td {
padding: 8px;
}
table.dataTable tbody td {
padding: 4px 4px !important;
}
table.dataTable thead th {
padding: 4px 4px !important;
}
.col-12 {
max-width: 98% !important;
}
</style>
<div class="row" id="client_list">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row" style="margin-bottom:1rem;">
<div class="col-6" style="align-self: center;">
<h4 style="position: relative;">CD Master List</h4>
</div>
<div class="col-6" style="text-align: right; position: relative;top: 56px;">
<button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light"
data-toggle="modal" data-target="#con-close-modal" data-placement="top" title="Add"
data-trigger="hover">ADD</button>
</div>
</div>
<table class="table table-sm table-hover m-0 table-centered dt-responsive w-100" cellspacing="0"
id="tickets-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">Client Name</th>
<th class="font-weight-medium">Insurer Name</th>
<th class="font-weight-medium">Opening Date</th>
<th class="font-weight-medium">CD Account No</th>
<th class="font-weight-medium">Deposite Amount</th>
<th class="font-weight-medium">Date/User</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php foreach($CD_Master_Data as $row){ ?>
<tr>
<td><?php echo $row['client_name']; ?>( <?= $row['short_name'] ?> )</td>
<td><?php echo $row['insurer_name']; ?></td>
<td><?php echo date('d-m-Y', strtotime($row['opening_date'])); ?></td>
<td><?php echo $row['cd_ac_no']; ?></td>
<td><?php echo $row['opening_bal']; ?></td>
<td><?php echo date('d-M-Y h:i A', strtotime($row['created_at'])) ?> by
<?php echo $row['user_name']; ?></td>
<td>
<div class="btn-group dropdown">
<a href="javascript: void(0);"
class="dropdown-toggle arrow-none btn btn-light btn-sm" data-toggle="dropdown"
aria-expanded="false"><i class="mdi mdi-dots-horizontal"></i></a>
<div class="dropdown-menu dropdown-menu-right">
<a class="dropdown-item btnEdit" data-id="<?= $row['id'];?>" data-toggle="modal" data-target="#con-close-modal"> <i
class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div><!-- end col -->
</div>
<!-- end row -->
<!-- modal content -->
<div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true" data-backdrop="static" style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="title">Add Cash Deposite</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body p-4">
<div class="">
<form role="form" class="parsley-examples" method="post" id="CDMasterForm" action=""
enctype="multipart/form-data">
<input type="hidden" value="<?= csrf_hash() ?>" name="<?= csrf_token() ?>" />
<input type="hidden" name="PrimaryKey" id="CD_Master_ID" />
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label for="emp_code">Client<span class="text-danger">*</span></label>
<select class="form-control" id="client_id" name="client_id" required>
<option value="">Select Client</option>
<?php foreach($clients as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['client_name'] ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="profile">Insurer<span class="text-danger">*</span></label>
<select class="form-control" id="insurer_id" name="insurer_id" required>
<option value="">Select Insurer</option>
<?php foreach($insurers as $value) { ?>
<option value="<?= $value['id'] ?>"><?= $value['name'] ?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="email">Opening Date<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="opening_date" id="opening_date" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="mobile">CD Account Number<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="cd_ac_no" name="cd_ac_no" required>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-12">
<label for="mobile">Deposite Amount<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="opening_bal" name="opening_bal" required>
</div>
</div>
</div>
<div class="form-group text-right m-b-0">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1"
id="btnSubmit">Submit</button>
<!-- <button type="button" class="btn btn-secondry waves-effect waves-light mr-1" data-dismiss="modal" aria-hidden="true">Close</button> -->
</div>
</form>
</div>
</div>
</div>
</div>
</div><!-- /.modal -->
<script>
$(document).ready(function() {
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>" +
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>",
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'CD-Master-List',
className: 'my_class',
exportOptions: {
columns: ':not(:last-child)'
},
}],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true,
});
})
$(document).ready(function(){
<?php if (session()->has('error')) : ?>
toastr.error('<?= session()->getFlashdata('error') ?>', 'Failed');
<?php endif; ?>
<?php if (session()->has('success')) : ?>
toastr.success('<?= session()->getFlashdata('success') ?>', 'success');
<?php endif; ?>
var endDatePicker = flatpickr("#opening_date", {
dateFormat: "d-m-Y",
// defaultDate: endDate,
allowInput: false
});
$('#client_id').select2();
$('#insurer_id').select2();
})
$('#btnAdd').click(function(){
$('#client_id').val('');
$('#insurer_id').val('');
$('#opening_date').val('');
$('#cd_ac_no').val('');
$('#opening_bal').val('');
$('#CDMasterForm').attr('action', '<?php echo base_url('master/cash_deposite/create');?>');
$('#title').html('Add Cash Deposite');
$('#btnSubmit').html('Submit');
})
$('.close').click(function(){
$('#CD_Master_ID').val('');
$('#client_id').val('').change();
$('#insurer_id').val('').change();
$('#opening_date').val('');
$('#cd_ac_no').val('');
$('#opening_bal').val('');
$('#CDMasterForm')[0].reset();
$('#CDMasterForm').parsley().reset();
})
$('body').on('click', '.btnEdit', function () {
var cd_id = $(this).attr('data-id');
$('#title').html('Update Cash Deposite');
$.ajax({
url: '<?php echo base_url('master/cash_deposite/list/');?>'+cd_id,
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res)
$('#updateModal').modal('show');
$('#CDMasterForm').attr('action', '<?php echo base_url('master/cash_deposite/edit');?>');
$('#CD_Master_ID').val(res.data.id);
$('#client_id').val(res.data.client_id).change();
$('#insurer_id').val(res.data.insurer_id).change();
$('#opening_date').val(res.data.opening_date);
$('#cd_ac_no').val(res.data.cd_ac_no);
$('#opening_bal').val(res.data.opening_bal);
$('#btnSubmit').html('Update');
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
});
$('#cd_ac_no').change(function(){
var cd_ac_no = $(this).val();
$.ajax({
url: '<?php echo base_url('util/check_cd_ac_no/');?>'+cd_ac_no,
type: "GET",
dataType: 'json',
success: function (res) {
console.log(res)
if(res.status == true){
toastr.warning(res.message, 'warning');
$('#cd_ac_no').val('');
}
},
error: function (xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
})
</script>

View File

@ -121,13 +121,22 @@
<div class="form-row" id="third" style="display: none; position: relative;top: 22px;">
<label class="switch">
<input id="inception_type" type="checkbox" name="inception_type">
<span class="slider round" style="height: 27px;"></span>
</label>
<div class="form-group col-md-4">
<label for="mobile">CD Account Number<span id="tpa_danger" class="text-danger">*</span></label>
<select class="form-control" id="cd_ac_no" name="cd_ac_no" required>
<option value="">Select CD Account Number</option>
</select>
</div>
<label for="inception_type" style="position: relative;bottom: 5px;left: 10px;">Enable
Employee Enrolment Process</label>
<div class="form-group col-md-4">
<label class="switch" style="position: relative;top: 43px;left: 20px;">
<input id="inception_type" type="checkbox" name="inception_type">
<span class="slider round" style="height: 27px;"></span>
</label>
<label for="inception_type" style="position: relative;bottom: 5px;left: 85px;">Enable
Employee Enrolment Process</label>
</div>
</div>
<div id="policy_fields"></div>
@ -521,10 +530,13 @@
$(document).ready(function() {
/********* To get the POLICY base on Insurer *******/
$('#insurer').change(function() {
var id = $(this).val();
var client_id = $('#client_id_policy').val()
var parts = id.split('-');
var secondPart = parts[1];
var url = "<?= base_url("util/police-by-insurer/") ?>" + secondPart;
var url_for_cd = "<?= base_url("util/get_cd_ac/") ?>" + client_id + '/' + secondPart;
var selectedOption = $('#base_policy').find(':selected');
var base_policy_data_id = selectedOption.data('id');
@ -597,6 +609,26 @@
console.error(xhr.responseText);
console.error(status, error);
});
$.get(url_for_cd, function(response){
console.log(response)
console.log(response.data)
if(response.status == false && response.insurer_id != 'undefined'){
toastr.warning('The CD Account Number not found.', 'Warning');
return;
}
appendCDACNO(response.data)
}).fail(function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
});
});
});
@ -720,7 +752,6 @@
// $('#policy').val(res.data.policy_id).change();
$('#policy_type').val(res.data.is_addon).change();
$('#base_policy').val(res.data.base_policy);
$('#client_branch').val(res.data.client_branch_id).change();
$('#policy_type_id').val(res.data.policy_type_id);
$('#policy_PrimaryKey').val(res.data.id);
@ -730,6 +761,7 @@
$('#policy_status').val(checkDateStatus(res.data.policy_end_date));
$('#policy_status_field').show();
if (res.data.inception_type == 2) {
$('#inception_type').prop('checked', true);
} else {
@ -841,6 +873,12 @@
}, 3000);
setTimeout(function(){
appendCDACNO(res.cd_data, res.data.cd_ac_no)
}, 3000)
$('#client_branch').val(res.data.client_branch_id).change();
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
@ -1528,4 +1566,32 @@
});
})
function appendCDACNO(data, select = null) {
console.log('appendCDACNO', data);
console.log('appendCDACNO', select);
$('#cd_ac_no').empty();
$('#cd_ac_no').append($('<option>', {
value: '',
text: 'Select CD Account Number'
}));
$.each(data, function(index, item) {
const option = $('<option>', {
value: item.cd_ac_no,
text: item.cd_ac_no
});
if (select === item.cd_ac_no) {
console.log('selected');
option.attr('selected', true);
}
$('#cd_ac_no').append(option);
});
}
</script>

View File

@ -580,6 +580,9 @@
<li>
<a href="<?= base_url('/master/policy/list') ?>">Policy</a>
</li>
<li>
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
</li>
</ul>
</div>
</li>

View File

@ -76,11 +76,12 @@
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-12" style="text-align: right;">
<a href="<?= base_url("client/deposit/$clientData->id"); ?>"><i class="fas fa-arrow-left" style="font-size: 17px;"></i></a>
<div class="row">
<div class="col-12" style="text-align: right;">
<a href="<?= base_url("client/deposit/$clientData->id"); ?>"><i class="fas fa-arrow-left"
style="font-size: 17px;"></i></a>
</div>
</div>
</div>
<div class="row" style="margin-bottom:1rem;">
<div class="col-6" style="align-self: center;">
@ -97,27 +98,31 @@
id="tickets-table">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">Date</th>
<th class="font-weight-medium">User</th>
<th class="font-weight-medium">Description</th>
<th class="font-weight-medium">CD Account No</th>
<th class="font-weight-medium">Policy Name</th>
<th class="font-weight-medium">Endorsement No</th>
<th class="font-weight-medium">Sub Type</th>
<th class="font-weight-medium">Credit</th>
<th class="font-weight-medium">Debit</th>
<th class="font-weight-medium">Balance</th>
<th class="font-weight-medium">Description</th>
<th class="font-weight-medium">Date/User</th>
</tr>
</thead>
<tbody>
<?php foreach($depositdata as $row) { ?>
<tr id="<?php echo $row->id;?>">
<td><?php echo date('d-M-Y h:i A', strtotime($row->created_at)); ?></td>
<td><?php echo $row->username; ?></td>
<td><?php echo $row->description; ?></td>
<td><?php echo isset($subTypeOptions[$row->sub_type]) ? $subTypeOptions[$row->sub_type] : ''; ?></td>
<td><?php echo $row->cd_ac_no; ?></td>
<td><?php echo $row->policy_name; ?></td>
<td><?php echo $row->endorsement_no; ?></td>
<td><?php echo isset($subTypeOptions[$row->sub_type]) ? $subTypeOptions[$row->sub_type] : ''; ?>
</td>
<td><?php echo ($row->transaction_type == 'Credit') ? $row->amount : ''; ?></td>
<td><?php echo ($row->transaction_type == 'Debit') ? $row->amount : ''; ?></td>
<td><?php echo $row->balance; ?></td>
<td><?php echo $row->description; ?></td>
<td><?php echo date('d-M-Y h:i A', strtotime($row->created_at)); ?> by
<?php echo $row->username; ?> </td>
</tr>
<?php } ?>
</tbody>
@ -151,7 +156,7 @@
<div class="form-check">
<input class="form-check-input" type="radio" name="transactionMode" id="addMode"
value="add" checked>
<label class="form-check-label" for="addMode">Deposit</label>
<label class="form-check-label" for="addMode">Replenishment</label>
</div>
<div class="form-check">
<input class="form-check-input" type="radio" name="transactionMode" id="adjustmentMode"
@ -191,7 +196,7 @@
<div class="form-group">
<label for="subType" class="control-label" style="display: none;">Transaction Sub Type</label>
<select class="form-control" id="subType" name="sub_type" style="display: none;">
<option value="Deposit" hidden>Deposit</option>
<option value="Deposit" hidden>Replenishment</option>
<option value="Adjustment" hidden>Adjustment</option>
<!-- Add more options as needed -->
</select>
@ -222,22 +227,22 @@ $(document).ready(function() {
$('#tickets-table').DataTable({
dom: "<'row'<'col-sm-0'f><'col-sm-9 text-right'B>>",
buttons: [{
extend: 'csv',
text: 'CSV',
title: 'TransactionDetails',
exportOptions: {
columns: ''
extend: 'csv',
text: 'CSV',
title: 'TransactionDetails',
exportOptions: {
columns: ''
}
},
{
extend: 'pdf',
text: 'PDF',
title: 'TransactionDetails',
exportOptions: {
columns: ''
}
}
},
{
extend: 'pdf',
text: 'PDF',
title: 'TransactionDetails',
exportOptions: {
columns: ''
}
}
],
],
language: {
@ -288,15 +293,25 @@ $(document).ready(function() {
// Add more options as needed
};
var subType = $('#subType').val();
var subTypeId = subTypeOptions[subType] || null;
if (subTypeId === null) {
// Handle the case where sub_type is not found in the options
alert('Invalid sub_type selected.');
toastr.warning('Invalid sub_type selected.', "Warning");
return;
}
// console.log('transactionType ', transactionType)
// console.log('description ', description)
// console.log('amount ', amount)
// console.log('subType ', subType)
// console.log('sub_type_id ', sub_type_id)
// console.log('clientId ', clientId)
// console.log('insurerId ', insurerId)
// Send data to the server using Ajax
$.ajax({
type: 'POST',
@ -312,15 +327,18 @@ $(document).ready(function() {
},
success: function(response) {
// Handle success response
console.log("Transaction saved successfully");
toastr.success("Transaction saved successfully", "Success");
// Reload the page or perform other actions as needed
location.reload();
},
error: function(error) {
// Handle error response
console.error(error);
error: function(xhr, status, error) {
toastr.error("Transaction save failed", "Error");
console.error(xhr.responseText);
console.error(status, error);
location.reload(); // Uncomment if you need to reload the page on error
}
});
});
});
</script>

View File

@ -38,6 +38,22 @@ Options -Indexes
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/js "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.