changes in master details

This commit is contained in:
vadivelJ96 2024-11-20 11:00:48 +05:30
parent d5574c72f4
commit 2987240c53
6 changed files with 189 additions and 50 deletions

View File

@ -71,6 +71,7 @@ $routes->post('reActivateMaterial', 'Rawmaterialdetails::reActivateMaterial');
// Cost Center Routes
$routes->get('costListing', 'CostCenter::index');
$routes->post('fetchCostCenterDetails', 'CostCenter::fetchCostCenterDetails');// for Ajax both add and edit....
$routes->get('reActivateCostCenter','CostCenter::reActivateCostCenter');
$routes->get('deleteCostCenter', 'CostCenter::deleteCostCenter');
$routes->get('exportcost', 'CostCenter::exportcost');

View File

@ -92,6 +92,23 @@ class CostCenter extends BaseController
return $this->response->setJSON($data);
}
/** re activate the cost center */
public function reActivateCostCenter(){
$CostCenterCode = $_GET['CostCenterCode'];
if(!empty($CostCenterCode)){
$updatedBy = $this->session->get('userId');
$message = $this->costcenter_model->reActivateCostCenter($CostCenterCode, $updatedBy);
}else{
$message = "Cost Center Code Not Avalable";
}
$this->session->setFlashdata('success', $message);
return redirect()->route('costListing');
}
/**
@ -100,7 +117,7 @@ class CostCenter extends BaseController
function deleteCostCenter($CostCode = NULL)
{
$CostCenterID = $CostCode ?? $_GET['CostCode'];
$CostCenterID = $CostCode ?? $_GET['CostCenterCode'];
if(!empty($CostCenterID)){
$updatedBy = $this->session->get('userId');
$message = $this->costcenter_model->deleteCostCenter($CostCenterID, $updatedBy);

View File

@ -341,7 +341,7 @@ class Supplier extends BaseController
$updatedDate = get_current_date_time();
$SupplierInfo = array('IsActive' => 1, 'updatedBy' => $this->session->get('userId'), 'Updatedon' => $updatedDate);
$SupplierInfo = array('IsActive' => 1, 'updatedBy' => $this->session->get('userId'), 'Updatedon' => $updatedDate);
$result = $this->supplier_model->reActivateSupplier($Sid, $SupplierInfo);

View File

@ -374,7 +374,8 @@ where Dept.DEPCode not in
return TRUE;
}
function deleteCostCenter($CostCode,$UpdatedBy)
function reActivateCostCenter( $CostCenterCode , $UpdatedBy)
{
$tables = [
@ -387,18 +388,45 @@ where Dept.DEPCode not in
foreach ($tables as $table) {
$builder = $this->db->table($table);
$builder->select('IsActive');
$builder->where('CostCenterCode', $CostCode);
$builder->where('CostCenterCode', $CostCenterCode);
$query = $builder->get();
$result = $query->getRowArray();
if ($result && $result['IsActive'] != 1) {
// If IsActive is not 1, update it to 1
$builder->where('CostCenterCode', $CostCenterCode);
$builder->update(['IsActive' => 1,'DeletedBy' => $UpdatedBy ]);
}
}
return "Cost center $CostCenterCode Reactivated successfully.";
}
function deleteCostCenter($CostCenterCode,$UpdatedBy)
{
$tables = [
't_costcenter_master',
't_costcenter_budget',
't_costcenter_departments'
];
foreach ($tables as $table) {
$builder = $this->db->table($table);
$builder->select('IsActive');
$builder->where('CostCenterCode', $CostCenterCode);
$query = $builder->get();
$result = $query->getRowArray();
if ($result && $result['IsActive'] != 0) {
// If IsActive is not 0, update it to 0
$builder->where('CostCenterCode', $CostCode);
$builder->where('CostCenterCode', $CostCenterCode);
$builder->update(['IsActive' => 0,'DeletedBy' => $UpdatedBy ]);
}
}
return "Cost center deactivated successfully.";
return "Cost center $CostCenterCode deactivated successfully.";
}
}
?>

View File

@ -43,6 +43,15 @@ class Supplier_model extends Model
}
function reActivateSupplier($Sid, $SupplierInfo){
$builder = $this->db->table('t_supplierdetailsn')
->where('SupplierID',$Sid)
->update($SupplierInfo);
return $this->db->affectedRows();
}
function deleteTransporter($Sid, $SupplierInfo){

View File

@ -43,17 +43,18 @@
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">Master Details</a></li>
<li class="breadcrumb-item active">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">Master Details</a></li>
<li class="breadcrumb-item active">
<h4 class="page-title">Cost Details</h4>
</li>
</ol>
</div>
<a data-toggle="modal" href="#ccwizard" data-id="0" data-name="" class="btn btn-success">Add New Cost List</a>
</li>
</ol>
</div>
<a data-toggle="modal" href="#ccwizard" data-id="0" data-name="" class="btn btn-success">Add New
Cost List</a>
</div>
</div>
</div>
@ -61,16 +62,35 @@
<div class="row">
<div class="col-12">
<div class="card">
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<form class="Date-filter-form" id="DateRangeFilter"
style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<input class="form-control date_range form-date-search" id="fromDate" name="fromDate"
placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range to-date-search" id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
<input class="form-control date_range to-date-search" id="toDate" name="toDate"
placeholder="Select To Date" autocomplete="off" required>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true"
class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button"
id="resetButton" title="Reset"></i>
<div style="margin-left:auto">
<div class="form-check" style="margin-right: 25px;">
<input class="form-check-input" type="checkbox" id="showArchiveId"
name="showArchive" value="1" onchange="showArchiveList()"
style="width: 18px; height: 18px;">
<label class="form-check-label" for="showArchiveId"
style="font-size: 1rem; margin-left: 8px;">
Show Archive
</label>
</div>
</div>
<button type="submit" class="range_search_button"><i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i></button>
<i class="fe-rotate-cw range_reset_button" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
<div class="error" id="error"></div>
</form>
<div class="card-body" style="overflow-x:scroll;">
@ -92,22 +112,35 @@
$createdat = new DateTime($record->CreatedDate);
$date = $createdat->format('d-m-Y');
$time = $createdat->format('h:i A');
?>
<tr>
?>
<tr class="<?php if ($record->IsActive == 0) {
echo "deactivatedRow";
} ?>" style="<?php if ($record->IsActive == 0) {
echo "display:none";
} ?>">
<td><?php echo $date; ?></td>
<td><?php echo $record->code ?></td>
<td><?php echo $record->CostCenterName ?></td>
<td><?php echo $record->FirstName ?></td>
<td>
<?php
if ($record->DeletedBy == '') {
?>
<a data-toggle="modal" href="#ccwizard" data-id="<?php echo $record->id; ?>" data-name="<?php echo $record->CostCenterName; ?>"><i class="fas fa-edit"></i>&nbsp;&nbsp;</a>
<a href="<?php echo base_url() . 'deleteCostCenter?CostCode=' . $record->code; ?>"><i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;</a>
if ($record->IsActive == 0) {
?>
<a onclick="confirmReActivate(event)" style="cursor:pointer;"
href="<?php echo base_url() . 'reActivateCostCenter?CostCenterCode=' . $record->code; ?>">
<i class="fa fa-key" style="color:#02a8b5;"></i>&nbsp;&nbsp;&nbsp;
</a>
<?php } else { ?>
<a data-toggle="modal" href="#ccwizard" data-id="<?php echo $record->id; ?>"
data-name="<?php echo $record->CostCenterName; ?>"><i
class="fas fa-edit"></i>&nbsp;&nbsp;</a>
<a onclick="confirmDelete(event)" style="cursor:pointer;"
href="<?php echo base_url() . 'deleteCostCenter?CostCenterCode=' . $record->code; ?>"><i
class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;</a>
<?php } ?>
</td>
</tr>
<?php
<?php
}
}
?>
@ -122,14 +155,13 @@
</div> <!-- content -->
</div>
<!-- for Add and edit Modal -->
<div id="ccwizard" class="modal fade" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
<div id="ccwizard" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
style="display: none;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"></h4>
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body p-4">
<form id="transporterForm" class="form-horizontal" role="form">
@ -149,17 +181,17 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect"
data-dismiss="modal" value="Cancel">Cancel</button>
<button type="button"
class="btn btn-info waves-effect waves-light tempClick" id="tempClick">Submit</button>
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal"
value="Cancel">Cancel</button>
<button type="button" class="btn btn-info waves-effect waves-light tempClick"
id="tempClick">Submit</button>
</div>
</div>
</div>
</div><!-- /.modal -->
<script>
$(document).ready(function() {
$("#ccwizard").on("shown.bs.modal", function(e) {
$(document).ready(function () {
$("#ccwizard").on("shown.bs.modal", function (e) {
var id = $(e.relatedTarget).data('id');
var name = $(e.relatedTarget).data('name');
$('#CostCenterName').val('');
@ -172,7 +204,7 @@
}
});
$('#tempClick').click(function() {
$('#tempClick').click(function () {
if ($('#CostCenterName').val() === '') {
alert('Please Enter the Cost Center Name');
return;
@ -188,7 +220,7 @@
url: "<?php echo base_url(); ?>fetchCostCenterDetails",
data: formData,
dataType: 'json',
success: function(response) {
success: function (response) {
$('#loader').hide();
if (response.status) {
@ -199,32 +231,37 @@
alert(response.message);
}
},
error: function(xhr, status, error) {
alert('An error occurred: ' + error);
error: function (xhr, status, error) {
$('#loader').hide();
console.error('An error occurred: ' + error);
},
complete: function () {
$('#loader').hide();
console.log("ajax call completed");
}
});
});
});
</script>
<script>
$(document).ready(function() {
$.fn.dataTable.ext.type.order['date-eu-pre'] = function(date) {
$(document).ready(function () {
$.fn.dataTable.ext.type.order['date-eu-pre'] = function (date) {
var dateSplit = date.split('-');
return (dateSplit[2] + dateSplit[1] + dateSplit[0]) * 1;
};
// Initialize the DataTable
var table = $('#cost_listing').DataTable({
dom: 'Blfrtip',
dom: 'Blfrtip',
buttons: [
'excel', 'pdf'
],
pageLength: 10,
pageLength: 10,
lengthMenu: [
[10, 20, 30, 50, -1],
[10, 20, 30, 50, "All"]
],
responsive: false,
],
responsive: false,
order: false,
language: {
paginate: {
@ -236,7 +273,7 @@
// Date range filter function
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
function (settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
console.log(fromDate); // e.g., 01-09-2024
@ -270,20 +307,20 @@
);
// Handle form submission for the date range filter
$("#DateRangeFilter").submit(function(e) {
$("#DateRangeFilter").submit(function (e) {
e.preventDefault();
table.draw(); // Redraw the table to apply the filter
});
// Reset button functionality
$("#resetButton").click(function() {
$("#resetButton").click(function () {
$("#fromDate").val('');
$("#toDate").val('');
table.draw(); // Redraw the table to clear the filter
});
// Automatically focus and open the To Date picker when From Date is selected
document.getElementById('fromDate').addEventListener('change', function() {
document.getElementById('fromDate').addEventListener('change', function () {
var fromDate = this.value;
var toDateInput = document.getElementById('toDate');
@ -296,4 +333,51 @@
}
});
});
</script>
<script>
$(window).on('load', function () {
function flashMessage() {
// Fetch the flash data from PHP and encode it for JavaScript
let message = <?= json_encode(session()->getFlashdata('success')) ?>;
if (message) {
alert(message);
}
}
flashMessage();
})
function confirmDelete(event) {
let result = confirm(` Do you Confirm to Delete the Cost Center Detail?`);
if (result) { return result; } else { event.preventDefault(); }
}
function confirmReActivate(event) {
let result = confirm(` Do you Confirm to Re-activate the Cost Center Detail?`);
if (result) { return result; } else { event.preventDefault(); }
}
function showArchiveList() {
let isChecked = $("#showArchiveId").prop('checked');
// Show or hide the rows based on checkbox status
$(".deactivatedRow").each(function () {
if (isChecked) {
$(this).show();
} else {
$(this).hide();
}
});
}
$(document).ready(function () {
showArchiveList();
});
</script>