sewer insert
This commit is contained in:
parent
6967f9b66e
commit
a2aa82e934
|
|
@ -13,6 +13,7 @@ use Flash;
|
|||
// use Illuminate\Validation\Validator;
|
||||
use \Validator;
|
||||
use DB;
|
||||
use Romanah\Gokbakja\Models\PivotSewer;
|
||||
|
||||
class MachineProduction extends ComponentBase
|
||||
{
|
||||
|
|
@ -69,7 +70,11 @@ class MachineProduction extends ComponentBase
|
|||
$data = post();
|
||||
|
||||
|
||||
$machineProductions = ProductionMachineModel::select('id', 'type_id', 'size_id', 'machine_id', 'produced_weight', 'employee_id', 'mechanic_id', 'note', 'date', 'color_id', 'left_weight', 'building_name', 'employee_name', 'mechanic_name')
|
||||
$machineProductions = ProductionMachineModel::select('id', 'is_finished', 'type_id', 'size_id', 'machine_id', 'produced_weight', 'employee_id', 'mechanic_id', 'note', 'date', 'color_id', 'building_name', 'employee_name', 'mechanic_name')
|
||||
->with(['bag_type', 'bag_size', 'machine.building', 'employee', 'mechanic', 'color'])
|
||||
->orderBy('id', 'DESC');
|
||||
|
||||
$machineProductionsCalc = ProductionMachineModel::select('id', 'is_finished', 'type_id', 'size_id', 'machine_id', 'produced_weight', 'employee_id', 'mechanic_id', 'note', 'date', 'color_id', 'building_name', 'employee_name', 'mechanic_name')
|
||||
->with(['bag_type', 'bag_size', 'machine.building', 'employee', 'mechanic', 'color'])
|
||||
->orderBy('id', 'DESC');
|
||||
|
||||
|
|
@ -79,38 +84,76 @@ class MachineProduction extends ComponentBase
|
|||
$mechanic = $data["mechanic_id"];
|
||||
$size = $data["size_id"];
|
||||
$type = $data["type_id"];
|
||||
// $is_finished = $data["is_finished"];
|
||||
|
||||
|
||||
// if ($is_finished) {
|
||||
// $machineProductions->where("is_finished", (bool) $is_finished);
|
||||
// }
|
||||
|
||||
if ($machine) {
|
||||
$machineProductions->where("machine_id", $machine);
|
||||
$machineProductionsCalc->where("machine_id", $machine);
|
||||
}
|
||||
|
||||
if ($mechanic) {
|
||||
$machineProductions->where("mechanic_id", $mechanic);
|
||||
$machineProductionsCalc->where("mechanic_id", $mechanic);
|
||||
}
|
||||
|
||||
if ($size) {
|
||||
$machineProductions->where("size_id", $size);
|
||||
$machineProductionsCalc->where("size_id", $size);
|
||||
}
|
||||
|
||||
if ($type) {
|
||||
$machineProductions->where("type_id", $type);
|
||||
$machineProductionsCalc->where("type_id", $type);
|
||||
}
|
||||
|
||||
if ($start != $currentDateFormat){
|
||||
$machineProductions->whereBetween('date', [$start, $end]);
|
||||
$machineProductionsCalc->whereBetween('date', [$start, $end]);
|
||||
}
|
||||
|
||||
$machineProductionsFiltered = $machineProductions->selectRaw('produced_weight - left_weight as spent')->get();
|
||||
|
||||
|
||||
$machineProductionsFiltered = $machineProductions->withCount([
|
||||
'pivot_sewer AS leftSum' => function ($query) {
|
||||
$query->select(DB::raw("(amount - SUM(spent_amount)) as leftSum"))->where('status', 'complated');
|
||||
}
|
||||
])
|
||||
->withCount([
|
||||
'pivot_sewer AS spentSum' => function ($query) {
|
||||
$query->select(DB::raw("(SUM(spent_amount)) as spentSum"))->where('status', 'complated');
|
||||
}
|
||||
])->get();
|
||||
|
||||
|
||||
$finishedRulons = $machineProductionsCalc->where('is_finished', 1)->count();
|
||||
$leftAllRulons = (count($machineProductionsFiltered) - $finishedRulons);
|
||||
// $pivotSewersWorking = PivotSewer::select('id', 'status', 'machine_production_id')
|
||||
// ->where('status', 'working')
|
||||
// ->get()
|
||||
// ->pluck('machine_production_id')
|
||||
// ->toArray();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$machineProductionsSum = $machineProductions->sum("produced_weight");
|
||||
$machineLeftProductionsSum = $machineProductions->sum("left_weight");
|
||||
$allSpent = $machineProductionsSum - $machineLeftProductionsSum;
|
||||
$machineLeftProductionsSum = 0;
|
||||
$allSpent = 0;
|
||||
|
||||
$html_data = '';
|
||||
|
||||
for ($x = 0; $x < count($machineProductionsFiltered); $x++) {
|
||||
|
||||
|
||||
|
||||
|
||||
if($machineProductionsFiltered[$x]->date != null){
|
||||
$dateFormat = $machineProductionsFiltered[$x]->date->format("d.m.Y");
|
||||
}else{
|
||||
|
|
@ -118,11 +161,20 @@ class MachineProduction extends ComponentBase
|
|||
}
|
||||
|
||||
$spent = '<span class="badge badge-soft-warning"
|
||||
style="font-size: 14px;">' . number_format($machineProductionsFiltered[$x]->spent) . ' kg</span>';
|
||||
style="font-size: 14px;">' . number_format($machineProductionsFiltered[$x]->spentSum, 2) . ' kg</span>';
|
||||
|
||||
$left = number_format(($machineProductionsFiltered[$x]->produced_weight - $machineProductionsFiltered[$x]->spentSum),2);
|
||||
|
||||
if($left==0){
|
||||
$left='Gutardy';
|
||||
}
|
||||
|
||||
$allSpent += $machineProductionsFiltered[$x]->spentSum;
|
||||
$machineLeftProductionsSum += ($machineProductionsFiltered[$x]->produced_weight - $machineProductionsFiltered[$x]->spentSum);
|
||||
|
||||
$html_data .= '<tr>
|
||||
<td style="font-weight: bold;">' . ($x + 1) . '</td>
|
||||
<td style="font-weight: bold;"> #' . $machineProductionsFiltered[$x]->id . '</td>
|
||||
<td><a href="#" style="font-weight: bold;">' . $dateFormat . '</a></td>
|
||||
<td><a href="#" style="font-weight: bold;">' . $machineProductionsFiltered[$x]->building_name . '</a></td>
|
||||
<td>' . $machineProductionsFiltered[$x]->machine->name . '</td>
|
||||
|
|
@ -135,7 +187,7 @@ class MachineProduction extends ComponentBase
|
|||
'.$spent.'
|
||||
</td>
|
||||
<td><span class="badge badge-soft-success"
|
||||
style="font-size: 14px;">' . number_format($machineProductionsFiltered[$x]->left_weight) . ' kg</span>
|
||||
style="font-size: 14px;">' . $left .'</span>
|
||||
</td>
|
||||
|
||||
<td>' . $machineProductionsFiltered[$x]->employee_name . '</td>
|
||||
|
|
@ -151,8 +203,7 @@ class MachineProduction extends ComponentBase
|
|||
<div class="col-md-3">
|
||||
<div class="card bg-info text-white-50">
|
||||
<div class="card-body">
|
||||
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;"><i
|
||||
class="mdi mdi-bullseye-arrow me-3"></i> Rulon: '.count($machineProductionsFiltered).' </h5>
|
||||
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;">Öndürlen Rulon: '.count($machineProductionsFiltered).'<br>Ulanylan Rulon: ' .$finishedRulons.'<br>Sklatdaky: '.$leftAllRulons.'</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -160,7 +211,7 @@ class MachineProduction extends ComponentBase
|
|||
<div class="card bg-info text-white-50">
|
||||
<div class="card-body">
|
||||
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;"><i
|
||||
class="mdi mdi-bullseye-arrow me-3"></i> Öndürlen: '.number_format($machineProductionsSum).' kg</h5>
|
||||
class="mdi mdi-bullseye-arrow me-3"></i> Öndürlen: '.number_format($machineProductionsSum, 2).' kg</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -168,7 +219,7 @@ class MachineProduction extends ComponentBase
|
|||
<div class="card bg-primary text-white-50">
|
||||
<div class="card-body">
|
||||
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;"><i
|
||||
class="mdi mdi-bullseye-arrow me-3"></i> Sklatda: '.number_format($machineLeftProductionsSum).' kg</h5>
|
||||
class="mdi mdi-bullseye-arrow me-3"></i> Sklatda: '.number_format($machineLeftProductionsSum, 2).' kg</h5>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -177,7 +228,7 @@ class MachineProduction extends ComponentBase
|
|||
<div class="card bg-danger text-white-50">
|
||||
<div class="card-body">
|
||||
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;"><i
|
||||
class="mdi mdi-bullseye-arrow me-3"></i> Ulanylan: '.number_format($allSpent).' kg</h5>
|
||||
class="mdi mdi-bullseye-arrow me-3"></i> Ulanylan: '.number_format($allSpent, 2).' kg</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>',
|
||||
|
|
@ -211,7 +262,6 @@ class MachineProduction extends ComponentBase
|
|||
$createProductionMachine->note = $data["note"];
|
||||
$createProductionMachine->date = Carbon::parse($data["date"])->format('Y-m-d');
|
||||
$createProductionMachine->user_id = $user->id;
|
||||
$createProductionMachine->left_weight = $data["produced_weight"];
|
||||
$createProductionMachine->save();
|
||||
|
||||
$productionMachine = ProductionMachineModel::where('id', $createProductionMachine->id)->with(['machine.employee', 'machine.mechanic', 'machine.building'])->first();
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Sewer extends ComponentBase
|
|||
$sewerProd = SewerModel::where("id", $data["sewerId"])->with("employee", "pivot_sewer")->first();
|
||||
|
||||
$html_data = '<div class="modal-header">
|
||||
<h5 class="modal-title" id="mySmallModalLabel">Önümçilik No #' . $sewerProd->id . ', Rulon: '.$sewerProd->pivot_sewer[0]->amount.' kg</h5>
|
||||
<h5 class="modal-title" id="mySmallModalLabel">Önümçilik No #' . $sewerProd->id . ', Rulon: ' . $sewerProd->pivot_sewer[0]->amount . ' kg</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal"
|
||||
aria-label="Close"></button>
|
||||
</div>
|
||||
|
|
@ -53,18 +53,29 @@ class Sewer extends ComponentBase
|
|||
<label class="form-label">Status</label>
|
||||
|
||||
<select class="form-control select2" name="status">
|
||||
<option value="working"'. ($sewerProd->pivot_sewer[0]->status == 'working' ? "selected" : "") .'>Işlenýär</option>
|
||||
<option value="complated" '. ($sewerProd->pivot_sewer[0]->status == 'complated' ? "selected" : "") .'>Tamamlandy</option>
|
||||
<option value="working"' . ($sewerProd->pivot_sewer[0]->status == 'working' ? "selected" : "") . '>Işlenýär</option>
|
||||
<option value="complated" ' . ($sewerProd->pivot_sewer[0]->status == 'complated' ? "selected" : "") . '>Tamamlandy</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 mt-3">
|
||||
<div>
|
||||
<label class="form-label">Ugramaly Senesi</label>
|
||||
<div class="input-group" id="datepicker2">
|
||||
<input type="text" class="form-control" placeholder="d.m.Y"
|
||||
data-date-format="d.m.yyyy" data-date-container="#datepicker2" data-provide="datepicker"
|
||||
data-date-autoclose="true" name="date" value="' . (Carbon::parse($sewerProd->date)->format('d.m.Y')) . '" ' . ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") . '>
|
||||
|
||||
<span class="input-group-text"><i class="mdi mdi-calendar"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-12 mt-3">
|
||||
<div>
|
||||
<label class="form-label">Halta Ini</label>
|
||||
|
||||
<input type="number" name="width" step="0.01" class="form-control"
|
||||
placeholder="Halta Ini" value="' . ($sewerProd->width == null ? 0 : $sewerProd->width) . '" '. ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") .'>
|
||||
placeholder="Halta Ini" value="' . ($sewerProd->width == null ? 0 : $sewerProd->width) . '" ' . ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") . '>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -73,7 +84,7 @@ class Sewer extends ComponentBase
|
|||
<label class="form-label">Halta Boýy</label>
|
||||
|
||||
<input type="number" name="height" step="0.01" class="form-control"
|
||||
placeholder="Halta Boýy" value="' . ($sewerProd->height == null ? 0 : $sewerProd->height) . '" '. ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") .'>
|
||||
placeholder="Halta Boýy" value="' . ($sewerProd->height == null ? 0 : $sewerProd->height) . '" ' . ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") . '>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -87,7 +98,8 @@ class Sewer extends ComponentBase
|
|||
<label class="form-label">Tikilen Halta</label>
|
||||
|
||||
<input type="number" name="produced_bag_qty" class="form-control"
|
||||
placeholder="tikilen halta sany" value="' . $sewerProd->produced_bag_qty . '" '. ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") .'>
|
||||
placeholder="tikilen halta sany" value="' . $sewerProd->produced_bag_qty . '" ' . ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") . '>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -96,7 +108,7 @@ class Sewer extends ComponentBase
|
|||
<label class="form-label">Galyndy (kg) </label>
|
||||
|
||||
<input type="number" name="left_amount" step="0.01" class="form-control"
|
||||
placeholder="Galyndy (kg)" value="' . ($sewerProd->pivot_sewer[0]->left_amount) . '" '. ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") .'>
|
||||
placeholder="Galyndy (kg)" value="' . ($sewerProd->pivot_sewer[0]->left_amount) . '" ' . ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") . '>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -105,7 +117,7 @@ class Sewer extends ComponentBase
|
|||
<div>
|
||||
<label class="form-label">Bellik</label>
|
||||
|
||||
<input type="text" name="note" class="form-control" placeholder="Bellik" value="' . $sewerProd->note . '" '. ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") .'>
|
||||
<input type="text" name="note" class="form-control" placeholder="Bellik" value="' . $sewerProd->note . '" ' . ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") . '>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -130,35 +142,56 @@ class Sewer extends ComponentBase
|
|||
|
||||
$data = post();
|
||||
|
||||
$sewer = SewerModel::where("id", $data["sewer_id"])->first();
|
||||
$pivotSewer = PivotSewer::where("sewer_production_id", $data["sewer_id"])->first();
|
||||
if ($data["produced_bag_qty"] == 0) {
|
||||
return Flash::error("Tikilen halta sanyny girizin");
|
||||
}elseif(!$data["produced_bag_qty"] && $data["status"] == "working"){
|
||||
|
||||
$spentCalc = (float)((float) $pivotSewer->amount - (float) $data["left_amount"]);
|
||||
$sewer = SewerModel::where("id", $data["sewer_id"])->first();
|
||||
$pivotSewer = PivotSewer::where("sewer_production_id", $data["sewer_id"])->first();
|
||||
|
||||
$sewer->produced_bag_qty = (float) $data["produced_bag_qty"];
|
||||
$sewer->width = (float) $data["width"];
|
||||
$sewer->height = (float) $data["height"];
|
||||
$sewer->note = $data["note"];
|
||||
$sewer->save();
|
||||
$pivotSewer->status = $data["status"];
|
||||
$pivotSewer->save();
|
||||
|
||||
$pivotSewer->left_amount = (float) $data["left_amount"];
|
||||
$pivotSewer->spent_amount = (float) $spentCalc;
|
||||
$pivotSewer->status = $data["status"];
|
||||
$pivotSewer->save();
|
||||
|
||||
if($data["left_amount"] == 0){
|
||||
$machinProduction = ProductionMachine::where("id", $pivotSewer->machine_production_id)->first();
|
||||
$machinProduction->is_finished = true;
|
||||
$machinProduction->save();
|
||||
}
|
||||
|
||||
if ($sewer) {
|
||||
|
||||
Flash::success("Maglumatlar Ustunlikli Üýtgedildi");
|
||||
return Redirect::refresh();
|
||||
if ($sewer && $pivotSewer) {
|
||||
Flash::success("Maglumatlar Ustunlikli Üýtgedildi");
|
||||
return Redirect::refresh();
|
||||
} else {
|
||||
return Flash::error("Yalnyshlyk bar!!");
|
||||
return Redirect::refresh();
|
||||
}
|
||||
} else {
|
||||
return Flash::error("Yalnyshlyk bar!!");
|
||||
return Redirect::refresh();
|
||||
$sewer = SewerModel::where("id", $data["sewer_id"])->first();
|
||||
$pivotSewer = PivotSewer::where("sewer_production_id", $data["sewer_id"])->first();
|
||||
|
||||
$spentCalc = (float)((float) $pivotSewer->amount - (float) $data["left_amount"]);
|
||||
|
||||
$sewer->produced_bag_qty = (float) $data["produced_bag_qty"];
|
||||
$sewer->width = (float) $data["width"];
|
||||
$sewer->height = (float) $data["height"];
|
||||
$sewer->date = Carbon::parse($data["date"])->format('Y-m-d');
|
||||
$sewer->note = $data["note"];
|
||||
$sewer->save();
|
||||
|
||||
$pivotSewer->left_amount = (float) $data["left_amount"];
|
||||
$pivotSewer->spent_amount = (float) $spentCalc;
|
||||
$pivotSewer->status = $data["status"];
|
||||
$pivotSewer->save();
|
||||
|
||||
if ($data["left_amount"] == 0 && $data["status"] == "complated") {
|
||||
$machinProduction = ProductionMachine::where("id", $pivotSewer->machine_production_id)->first();
|
||||
$machinProduction->is_finished = true;
|
||||
$machinProduction->save();
|
||||
}else{
|
||||
return Flash::error("Status tamamlamaly!");
|
||||
}
|
||||
|
||||
if ($sewer && $pivotSewer) {
|
||||
Flash::success("Maglumatlar Ustunlikli Üýtgedildi");
|
||||
return Redirect::refresh();
|
||||
} else {
|
||||
return Flash::error("Yalnyshlyk bar!!");
|
||||
return Redirect::refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -171,22 +204,25 @@ class Sewer extends ComponentBase
|
|||
// dd($sewerDatas);
|
||||
for ($x = 0; $x < count($sewerDatas); $x++) {
|
||||
$statusTitle = '';
|
||||
if($sewerDatas[$x]->pivot_sewer[0]->status == "working"){
|
||||
if ($sewerDatas[$x]->pivot_sewer[0]->status == "working") {
|
||||
$statusTitle = "Işlenilýär";
|
||||
}else{
|
||||
} else {
|
||||
$statusTitle = "Tamamlandy";
|
||||
}
|
||||
|
||||
$dateTitle = ($sewerDatas[$x]->date == null ? "" : Carbon::parse($sewerDatas[$x]->date)->format('d.m.Y'));
|
||||
|
||||
|
||||
$html_data .= '<tr>
|
||||
<td style="font-weight: bold;">' . ($x + 1) . '</td>
|
||||
<td style="font-weight: bold;"> #' . $sewerDatas[$x]->id . '</td>
|
||||
<td><span class="badge badge-soft-primary"
|
||||
style="font-size: 14px;">ini: ' . ($sewerDatas[$x]->width ?? "") . '- boyy:'. ($sewerDatas[$x]->height ?? "") .' </span>
|
||||
style="font-size: 14px;">ini: ' . ($sewerDatas[$x]->width ?? "") . '- boyy:' . ($sewerDatas[$x]->height ?? "") . ' </span>
|
||||
</td>
|
||||
<td> #'.$sewerDatas[$x]->machin_production->id.'- ' . ($sewerDatas[$x]->machin_production->bag_size->width ?? "") . 'x' .($sewerDatas[$x]->machin_production->bag_size->height ?? "").'m2, '.($sewerDatas[$x]->machin_production->bag_type->name ?? "") .', '.($sewerDatas[$x]->machin_production->color->name ?? "").'
|
||||
<td> #' . $sewerDatas[$x]->machin_production->id . '- ' . ($sewerDatas[$x]->machin_production->bag_size->width ?? "") . 'x' . ($sewerDatas[$x]->machin_production->bag_size->height ?? "") . 'm2, ' . ($sewerDatas[$x]->machin_production->bag_type->name ?? "") . ', ' . ($sewerDatas[$x]->machin_production->color->name ?? "") . '
|
||||
</td>
|
||||
<td><a href="#" style="font-weight: bold;">' . $sewerDatas[$x]->employee->name . '</a></td>
|
||||
<td>' . $sewerDatas[$x]->created_at->format('d.m.Y') . '</td>
|
||||
<td>' . $dateTitle . '</td>
|
||||
<td><span class="badge badge-soft-success"
|
||||
style="font-size: 14px;">' . number_format($sewerDatas[$x]->pivot_sewer[0]->amount, 2) . ' kg</span>
|
||||
</td>
|
||||
|
|
@ -201,9 +237,8 @@ class Sewer extends ComponentBase
|
|||
<div style="margin-right: 10px;">
|
||||
<a type="button" data-request="onModalSetSewer"
|
||||
data-request-data="sewerId: ' . $sewerDatas[$x]->id . '"
|
||||
data-bs-toggle="modal" data-bs-target=".bs-example-modal-sm-1"
|
||||
class="btn btn-warning waves-effect waves-light" data-bs-toggle="offcanvas"
|
||||
data-bs-target="#offcanvasBottom" aria-controls="offcanvasBottom"
|
||||
data-bs-toggle="modal" data-bs-target=".bs-example-modal-sm-1"
|
||||
class="btn btn-warning waves-effect waves-light"
|
||||
style="padding-top: 5px;padding-bottom: 5px;">
|
||||
<i class="ri-pencil-line align-middle me-2"></i> Täzele
|
||||
</a>
|
||||
|
|
@ -232,56 +267,96 @@ class Sewer extends ComponentBase
|
|||
$data = post();
|
||||
|
||||
|
||||
$sewerProductions = SewerModel::with("employee")->orderBy('id', 'DESC');
|
||||
$sewerProductions = SewerModel::with(["employee", "machin_production.bag_size", "machin_production.bag_type", "machin_production.color", "pivot_sewer"])->orderBy('id', 'DESC');
|
||||
|
||||
$start = Carbon::parse($data["start"])->format('Y-m-d');
|
||||
$end = Carbon::parse($data["end"])->format('Y-m-d');;
|
||||
$employee = $data["employee_id"];
|
||||
$min = $data["min"];
|
||||
$max = $data["max"];
|
||||
$amount = $data["amount"];
|
||||
$status = $data["status"];
|
||||
$width = $data["width"];
|
||||
$height = $data["height"];
|
||||
|
||||
|
||||
|
||||
if ($height) {
|
||||
$sewerProductions->where("height", $height);
|
||||
}
|
||||
|
||||
if ($width) {
|
||||
$sewerProductions->where("width", $width);
|
||||
}
|
||||
|
||||
if ($employee) {
|
||||
$sewerProductions->where("employee_id", $employee);
|
||||
}
|
||||
|
||||
if ($status) {
|
||||
$sewerProductions->with("pivot_sewer")->whereHas('pivot_sewer', function ($query) use($status) {
|
||||
$query->where('status', $status);
|
||||
});
|
||||
}
|
||||
|
||||
if ($min) {
|
||||
$sewerProductions->whereRaw('produced_bag_qty >' . $min);
|
||||
$sewerProductions->whereRaw('produced_bag_qty >' . ($min - 1));
|
||||
}
|
||||
|
||||
if ($max) {
|
||||
$sewerProductions->whereRaw('produced_bag_qty <' . $max);
|
||||
$sewerProductions->whereRaw('produced_bag_qty <' . ($max + 1));
|
||||
}
|
||||
|
||||
if ($amount) {
|
||||
$sewerProductions->whereRaw('amount <=' . $amount);
|
||||
}
|
||||
|
||||
|
||||
if ($start != $currentDateFormat) {
|
||||
$sewerProductions->whereBetween('created_at', [$start, $end]);
|
||||
$sewerProductions->whereBetween('date', [$start, $end]);
|
||||
}
|
||||
|
||||
$sewerProductionsFiltered = $sewerProductions->get();
|
||||
$sewerProductionsSumBagQty = $sewerProductions->sum("produced_bag_qty");
|
||||
$sewerProductionsamount = $sewerProductions->sum("amount");
|
||||
$sewerDatas = $sewerProductions->get();
|
||||
|
||||
$sewerIds = $sewerProductions->get()->pluck("id")->toArray();
|
||||
|
||||
$sewerProductionsSumBagQty = $sewerProductions->sum("produced_bag_qty");
|
||||
|
||||
$sewerProductionsamount = PivotSewer::whereIn("sewer_production_id", $sewerIds)->sum("spent_amount");
|
||||
// dd($sewerProductionsamount->spentAmount);
|
||||
$html_data = '';
|
||||
|
||||
for ($x = 0; $x < count($sewerProductionsFiltered); $x++) {
|
||||
for ($x = 0; $x < count($sewerDatas); $x++) {
|
||||
$statusTitle = '';
|
||||
if ($sewerDatas[$x]->pivot_sewer[0]->status == "working") {
|
||||
$statusTitle = "Işlenilýär";
|
||||
} else {
|
||||
$statusTitle = "Tamamlandy";
|
||||
}
|
||||
|
||||
$dateTitle = ($sewerDatas[$x]->date == null ? "" : Carbon::parse($sewerDatas[$x]->date)->format('d.m.Y'));
|
||||
|
||||
|
||||
$html_data .= '<tr>
|
||||
<td style="font-weight: bold;">' . ($x + 1) . '</td>
|
||||
<td><a href="#" style="font-weight: bold;">' . $sewerProductionsFiltered[$x]->employee->name . '</a></td>
|
||||
<td>' . $sewerProductionsFiltered[$x]->created_at->format('d.m.Y') . '</td>
|
||||
<td><span class="badge badge-soft-success"
|
||||
style="font-size: 14px;">' . $sewerProductionsFiltered[$x]->amount . ' kg</span>
|
||||
<td style="font-weight: bold;"> #' . $sewerDatas[$x]->id . '</td>
|
||||
<td><span class="badge badge-soft-primary"
|
||||
style="font-size: 14px;">ini: ' . ($sewerDatas[$x]->width ?? "") . '- boyy:' . ($sewerDatas[$x]->height ?? "") . ' </span>
|
||||
</td>
|
||||
<td>' . $sewerProductionsFiltered[$x]->produced_bag_qty . '</td>
|
||||
<td>' . $sewerProductionsFiltered[$x]->note . '</td>
|
||||
<td> #' . $sewerDatas[$x]->machin_production->id . '- ' . ($sewerDatas[$x]->machin_production->bag_size->width ?? "") . 'x' . ($sewerDatas[$x]->machin_production->bag_size->height ?? "") . 'm2, ' . ($sewerDatas[$x]->machin_production->bag_type->name ?? "") . ', ' . ($sewerDatas[$x]->machin_production->color->name ?? "") . '
|
||||
</td>
|
||||
<td><a href="#" style="font-weight: bold;">' . $sewerDatas[$x]->employee->name . '</a></td>
|
||||
<td>' . $dateTitle . '</td>
|
||||
<td><span class="badge badge-soft-success"
|
||||
style="font-size: 14px;">' . number_format($sewerDatas[$x]->pivot_sewer[0]->amount, 2) . ' kg</span>
|
||||
</td>
|
||||
<td>' . $sewerDatas[$x]->produced_bag_qty . '</td>
|
||||
<td>' . number_format($sewerDatas[$x]->pivot_sewer[0]->spent_amount, 2) . ' kg</td>
|
||||
<td>' . number_format($sewerDatas[$x]->pivot_sewer[0]->left_amount, 2) . ' kg</td>
|
||||
<td><span class="badge badge-soft-warning"
|
||||
style="font-size: 14px;">' . $statusTitle . '</span></td>
|
||||
<td>' . $sewerDatas[$x]->note . '</td>
|
||||
|
||||
</tr>';
|
||||
}
|
||||
|
||||
if ($sewerProductionsFiltered) {
|
||||
if ($sewerDatas) {
|
||||
return [
|
||||
'#sewer_report_datas' => $html_data,
|
||||
'#all_amount' => '<div class="col-md-6">
|
||||
|
|
@ -298,7 +373,7 @@ class Sewer extends ComponentBase
|
|||
<div class="col-md-3">
|
||||
<div class="card bg-info text-white-50">
|
||||
<div class="card-body">
|
||||
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;"><i class="mdi mdi-bullseye-arrow me-3"></i> Jemi Sarp Edilen Çig mal: ' . number_format($sewerProductionsamount) . ' kg</h5>
|
||||
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;"><i class="mdi mdi-bullseye-arrow me-3"></i> Jemi Sarp Edilen Çig mal: ' . number_format($sewerProductionsamount, 2) . ' kg</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>',
|
||||
|
|
@ -321,13 +396,13 @@ class Sewer extends ComponentBase
|
|||
$machineProductionSpent = PivotSewer::where("machine_production_id", $data["machine_production_id"])->sum('spent_amount');
|
||||
|
||||
$leftAmount = 0;
|
||||
if($machineProduction->produced_weight > $machineProductionSpent){
|
||||
if ($machineProduction->produced_weight > $machineProductionSpent) {
|
||||
$calcLeft = ((float) $machineProduction->produced_weight - (float) $machineProductionSpent);
|
||||
|
||||
$leftAmount = $calcLeft;
|
||||
}elseif($machineProduction->produced_weight == $machineProductionSpent){
|
||||
} elseif ($machineProduction->produced_weight == $machineProductionSpent) {
|
||||
$leftAmount = 0;
|
||||
}else{
|
||||
} else {
|
||||
$leftAmount = 0;
|
||||
}
|
||||
|
||||
|
|
@ -340,6 +415,7 @@ class Sewer extends ComponentBase
|
|||
$createSewer->machine_production_id = $data["machine_production_id"];
|
||||
$createSewer->width = (float) $data["width"];
|
||||
$createSewer->height = (float) $data["height"];
|
||||
$createSewer->date = Carbon::parse($data["date"])->format('Y-m-d');
|
||||
$createSewer->save();
|
||||
|
||||
$createPivotSewer = new PivotSewer();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
<?php namespace Romanah\Gokbakja\Updates;
|
||||
|
||||
use Schema;
|
||||
use October\Rain\Database\Updates\Migration;
|
||||
|
||||
class BuilderTableUpdateRomanahGokbakjaProductionMachine11 extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('romanah_gokbakja_production_machine', function($table)
|
||||
{
|
||||
$table->dropColumn('left_weight');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('romanah_gokbakja_production_machine', function($table)
|
||||
{
|
||||
$table->double('left_weight', 10, 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
<?php namespace Romanah\Gokbakja\Updates;
|
||||
|
||||
use Schema;
|
||||
use October\Rain\Database\Updates\Migration;
|
||||
|
||||
class BuilderTableUpdateRomanahGokbakjaSewerProduction5 extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('romanah_gokbakja_sewer_production', function($table)
|
||||
{
|
||||
$table->date('date')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('romanah_gokbakja_sewer_production', function($table)
|
||||
{
|
||||
$table->dropColumn('date');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -273,3 +273,9 @@
|
|||
1.0.92:
|
||||
- 'Updated table romanah_gokbakja_production_machine'
|
||||
- builder_table_update_romanah_gokbakja_production_machine_10.php
|
||||
1.0.93:
|
||||
- 'Updated table romanah_gokbakja_sewer_production'
|
||||
- builder_table_update_romanah_gokbakja_sewer_production_5.php
|
||||
1.0.94:
|
||||
- 'Updated table romanah_gokbakja_production_machine'
|
||||
- builder_table_update_romanah_gokbakja_production_machine_11.php
|
||||
|
|
|
|||
|
|
@ -92,6 +92,15 @@ function onStart(){
|
|||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<!-- <div class="col">
|
||||
<label class="form-label">Gutaran Rulonlar</label>
|
||||
<select class="form-control select2" name="is_finished">
|
||||
|
||||
<option value="0">ÝOK</option>
|
||||
<option value="1">HAWA</option>
|
||||
|
||||
</select>
|
||||
</div> -->
|
||||
<div class="col">
|
||||
<div>
|
||||
<label class="form-label">Seneleri Saýlaň</label>
|
||||
|
|
@ -170,6 +179,7 @@ function onStart(){
|
|||
<thead>
|
||||
<tr>
|
||||
<th style="width: 5%;">№</th>
|
||||
<th>Kody</th>
|
||||
<th>Sene</th>
|
||||
<th>Bina No</th>
|
||||
<th>Enjam No</th>
|
||||
|
|
@ -191,6 +201,7 @@ function onStart(){
|
|||
<tfoot>
|
||||
<tr>
|
||||
<th style="width: 5%;">№</th>
|
||||
<th>Kody</th>
|
||||
<th>Sene</th>
|
||||
<th>Bina No</th>
|
||||
<th>Enjam No</th>
|
||||
|
|
|
|||
|
|
@ -17,10 +17,11 @@ function onStart(){
|
|||
$this["year"] = $currentDate->year;
|
||||
}
|
||||
|
||||
$this["all_amount_total"] = Romanah\Gokbakja\Models\SewerProduction::whereYear('created_at', $this["year"])
|
||||
->sum('amount');
|
||||
$sewerIds = Romanah\Gokbakja\Models\SewerProduction::whereYear('date', $this["year"])->get()->pluck("id")->toArray();
|
||||
|
||||
$this["all_bag_qty_total"] = Romanah\Gokbakja\Models\SewerProduction::whereYear('created_at', $this["year"])
|
||||
$this["all_amount_total"] = Romanah\Gokbakja\Models\PivotSewer::whereIn("sewer_production_id", $sewerIds)->sum("spent_amount");
|
||||
|
||||
$this["all_bag_qty_total"] = Romanah\Gokbakja\Models\SewerProduction::whereYear('date', $this["year"])
|
||||
->sum('produced_bag_qty');
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ function onStart(){
|
|||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-3">
|
||||
<div class="col">
|
||||
<label class="form-label">Tikinçi Saýlaň</label>
|
||||
<select class="form-control select2" name="employee_id">
|
||||
<option value="0">Saýla</option>
|
||||
|
|
@ -62,6 +62,16 @@ function onStart(){
|
|||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
<label class="form-label">Sene</label>
|
||||
<div class="input-group" id="datepicker2">
|
||||
<input type="text" class="form-control" name="date" placeholder="Sene"
|
||||
data-date-format="d.m.yyyy" data-date-container='#datepicker2' data-provide="datepicker"
|
||||
data-date-autoclose="true">
|
||||
|
||||
<span class="input-group-text"><i class="mdi mdi-calendar"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3">
|
||||
<label class="form-label">Rulon Saýlaň</label>
|
||||
<select class="form-control select2" name="machine_production_id">
|
||||
|
|
@ -212,6 +222,7 @@ function onStart(){
|
|||
</div>
|
||||
|
||||
{% put scripts %}
|
||||
<script src="{{'assets/libs/bootstrap-datepicker/js/bootstrap-datepicker.min.js'|theme}}"></script>
|
||||
<script src="{{'assets/libs/select2/js/select2.min.js'|theme}}"></script>
|
||||
<script src="{{'assets/js/pages/form-advanced.init.js'|theme}}"></script>
|
||||
{% endput %}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ function onStart(){
|
|||
|
||||
$this["sewers"] = Romanah\Gokbakja\Models\Employee::where("status", 1)->where("is_sewer", 1)->get();
|
||||
|
||||
$this["widths"] = Romanah\Gokbakja\Models\SewerProduction::groupBy("width")->get();
|
||||
$this["heights"] = Romanah\Gokbakja\Models\SewerProduction::groupBy("height")->get();
|
||||
|
||||
}
|
||||
?>
|
||||
==
|
||||
|
|
@ -32,6 +35,37 @@ function onStart(){
|
|||
<div class="card-body">
|
||||
<form data-request="onReportSewer" data-request-flash>
|
||||
<div class="row">
|
||||
|
||||
<div class="col">
|
||||
<label class="form-label">Tikinçi Saýlaň</label>
|
||||
<select class="form-control select2" name="employee_id">
|
||||
<option value="0">Saýla</option>
|
||||
{% for sewer in sewers %}
|
||||
<option value="{{sewer.id}}">{{sewer.name}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
<label class="form-label">Halta Ini</label>
|
||||
<select class="form-control select2" name="width">
|
||||
<option value="0">Saýla</option>
|
||||
{% for width in widths %}
|
||||
<option value="{{width.width}}">{{width.width}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
<label class="form-label">Halta Boyy</label>
|
||||
<select class="form-control select2" name="height">
|
||||
<option value="0">Saýla</option>
|
||||
{% for height in heights %}
|
||||
<option value="{{height.height}}">{{height.height}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
<div>
|
||||
<label class="form-label">Seneleri Saýlaň</label>
|
||||
|
|
@ -47,12 +81,13 @@ function onStart(){
|
|||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label class="form-label">Tikinçi Saýlaň</label>
|
||||
<select class="form-control select2" name="employee_id">
|
||||
<label class="form-label">Status Saýlaň</label>
|
||||
<select class="form-control select2" name="status">
|
||||
<option value="0">Saýla</option>
|
||||
{% for sewer in sewers %}
|
||||
<option value="{{sewer.id}}">{{sewer.name}}</option>
|
||||
{% endfor %}
|
||||
|
||||
<option value="working">Işlenilýär</option>
|
||||
<option value="complated">Tamamlandy</option>
|
||||
|
||||
</select>
|
||||
</div>
|
||||
<div class="col">
|
||||
|
|
@ -64,10 +99,7 @@ function onStart(){
|
|||
<input name="max" class="form-control" placeholder="Maximum Halta San">
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
<label class="form-label">Sarp edilen çig mal (kg)</label>
|
||||
<input name="amount" class="form-control" placeholder="Sarp edilen çig mal (kg)">
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="col">
|
||||
|
|
@ -105,10 +137,16 @@ function onStart(){
|
|||
<thead>
|
||||
<tr>
|
||||
<th style="width: 5%;">№</th>
|
||||
<th>Önümçilik No</th>
|
||||
<th>Halta Görnüş</th>
|
||||
<th>Rulon Görnüş</th>
|
||||
<th>Tikinçi</th>
|
||||
<th>Senesi</th>
|
||||
<th>Çig mal mukdary</th>
|
||||
<th>Tikilen Halta</th>
|
||||
<th>Ulanylan</th>
|
||||
<th>Galyndy</th>
|
||||
<th>Status</th>
|
||||
<th>Bellik</th>
|
||||
<!-- <th>Настройки</th> -->
|
||||
</tr>
|
||||
|
|
@ -120,10 +158,16 @@ function onStart(){
|
|||
<tfoot>
|
||||
<tr>
|
||||
<th style="width: 5%;">№</th>
|
||||
<th>Önümçilik No</th>
|
||||
<th>Halta Görnüş</th>
|
||||
<th>Rulon Görnüş</th>
|
||||
<th>Tikinçi</th>
|
||||
<th>Senesi</th>
|
||||
<th>Çig mal mukdary</th>
|
||||
<th>Tikilen Halta</th>
|
||||
<th>Ulanylan</th>
|
||||
<th>Galyndy</th>
|
||||
<th>Status</th>
|
||||
<th>Bellik</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
|
|
|||
|
|
@ -5,12 +5,14 @@ function onStart (){
|
|||
$no = $this->no;
|
||||
$year = $this->year;
|
||||
|
||||
$this["all_amount"] = Romanah\Gokbakja\Models\SewerProduction::whereMonth('created_at', $no)
|
||||
->whereYear('created_at', $year)
|
||||
->sum('amount');
|
||||
|
||||
$this["all_bag_qty"] = Romanah\Gokbakja\Models\SewerProduction::whereMonth('created_at', $no)
|
||||
->whereYear('created_at', $year)
|
||||
$sewerIds = Romanah\Gokbakja\Models\SewerProduction::whereMonth('date', $no)->whereYear('date', $year)->get()->pluck("id")->toArray();
|
||||
|
||||
$this["all_amount"] = Romanah\Gokbakja\Models\PivotSewer::whereIn("sewer_production_id", $sewerIds)->sum("spent_amount");
|
||||
|
||||
|
||||
$this["all_bag_qty"] = Romanah\Gokbakja\Models\SewerProduction::whereMonth('date', $no)
|
||||
->whereYear('date', $year)
|
||||
->sum('produced_bag_qty');
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue