Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
velz 2024-10-08 10:48:13 +05:30
commit aaeb29b9dc
18 changed files with 1128 additions and 64 deletions

View File

@ -241,6 +241,12 @@ $routes->group("/master", ["filter" => "authMVC"], function ($routes) {
$routes->get("list/(:any)", "MasterController::getCDMasterDataByID/$1");
$routes->get("remove/(:any)", "MasterController::removeCDMaster/$1");
});
$routes->group("vehicle", ["filter" => "authMVC"], function ($routes) {
$routes->get("list", "MasterController::VehicleMasterList");
$routes->get("list/(:any)", "MasterController::getVehicleMasterDataByID/$1");
$routes->get("remove/(:any)", "MasterController::deactiveVehicleData/$1");
});
});
@ -305,6 +311,7 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
$routes->get("get_client_policy_data_using_policy_no/(:any)", "ClientController::get_client_policy_data_using_policy_no/$1");
$routes->get("get_client_policy_data_using_policy_no_and_endo_no/(:any)", "ClientController::get_client_policy_data_using_policy_no_and_endo_no/$1");
$routes->get("checkInvoiceStatus/(:any)", "PolicyTransactionController::checkInvoiceStatus/$1");
$routes->get("base_policy_for_policy_inception/(:any)", "PolicyTransactionController::getBasePolicy/$1");
});

View File

@ -866,18 +866,19 @@ class ClientController extends AdminController
$data['cd_ac_no'] = $this->request->getPost('cd_ac_no');
$data['gst'] = $this->request->getPost('gst');
if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7){
$data['is_addon'] = 1;
$data['is_addon'] = 1; // Base Policy
}else if($policy_type_id == 4 || $policy_type_id == 5){
$data['is_addon'] = 2;
$data['is_addon'] = 2; // SI TOPUP
}else if($policy_type_id == 3){
if($base_policy){
$data['is_addon'] = 3;
$data['is_addon'] = 3; // Dependent Addon
}else{
$data['is_addon'] = 1;
}
@ -952,6 +953,8 @@ class ClientController extends AdminController
$id = $this->request->getPost('PrimaryKey');
$client_id = $this->request->getPost('client_id');
$policy_type_id = $this->request->getPost('policy_type_id');
$base_policy = $this->request->getPost('base_policy');
$insurerValue = (string) $this->request->getPost('insurer');
list($insurerBranchId, $insurerId) = explode('-', $insurerValue);
@ -1002,17 +1005,34 @@ class ClientController extends AdminController
$data['reminder_date'] = null;
}
if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 3 || $policy_type_id == 6 || $policy_type_id == 7){
// if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 3 || $policy_type_id == 6 || $policy_type_id == 7){
$data['is_addon'] = 1;
// $data['is_addon'] = 1;
}else if($policy_type_id == 4){
// }else if($policy_type_id == 4){
$data['is_addon'] = 2;
// $data['is_addon'] = 2;
}else if($policy_type_id == 5){
// }else if($policy_type_id == 5){
$data['is_addon'] = 3;
// $data['is_addon'] = 3;
// }
if($policy_type_id == 1 || $policy_type_id == 2 || $policy_type_id == 6 || $policy_type_id == 7){
$data['is_addon'] = 1; // Base Policy
}else if($policy_type_id == 4 || $policy_type_id == 5){
$data['is_addon'] = 2; // SI TOPUP
}else if($policy_type_id == 3){
if($base_policy){
$data['is_addon'] = 3; // Dependent Addon
}else{
$data['is_addon'] = 1;
}
}
@ -3261,6 +3281,7 @@ class ClientController extends AdminController
return $this->respond([
'status' => true,
'data' => $postData,
'client_id' => $client_insert,
'branch_id' => $branch_insert ?? null,
'message' => 'Client created successfully'
@ -3270,22 +3291,36 @@ class ClientController extends AdminController
public function createVehicleWithMinimalData()
{
$data = $this->request->getPost();
$id = $this->request->getPost('vehicle_primary_key');
$vehicle_insert = $this->vehicleModel->insert($data);
if($id){
$vehicle_update = $this->vehicleModel->where('id', $id)->set($data)->update();
if($vehicle_update){
return $this->respond(['status' => true, 'message' => 'Vehicle details updated successfully'], 200);
}else{
return $this->respond(['status' => false, 'message' => 'Failed to update vehicle details'], 200);
}
if($vehicle_insert){
$vehicles = $this->vehicleModel->where('is_active', 1)->findAll();
return $this->respond([
'status' => true,
'vehicle_id' => $vehicle_insert,
'owner_id' => $data['owner'],
'owner_branch_id' => $data['branch_id'],
'owner_type' => $data['Owner_type'],
'vehicles' => $vehicles,
'message' => 'Vehicle created successfully
'], 200);
}else{
return $this->respond(['status' => false, 'message' => 'Failed to created vehicle'], 200);
$vehicle_insert = $this->vehicleModel->insert($data);
if($vehicle_insert){
$vehicles = $this->vehicleModel->where('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);
}
}
}

View File

@ -1811,6 +1811,11 @@ class EmpDataServiceController extends BaseController
$file_data = $this->getDataByFileId($file_id, 'success');
$this->setPullNotification($file_data);
// if(excelFileGDriveUpload($file_id, 'batch_file')){
// $this->myLogger->logme('error', 'Inception Update Google Drive File Upload -- File Uploaded Successfully');
// }else{
// $this->myLogger->logme('error', 'Inception Update Google Drive File Upload -- File Uploaded Field');
// }
return 'Import Inception Updated ' . $status_val . '- Updated Count : ' . $emp_count;
}

View File

@ -148,6 +148,10 @@ class EmployeeController extends AdminController
public function employeesUplodWithEvents()
{
// $empDataServiceController = new EmpDataServiceController();
// !dd($empDataServiceController->importInceptionUpdateTPAandUHID(['file_id' => 79]));
// $job_details = new Jobs();
// $r = Jobs::addJob(['job_name' => 'add','payload' => ['a' => 10, 'b' => 35]]);
// print_r($r);//die();

View File

@ -1453,7 +1453,7 @@ class EmployeeRestController extends AdminController
if ($value > 0) {
if($value == 1 && $key ==='either-parents-pil') {
$result .= ' + Either 2 Parents or 2 Parents in law';
}if($value == 2 && $key ==='either-parents-pil') {
}else if($value == 2 && $key ==='either-parents-pil') {
$result .= ' + Any 2 of Parents and Parents in law';
}else if($value != 0 && $key ==='spouse') {
$string = str_replace('-', ' ', $key);

View File

@ -32,6 +32,7 @@ use App\Models\CDMasterModel;
use App\Models\ClientDepositModel;
use App\Models\InsurerExcelExportTemplateModel;
use App\Models\SettingsModel;
use App\Models\VehicleModel;
class MasterController extends AdminController
{
@ -57,6 +58,7 @@ class MasterController extends AdminController
protected $clientDepositModel;
protected $insurerTemplateModel;
protected $cli_colors;
protected $vehicleModel;
@ -85,6 +87,7 @@ class MasterController extends AdminController
$this->clientModel = new ClientModel();
$this->clientDepositModel = new ClientDepositModel();
$this->insurerTemplateModel = new InsurerExcelExportTemplateModel();
$this->vehicleModel = new VehicleModel();
$this->cli_colors = [
'red' => "\033[31m",
'green' => "\033[32m",
@ -1395,6 +1398,65 @@ class MasterController extends AdminController
}
//Vehicle Master data Function
public function VehicleMasterList()
{
$data['page_name'] = 'Vehicle Master List';
$data['vehicle_type'] = [
'two_wheeler' => 'Two Wheeler',
'four_wheeler' => 'Four Wheeler',
'truck' => 'Truck',
'bus' => 'Bus',
'van' => 'Van',
'suv' => 'SUV',
'motorcycle' => 'Motorcycle',
'bicycle' => 'Bicycle'
];
$data['vehicle_des'] = [
'commercial' => 'Commercial',
'private' => 'Private',
];
$data['entity'] = $this->kycEntityTypeModel->where('is_active', 1)->findAll();
$data['clients'] = $this->clientModel->where('is_active', 1)->findAll();
$data['vehicle_Master_Data'] = $this->vehicleModel->getVehicleMasterList();
$this->loadLayout('vehicle_master_list', $data);
}
public function getVehicleMasterDataByID($id = null)
{
$vehicle_data = $this->vehicleModel
->select('vehicle.*, clients.client_type')
->join('clients', 'vehicle.owner = clients.id')
->where('vehicle.id', $id)
->where('vehicle.is_active', 1)
->first();
if ($vehicle_data) {
return $this->respond(['status' => true, 'code' => 200, 'data' => $vehicle_data], 200);
} else {
return $this->respond(['status' => false, 'code' => 404], 200);
}
}
public function deactiveVehicleData($id)
{
$this->myLogger->logme('error','deactiveVehicleData function called');
$data['updated_by'] = get_session_userid();
$data['is_active'] = 0;
$update = $this->vehicleModel->where('id', $id)->set($data)->update();
if($update){
return $this->respond(['status' => true,'code' => 200], 200);
}else{
return $this->respond(['status' => false,'code' => 404], 200);
}
}
//excel export template
public function createExcelTemplate()
{

View File

@ -216,25 +216,46 @@ class PolicyTransactionController extends BaseController
// $data['renewal_date'] = change_date_format($this->request->getPost('renewal_date'), 'd/m/Y', 'Y-m-d') ?? null;
// $data['rollover_date'] = change_date_format($this->request->getPost('rollover_date'), 'd/m/Y', 'Y-m-d') ?? null;
$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_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_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['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['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['rollover_date'] = (isset($data['rollover_date']) && $data['rollover_date'] !== null && $data['rollover_date'] !== '')
// ? date('d/m/Y', strtotime($data['rollover_date']))
// : null;
if(empty($data['policy_issue_date'])){
$data['policy_issue_date'] = null;
}
if(empty($data['policy_start_date'])){
$data['policy_start_date'] = null;
}
if(empty($data['policy_end_date'])){
$data['policy_end_date'] = null;
}
if(empty($data['renewal_date'])){
$data['renewal_date'] = null;
}
if(empty($data['rollover_date'])){
$data['rollover_date'] = null;
}
// Separate Insurer and TPA Branch IDs and IDs
@ -275,7 +296,7 @@ class PolicyTransactionController extends BaseController
// Determine $is_addon value
$data['is_addon'] = in_array($data['policy_type_id'], [1, 2, 6, 7]) ? 1 :
(in_array($data['policy_type_id'], [4, 5]) ? 2 : ($data['policy_type_id'] == 3 && $data['base_policy'] ? 3 : 1));
(in_array($data['policy_type_id'], [4, 5]) ? 2 : ($data['policy_type_id'] == 3 && isset($data['base_policy']) ? 3 : 1));
// print_r($data); die;
@ -717,16 +738,14 @@ class PolicyTransactionController extends BaseController
->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')
// ->where('client_policy.client_id', $data['client_id'])
// ->where('client_policy.client_branch_id', $data['client_branch_id'])
// ->where('client_policy.policy_type_id', 2)
// ->where('client_policy.is_active', 1)
// ->findAll();
$data['base_policy_data'] = $this->clientPolicyModel->getPolicyDetailsForRemainder($data['client_id']);
$data['base_policy_data'] = $this->clientPolicyModel
->select('client_policy.*, policy_type.policy_type')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->where('client_policy.client_id', $data['client_id'])
->where('client_policy.client_branch_id', $data['client_branch_id'])
->whereIn('client_policy.policy_type_id', [2, 3])
->where('client_policy.is_active', 1)
->findAll();
$data['pt_files'] = $this->PTFileModel
->join('policy_transaction', 'pt_files.pt_id = policy_transaction.id')
@ -1234,6 +1253,24 @@ class PolicyTransactionController extends BaseController
}
}
public function getBasePolicy($client_id, $client_branch_id)
{
$data = $this->clientPolicyModel
->select('client_policy.*, policy_type.policy_type')
->join('policy_type', 'policy_type.id = client_policy.policy_type_id')
->where('client_policy.client_id', $client_id)
->where('client_policy.client_branch_id', $client_branch_id)
->whereIn('client_policy.policy_type_id', [2, 3])
->where('client_policy.is_active', 1)
->findAll();
if($data){
return $this->respond(['status' => true, 'data'=> $data, 'code' => 200], 200);
}else{
return $this->respond(['status' => false, 'count'=> 0, 'message' => 'No Data Found', 'code' => 404], 200);
}
}
//---------------------------------------------------------------------------------------------------
//get BDS Reports data
@ -1938,7 +1975,7 @@ class PolicyTransactionController extends BaseController
//get policy docs from policy transation related tables
$pt_files = $this->PTFileModel->getPolicyDriveFilesIndex($policy_id,$policy_doc_name);
// ~dd($this->PTFileModel->getLastQuery());
// ~dd($d);
// ~dd($pt_files);
}
if($customer_id != "")
{

View File

@ -71,7 +71,9 @@ class RestAuthenticationController extends AdminController
$mobile_number = $this->request->getJSON()->mobile_number;
$employeeData = $this->employeeModel->where('mobile', $mobile_number)->where('relationship', 'self')->first();
$employeeData = $this->employeeModel->where('mobile', $mobile_number)
->where('relationship', 'self')
->where('is_active', 1)->first();
if ($employeeData) {
@ -126,7 +128,9 @@ class RestAuthenticationController extends AdminController
try {
$mobile_number = $this->request->getJSON()->mobile_number;
$HrData = $this->hrModel->where('mobile', $mobile_number)->where('contact_type', 'client')->first();
$HrData = $this->hrModel->where('mobile', $mobile_number)
->where('contact_type', 'client')
->where('is_active', 1)->first();
if ($HrData) {

View File

@ -105,9 +105,9 @@ class sendMailNotification
$wholeData = [];
}
return $wholeData;
// }else{
// return "false";
// }
// }else{
// return "false";
// }
} else if($action == 'member_ecard_mail'){
$notification = $params['notification'];
@ -160,7 +160,7 @@ class sendMailNotification
$client_data =$clientModel->where('id', $client_id)->first();
$notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
if ($notification_data['enabled'] == 1) {
if (isset($notification_data) && $notification_data['enabled'] == 1) {
$mail_content = $notification_data['mail_content'];
$subject = $notification_data['subject'];
$app_link = $_ENV['App_Url'];
@ -259,7 +259,7 @@ class sendMailNotification
$client_data =$clientModel->where('id', $client_id)->first();
$notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
if ($notification_data['enabled'] == 1) {
if (isset($notification_data) && $notification_data['enabled'] == 1) {
$client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll();
$user_list= [];
foreach ($client_rm_data as $key => $value) {
@ -376,7 +376,7 @@ class sendMailNotification
$notification_data = $notificationModel->where('client_id' ,$client_id)->where('template_name', $action)->first();
$clientRMModel =new ClientRMModel();
if ($notification_data['enabled'] == 1) {
if (isset($notification_data['enabled']) && $notification_data['enabled'] == 1) {
$client_rm_data= $clientRMModel->where('client_id', $client_id)->where('is_active',1)->findAll();
$user_list= [];
foreach ($client_rm_data as $key => $value) {

View File

@ -1,7 +1,10 @@
<?php
use App\Models\ClientModel;
use App\Models\UserTeamsModel;
use App\Models\FileModel;
use App\Models\BatchFileModelFileModel;
use App\Controllers\GoogleDriveController;
use App\Models\BatchFileModel;
// File: app/Helpers/Uuid_helper.php
@ -318,6 +321,61 @@ if (!function_exists('generateRandomCode')) {
}
}
if (!function_exists('excelFileGDriveUpload')) {
function excelFileGDriveUpload($file_id, $table_name) {
$doc_type = "UPLOADS";
$uploadFilePath = WRITEPATH . 'uploads/' . ($table_name == 'batch_file' ? 'import_excel' : 'excel');
$models = [
'batch_file' => [
'model' => new BatchFileModel(),
'select' => "client_id, client_policy_id, file_name"
],
'files' => [
'model' => new FileModel(),
'select' => "client_id, policy_id as client_policy_id, file_name"
],
];
if (!array_key_exists($table_name, $models)) {
return;
}
// Retrieve data
$data = $models[$table_name]['model']
->select($models[$table_name]['select'])
->where('id', $file_id)
->where('is_active', 1)
->first();
if ($data) {
$uploadFilePath .= '/' . $data['file_name'];
// dd($data, $uploadFilePath);
$GoogleDriveController = new GoogleDriveController();
$result = $GoogleDriveController->uploadFiletoGdrive(
// client_id : $data['client_id'],
client_policy_id: $data['client_policy_id'],
doc_type : $doc_type,
file_path : $uploadFilePath,
file_name : $data['file_name']
);
// dd($result);
return true;
}else{
return false;
}
}
}
function numberToWords($number)

View File

@ -61,4 +61,26 @@ class VehicleModel extends Model
return $data;
}
public function getVehicleMasterList(){
return $this->db->table('vehicle')
->select("
vehicle.*,
CASE
WHEN clients.client_type = 1 THEN 'Group'
WHEN clients.client_type = 2 THEN 'Individual'
ELSE '-'
END AS owner_type,
clients.client_name as owner_name,
client_branch.branch_name as owner_branch
")
->join('clients', 'vehicle.owner = clients.id')
->join('client_branch', 'vehicle.branch_id = client_branch.id', 'left')
->where('vehicle.is_active', 1)
->orderBy('vehicle.id', 'desc')
->get()
->getResultArray();
}
}

View File

@ -180,6 +180,8 @@
"&file_name=" + item.file_name +
"&client_policy_id=client_policy_id";
// var url = '<?= base_url('download-kyc-docs/') ?>' + item.file_name;
// console.log('step 1')
if(item.file_name != null && item.file_name != ""){
@ -298,6 +300,7 @@
"&client_policy_id=client_policy_id";
// var url = '<?= base_url('download-kyc-docs/') ?>' + item.file_name;
// console.log("Current item:", item);
if (item.kyc_doc_type_id == '0') {
@ -468,6 +471,9 @@
"&file_name=" + item.file_name +
"&client_policy_id=client_policy_id";
// var url = '<?= base_url('download-kyc-docs/') ?>' + item.file_name;
if(item.kyc_doc_type_id == '0'){
table += `
<tr id="kyc-${item.id}">
@ -508,6 +514,9 @@
"&file_name=" + item.file_name +
"&client_policy_id=client_policy_id";
// var url = '<?= base_url('download-kyc-docs/') ?>' + item.file_name;
if(item.file_name != null && item.file_name != ""){
// console.log('step 2')

View File

@ -610,6 +610,9 @@
<li>
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
</li>
<li>
<a href="<?= base_url('/master/vehicle/list') ?>">Vehicle Master</a>
</li>
<li>
<a href="<?= base_url('/user/list') ?>"> Users </a>
</li>
@ -697,6 +700,9 @@
<li>
<a href="<?= base_url('/master/cash_deposite/list') ?>">CD Master</a>
</li>
<li>
<a href="<?= base_url('/master/vehicle/list') ?>">Vehicle Master</a>
</li>
<li>
<a href="<?= base_url('/dmsSearch') ?>">Documents</a>
</li>

View File

@ -175,7 +175,7 @@ table.dataTable thead th {
<button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" onclick="hide_list_show_add()">Add</button>
</div>
</div>
<div style="overflow-x: auto;">
<div>
<table class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
<thead class="bg-light">
<tr>
@ -276,6 +276,7 @@ table.dataTable thead th {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector

View File

@ -2864,9 +2864,9 @@ $('#policy_status').change(function(){
if(client_id && client_branch_id){
var url_for_get_policy_type_list = '<?php echo base_url('util/get_policy_type_for_base_policy/') ?>' + client_id + '/' + client_branch_id;
var url_for_get_policy_type_list = '<?php echo base_url('util/base_policy_for_policy_inception/') ?>' + client_id + '/' + client_branch_id;
$.get(url_for_get_policy_type_list, function(response){
console.log('get_policy_type_for_base_policy response', response)
console.log('base_policy_for_policy_inception response', response)
appendBasePolicyList(response.data);
}).fail(function(xhr, status, error) {
console.error(xhr.responseText);

View File

@ -243,7 +243,7 @@ table.dataTable tbody td {
<button type="button" id="btnAdd" class="btn btn-primary waves-effect waves-light" onclick="hide_list_show_add();">Add</button>
</div>
</div>
<div style="overflow-x: auto;">
<div>
<table class="table table-striped mb-0 nowrap" cellspacing="0" id="tickets-table">
<thead class="bg-light">
<tr>
@ -415,6 +415,7 @@ $(document).ready(function() {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-5 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector

View File

@ -31,7 +31,7 @@ table.dataTable tbody td {
</div>
</div>
<div class="table-responsive" style="overflow-x: auto;">
<div class="table-responsive">
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
@ -148,6 +148,7 @@ $(document).ready(function() {
if (ticketsTable.length) {
ticketsTable.DataTable({
scrollX: true,
dom: "<'row'<'col-sm-6'f><'col-sm-6 text-right'B>>" + // Filter left, buttons right
"<'row'<'col-sm-12'tr>>" +
"<'row'<'col-sm-5'i><'col-sm-7'p>>", // Pagination at the bottom, without page length selector

View File

@ -0,0 +1,812 @@
<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;
}
.readonly-select {
pointer-events: none;
background-color: #f0f0f0;
color: #666;
}
</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;">Vehicle 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"
onclick="showModal('add')">ADD</button>
</div>
</div>
<table id="scroll-horizontal-datatable" class="table w-100 nowrap">
<thead class="bg-light">
<tr>
<th class="font-weight-medium">S.No.</th>
<th class="font-weight-medium">Owner Type</th>
<th class="font-weight-medium">Owner Name</th>
<th class="font-weight-medium">RC Book No</th>
<th class="font-weight-medium">Vehicle No</th>
<th class="font-weight-medium">Vehicle type</th>
<th class="font-weight-medium">Description</th>
<th class="font-weight-medium">Action</th>
</tr>
</thead>
<tbody>
<?php foreach($vehicle_Master_Data as $index => $row){ ?>
<tr>
<td><?php echo $index+1; ?></td>
<td><?php echo $row['owner_type']; ?></td>
<td><?php echo $row['owner_name']; ?></td>
<td><?php echo $row['rc']; ?></td>
<td><?php echo $row['vehicle_no']; ?></td>
<td><?php echo $vehicle_type[$row['type']]; ?></td>
<td><?php echo $vehicle_des[$row['description']]; ?></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" data-id="<?= $row['id'];?>"
onclick="getEditVehicleDetailsData(this)"> <i
class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
<a class="dropdown-item" data-id="<?= $row['id'];?>"
onclick="removeVehicleMasterData(this)"><i
class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div><!-- end col -->
</div>
<!-- end row -->
<!-- modal content -->
<div class="modal fade" id="vehicle_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myCenterModalLabel">Add New Vehicle</h4>
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-label="Close"
aria-hidden="true">×</button>
</div>
<div class="modal-body">
<form class="parsley-examples" method="post" id="vehicle_form" enctype="multipart/form-data">
<div class="form-group">
<input type="hidden" id="vehicle_primary_key" name="vehicle_primary_key">
<div class="form-row">
<div class="form-group col-md-6 client_type_div">
<label for="owner_type">Owner Type<span class="text-danger">*</span></label>
<select class="form-control" id="Owner_type" name="Owner_type"
onchange="ownerTypeBasedShowAndHideOwnerBranch(this)" required>
<option value="">Select Owner type</option>
<option value="1">Group</option>
<option value="2">Individual</option>
</select>
</div>
<div class="form-group col-md-6">
<label for="cost_center">Vehicle No<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="vehicle_no" placeholder="Enter Vehicle No"
name="vehicle_no"
data-parsley-error-message="Invalid Vehicle Number. Example: TN22AB1234"
data-parsley-trigger="change"
data-parsley-pattern="^[A-Z]{2}[0-9]{2}[A-Z]{1,2}[0-9]{4}$" required>
</div>
<div class="form-group col-md-6">
<label for="rc">RC Book <span class="text-danger">*</span></label>
<input type="text" class="form-control" id="rc" placeholder="Enter RC Book No" name="rc"
required>
</div>
<div class="form-group col-md-6">
<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=" . $key . ">" . $value . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-6">
<label for="description">Description<span class="text-danger">*</span></label>
<select class="form-control" id="description" name="description" required>
<option value="">Select Description</option>
<?php
if (isset($vehicle_des) && count($vehicle_des)) {
foreach ($vehicle_des as $key => $value) {
echo "<option value=" . $key . ">" . $value . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-6">
<label for="rc"> Old Owner Name <span class="text-danger">(if exist)</span></label>
<input type="text" class="form-control" id="old_onwer" name="old_onwer"
placeholder="Enter Old Owner Name">
</div>
<div class="form-group col-md-12">
<label for="owner">Owner Name <span class="text-danger">*</span></label>
<select class="form-control" id="owner" name="owner"
onchange="listOwnerBranch(this); addClient(this)" required>
<option value="">Select Owner</option>
</select>
</div>
<div class="form-group col-md-12 ownerbranchdiv">
<label for="client_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>
</div>
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
<button type="submit" id="btnSubmit" class="btn btn-primary">Submit</button>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->
<!-- Client form content modal-->
<div class="modal fade" id="upload_enrollment_model" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="myCenterModalLabel">Add New Client</h4>
<button type="button" id="close_btn" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<form class="parsley-examples" method="post" id="client_form" enctype="multipart/form-data">
<div class="form-group">
<div class="form-row">
<div class="form-group col-md-12">
<label for="client_type">Client type<span class="text-danger">*</span></label>
<select class="form-control" id="client_type" name="client_type"
onchange="ownerTypeBasedShowAndHideOwnerBranch(this)" required>
<option value="">Select Owner type</option>
<option value="1">Group</option>
<option value="2">Individual</option>
</select>
</div>
<div class="form-group col-md-12">
<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-12">
<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" required>
</div>
<div class="form-group col-md-12">
<label for="cost_center">PAN<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="pan" placeholder="Enter PAN No" name="pan">
</div>
</div>
<hr>
<!-- Individual Client HTML -->
<div class="form-row clienttypediv" style="display: none;">
<div class="form-group col-md-6">
<label for="dob">Date of Birth<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="dob" placeholder="DD/MM/YYYY" name="dob">
</div>
<div class="form-group col-md-6">
<label for="cost_center">Mobile<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="phone" placeholder="Enter Mobile Number"
maxlength="10" name="phone" onkeypress="return onlyNumbers(event)">
</div>
<div class="form-group col-md-12">
<label for="cost_center">Email<span class="text-danger">*</span></label>
<input type="email" class="form-control" id="email" placeholder="Enter Email"
name="email">
</div>
<div class="form-group col-md-12">
<label for="aadhar">Aadhar<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="aadhar" placeholder="Enter PAN No"
name="aadhar">
</div>
</div>
<!-- Group client HTML -->
<div class="form-row branchdiv">
<div class="form-group col-md-12">
<label for="short_name">Entity Type<span class="text-danger">*</span></label>
<select class="form-control" id="entity_type_id" name="entity_type_id">
<option value="" selected>Select Entity</option>
<?php
if (isset($entity) && count($entity)) {
foreach ($entity as $key => $value) {
echo "<option value=" . $value['id'] . ">" . $value['name'] . "</option>";
}
}
?>
</select>
</div>
<div class="form-group col-md-6">
<label for="client_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-6">
<label for="branch_code">Branch Code<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="branch_code" name="branch_code">
</div>
<div class="form-group col-md-6">
<label for="branch_code">Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="name" name="name">
</div>
<div class="form-group col-md-6">
<label for="branch_code">Mobile<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="mobile" maxlength="10" name="mobile"
onkeypress="return onlyNumbers(event)">
</div>
<div class="form-group col-md-12">
<label for="gst">GST<span class="text-danger">*</span></label>
<input type="text" class="form-control" id="gst" placeholder="Enter GST Number"
data-parsley-error-message="Invalid GST Number. Example: 12ABCDE1234F5Z6" name="gst"
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>
<div class="form-group text-right m-b-0" id="hide_smbt_btn">
<button type="submit" class="btn btn-primary waves-effect waves-light mr-1">Submit</button>
</div>
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
<!-- end of Client form content modal -->
<script>
var client_list = ''; // local variable for storing the client list
var branch_list = ''; // local variable for storing the client branch list
$(document).ready(function() {
getClientAndBranchAndPolicy()
$('#owner').select2();
$('#owner_branch').select2();
})
$(document).ready(function() {
$('#scroll-horizontal-datatable').DataTable({
scrollX: true,
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: 'Vehicle-Master-List',
className: 'my_class',
exportOptions: {
columns: ':not(:last-child)'
},
}],
language: {
search: "_INPUT_",
searchPlaceholder: "Search..."
},
paging: true,
});
})
function getEditVehicleDetailsData(input) {
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var vehicle_id = $(input).attr('data-id');
$('#myCenterModalLabel').text('Update Vehicle Details');
showModal()
$.ajax({
url: '<?php echo base_url('master/vehicle/list/');?>' + vehicle_id,
type: "GET",
dataType: 'json',
success: function(res) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log(res)
// $('#vehicle_form').attr('action', '<?php echo base_url('master/vehicle/edit');?>');
$('#vehicle_primary_key').val(res.data.id);
$('#Owner_type').val(res.data.client_type);
$('#vehicle_no').val(res.data.vehicle_no);
$('#rc').val(res.data.rc);
$('#type').val(res.data.type);
$('#description').val(res.data.description);
$('#owner').val(res.data.owner).addClass('readonly-select').change().select2('destroy');
setTimeout(function() {
$('#owner_branch').val(res.data.branch_id).addClass('readonly-select').change()
.select2('destroy');
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}, 1000)
$('#btnSubmit').text('Update');
if (res.data.client_type == 2) {
$('.ownerbranchdiv').hide();
} else {
$('.ownerbranchdiv').show();
}
},
error: function(xhr, status, error) {
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.error(xhr.responseText);
console.error(status, error);
}
});
}
function showModal(type) {
if (type == 'add') {
$('#myCenterModalLabel').text('Add New Vehicle');
$('#Owner_type').val('');
$('#vehicle_no').val('');
$('#rc').val('');
$('#type').val('');
$('#description').val('');
$('#owner').val('').select2();
$('#owner_branch').val('').select2();
$('#btnSubmit').text('Submit');
}
var myModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
myModal.show();
}
function removeVehicleMasterData(element) {
Swal.fire({
title: "Are you sure?",
text: "You need to remove this Vehicle.",
icon: "info",
showCancelButton: true,
confirmButtonColor: "#3085d6",
confirmButtonText: "Yes",
}).then((result) => {
if (result.isConfirmed) {
var id = element.getAttribute('data-id');
var form_action = '<?= base_url("master/vehicle/remove/") ?>' + id;
$.ajax({
url: form_action,
type: "GET",
dataType: 'json',
processData: false,
contentType: false,
success: function(res) {
// console.log(res.status == true);
if (res) {
if (res.status == true) {
toastr.success('Vehicle Data removed successfully.', 'success');
location.reload();
} else {
toastr.warning('Failed to remove Vehicle Data.', 'warning');
}
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
console.log('Something Wrong!', 'warning');
}
});
}
});
}
function ownerTypeBasedShowAndHideOwnerBranch(input) {
var owner_type_id = $(input).val()
if (owner_type_id == 2) {
$('.ownerbranchdiv').hide();
// $('#owner_branch').prop('required', false);
} else {
$('.ownerbranchdiv').show();
// $('#owner_branch').prop('required', true);
}
// Clear and add default options for client
$('#owner').empty().append($('<option>', {
value: '',
text: 'Select Client'
}));
$('#owner').append($('<option>', {
value: 'add_owner',
text: '+ Add Owner'
}));
// Populate client options based on selected client type
if (owner_type_id) {
$.each(client_list, function(index, item) {
if (item.client_type == owner_type_id) {
var option = $('<option>', {
value: item.id,
text: item.client_name,
'data-cn': item.client_name,
'data-ct': item.client_type
});
$('#owner').append(option);
}
});
}
// Initialize or refresh Select2 for both dropdowns
$('#owner').select2();
}
function addClient(input) {
let client_id = $(input).val();
console.log('client_id ----', client_id);
if (client_id === 'add_owner') {
// Initialize the modals
// $('.close').click();
var vehicleModal = new bootstrap.Modal(document.getElementById('vehicle_modal'));
var clientModal = new bootstrap.Modal(document.getElementById('upload_enrollment_model'));
// Clear the form fields
$('#entity_type_id').val('');
$('#branch_name').val('');
$('#client_branch_id').val('');
$('#branch_code').val('');
$('#name').val('');
$('#mobile').val('');
$('#gst').val('');
$('#dob').val('');
$('#phone').val('');
$('#email').val('');
$('#aadhar').val('');
$('#owner').val('').change();
// Hide the vehicle modal
// vehicleModal.hide();
clientModal.show();
// Once the vehicle modal is hidden, show the client modal
// document.getElementById('vehicle_modal').addEventListener('hidden.bs.modal', function () {
// console.log('vehicle_modal is hidden');
// clientModal.show();
// });
}
}
//---------------------------------------------------------------------------------------------------
$("#vehicle_form").submit(function(event) {
event.preventDefault();
var isValid = $('#vehicle_form').parsley().validate();
if (!isValid) {
console.log('Form is Empty', 'Warning');
return;
}
form_action = '<?= base_url("util/createVehicleWithMinimalData"); ?>';
$('.loader').fadeIn();
$('.loader-mask').fadeIn();
var formData = new FormData($('#vehicle_form')[0]);
$.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 Vehicle Data response', res);
if (res.status == true) {
toastr.success(res.message, 'Success');
window.location.reload()
} else {
toastr.error(res.message, 'Error');
}
$('.close').click();
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
});
$("#client_form").submit(function(event) {
event.preventDefault();
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();
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 response', res)
// console.log('create Client With Minimal Data response', res.data)
if (res.status == true) {
getClientAndBranchAndPolicy();
if (res.data.client_type == 2) {
$('.ownerbranchdiv').hide();
} else {
$('.ownerbranchdiv').show();
}
$('#Owner_type').val(res.data.client_type);
setTimeout(function() {
$('#owner').val(res.client_id).change();
setTimeout(function() {
$('#owner_branch').val(res.branch_id).select2();
}, 1000);
}, 2000)
toastr.success(res.message, 'Success');
} else {
toastr.error(res.message, 'Error');
}
$('.close').click();
showModal()
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
$('.loader').fadeOut();
$('.loader-mask').delay(350).fadeOut('slow');
}
});
});
//----------------------------------------------------------------------------------------------------
$('#client_type').change(function() {
if ($(this).val() == 2) {
$('.branchdiv').hide();
$('.clienttypediv').show();
$('#entity_type_id').prop('required', false);
$('#branch_name').prop('required', false);
$('#client_branch_id').prop('required', false);
$('#branch_code').prop('required', false);
$('#name').prop('required', false);
$('#mobile').prop('required', false);
$('#gst').prop('required', false);
$('#dob').prop('required', true);
$('#phone').prop('required', true);
$('#email').prop('required', true);
$('#aadhar').prop('required', true);
} else {
$('.branchdiv').show();
$('.clienttypediv').hide();
$('#entity_type_id').prop('required', true);
$('#branch_name').prop('required', true);
$('#client_branch_id').prop('required', true);
$('#branch_code').prop('required', true);
$('#name').prop('required', true);
$('#mobile').prop('required', true);
$('#gst').prop('required', true);
$('#dob').prop('required', false);
$('#phone').prop('required', false);
$('#email').prop('required', false);
$('#aadhar').prop('required', false);
}
});
//----------------------------------------------------------------------------------------------------
function getClientAndBranchAndPolicy() {
$.ajax({
url: '<?= base_url("/util/getClientAndBranchAndPolicy") ?>',
type: "GET",
dataType: 'json',
success: function(res) {
console.log('getClientAndBranchAndPolicy', res);
if (res.status == true) {
client_list = res.client_data;
branch_list = res.branch_data;
appendOwner(client_list)
} else {
console.log('No data found');
}
},
error: function(xhr, status, error) {
console.error(xhr.responseText);
console.error(status, error);
}
});
}
function appendOwner(data) {
$('#owner').empty();
$('#owner').append($('<option>', {
value: '',
text: 'Select Owner'
}));
$('#owner').append($('<option>', {
value: 'add_owner',
text: '+ Add Owner'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.client_name,
});
$('#owner').append(option);
});
}
function listOwnerBranch(input) {
let owner_id = $(input).val();
console.log('owner_id', owner_id);
if (branch_list != '') {
// console.log(branch_list[client_id]);
let data = branch_list[owner_id];
appendOwnerBranch(data);
}
}
function appendOwnerBranch(data) {
$('#owner_branch').empty();
$('#owner_branch').append($('<option>', {
value: '',
text: 'Select Branch'
}));
$.each(data, function(index, item) {
var option = $('<option>', {
value: item.id,
text: item.branch_name
});
$('#owner_branch').append(option);
});
}
function onlyNumbers(event) {
var charcode;
charcode = event.which || event.keyCode;
if (charcode >= 48 && charcode <= 57 || charcode == 46) return true;
return false;
}
</script>