FIX_Master screen
This commit is contained in:
parent
77406ef335
commit
7b1d98d86c
@ -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');
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
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;
|
||||
}}
|
||||
@ -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>
|
||||
|
||||
@ -5739,6 +5739,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() === "") {
|
||||
@ -6147,6 +6154,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 +6191,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) {
|
||||
|
||||
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>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user