CHANGE_BDS : RV
This commit is contained in:
parent
4536bc7f45
commit
11dd30597f
@ -690,6 +690,7 @@ $routes->group('test', function($routes) {
|
||||
$routes->get('generatePDF', 'TestingController::generatePDF');
|
||||
$routes->get('viewPDF', 'TestingController::viewPDF');
|
||||
$routes->get('generate-pdf-view', 'TestingController::generatePDFWithView');
|
||||
$routes->get('param/(:any)', 'TestingController::ptedfitdata/$1');
|
||||
});
|
||||
$routes->cli('cli/testcli', 'TestingController::testcli');
|
||||
|
||||
|
||||
@ -999,31 +999,52 @@ class ClientController extends AdminController
|
||||
$data['client_id'] = $this->request->getPost('client_id');
|
||||
$data['updated_by'] = get_session_userid();
|
||||
$inserted = false;
|
||||
// print_r($this->request->getPost()); die;
|
||||
|
||||
if ($this->request->getPost('head')) {
|
||||
|
||||
$data['user_id'] = $this->request->getPost('head');
|
||||
$checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('head'), 1);
|
||||
if ($checkHead) {
|
||||
$inserted = $this->clientRMModel->where('client_id', $id)->where('level', 1)->set($data)->update();
|
||||
} else {
|
||||
$data['level'] = "1";
|
||||
$data['user_id'] = $this->request->getPost('head');
|
||||
$inserted = $this->clientRMModel->insert($data);
|
||||
}
|
||||
$this->clientRMModel->where('client_id', $id)->where('level', 1)->delete();
|
||||
|
||||
$data['level'] = "1";
|
||||
$data['user_id'] = $this->request->getPost('head');
|
||||
$inserted = $this->clientRMModel->insert($data);
|
||||
}
|
||||
|
||||
if ($this->request->getPost('manager')) {
|
||||
|
||||
$data['user_id'] = $this->request->getPost('manager');
|
||||
$checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('manager'), 2);
|
||||
if ($checkHead) {
|
||||
$inserted = $this->clientRMModel->where('client_id', $id)->where('level', 2)->set($data)->update();
|
||||
} else {
|
||||
$data['level'] = "2";
|
||||
$data['user_id'] = $this->request->getPost('manager');
|
||||
$inserted = $this->clientRMModel->insert($data);
|
||||
}
|
||||
$this->clientRMModel->where('client_id', $id)->where('level', 2)->delete();
|
||||
|
||||
$data['level'] = "2";
|
||||
$data['user_id'] = $this->request->getPost('manager');
|
||||
$inserted = $this->clientRMModel->insert($data);
|
||||
}
|
||||
|
||||
// if ($this->request->getPost('head')) {
|
||||
// $data['user_id'] = $this->request->getPost('head');
|
||||
// $checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('head'), 1);
|
||||
// if ($checkHead) {
|
||||
// $inserted = $this->clientRMModel->where('client_id', $id)->where('level', 1)->set($data)->update();
|
||||
// } else {
|
||||
// $data['level'] = "1";
|
||||
// $data['user_id'] = $this->request->getPost('head');
|
||||
// $inserted = $this->clientRMModel->insert($data);
|
||||
// }
|
||||
// }
|
||||
|
||||
// if ($this->request->getPost('manager')) {
|
||||
// $data['user_id'] = $this->request->getPost('manager');
|
||||
// $checkHead = $this->clientRMModel->checkExistenceOfClientRelation($id, $this->request->getPost('manager'), 2);
|
||||
// if ($checkHead) {
|
||||
// $inserted = $this->clientRMModel->where('client_id', $id)->where('level', 2)->set($data)->update();
|
||||
// } else {
|
||||
// $data['level'] = "2";
|
||||
// $data['user_id'] = $this->request->getPost('manager');
|
||||
// $inserted = $this->clientRMModel->insert($data);
|
||||
// }
|
||||
// }
|
||||
|
||||
if ($this->request->getPost('account_manager')) {
|
||||
|
||||
$this->clientRMModel->where('client_id', $id)->where('level', 3)->delete();
|
||||
@ -4422,7 +4443,7 @@ class ClientController extends AdminController
|
||||
// }
|
||||
// }
|
||||
|
||||
public function createClientWithMinimalData()
|
||||
public function createClientWithMinimalData2()
|
||||
{
|
||||
$postData = $this->request->getPost();
|
||||
// print_r($postData); die;
|
||||
@ -4474,7 +4495,74 @@ class ClientController extends AdminController
|
||||
'name' => $postData['name'],
|
||||
'mobile' => $postData['mobile'],
|
||||
'email' => $postData['email'],
|
||||
];
|
||||
$this->levelContactModel->insert($contact_data);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'data' => $postData,
|
||||
'client_id' => $client_insert,
|
||||
'branch_id' => $branch_insert ?? null,
|
||||
'message' => 'Client created successfully'
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function createClientWithMinimalData()
|
||||
{
|
||||
$postData = $this->request->getPost();
|
||||
|
||||
// print_r($postData); die;
|
||||
$client_type = $postData['client_type'] ?? null;
|
||||
|
||||
if($client_type == 2){
|
||||
|
||||
$client_data = [
|
||||
'client_type' => $postData['client_type'],
|
||||
'client_name' => $postData['client_name'],
|
||||
'email' => $postData['short_name'] ?? $postData['client_name'],
|
||||
'phone' => $postData['mobile'],
|
||||
'client_code' => generate_client_code()
|
||||
];
|
||||
|
||||
$client_insert = $this->clientModel->insert($client_data);
|
||||
|
||||
}else if($client_type == 1){
|
||||
|
||||
$client_data = [
|
||||
'client_type' => $postData['client_type'],
|
||||
'client_name' => $postData['client_name'],
|
||||
'short_name' => $postData['short_name'] ?? $postData['client_name'],
|
||||
'client_code' => generate_client_code(),
|
||||
'entity_type_id' => 2
|
||||
];
|
||||
|
||||
$client_insert = $this->clientModel->insert($client_data);
|
||||
}
|
||||
|
||||
if (!$client_insert) {
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to create client'], 200);
|
||||
}
|
||||
|
||||
// Additional logic for non-individual clients (client_type != 2)
|
||||
if ($client_type != 2) {
|
||||
$unit[] = $postData['short_name'] . '-' . 001;
|
||||
$branch_data = [
|
||||
'client_id' => $client_insert,
|
||||
'branch_name' => $postData['branch_name'],
|
||||
'branch_code' => 001,
|
||||
'gst' => $postData['gst'],
|
||||
'units' => json_encode($unit) ?? null,
|
||||
];
|
||||
|
||||
$branch_insert = $this->clientBranchModel->insert($branch_data);
|
||||
if ($branch_insert) {
|
||||
$contact_data = [
|
||||
'ref_id' => $branch_insert,
|
||||
'contact_type' => 'client',
|
||||
'name' => $postData['name'],
|
||||
'email' => $postData['email'],
|
||||
];
|
||||
$this->levelContactModel->insert($contact_data);
|
||||
}
|
||||
@ -4508,7 +4596,49 @@ class ClientController extends AdminController
|
||||
$vehicle_insert = $this->vehicleModel->insert($data);
|
||||
|
||||
if ($vehicle_insert) {
|
||||
$vehicles = $this->vehicleModel->where('is_active', 1)->findAll();
|
||||
|
||||
// $vehicles = $this->vehicleModel->where('is_active', 1)->findAll();
|
||||
$vehicles = $this->vehicleModel->select('vehicle.*, clients.client_type')
|
||||
->join('clients', 'clients.id=vehicle.owner')
|
||||
->where('vehicle.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'vehicle_id' => $vehicle_insert,
|
||||
'owner_id' => $data['owner'],
|
||||
'owner_branch_id' => $data['branch_id'] ?? null,
|
||||
'owner_type' => $data['Owner_type'],
|
||||
'vehicles' => $vehicles,
|
||||
'message' => 'Vehicle created successfully
|
||||
'
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'message' => 'Failed to created vehicle'], 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function createVehicleWithMinimalData2()
|
||||
{
|
||||
$data = $this->request->getPost();
|
||||
|
||||
if (isset($data['client_name']) && !empty($data['client_name'])) {
|
||||
|
||||
$this->clientModel->insert();
|
||||
|
||||
} else {
|
||||
|
||||
$vehicle_insert = $this->vehicleModel->insert($data);
|
||||
|
||||
if ($vehicle_insert) {
|
||||
|
||||
// $vehicles = $this->vehicleModel->where('is_active', 1)->findAll();
|
||||
$vehicles = $this->vehicleModel->select('vehicle.*, clients.client_type')
|
||||
->join('clients', 'clients.id=vehicle.owner')
|
||||
->where('vehicle.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'vehicle_id' => $vehicle_insert,
|
||||
@ -4604,6 +4734,68 @@ class ClientController extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
// public function get_client_policy_data_using_policy_no()
|
||||
// {
|
||||
// $received_data = $this->request->getGet();
|
||||
// $policy_no = $this->request->getGet('policy_no');
|
||||
// $client_id = $this->request->getGet('client_id');
|
||||
// $client_branch_id = $this->request->getGet('client_branch_id');
|
||||
// $policy_type_id = $this->request->getGet('policy_type_id');
|
||||
// $client_type = $this->request->getGet('client_type');
|
||||
|
||||
// $data = $this->clientPolicyModel
|
||||
// ->select("
|
||||
// client_policy.*,
|
||||
// policy_type.policy_type,
|
||||
// clients.client_type,
|
||||
// clients.client_name,
|
||||
// DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date,
|
||||
// DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date
|
||||
// ")
|
||||
// ->join('clients', 'client_policy.client_id = clients.id')
|
||||
// ->join('policy_type', 'client_policy.policy_type_id = policy_type.id')
|
||||
// ->where('client_policy.policy_no', $policy_no)
|
||||
// ->where('client_policy.is_active', 1)
|
||||
// ->where('client_policy.policy_status', 1)
|
||||
// ->first();
|
||||
|
||||
// if ($data) {
|
||||
|
||||
// if ($client_type == 1) {
|
||||
// if ($data['client_id'] == $client_id && $data['client_branch_id'] == $client_branch_id) {
|
||||
|
||||
// if ($data['policy_type_id'] == $policy_type_id) {
|
||||
// return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200);
|
||||
// } else {
|
||||
// $policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first();
|
||||
// $message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.';
|
||||
// return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200);
|
||||
// }
|
||||
// } else {
|
||||
// $message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check';
|
||||
// return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200);
|
||||
// }
|
||||
// } else {
|
||||
// if ($data['client_id'] == $client_id) {
|
||||
|
||||
// if ($data['policy_type_id'] == $policy_type_id) {
|
||||
// return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200);
|
||||
// } else {
|
||||
// $policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first();
|
||||
// $message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.';
|
||||
// return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200);
|
||||
// }
|
||||
// } else {
|
||||
// $message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check';
|
||||
// return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200);
|
||||
// }
|
||||
// }
|
||||
|
||||
// } else {
|
||||
// return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404, 'received_data' => $received_data], 200);
|
||||
// }
|
||||
// }
|
||||
|
||||
public function get_client_policy_data_using_policy_no()
|
||||
{
|
||||
$received_data = $this->request->getGet();
|
||||
@ -4613,54 +4805,14 @@ class ClientController extends AdminController
|
||||
$policy_type_id = $this->request->getGet('policy_type_id');
|
||||
$client_type = $this->request->getGet('client_type');
|
||||
|
||||
$data = $this->clientPolicyModel
|
||||
->select("
|
||||
client_policy.*,
|
||||
policy_type.policy_type,
|
||||
clients.client_type,
|
||||
clients.client_name,
|
||||
DATE_FORMAT(client_policy.policy_start_date, '%d/%m/%Y') as policy_start_date,
|
||||
DATE_FORMAT(client_policy.policy_end_date, '%d/%m/%Y') as policy_end_date
|
||||
")
|
||||
->join('clients', 'client_policy.client_id = clients.id')
|
||||
->join('policy_type', 'client_policy.policy_type_id = policy_type.id')
|
||||
->where('client_policy.policy_no', $policy_no)
|
||||
->where('client_policy.is_active', 1)
|
||||
->where('client_policy.policy_status', 1)
|
||||
->first();
|
||||
$data = $this->policyTransactionModel
|
||||
->where('is_active', 1)
|
||||
->where('action_type', 'inception')
|
||||
->where('policy_no', $policy_no)
|
||||
->countAllResults();
|
||||
|
||||
if ($data) {
|
||||
|
||||
if ($client_type == 1) {
|
||||
if ($data['client_id'] == $client_id && $data['client_branch_id'] == $client_branch_id) {
|
||||
|
||||
if ($data['policy_type_id'] == $policy_type_id) {
|
||||
return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200);
|
||||
} else {
|
||||
$policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first();
|
||||
$message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.';
|
||||
return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200);
|
||||
}
|
||||
} else {
|
||||
$message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check';
|
||||
return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200);
|
||||
}
|
||||
} else {
|
||||
if ($data['client_id'] == $client_id) {
|
||||
|
||||
if ($data['policy_type_id'] == $policy_type_id) {
|
||||
return $this->respond(['status' => true, 'data' => $data, 'code' => 200, 'received_data' => $received_data], 200);
|
||||
} else {
|
||||
$policy_type = $this->policyTypeModel->where('id', $policy_type_id)->first();
|
||||
$message = 'This policy number is mapped to the selected client with policy type: ' . (!empty($data['policy_type']) ? $data['policy_type'] : 'N/A') . '. You selected: ' . (!empty($policy_type['policy_type']) ? $policy_type['policy_type'] : 'N/A') . '. Please check.';
|
||||
return $this->respond(['status' => true, 'data' => $data, 'code' => 409, "message" => $message, 'received_data' => $received_data], 200);
|
||||
}
|
||||
} else {
|
||||
$message = 'This policy number is already linked to another client' . (!empty($data['client_name']) ? '. Client name : ' . $data['client_name'] : '') . '. Please check';
|
||||
return $this->respond(['status' => true, 'code' => 409, "message" => $message, 'received_data' => $received_data, 'db_data' => $data], 200);
|
||||
}
|
||||
}
|
||||
|
||||
if ($data > 0) {
|
||||
return $this->respond(['status' => true, 'message' => 'This policy number is already linked to another client', 'data' => $data, 'code' => 409, 'received_data' => $received_data], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'message' => 'No Data Found', 'code' => 404, 'received_data' => $received_data], 200);
|
||||
}
|
||||
@ -5259,7 +5411,7 @@ class ClientController extends AdminController
|
||||
// ---------- EMP SERVICE CONTROLLER --------------------------------------------------------------------------------
|
||||
|
||||
$empServiceController = new EmployeeServiceController();
|
||||
// $res = $empServiceController->excelFileFormatValidation(['file_id' => '865']);
|
||||
$res = $empServiceController->excelFileFormatValidation(['file_id' => '2055']);
|
||||
// $res = $empServiceController->excelFileDataValidation(['file_id' => '865']);
|
||||
// $res = $empServiceController->employeesOnboardPreprocess(['file_id' => 726]);
|
||||
// $res = $empServiceController->employeesOnboardProcess(['file_id' => 835]);
|
||||
@ -5267,7 +5419,7 @@ class ClientController extends AdminController
|
||||
// $res = $empServiceController->employeesSIEnhanceProcess(['file_id' => '978']);
|
||||
// $res = $empServiceController->employeeDisembark(['file_id' => '1681']);
|
||||
// $res = $empServiceController->employeesCorrectionProcess(['file_id' => '2033']);
|
||||
// dd( $res);
|
||||
dd( $res);
|
||||
|
||||
$EmployeeMultiEventServiceController = new EmployeeMultiEventServiceController();
|
||||
// $res = $EmployeeMultiEventServiceController->constructMultiEventData(['file_id' => '1069']);
|
||||
|
||||
@ -36,6 +36,7 @@ use App\Models\BdsPlacementModel;
|
||||
use Kint\Kint;
|
||||
use App\Helpers\MailHelper;
|
||||
use App\Helpers\ExcelSanitizeHelper;
|
||||
use App\Models\NhanceBranchModel;
|
||||
use Exception;
|
||||
|
||||
class PolicyTransactionController extends BaseController
|
||||
@ -69,6 +70,7 @@ class PolicyTransactionController extends BaseController
|
||||
protected $filesModel;
|
||||
protected $coShareStmtDetailsModel;
|
||||
protected $BdsPlacementModel;
|
||||
protected $nhanceBranchModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@ -100,6 +102,7 @@ class PolicyTransactionController extends BaseController
|
||||
$this->filesModel = new FileModel();
|
||||
$this->coShareStmtDetailsModel = new COShareStmtDetailsModel();
|
||||
$this->BdsPlacementModel = new BdsPlacementModel();
|
||||
$this->nhanceBranchModel = new NhanceBranchModel();
|
||||
$this->invoiceStatus = [
|
||||
'pending' => 'Pending',
|
||||
'generated' => 'Generated',
|
||||
@ -115,6 +118,7 @@ class PolicyTransactionController extends BaseController
|
||||
|
||||
// Static arrays for dropdowns
|
||||
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
|
||||
$data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll();
|
||||
$data['client_type'] = [1 => 'Group', 2 => 'Individual'];
|
||||
$data['issuing_type'] = [1 => 'Fresh', 2 => 'Renewal', 3 => 'Roll Over'];
|
||||
$data['policy_status'] = [
|
||||
@ -255,6 +259,7 @@ class PolicyTransactionController extends BaseController
|
||||
$id = $this->request->getPost('id');
|
||||
$data = $this->preparePolicyData();
|
||||
$data['cd_ac_pk'] = $this->request->getPost('cd_ac_no');
|
||||
$data['issuer'] = 2;
|
||||
$this->myLogger->logme('error', 'Policy Trancaction modified form data ( insert data ) : '. json_encode($data));
|
||||
|
||||
|
||||
@ -334,11 +339,8 @@ class PolicyTransactionController extends BaseController
|
||||
$data['policy_with_corr'] = 1;
|
||||
}
|
||||
|
||||
if (!isset($data['is_cd_reduce_from_bds'])) {
|
||||
$data['is_cd_reduce_from_bds'] = 0;
|
||||
} elseif ($data['is_cd_reduce_from_bds']) {
|
||||
$data['is_cd_reduce_from_bds'] = 1;
|
||||
}
|
||||
$data['is_cd_reduce_from_bds'] = ($data['policy_type_id'] > 7 && $data['client_type'] === 1) ? 1 : 0;
|
||||
|
||||
|
||||
if ($data['ct_type'] == "") {
|
||||
$data['ct_type'] = 1;
|
||||
@ -436,6 +438,11 @@ class PolicyTransactionController extends BaseController
|
||||
$data['pt_co_share_details'] = $this->PTCOShareDetailsModel->where('pt_id', $id)->where('is_active', 1)->findAll();
|
||||
}
|
||||
|
||||
if(isset($data['cd_amt_changed']) && !empty($data['cd_amt_changed'])){
|
||||
$policy_data = $this->policyTransactionModel->where('is_active', 1)->where('id', $id)->first();
|
||||
$this->cdCorrection($policy_data, $data['cd_amt_changed']);
|
||||
}
|
||||
|
||||
$client_data = $this->clientModel->where('id', $data['client_id'])->first();
|
||||
$data['client_kyc'] = $this->clientKYCDocsModel->where('client_id', $data['client_id'])->findAll();
|
||||
|
||||
@ -621,6 +628,30 @@ class PolicyTransactionController extends BaseController
|
||||
DepositHelper::saveDeposit($cdTransactionData, get_session_userid());
|
||||
}
|
||||
|
||||
private function cdCorrection($data, $amt)
|
||||
{
|
||||
$totalAmount = (int)($amt ?? 0);
|
||||
$description = 'The following amount of Rs. ' . $totalAmount . '/- has been debited towards the difference arising from the change in the BDS base premium.';
|
||||
|
||||
$cdTransactionData = [
|
||||
'amount' => abs($totalAmount),
|
||||
'sub_type_id' => 4,
|
||||
'client_id' => $data['client_id'],
|
||||
'client_policy_id' => $data['client_policy_id'] ?? 0,
|
||||
'endorsement_no' => null,
|
||||
'cd_ac_no' => $data['cd_ac_no'] ?? null,
|
||||
'insurer_id' => $data['insurer_id'],
|
||||
'description' => $description,
|
||||
'transaction_type' => $totalAmount < 0 ? 'Credit' : 'Debit',
|
||||
'updated_by' => get_session_userid(),
|
||||
'event_name' => 'inception',
|
||||
'is_active' => 1,
|
||||
'cd_ac_pk' => $data['cd_ac_pk']
|
||||
];
|
||||
|
||||
DepositHelper::saveDeposit($cdTransactionData, get_session_userid());
|
||||
}
|
||||
|
||||
private function processInsertIndividualMemberInEmpTable($data)
|
||||
{
|
||||
// print_r($data);
|
||||
@ -753,31 +784,6 @@ class PolicyTransactionController extends BaseController
|
||||
->where('policy_transaction.is_active', 1)
|
||||
->first();
|
||||
|
||||
// $data['policy_issue_date'] = (isset($data['policy_issue_date']) && $data['policy_issue_date'] !== null && $data['policy_issue_date'] !== '')
|
||||
// ? date('d/m/Y', strtotime($data['policy_issue_date']))
|
||||
// : null;
|
||||
|
||||
// $data['policy_start_date'] = (isset($data['policy_start_date']) && $data['policy_start_date'] !== null && $data['policy_start_date'] !== '')
|
||||
// ? date('d/m/Y', strtotime($data['policy_start_date']))
|
||||
// : null;
|
||||
|
||||
// $data['policy_end_date'] = (isset($data['policy_end_date']) && $data['policy_end_date'] !== null && $data['policy_end_date'] !== '')
|
||||
// ? date('d/m/Y', strtotime($data['policy_end_date']))
|
||||
// : null;
|
||||
|
||||
// $data['renewal_date'] = (isset($data['renewal_date']) && $data['renewal_date'] !== null && $data['renewal_date'] !== '')
|
||||
// ? date('d/m/Y', strtotime($data['renewal_date']))
|
||||
// : null;
|
||||
|
||||
// $data['rollover_date'] = (isset($data['rollover_date']) && $data['rollover_date'] !== null && $data['rollover_date'] !== '')
|
||||
// ? date('d/m/Y', strtotime($data['rollover_date']))
|
||||
// : null;
|
||||
|
||||
// $data['month'] = (isset($data['month']) && $data['month'] !== null && $data['month'] !== '')
|
||||
// ? date('M/Y', strtotime($data['month']))
|
||||
// : null;
|
||||
|
||||
|
||||
$data['created_at'] = (isset($data['created_at']) && $data['created_at'] !== null && $data['created_at'] !== '')
|
||||
? date('d/m/Y h:i:s A', strtotime($data['created_at']))
|
||||
: null;
|
||||
@ -821,8 +827,6 @@ class PolicyTransactionController extends BaseController
|
||||
$data['month'] = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// print_r($data); die;
|
||||
|
||||
$data['renewal_policy'] = $this->clientPolicyModel
|
||||
@ -833,7 +837,6 @@ class PolicyTransactionController extends BaseController
|
||||
->where('client_policy.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
|
||||
$data['base_policy_data'] = $this->clientPolicyModel
|
||||
->select('client_policy.*, policy_type.policy_type')
|
||||
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
|
||||
@ -843,6 +846,16 @@ class PolicyTransactionController extends BaseController
|
||||
->where('client_policy.is_active', 1)
|
||||
->findAll();
|
||||
|
||||
$pt_bp_amt = $this->PTCOShareDetailsModel
|
||||
->select('bp_amt')
|
||||
->where('pt_id', $id)
|
||||
->where('co_share_type', 1)
|
||||
->where('is_active', 1)
|
||||
->first();
|
||||
|
||||
// dd(db_connect()->getLastQuery() ,$pt_bp_amt);
|
||||
$data['base_cd_amount'] = $pt_bp_amt['bp_amt'] ?? null;
|
||||
|
||||
|
||||
$ptFileQuery = $this->PTFileModel
|
||||
->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
|
||||
@ -999,7 +1012,7 @@ class PolicyTransactionController extends BaseController
|
||||
->findAll();
|
||||
|
||||
// print_r( $data['pt_co_share_details']); die;
|
||||
|
||||
// return $data;
|
||||
if ($data) {
|
||||
return $this->respond(['status' => true, 'data' => $data], 200);
|
||||
} else {
|
||||
@ -1059,8 +1072,8 @@ class PolicyTransactionController extends BaseController
|
||||
// !dd($this->getEndorsementDataForEdit(17));
|
||||
|
||||
$data['page_name'] = 'Endorsement';
|
||||
|
||||
$data['issuer'] = [1 => 'JIBS', 2 => 'Nhance'];
|
||||
$data['issuer_branch'] = $this->nhanceBranchModel->where('is_active', 1)->findAll();
|
||||
$data['client_type'] = [1 => 'Group', 2 => 'Individual'];
|
||||
|
||||
$data['policy_status'] = [
|
||||
@ -1242,7 +1255,8 @@ class PolicyTransactionController extends BaseController
|
||||
if (!$data['id']) {
|
||||
|
||||
$data += [
|
||||
'issuer' => $issue_type['issuer'] ?? null,
|
||||
'issuer' => 2,
|
||||
'issuer_branch' => $data['issuer_branch'] ?? 1,
|
||||
'client_type' => $data['client_type'] ?? $issue_type['client_type'] ?? null,
|
||||
'policy_type_id' => $issue_type['policy_type_id'] ?? null,
|
||||
'issue_type' => $issue_type['issue_type'] ?? null,
|
||||
|
||||
@ -4,6 +4,7 @@ namespace App\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\EmployeePolicyModel;
|
||||
use App\Models\InsurerBranchModel;
|
||||
use CodeIgniter\HTTP\ResponseInterface;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
use Dompdf\Dompdf;
|
||||
@ -236,4 +237,80 @@ class TestingController extends BaseController
|
||||
->findAll();
|
||||
|
||||
}
|
||||
|
||||
public function ptedfitdata($id){
|
||||
$policy_transaction = new PolicyTransactionController();
|
||||
$data = $policy_transaction->getInceptionDataForEdit($id);
|
||||
// dd($data);
|
||||
$insurerBranchModel = new InsurerBranchModel();
|
||||
$insurer_branch = $insurerBranchModel->getInsurerBranchesWithInsurerNames();
|
||||
|
||||
$dataArray = $data['pt_co_share_details']; // Example
|
||||
$cd_ac_pk = 'CD12345';
|
||||
$role_id = 1;
|
||||
$team_id = ['6'];
|
||||
$insurer_branch = $insurer_branch;
|
||||
|
||||
return view('pt_calc_table', [
|
||||
'dataArray' => $dataArray,
|
||||
'cd_ac_pk' => $cd_ac_pk,
|
||||
'role_id' => $role_id,
|
||||
'team_id' => $team_id,
|
||||
'insurer_branch' => $insurer_branch
|
||||
]);
|
||||
}
|
||||
|
||||
function generateInsurerTable($dataArray, $cd_ac_pk, $role_id, $team_id, $insurer_branch)
|
||||
{
|
||||
$html = '<table id="insurerTable" class="table table-bordered"><tbody>';
|
||||
|
||||
foreach ($dataArray as $index => $data) {
|
||||
$disable_td = ($data['record_count'] > 0) ? 'readonly-select' : '';
|
||||
$insurer = $data['insurer_branch_id'] . '-' . $data['insurer_id'];
|
||||
|
||||
$html .= '<tr id="table_tr_' . ($index + 1) . '">';
|
||||
|
||||
// Insurer selection
|
||||
$html .= '<td><select class="form-control follow_insurer ' . $disable_td . '" name="follow_insurer_id[]">';
|
||||
$html .= '<option value="">Select Insurer</option>';
|
||||
foreach ($insurer_branch as $value) {
|
||||
$selected = ($insurer == ($value['id'] . '-' . $value['insurer_id'])) ? 'selected' : '';
|
||||
$html .= '<option value="' . $value['id'] . '-' . $value['insurer_id'] . '" ' . $selected . '>'
|
||||
. $value['insurer_name'] . '-' . $value['branch_code'] . '</option>';
|
||||
}
|
||||
$html .= '</select></td>';
|
||||
|
||||
// Leader toggle
|
||||
$checked = ($data['co_share_type'] == 1) ? 'checked' : '';
|
||||
$html .= '<td><input type="checkbox" class="' . $disable_td . '" name="co_share_type[]" ' . $checked . '></td>';
|
||||
|
||||
// CD Account
|
||||
$html .= '<td><select class="form-control follow_insurer_cd ' . $disable_td . '" name="cd_ac_no_for_child[]">';
|
||||
$html .= '<option value="">Select CD No</option>';
|
||||
$html .= '<option value="add_cd">+ Add CD No</option>';
|
||||
if ($cd_ac_pk) {
|
||||
$html .= '<option value="' . $cd_ac_pk . '" selected>' . $cd_ac_pk . '</option>';
|
||||
}
|
||||
$html .= '</select></td>';
|
||||
|
||||
// CD Amount
|
||||
$html .= '<td><input type="text" readonly value="' . htmlspecialchars($data['cd_amount'] ?? '') . '"></td>';
|
||||
|
||||
// Example of follower policy no
|
||||
$html .= '<td><input type="text" class="' . $disable_td . '" value="' . htmlspecialchars($data['follower_policy_no']) . '"></td>';
|
||||
|
||||
// Add other fields (bp_amt, tp_amt, gst, etc.)
|
||||
$html .= '<td><input type="text" class="' . $disable_td . '" value="' . htmlspecialchars($data['bp_amt']) . '"></td>';
|
||||
$html .= '<td><input type="text" class="' . $disable_td . '" value="' . htmlspecialchars($data['tp_amt']) . '"></td>';
|
||||
$html .= '<td><input type="text" class="' . $disable_td . '" value="' . htmlspecialchars($data['tep_amt']) . '"></td>';
|
||||
$html .= '<td><input type="hidden" name="co_share_id[]" value="' . htmlspecialchars($data['id']) . '"></td>';
|
||||
|
||||
$html .= '</tr>';
|
||||
}
|
||||
|
||||
$html .= '</tbody></table>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -305,10 +305,12 @@ if (!function_exists('check_si')) {
|
||||
|
||||
if (!function_exists('check_basic_pay')) {
|
||||
function check_basic_pay($row, $policy_terms, $slab_details)
|
||||
{
|
||||
{
|
||||
// dd($row, $policy_terms, $slab_details);
|
||||
if ($row['current_action'] != null && in_array(strtoupper($row['current_action']), ['I', 'A', 'DA', 'MI'])) // check rule only of action column data available
|
||||
{
|
||||
$is_basic_pay_needed = $slab_details['grid_master']['basicpay'];
|
||||
// $is_basic_pay_needed = $slab_details['grid_master']['basicpay'];
|
||||
$is_basic_pay_needed = ($slab_details['grid_master']['basicpay'] == 1 && $slab_details['slab_rates'][0]['si_or_bp'] == 2 && $slab_details['slab_rates'][0]['basic_pay'] != null) ? 1 : 0;
|
||||
// $is_basic_pay_needed = true;
|
||||
$slug = \Config\Services::slug();
|
||||
$relationship = $slug->slugify($row[5]);
|
||||
|
||||
51
app/Models/NhanceBranchModel.php
Normal file
51
app/Models/NhanceBranchModel.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class NhanceBranchModel extends Model
|
||||
{
|
||||
protected $table = 'nhance_branch';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
"id",
|
||||
"branch_name",
|
||||
"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;
|
||||
}
|
||||
}
|
||||
@ -15,6 +15,7 @@ class PolicyTransactionModel extends Model
|
||||
protected $allowedFields = [
|
||||
'id',
|
||||
'issuer',
|
||||
'issuer_branch',
|
||||
'client_id',
|
||||
'client_branch_id',
|
||||
'insurer_id',
|
||||
|
||||
@ -162,8 +162,7 @@
|
||||
>Back</a>
|
||||
</div>
|
||||
</div>
|
||||
<form role="form" class="parsley-examples" method="post" id="inception_form_id"
|
||||
enctype="multipart/form-data">
|
||||
<form role="form" class="parsley-examples" method="post" id="inception_form_id" enctype="multipart/form-data">
|
||||
|
||||
<input type="hidden" name="id" id="policy_tranction_primarykey">
|
||||
<input type="hidden" name="client_policy_id" id="client_policy_id">
|
||||
@ -173,10 +172,13 @@
|
||||
<input type="hidden" name="ct_type" id="ct_type">
|
||||
<input type="hidden" name="remove_pt_co_id" id="remove_pt_co_id" >
|
||||
<input type="hidden" name="issuer" id="issuer" value="2">
|
||||
<input type="hidden" name="base_cd_amount" id="base_cd_amount">
|
||||
<input type="hidden" name="cd_amt_changed" id="cd_amt_changed" disabled>
|
||||
|
||||
<!-- <input type="hidden" id="cd_ac_no_for_edit"> -->
|
||||
<input type="hidden" id="premium_details_unique_id">
|
||||
<input type="hidden" id="policy_tranction_policy_number">
|
||||
<input type="hidden" id="pt_form_sumbit_handler" value="1">
|
||||
|
||||
<!-- Client Row -->
|
||||
<div class="row">
|
||||
@ -264,6 +266,19 @@
|
||||
</select>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="client_branch">Issuer Branch<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="issuer_branch" name="issuer_branch" required>
|
||||
<option value="">Select Issuer Branch</option>
|
||||
<?php
|
||||
if (isset($issuer_branch) && count($issuer_branch)) {
|
||||
foreach ($issuer_branch as $key => $value) {
|
||||
echo "<option value=" . $value['id'] . ">" . $value['branch_name'] . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -272,6 +287,13 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row" id="vehicle_row_div">
|
||||
</div>
|
||||
|
||||
<!-- Client Section -->
|
||||
<div class="row" id="client_row_div">
|
||||
</div>
|
||||
|
||||
<!-- Pre sales Row -->
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
@ -368,9 +390,8 @@
|
||||
<input id="ref" value="" type="text" class="form-control" name="ref">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="ppteam">PP Team</label>
|
||||
<!-- <input id="ppteam" type="text" class="form-control" name="ppteam"> -->
|
||||
<select class="form-control" id="ppteam" name="ppteam">
|
||||
<option value="">Select PP Team</option>
|
||||
<?php if (isset($ppTeamsData)) { ?>
|
||||
@ -381,15 +402,14 @@
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="remark">Remarks</label>
|
||||
<textarea id="remark" class="form-control" name="remarks" rows="1"></textarea>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<!-- <div class="form-group col-md-6">
|
||||
<label for="listed_insurers">Shortlisted Insurers</label>
|
||||
<select class="form-control" id="listed_insurers" name="listed_insurers" multiple>
|
||||
<option value=""></option>
|
||||
@ -399,7 +419,7 @@
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
<hr>
|
||||
@ -432,16 +452,16 @@
|
||||
<input id="fund_received" value="" type="text" class="form-control" name="fund_received">
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label class="switch" style="position: relative;top: 32px;left: 20px;">
|
||||
<input id="policy_with_corr" type="checkbox" name="policy_with_corr">
|
||||
<span class="slider round" style="height: 27px;"></span>
|
||||
</label>
|
||||
|
||||
<label for="policy_with_corr" style="position: relative;top: 33px;left: 25px;"> Policy with Correction</label>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label class="switch" style="position: relative;top: 32px;left: 20px;">
|
||||
<input id="is_cd_reduce_from_bds" type="checkbox" name="is_cd_reduce_from_bds">
|
||||
<span class="slider round" style="height: 27px;"></span>
|
||||
@ -449,7 +469,7 @@
|
||||
|
||||
<label for="is_cd_reduce_from_bds" style="position: relative;top: 33px;left: 25px;"> Make Entry in CD <i class="mdi mdi-information-outline info-icon" data-toggle="tooltip" title="Enabling this will affect ( Credit/Debit ) the CD transaction. ( GMC, GPA, EDLI and GTLI, CD transaction from CRM )"></i>
|
||||
</label>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<!-- <div class="form-group col-md-3 current_date" style="display: none;">
|
||||
<label for="bp_igst">Process Start Date</label>
|
||||
@ -544,10 +564,10 @@
|
||||
<input id="installment_data" class="form-control" name="installment_data">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="spl">SPL</label>
|
||||
<input id="spl" value="" type="text" class="form-control" name="spl">
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
@ -573,10 +593,10 @@
|
||||
<hr>
|
||||
<div class="row">
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<!-- <div class="form-group col-md-3">
|
||||
<label for="location">Location<span id="base_danger"class="text-danger"></span></label>
|
||||
<input type="text" class="form-control" id="location" name="location"placeholder="Enter location" >
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="renewal_date">Renewal Date<span id="base_danger"
|
||||
@ -810,8 +830,6 @@
|
||||
</div>
|
||||
<!-- end form row -->
|
||||
|
||||
<?php include("newClientModal.php") ?>
|
||||
|
||||
<!-- Vehicle form content modal-->
|
||||
<div class="modal fade" id="vehicle_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
@ -1175,11 +1193,6 @@ let isVehicleFormSubmitting = false;
|
||||
var insurer_count_array = [];
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
// $('#upload_enrollment_model').modal({
|
||||
// backdrop: 'static',
|
||||
// keyboard: false
|
||||
// })
|
||||
|
||||
document.getElementById('vehicle_form').addEventListener('reset', function(event) {
|
||||
console.log('vehicle_form reset called', event.type);
|
||||
@ -1337,16 +1350,16 @@ $(document).ready(function(){
|
||||
|
||||
var val = $(this).val()
|
||||
var selectedOption = $(this).find('option:selected');
|
||||
var client_id = selectedOption.data('cid')
|
||||
var branch_id = selectedOption.data('bid')
|
||||
var client_type = selectedOption.data('cty')
|
||||
var client_id = selectedOption.data('cid');
|
||||
var branch_id = selectedOption.data('bid');
|
||||
var client_type = selectedOption.data('cty');
|
||||
|
||||
console.log(client_id)
|
||||
console.log(branch_id)
|
||||
console.log(client_type)
|
||||
console.log(client_id);
|
||||
console.log(branch_id);
|
||||
console.log(client_type);
|
||||
|
||||
$('#client_id').val(client_id).change()
|
||||
$('#client_type').val(client_type)
|
||||
$('#client_id').val(client_id).change();
|
||||
$('#client_type').val(client_type);
|
||||
|
||||
if(client_type == 1){
|
||||
|
||||
@ -1358,21 +1371,27 @@ $(document).ready(function(){
|
||||
|
||||
$('#table_tr_34').show();
|
||||
$('#table_tr_37').show();
|
||||
$("select[name='cd_ac_no_for_child[]']").attr('required', 'required');
|
||||
|
||||
}else{
|
||||
|
||||
$('.branchdiv').hide()
|
||||
$('#client_branch_id').prop('required', false);
|
||||
|
||||
$('#table_tr_34').hide();
|
||||
$('#table_tr_37').hide();
|
||||
$("select[name='cd_ac_no_for_child[]']").removeAttr("required");
|
||||
|
||||
}
|
||||
|
||||
if(val == 'add_vehicle'){
|
||||
|
||||
$('#modal_vehicle_no').val('');
|
||||
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
myModal.show();
|
||||
// var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
// myModal.show();
|
||||
|
||||
$(this).val('').select2();
|
||||
// $(this).val('').select2();
|
||||
appendVehicleForm();
|
||||
}
|
||||
})
|
||||
|
||||
@ -1467,6 +1486,8 @@ $(document).ready(function(){
|
||||
$('#client_type').val('');
|
||||
$('#client_id').val('').select2();
|
||||
$('#client_branch_id').val('').select2();
|
||||
$('#vehicle_row_div').empty();
|
||||
$('#client_row_div').empty();
|
||||
|
||||
var client_type = $('#client_type').val();
|
||||
var value = $(this).val();
|
||||
@ -1489,7 +1510,6 @@ $(document).ready(function(){
|
||||
// console.log('ITEP:', itep);
|
||||
|
||||
|
||||
|
||||
var client_type_id = $('#client_type').val() ?? 1;
|
||||
var is_co_pay_yes = $('#cop_yes').prop('checked') ? 1 : 0;
|
||||
|
||||
@ -1554,6 +1574,7 @@ $(document).ready(function(){
|
||||
$('#client_id').addClass('readonly-select ').select2('destroy');
|
||||
$('#client_branch_id').addClass('readonly-select ').select2('destroy');
|
||||
}else{
|
||||
$('#vehicle_no').val("").select2();
|
||||
$('#vhnodiv').hide();
|
||||
$('#client_type_div').show();
|
||||
$('#hide_vehicle_tab').hide();
|
||||
@ -1576,8 +1597,6 @@ $(document).ready(function(){
|
||||
$('#client_type option[value="2"]').show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(value == 1 || value == 2 || value == 3 || value == 4 || value == 5 || value == 38 || value == 40){
|
||||
$('#tpa_div').hide();
|
||||
}else{
|
||||
@ -1599,9 +1618,20 @@ $(document).ready(function(){
|
||||
}
|
||||
|
||||
if(value == 1 || value == 2 || value == 3 || value == 4 || value == 5 || value == 6 || value == 7){
|
||||
$('#is_cd_reduce_from_bds').prop('disabled',true).prop('checked', false)
|
||||
|
||||
$('#is_cd_reduce_from_bds').prop('disabled',true).prop('checked', false);
|
||||
|
||||
$('#table_tr_34').hide();
|
||||
$('#table_tr_37').hide();
|
||||
$("select[name='cd_ac_no_for_child[]']").removeAttr("required");
|
||||
|
||||
}else{
|
||||
$('#is_cd_reduce_from_bds').prop('disabled',false)
|
||||
|
||||
$('#is_cd_reduce_from_bds').prop('disabled',false);
|
||||
|
||||
$('#table_tr_34').show();
|
||||
$('#table_tr_37').show();
|
||||
$("select[name='cd_ac_no_for_child[]']").attr('required', 'required');
|
||||
}
|
||||
|
||||
});
|
||||
@ -1754,8 +1784,6 @@ function getPolicyTransactionDataForEdit(input) {
|
||||
$('#other_docs').append(res.data.client_kyc_other_table);
|
||||
|
||||
|
||||
|
||||
|
||||
// Setting values to correct fields
|
||||
$('#policy_tranction_primarykey').val(res.data.id);
|
||||
$('#client_policy_id').val(res.data.client_policy_id);
|
||||
@ -1823,9 +1851,9 @@ function getPolicyTransactionDataForEdit(input) {
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
if (res.data.listed_insurers) {
|
||||
selectListedInsurers(res.data.listed_insurers);
|
||||
}
|
||||
// if (res.data.listed_insurers) {
|
||||
// selectListedInsurers(res.data.listed_insurers);
|
||||
// }
|
||||
|
||||
if (res.data.pt_co_share_details && res.data.pt_co_share_details.length > 0) {
|
||||
$('#tab_content').empty();
|
||||
@ -1886,6 +1914,11 @@ function getPolicyTransactionDataForEdit(input) {
|
||||
// $('.current_date').show();
|
||||
$('#sales_generated_by').val(res.data.sales_generated_by ?? '').change();
|
||||
$('#serviced_by').val(res.data.serviced_by ?? '').change();
|
||||
$('#base_cd_amount').val(res.data.base_cd_amount);
|
||||
$('#issuer_branch').val(res.data.issuer_branch);
|
||||
console.log('res.data.base_cd_amount', res.data.base_cd_amount);
|
||||
console.log('res.data.issuer_branch', res.data.issuer_branch);
|
||||
|
||||
|
||||
// Additional form handling logic
|
||||
if (res.data.issue_type == 2) {
|
||||
@ -3237,7 +3270,6 @@ function convertMonthYearToMySQLDate(dateString) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
$("#inception_form_id").submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
@ -3245,6 +3277,7 @@ $("#inception_form_id").submit(function(event) {
|
||||
var isValid = $('#inception_form_id').parsley().validate();
|
||||
var client_type_id = $('#client_type').val();
|
||||
var policy_status = $('#policy_status').val();
|
||||
var pt_form_sumbit_handler = $('#pt_form_sumbit_handler').val();
|
||||
|
||||
if (!isValid) {
|
||||
$('#inception_form_id').find('input, select, textarea').each(function() {
|
||||
@ -3256,6 +3289,10 @@ $("#inception_form_id").submit(function(event) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(pt_form_sumbit_handler == 0){
|
||||
toastr.warning('Base premium greater than CD Amount', 'WARNING');
|
||||
return;
|
||||
}
|
||||
|
||||
if(client_type_id == 1 && policy_status == 'completed'){
|
||||
|
||||
@ -3401,109 +3438,6 @@ $("#inception_form_id").submit(function(event) {
|
||||
});
|
||||
});
|
||||
|
||||
// $("#client_form").submit(function(event) {
|
||||
|
||||
// let form_type = $(this).data('id') || 0;
|
||||
|
||||
// console.log('onsubmit event', this)
|
||||
// console.log('onsubmit event get data value',form_type)
|
||||
// console.log('client_type', $('#client_type').val());
|
||||
|
||||
// event.preventDefault();
|
||||
|
||||
|
||||
// $('#aadhar').attr('data-parsley-required', 'false');
|
||||
// $('#aadhar').removeAttr('required');
|
||||
|
||||
|
||||
// isClientFormSubmitting = true;
|
||||
// var isValid = $('#client_form').parsley().validate();
|
||||
// if (!isValid) {
|
||||
// console.log('Form is Empty', 'Warning');
|
||||
// return ;
|
||||
// }
|
||||
|
||||
// form_action = '<?= base_url("util/createClientWithMinimalData"); ?>';
|
||||
|
||||
// $('.loader').fadeIn();
|
||||
// $('.loader-mask').fadeIn();
|
||||
|
||||
// var client_type = $('#client_type').val() || $('#Owner_type').val();
|
||||
// console.log('client_type:', client_type);
|
||||
|
||||
// //FORM Data
|
||||
// var formData = new FormData($('#client_form')[0]);
|
||||
// formData.append('client_type', client_type);
|
||||
|
||||
// $.ajax({
|
||||
// data:formData,
|
||||
// url: form_action,
|
||||
// type: "POST",
|
||||
// dataType: 'json',
|
||||
// processData: false,
|
||||
// contentType: false,
|
||||
// success: function(res) {
|
||||
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
// console.log('create_Client_With_Minimal_Data', res)
|
||||
|
||||
// if(res.status == true){
|
||||
// getClientAndBranchAndPolicy(res.client_id, res.branch_id);
|
||||
|
||||
// if(form_type != 1){
|
||||
|
||||
// setTimeout(function(){
|
||||
// $('#client_id').val(res.client_id).change();
|
||||
// setTimeout(function(){
|
||||
// $('#client_branch_id').val(res.branch_id).change();
|
||||
// }, 1000)
|
||||
// }, 2000)
|
||||
|
||||
// }else{
|
||||
|
||||
// setTimeout(function(){
|
||||
// $('#owner').val(res.client_id).change();
|
||||
// $('#owner_branch').val(res.branch_id).change();
|
||||
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
// }, 2000)
|
||||
// }
|
||||
|
||||
// toastr.success(res.message, 'Success');
|
||||
|
||||
// }else{
|
||||
// toastr.error(res.message, 'Error');
|
||||
// }
|
||||
|
||||
// $('#client_form')[0].reset();
|
||||
// $('.close').click();
|
||||
|
||||
// if(form_type == 1){
|
||||
|
||||
// var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
|
||||
// myModal.show();
|
||||
|
||||
// $('#client_form').removeAttr('data-id');
|
||||
|
||||
// // Load form data into #vehicle_form from localStorage
|
||||
// setFormDataFromLocalStorage("#vehicle_form", "vehicleFormData");
|
||||
// }
|
||||
|
||||
// isClientFormSubmitting = false;
|
||||
// },
|
||||
// error: function (xhr, status, error) {
|
||||
// console.error(xhr.responseText);
|
||||
// console.error(status, error);
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
$("#vehicle_form").submit(function(event) {
|
||||
|
||||
event.preventDefault();
|
||||
@ -3555,6 +3489,17 @@ $("#vehicle_form").submit(function(event) {
|
||||
$('.branchdiv').hide()
|
||||
$('#client_branch_id').prop('required', false);
|
||||
}
|
||||
|
||||
// if(res.owner_type == 2){
|
||||
// $('#table_tr_34').hide();
|
||||
// $('#table_tr_37').hide();
|
||||
// $("select[name='cd_ac_no_for_child[]']").removeAttr("required");
|
||||
// }else{
|
||||
// $('#table_tr_34').show();
|
||||
// $('#table_tr_37').show();
|
||||
// $("select[name='cd_ac_no_for_child[]']").attr('required', 'required');
|
||||
// }
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
}, 2000)
|
||||
@ -3694,6 +3639,9 @@ $('#cop_yes').change(function() {
|
||||
|
||||
$('#client_type').change(function() {
|
||||
|
||||
let policy_type_id = $('#policy_type_id').val();
|
||||
console.log("client_policy_type_id", policy_type_id);
|
||||
|
||||
if ($(this).val() == 2) {
|
||||
if($('#policy_type_id').val() == 8){
|
||||
$('#policyholdernamediv').hide();
|
||||
@ -3744,6 +3692,7 @@ $('#client_type').change(function() {
|
||||
|
||||
$('#table_tr_34').hide();
|
||||
$('#table_tr_37').hide();
|
||||
$("select[name='cd_ac_no_for_child[]']").removeAttr("required");
|
||||
|
||||
} else {
|
||||
|
||||
@ -3769,9 +3718,15 @@ $('#client_type').change(function() {
|
||||
|
||||
$('#owner_branch').prop('required', true);
|
||||
|
||||
$('#table_tr_34').show();
|
||||
$('#table_tr_37').show();
|
||||
|
||||
if(policy_type_id == 1 || policy_type_id == 2 || policy_type_id == 3 || policy_type_id == 4 || policy_type_id == 5 || policy_type_id == 6 || policy_type_id == 7){
|
||||
$('#table_tr_34').hide();
|
||||
$('#table_tr_37').hide();
|
||||
$("select[name='cd_ac_no_for_child[]']").removeAttr("required");
|
||||
}else{
|
||||
$('#table_tr_34').show();
|
||||
$('#table_tr_37').show();
|
||||
$("select[name='cd_ac_no_for_child[]']").attr('required', 'required');
|
||||
}
|
||||
}
|
||||
|
||||
$('[name="standard_bp[]"]').val(std_bp);
|
||||
@ -4034,22 +3989,6 @@ $('#policy_no').change(function(){
|
||||
}
|
||||
});
|
||||
|
||||
// $('.follow_insurer_cd').on('change', function(){
|
||||
|
||||
// const selectedValue = $(this).val();
|
||||
// const unique_id = $(this).data('count');
|
||||
// let leader = $('#co_share_type_' + unique_id).is(':checked');
|
||||
|
||||
// console.log('leader', leader);
|
||||
// console.log('selectedValue', selectedValue);
|
||||
// console.log('unique_id', unique_id);
|
||||
|
||||
// if (!leader) {
|
||||
// $(this).val('');
|
||||
// toastr.warning('Please select the Leader.', 'WARNING!');
|
||||
// }
|
||||
// });
|
||||
|
||||
$('.close').on('click', function(){
|
||||
$('#client_form')[0].reset();
|
||||
$('#vehicle_form')[0].reset();
|
||||
@ -4128,7 +4067,7 @@ function addInsurerColumn() {
|
||||
newCell = `<td><input type="text" class="right-align-input" id="non_comm_per_amt_${insurerCount}" name="non_comm_per_amt[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
|
||||
break;
|
||||
case 7: // Base Premium
|
||||
newCell = `<td><input type="text" class="right-align-input" id="base_premium_${insurerCount}" name="base_premium[]" oninput="" onkeypress="return onlyNumbers(event)" onchange="checkCDAmountForBasePremium(this);"></td>`;
|
||||
newCell = `<td><input type="text" class="right-align-input" id="base_premium_${insurerCount}" name="base_premium[]" oninput="" onkeypress="return onlyNumbers(event)" onkeyup="checkCDAmountForBasePremium(this);"></td>`;
|
||||
break;
|
||||
case 8: // TP Premium
|
||||
newCell = `<td><input type="text" class="right-align-input" id="tp_premium_${insurerCount}" name="tp_premium[]" oninput="" onkeypress="return onlyNumbers(event)"></td>`;
|
||||
@ -4828,14 +4767,30 @@ function checkCDAmountForBasePremium(input) {
|
||||
let client_type = $('#client_type').val();
|
||||
console.log('client type', client_type);
|
||||
|
||||
if(client_type == 1){
|
||||
let current_bp_amt = $('#base_cd_amount').val() ?? 0;
|
||||
console.log('current_bp_amt', current_bp_amt);
|
||||
|
||||
let base_premium = $(input).val();
|
||||
console.log("base_premium:", base_premium);
|
||||
let base_premium = $(input).val();
|
||||
console.log("base_premium:", base_premium);
|
||||
|
||||
let differnce_bp_amt = 0;
|
||||
|
||||
if (base_premium === current_bp_amt) {
|
||||
differnce_bp_amt = 0;
|
||||
} else {
|
||||
differnce_bp_amt = base_premium - current_bp_amt;
|
||||
console.log("differnce_bp_amt 1:", differnce_bp_amt);
|
||||
}
|
||||
|
||||
console.log("differnce_bp_amt:", differnce_bp_amt);
|
||||
console.log("base_premium:", base_premium);
|
||||
|
||||
if(client_type == 1){
|
||||
|
||||
// Extract increment value from input ID
|
||||
let input_id = input.id;
|
||||
console.log("input_id:", input_id);
|
||||
|
||||
let increment = input_id.split("_").pop();
|
||||
console.log("increment:", increment);
|
||||
|
||||
@ -4864,9 +4819,17 @@ function checkCDAmountForBasePremium(input) {
|
||||
if (response.status) {
|
||||
if (!response.base_premium_greater_than_balance) {
|
||||
console.log('Base premium is less than or equal to CD balance:', 'SUCCESS');
|
||||
if(differnce_bp_amt !== 0){
|
||||
$('#cd_amt_changed').prop('disabled', false).val(differnce_bp_amt);
|
||||
}else{
|
||||
$('#cd_amt_changed').prop('disabled', true).val("");
|
||||
}
|
||||
$('#pt_form_sumbit_handler').val(1);
|
||||
} else {
|
||||
toastr.warning('Base premium greater than CD Amount', 'WARNING');
|
||||
$(input).val("0")
|
||||
$('#cd_amt_changed').prop('disabled', true).val("");
|
||||
$('#pt_form_sumbit_handler').val(0);
|
||||
// $(input).val("0")
|
||||
}
|
||||
} else {
|
||||
toastr.error(response.message || 'Unable to fetch data', 'ERROR');
|
||||
@ -4969,4 +4932,423 @@ $('#new_vehicle_switch').change(function () {
|
||||
});
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------
|
||||
|
||||
function toggleClient(input) {
|
||||
let btn = $("#vehicle_client_btn");
|
||||
|
||||
// if (btn.text().trim() === "New Client") {
|
||||
// btn.text("Existing Client");
|
||||
// console.log("✅ Switched to Existing Client");
|
||||
// $('.new_client').show();
|
||||
// $('.old_client').hide();
|
||||
// $(".old_client").find("select, input, textarea").val("").prop("required", false);
|
||||
// $(".new_client").find("select, input, textarea").val("").prop("required", true);
|
||||
// $('#owner').select2();
|
||||
// $('#owner_branch').select2();
|
||||
|
||||
// } else {
|
||||
// btn.text("New Client");
|
||||
// console.log("✅ Switched to New Client");
|
||||
// $('.new_client').hide();
|
||||
// $('.old_client').show();
|
||||
// $(".old_client").find("select, input, textarea").prop("required", true);
|
||||
// $(".new_client").find("select, input, textarea").val("").prop("required", false);
|
||||
// $('#owner').select2();
|
||||
// $('#owner_branch').select2();
|
||||
|
||||
// }
|
||||
|
||||
if($(input).is(":checked")){
|
||||
$('.new_client').show();
|
||||
$('.old_client').hide();
|
||||
$(".old_client").find("select, input, textarea").val("").prop("required", false);
|
||||
$(".new_client").find("select, input, textarea").val("").prop("required", true);
|
||||
$('#owner').select2();
|
||||
$('#owner_branch').select2();
|
||||
}else {
|
||||
$('.new_client').hide();
|
||||
$('.old_client').show();
|
||||
$(".old_client").find("select, input, textarea").prop("required", true);
|
||||
$(".new_client").find("select, input, textarea").val("").prop("required", false);
|
||||
$('#owner').select2();
|
||||
$('#owner_branch').select2();
|
||||
}
|
||||
}
|
||||
|
||||
function removeVehicleForm(){
|
||||
$('#vehicle_row_div').empty();
|
||||
}
|
||||
|
||||
function removeClientForm(){
|
||||
$('#client_row_div').empty();
|
||||
}
|
||||
|
||||
function getVehicleFormData() {
|
||||
|
||||
console.log("🔹 Collecting Vehicle Form Data...");
|
||||
let vhno = $('#modal_vehicle_no').val();
|
||||
let rc = $('#rc').val();
|
||||
|
||||
if (vhno === "" && rc === "") {
|
||||
toastr.warning("Please enter any one of these: Vehicle No or Chassis No", "WARNING");
|
||||
}
|
||||
|
||||
|
||||
var isValid = $('#vehicle_form_row_div').parsley().validate();
|
||||
|
||||
if (!isValid) {
|
||||
console.log("❌ Validation failed for Vehicle Form section");
|
||||
return false;
|
||||
}
|
||||
|
||||
let data = {};
|
||||
$("#vehicle_form_row_div").find("input, select, textarea").each(function () {
|
||||
let name = $(this).attr("name");
|
||||
let value = $.trim($(this).val());
|
||||
|
||||
if (name) {
|
||||
data[name] = value;
|
||||
console.log("✅ Added field:", name, "=", value);
|
||||
}
|
||||
});
|
||||
|
||||
console.log("📌 Final Data Object:", data);
|
||||
|
||||
let url = '<?= base_url("util/createVehicleWithMinimalData"); ?>';
|
||||
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, 'POST', data, function(response) {
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status == true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
} else {
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
}
|
||||
|
||||
$('#client_row_div').empty();
|
||||
$('#vehicle_row_div').empty();
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while checking the CD amount.', 'ERROR');
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function getClientFormData() {
|
||||
|
||||
let client_type = $('#client_type').val();
|
||||
console.log("🔹 Collecting Client Form Data...");
|
||||
|
||||
var isValid = $('#client_form_row_div').parsley().validate();
|
||||
|
||||
if (!isValid) {
|
||||
console.log("❌ Validation failed for Client Form section");
|
||||
return false;
|
||||
}
|
||||
|
||||
let data = {};
|
||||
$("#client_form_row_div").find("input, select, textarea").each(function () {
|
||||
let name = $(this).attr("name");
|
||||
let value = $.trim($(this).val());
|
||||
|
||||
if (name) {
|
||||
data[name] = value;
|
||||
console.log("✅ Added field:", name, "=", value);
|
||||
}
|
||||
});
|
||||
data["client_type"] = client_type;
|
||||
|
||||
console.log("📌 Final Data Object:", data);
|
||||
|
||||
let url = '<?= base_url("util/createClientWithMinimalData"); ?>';
|
||||
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, 'POST', data, function(response) {
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status == true) {
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
} else {
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
}
|
||||
|
||||
$('#client_row_div').empty();
|
||||
$('#vehicle_row_div').empty();
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
toastr.error('An error occurred while checking the CD amount.', 'ERROR');
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
function appendVehicleForm(){
|
||||
$('#vehicle_row_div').empty();
|
||||
|
||||
let html = `
|
||||
<div class="col-md-12">
|
||||
<div class="form-section">
|
||||
<div id="vehicle_form_row_div" data-parsley-validate>
|
||||
<h4 class="m-1">
|
||||
Add New Vehicle
|
||||
<a class="text-dark float-right" aria-expanded="true">
|
||||
<i class="mdi mdi-close" style="font-size: 28px;" onclick="removeVehicleForm()"></i>
|
||||
</a>
|
||||
</h4>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="form-group col-md-3 mt-3">
|
||||
<!-- <label for="vehicle_client_btn">Client</label> -->
|
||||
<input id="vehicle_client_btn" type="checkbox" name="new_vehicle" value="1" data-toggle="toggle" data-off="Existing Client" data-on="Add Client" data-onstyle="info" data-offstyle="primary" data-style="border" data-width="218" onchange="toggleClient(this)">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="modal_vehicle_no">Vehicle No</label>
|
||||
<input type="text" class="form-control" id="modal_vehicle_no" name="vehicle_no"
|
||||
placeholder="Enter Vehicle No"
|
||||
onchange="validateInput(this, 'vehicle', 'vehicle_no')">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="rc">Chassis No</label>
|
||||
<input type="text" class="form-control" id="rc" name="rc"
|
||||
placeholder="Enter Chassis No"
|
||||
onchange="validateInput(this, 'vehicle', 'rc')">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="type">Type <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="type" name="type" required>
|
||||
<option value="">Select Type</option>
|
||||
<?php
|
||||
if (isset($vehicle_type) && count($vehicle_type)) {
|
||||
foreach ($vehicle_type as $key => $value) {
|
||||
echo "<option value='" . $value['id'] . "'>" . $value['vehicle_type'] . "</option>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 old_client">
|
||||
<label for="owner">Owner Name <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="owner" name="owner" required>
|
||||
<option value="">Select Owner</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 old_client">
|
||||
<label for="owner_branch">Branch <span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="owner_branch" name="branch_id">
|
||||
<option value="">Select Branch</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 new_client" style="display: none;">
|
||||
<label for="client_name">Client Name <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="client_name" name="client_name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 group_client new_client" style="display: none;">
|
||||
<label for="short_name">Client Short Name <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="short_name" name="short_name"
|
||||
onkeyup="validateInputForClient(this, 'clients', 'short_name')">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 group_client new_client" style="display: none;">
|
||||
<label for="branch_name">Branch Name <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_name" name="branch_name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 group_client new_client" style="display: none;">
|
||||
<label for="contact_name">Contact Name <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="contact_name" name="name">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 new_client" style="display: none;">
|
||||
<label for="email">Email <span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" id="email" name="email"
|
||||
placeholder="Enter Email">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 new_client" style="display: none;">
|
||||
<label for="mobile">Mobile <span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" id="mobile" name="mobile"
|
||||
placeholder="Enter Mobile">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 group_client new_client" style="display: none;">
|
||||
<label for="gst">GST <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="gst" name="gst"
|
||||
placeholder="Enter GST Number"
|
||||
oninput="validateInputForClient(this, 'client_branch', 'gst')">
|
||||
</div>
|
||||
|
||||
</div> <!-- /.row -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right m-b-0">
|
||||
<a class="btn btn-primary waves-effect waves-light mr-1"
|
||||
onclick="getVehicleFormData()">Submit</a>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- /#vehicle_form_row_div -->
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
$('#vehicle_row_div').append(html);
|
||||
}
|
||||
|
||||
function appendClientForm(){
|
||||
let client_type = $('#client_type').val();
|
||||
$('#client_row_div').empty();
|
||||
|
||||
let html = `
|
||||
<div class="col-md-12">
|
||||
<div class="form-section">
|
||||
<div id="client_form_row_div" data-parsley-validate>
|
||||
<h4 class="m-1">
|
||||
Add New Client
|
||||
<a class="text-dark float-right" aria-expanded="true">
|
||||
<i class="mdi mdi-close" style="font-size: 28px;" onclick="removeClientForm()"></i>
|
||||
</a>
|
||||
</h4>
|
||||
<div class="row">
|
||||
|
||||
<div class="form-group col-md-3 new_client">
|
||||
<label for="client_name">Client Name <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="client_name" name="client_name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 group_client new_client">
|
||||
<label for="short_name">Client Short Name <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="short_name" name="short_name"
|
||||
onkeyup="validateInputForClient(this, 'clients', 'short_name')" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 group_client new_client">
|
||||
<label for="branch_name">Branch Name <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_name" name="branch_name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 group_client new_client">
|
||||
<label for="contact_name">Contact Name <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="contact_name" name="name" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 new_client" >
|
||||
<label for="email">Email <span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" id="email" name="email"
|
||||
placeholder="Enter Email" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 individual_client new_client">
|
||||
<label for="mobile">Mobile <span class="text-danger">*</span></label>
|
||||
<input type="number" class="form-control" id="mobile" name="mobile"
|
||||
placeholder="Enter Mobile" required>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3 group_client new_client">
|
||||
<label for="gst">GST <span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="gst" name="gst"
|
||||
placeholder="Enter GST Number"
|
||||
oninput="validateInputForClient(this, 'client_branch', 'gst')"
|
||||
data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6"
|
||||
data-parsley-trigger="change"
|
||||
data-parsley-pattern="^\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}Z{1}[A-Z\d]{1}$" required>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right m-b-0">
|
||||
<a class="btn btn-primary waves-effect waves-light mr-1"
|
||||
onclick="getClientFormData()">Submit</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
$('#client_row_div').append(html);
|
||||
|
||||
if(client_type == 1){
|
||||
$('.group_client').show();
|
||||
$('.individual_client').hide();
|
||||
$(".group_client").find("select, input, textarea").val("").prop("required", true);
|
||||
$(".individual_client").find("select, input, textarea").val("").prop("required", false);
|
||||
}else{
|
||||
$('.group_client').hide();
|
||||
$('.individual_client').show();
|
||||
$(".group_client").find("select, input, textarea").val("").prop("required", false);
|
||||
$(".individual_client").find("select, input, textarea").val("").prop("required", true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$('#client_type').on('change', function() {
|
||||
|
||||
let client_type = $(this).val();
|
||||
|
||||
if(client_type == 1){
|
||||
$('.group_client').show();
|
||||
$('.individual_client').hide();
|
||||
$(".group_client").find("select, input, textarea").val("").prop("required", true);
|
||||
$(".individual_client").find("select, input, textarea").val("").prop("required", false);
|
||||
}else{
|
||||
$('.group_client').hide();
|
||||
$('.individual_client').show();
|
||||
$(".group_client").find("select, input, textarea").val("").prop("required", false);
|
||||
$(".individual_client").find("select, input, textarea").val("").prop("required", true);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function validateInputForClient(input, table, field) {
|
||||
|
||||
let owner_type = $('#Owner_type').val();
|
||||
let client_type = $('#client_type').val();
|
||||
|
||||
console.log('owner_type', owner_type);
|
||||
console.log('client_type', client_type);
|
||||
|
||||
if((client_type == 2 || owner_type == 2) && field == 'short_name'){
|
||||
return;
|
||||
}
|
||||
|
||||
let value = $(input).val();
|
||||
if (!value) return;
|
||||
|
||||
let label = $(input).closest('.form-group').find('label').text().replace('*', '').trim();
|
||||
let message = label ? label + " already exists!" : "Value is duplicate!";
|
||||
|
||||
// Set validating state
|
||||
isGSTValidating = true;
|
||||
isGSTValid = false;
|
||||
$('#hide_smbt_btn button').prop('disabled', true);
|
||||
|
||||
checkDuplicateTableFieldValue(table, field, value, function(isDuplicate) {
|
||||
isGSTValidating = false;
|
||||
if (isDuplicate) {
|
||||
toastr.warning(message, 'WARNING');
|
||||
// $(input).val('');
|
||||
isGSTValid = false;
|
||||
$('#client_add_modal_submit_btn').prop('disabled', true);
|
||||
} else {
|
||||
isGSTValid = true;
|
||||
$('#client_add_modal_submit_btn').prop('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
$('#hide_smbt_btn button').prop('disabled', false);
|
||||
}
|
||||
|
||||
</script>
|
||||
@ -1227,23 +1227,24 @@ $(document).ready(function(){
|
||||
|
||||
if(client_id == 'add_client') {
|
||||
|
||||
if($('#client_type').val()){
|
||||
$('#client_id').val('').change();
|
||||
// if($('#client_type').val()){
|
||||
// $('#client_id').val('').change();
|
||||
|
||||
if($('#client_type').val() == 2){
|
||||
$('#short_name').closest('.form-group').hide();
|
||||
$('#short_name').removeAttr('required');
|
||||
} else {
|
||||
$('#short_name').closest('.form-group').show();
|
||||
$('#short_name').attr('required', 'required');
|
||||
}
|
||||
// if($('#client_type').val() == 2){
|
||||
// $('#short_name').closest('.form-group').hide();
|
||||
// $('#short_name').removeAttr('required');
|
||||
// } else {
|
||||
// $('#short_name').closest('.form-group').show();
|
||||
// $('#short_name').attr('required', 'required');
|
||||
// }
|
||||
|
||||
var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
||||
myModal.show();
|
||||
}else{
|
||||
$('#client_id').val('').change();
|
||||
toastr.warning('Please select the client type', 'WARNING')
|
||||
}
|
||||
// var myModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
|
||||
// myModal.show();
|
||||
// }else{
|
||||
// $('#client_id').val('').change();
|
||||
// toastr.warning('Please select the client type', 'WARNING')
|
||||
// }
|
||||
appendClientForm();
|
||||
}
|
||||
|
||||
if(branch_list != '') {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user