Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
291037fdaa
@ -396,6 +396,9 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) {
|
||||
$routes->post('savePlacementDataAndValidateMemberDataFile', 'LeadsController::savePlacementDataAndValidateMemberDataFile');
|
||||
$routes->get('checkMemberDataFileValidationStatus', 'LeadsController::checkMemberDataFileValidationStatus');
|
||||
$routes->match(['get', 'post', 'delete'], 'nhanceBranchMaster', 'MasterController::nhanceBranchMaster');
|
||||
$routes->match(['get', 'post', 'delete'], 'vehicleTypeMaster', 'MasterController::vehicleTypeMaster');
|
||||
$routes->match(['get', 'post', 'delete'], 'rtoMaster', 'MasterController::rtoMaster');
|
||||
|
||||
|
||||
});
|
||||
|
||||
@ -713,6 +716,7 @@ $routes->group('test', function($routes) {
|
||||
$routes->get('mapping_client_id_and_branch_id','TestingController::mapping_client_id_and_branch_id');
|
||||
$routes->get('membervalidation', 'TestingController::membervalidation');
|
||||
$routes->get('generateExcel', 'TestingController::generateExcel');
|
||||
$routes->get('logo_renaming','TestingController::logo_renaming');
|
||||
});
|
||||
$routes->cli('cli/testcli', 'TestingController::testcli');
|
||||
|
||||
|
||||
@ -4816,6 +4816,7 @@ class ClientController extends AdminController
|
||||
'vehicle_no' => $data['vehicle_no'],
|
||||
'type' => $data['type'],
|
||||
'rc' => $data['rc'],
|
||||
'rto_id' => $data['rto_id'],
|
||||
'branch_id' => $branch_insert,
|
||||
'owner' => $client_insert,
|
||||
];
|
||||
@ -4861,6 +4862,7 @@ class ClientController extends AdminController
|
||||
'vehicle_no' => $data['vehicle_no'],
|
||||
'type' => $data['type'],
|
||||
'rc' => $data['rc'],
|
||||
'rto_id' => $data['rto_id'],
|
||||
'branch_id' => $data['branch_id'] ?? null,
|
||||
'owner' => $data['owner'],
|
||||
];
|
||||
|
||||
@ -36,6 +36,8 @@ use App\Models\InsurerExcelExportTemplateModel;
|
||||
use App\Models\NhanceBranchModel;
|
||||
use App\Models\SettingsModel;
|
||||
use App\Models\VehicleModel;
|
||||
use App\Models\VehicleTypeModel;
|
||||
use App\Models\RTOModel;
|
||||
|
||||
use CodeIgniter\CLI\CLI;
|
||||
|
||||
@ -2022,15 +2024,19 @@ class MasterController extends AdminController
|
||||
dd($result);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
|
||||
public function nhanceBranchMaster()
|
||||
{
|
||||
$nhanceBranchModel = new NhanceBranchModel();
|
||||
$method = $this->request->getMethod();
|
||||
$data['tab_name'] = 'Nhance Branch';
|
||||
$data['page_name'] = 'Nhance Branchs';
|
||||
|
||||
if ($this->request->is('post')) {
|
||||
if ($method === 'post') {
|
||||
|
||||
$id = $this->request->getPost('pk') ?? null;
|
||||
$data = $this->request->getPost();
|
||||
print_r($data); die;
|
||||
|
||||
if (empty($id)) {
|
||||
$update_status = $nhanceBranchModel->insert($data);
|
||||
@ -2054,7 +2060,7 @@ class MasterController extends AdminController
|
||||
], 200);
|
||||
}
|
||||
|
||||
} elseif ($this->request->is('get')) {
|
||||
} elseif ($method === 'get') {
|
||||
|
||||
$id = $this->request->getGet('pk') ?? null;
|
||||
|
||||
@ -2070,7 +2076,7 @@ class MasterController extends AdminController
|
||||
$data = $nhanceBranchModel->where('is_active', 1)->findAll();
|
||||
return $this->loadLayout('nhance_branch_list', ['data' => $data]);
|
||||
|
||||
} elseif ($this->request->is('delete')) {
|
||||
} elseif ($method === 'delete') {
|
||||
|
||||
$input = $this->request->getRawInput();
|
||||
$id = $input['pk'] ?? null;
|
||||
@ -2106,7 +2112,167 @@ class MasterController extends AdminController
|
||||
|
||||
public function vehicleTypeMaster()
|
||||
{
|
||||
$vehicleTypeModel = new VehicleTypeModel();
|
||||
$method = $this->request->getMethod();
|
||||
$data['tab_name'] = 'Vehicle Type';
|
||||
$data['page_name'] = 'Vehicle Types';
|
||||
if ($method === 'post') {
|
||||
|
||||
$id = $this->request->getPost('pk') ?? null;
|
||||
$data = $this->request->getPost();
|
||||
|
||||
if (empty($id)) {
|
||||
$update_status = $vehicleTypeModel->insert($data);
|
||||
} else {
|
||||
$update_status = $vehicleTypeModel->where('id', $id)->set($data)->update();
|
||||
}
|
||||
|
||||
if ($update_status) {
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
'message' => 'Vehicle Type Master updated successfully',
|
||||
'data' => $data
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 400,
|
||||
'message' => 'Failed to update',
|
||||
'data' => $data
|
||||
], 200);
|
||||
}
|
||||
|
||||
} elseif ($method === 'get') {
|
||||
|
||||
$id = $this->request->getGet('pk') ?? null;
|
||||
|
||||
if (!empty($id)) {
|
||||
$data = $vehicleTypeModel->where('is_active', 1)->where('id', $id)->findAll();
|
||||
if (!empty($data)) {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No data found'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
$data = $vehicleTypeModel->where('is_active', 1)->findAll();
|
||||
return $this->loadLayout('vehicle_type_master_list', ['data' => $data]);
|
||||
|
||||
} elseif ($method === 'delete') {
|
||||
|
||||
$input = $this->request->getRawInput();
|
||||
$id = $input['pk'] ?? null;
|
||||
|
||||
if (empty($id)) {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 404,
|
||||
'message' => 'No ID provided for deletion'
|
||||
], 200);
|
||||
}
|
||||
|
||||
$update_status = $vehicleTypeModel->where('id', $id)->set(['is_active' => 0])->update();
|
||||
|
||||
if ($update_status) {
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
'message' => 'Data removed successfully',
|
||||
'pk' => $id
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 400,
|
||||
'message' => 'Failed to remove data',
|
||||
'pk' => $id
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function rtoMaster()
|
||||
{
|
||||
$rtoModel = new RTOModel();
|
||||
$method = $this->request->getMethod();
|
||||
$data['tab_name'] = 'RTO';
|
||||
$data['page_name'] = 'RTO';
|
||||
|
||||
if ($method === 'post') {
|
||||
|
||||
$id = $this->request->getPost('pk') ?? null;
|
||||
$data = $this->request->getPost();
|
||||
|
||||
if (empty($id)) {
|
||||
$update_status = $rtoModel->insert($data);
|
||||
} else {
|
||||
$update_status = $rtoModel->where('id', $id)->set($data)->update();
|
||||
}
|
||||
|
||||
if ($update_status) {
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
'message' => 'RTO Master updated successfully',
|
||||
'data' => $data
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 400,
|
||||
'message' => 'Failed to update',
|
||||
'data' => $data
|
||||
], 200);
|
||||
}
|
||||
|
||||
} elseif ($method === 'get') {
|
||||
|
||||
$id = $this->request->getGet('pk') ?? null;
|
||||
|
||||
if (!empty($id)) {
|
||||
$data = $rtoModel->where('is_active', 1)->where('id', $id)->findAll();
|
||||
if (!empty($data)) {
|
||||
return $this->respond(['status' => true, 'code' => 200, 'data' => $data], 200);
|
||||
} else {
|
||||
return $this->respond(['status' => false, 'code' => 400, 'message' => 'No data found'], 200);
|
||||
}
|
||||
}
|
||||
|
||||
$data = $rtoModel->where('is_active', 1)->findAll();
|
||||
return $this->loadLayout('rto_master_list', ['data' => $data]);
|
||||
|
||||
} elseif ($method === 'delete') {
|
||||
|
||||
$input = $this->request->getRawInput();
|
||||
$id = $input['pk'] ?? null;
|
||||
|
||||
if (empty($id)) {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 404,
|
||||
'message' => 'No ID provided for deletion'
|
||||
], 200);
|
||||
}
|
||||
|
||||
$update_status = $rtoModel->where('id', $id)->set(['is_active' => 0])->update();
|
||||
|
||||
if ($update_status) {
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
'message' => 'Data removed successfully',
|
||||
'pk' => $id
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 400,
|
||||
'message' => 'Failed to remove data',
|
||||
'pk' => $id
|
||||
], 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -151,6 +151,8 @@ class PolicyTransactionController extends BaseController
|
||||
// 'bicycle' => 'Bicycle'
|
||||
// ];
|
||||
$data['vehicle_type'] = db_connect()->table('vehicle_type')->where('is_active', 1)->get()->getResultArray();
|
||||
$data['rto_details'] = db_connect()->table('rto_master')->where('is_active', 1)->get()->getResultArray();
|
||||
|
||||
$data['vehicle_des'] = [
|
||||
'commercial' => 'Commercial',
|
||||
'private' => 'Private',
|
||||
@ -2122,7 +2124,7 @@ class PolicyTransactionController extends BaseController
|
||||
//insurer statement list page
|
||||
public function statementList()
|
||||
{
|
||||
// dd($this->validateInsurerStatement(['file_id' => 49])); // for check validateInsurerStatementfunction with hard coded file id always un command
|
||||
// dd($this->updateInsurerStatement(['file_id' => 133])); // for check validateInsurerStatementfunction with hard coded file id always un command
|
||||
$data['insurers'] = $this->insurerModel->where('is_active',1)->findAll();
|
||||
$today = date('Y-m-d');
|
||||
$fromday = $from_date = date('Y-m-d', strtotime('-180 days', strtotime($today)));
|
||||
@ -2367,13 +2369,13 @@ class PolicyTransactionController extends BaseController
|
||||
// $excel_row = ExcelSanitizeHelper::sanitizeArrayData($excel_row);
|
||||
$is_source_found = 0;
|
||||
// Kint::dump($excel_key,$excel_row[1],$excel_row[2]);
|
||||
$policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel
|
||||
$policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel
|
||||
// $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel
|
||||
// $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel
|
||||
|
||||
$policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_end_date from excel
|
||||
$policy_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[1]); //policy_end_date from excel
|
||||
|
||||
$client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
|
||||
// $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
|
||||
|
||||
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel
|
||||
$endorsement_no = preg_replace( '/[\x{200B}\x{200C}\x{200D}\x{FEFF}\x{00A0}\x{200E}\x{200F}\x{202A}-\x{202E}]/u', '', $excel_row[2]); //policy_end_date from excel
|
||||
@ -2479,11 +2481,11 @@ class PolicyTransactionController extends BaseController
|
||||
if (!$is_row_empty) {
|
||||
|
||||
$is_source_found = 0;
|
||||
$policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel
|
||||
$policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel
|
||||
// $policy_start_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[4]); //policy_start_date from excel
|
||||
// $policy_end_date = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[5]); //policy_end_date from excel
|
||||
$policy_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[1]); //policy_end_date from excel
|
||||
$policy_no = preg_replace('/[\x{200C}\x{200B}]/u', '', $excel_row[1]); //
|
||||
$client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
|
||||
// $client_name = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[3]); //clientname from excel
|
||||
$endorsement_no = preg_replace('/^\p{Z}+|\p{Z}+$/u', '', $excel_row[2]); //policy_end_date from excel
|
||||
|
||||
foreach ($source_data as $source_key => $source_row) {
|
||||
@ -2496,9 +2498,10 @@ class PolicyTransactionController extends BaseController
|
||||
//calculate percentage first
|
||||
$total_amt = 0;
|
||||
|
||||
$actual_bp_per = trim($excel_row[9]);
|
||||
$actual_bp_brokerage = trim($excel_row[12]);
|
||||
$actual_bp_amt = trim($excel_row[6]);
|
||||
// $actual_bp_per = trim($excel_row[9]); //commented becoz this filed removed tfrom excel file
|
||||
$actual_bp_per = 0; //set default value 0 for maintaining existing code flow
|
||||
$actual_bp_brokerage = trim($excel_row[5]);
|
||||
$actual_bp_amt = trim($excel_row[3]);
|
||||
|
||||
if (($actual_bp_brokerage && $actual_bp_brokerage != 0 && $actual_bp_brokerage != "")) {
|
||||
$total_amt += $actual_bp_brokerage;
|
||||
@ -2511,9 +2514,10 @@ class PolicyTransactionController extends BaseController
|
||||
$total_amt += $actual_bp_brokerage;
|
||||
}
|
||||
|
||||
$actual_tp_per = trim($excel_row[10]);
|
||||
$actual_tp_brokerage = trim($excel_row[13]);
|
||||
$actual_tp_amt = trim($excel_row[7]);
|
||||
// $actual_tp_per = trim($excel_row[10]);//commented becoz this filed removed tfrom excel file
|
||||
$actual_tp_per = 0;//set default value 0 for maintaining existing code flow
|
||||
$actual_tp_brokerage = trim($excel_row[6]);
|
||||
$actual_tp_amt = trim($excel_row[4]);
|
||||
|
||||
if ($actual_tp_brokerage && $actual_tp_brokerage != 0 && $actual_tp_brokerage != "") {
|
||||
$total_amt += $actual_tp_brokerage;
|
||||
@ -2526,9 +2530,13 @@ class PolicyTransactionController extends BaseController
|
||||
$total_amt += $actual_tp_brokerage;
|
||||
}
|
||||
|
||||
$actual_tep_per = trim($excel_row[11]);
|
||||
$actual_tep_brokerage = trim($excel_row[14]);
|
||||
$actual_tep_amt = trim($excel_row[8]);
|
||||
// $actual_tep_per = trim($excel_row[11]);
|
||||
// $actual_tep_brokerage = trim($excel_row[14]);
|
||||
// $actual_tep_amt = trim($excel_row[8]);
|
||||
|
||||
$actual_tep_per = 0;
|
||||
$actual_tep_brokerage = 0;
|
||||
$actual_tep_amt = 0;
|
||||
|
||||
if ($actual_tep_brokerage && $actual_tep_brokerage != 0 && $actual_tep_brokerage != "") {
|
||||
$total_amt += $actual_tep_brokerage;
|
||||
@ -2544,7 +2552,7 @@ class PolicyTransactionController extends BaseController
|
||||
//find variance
|
||||
$variance_amt = $source_row['exp_amt'] - $total_amt;
|
||||
|
||||
$data_to_update[] = ['co_share_id' => $source_row['id'], 'actual_bp_amt' => $actual_bp_amt, 'actual_tp_amt' => $actual_tp_amt, 'actual_tep_amt' => $actual_tep_amt, 'actual_bp_per' => $actual_bp_per, 'actual_tp_per' => $actual_tp_per, 'actual_tep_per' => $actual_tep_per, 'variance' => $variance_amt, 'actual_tep_brokerage_amt' => $actual_tep_brokerage, 'actual_tp_brokerage_amt' => $actual_tp_brokerage, 'actual_bp_brokerage_amt' => $actual_bp_brokerage, 'reward' => trim($excel_row[15]), 'statement_id' => $file_id];
|
||||
$data_to_update[] = ['co_share_id' => $source_row['id'], 'actual_bp_amt' => $actual_bp_amt, 'actual_tp_amt' => $actual_tp_amt, 'actual_tep_amt' => $actual_tep_amt, 'actual_bp_per' => $actual_bp_per, 'actual_tp_per' => $actual_tp_per, 'actual_tep_per' => $actual_tep_per, 'variance' => $variance_amt, 'actual_tep_brokerage_amt' => $actual_tep_brokerage, 'actual_tp_brokerage_amt' => $actual_tp_brokerage, 'actual_bp_brokerage_amt' => $actual_bp_brokerage, 'reward' => trim($excel_row[7]), 'statement_id' => $file_id];
|
||||
|
||||
unset($source_data[$source_key]);
|
||||
continue 2;
|
||||
|
||||
@ -715,4 +715,97 @@ class TestingController extends BaseController
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function logo_renaming(){
|
||||
|
||||
$directory = ROOTPATH . 'public/uploads/logo/';
|
||||
|
||||
if (!is_dir($directory)) {
|
||||
die("Directory not found: $directory");
|
||||
}
|
||||
|
||||
$files = scandir($directory);
|
||||
|
||||
$client_logo_files = $this->get_client_logo_files();
|
||||
|
||||
$rename_files = "";
|
||||
$failed_rename_files = "";
|
||||
|
||||
foreach ($files as $file) {
|
||||
// Skip system entries
|
||||
if ($file === '.' || $file === '..' ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
$oldPath = $directory . $file;
|
||||
|
||||
if (is_file($oldPath) && in_array(trim($file) , $client_logo_files)) {
|
||||
|
||||
// Remove all spaces from filename
|
||||
$newFileName = preg_replace('/\s+|\x{00A0}|\x{200B}|\x{200C}|\x{200D}|\x{FEFF}/u', '', $file);
|
||||
|
||||
$newPath = $directory . $newFileName;
|
||||
|
||||
// Only rename if the name changed
|
||||
if ($oldPath !== $newPath) {
|
||||
if (rename($oldPath, $newPath)) {
|
||||
$rename_files .= "\n Renamed: $file → $newFileName \n";
|
||||
} else {
|
||||
$failed_rename_files .= "\n Failed file: $file \n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$dbUpdated = $this->update_client_logo_files();
|
||||
|
||||
log_message('error', 'Renamed Files: ' . $rename_files);
|
||||
log_message('error', 'Failed Renames: ' . $failed_rename_files);
|
||||
log_message('error', 'Database Update Status: ' . ($dbUpdated ? 'Success' : 'No changes made'));
|
||||
|
||||
return $this->response->setJSON(['status' => 'success',
|
||||
'message' => 'Logo renaming completed. kindly check backend logs for details',
|
||||
'data' => [
|
||||
'renamed_files' => $rename_files,
|
||||
'failed_renames' => $failed_rename_files
|
||||
]
|
||||
])->setStatusCode(200);
|
||||
}
|
||||
|
||||
public function get_client_logo_files(){
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
$sql = "SELECT client_logo FROM clients WHERE client_logo IS NOT NULL AND TRIM(client_logo) <> '' ";
|
||||
|
||||
$query = $db->query($sql);
|
||||
|
||||
$results = $query->getResultArray() ?? [];
|
||||
|
||||
$files = array_map(function($item) {
|
||||
return trim($item['client_logo']);
|
||||
}, $results);
|
||||
|
||||
return $files;
|
||||
}
|
||||
|
||||
public function update_client_logo_files(){
|
||||
|
||||
$db = \Config\Database::connect();
|
||||
|
||||
$sql = "UPDATE clients
|
||||
SET client_logo = REPLACE(REPLACE(REPLACE(client_logo, CHAR(160), ''), ' ', ''), '\t', '')
|
||||
WHERE client_logo IS NOT NULL
|
||||
AND TRIM(client_logo) <> ''
|
||||
";
|
||||
|
||||
$query = $db->query($sql);
|
||||
|
||||
return $db->affectedRows() > 0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
57
app/Models/RTOModel.php
Normal file
57
app/Models/RTOModel.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class RTOModel extends Model
|
||||
{
|
||||
|
||||
protected $table = 'rto_master';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
|
||||
'id',
|
||||
'rto_state',
|
||||
'rto_code',
|
||||
'rto_name',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'updated_at',
|
||||
'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;
|
||||
}}
|
||||
@ -25,6 +25,7 @@ class VehicleModel extends Model
|
||||
'is_active',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'rto_id',
|
||||
];
|
||||
|
||||
|
||||
|
||||
@ -1792,6 +1792,15 @@
|
||||
<li>
|
||||
<a href="<?= base_url('/user/list') ?>"> Users </a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/util/nhanceBranchMaster') ?>"> Nhance Branch </a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/util/vehicleTypeMaster') ?>"> Vehicle Type </a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="<?= base_url('/util/rtoMaster') ?>"> RTO </a>
|
||||
</li>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
|
||||
@ -14,25 +14,43 @@
|
||||
<tr>
|
||||
<th class="font-weight-medium">S.No.</th>
|
||||
<th class="font-weight-medium">Branch Name</th>
|
||||
<!-- <th class="font-weight-medium">Status</th> -->
|
||||
<th class="font-weight-medium">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if(isset($data)) { ?>
|
||||
<?php foreach($data as $index => $row) { ?>
|
||||
<tr>
|
||||
<td class="text-dark"><?= esc($index + 1); ?></td>
|
||||
<td class="text-dark"> <?= esc($index + 1); ?></td>
|
||||
<td><?= $row['branch_name']; ?></td>
|
||||
<!-- <td>
|
||||
<span class="<?php if($row['is_active'] == 1){ echo 'badge badge-primary'; }else{ echo 'badge badge-danger'; } ?>">
|
||||
<?php if($row['is_active'] == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?>
|
||||
</span>
|
||||
</td> -->
|
||||
<td>
|
||||
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
|
||||
<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" style="cursor: pointer;">
|
||||
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', <?= $row['id']; ?>)"><i data-id="<?= $row['id']; ?>" class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('remove', <?= $row['id']; ?>)"><i data-id="<?= $row['id']; ?>" class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
|
||||
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', this)">
|
||||
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
||||
</a>
|
||||
<?php if ($row['is_active'] == 1): ?>
|
||||
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('remove', this)">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<tr>
|
||||
<td colspan="3" class="text-center">No data available</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
@ -43,14 +61,15 @@
|
||||
|
||||
<!-- modal content -->
|
||||
<div id="con-close-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Add Branch</h4>
|
||||
<h4 class="modal-title" id="modalLabel">Add Branch</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body p-4">
|
||||
<form class="parsley-examples" id="nhanceBranchForm" enctype="multipart/form-data">
|
||||
<!-- <form class="parsley-examples" id="nhanceBranchForm" enctype="multipart/form-data"> -->
|
||||
<form id="nhanceBranchForm" enctype="multipart/form-data">
|
||||
<input type="hidden" name="pk" id="nhance_branch_id"/>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
@ -61,7 +80,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit" onclick="handleSaveEditAndDelete('submit')">Submit</button>
|
||||
<button type="button" class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit" onclick="handleSaveEditAndDelete('submit')">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
@ -69,7 +88,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
var table;
|
||||
$(document).ready(function () {
|
||||
@ -127,42 +145,100 @@
|
||||
myModal.show();
|
||||
}
|
||||
|
||||
function handleSaveEditAndDelete(type = 'submit', pk = null){
|
||||
// old Version
|
||||
// function handleSaveEditAndDelete(type = 'submit', pk = null){
|
||||
|
||||
console.log("type", type)
|
||||
// let url = '<?= base_url('util/nhanceBranchMaster') ?>';
|
||||
// let method = "POST";
|
||||
// let requestData = {};
|
||||
|
||||
// $('#modalLabel').text('Add Branch');
|
||||
// requestData.pk = pk;
|
||||
|
||||
// if(type == 'submit'){
|
||||
// $("#nhanceBranchForm").find("input, select, textarea").each(function () {
|
||||
// let name = $(this).attr("name");
|
||||
// let value = $.trim($(this).val());
|
||||
// if (name) requestData[name] = value;
|
||||
// });
|
||||
// }
|
||||
|
||||
// if(type == 'remove'){
|
||||
// method = "DELETE";
|
||||
// }else if (type == 'edit'){
|
||||
// method = "GET"
|
||||
// }
|
||||
|
||||
// console.log("type", type)
|
||||
// console.log("url", url)
|
||||
// console.log("method", method)
|
||||
// console.log("requestData", requestData)
|
||||
|
||||
|
||||
// $('.loader').fadeIn();
|
||||
// $('.loader-mask').fadeIn();
|
||||
|
||||
// // Send AJAX request
|
||||
// sendAjaxRequestForGlobal(url, method, requestData, function(response) {
|
||||
|
||||
// console.log('Data fetched successfully:', response);
|
||||
|
||||
// if (response.status) {
|
||||
// if(type == 'edit'){
|
||||
// $('#modalLabel').text('Edit Branch');
|
||||
// appendEditData(response.data);
|
||||
// }else{
|
||||
// toastr.success(response.message, 'SUCCESS');
|
||||
// }
|
||||
// } else {
|
||||
// toastr.warning(response.message, 'WARNING');
|
||||
// }
|
||||
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
// }, function(xhr, status, error) {
|
||||
// console.error('Error fetching data:', error);
|
||||
// console.error(xhr.responseText);
|
||||
// $('.loader').fadeOut();
|
||||
// $('.loader-mask').delay(350).fadeOut('slow');
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
function handleSaveEditAndDelete(type = 'submit', el = null) {
|
||||
|
||||
let url = '<?= base_url('util/nhanceBranchMaster') ?>';
|
||||
console.log("url", url)
|
||||
|
||||
|
||||
let method = "POST";
|
||||
let requestData = {};
|
||||
|
||||
let pk = null;
|
||||
|
||||
// If element is passed (from edit/remove button), get its data-id
|
||||
if (el) { pk = $(el).data('id'); }
|
||||
|
||||
requestData.pk = pk;
|
||||
|
||||
if(type == 'submit'){
|
||||
$("#vehicle_form_row_div").find("input, select, textarea").each(function () {
|
||||
$("#nhanceBranchForm").find("input, select, textarea").each(function () {
|
||||
let name = $(this).attr("name");
|
||||
let value = $.trim($(this).val());
|
||||
|
||||
if (name) {
|
||||
requestData[name] = value;
|
||||
console.log("✅ Added field:", name, "=", value);
|
||||
}
|
||||
if (name) requestData[name] = value;
|
||||
});
|
||||
}else{
|
||||
requestData = {
|
||||
pk: pk,
|
||||
};
|
||||
}
|
||||
|
||||
console.log("requestData", requestData)
|
||||
|
||||
|
||||
let method = "POST";
|
||||
if(type == 'remove'){
|
||||
method = "DELETE";
|
||||
}else if (type == 'edit'){
|
||||
method = "GET"
|
||||
method = "DELETE";
|
||||
} else if (type == 'edit'){
|
||||
method = "GET";
|
||||
$('#modalLabel').text('Edit Branch');
|
||||
$('#nhanceBranchForm')[0].reset();
|
||||
}
|
||||
console.log("method", method)
|
||||
|
||||
console.log("type", type)
|
||||
console.log("url", url)
|
||||
console.log("method", method)
|
||||
console.log("requestData", requestData)
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
@ -175,11 +251,18 @@
|
||||
if (response.status) {
|
||||
if(type == 'edit'){
|
||||
appendEditData(response.data);
|
||||
}else{
|
||||
toastr.success(response.message, 'SUCCESS');
|
||||
} else if(type == 'remove'){
|
||||
toastr.success(response.message, 'Success');
|
||||
if(el) $(el).closest('tr').remove();
|
||||
} else if(type == 'submit'){
|
||||
toastr.success(response.message, 'Success');
|
||||
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||||
myModal.hide();
|
||||
$('#nhanceBranchForm')[0].reset();
|
||||
window.location.reload();
|
||||
}
|
||||
} else {
|
||||
toastr.warning(response.message, 'WARNING');
|
||||
toastr.warning(response.message, 'Warning');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
@ -188,19 +271,19 @@
|
||||
}, 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');
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
});
|
||||
}
|
||||
|
||||
function resetValues(){
|
||||
$('#branch_name').val('');
|
||||
$('#modalLabel').text('Add Branch');
|
||||
$('#nhanceBranchForm')[0].reset();
|
||||
}
|
||||
|
||||
function appendEditData(data){
|
||||
$('#branch_name').val(data.branch_name);
|
||||
$('#nhance_branch_id').val(data[0]['id']);
|
||||
$('#branch_name').val(data[0]['branch_name']);
|
||||
openModal()
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -5640,6 +5640,20 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="rto_id">RTO</label>
|
||||
<select class="form-control readonly-color readonly-select" id="rto_id" name="rto_id" style="appearance:none;-webkit-appearance:none;-moz-appearance:none;cursor:not-allowed;">
|
||||
<option value=""></option>
|
||||
<?php
|
||||
if (isset($rto_details) && count($rto_details)) {
|
||||
foreach ($rto_details as $key => $value) {
|
||||
echo '<option value="' . $value['id'] . '" data-state="' . $value['rto_state'] . '" data-code="' . $value['rto_code'] . '">' . $value['rto_name'] . '</option>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-3">
|
||||
<label for="rc">Chassis No</label>
|
||||
<input type="text" class="form-control" id="rc" name="rc"
|
||||
@ -5739,6 +5753,13 @@
|
||||
appendOwner(client_list);
|
||||
$('#owner').select2();
|
||||
$('#owner_branch').select2();
|
||||
$('#client_name').on('input', generateShortName);
|
||||
/** $("#client_name").on("input change keyup", function() {
|
||||
clearTimeout(shortNameTimer); // cancel previous call
|
||||
shortNameTimer = setTimeout(() => {
|
||||
generateShortName(); // only runs after 200ms pause
|
||||
}, 200); // adjust debounce delay as needed
|
||||
}); **/
|
||||
|
||||
// $("#vehicle_form_row_div").on("input change", "input, select, textarea", function () {
|
||||
// if ($("#client_type").val() === "") {
|
||||
@ -6001,6 +6022,9 @@
|
||||
// resultDiv.classList.add('show');
|
||||
$('#vehicle_no_validation').val('1');
|
||||
}
|
||||
|
||||
// call here
|
||||
autoFetchRtoName(input);
|
||||
}
|
||||
|
||||
// Custom Parsley validator for vehicle format
|
||||
@ -6147,6 +6171,14 @@
|
||||
</div>`;
|
||||
|
||||
$('#client_row_div').append(html);
|
||||
$('#client_name').on('input', generateShortName);
|
||||
/** $("#client_name").on("input change keyup", function() {
|
||||
clearTimeout(shortNameTimer); // cancel previous call
|
||||
shortNameTimer = setTimeout(() => {
|
||||
generateShortName(); // only runs after 200ms pause
|
||||
}, 200); // adjust debounce delay as needed
|
||||
}); **/
|
||||
|
||||
|
||||
if(client_type == 1){
|
||||
$('.group_client').show();
|
||||
@ -6176,6 +6208,52 @@
|
||||
$("#client_type").focus(); // focus back to client_type
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function generateShortName() {
|
||||
let clientInput = $("#client_name");
|
||||
let shortInput = $("#short_name");
|
||||
let newClientName = clientInput.val().trim();
|
||||
|
||||
console.log(`LN : NEW - ${newClientName}`);
|
||||
if (newClientName.length == 0){ shortInput.val(''); return; }
|
||||
|
||||
if (newClientName.length > 0) {
|
||||
let shortName = newClientName.substring(0, 10).replace(/\s+/g, '').toUpperCase();
|
||||
makeUniqueShortName(shortName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function makeUniqueShortName(baseName) {
|
||||
let input = $("#short_name")[0]; // input element
|
||||
checkDuplicateTableFieldValue("clients", "short_name", baseName, function(isDuplicate) {
|
||||
if (isDuplicate) {
|
||||
// Append sequence until unique
|
||||
let counter = 1;
|
||||
function tryNext() {
|
||||
let padded = String(counter).padStart(3, '0'); // 001, 002, 003
|
||||
let newName = baseName + padded;
|
||||
|
||||
checkDuplicateTableFieldValue("clients", "short_name", newName, function(exists) {
|
||||
if (exists) {
|
||||
counter++;
|
||||
tryNext(); // keep checking
|
||||
} else {
|
||||
$("#short_name").val(newName);
|
||||
validateInputForClient(input, "clients", "short_name");
|
||||
}
|
||||
});
|
||||
}
|
||||
tryNext();
|
||||
} else {
|
||||
$("#short_name").val(baseName);
|
||||
validateInputForClient(input, "clients", "short_name");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function validateInputForClient(input, table, field) {
|
||||
@ -6277,5 +6355,32 @@
|
||||
console.log("✅ total[] changed:", val);
|
||||
});
|
||||
|
||||
function autoFetchRtoName(val) {
|
||||
console.log(`i am here ${val}`);
|
||||
val = val.toUpperCase().trim();
|
||||
|
||||
let stateCode = val.slice(0, 2); // 1st 2 here i am split the state code
|
||||
let numberCode = val.slice(2, 4); // 2nd 2 here i am split the number code
|
||||
|
||||
console.log(`Ln ST: ${stateCode} | NC: ${numberCode}`);
|
||||
|
||||
let matched = false;
|
||||
|
||||
$('#rto_id option').each(function() {
|
||||
let optionState = $(this).attr('data-state');
|
||||
let optionCode = $(this).attr('data-code');
|
||||
console.log(`Ln optionState : ${optionState} | optionCode : ${optionCode}`);
|
||||
|
||||
if (stateCode === optionState && numberCode === optionCode) {
|
||||
$('#rto_id').val($(this).val()).trigger('change'); // ✅ select it
|
||||
matched = true;
|
||||
return false; // break the loop
|
||||
}
|
||||
});
|
||||
|
||||
if (!matched) {
|
||||
$('#rto_id').val('').trigger('change'); // reset select
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
254
app/Views/rto_master_list.php
Normal file
254
app/Views/rto_master_list.php
Normal file
@ -0,0 +1,254 @@
|
||||
<style>
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- End ADD and EDIT Page HTML -->
|
||||
<div class="row" id="List-page">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body maincard">
|
||||
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="user-table">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="font-weight-medium">S.No.</th>
|
||||
<th class="font-weight-medium">RTO Office at</th>
|
||||
<th class="font-weight-medium">RTO Code</th>
|
||||
<th class="font-weight-medium">RTO State</th>
|
||||
<!-- <th class="font-weight-medium">Status</th> -->
|
||||
<th class="font-weight-medium">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if(isset($data)) { ?>
|
||||
<?php foreach($data as $index => $row) { ?>
|
||||
<tr>
|
||||
<td class="text-dark"> <?= esc($index + 1); ?></td>
|
||||
<td><?= $row['rto_name']; ?></td>
|
||||
<td><?= $row['rto_code']; ?></td>
|
||||
<td><?= $row['rto_state']; ?></td>
|
||||
<!-- <td>
|
||||
<span class="<?php if($row['is_active'] == 1){ echo 'badge badge-primary'; }else{ echo 'badge badge-danger'; } ?>">
|
||||
<?php if($row['is_active'] == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?>
|
||||
</span>
|
||||
</td> -->
|
||||
<td>
|
||||
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
|
||||
<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" style="cursor: pointer;">
|
||||
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', this)">
|
||||
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
||||
</a>
|
||||
<?php if ($row['is_active'] == 1): ?>
|
||||
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('remove', this)">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<tr>
|
||||
<td colspan="3" class="text-center">No data available</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- modal content -->
|
||||
<div id="con-close-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="modalLabel">Add RTO Details</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body p-4">
|
||||
<!-- <form class="parsley-examples" id="RTOForm" enctype="multipart/form-data"> -->
|
||||
<form id="RTOForm" enctype="multipart/form-data">
|
||||
<input type="hidden" name="pk" id="rto_id"/>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="rto_name">RTO Office Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="rto_name" name="rto_name" placeholder="Enter RTO Office Name" required>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="rto_code">RTO Code<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="rto_code" name="rto_code"
|
||||
placeholder="Enter RTO Code" required
|
||||
maxlength="2"
|
||||
inputmode="numeric"
|
||||
pattern="[0-9]{2}"
|
||||
oninput="this.value = this.value.replace(/[^0-9]/g, '').slice(0,2);">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-12">
|
||||
<label for="rto_state">RTO State<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="rto_state" name="rto_state"
|
||||
placeholder="Enter RTO State" required
|
||||
maxlength="2"
|
||||
pattern="[A-Z]{2}"
|
||||
oninput="this.value = this.value.replace(/[^A-Za-z]/g, '').toUpperCase().slice(0,2);">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="button" class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit" onclick="handleSaveEditAndDelete('submit')">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var table;
|
||||
$(document).ready(function () {
|
||||
var ticketsTable = $('#user-table');
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
dom: "<'row'<'col-sm-7'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
|
||||
buttons: [
|
||||
{
|
||||
text: 'Add',
|
||||
className: 'btn app-btn-primary mr-2',
|
||||
action: function(e, dt, node, config) {
|
||||
openModal()
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'collection',
|
||||
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
|
||||
className: 'btn app-btn-secondary ',
|
||||
buttons: [
|
||||
{
|
||||
extend: 'csv',
|
||||
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
||||
title: 'RTO',
|
||||
className: 'app-btn-primary ',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
language: {
|
||||
search: `
|
||||
<div class="datatable-search-wrapper">
|
||||
_INPUT_
|
||||
<i class="mdi mdi-magnify datatable-search-icon"></i>
|
||||
</div>`,
|
||||
searchPlaceholder: "Search"
|
||||
},
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 10, // Set default number of rows per page (optional)
|
||||
// ordering: false,
|
||||
});
|
||||
});
|
||||
|
||||
$('.close').click(function(){
|
||||
resetValues()
|
||||
})
|
||||
|
||||
function openModal(){
|
||||
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||||
myModal.show();
|
||||
}
|
||||
|
||||
function handleSaveEditAndDelete(type = 'submit', el = null) {
|
||||
|
||||
let url = '<?= base_url('util/rtoMaster') ?>';
|
||||
let method = "POST";
|
||||
let requestData = {};
|
||||
|
||||
let pk = null;
|
||||
|
||||
// If element is passed (from edit/remove button), get its data-id
|
||||
if (el) { pk = $(el).data('id'); }
|
||||
|
||||
requestData.pk = pk;
|
||||
|
||||
if(type == 'submit'){
|
||||
$("#RTOForm").find("input, select, textarea").each(function () {
|
||||
let name = $(this).attr("name");
|
||||
let value = $.trim($(this).val());
|
||||
if (name) requestData[name] = value;
|
||||
});
|
||||
}
|
||||
|
||||
if(type == 'remove'){
|
||||
method = "DELETE";
|
||||
} else if (type == 'edit'){
|
||||
method = "GET";
|
||||
$('#modalLabel').text('Edit RTO details');
|
||||
$('#vehicleTypeForm')[0].reset();
|
||||
}
|
||||
|
||||
console.log("type", type)
|
||||
console.log("url", url)
|
||||
console.log("method", method)
|
||||
console.log("requestData", requestData)
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, method, requestData, function(response) {
|
||||
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status) {
|
||||
if(type == 'edit'){
|
||||
appendEditData(response.data);
|
||||
} else if(type == 'remove'){
|
||||
toastr.success(response.message, 'Success');
|
||||
if(el) $(el).closest('tr').remove();
|
||||
} else if(type == 'submit'){
|
||||
toastr.success(response.message, 'Success');
|
||||
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||||
myModal.hide();
|
||||
resetValues();
|
||||
window.location.reload();
|
||||
}
|
||||
} else {
|
||||
toastr.warning(response.message, 'Warning');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
});
|
||||
}
|
||||
|
||||
function resetValues(){
|
||||
$('#modalLabel').text('Add RTO Details');
|
||||
$('#RTOForm')[0].reset();
|
||||
}
|
||||
|
||||
function appendEditData(data){
|
||||
$('#rto_id').val(data[0]['id']);
|
||||
$('#rto_name').val(data[0]['rto_name']);
|
||||
$('#rto_code').val(data[0]['rto_code']);
|
||||
$('#rto_state').val(data[0]['rto_state']);
|
||||
openModal()
|
||||
}
|
||||
</script>
|
||||
|
||||
230
app/Views/vehicle_type_master_list.php
Executable file
230
app/Views/vehicle_type_master_list.php
Executable file
@ -0,0 +1,230 @@
|
||||
<style>
|
||||
.dataTables_filter {
|
||||
position: absolute;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- End ADD and EDIT Page HTML -->
|
||||
<div class="row" id="List-page">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body maincard">
|
||||
<table data-custom-table-css="table" class="table table-sm m-0 table-centered dt-responsive nowrap w-100" cellspacing="a" id="user-table">
|
||||
<thead class="bg-light">
|
||||
<tr>
|
||||
<th class="font-weight-medium">S.No.</th>
|
||||
<th class="font-weight-medium">Vehicle Type</th>
|
||||
<!-- <th class="font-weight-medium">Status</th> -->
|
||||
<th class="font-weight-medium">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if(isset($data)) { ?>
|
||||
<?php foreach($data as $index => $row) { ?>
|
||||
<tr>
|
||||
<td class="text-dark"> <?= esc($index + 1); ?></td>
|
||||
<td><?= $row['vehicle_type']; ?></td>
|
||||
<!-- <td>
|
||||
<span class="<?php if($row['is_active'] == 1){ echo 'badge badge-primary'; }else{ echo 'badge badge-danger'; } ?>">
|
||||
<?php if($row['is_active'] == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?>
|
||||
</span>
|
||||
</td> -->
|
||||
<td>
|
||||
<div class="btn-group dropdown" style="position: relative !important;left:0px !important;top:0px !important;">
|
||||
<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" style="cursor: pointer;">
|
||||
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('edit', this)">
|
||||
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
||||
</a>
|
||||
<?php if ($row['is_active'] == 1): ?>
|
||||
<a class="dropdown-item" data-id="<?= $row['id']; ?>" onclick="handleSaveEditAndDelete('remove', this)">
|
||||
<i class="mdi mdi-delete mr-2 text-muted font-18 vertical-middle"></i>Delete
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php } else { ?>
|
||||
<tr>
|
||||
<td colspan="3" class="text-center">No data available</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- modal content -->
|
||||
<div id="con-close-modal" class="modal fade app-font-family" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;" data-backdrop="static">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="modalLabel">Add Vehicle Type</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body p-4">
|
||||
<!-- <form class="parsley-examples" id="vehicleTypeForm" enctype="multipart/form-data"> -->
|
||||
<form id="vehicleTypeForm" enctype="multipart/form-data">
|
||||
<input type="hidden" name="pk" id="vehicle_type_id"/>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="vehicle_type">Vehicle Type<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="vehicle_type" name="vehicle_type" placeholder="Enter Vehicle Type" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<button type="button" class="btn app-btn-secondary waves-effect waves-light" id="btnSubmit" onclick="handleSaveEditAndDelete('submit')">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var table;
|
||||
$(document).ready(function () {
|
||||
var ticketsTable = $('#user-table');
|
||||
ticketsTable.DataTable({
|
||||
scrollX: true,
|
||||
dom: "<'row'<'col-sm-7'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
|
||||
buttons: [
|
||||
{
|
||||
text: 'Add',
|
||||
className: 'btn app-btn-primary mr-2',
|
||||
action: function(e, dt, node, config) {
|
||||
openModal()
|
||||
}
|
||||
},
|
||||
{
|
||||
extend: 'collection',
|
||||
text: '<span class=" btn-custom"> Export </span><i class="mdi mdi-menu-down"></i>',
|
||||
className: 'btn app-btn-secondary ',
|
||||
buttons: [
|
||||
{
|
||||
extend: 'csv',
|
||||
text: '<i class="mdi mdi-file-delimited " ></i><span class=" btn-custom"> CSV </span>',
|
||||
title: 'Policy-Tranction-Inception-List',
|
||||
className: 'app-btn-primary ',
|
||||
exportOptions: {
|
||||
columns: ':not(:last-child)'
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
language: {
|
||||
search: `
|
||||
<div class="datatable-search-wrapper">
|
||||
_INPUT_
|
||||
<i class="mdi mdi-magnify datatable-search-icon"></i>
|
||||
</div>`,
|
||||
searchPlaceholder: "Search"
|
||||
},
|
||||
paging: true, // Enable pagination
|
||||
pageLength: 10, // Set default number of rows per page (optional)
|
||||
// ordering: false,
|
||||
});
|
||||
});
|
||||
|
||||
$('.close').click(function(){
|
||||
resetValues()
|
||||
})
|
||||
|
||||
function openModal(){
|
||||
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||||
myModal.show();
|
||||
}
|
||||
|
||||
function handleSaveEditAndDelete(type = 'submit', el = null) {
|
||||
|
||||
let url = '<?= base_url('util/vehicleTypeMaster') ?>';
|
||||
let method = "POST";
|
||||
let requestData = {};
|
||||
|
||||
let pk = null;
|
||||
|
||||
// If element is passed (from edit/remove button), get its data-id
|
||||
if (el) { pk = $(el).data('id'); }
|
||||
|
||||
requestData.pk = pk;
|
||||
|
||||
if(type == 'submit'){
|
||||
$("#vehicleTypeForm").find("input, select, textarea").each(function () {
|
||||
let name = $(this).attr("name");
|
||||
let value = $.trim($(this).val());
|
||||
if (name) requestData[name] = value;
|
||||
});
|
||||
}
|
||||
|
||||
if(type == 'remove'){
|
||||
method = "DELETE";
|
||||
} else if (type == 'edit'){
|
||||
method = "GET";
|
||||
$('#modalLabel').text('Edit Vehicle Type');
|
||||
$('#vehicleTypeForm')[0].reset();
|
||||
|
||||
}
|
||||
|
||||
console.log("type", type)
|
||||
console.log("url", url)
|
||||
console.log("method", method)
|
||||
console.log("requestData", requestData)
|
||||
|
||||
$('.loader').fadeIn();
|
||||
$('.loader-mask').fadeIn();
|
||||
|
||||
// Send AJAX request
|
||||
sendAjaxRequestForGlobal(url, method, requestData, function(response) {
|
||||
|
||||
console.log('Data fetched successfully:', response);
|
||||
|
||||
if (response.status) {
|
||||
if(type == 'edit'){
|
||||
appendEditData(response.data);
|
||||
} else if(type == 'remove'){
|
||||
toastr.success(response.message, 'Success');
|
||||
if(el) $(el).closest('tr').remove();
|
||||
} else if(type == 'submit'){
|
||||
toastr.success(response.message, 'Success');
|
||||
var myModal = new bootstrap.Modal(document.getElementById('con-close-modal'));
|
||||
myModal.hide();
|
||||
resetValues();
|
||||
window.location.reload();
|
||||
}
|
||||
} else {
|
||||
toastr.warning(response.message, 'Warning');
|
||||
}
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
|
||||
}, function(xhr, status, error) {
|
||||
console.error('Error fetching data:', error);
|
||||
console.error(xhr.responseText);
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
});
|
||||
}
|
||||
|
||||
function resetValues(){
|
||||
$('#modalLabel').text('Add Vehicle Type');
|
||||
$('#vehicleTypeForm')[0].reset();
|
||||
}
|
||||
|
||||
function appendEditData(data){
|
||||
$('#vehicle_type_id').val(data[0]['id']);
|
||||
$('#vehicle_type').val(data[0]['vehicle_type']);
|
||||
openModal()
|
||||
}
|
||||
</script>
|
||||
|
||||
Binary file not shown.
BIN
public/sample_excel/insurer_stament_sample_old.xlsx
Normal file
BIN
public/sample_excel/insurer_stament_sample_old.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user