changes in stock controller

This commit is contained in:
vadivel J 2024-11-11 11:02:03 +05:30
parent f5c899f29b
commit 864a6f62ac
2 changed files with 33 additions and 6 deletions

View File

@ -119,6 +119,21 @@ class StockController extends BaseController
$postData=$this->request->getPost();
$date = $postData['date'];
$shift = $postData['shift'];
$sameShiftOnDateExists = $this->coatingMachineDetails_model
->where('date',$date)
->where('shift',$shift)
->where('is_active',1)
->first();
if(!empty($sameShiftOnDateExists)){
return redirect()->back()->with('error', 'Already same shift exists on the same date ..!!');
}
$inserted= $this->coatingMachineDetails_model->insert($postData);
@ -496,15 +511,16 @@ class StockController extends BaseController
foreach($updateDustAndRoughStockDetailsData as $data){
$date = $data['date'];
$data['date'] = DateTime::createFromFormat('d-m-Y', $data['date'])->format('Y-m-d');
$date =$data['date'];
$dbData= [
'date' => $data['date'],
'finalRough' => $data['finalRough'],
'dust' => $data['dust'],
'total' => $data['total']
];
];
$resultExists=$this->dustAndRoughStockDetails_model
->where('date',$date)

View File

@ -194,6 +194,11 @@
</div>
</div>
<?php if (session()->getFlashdata('error')): ?>
<div class="alert alert-danger">
<?= session()->getFlashdata('error'); ?>
</div>
<?php endif; ?>
<div class="row">
<div class="col-12">
@ -250,7 +255,11 @@
?>
<tr data-id="<?php echo $record['id']; ?>">
<td class="celda_normal"><?php echo $record['date'] ?></td>
<?php
$date = DateTime::createFromFormat('Y-m-d', $record['date'])->format('d-m-Y');
?>
<td class="celda_normal"><?php echo $date ?></td>
<td class="celda_normal"><?php echo $record['shift'] ?></td>
<td class="celda_normal"><?php echo $record['machineOnTime'] ?></td>
<td class="celda_normal"><?php echo $record['machineOffTime'] ?></td>
@ -708,7 +717,8 @@
// Get values from the row
var date = row.find('td:eq(0)').text();
var date = row.find('td:eq(0)').text().split('-');
date=`${date[2]}-${date[1]}-${date[0]}`;
var shift = row.find('td:eq(1)').text();
var machineOnTimeHr = row.find('td:eq(2)').text();
var machineOffTimeHr = row.find('td:eq(3)').text();
@ -723,9 +733,10 @@
// Fill the modal fields with the values
$('#editCoatingMachineDetailId').val(row.data('id'));
$('#editCustomerNameId').val(customerName);
$('#editDateId').val(date);
$('#editDateId').val(date);//convert this from d-m-y to Y-m-d in javascript
$('#editShiftId').val(shift);
$('#editMachineOnTimeHrId').val(machineOnTimeHr).change();
$('#editMachineOffTimeHrId').val(machineOffTimeHr).change();