2023-10-04 20:51:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Romanah\Gokbakja\Components;
|
|
|
|
|
|
|
|
|
|
use Cms\Classes\ComponentBase;
|
|
|
|
|
use Romanah\Gokbakja\Models\Production as ProductionModel;
|
|
|
|
|
use Romanah\Gokbakja\Models\PivotProduction as PivotProductionModel;
|
|
|
|
|
use Romanah\Gokbakja\Models\SewerProduction as SewerModel;
|
|
|
|
|
use Redirect;
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
|
use Flash;
|
|
|
|
|
use DB;
|
2023-10-20 21:54:07 +00:00
|
|
|
use Romanah\Gokbakja\Models\ProductionMachine;
|
|
|
|
|
use Romanah\Gokbakja\Models\PivotSewer;
|
2023-10-04 20:51:27 +00:00
|
|
|
|
|
|
|
|
class Sewer extends ComponentBase
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public $sewers;
|
|
|
|
|
|
|
|
|
|
public function componentDetails()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'name' => 'Sewer',
|
|
|
|
|
'description' => 'Sewer settings'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// public function onRun() {
|
|
|
|
|
// $this->sewers = $this->loadSewers();
|
|
|
|
|
// }
|
|
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
public function onModalSetSewer()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$data = post();
|
2023-10-04 20:51:27 +00:00
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
$sewerProd = SewerModel::where("id", $data["sewerId"])->with("employee", "pivot_sewer")->first();
|
|
|
|
|
|
|
|
|
|
$html_data = '<div class="modal-header">
|
2023-10-22 23:05:55 +00:00
|
|
|
<h5 class="modal-title" id="mySmallModalLabel">Önümçilik No #' . $sewerProd->id . ', Rulon: ' . $sewerProd->pivot_sewer[0]->amount . ' kg</h5>
|
2023-10-20 21:54:07 +00:00
|
|
|
<button type="button" class="btn-close" data-bs-dismiss="modal"
|
|
|
|
|
aria-label="Close"></button>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-body">
|
|
|
|
|
<form data-request="onUpdateSewerItem" method="POST" data-request-flash>
|
|
|
|
|
<div class="row">
|
|
|
|
|
|
|
|
|
|
<div class="col-md-12 mt-3">
|
|
|
|
|
<div>
|
|
|
|
|
<label class="form-label">Status</label>
|
|
|
|
|
|
|
|
|
|
<select class="form-control select2" name="status">
|
2023-10-22 23:05:55 +00:00
|
|
|
<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>
|
2023-10-20 21:54:07 +00:00
|
|
|
</select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-10-22 23:05:55 +00:00
|
|
|
<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" : "") . '>
|
2023-10-04 20:51:27 +00:00
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
<span class="input-group-text"><i class="mdi mdi-calendar"></i></span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-10-20 21:54:07 +00:00
|
|
|
<div class="col-md-12 mt-3">
|
|
|
|
|
<div>
|
|
|
|
|
<label class="form-label">Halta Ini</label>
|
2023-10-04 20:51:27 +00:00
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
<input type="number" name="width" step="0.01" class="form-control"
|
2023-10-22 23:05:55 +00:00
|
|
|
placeholder="Halta Ini" value="' . ($sewerProd->width == null ? 0 : $sewerProd->width) . '" ' . ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") . '>
|
2023-10-20 21:54:07 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-md-12 mt-3">
|
|
|
|
|
<div>
|
|
|
|
|
<label class="form-label">Halta Boýy</label>
|
|
|
|
|
|
|
|
|
|
<input type="number" name="height" step="0.01" class="form-control"
|
2023-10-22 23:05:55 +00:00
|
|
|
placeholder="Halta Boýy" value="' . ($sewerProd->height == null ? 0 : $sewerProd->height) . '" ' . ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") . '>
|
2023-10-20 21:54:07 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-md-12 mt-3">
|
|
|
|
|
<label class="form-label">Tikinçi</label>
|
|
|
|
|
<input type="text" name="employee" class="form-control" value="' . $sewerProd->employee->name . '" disabled>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-md-12 mt-3">
|
|
|
|
|
<div>
|
|
|
|
|
<label class="form-label">Tikilen Halta</label>
|
|
|
|
|
|
|
|
|
|
<input type="number" name="produced_bag_qty" class="form-control"
|
2023-10-22 23:05:55 +00:00
|
|
|
placeholder="tikilen halta sany" value="' . $sewerProd->produced_bag_qty . '" ' . ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") . '>
|
|
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="col-md-12 mt-3">
|
|
|
|
|
<div>
|
|
|
|
|
<label class="form-label">Galyndy (kg) </label>
|
|
|
|
|
|
|
|
|
|
<input type="number" name="left_amount" step="0.01" class="form-control"
|
2023-10-22 23:05:55 +00:00
|
|
|
placeholder="Galyndy (kg)" value="' . ($sewerProd->pivot_sewer[0]->left_amount) . '" ' . ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") . '>
|
2023-10-20 21:54:07 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="col-md-12 mt-3">
|
|
|
|
|
<div>
|
|
|
|
|
<label class="form-label">Bellik</label>
|
|
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
<input type="text" name="note" class="form-control" placeholder="Bellik" value="' . $sewerProd->note . '" ' . ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") . '>
|
2023-10-20 21:54:07 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
<input type="hidden" name="sewer_id" value="' . $data["sewerId"] . '">
|
|
|
|
|
<button type="submit" data-bs-dismiss="modal"
|
|
|
|
|
class="btn btn-primary waves-effect waves-light"
|
|
|
|
|
style="margin-top: 15px;width: 100%;">Üýtget</button>
|
|
|
|
|
</form>
|
|
|
|
|
</div>';
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'#modal-form' => $html_data,
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function onUpdateSewerItem()
|
|
|
|
|
{
|
|
|
|
|
$currentDate = Carbon::now()->timezone('UTC +05:00');
|
|
|
|
|
|
|
|
|
|
$currentDateFormat = $currentDate->format('Y-m-d');
|
|
|
|
|
|
|
|
|
|
$data = post();
|
|
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
if ($data["produced_bag_qty"] == 0) {
|
|
|
|
|
return Flash::error("Tikilen halta sanyny girizin");
|
|
|
|
|
}elseif(!$data["produced_bag_qty"] && $data["status"] == "working"){
|
2023-10-20 21:54:07 +00:00
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
$sewer = SewerModel::where("id", $data["sewer_id"])->first();
|
|
|
|
|
$pivotSewer = PivotSewer::where("sewer_production_id", $data["sewer_id"])->first();
|
2023-10-20 21:54:07 +00:00
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
$pivotSewer->status = $data["status"];
|
|
|
|
|
$pivotSewer->save();
|
2023-10-20 21:54:07 +00:00
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
if ($sewer && $pivotSewer) {
|
|
|
|
|
Flash::success("Maglumatlar Ustunlikli Üýtgedildi");
|
|
|
|
|
return Redirect::refresh();
|
|
|
|
|
} else {
|
|
|
|
|
return Flash::error("Yalnyshlyk bar!!");
|
|
|
|
|
return Redirect::refresh();
|
|
|
|
|
}
|
2023-10-20 21:54:07 +00:00
|
|
|
} else {
|
2023-10-22 23:05:55 +00:00
|
|
|
$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();
|
|
|
|
|
}
|
2023-10-20 21:54:07 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function onRender()
|
|
|
|
|
{
|
2023-10-04 20:51:27 +00:00
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
$html_data = '';
|
2023-10-04 20:51:27 +00:00
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
$sewerDatas = SewerModel::with(["employee", "machin_production.bag_size", "machin_production.bag_type", "machin_production.color", "pivot_sewer"])->orderBy('id', 'DESC')->get();
|
|
|
|
|
// dd($sewerDatas);
|
2023-10-04 20:51:27 +00:00
|
|
|
for ($x = 0; $x < count($sewerDatas); $x++) {
|
2023-10-20 21:54:07 +00:00
|
|
|
$statusTitle = '';
|
2023-10-22 23:05:55 +00:00
|
|
|
if ($sewerDatas[$x]->pivot_sewer[0]->status == "working") {
|
2023-10-20 21:54:07 +00:00
|
|
|
$statusTitle = "Işlenilýär";
|
2023-10-22 23:05:55 +00:00
|
|
|
} else {
|
2023-10-20 21:54:07 +00:00
|
|
|
$statusTitle = "Tamamlandy";
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
$dateTitle = ($sewerDatas[$x]->date == null ? "" : Carbon::parse($sewerDatas[$x]->date)->format('d.m.Y'));
|
|
|
|
|
|
|
|
|
|
|
2023-10-04 20:51:27 +00:00
|
|
|
$html_data .= '<tr>
|
2023-10-20 21:54:07 +00:00
|
|
|
<td style="font-weight: bold;">' . ($x + 1) . '</td>
|
|
|
|
|
<td style="font-weight: bold;"> #' . $sewerDatas[$x]->id . '</td>
|
|
|
|
|
<td><span class="badge badge-soft-primary"
|
2023-10-22 23:05:55 +00:00
|
|
|
style="font-size: 14px;">ini: ' . ($sewerDatas[$x]->width ?? "") . '- boyy:' . ($sewerDatas[$x]->height ?? "") . ' </span>
|
2023-10-20 21:54:07 +00:00
|
|
|
</td>
|
2023-10-22 23:05:55 +00:00
|
|
|
<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 ?? "") . '
|
2023-10-20 21:54:07 +00:00
|
|
|
</td>
|
|
|
|
|
<td><a href="#" style="font-weight: bold;">' . $sewerDatas[$x]->employee->name . '</a></td>
|
2023-10-22 23:05:55 +00:00
|
|
|
<td>' . $dateTitle . '</td>
|
2023-10-04 20:51:27 +00:00
|
|
|
<td><span class="badge badge-soft-success"
|
2023-10-20 21:54:07 +00:00
|
|
|
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>
|
|
|
|
|
<td>
|
|
|
|
|
<div style="display: flex;justify-content: center;">
|
|
|
|
|
<div style="margin-right: 10px;">
|
|
|
|
|
<a type="button" data-request="onModalSetSewer"
|
|
|
|
|
data-request-data="sewerId: ' . $sewerDatas[$x]->id . '"
|
2023-10-22 23:05:55 +00:00
|
|
|
data-bs-toggle="modal" data-bs-target=".bs-example-modal-sm-1"
|
|
|
|
|
class="btn btn-warning waves-effect waves-light"
|
2023-10-20 21:54:07 +00:00
|
|
|
style="padding-top: 5px;padding-bottom: 5px;">
|
|
|
|
|
<i class="ri-pencil-line align-middle me-2"></i> Täzele
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<a type="button"
|
|
|
|
|
class="btn btn-danger waves-effect waves-light"
|
|
|
|
|
style="padding-top: 5px;padding-bottom: 5px;">
|
|
|
|
|
<i class="ri-close-line align-middle me-2"></i> Poz
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-10-04 20:51:27 +00:00
|
|
|
</td>
|
|
|
|
|
</tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $html_data;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 21:53:59 +00:00
|
|
|
public function onReportSewer()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
$currentDate = Carbon::now()->timezone('UTC +05:00');
|
|
|
|
|
$currentDateFormat = $currentDate->format('Y-m-d');
|
|
|
|
|
|
|
|
|
|
$data = post();
|
|
|
|
|
|
|
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
$sewerProductions = SewerModel::with(["employee", "machin_production.bag_size", "machin_production.bag_type", "machin_production.color", "pivot_sewer"])->orderBy('id', 'DESC');
|
2023-10-09 21:53:59 +00:00
|
|
|
|
|
|
|
|
$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"];
|
2023-10-22 23:05:55 +00:00
|
|
|
$status = $data["status"];
|
|
|
|
|
$width = $data["width"];
|
|
|
|
|
$height = $data["height"];
|
2023-10-09 21:53:59 +00:00
|
|
|
|
|
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
|
|
|
|
|
if ($height) {
|
|
|
|
|
$sewerProductions->where("height", $height);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($width) {
|
|
|
|
|
$sewerProductions->where("width", $width);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-09 21:53:59 +00:00
|
|
|
if ($employee) {
|
|
|
|
|
$sewerProductions->where("employee_id", $employee);
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
if ($status) {
|
|
|
|
|
$sewerProductions->with("pivot_sewer")->whereHas('pivot_sewer', function ($query) use($status) {
|
|
|
|
|
$query->where('status', $status);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
if ($min) {
|
2023-10-22 23:05:55 +00:00
|
|
|
$sewerProductions->whereRaw('produced_bag_qty >' . ($min - 1));
|
2023-10-09 21:53:59 +00:00
|
|
|
}
|
|
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
if ($max) {
|
2023-10-22 23:05:55 +00:00
|
|
|
$sewerProductions->whereRaw('produced_bag_qty <' . ($max + 1));
|
2023-10-09 21:53:59 +00:00
|
|
|
}
|
|
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
|
2023-10-09 21:53:59 +00:00
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
if ($start != $currentDateFormat) {
|
2023-10-22 23:05:55 +00:00
|
|
|
$sewerProductions->whereBetween('date', [$start, $end]);
|
2023-10-09 21:53:59 +00:00
|
|
|
}
|
|
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
$sewerDatas = $sewerProductions->get();
|
|
|
|
|
|
|
|
|
|
$sewerIds = $sewerProductions->get()->pluck("id")->toArray();
|
|
|
|
|
|
2023-10-09 21:53:59 +00:00
|
|
|
$sewerProductionsSumBagQty = $sewerProductions->sum("produced_bag_qty");
|
|
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
$sewerProductionsamount = PivotSewer::whereIn("sewer_production_id", $sewerIds)->sum("spent_amount");
|
|
|
|
|
// dd($sewerProductionsamount->spentAmount);
|
2023-10-20 21:54:07 +00:00
|
|
|
$html_data = '';
|
2023-10-09 21:53:59 +00:00
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
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'));
|
|
|
|
|
|
|
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
$html_data .= '<tr>
|
|
|
|
|
<td style="font-weight: bold;">' . ($x + 1) . '</td>
|
2023-10-22 23:05:55 +00:00
|
|
|
<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> #' . $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>
|
2023-10-09 21:53:59 +00:00
|
|
|
<td><span class="badge badge-soft-success"
|
2023-10-22 23:05:55 +00:00
|
|
|
style="font-size: 14px;">' . number_format($sewerDatas[$x]->pivot_sewer[0]->amount, 2) . ' kg</span>
|
2023-10-09 21:53:59 +00:00
|
|
|
</td>
|
2023-10-22 23:05:55 +00:00
|
|
|
<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>
|
|
|
|
|
|
2023-10-09 21:53:59 +00:00
|
|
|
</tr>';
|
2023-10-20 21:54:07 +00:00
|
|
|
}
|
2023-10-09 21:53:59 +00:00
|
|
|
|
2023-10-22 23:05:55 +00:00
|
|
|
if ($sewerDatas) {
|
2023-10-20 21:54:07 +00:00
|
|
|
return [
|
|
|
|
|
'#sewer_report_datas' => $html_data,
|
|
|
|
|
'#all_amount' => '<div class="col-md-6">
|
2023-10-09 21:53:59 +00:00
|
|
|
<h3 class="card-title" style="font-size: 22px;color: #1e2038;">Tikinçiler Boýunça Umumy</h3>
|
|
|
|
|
<p class="card-title-desc" style="color: #6c6ff5;">Hasabat</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-md-3">
|
|
|
|
|
<div class="card bg-info text-white-50">
|
|
|
|
|
<div class="card-body">
|
2023-10-20 21:54:07 +00:00
|
|
|
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;"><i class="mdi mdi-bullseye-arrow me-3"></i> Jemi Dikilen Halta: ' . number_format($sewerProductionsSumBagQty) . ' sany</h5>
|
2023-10-09 21:53:59 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-md-3">
|
|
|
|
|
<div class="card bg-info text-white-50">
|
|
|
|
|
<div class="card-body">
|
2023-10-22 23:05:55 +00:00
|
|
|
<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>
|
2023-10-09 21:53:59 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>',
|
2023-10-20 21:54:07 +00:00
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
Flash::error("Yalnyshlyk bar!!");
|
|
|
|
|
}
|
2023-10-09 21:53:59 +00:00
|
|
|
}
|
2023-10-04 20:51:27 +00:00
|
|
|
|
|
|
|
|
public function onCreateSewerProduction()
|
|
|
|
|
{
|
|
|
|
|
$currentDate = Carbon::now()->timezone('UTC +05:00');
|
|
|
|
|
|
|
|
|
|
$currentDateFormat = $currentDate->format('Y-m-d');
|
|
|
|
|
|
|
|
|
|
$data = post();
|
|
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
$machineProduction = ProductionMachine::where("id", $data["machine_production_id"])->first();
|
2023-10-04 20:51:27 +00:00
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
$machineProductionSpent = PivotSewer::where("machine_production_id", $data["machine_production_id"])->sum('spent_amount');
|
2023-10-04 20:51:27 +00:00
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
$leftAmount = 0;
|
2023-10-22 23:05:55 +00:00
|
|
|
if ($machineProduction->produced_weight > $machineProductionSpent) {
|
2023-10-20 21:54:07 +00:00
|
|
|
$calcLeft = ((float) $machineProduction->produced_weight - (float) $machineProductionSpent);
|
2023-10-04 20:51:27 +00:00
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
$leftAmount = $calcLeft;
|
2023-10-22 23:05:55 +00:00
|
|
|
} elseif ($machineProduction->produced_weight == $machineProductionSpent) {
|
2023-10-20 21:54:07 +00:00
|
|
|
$leftAmount = 0;
|
2023-10-22 23:05:55 +00:00
|
|
|
} else {
|
2023-10-20 21:54:07 +00:00
|
|
|
$leftAmount = 0;
|
2023-10-04 20:51:27 +00:00
|
|
|
}
|
|
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
// dd($leftAmount);
|
2023-10-04 20:51:27 +00:00
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
$createSewer = new SewerModel();
|
|
|
|
|
$createSewer->employee_id = $data["employee_id"];
|
|
|
|
|
$createSewer->produced_bag_qty = 0;
|
|
|
|
|
$createSewer->note = $data["note"] ?? '';
|
|
|
|
|
$createSewer->machine_production_id = $data["machine_production_id"];
|
|
|
|
|
$createSewer->width = (float) $data["width"];
|
|
|
|
|
$createSewer->height = (float) $data["height"];
|
2023-10-22 23:05:55 +00:00
|
|
|
$createSewer->date = Carbon::parse($data["date"])->format('Y-m-d');
|
2023-10-20 21:54:07 +00:00
|
|
|
$createSewer->save();
|
2023-10-04 20:51:27 +00:00
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
$createPivotSewer = new PivotSewer();
|
|
|
|
|
$createPivotSewer->machine_production_id = $createSewer->machine_production_id;
|
|
|
|
|
$createPivotSewer->sewer_production_id = $createSewer->id;
|
|
|
|
|
$createPivotSewer->left_amount = 0;
|
|
|
|
|
$createPivotSewer->amount = $leftAmount;
|
|
|
|
|
$createPivotSewer->save();
|
2023-10-04 20:51:27 +00:00
|
|
|
|
|
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
if ($createSewer && $createPivotSewer) {
|
2023-10-04 20:51:27 +00:00
|
|
|
|
2023-10-20 21:54:07 +00:00
|
|
|
Flash::success("Maglumatlar Ustunlikli Goshuldy");
|
|
|
|
|
return Redirect::refresh();
|
|
|
|
|
} else {
|
|
|
|
|
return Flash::error("Yalnyshlyk bar!!");
|
|
|
|
|
return Redirect::refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-04 20:51:27 +00:00
|
|
|
}
|