From 8a041653870a558fe2108ef83f352dd8de00f959 Mon Sep 17 00:00:00 2001 From: Shohrat Date: Thu, 21 Dec 2023 01:59:14 +0500 Subject: [PATCH] production settings --- .../gokbakja/components/Production.php | 28 ++++++++++--- .../pages/production/all-production-month.htm | 42 +++++++++++-------- .../pages/production/report-production.htm | 12 +++--- themes/gokbakja/partials/report/month-row.htm | 7 ++-- .../partials/report/product-month-row.htm | 16 ++++--- themes/gokbakja/partials/report/row.htm | 12 ++++-- 6 files changed, 73 insertions(+), 44 deletions(-) diff --git a/plugins/romanah/gokbakja/components/Production.php b/plugins/romanah/gokbakja/components/Production.php index f258abd..4dcfedc 100644 --- a/plugins/romanah/gokbakja/components/Production.php +++ b/plugins/romanah/gokbakja/components/Production.php @@ -88,13 +88,12 @@ class Production extends ComponentBase if ($start != $currentDateFormat) { $productions->whereBetween('date', [$start, $end]); - $calc = $productionsCalc->select(DB::raw('MAX(time) AS max_time'), DB::raw('MIN(time) AS min_time')) - ->whereBetween('date', [$start, $end])->first(); - $diffMinutes = Carbon::parse($calc->max_time)->diffInMinutes($calc->min_time); - $calcTimeDiff = floor($diffMinutes / 60) . ' sagat ' . ($diffMinutes - floor($diffMinutes / 60) * 60) . ' minut'; - $calcq = $this->calculateHoursAndMinutes($calc->date, $calc->time); + // $diffMinutes = Carbon::parse($calc->max_time)->diffInMinutes($calc->min_time); + // $calcTimeDiff = floor($diffMinutes / 60) . ' sagat ' . ($diffMinutes - floor($diffMinutes / 60) * 60) . ' minut'; + + // $calcq = $this->calculateHoursAndMinutes($calc->date, $calc->time); // dd($calcq); @@ -114,9 +113,26 @@ class Production extends ComponentBase $pivotIds = PivotProductionModel::whereIn('production_id', $calculationAmountqq)->get()->pluck('id')->toArray(); - $calculationAmount = ProductionCalculateModel::whereIn('production_id', $calculationAmountqq)->sum("amount_calc"); + $calculationAmount = ProductionCalculateModel::whereIn('prev_pivot_id', $pivotIds)->sum("amount_calc"); + $calcHours = $productionsCalcPivot->orderBy('date', 'DESC')->orderBy('time', 'DESC')->get(); + + $calcHourCount = (count($calcHours) - 1); + + $dateStart = $calcHours[0]->date.' '.$calcHours[0]->time; + $dateEnd = $calcHours[$calcHourCount]->date.' '.$calcHours[$calcHourCount]->time; + + $carbonInstanceStart = Carbon::parse($dateStart); + $carbonInstanceEnd = Carbon::parse($dateEnd); + + $calcHourq = $carbonInstanceEnd->diffInHours($carbonInstanceStart); + + $hours = floor($calcHourq); // Get the whole hours + $minutes = ($calcHourq - $hours) * 60; + + $calcTimeDiff = $hours.' sagat '; + //dd($pivotIds); $html_data = ''; diff --git a/themes/gokbakja/pages/production/all-production-month.htm b/themes/gokbakja/pages/production/all-production-month.htm index f186d0a..bc94194 100644 --- a/themes/gokbakja/pages/production/all-production-month.htm +++ b/themes/gokbakja/pages/production/all-production-month.htm @@ -16,13 +16,13 @@ function onStart() { } if($year){ - $this["productions"] = Romanah\Gokbakja\Models\Production::whereMonth('created_at', $this["month"])->whereYear('created_at', $year)->with(['pivot_production'])->get(); + $this["productions"] = Romanah\Gokbakja\Models\Production::whereMonth('date', $this["month"])->whereYear('date', $year)->with(['pivot_production'])->get(); $this["month_all_amount_calcq"] = Romanah\Gokbakja\Models\ProductionCalculate::whereMonth('date', $this["month"])->whereYear('date', $year)->sum("amount_calc"); }else{ - $this["productions"] = Romanah\Gokbakja\Models\Production::whereMonth('created_at', $this["month"])->whereYear('created_at', $currentDate->year)->with(['pivot_production'])->get(); + $this["productions"] = Romanah\Gokbakja\Models\Production::whereMonth('date', $this["month"])->whereYear('date', $currentDate->year)->with(['pivot_production'])->get(); $this["month_all_amount_calcq"] = Romanah\Gokbakja\Models\ProductionCalculate::whereMonth('date', $this["month"])->whereYear('date', $currentDate->year)->sum("amount_calc"); @@ -109,9 +109,7 @@ function onStart() { № Senesi Hemmesi - {% for key, record in reportProducts %} - {{record.code}} - {% endfor %} + Harytlar Bellik @@ -122,16 +120,22 @@ function onStart() { {{key + 1}} {{report.created_at|date('d.m.Y | + style="font-weight: bold;color: #0005c5;">{{report.date|date('d.m.Y | H:i')}} {{report.all_amount|number_format}} kg - - {% for product in report.pivot_production %} - {{product.amount_percentage}} % - {% endfor %} + +
+ {% for product in report.pivot_production %} +
+ {{product.product_code}}: + {{product.amount_percentage}} % +
+ {% endfor %} +
+ {{report.note}} {% endfor %} @@ -145,10 +149,14 @@ function onStart() { {{month_all_amount_calcq|number_format}} kg - - {% for key, product in reportProducts %} - {% partial 'report/product-month-row' prodId=product.id all_amount=month_all_amount_calc.amount_subtraction %} - {% endfor %} + +
+ {% for key, product in reportProducts %} + {% partial 'report/product-month-row' product_code=product.code + prodId=product.id all_amount=month_all_amount_calc.amount_subtraction %} + {% endfor %} +
+ @@ -158,9 +166,7 @@ function onStart() { № Senesi Hemmesi - {% for key, record in reportProducts %} - {{record.code}} - {% endfor %} + Harytlar Bellik @@ -178,4 +184,4 @@ function onStart() { -{% partial 'dataTableJs' %} \ No newline at end of file +{% partial 'dataTableJs' %} diff --git a/themes/gokbakja/pages/production/report-production.htm b/themes/gokbakja/pages/production/report-production.htm index fa84703..b3e71d8 100644 --- a/themes/gokbakja/pages/production/report-production.htm +++ b/themes/gokbakja/pages/production/report-production.htm @@ -55,9 +55,9 @@ function onStart(){ № Aýlar Işlenen çig mal - {% for key, record in reportProducts %} - {{record.code}} - {% endfor %} + + Harytlar + Bellik @@ -85,9 +85,7 @@ function onStart(){ № Aýlar Işlenen çig mal - {% for key, record in reportProducts %} - {{record.code}} - {% endfor %} + Harytlar Bellik @@ -102,4 +100,4 @@ function onStart(){ -{% partial 'dataTableJs' %} \ No newline at end of file +{% partial 'dataTableJs' %} diff --git a/themes/gokbakja/partials/report/month-row.htm b/themes/gokbakja/partials/report/month-row.htm index 00f691f..52a9bf9 100644 --- a/themes/gokbakja/partials/report/month-row.htm +++ b/themes/gokbakja/partials/report/month-row.htm @@ -23,9 +23,8 @@ function onStart (){ } ?> == - - {% if pivot_calc > 0 %} - {{pivot_calc|number_format}} kg
+ {% if pivot_calc > 0 %} + {{product_code}}: {{pivot_calc|number_format}} kg
{% endif %} - + diff --git a/themes/gokbakja/partials/report/product-month-row.htm b/themes/gokbakja/partials/report/product-month-row.htm index f5667b6..8ed319e 100644 --- a/themes/gokbakja/partials/report/product-month-row.htm +++ b/themes/gokbakja/partials/report/product-month-row.htm @@ -26,8 +26,8 @@ function onStart (){ }else{ $amountCalc = Romanah\Gokbakja\Models\ProductionCalculate::where('product_id', $prodId) - ->whereMonth('created_at', $this["month"]) - ->whereYear('created_at', $currentDate->year) + ->whereMonth('date', $this["month"]) + ->whereYear('date', $currentDate->year) ->sum("amount_calc"); @@ -43,7 +43,11 @@ function onStart (){ } ?> == - - {{pivot_calc|number_format}} kg - +
+ + + {{product_code}}: {{pivot_calc|number_format}} kg + + +
+ diff --git a/themes/gokbakja/partials/report/row.htm b/themes/gokbakja/partials/report/row.htm index b3573b1..f503a2d 100644 --- a/themes/gokbakja/partials/report/row.htm +++ b/themes/gokbakja/partials/report/row.htm @@ -17,8 +17,14 @@ function onStart (){ {{no}} {{title}} {{all_amount_calc|number_format}} kg - {% for key, record in products %} - {% partial "report/month-row" prodId=record.id all_amount=all_amount_calc %} - {% endfor %} + +
+ {% for key, record in products %} +
+ {% partial "report/month-row" product_code=record.code prodId=record.id all_amount=all_amount_calc %} +
+ {% endfor %} +
+ {{hours}}