From a26469f63da7705e9286fbbc29f664bc4783cb7d Mon Sep 17 00:00:00 2001 From: Shohrat Date: Mon, 30 Oct 2023 00:54:41 +0500 Subject: [PATCH] softDelete relations --- .../gokbakja/components/MachineProduction.php | 203 +++++++++++++----- .../gokbakja/components/Production.php | 20 +- plugins/romanah/gokbakja/models/Order.php | 6 +- .../gokbakja/models/PivotProduction.php | 5 +- .../romanah/gokbakja/models/Production.php | 4 +- .../gokbakja/models/ProductionMachine.php | 6 +- .../gokbakja/models/SewerProduction.php | 3 +- themes/gokbakja/meta/menus/aside.yaml | 10 +- themes/gokbakja/pages/machine/machine.htm | 2 + .../gokbakja/pages/production/production.htm | 3 + 10 files changed, 178 insertions(+), 84 deletions(-) diff --git a/plugins/romanah/gokbakja/components/MachineProduction.php b/plugins/romanah/gokbakja/components/MachineProduction.php index 2d64a84..a4786a7 100644 --- a/plugins/romanah/gokbakja/components/MachineProduction.php +++ b/plugins/romanah/gokbakja/components/MachineProduction.php @@ -39,8 +39,13 @@ class MachineProduction extends ComponentBase $allSpent = 0; $allLeft = 0; - $html_data = ''; + $html_data .= ''; + } + + + + return [ + '#modal-form' => $html_data, + ]; + } + + public function onSetFormUpdate() + { + $data = post(); + $machinProdId = $data["machineProdId"]; + + $production = ProductionMachineModel::where("id", $machinProdId)->first(); + + $html_data = ' + '; return [ '#modal-form' => $html_data, @@ -113,7 +199,7 @@ class MachineProduction extends ComponentBase ' . ($x + 1) . ' #Rulon' . ($machineProductions[$x]->id) . ' + data-bs-toggle="modal" data-bs-target=".bs-example-modal-lg" style="color: darkblue;"> #Rulon' . ($machineProductions[$x]->id) . ' ' . ($machineProductions[$x]->date == null ? "" : Carbon::parse($machineProductions[$x]->date)->format('d.m.Y')) . ' ' . $machineProductions[$x]->building_name . ' ' . $machineProductions[$x]->machine->name . ' @@ -126,6 +212,7 @@ class MachineProduction extends ComponentBase ' . $machineProductions[$x]->employee_name . ' ' . $machineProductions[$x]->mechanic_name . ' ' . $machineProductions[$x]->note . ' + ÜÝTGET '; } @@ -142,12 +229,12 @@ class MachineProduction extends ComponentBase $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'); + ->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'); + ->with(['bag_type', 'bag_size', 'machine.building', 'employee', 'mechanic', 'color']) + ->orderBy('id', 'DESC'); $start = Carbon::parse($data["start"])->format('Y-m-d'); $end = Carbon::parse($data["end"])->format('Y-m-d'); @@ -182,7 +269,7 @@ class MachineProduction extends ComponentBase $machineProductionsCalc->where("type_id", $type); } - if ($start != $currentDateFormat){ + if ($start != $currentDateFormat) { $machineProductions->whereBetween('date', [$start, $end]); $machineProductionsCalc->whereBetween('date', [$start, $end]); } @@ -193,8 +280,8 @@ class MachineProduction extends ComponentBase 'pivot_sewer AS leftSum' => function ($query) { $query->select(DB::raw("(amount - SUM(spent_amount)) as leftSum"))->where('status', 'complated'); } - ]) - ->withCount([ + ]) + ->withCount([ 'pivot_sewer AS spentSum' => function ($query) { $query->select(DB::raw("(SUM(spent_amount)) as spentSum"))->where('status', 'complated'); } @@ -218,32 +305,32 @@ class MachineProduction extends ComponentBase $machineLeftProductionsSum = 0; $allSpent = 0; - $html_data = ''; + $html_data = ''; - for ($x = 0; $x < count($machineProductionsFiltered); $x++) { + for ($x = 0; $x < count($machineProductionsFiltered); $x++) { - if($machineProductionsFiltered[$x]->date != null){ - $dateFormat = $machineProductionsFiltered[$x]->date->format("d.m.Y"); - }else{ - $dateFormat = ""; - } + if ($machineProductionsFiltered[$x]->date != null) { + $dateFormat = $machineProductionsFiltered[$x]->date->format("d.m.Y"); + } else { + $dateFormat = ""; + } - $spent = 'spentSum, 2) . ' kg'; - $left = number_format(($machineProductionsFiltered[$x]->produced_weight - $machineProductionsFiltered[$x]->spentSum),2); + $left = number_format(($machineProductionsFiltered[$x]->produced_weight - $machineProductionsFiltered[$x]->spentSum), 2); - if($left==0){ - $left='Gutardy'; - } + if ($left == 0) { + $left = 'Gutardy'; + } - $allSpent += $machineProductionsFiltered[$x]->spentSum; - $machineLeftProductionsSum += ($machineProductionsFiltered[$x]->produced_weight - $machineProductionsFiltered[$x]->spentSum); + $allSpent += $machineProductionsFiltered[$x]->spentSum; + $machineLeftProductionsSum += ($machineProductionsFiltered[$x]->produced_weight - $machineProductionsFiltered[$x]->spentSum); - $html_data .= ' + $html_data .= ' ' . ($x + 1) . ' ' . number_format($machineProductionsFiltered[$x]->produced_weight) . ' kg - '.$spent.' + ' . $spent . ' ' . $left .' + style="font-size: 14px;">' . $left . ' ' . $machineProductionsFiltered[$x]->employee_name . ' ' . $machineProductionsFiltered[$x]->mechanic_name . ' ' . $machineProductionsFiltered[$x]->note . ' '; - } + } - if ($machineProductionsFiltered) { - return [ - '#machine_report_datas' => $html_data, - '#all_amount' => ' + if ($machineProductionsFiltered) { + return [ + '#machine_report_datas' => $html_data, + '#all_amount' => '
-
Öndürlen Rulon: '.count($machineProductionsFiltered).'
Ulanylan Rulon: ' .$finishedRulons.'
Sklatdaky: '.$leftAllRulons.'
+
Öndürlen Rulon: ' . count($machineProductionsFiltered) . '
Ulanylan Rulon: ' . $finishedRulons . '
Sklatdaky: ' . $leftAllRulons . '
@@ -284,7 +371,7 @@ class MachineProduction extends ComponentBase
Öndürlen: '.number_format($machineProductionsSum, 2).' kg
+ class="mdi mdi-bullseye-arrow me-3"> Öndürlen: ' . number_format($machineProductionsSum, 2) . ' kg
@@ -292,7 +379,7 @@ class MachineProduction extends ComponentBase
Sklatda: '.number_format($machineLeftProductionsSum, 2).' kg
+ class="mdi mdi-bullseye-arrow me-3"> Sklatda: ' . number_format($machineLeftProductionsSum, 2) . ' kg
@@ -301,16 +388,14 @@ class MachineProduction extends ComponentBase
Ulanylan: '.number_format($allSpent, 2).' kg
+ class="mdi mdi-bullseye-arrow me-3"> Ulanylan: ' . number_format($allSpent, 2) . ' kg
', - ]; - } else { - Flash::error("Yalnyshlyk bar!!"); - } - - + ]; + } else { + Flash::error("Yalnyshlyk bar!!"); + } } public function onCreateMachineProduction() diff --git a/plugins/romanah/gokbakja/components/Production.php b/plugins/romanah/gokbakja/components/Production.php index 508a6c3..f0936cc 100644 --- a/plugins/romanah/gokbakja/components/Production.php +++ b/plugins/romanah/gokbakja/components/Production.php @@ -609,18 +609,18 @@ class Production extends ComponentBase return ActionModel::where('id', $id)->first(); } - // public function onDeleteProduction() - // { - // $id = post('id'); + public function onDeleteProduction() + { + $id = post('id'); - // $item = ActionModel::Find($id); - // $item->delete(); + $item = ProductionModel::Find($id); + $item->delete(); - // if ($item) { - // Flash::success("Action Ustunlikli Pozuldy"); - // return Redirect::refresh(); - // } - // } + if ($item) { + Flash::success("Hasabat Ustunlikli Pozuldy"); + return Redirect::refresh(); + } + } diff --git a/plugins/romanah/gokbakja/models/Order.php b/plugins/romanah/gokbakja/models/Order.php index e6700f0..4c7d844 100644 --- a/plugins/romanah/gokbakja/models/Order.php +++ b/plugins/romanah/gokbakja/models/Order.php @@ -27,11 +27,13 @@ class Order extends Model public $hasMany = [ 'order_items' => [ 'Romanah\Gokbakja\Models\OrderItem', - 'key' => 'order_id' + 'key' => 'order_id', + 'softDelete' => true ], 'payment' => [ 'Romanah\Gokbakja\Models\Payment', - 'key' => 'order_id' + 'key' => 'order_id', + 'softDelete' => true ], ]; diff --git a/plugins/romanah/gokbakja/models/PivotProduction.php b/plugins/romanah/gokbakja/models/PivotProduction.php index 43899ec..90d266b 100644 --- a/plugins/romanah/gokbakja/models/PivotProduction.php +++ b/plugins/romanah/gokbakja/models/PivotProduction.php @@ -16,15 +16,14 @@ class PivotProduction extends Model public $hasMany = [ 'pivot_production_calculate' => [ 'Romanah\Gokbakja\Models\ProductionCalculate', - 'key' => 'prev_pivot_id', - 'delete' => true + 'key' => 'prev_pivot_id' ] ]; public $belongsTo = [ 'production' => [ 'Romanah\Gokbakja\Models\Production', - 'key' => 'production_id' + 'key' => 'production_id', ], 'product' => [ 'Romanah\Gokbakja\Models\Product', diff --git a/plugins/romanah/gokbakja/models/Production.php b/plugins/romanah/gokbakja/models/Production.php index 1bd794a..aefddd8 100644 --- a/plugins/romanah/gokbakja/models/Production.php +++ b/plugins/romanah/gokbakja/models/Production.php @@ -18,12 +18,12 @@ class Production extends Model 'pivot_production' => [ 'Romanah\Gokbakja\Models\PivotProduction', 'key' => 'production_id', - 'delete' => true + 'softDelete' => true ], 'pivot_production_calculation' => [ 'Romanah\Gokbakja\Models\ProductionCalculate', 'key' => 'production_id', - 'delete' => true + 'softDelete' => true ] ]; diff --git a/plugins/romanah/gokbakja/models/ProductionMachine.php b/plugins/romanah/gokbakja/models/ProductionMachine.php index a49fdf3..8261115 100644 --- a/plugins/romanah/gokbakja/models/ProductionMachine.php +++ b/plugins/romanah/gokbakja/models/ProductionMachine.php @@ -16,11 +16,13 @@ class ProductionMachine extends Model public $hasMany = [ 'sewer_productions' => [ 'Romanah\Gokbakja\Models\SewerProduction', - 'key' => 'machine_production_id' + 'key' => 'machine_production_id', + 'softDelete' => true ], 'pivot_sewer' => [ 'Romanah\Gokbakja\Models\PivotSewer', - 'key' => 'machine_production_id' + 'key' => 'machine_production_id', + 'softDelete' => true ], ]; diff --git a/plugins/romanah/gokbakja/models/SewerProduction.php b/plugins/romanah/gokbakja/models/SewerProduction.php index 04f8165..40708ea 100644 --- a/plugins/romanah/gokbakja/models/SewerProduction.php +++ b/plugins/romanah/gokbakja/models/SewerProduction.php @@ -16,7 +16,8 @@ class SewerProduction extends Model public $hasMany = [ 'pivot_sewer' => [ 'Romanah\Gokbakja\Models\PivotSewer', - 'key' => 'sewer_production_id' + 'key' => 'sewer_production_id', + 'softDelete' => true ], ]; diff --git a/themes/gokbakja/meta/menus/aside.yaml b/themes/gokbakja/meta/menus/aside.yaml index eb4700c..78539ba 100644 --- a/themes/gokbakja/meta/menus/aside.yaml +++ b/themes/gokbakja/meta/menus/aside.yaml @@ -79,14 +79,10 @@ items: cssClass: '' isExternal: '0' - - title: 'Çig mallar boýunça' - nesting: null + title: 'Ekstrudor boýunça' type: url url: /w code: '' - reference: null - cmsPage: null - replace: null viewBag: isHidden: '0' cssClass: ri-stack-line @@ -146,9 +142,13 @@ items: isExternal: '0' - title: 'Rulonlar Boýunça' + nesting: null type: url url: /ee code: '' + reference: null + cmsPage: null + replace: null viewBag: isHidden: '0' cssClass: 'ri-bar-chart-2-line ' diff --git a/themes/gokbakja/pages/machine/machine.htm b/themes/gokbakja/pages/machine/machine.htm index 5c3672f..316d5e3 100644 --- a/themes/gokbakja/pages/machine/machine.htm +++ b/themes/gokbakja/pages/machine/machine.htm @@ -187,6 +187,7 @@ pageNumber = "{{ :page }}" Ady Familiýasy Mehanik Bellik + Sazlama @@ -207,6 +208,7 @@ pageNumber = "{{ :page }}" Ady Familiýasy Mehanik Bellik + Sazlama diff --git a/themes/gokbakja/pages/production/production.htm b/themes/gokbakja/pages/production/production.htm index de71ec4..3033bd9 100644 --- a/themes/gokbakja/pages/production/production.htm +++ b/themes/gokbakja/pages/production/production.htm @@ -185,6 +185,7 @@ function onStart(){ {{record.name}} {% endfor %} Bellik + Sazlama @@ -241,6 +242,7 @@ function onStart(){ {% endfor %} {{report.note}} +
POZ @@ -260,6 +262,7 @@ function onStart(){ {{record.name}} {% endfor %} Bellik + Sazlama