diff --git a/plugins/romanah/gokbakja/components/Production.php b/plugins/romanah/gokbakja/components/Production.php index c9d718c..15bded0 100644 --- a/plugins/romanah/gokbakja/components/Production.php +++ b/plugins/romanah/gokbakja/components/Production.php @@ -5,12 +5,14 @@ namespace Romanah\Gokbakja\Components; use Cms\Classes\ComponentBase; use Romanah\Gokbakja\Models\Product as ProductModel; use Romanah\Gokbakja\Models\Production as ProductionModel; +use Romanah\Gokbakja\Models\Excruiter as ExcruiterModel; use Romanah\Gokbakja\Models\ProductionMachine as ProductionMachineModel; use Romanah\Gokbakja\Models\PivotProduction as PivotProductionModel; use Redirect; use Carbon\Carbon; use Flash; use DB; +use October\Rain\Support\Facades\Flash as FacadesFlash; class Production extends ComponentBase { @@ -25,6 +27,76 @@ class Production extends ComponentBase } + public function onReportProduction() + { + + $currentDate = Carbon::now()->timezone('UTC +05:00'); + $currentDateFormat = $currentDate->format('Y-m-d'); + + $data = post(); + + + $productions = ProductionModel::with(['pivot_production', 'excruiter', 'shift'])->orderBy('id', 'DESC'); + + $start = Carbon::parse($data["start"])->format('Y-m-d'); + $end = Carbon::parse($data["end"])->format('Y-m-d'); + + $startView = Carbon::parse($data["start"])->format('d.m.Y'); + $endView = Carbon::parse($data["end"])->format('d.m.Y'); + + $excruiter = $data["excruiter_id"]; + $shiftId = $data["shift_id"]; + + + if ($excruiter) { + $productions->where("excruiter_id", $excruiter); + } + + if ($shiftId) { + $productions->where("shift_id", $shiftId); + } + + if ($start != $currentDateFormat) { + $productions->whereBetween('created_at', [$start, $end]); + } + + $productionsFiltered = $productions->get(); + + $html_data = ''; + for ($x = 0; $x < count($productionsFiltered); $x++) { + // dd($productionsFiltered[0]->shift->desc); + $html_data .= '
| # | +Smen | +Ekskruiter | +Wagty | +Jemi | + '; + for ($ii = 0; $ii < count($currentDateShifts[0]->pivot_production); $ii++) { + $html_data4 .= '' . $currentDateShifts[0]->pivot_production[$ii]->product_name . ' | '; + } + $html_data4 .= '
|---|---|---|---|---|---|
| ' . ($i + 1) . ' | +' . $currentDateShifts[$i]->shift->desc . '(' . $currentDateShifts[$i]->shift->start . ' - ' . $currentDateShifts[$i]->shift->end . ') | +' . $currentDateLastShift->excruiter->name . ' | +' . $hourCountShift . ' | +' . $allAmountShift . ' kg | '; + + + for ($x = 0; $x < count($pivotShiftLasts); $x++) { + + $calculatedPercentageShift = (float) ($pivotShiftLasts[$x]->amount_percentage / 100) * (float) $allAmountShift; + + $html_data4 .= '' . ($calculatedPercentageShift) . ' kg | '; + } + + + $html_data4 .= '
Hasabat
| № | -Aýlar | -Ortaça Işlenen | - {% for key, record in reportProducts %} +Senesi | +Smen | +Ekskruiter | +Hemmesi | + {% for key, record in records %}{{record.name}} | {% endfor %}Bellik |
|---|---|---|---|---|---|---|---|---|
| № | Senesi | +Smen | +Ekskruiter | Hemmesi | - {% for key, record in reportProducts %} + {% for key, record in records %}{{record.name}} | {% endfor %}Bellik | +