FEAT_MASTERS : RV
This commit is contained in:
parent
950c117a2e
commit
fadcd8d685
@ -33,6 +33,7 @@ use App\Models\ClientDepositModel;
|
||||
use App\Models\EmployeePolicyModel;
|
||||
use App\Models\FileModel;
|
||||
use App\Models\InsurerExcelExportTemplateModel;
|
||||
use App\Models\NhanceBranchModel;
|
||||
use App\Models\SettingsModel;
|
||||
use App\Models\VehicleModel;
|
||||
|
||||
@ -1618,7 +1619,8 @@ class MasterController extends AdminController
|
||||
//Vehicle Master data Function
|
||||
|
||||
public function VehicleMasterList()
|
||||
{ $data['tab_name'] = 'Vehicle Master';
|
||||
{
|
||||
$data['tab_name'] = 'Vehicle Master';
|
||||
$data['page_name'] = 'Vehicles';
|
||||
$data['vehicle_type'] = [
|
||||
'two_wheeler' => 'Two Wheeler',
|
||||
@ -2020,4 +2022,91 @@ class MasterController extends AdminController
|
||||
dd($result);
|
||||
}
|
||||
|
||||
public function nhanceBranchMaster()
|
||||
{
|
||||
$nhanceBranchModel = new NhanceBranchModel();
|
||||
|
||||
if ($this->request->is('post')) {
|
||||
|
||||
$id = $this->request->getPost('pk') ?? null;
|
||||
$data = $this->request->getPost();
|
||||
print_r($data); die;
|
||||
|
||||
if (empty($id)) {
|
||||
$update_status = $nhanceBranchModel->insert($data);
|
||||
} else {
|
||||
$update_status = $nhanceBranchModel->where('id', $id)->set($data)->update();
|
||||
}
|
||||
|
||||
if ($update_status) {
|
||||
return $this->respond([
|
||||
'status' => true,
|
||||
'code' => 200,
|
||||
'message' => 'Nhance Branch Master updated successfully',
|
||||
'data' => $data
|
||||
], 200);
|
||||
} else {
|
||||
return $this->respond([
|
||||
'status' => false,
|
||||
'code' => 400,
|
||||
'message' => 'Failed to update',
|
||||
'data' => $data
|
||||
], 200);
|
||||
}
|
||||
|
||||
} elseif ($this->request->is('get')) {
|
||||
|
||||
$id = $this->request->getGet('pk') ?? null;
|
||||
|
||||
if (!empty($id)) {
|
||||
$data = $nhanceBranchModel->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 = $nhanceBranchModel->where('is_active', 1)->findAll();
|
||||
return $this->loadLayout('nhance_branch_list', ['data' => $data]);
|
||||
|
||||
} elseif ($this->request->is('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 = $nhanceBranchModel->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 vehicleTypeMaster()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
54
app/Models/VehicleTypeModel.php
Normal file
54
app/Models/VehicleTypeModel.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class VehicleTypeModel extends Model
|
||||
{
|
||||
protected $table = 'vehicle_type';
|
||||
protected $primaryKey = 'id';
|
||||
protected $allowedFields = [
|
||||
|
||||
'id',
|
||||
'vehicle_type',
|
||||
'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;
|
||||
}}
|
||||
207
app/Views/nhance_branch_list.php
Normal file
207
app/Views/nhance_branch_list.php
Normal file
@ -0,0 +1,207 @@
|
||||
<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">Branch Name</th>
|
||||
<th class="font-weight-medium">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($data as $index => $row) { ?>
|
||||
<tr>
|
||||
<td class="text-dark"><?= esc($index + 1); ?></td>
|
||||
<td><?= $row['branch_name']; ?></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>
|
||||
</div>
|
||||
</div>
|
||||
</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 modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">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">
|
||||
<input type="hidden" name="pk" id="nhance_branch_id"/>
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<label for="branch_name">Branch Name<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="branch_name" name="branch_name" placeholder="Enter Branch Name" required>
|
||||
</div>
|
||||
</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>
|
||||
</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', pk = null){
|
||||
|
||||
console.log("type", type)
|
||||
|
||||
let url = '<?= base_url('util/nhanceBranchMaster') ?>';
|
||||
console.log("url", url)
|
||||
|
||||
|
||||
let requestData = {};
|
||||
if(type == 'submit'){
|
||||
$("#vehicle_form_row_div").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);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
requestData = {
|
||||
pk: pk,
|
||||
};
|
||||
}
|
||||
|
||||
console.log("requestData", requestData)
|
||||
|
||||
|
||||
let method = "POST";
|
||||
if(type == 'remove'){
|
||||
method = "DELETE";
|
||||
}else if (type == 'edit'){
|
||||
method = "GET"
|
||||
}
|
||||
console.log("method", method)
|
||||
|
||||
|
||||
$('.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{
|
||||
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);
|
||||
toastr.error('An error occurred while checking the CD amount.', 'ERROR');
|
||||
|
||||
$('.loader').fadeOut();
|
||||
$('.loader-mask').delay(350).fadeOut('slow');
|
||||
});
|
||||
}
|
||||
|
||||
function resetValues(){
|
||||
$('#branch_name').val('');
|
||||
}
|
||||
|
||||
function appendEditData(data){
|
||||
$('#branch_name').val(data.branch_name);
|
||||
openModal()
|
||||
}
|
||||
</script>
|
||||
|
||||
1692
app/Views/vehicle_type_list.php
Normal file
1692
app/Views/vehicle_type_list.php
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user