changes in stock controller
This commit is contained in:
parent
f6573a31db
commit
ab5e5b10a1
@ -91,7 +91,6 @@ class StockController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Coating Machine Details starts
|
//Coating Machine Details starts
|
||||||
|
|
||||||
public function loadView_coatingMachineDetails(){
|
public function loadView_coatingMachineDetails(){
|
||||||
|
|
||||||
if ($this->request->getMethod() === 'POST'){
|
if ($this->request->getMethod() === 'POST'){
|
||||||
@ -104,7 +103,9 @@ class StockController extends BaseController
|
|||||||
$month=$formattedDate;
|
$month=$formattedDate;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$month = date('Y-m');
|
|
||||||
|
$filteredMonth=$this->request->getGet('month');
|
||||||
|
$month = $filteredMonth ?? date('Y-m');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->global['pageTitle'] = 'Coating Machine Details ';
|
$this->global['pageTitle'] = 'Coating Machine Details ';
|
||||||
@ -132,7 +133,8 @@ class StockController extends BaseController
|
|||||||
public function addNewCoatingMachineDetails(){
|
public function addNewCoatingMachineDetails(){
|
||||||
|
|
||||||
$postData=$this->request->getPost();
|
$postData=$this->request->getPost();
|
||||||
|
$month =$this->request->getGet('month');
|
||||||
|
$month = DateTime::createFromFormat('M-Y', $month)->format('Y-m');
|
||||||
|
|
||||||
$date = $postData['date'];
|
$date = $postData['date'];
|
||||||
$shift = $postData['shift'];
|
$shift = $postData['shift'];
|
||||||
@ -144,16 +146,19 @@ class StockController extends BaseController
|
|||||||
->first();
|
->first();
|
||||||
|
|
||||||
if(!empty($sameShiftOnDateExists)){
|
if(!empty($sameShiftOnDateExists)){
|
||||||
|
|
||||||
return redirect()->back()->with('error', 'Already same shift exists on the same date ..!!');
|
return redirect()->back()->with('error', 'Already same shift exists on the same date ..!!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$inserted= $this->coatingMachineDetails_model->insert($postData);
|
$inserted= $this->coatingMachineDetails_model->insert($postData);
|
||||||
|
|
||||||
if ($inserted) {
|
if ($inserted) {
|
||||||
|
//update Gas stock consumption if insert is successfull..!!
|
||||||
|
$dateToBeInserted = $postData['date'];
|
||||||
|
$consumption = $postData['totalGasConsumption'];
|
||||||
|
$this->updateGasStockConsumption($dateToBeInserted , $consumption);
|
||||||
|
|
||||||
// Set flashdata for success message
|
// Set flashdata for success message
|
||||||
return redirect()->to('/coatingMachineDetails')->with('success', 'Coating Machine details updated successfully');
|
return redirect()->to("/coatingMachineDetails?month=$month")->with('success', 'Coating Machine details updated successfully');
|
||||||
} else {
|
} else {
|
||||||
// Set flashdata for error message
|
// Set flashdata for error message
|
||||||
return redirect()->back()->with('error', 'Failed to update Coating machine details');
|
return redirect()->back()->with('error', 'Failed to update Coating machine details');
|
||||||
@ -165,14 +170,26 @@ class StockController extends BaseController
|
|||||||
public function updateCoatingMachineDetails(){
|
public function updateCoatingMachineDetails(){
|
||||||
|
|
||||||
$putData=$this->request->getPost();
|
$putData=$this->request->getPost();
|
||||||
|
$month =$this->request->getGet('month');
|
||||||
|
$month = DateTime::createFromFormat('M-Y', $month)->format('Y-m');
|
||||||
|
|
||||||
$id = $putData['editCoatingMachineDetailId'];
|
$id = $putData['editCoatingMachineDetailId'];
|
||||||
|
|
||||||
$updated= $this->coatingMachineDetails_model->update($id,$putData);
|
$updated= $this->coatingMachineDetails_model->update($id,$putData);
|
||||||
|
|
||||||
if ($updated) {
|
if ($updated) {
|
||||||
|
//update Gas stock consumption if update is successfull..!!
|
||||||
|
$dateToBeUpdated = $putData['date'];
|
||||||
|
|
||||||
|
$existingCoatingGasConsumption = $putData['existingTotalGasConsumption'];
|
||||||
|
$updatedCoatingGasConsumption = $putData['totalGasConsumption'];
|
||||||
|
if( $existingCoatingGasConsumption != $updatedCoatingGasConsumption ){
|
||||||
|
$changeInConsumption = $updatedCoatingGasConsumption - $existingCoatingGasConsumption;
|
||||||
|
$this->updateGasStockConsumption($dateToBeUpdated , $changeInConsumption);
|
||||||
|
}
|
||||||
|
|
||||||
// Set flashdata for success message
|
// Set flashdata for success message
|
||||||
return redirect()->to('/coatingMachineDetails')->with('success', 'Coating Machine details updated successfully');
|
return redirect()->to("/coatingMachineDetails?month=$month")->with('success', 'Coating Machine details updated successfully');
|
||||||
} else {
|
} else {
|
||||||
// Set flashdata for error message
|
// Set flashdata for error message
|
||||||
return redirect()->back()->with('error', 'Failed to update Coating machine details');
|
return redirect()->back()->with('error', 'Failed to update Coating machine details');
|
||||||
@ -199,7 +216,6 @@ class StockController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
//incoming Silica Sand Details starts
|
//incoming Silica Sand Details starts
|
||||||
|
|
||||||
public function loadView_incomingSilicaSandDetails(){
|
public function loadView_incomingSilicaSandDetails(){
|
||||||
|
|
||||||
if ($this->request->getMethod() === 'POST'){
|
if ($this->request->getMethod() === 'POST'){
|
||||||
@ -308,8 +324,8 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bag Stock details starts
|
|
||||||
|
|
||||||
|
// Bag Stock details starts
|
||||||
public function loadView_bagStockDetails(){
|
public function loadView_bagStockDetails(){
|
||||||
|
|
||||||
if ($this->request->getMethod() === 'POST'){
|
if ($this->request->getMethod() === 'POST'){
|
||||||
@ -473,7 +489,6 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
//Dust And Rough Stock Details
|
//Dust And Rough Stock Details
|
||||||
|
|
||||||
public function loadView_dustAndRoughStockDetails(){
|
public function loadView_dustAndRoughStockDetails(){
|
||||||
|
|
||||||
if ($this->request->getMethod() === 'POST'){
|
if ($this->request->getMethod() === 'POST'){
|
||||||
@ -571,7 +586,6 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
//Resin Stock Details
|
//Resin Stock Details
|
||||||
|
|
||||||
public function loadView_resinStockDetails(){
|
public function loadView_resinStockDetails(){
|
||||||
|
|
||||||
if ($this->request->getMethod() === 'POST'){
|
if ($this->request->getMethod() === 'POST'){
|
||||||
@ -736,7 +750,6 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
|
|
||||||
//Gas Stock Details
|
//Gas Stock Details
|
||||||
|
|
||||||
public function loadView_gasStockDetails(){
|
public function loadView_gasStockDetails(){
|
||||||
|
|
||||||
if ($this->request->getMethod() === 'POST'){
|
if ($this->request->getMethod() === 'POST'){
|
||||||
@ -863,8 +876,6 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
private function updateGasStockConsumption($date , $consumption){
|
private function updateGasStockConsumption($date , $consumption){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$resultExists = $this->gasStockDetails_model
|
$resultExists = $this->gasStockDetails_model
|
||||||
->where('date',$date)
|
->where('date',$date)
|
||||||
->first();
|
->first();
|
||||||
@ -908,7 +919,6 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
if(!empty($inserts)){
|
if(!empty($inserts)){
|
||||||
$this->gasStockDetails_model->insertBatch($inserts);
|
$this->gasStockDetails_model->insertBatch($inserts);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -918,7 +928,7 @@ class StockController extends BaseController
|
|||||||
// --------------------------------------------gwm----------------------------------------------
|
// --------------------------------------------gwm----------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
function getMonthDatesFromInput($monthYear) {
|
public function getMonthDatesFromInput($monthYear) {
|
||||||
|
|
||||||
$date = DateTime::createFromFormat('M-Y', $monthYear);
|
$date = DateTime::createFromFormat('M-Y', $monthYear);
|
||||||
|
|
||||||
@ -945,8 +955,7 @@ class StockController extends BaseController
|
|||||||
return $dates;
|
return $dates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function generateTimeOptions() {
|
||||||
function generateTimeOptions() {
|
|
||||||
$times = [];
|
$times = [];
|
||||||
$start = strtotime('00:00'); // Start at midnight (12:00 AM)
|
$start = strtotime('00:00'); // Start at midnight (12:00 AM)
|
||||||
$end = strtotime('23:45'); // End at 11:45 PM
|
$end = strtotime('23:45'); // End at 11:45 PM
|
||||||
@ -961,8 +970,7 @@ class StockController extends BaseController
|
|||||||
return $times;
|
return $times;
|
||||||
}
|
}
|
||||||
|
|
||||||
function drierMachineDetails()
|
public function drierMachineDetails(){
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
$currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y');
|
$currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y');
|
||||||
@ -996,8 +1004,7 @@ class StockController extends BaseController
|
|||||||
$this->loadViews("drierMachineDetails", $this->global, $data, NULL);
|
$this->loadViews("drierMachineDetails", $this->global, $data, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addOrEditdrierMachineDetails()
|
public function addOrEditdrierMachineDetails(){
|
||||||
{
|
|
||||||
$drierData = json_decode($this->request->getPost('drierData'), true);
|
$drierData = json_decode($this->request->getPost('drierData'), true);
|
||||||
|
|
||||||
if (empty($drierData)) {
|
if (empty($drierData)) {
|
||||||
@ -1057,7 +1064,6 @@ class StockController extends BaseController
|
|||||||
echo "Data successfully saved.";
|
echo "Data successfully saved.";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function factoryVehicleDieselDetails()
|
public function factoryVehicleDieselDetails()
|
||||||
{
|
{
|
||||||
$currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y');
|
$currentMonth = $this->request->getPost('month') ? $this->request->getPost('month') : date('M-Y');
|
||||||
@ -1263,8 +1269,7 @@ class StockController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getElectricConsumptionPivot($machineDetails , $startDate , $endDeate)
|
public function getElectricConsumptionPivot($machineDetails , $startDate , $endDeate) {
|
||||||
{
|
|
||||||
$machineIds = array_column($machineDetails, 'id');
|
$machineIds = array_column($machineDetails, 'id');
|
||||||
|
|
||||||
if (empty($machineIds)) { return []; }
|
if (empty($machineIds)) { return []; }
|
||||||
@ -1290,8 +1295,7 @@ class StockController extends BaseController
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addOrEditPowerConsumptionDetails()
|
public function addOrEditPowerConsumptionDetails(){
|
||||||
{
|
|
||||||
$electricMachineTableData = json_decode($this->request->getPost('electricMachineTableData'), true);
|
$electricMachineTableData = json_decode($this->request->getPost('electricMachineTableData'), true);
|
||||||
|
|
||||||
$transformedData = [];
|
$transformedData = [];
|
||||||
|
|||||||
@ -338,7 +338,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- form -->
|
<!-- form -->
|
||||||
<form method="post" action="<?php echo base_url(); ?>addNewCoatingMachineDetails">
|
<form method="post" action="<?php echo base_url(); ?>addNewCoatingMachineDetails?month=<?=$month;?>">
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
@ -518,7 +518,7 @@
|
|||||||
|
|
||||||
<!-- form -->
|
<!-- form -->
|
||||||
<form method="post" id="editCoatingMachineDetailModalFormId"
|
<form method="post" id="editCoatingMachineDetailModalFormId"
|
||||||
action="<?php echo base_url(); ?>updateCoatingMachineDetails">
|
action="<?php echo base_url(); ?>updateCoatingMachineDetails?month=<?=$month;?>">
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
@ -634,6 +634,8 @@
|
|||||||
<span class="badge mandatory">*</span>
|
<span class="badge mandatory">*</span>
|
||||||
<input type="text" class="form-control" id="editTotalGasConsumptionId"
|
<input type="text" class="form-control" id="editTotalGasConsumptionId"
|
||||||
name="totalGasConsumption" value="" required>
|
name="totalGasConsumption" value="" required>
|
||||||
|
<input type="hidden" class="form-control" id="existingTotalGasConsumptionId"
|
||||||
|
name="existingTotalGasConsumption" value="" >
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -743,6 +745,7 @@
|
|||||||
$('#editTotalCoatingId').val(totalCoating);
|
$('#editTotalCoatingId').val(totalCoating);
|
||||||
$('#editTotalCoatingSandId').val(totalCoatingSandInKg);
|
$('#editTotalCoatingSandId').val(totalCoatingSandInKg);
|
||||||
$('#editTotalGasConsumptionId').val(totalGasConsumption);
|
$('#editTotalGasConsumptionId').val(totalGasConsumption);
|
||||||
|
$('#existingTotalGasConsumptionId').val(totalGasConsumption);
|
||||||
$('#editMachineRunningInHrsId').val(machineRunningInHrs);
|
$('#editMachineRunningInHrsId').val(machineRunningInHrs);
|
||||||
$('#editPerHourGasConsumptionId').val(perHourGasConsumption);
|
$('#editPerHourGasConsumptionId').val(perHourGasConsumption);
|
||||||
$('#editPerHourCoatingSandQTYId').val(perHourCoatingSandQTY);
|
$('#editPerHourCoatingSandQTYId').val(perHourCoatingSandQTY);
|
||||||
|
|||||||
@ -461,7 +461,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
|||||||
|
|
||||||
const totalHours = hours + (minutes / 60);
|
const totalHours = hours + (minutes / 60);
|
||||||
|
|
||||||
tr.find('td:eq(4)').text(totalHours);
|
tr.find('td:eq(3)').text(totalHours);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,7 +493,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
|||||||
|
|
||||||
const totalHours = hours + (minutes / 60);
|
const totalHours = hours + (minutes / 60);
|
||||||
|
|
||||||
tr.find('td:eq(4)').text(totalHours);
|
tr.find('td:eq(3)').text(totalHours);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user