stock changes 07-04-2025

This commit is contained in:
vadivelJ96 2025-04-07 15:48:21 +05:30
parent 7291373b39
commit ba328c5fe7
4 changed files with 61 additions and 4 deletions

View File

@ -289,6 +289,7 @@ class Rawmaterialdetails extends BaseController
$data['assetcode'] = $this->rawmaterialdetails_model->getAssetcode();
$data['avg_price'] = $this->rawmaterialdetails_model->getMaterialAvg($RawMaterialID);
$data['materialRateHistory'] = $this->rawmaterialdetails_model->getMaterialRateHistory($RawMaterialID);
$data['materialListPage'] = $_GET['page'];
//print_r($data['avg_price']);die();
$this->global['pageTitle'] = 'Edit Material Master';
@ -317,6 +318,7 @@ class Rawmaterialdetails extends BaseController
$stock = $this->request->getPost('openstock');
$reorder = $this->request->getPost('reorder');
$stockdate = $this->request->getPost('Date');
$materialListPage = $this->request->getPost('materialListPage');
$stockdate = (empty($stockdate)) ? NULL : get_date_time_dynamical_format('d-m-Y','Y-m-d',"$stockdate");
$chked = $this->request->getPost('isactive');
@ -329,11 +331,15 @@ class Rawmaterialdetails extends BaseController
$result = $this->rawmaterialdetails_model->editRawmaterial($RawMaterial, $MaterialCode);
if ($result == true) {
if ($result == true) {
$this->session->setFlashdata('success', 'RawMaterial Updated successfully!');
$this->session->setFlashdata('materialListPage', "$materialListPage");
} else {
echo "<script>alert('RawMaterial Record Not updated!');</script>";
$this->session->setFlashdata('error', 'RawMaterial Record Not updated!');
$this->session->setFlashdata('materialListPage', "$materialListPage");
}
return redirect()->route('rawmaterialListing');

View File

@ -113,7 +113,7 @@ if ($total <= $reorder) {
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Edit Material - <?php echo $MaterialCode; ?> Details</h4>
<button type="button" class="btn btn-secondary" onclick="window.location.href='<?= base_url() ?>rawmaterialListing'">
<button type="button" class="btn btn-secondary" onclick="window.location.href='<?= base_url() ?>rawmaterialListing?materialListPage=<?= $materialListPage ?>'">
<span class="bold">Cancel</span>
</button>
</div>
@ -361,10 +361,12 @@ if ($total <= $reorder) {
</div>
</div>
<div class="box-footer text-right">
<button type="button" class="btn btn-secondary" onclick="window.location.href='<?= base_url() ?>rawmaterialListing'">
<button type="button" class="btn btn-secondary" onclick="window.location.href='<?= base_url() ?>rawmaterialListing?materialListPage=<?= $materialListPage ?>'">
<span class="bold">Cancel</span>
</button>
<input type="button" id="editRawMaterialBtnId" class="btn btn-success" value="Submit" />
<input type="hidden" id="materialListPage" name="materialListPage" value="<?php echo $materialListPage; ?>" />
</div>
</form>
</div><!-- /.card-body -->

View File

@ -76,6 +76,9 @@
$type = "success";
echo show_alert($type, $success);
}
$materialListPage = session()->getFlashdata('materialListPage') ?? $_GET['materialListPage'] ?? 1;
?>
<div class="row">
@ -207,6 +210,7 @@
<?php } else { ?>
<a class="a_tag_link"
onclick="editMaterial(event)"
href="<?php echo base_url() . 'viewRawmaterial?RID=' . $record->MaterialCode . '&MType=' . $record->MaterialType . '&UOM=' . $record->UOM . '&date1=' . $date ?>"
data-toggle="tooltip"
title="<?php echo $record->MaterialCode; ?> - Click here to view Material details"><i
@ -414,6 +418,30 @@ $(document).ready(function () {
}
});
// Ensure the saved page is a valid number
let savedPage =<?= $materialListPage ?? 0 ?>; // Default to 1 if not set
savedPage = savedPage -1 ;
if (!isNaN(savedPage)) {
// Check if the DataTable is initialized
if ($.fn.DataTable.isDataTable('#raw_material_list_table')) {
var dataTable = $('#raw_material_list_table').DataTable();
// Get the total number of pages in DataTable
var totalPages = dataTable.page.info().pages;
// Ensure the page number is within range
if (savedPage >= totalPages) {
savedPage = totalPages > 0 ? totalPages - 1 : 0;
}
// Set DataTable to the saved page
dataTable.page(savedPage).draw(false);
}
}
// Date range filter function
// $.fn.dataTable.ext.search.push(
// function (settings, data, dataIndex) {
@ -542,10 +570,31 @@ $(document).ready(function () {
});
});
</script>
<script>
function editMaterial(event) {
event.preventDefault();
const targetElement = event.currentTarget;
let href = $(targetElement).attr('href');
let paginationNumber = $('#raw_material_list_table').DataTable().page.info().page + 1; // Get the current page number from dataTable
href += '&page=' + paginationNumber;
// Update the 'href' attribute of the target element
$(targetElement).attr('href', href);
window.location.href = href;
}
function deleteMaterial(mid) {
var answer = confirm(" Do you want to delete the Material from the List?")

View File

@ -1448,7 +1448,7 @@
<!-- Save All Data in Incoming Silica Sand Details from table -->
<script type="text/javascript">
$(document).ready(function() {
$('#save').click(function() {
$('#saveId').click(function() {
var incomingSilicaSandDetailsData = incomingSilicaSandTableToJson();