Merge branch 'new_theme' of bitbucket.org:venbainformationtechnology/ria into new_theme

This commit is contained in:
VE10-Sanjeev 2025-02-05 11:59:52 +00:00
commit aa1feea067
5 changed files with 390 additions and 82 deletions

View File

@ -463,8 +463,7 @@ $routes->post('getSilicaIGR', 'Supplier::getSilicaIGR');
$routes->match(['GET', 'POST'], 'coatingMachineDetails', 'StockController::loadView_coatingMachineDetails'); $routes->match(['GET', 'POST'], 'coatingMachineDetails', 'StockController::loadView_coatingMachineDetails');
$routes->post('addNewCoatingMachineDetails', 'StockController::addNewCoatingMachineDetails'); $routes->post('addNewCoatingMachineDetails', 'StockController::addNewCoatingMachineDetails');
$routes->post('updateCoatingMachineDetails', 'StockController::updateCoatingMachineDetails'); $routes->post('updateCoatingMachineDetails', 'StockController::updateCoatingMachineDetails');
$routes->get('deleteCoatingMachineDetails', 'StockController::deleteCoatingMachineDetails'); $routes->post('deleteBatchCardFile','StockController::deleteBatchCardFile');
//drier machine details //drier machine details
$routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'drierMachineDetails', 'StockController::drierMachineDetails'); $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'drierMachineDetails', 'StockController::drierMachineDetails');

View File

@ -688,7 +688,7 @@ class Payslip extends BaseController
if ($value->esi_applicable == 1) { $esiAmount = $currentDayBasic * $ESI_Rate / 100; } else { $esiAmount = 0; } if ($value->esi_applicable == 1) { $esiAmount = ($currentDayBasic + $currentDayHra) * $ESI_Rate / 100; } else { $esiAmount = 0; }
if ($value->pf_applicable == 1) { $pfAmount = $currentDayBasic * $PF_Rate / 100; } else { $pfAmount = 0; } if ($value->pf_applicable == 1) { $pfAmount = $currentDayBasic * $PF_Rate / 100; } else { $pfAmount = 0; }
/** pf amount per day**/ /** pf amount per day**/
@ -830,7 +830,7 @@ class Payslip extends BaseController
//$totalSalary = $currentDayBasic + $currentDayHra + $totSalayOT; //$totalSalary = $currentDayBasic + $currentDayHra + $totSalayOT;
if ($value->esi_applicable == 1) { $esiAmount = $currentDayBasic * $ESI_Rate / 100; } else { $esiAmount = 0;} if ($value->esi_applicable == 1) { $esiAmount = ($currentDayBasic + $currentDayHra) * $ESI_Rate / 100; } else { $esiAmount = 0;}
if ($value->pf_applicable == 1) { $pfAmount = $currentDayBasic * $PF_Rate / 100; } else { $pfAmount = 0;} if ($value->pf_applicable == 1) { $pfAmount = $currentDayBasic * $PF_Rate / 100; } else { $pfAmount = 0;}
/** pf amount per day**/ /** pf amount per day**/

View File

@ -149,12 +149,22 @@ class StockController extends BaseController
$startDate = "$month-01"; $startDate = "$month-01";
$endDate = date("Y-m-t", strtotime($startDate)); $endDate = date("Y-m-t", strtotime($startDate));
$data['coatingMachineDetails'] = $this->coatingMachineDetails_model $data['coatingMachineDetails'] = $this->coatingMachineDetails_model
->where('date >=', $startDate) ->select('t_coatingMachineDetails.*,
->where('date <=', $endDate) JSON_ARRAYAGG(
->where('is_active', 1) JSON_OBJECT(
->orderBy('date', 'asc') "client_given_name", t_batchcard_files.client_file_name,
"filename", t_batchcard_files.filename,
"batchCardId" , t_batchcard_files.id
)
) as batchcard_files')
->join('t_batchcard_files', 't_batchcard_files.coating_id = t_coatingMachineDetails.id', 'left')
->where('t_coatingMachineDetails.date >=', $startDate)
->where('t_coatingMachineDetails.date <=', $endDate)
->groupBy('t_coatingMachineDetails.id')
->orderBy('t_coatingMachineDetails.date', 'asc')
->findAll(); ->findAll();
$date = DateTime::createFromFormat('Y-m', $month); $date = DateTime::createFromFormat('Y-m', $month);
$formattedDate = $date->format('M-Y'); $formattedDate = $date->format('M-Y');
@ -193,9 +203,9 @@ class StockController extends BaseController
try { try {
// Insert into coating machine details table // Insert into coating machine details table
$inserted = $this->coatingMachineDetails_model->insert($postData); $insertedId = $this->coatingMachineDetails_model->insert($postData);
if ($inserted !== false && $inserted > 0) { if ($insertedId !== false && $insertedId > 0) {
$message1 = 'Coating Machine details updated successfully'; $message1 = 'Coating Machine details updated successfully';
@ -214,6 +224,37 @@ class StockController extends BaseController
throw new \Exception('Failed to insert Coating machine details.'); throw new \Exception('Failed to insert Coating machine details.');
} }
if ($insertedId !== false && $insertedId > 0) {
$batchCardFiles = $this->request->getFileMultiple('batchCard');
if (!empty($batchCardFiles) && !($batchCardFiles[0]->getError() === UPLOAD_ERR_NO_FILE)) {
foreach ($batchCardFiles as $file) {
if ($file->isValid() && !$file->hasMoved()) {
$clientGivenName = $file->getClientName(); // User-given filename
$newName = $file->getRandomName();
if ($file->move(WRITEPATH . 'uploads/batchcard', $newName)) {
// Only save to DB if file moved successfully
$db = \Config\Database::connect();
$builder = $db->table('t_batchcard_files');
$data = [
'client_file_name' => $clientGivenName,
'filename' => $newName,
'coating_id' => $insertedId
];
$builder->insert($data);
}
}
}
}
}
if ($this->db->transStatus() === false) { if ($this->db->transStatus() === false) {
@ -236,6 +277,8 @@ class StockController extends BaseController
public function updateCoatingMachineDetails() public function updateCoatingMachineDetails()
{ {
$message1 = ''; $message1 = '';
$message2 = ''; $message2 = '';
$message3 = ''; $message3 = '';
@ -250,6 +293,41 @@ class StockController extends BaseController
$this->db->transBegin(); $this->db->transBegin();
try { try {
$updated = $this->coatingMachineDetails_model->update($id, $putData); $updated = $this->coatingMachineDetails_model->update($id, $putData);
if ($updated !== false && $updated > 0) { // Assuming $id is the record ID being updated
$batchCardFiles = $this->request->getFileMultiple('batchCard');
// Step 4: Upload new files and insert into DB
foreach ($batchCardFiles as $index => $file) {
if ( !empty($batchCardFiles[$index]) && !($batchCardFiles[$index]->getError() === UPLOAD_ERR_NO_FILE)) {
$db = \Config\Database::connect();
$builder = $db->table('t_batchcard_files');
if ($file->isValid() && !$file->hasMoved()) {
$clientGivenName = $file->getClientName(); // User-given filename
$newName = $file->getRandomName(); // Randomized unique filename
// Move the new file to storage
if ($file->move(WRITEPATH . 'uploads/batchcard', $newName)) {
// Insert new file record into the database
$data = [
'client_file_name' => $clientGivenName,
'filename' => $newName,
'coating_id' => $id
];
$builder->insert($data);
}
}
}
}
}
if ($updated !== false && $updated > 0) { if ($updated !== false && $updated > 0) {
$message1 = "successfully updated Coating machineDetail ."; $message1 = "successfully updated Coating machineDetail .";
//update Gas stock consumption if update is successfull..!! //update Gas stock consumption if update is successfull..!!
@ -288,30 +366,68 @@ class StockController extends BaseController
} else { } else {
throw new \Exception('Failed to update Coating machine details.'); throw new \Exception('Failed to update Coating machine details.');
} }
} catch (\Exception $error) { } catch (\Exception $error) {
$this->db->transRollback(); $this->db->transRollback();
return redirect()->back()->with('error', ' ' . $error->getMessage()); return redirect()->back()->with('error', ' ' . $error->getMessage());
} }
} }
public function deleteCoatingMachineDetails() public function deleteBatchCardFile()
{ {
$data = $this->request->getPost();
$id = $this->request->getGet('id'); if (!empty($data)) {
$data['is_active'] = 0; $batchId = $data['id'];
$db = \Config\Database::connect();
$builder = $db->table('t_batchcard_files');
$updated = $this->coatingMachineDetails_model->update($id, $data); // Step 1: Fetch the filename from DB before deleting
$fileRecord = $builder->select('filename')->where('id', $batchId)->get()->getRow();
if ($updated) { if ($fileRecord) {
// Set flashdata for success message $filePath = WRITEPATH . 'uploads/batchcard/' . $fileRecord->filename;
return redirect()->to('/coatingMachineDetails')->with('success', 'Coating Machine details deleted successfully');
// Step 2: Delete the file from storage
if (file_exists($filePath)) {
unlink($filePath);
}
// Step 3: Delete the record from the database
$sql = "DELETE FROM t_batchcard_files WHERE id = ?";
$deleted = $db->query($sql, [$batchId]);
if ($deleted) {
return $this->response->setJSON([
'status' => '200',
'message' => "Deleted Batch Card File Successfully..!!"
]);
} else { } else {
// Set flashdata for error message return $this->response->setJSON([
return redirect()->back()->with('error', 'Failed to delete Coating machine details'); 'status' => '400',
'message' => "Failed to Delete..!! Try Again Later"
]);
}
} else {
return $this->response->setJSON([
'status' => '404',
'message' => "File Not Found..!!"
]);
} }
} }
return $this->response->setJSON([
'status' => '400',
'message' => "Invalid Request..!!"
]);
}
//incoming Silica Sand Details starts //incoming Silica Sand Details starts
public function loadView_incomingSilicaSandDetails() public function loadView_incomingSilicaSandDetails()
{ {

View File

@ -13,7 +13,7 @@ class CoatingMachineDetailsModel extends Model
protected $useSoftDeletes = false; protected $useSoftDeletes = false;
protected $protectFields = true; protected $protectFields = true;
protected $allowedFields = ['shift','machineOnTime','machineOffTime','totalCoating','date', protected $allowedFields = ['shift','machineOnTime','machineOffTime','totalCoating','date',
'machineRunningInHrs' , 'perHourCoatingSandQTY' , 'perHourGasConsumption' , 'machineRunningInHrs' , 'perHourCoatingSandQTY' , 'perHourGasConsumption' ,'grade',
'totalCoatingSandInKg','totalGasConsumption','customerName', 'is_active','created_at','updated_at']; 'totalCoatingSandInKg','totalGasConsumption','customerName', 'is_active','created_at','updated_at'];
protected bool $allowEmptyInserts = false; protected bool $allowEmptyInserts = false;

View File

@ -327,12 +327,13 @@
<th class="celda_encabezado_general" style="padding: 10px;">Machine On Time</th> <th class="celda_encabezado_general" style="padding: 10px;">Machine On Time</th>
<th class="celda_encabezado_general" style="padding: 10px;">Machine Off Time</th> <th class="celda_encabezado_general" style="padding: 10px;">Machine Off Time</th>
<th class="celda_encabezado_general" style="padding: 10px;">Machine Running(hr)</th> <th class="celda_encabezado_general" style="padding: 10px;">Machine Running(hr)</th>
<th class="celda_encabezado_general" style="padding: 10px;">Customer Name</th>
<th class="celda_encabezado_general" style="padding: 10px;">Grade</th>
<th class="celda_encabezado_general" style="padding: 10px;">Total Coating</th> <th class="celda_encabezado_general" style="padding: 10px;">Total Coating</th>
<th class="celda_encabezado_general" style="padding: 10px;">Total Coating Sand(kg)</th> <th class="celda_encabezado_general" style="padding: 10px;">Total Coating Sand(kg)</th>
<th class="celda_encabezado_general" style="padding: 10px;">Total Gas Consumption</th> <th class="celda_encabezado_general" style="padding: 10px;">Total Gas Consumption</th>
<th class="celda_encabezado_general" style="padding: 10px;">Hour Gas</th> <th class="celda_encabezado_general" style="padding: 10px;">Hour Gas</th>
<th class="celda_encabezado_general" style="padding: 10px;">Hour QTY(kg)</th> <th class="celda_encabezado_general" style="padding: 10px;">Hour QTY(kg)</th>
<th class="celda_encabezado_general" style="padding: 10px;">Customer Name</th>
<th class="celda_encabezado_general" style="padding: 10px;">Action</th> <th class="celda_encabezado_general" style="padding: 10px;">Action</th>
</tr> </tr>
</thead> </thead>
@ -357,18 +358,31 @@
<?php <?php
$date = DateTime::createFromFormat('Y-m-d', $record['date'])->format('d-m-Y'); $date = DateTime::createFromFormat('Y-m-d', $record['date'])->format('d-m-Y');
?> ?>
<!-- td:eq(0) -->
<td class="celda_normal"><?php echo $date ?></td> <td class="celda_normal"><?php echo $date ?></td>
<!-- td:eq(1) -->
<td class="celda_normal"><?php echo $record['shift'] ?></td> <td class="celda_normal"><?php echo $record['shift'] ?></td>
<!-- td:eq(2) -->
<td class="celda_normal"><?php echo $record['machineOnTime'] ?></td> <td class="celda_normal"><?php echo $record['machineOnTime'] ?></td>
<!-- td:eq(3) -->
<td class="celda_normal"><?php echo $record['machineOffTime'] ?></td> <td class="celda_normal"><?php echo $record['machineOffTime'] ?></td>
<td class="celda_normal"><?php echo $record['machineRunningInHrs'] ?? '' ?></td> <!-- td:eq(4) -->
<td class="celda_normal"><?php echo $record['machineRunningInHrs'] ?? ' ' ?></td>
<!-- td:eq(5) -->
<td class="celda_normal"><?php echo $record['customerName'] ?? '' ?></td>
<!-- td:eq(6) -->
<td class="celda_normal"><?php echo $record['grade'] ?? ' ' ?></td>
<!-- td:eq(7) -->
<td class="celda_normal"><?php echo $record['totalCoating'] ?></td> <td class="celda_normal"><?php echo $record['totalCoating'] ?></td>
<!-- td:eq(8) -->
<td class="celda_normal"><?php echo $record['totalCoatingSandInKg'] ?></td> <td class="celda_normal"><?php echo $record['totalCoatingSandInKg'] ?></td>
<!-- td:eq(9) -->
<td class="celda_normal"><?php echo $record['totalGasConsumption'] ?></td> <td class="celda_normal"><?php echo $record['totalGasConsumption'] ?></td>
<!-- td:eq(10) -->
<td class="celda_normal"><?php echo $record['perHourGasConsumption'] ?? '' ?></td> <td class="celda_normal"><?php echo $record['perHourGasConsumption'] ?? '' ?></td>
<!-- td:eq(11) -->
<td class="celda_normal"><?php echo $record['perHourCoatingSandQTY'] ?? '' ?></td> <td class="celda_normal"><?php echo $record['perHourCoatingSandQTY'] ?? '' ?></td>
<td class="celda_normal"><?php echo $record['customerName']; ?></td> <!-- td:eq(12) -->
<td class="celda_normal" style="background-color:white;"> <td class="celda_normal" style="background-color:white;">
<a data-toggle="tooltip" class="edit-btn" <a data-toggle="tooltip" class="edit-btn"
data-target="editCoatingMachineDetailModal" data-toggle="modal" data-target="editCoatingMachineDetailModal" data-toggle="modal"
@ -379,6 +393,8 @@
</a> </a>
</td> </td>
<!-- td:eq(13) -->
<td style="display:none;"><?php echo $record['batchcard_files'] ?? ' ' ?></td>
</tr> </tr>
@ -389,6 +405,7 @@
if (!isset($summary['totalCoating'])) { if (!isset($summary['totalCoating'])) {
$summary['totalMachineRunningHrs'] = 0 ;
$summary['totalCoating'] = 0 ; $summary['totalCoating'] = 0 ;
$summary['totalCoatingSandInKg'] = 0 ; $summary['totalCoatingSandInKg'] = 0 ;
$summary['totalGasConsumption'] = 0 ; $summary['totalGasConsumption'] = 0 ;
@ -397,6 +414,7 @@
} }
$summary['totalMachineRunningHrs'] += $record['machineRunningInHrs'] == "-" ? 0 : (float) $record['machineRunningInHrs'];
$summary['totalCoating'] += $record['totalCoating'] == "-" ? 0 : (float) $record['totalCoating'] ; $summary['totalCoating'] += $record['totalCoating'] == "-" ? 0 : (float) $record['totalCoating'] ;
$summary['totalCoatingSandInKg'] += $record['totalCoatingSandInKg'] == "-" ? 0 : (float) $record['totalCoatingSandInKg'] ; $summary['totalCoatingSandInKg'] += $record['totalCoatingSandInKg'] == "-" ? 0 : (float) $record['totalCoatingSandInKg'] ;
$summary['totalGasConsumption'] += $record['totalGasConsumption'] == "-" ? 0 :(float) $record['totalGasConsumption'] ; $summary['totalGasConsumption'] += $record['totalGasConsumption'] == "-" ? 0 :(float) $record['totalGasConsumption'] ;
@ -415,6 +433,8 @@
<th class="celda_encabezado_total" style="padding: 10px;">Machine On Time</th> <th class="celda_encabezado_total" style="padding: 10px;">Machine On Time</th>
<th class="celda_encabezado_total" style="padding: 10px;">Machine Off Time</th> <th class="celda_encabezado_total" style="padding: 10px;">Machine Off Time</th>
<th class="celda_encabezado_total" style="padding: 10px;">Machine Running(hr)</th> <th class="celda_encabezado_total" style="padding: 10px;">Machine Running(hr)</th>
<th class="celda_encabezado_total" style="padding: 10px;">Customer Name </th>
<th class="celda_encabezado_total" style="padding: 10px;">Grade</th>
<th class="celda_encabezado_total" style="padding: 10px;">Total Coating</th> <th class="celda_encabezado_total" style="padding: 10px;">Total Coating</th>
<th class="celda_encabezado_total" style="padding: 10px;">Total Coating Sand(kg)</th> <th class="celda_encabezado_total" style="padding: 10px;">Total Coating Sand(kg)</th>
<th class="celda_encabezado_total" style="padding: 10px;">Total Gas Consumption</th> <th class="celda_encabezado_total" style="padding: 10px;">Total Gas Consumption</th>
@ -434,12 +454,14 @@
<td class="celda_normal "> - </td> <td class="celda_normal "> - </td>
<td class="celda_normal "> - </td> <td class="celda_normal "> - </td>
<td class="celda_normal "> - </td> <td class="celda_normal "> - </td>
<td class="celda_normal "> <?=$summary['totalMachineRunningHrs']?></td>
<td class="celda_normal "> - </td>
<td class="celda_normal "> - </td> <td class="celda_normal "> - </td>
<td class="celda_normal "><?=$summary['totalCoating']?></td> <td class="celda_normal "><?=$summary['totalCoating']?></td>
<td class="celda_normal "><?=$summary['totalCoatingSandInKg']?></td> <td class="celda_normal "><?=$summary['totalCoatingSandInKg']?></td>
<td class="celda_normal "><?=$summary['totalGasConsumption']?></td> <td class="celda_normal "><?=$summary['totalGasConsumption']?></td>
<td class="celda_normal "><?=$summary['perHourGasConsumption']?></td> <td class="celda_normal "><?=number_format($summary['totalGasConsumption']/$summary['totalMachineRunningHrs'], 2)?> (avg)</td>
<td class="celda_normal "><?=$summary['perHourCoatingSandQTY']?></td> <td class="celda_normal "><?=number_format($summary['totalCoatingSandInKg']/$summary['totalMachineRunningHrs'], 2)?> (avg)</td>
</tr> </tr>
</tbody> </tbody>
@ -492,7 +514,9 @@
</div> </div>
<!-- form --> <!-- form -->
<form method="post" action="<?php echo base_url(); ?>addNewCoatingMachineDetails?month=<?= $month; ?>"> <form method="post"
enctype="multipart/form-data"
action="<?php echo base_url(); ?>addNewCoatingMachineDetails?month=<?= $month; ?>">
<div class="modal-body"> <div class="modal-body">
<div class="form-row"> <div class="form-row">
@ -594,7 +618,7 @@
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="machineRunningInHrsId"> Machine Running In Hrs</label> <label for="machineRunningInHrsId"> Machine Running In Hrs</label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
<input type="text" class="form-control" id="machineRunningInHrsId" <input type="text" class="form-control" readonly id="machineRunningInHrsId"
name="machineRunningInHrs" required> name="machineRunningInHrs" required>
</div> </div>
@ -609,9 +633,9 @@
<!-- grade --> <!-- grade -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="totalCoatingId">grade</label> <label for="gradeId">grade</label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
<input type="text" class="form-control" id="totalCoatingId" name="totalCoating" value="" <input type="text" class="form-control" id="gradeId" name="grade" value=""
required> required>
</div> </div>
@ -648,7 +672,7 @@
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="perHourCoatingSandQTY">Per Hour Coating Sand QTY</label> <label for="perHourCoatingSandQTY">Per Hour Coating Sand QTY</label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
<input type="text" class="form-control" id="perHourCoatingSandQTYId" <input type="text" class="form-control" readonly id="perHourCoatingSandQTYId"
name="perHourCoatingSandQTY" required> name="perHourCoatingSandQTY" required>
</div> </div>
@ -657,8 +681,8 @@
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="perHourGasConsumptionId">Per Hour Gas Consumption </label> <label for="perHourGasConsumptionId">Per Hour Gas Consumption </label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
<input type="text" class="form-control" id="perHourGasConsumptionId" <input type="text" class="form-control" readonly id="perHourGasConsumptionId"
name="perHourGasConsumption" required> name="perHourGasConsumption" required >
</div> </div>
@ -666,14 +690,21 @@
</div> </div>
<div class="form-row">
<div class="form-row" id="batchCardRowId">
<!-- batch card file upload --> <!-- batch card file upload -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="totalCoatingSandId">upload batch card</label>
<span class="badge mandatory">*</span> <label for="">Upload Batch Card</label>
<input type="text" class="form-control" id="totalCoatingSandId" name="totalCoatingSandInKg"
value="" required> <div>
<input type="file" class="batchfile" name="batchCard[]">
</div>
<button type="button" class="btn btn-success btn-sm mt-2" id="batchCardAddBtnId">Add More</button>
</div> </div>
@ -693,7 +724,7 @@
<!-- editCoatingMachineDetailModal --> <!-- editCoatingMachineDetailModal -->
<div class="modal fade" id="editCoatingMachineDetailModal" tabindex="-1" role="dialog" <div class="modal fade" id="editCoatingMachineDetailModal" tabindex="-1" role="dialog"
aria-labelledby="editCoatingMachineDetailModalLabel" aria-hidden="true"> aria-labelledby="editCoatingMachineDetailModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl" style="width:1060px !important ;" role="document"> <div class="modal-dialog modal-lg" style="width:1060px !important ;" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
@ -707,21 +738,28 @@
<!-- form --> <!-- form -->
<form method="post" id="editCoatingMachineDetailModalFormId" <form method="post" id="editCoatingMachineDetailModalFormId"
enctype="multipart/form-data"
action="<?php echo base_url(); ?>updateCoatingMachineDetails?month=<?= $month; ?>"> action="<?php echo base_url(); ?>updateCoatingMachineDetails?month=<?= $month; ?>">
<div class="modal-body"> <div class="modal-body">
<div class="form-row"> <div class="form-row">
<!-- date -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="editDateId">Date</label> <label for="editDateId">Date</label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
<input type="date" class="form-control" id="editDateId" name="date" value="" required> <input type="date" class="form-control" id="editDateId" name="date" value="" required>
<input type="hidden" name="editCoatingMachineDetailId" id="editCoatingMachineDetailId"> <input type="hidden" name="editCoatingMachineDetailId" id="editCoatingMachineDetailId">
</div> </div>
<!-- shift -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="editShiftId">Shift</label> <label for="editShiftId">Shift</label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editShiftId" name="shift" value="" required> <input type="text" class="form-control" id="editShiftId" name="shift" value="" required>
</div> </div>
<!-- machine on time -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="editMachineOnTimeHrId">Machine On Time</label> <label for="editMachineOnTimeHrId">Machine On Time</label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
@ -758,6 +796,7 @@
</div> </div>
<!-- machine off time -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="editMachineOffTimeHrId">Machine Off Time</label> <label for="editMachineOffTimeHrId">Machine Off Time</label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
@ -796,24 +835,55 @@
</div> </div>
<div class="form-row"> <div class="form-row">
<!-- total hours -->
<div class="form-group col-md-3">
<label for="editMachineRunningInHrsId"> Machine Running In Hrs</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" readonly id="editMachineRunningInHrsId"
name="machineRunningInHrs" required>
</div>
<!-- customer name -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="editCustomerNameId">Customer Name</label> <label for="editCustomerNameId">Customer Name</label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editCustomerNameId" name="customerName" value="" <input type="text" class="form-control" id="editCustomerNameId" name="customerName" value=""
required> required>
</div> </div>
<!-- grade -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="editTotalCoatingId">Total Coating</label> <label for="editGradeId">grade</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editGradeId" name="grade" value=""
required>
</div>
<!-- total coating as renamed to total production -->
<div class="form-group col-md-3">
<label for="editTotalCoatingId">Total Production</label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editTotalCoatingId" name="totalCoating" value="" <input type="text" class="form-control" id="editTotalCoatingId" name="totalCoating" value=""
required> required>
</div> </div>
</div>
<div class="form-row">
<!-- total coating sand in kg -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="editTotalCoatingSandId">Total Coating Sand (in Kg)</label> <label for="editTotalCoatingSandId">Total Coating Sand (in Kg)</label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editTotalCoatingSandId" <input type="text" class="form-control" id="editTotalCoatingSandId"
name="totalCoatingSandInKg" value="" required> name="totalCoatingSandInKg" value="" required>
</div> </div>
<!-- total gas consumption -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="editTotalGasConsumptionId">Total Gas Consumption</label> <label for="editTotalGasConsumptionId">Total Gas Consumption</label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
@ -823,35 +893,45 @@
name="existingTotalGasConsumption" value=""> name="existingTotalGasConsumption" value="">
</div> </div>
<!-- per hour Coating sand qty -->
</div>
<div class="form-row">
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="editMachineRunningInHrsId"> Machine Running In Hrs</label> <label for="editPerHourCoatingSandQTYId">Per Hour Coating Sand QTY</label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editMachineRunningInHrsId" <input type="text" class="form-control" readonly id="editPerHourCoatingSandQTYId"
name="machineRunningInHrs" required> name="perHourCoatingSandQTY" required>
</div> </div>
<!-- per hour gas consumption -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="editPerHourGasConsumptionId">Per Hour Gas Consumption </label> <label for="editPerHourGasConsumptionId">Per Hour Gas Consumption </label>
<span class="badge mandatory">*</span> <span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editPerHourGasConsumptionId" <input type="text" class="form-control" readonly id="editPerHourGasConsumptionId"
name="perHourGasConsumption" required> name="perHourGasConsumption" required>
</div> </div>
<div class="form-group col-md-3">
<label for="editPerHourCoatingSandQTYId">Per Hour Coating Sand QTY</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="editPerHourCoatingSandQTYId"
name="perHourCoatingSandQTY" required>
</div> </div>
<div class="form-row" id="editBatchCardRowId">
<!-- batch card file upload -->
<div class="form-group col-md-3">
<label for="editBatchCardId">Upload Batch Card</label>
<div>
<input type="file" class="editBatchFile " name="batchCard[]">
</div>
<button type="button" class="btn btn-success btn-sm mt-2" id="editBatchCardAddBtnId">Add More</button>
</div>
</div> </div>
</div> </div>
@ -1147,16 +1227,46 @@
var machineOnTimeHr = row.find('td:eq(2)').text(); var machineOnTimeHr = row.find('td:eq(2)').text();
var machineOffTimeHr = row.find('td:eq(3)').text(); var machineOffTimeHr = row.find('td:eq(3)').text();
var machineRunningInHrs = row.find('td:eq(4)').text(); var machineRunningInHrs = row.find('td:eq(4)').text();
var totalCoating = row.find('td:eq(5)').text(); var customerName = row.find('td:eq(5)').text();
var totalCoatingSandInKg = row.find('td:eq(6)').text(); var grade = row.find('td:eq(6)').text();
var totalGasConsumption = row.find('td:eq(7)').text(); var totalCoating = row.find('td:eq(7)').text();
var perHourGasConsumption = row.find('td:eq(8)').text(); var totalCoatingSandInKg = row.find('td:eq(8)').text();
var perHourCoatingSandQTY = row.find('td:eq(9)').text(); var totalGasConsumption = row.find('td:eq(9)').text();
var customerName = row.find('td:eq(10)').text(); var perHourGasConsumption = row.find('td:eq(10)').text();
var perHourCoatingSandQTY = row.find('td:eq(11)').text();
var batchCards = row.find('td:eq(13)').text().trim();
console.log(batchCards);
JSON.parse(batchCards).map(element => {
if(!element.client_given_name){
console.log("filename null")
return;
}
let fileCount = $('.editBatchFile').length; // Count existing batch files
if (fileCount >= 5) {
return;
}
let string = `<div class="form-group col-md-3 batch-container">
<label for="">Change Batch Card</label>
<input type="file" class="editBatchFile additionalBatchFile" name="batchCard[]" >
<p>( Previously Uploaded File ${element.client_given_name} )</p>
<button type="button" class="btn btn-danger btn-sm mt-2 removeBatch" data-id="${element.batchCardId}">Remove</button>
</div>`;
$('#editBatchCardRowId').append(string)
});
// Fill the modal fields with the values // Fill the modal fields with the values
//batchfile
$('#editCoatingMachineDetailId').val(row.data('id')); $('#editCoatingMachineDetailId').val(row.data('id'));
$('#editCustomerNameId').val(customerName); $('#editCustomerNameId').val(customerName);
@ -1164,6 +1274,7 @@
$('#editShiftId').val(shift); $('#editShiftId').val(shift);
$('#editMachineOnTimeHrId').val(machineOnTimeHr).change(); $('#editMachineOnTimeHrId').val(machineOnTimeHr).change();
$('#editMachineOffTimeHrId').val(machineOffTimeHr).change(); $('#editMachineOffTimeHrId').val(machineOffTimeHr).change();
$('#editGradeId').val(grade);
$('#editTotalCoatingId').val(totalCoating); $('#editTotalCoatingId').val(totalCoating);
$('#editTotalCoatingSandId').val(totalCoatingSandInKg); $('#editTotalCoatingSandId').val(totalCoatingSandInKg);
$('#editTotalGasConsumptionId').val(totalGasConsumption); $('#editTotalGasConsumptionId').val(totalGasConsumption);
@ -1180,6 +1291,16 @@
}); });
</script> </script>
<script>
$(document).ready(function(){
$('#editCoatingMachineDetailModal').on('hidden.bs.modal', function () {
$('.batch-container').remove(); // This will remove all child elements
});
});
</script>
<!-- calculations for some fields needed in onChange while adding coating machine details --> <!-- calculations for some fields needed in onChange while adding coating machine details -->
<script> <script>
@ -1510,3 +1631,75 @@
</script> </script>
<script>
$(document).ready(function () {
$('#batchCardAddBtnId').click(function () {
let fileCount = $('.batchfile').length; // Count existing batch files
if (fileCount >= 5) { // Set your limit here (e.g., max 5 files)
alert("You can only upload up to 5 batch files.");
return;
}
let string = `<div class="form-group col-md-3 batch-container">
<label for="">Upload Batch Card</label>
<input type="file" class="batchfile" name="batchCard[]" >
<button type="button" class="btn btn-danger btn-sm mt-2 removeBatch">Remove</button>
</div>`;
$('#batchCardRowId').append(string);
});
// Remove batch card field dynamically
$(document).on('click', '.removeBatch', function () {
$(this).closest('.batch-container').remove();
});
});
$(document).ready(function () {
$('#editBatchCardAddBtnId').click(function () {
let fileCount = $('.editBatchFile').length; // Count existing batch files
if (fileCount >= 5) { // Set your limit here (e.g., max 5 files)
alert("You can only upload up to 5 batch files.");
return;
}
let string = `<div class="form-group col-md-3 batch-container">
<label for="">Upload Batch Card</label>
<input type="file" class="editBatchFile" name="batchCard[]" >
<button type="button" class="btn btn-danger btn-sm mt-2 removeBatch">Remove</button>
</div>`;
$('#editBatchCardRowId').append(string);
});
// Remove batch card field dynamically
$(document).on('click', '.removeBatch', function () {
let batchId = this.getAttribute('data-id'); // Get the data-id
if (confirm("Are you sure you want to delete this batch file?")) {
$.ajax({
url: "<?php echo base_url();?>/deleteBatchCardFile",
type: "POST",
data: { id: batchId },
success: function (response) {
if(response.status == "200"){
alert("Batch file deleted successfully!");
$(this).closest('.batch-container').remove(); // Remove from UI
}
},
error: function (xhr, status, error) {
alert("Error deleting batch file: " + error);
}
});
}
});
});
</script>