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 // Cost Center Routes
$routes->get('costListing', 'CostCenter::index'); $routes->get('costListing', 'CostCenter::index');
$routes->post('fetchCostCenterDetails', 'CostCenter::fetchCostCenterDetails');// for Ajax both add and edit.... $routes->post('fetchCostCenterDetails', 'CostCenter::fetchCostCenterDetails');// for Ajax both add and edit....
$routes->get('reActivateCostCenter','CostCenter::reActivateCostCenter');
$routes->get('deleteCostCenter', 'CostCenter::deleteCostCenter'); $routes->get('deleteCostCenter', 'CostCenter::deleteCostCenter');
$routes->get('exportcost', 'CostCenter::exportcost'); $routes->get('exportcost', 'CostCenter::exportcost');

View File

@ -94,13 +94,30 @@ class CostCenter extends BaseController
} }
/** 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');
}
/** /**
* delete the Cost * delete the Cost
*/ */
function deleteCostCenter($CostCode = NULL) function deleteCostCenter($CostCode = NULL)
{ {
$CostCenterID = $CostCode ?? $_GET['CostCode']; $CostCenterID = $CostCode ?? $_GET['CostCenterCode'];
if(!empty($CostCenterID)){ if(!empty($CostCenterID)){
$updatedBy = $this->session->get('userId'); $updatedBy = $this->session->get('userId');
$message = $this->costcenter_model->deleteCostCenter($CostCenterID, $updatedBy); $message = $this->costcenter_model->deleteCostCenter($CostCenterID, $updatedBy);

View File

@ -374,7 +374,8 @@ where Dept.DEPCode not in
return TRUE; return TRUE;
} }
function deleteCostCenter($CostCode,$UpdatedBy)
function reActivateCostCenter( $CostCenterCode , $UpdatedBy)
{ {
$tables = [ $tables = [
@ -387,18 +388,45 @@ where Dept.DEPCode not in
foreach ($tables as $table) { foreach ($tables as $table) {
$builder = $this->db->table($table); $builder = $this->db->table($table);
$builder->select('IsActive'); $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(); $query = $builder->get();
$result = $query->getRowArray(); $result = $query->getRowArray();
if ($result && $result['IsActive'] != 0) { if ($result && $result['IsActive'] != 0) {
// If IsActive is not 0, update it to 0 // If IsActive is not 0, update it to 0
$builder->where('CostCenterCode', $CostCode); $builder->where('CostCenterCode', $CostCenterCode);
$builder->update(['IsActive' => 0,'DeletedBy' => $UpdatedBy ]); $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){ function deleteTransporter($Sid, $SupplierInfo){

View File

@ -53,7 +53,8 @@
</li> </li>
</ol> </ol>
</div> </div>
<a data-toggle="modal" href="#ccwizard" data-id="0" data-name="" class="btn btn-success">Add New Cost List</a> <a data-toggle="modal" href="#ccwizard" data-id="0" data-name="" class="btn btn-success">Add New
Cost List</a>
</div> </div>
</div> </div>
</div> </div>
@ -61,16 +62,35 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div class="card"> <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"> <input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label> <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> <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> <div class="error" id="error"></div>
</form> </form>
<div class="card-body" style="overflow-x:scroll;"> <div class="card-body" style="overflow-x:scroll;">
@ -93,17 +113,30 @@
$date = $createdat->format('d-m-Y'); $date = $createdat->format('d-m-Y');
$time = $createdat->format('h:i A'); $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 $date; ?></td>
<td><?php echo $record->code ?></td> <td><?php echo $record->code ?></td>
<td><?php echo $record->CostCenterName ?></td> <td><?php echo $record->CostCenterName ?></td>
<td><?php echo $record->FirstName ?></td> <td><?php echo $record->FirstName ?></td>
<td> <td>
<?php <?php
if ($record->DeletedBy == '') { if ($record->IsActive == 0) {
?> ?>
<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="confirmReActivate(event)" style="cursor:pointer;"
<a href="<?php echo base_url() . 'deleteCostCenter?CostCode=' . $record->code; ?>"><i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;</a> 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 } ?> <?php } ?>
</td> </td>
</tr> </tr>
@ -122,14 +155,13 @@
</div> <!-- content --> </div> <!-- content -->
</div> </div>
<!-- for Add and edit Modal --> <!-- for Add and edit Modal -->
<div id="ccwizard" class="modal fade" tabindex="-1" role="dialog" <div id="ccwizard" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;"> style="display: none;">
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h4 class="modal-title"></h4> <h4 class="modal-title"></h4>
<button type="button" class="close" data-dismiss="modal" <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
aria-hidden="true">×</button>
</div> </div>
<div class="modal-body p-4"> <div class="modal-body p-4">
<form id="transporterForm" class="form-horizontal" role="form"> <form id="transporterForm" class="form-horizontal" role="form">
@ -149,10 +181,10 @@
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary waves-effect" <button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal"
data-dismiss="modal" value="Cancel">Cancel</button> value="Cancel">Cancel</button>
<button type="button" <button type="button" class="btn btn-info waves-effect waves-light tempClick"
class="btn btn-info waves-effect waves-light tempClick" id="tempClick">Submit</button> id="tempClick">Submit</button>
</div> </div>
</div> </div>
</div> </div>
@ -200,7 +232,12 @@
} }
}, },
error: function (xhr, status, error) { error: function (xhr, status, error) {
alert('An error occurred: ' + error); $('#loader').hide();
console.error('An error occurred: ' + error);
},
complete: function () {
$('#loader').hide();
console.log("ajax call completed");
} }
}); });
}); });
@ -297,3 +334,50 @@
}); });
}); });
</script> </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>