From c656a5b6c8302913e03e921c75c89466575eb777 Mon Sep 17 00:00:00 2001 From: Shohrat Date: Wed, 6 Dec 2023 01:37:39 +0500 Subject: [PATCH] acception settings --- .../gokbakja/components/MachineProduction.php | 206 ++++++++++-------- themes/gokbakja/pages/actions/bag.htm | 13 +- themes/gokbakja/pages/actions/rulon.htm | 15 +- themes/gokbakja/pages/produced/bagstock.htm | 8 +- themes/gokbakja/pages/produced/rulonstock.htm | 8 +- themes/gokbakja/pages/product/actions.htm | 12 +- themes/gokbakja/pages/product/stock.htm | 4 +- 7 files changed, 152 insertions(+), 114 deletions(-) diff --git a/plugins/romanah/gokbakja/components/MachineProduction.php b/plugins/romanah/gokbakja/components/MachineProduction.php index b333d9c..b13f680 100644 --- a/plugins/romanah/gokbakja/components/MachineProduction.php +++ b/plugins/romanah/gokbakja/components/MachineProduction.php @@ -11,7 +11,8 @@ use Redirect; use Carbon\Carbon; use Flash; // use Illuminate\Validation\Validator; -use \Validator; +use Validator; +use ValidationException; use DB; use Romanah\Gokbakja\Models\BagColor; use Romanah\Gokbakja\Models\BagSize; @@ -39,7 +40,7 @@ class MachineProduction extends ComponentBase $data = post(); $machinProdId = $data["machineProdId"]; - $productions = PivotSewer::whereHas("rulon_action", function($q) use($machinProdId){ + $productions = PivotSewer::whereHas("rulon_action", function ($q) use ($machinProdId) { $q->where('product_id', $machinProdId); })->with(["sewer_production", "rulon_action.product"])->get(); @@ -51,7 +52,7 @@ class MachineProduction extends ComponentBase //dd(count($productions)); - if (count($productions) > 0){ + if (count($productions) > 0) { $html_data = ''; - }else{ + } else { $html_data = '
- user_id != $user->id ? 'disabled' : '') . '> '; - for ($x = 0; $x < count($machines); $x++) { - $html_data .=''; - } + for ($x = 0; $x < count($machines); $x++) { + $html_data .= ''; + } - $html_data .=' + $html_data .= '
- user_id != $user->id ? 'disabled' : '') . '> - - + +
- user_id != $user->id ? 'disabled' : '') .'> + user_id != $user->id ? 'disabled' : '') . '>
- user_id != $user->id ? 'disabled' : '') . '> '; - for ($x = 0; $x < count($types); $x++) { - $html_data .=''; - } - $html_data .=' + for ($x = 0; $x < count($types); $x++) { + $html_data .= ''; + } + $html_data .= '
user_id != $user->id ? 'disabled' : '') .'> + placeholder="Ini" value="' . ($production->width ?? "") . '" ' . ($production->user_id != $user->id ? 'disabled' : '') . '>
user_id != $user->id ? 'disabled' : '') .'> + placeholder="Gram" value="' . ($production->gram ?? "") . '" ' . ($production->user_id != $user->id ? 'disabled' : '') . '>
- user_id != $user->id ? 'disabled' : '') . '> '; - for ($x = 0; $x < count($colors); $x++) { - $html_data .=''; - } - $html_data .=' + for ($x = 0; $x < count($colors); $x++) { + $html_data .= ''; + } + $html_data .= '
user_id != $user->id ? 'disabled' : '') .'> + placeholder="Mukdar (kg)" value="' . ($production->produced_weight ?? "") . '" ' . ($production->user_id != $user->id ? 'disabled' : '') . '>
user_id != $user->id ? 'disabled' : '') .'> + placeholder="Brutto (kg)" value="' . ($production->brutto_kg ?? "") . '" ' . ($production->user_id != $user->id ? 'disabled' : '') . '>
user_id != $user->id ? 'disabled' : '') .'> + placeholder="Othod (kg)" value="' . ($production->defective_weight ?? "") . '" ' . ($production->user_id != $user->id ? 'disabled' : '') . '>
- user_id != $user->id ? 'disabled' : '') .'> + user_id != $user->id ? 'disabled' : '') . '>
- +
-
@@ -241,7 +242,8 @@ class MachineProduction extends ComponentBase ]; } - public function onDeleteProductionMachine(){ + public function onDeleteProductionMachine() + { $id = post('production_id'); $productionDelete = ProductionMachineModel::Find($id); @@ -276,19 +278,17 @@ class MachineProduction extends ComponentBase $editBtn = ''; - if($machineProductions[$x]->user_id != $user->id){ + if ($machineProductions[$x]->user_id != $user->id) { $editBtn = ' Size degişli däl '; - }else{ - if(!$inStock){ + } else { + if (!$inStock) { - $editBtn = $crudProductionRulonq ? '   ' : ''; + $editBtn = $crudProductionRulonq ? '   ' : ''; - $editBtn .= $inboxProductionRulonq ? '' : ''; - - }else{ + $editBtn .= $inboxProductionRulonq ? '' : ''; + } else { $editBtn = ' Sklada salyndy '; - } } // dd($machineProductions[0]->bag_size); @@ -298,12 +298,12 @@ class MachineProduction extends ComponentBase data-request-data="machineProdId: ' . $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]->shift->desc ?? ''). ' + ' . ($machineProductions[$x]->shift->desc ?? '') . ' ' . $machineProductions[$x]->machine->name . ' ' . $machineProductions[$x]->width . ' ' . $machineProductions[$x]->gram . ' m2 ' . $machineProductions[$x]->bag_type->name . ' - ' . ($machineProductions[$x]->color->name ?? "") . ', '. $machineProductions[$x]->layer .' gat + ' . ($machineProductions[$x]->color->name ?? "") . ', ' . $machineProductions[$x]->layer . ' gat ' . number_format($machineProductions[$x]->produced_weight, 2) . ' kg @@ -318,7 +318,7 @@ class MachineProduction extends ComponentBase ' . $machineProductions[$x]->employee_name . ' ' . $machineProductions[$x]->note . ' - '. $editBtn.' + ' . $editBtn . ' '; } @@ -425,7 +425,7 @@ class MachineProduction extends ComponentBase ' . $machineProductionsFiltered[$x]->width . ' ' . $machineProductionsFiltered[$x]->gram . ' m2 ' . $machineProductionsFiltered[$x]->bag_type->name . ' - ' . ($machineProductionsFiltered[$x]->color->name ?? "") . ', '. $machineProductionsFiltered[$x]->layer .' gat + ' . ($machineProductionsFiltered[$x]->color->name ?? "") . ', ' . $machineProductionsFiltered[$x]->layer . ' gat ' . number_format($machineProductionsFiltered[$x]->produced_weight, 2) . ' kg @@ -450,7 +450,7 @@ class MachineProduction extends ComponentBase
-
Öndürlen Rulon: ' . count($machineProductionsFiltered) .'
+
Öndürlen Rulon: ' . count($machineProductionsFiltered) . '
@@ -485,22 +485,23 @@ class MachineProduction extends ComponentBase } - public function onUpdateMachineProduction(){ + public function onUpdateMachineProduction() + { $user = \Auth::user(); $data = post(); $oldData = ProductionMachineModel::where("id", $data["production_id"]) - ->with(['bag_type', 'bag_size', 'machine.building', 'employee', 'mechanic', 'color']) - ->first(); + ->with(['bag_type', 'bag_size', 'machine.building', 'employee', 'mechanic', 'color']) + ->first(); $updateProductionMachine = ProductionMachineModel::where("id", $data["production_id"]) - ->with(['bag_type', 'bag_size', 'machine.building', 'employee', 'mechanic', 'color']) - ->first(); + ->with(['bag_type', 'bag_size', 'machine.building', 'employee', 'mechanic', 'color']) + ->first(); $metrOfRulon = (float)((float)($data["gram"] / 100) * ($data["width"] / 100)) * (int)$data["layer"]; @@ -544,7 +545,16 @@ class MachineProduction extends ComponentBase Flash::error("Yalnyshlyk bar!!"); return Redirect::refresh(); } + } + + protected function validateForm($data, $rules) + { + $validator = Validator::make($data, $rules); + + if ($validator->fails()) { + throw new ValidationException($validator); + } } public function onCreateMachineProduction() @@ -553,53 +563,75 @@ class MachineProduction extends ComponentBase $data = post(); + if (empty($data["produced_weight"]) || $data["type_id"] == 0 || $data["machine_id"] == 0) { Flash::error("Gutulary Dolduryn!"); return [ '#validationq' => ' Gutulary Dolduryn!', ]; } else { - $createProductionMachine = new ProductionMachineModel(); + $dateq = Carbon::parse($data["date"])->format('Y-m-d'); + $bruttoq = $data["brutto_kg"]; + $layerq = $data["layer"]; + $produced_weightq = $data["produced_weight"]; + $machineq = $data["machine_id"]; - $metrOfRulon = (float)((float)($data["gram"] / 100) * ($data["width"] / 100)) * (int)$data["layer"]; - $metrOfAllRulon = (float) $data["produced_weight"] / $metrOfRulon; + $rulonq = ProductionMachineModel::where('produced_weight', $produced_weightq) + ->where('brutto_kg', $bruttoq) + ->where('layer', $layerq) + ->where('machine_id', $machineq) + ->where('date', $dateq) + ->first(); - $createProductionMachine->type_id = $data["type_id"]; - $createProductionMachine->width = $data["width"]; - $createProductionMachine->gram = $data["gram"]; - $createProductionMachine->brutto_kg = $data["brutto_kg"]; - $createProductionMachine->layer = $data["layer"]; - $createProductionMachine->machine_id = $data["machine_id"]; - $createProductionMachine->shift_id = $data["shift_id"]; - $createProductionMachine->color_id = $data["color_id"]; - $createProductionMachine->produced_weight = $data["produced_weight"]; - $createProductionMachine->produced_length = $metrOfAllRulon; - $createProductionMachine->defective_weight = $data["defective_weight"]; - $createProductionMachine->employee_name = $data["employee_name"]; - $createProductionMachine->mechanic_name = $data["employee_name"]; - $createProductionMachine->note = $data["note"]; - $createProductionMachine->date = Carbon::parse($data["date"])->format('Y-m-d'); - $createProductionMachine->user_id = $user->id; - $createProductionMachine->save(); + if ($rulonq) { - $productionMachine = ProductionMachineModel::where('id', $createProductionMachine->id)->with(['machine.employee', 'machine.mechanic', 'machine.building'])->first(); - // dd($productionMachine->machine->name); - if ($productionMachine) { - $updateResult = ProductionMachineModel::where('id', $productionMachine->id) - ->update(array( - 'building_name' => $productionMachine->machine->building->name, - )); - } - - - - if ($createProductionMachine && $updateResult) { - - Flash::success("Hasabat Ustunlikli Goşuldy"); + Flash::error("Bu Senede Haryt öň girizilen!!!"); return Redirect::refresh(); + } else { - Flash::error("Yalnyshlyk bar!!"); - return Redirect::refresh(); + + $createProductionMachine = new ProductionMachineModel(); + + $metrOfRulon = (float)((float)($data["gram"] / 100) * ($data["width"] / 100)) * (int)$data["layer"]; + $metrOfAllRulon = (float) $data["produced_weight"] / $metrOfRulon; + + $createProductionMachine->type_id = $data["type_id"]; + $createProductionMachine->width = $data["width"]; + $createProductionMachine->gram = $data["gram"]; + $createProductionMachine->brutto_kg = $data["brutto_kg"]; + $createProductionMachine->layer = $data["layer"]; + $createProductionMachine->machine_id = $data["machine_id"]; + $createProductionMachine->shift_id = $data["shift_id"]; + $createProductionMachine->color_id = $data["color_id"]; + $createProductionMachine->produced_weight = $data["produced_weight"]; + $createProductionMachine->produced_length = $metrOfAllRulon; + $createProductionMachine->defective_weight = $data["defective_weight"]; + $createProductionMachine->employee_name = $data["employee_name"]; + $createProductionMachine->mechanic_name = $data["employee_name"]; + $createProductionMachine->note = $data["note"]; + $createProductionMachine->date = Carbon::parse($data["date"])->format('Y-m-d'); + $createProductionMachine->user_id = $user->id; + $createProductionMachine->save(); + + $productionMachine = ProductionMachineModel::where('id', $createProductionMachine->id)->with(['machine.employee', 'machine.mechanic', 'machine.building'])->first(); + // dd($productionMachine->machine->name); + if ($productionMachine) { + $updateResult = ProductionMachineModel::where('id', $productionMachine->id) + ->update(array( + 'building_name' => $productionMachine->machine->building->name, + )); + } + + + + if ($createProductionMachine && $updateResult) { + + Flash::success("Hasabat Ustunlikli Goşuldy"); + return Redirect::refresh(); + } else { + Flash::error("Yalnyshlyk bar!!"); + return Redirect::refresh(); + } } } } diff --git a/themes/gokbakja/pages/actions/bag.htm b/themes/gokbakja/pages/actions/bag.htm index 27f7f1e..b87438b 100644 --- a/themes/gokbakja/pages/actions/bag.htm +++ b/themes/gokbakja/pages/actions/bag.htm @@ -73,8 +73,8 @@ function onStart(){ Mukdary (sany) Senesi Sklad - Direktor - Bugalter + Bellik Sazlamalar @@ -93,7 +93,7 @@ function onStart(){ {{record.created_at|date('d.m.Y')}} {{record.stock.name}} - {% if isDirector %} + + + {{record.note}}
@@ -160,8 +163,8 @@ function onStart(){ Mukdary (sany) Senesi Sklad - Direktor - Bugalter + Bellik Sazlamalar diff --git a/themes/gokbakja/pages/actions/rulon.htm b/themes/gokbakja/pages/actions/rulon.htm index d54056d..70f1852 100644 --- a/themes/gokbakja/pages/actions/rulon.htm +++ b/themes/gokbakja/pages/actions/rulon.htm @@ -71,8 +71,8 @@ function onStart(){ Mukdary (KG) Senesi Sklad - Direktor - Bugalter + Bellik Sazlamalar @@ -90,8 +90,11 @@ function onStart(){ {{record.amount|number_format(2)}} kg {{record.created_at|date('d.m.Y')}} {{record.stock.name}} - {% if record.status_director == 'accept' %} + {% else %} Tassyklanmadyk {% endif %} - {% if record.status_accountant == 'accept' %} + {% else %} Tassyklanmadyk {% endif %} + + + + {{record.note}}
@@ -140,8 +143,8 @@ function onStart(){ Mukdary (KG) Senesi Sklad - Direktor - Bugalter + Bellik Sazlamalar diff --git a/themes/gokbakja/pages/produced/bagstock.htm b/themes/gokbakja/pages/produced/bagstock.htm index 5cc9905..05c28f7 100644 --- a/themes/gokbakja/pages/produced/bagstock.htm +++ b/themes/gokbakja/pages/produced/bagstock.htm @@ -10,8 +10,8 @@ function onStart(){ $this["actions"] = Romanah\Gokbakja\Models\BagAction::select('romanah_gokbakja_bag_actions.*') ->with(['product.rulon_action.product.bag_type', 'product.rulon_action.product.color', 'product.pivot_sewer']) ->where("stock_id", $stockId) - ->where("status_accountant", "accept") - ->where("status_director", "accept") + //->where("status_accountant", "accept") + //->where("status_director", "accept") ->addSelect(DB::raw("SUM(amount) as quantity")) ->groupBy('romanah_gokbakja_bag_actions.product_id') ->orderBy('id', 'DESC') @@ -20,8 +20,8 @@ function onStart(){ $this["actionsQtyCount"] = Romanah\Gokbakja\Models\BagAction::select('romanah_gokbakja_bag_actions.*') ->where("stock_id", $stockId) - ->where("status_accountant", "accept") - ->where("status_director", "accept") + //->where("status_accountant", "accept") + //->where("status_director", "accept") ->sum('amount'); // dd($this["actions"]); diff --git a/themes/gokbakja/pages/produced/rulonstock.htm b/themes/gokbakja/pages/produced/rulonstock.htm index d429bd5..324c0ce 100644 --- a/themes/gokbakja/pages/produced/rulonstock.htm +++ b/themes/gokbakja/pages/produced/rulonstock.htm @@ -12,8 +12,8 @@ function onStart(){ $q->with(['bag_type', 'bag_size', 'color']); }]) ->where("stock_id", $stockId) - ->where("status_accountant", "accept") - ->where("status_director", "accept") + //->where("status_accountant", "accept") + //->where("status_director", "accept") ->addSelect(DB::raw("SUM(amount) as quantity")) ->groupBy('romanah_gokbakja_rulon_action.product_id') ->orderBy('id', 'DESC') @@ -21,8 +21,8 @@ function onStart(){ $this["actionsSumWeight"] = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*') ->where("stock_id", $stockId) - ->where("status_accountant", "accept") - ->where("status_director", "accept") + //->where("status_accountant", "accept") + //->where("status_director", "accept") ->sum('amount'); diff --git a/themes/gokbakja/pages/product/actions.htm b/themes/gokbakja/pages/product/actions.htm index 026b4ea..b8bbb2e 100644 --- a/themes/gokbakja/pages/product/actions.htm +++ b/themes/gokbakja/pages/product/actions.htm @@ -105,8 +105,8 @@ function onStart(){ Mukdary (KG) Senesi Sklad - Direktor - Bugalter + Bellik Sazlamalar @@ -125,7 +125,7 @@ function onStart(){ {{record.created_at|date('d.m.Y')}} {{record.stock.name}} - {% if isDirector %} + {{record.note}} @@ -194,8 +194,8 @@ function onStart(){ Mukdary (KG) Senesi Sklad - Direktor - Bugalter + Bellik Sazlamalar diff --git a/themes/gokbakja/pages/product/stock.htm b/themes/gokbakja/pages/product/stock.htm index 737ecd6..ba68c3e 100644 --- a/themes/gokbakja/pages/product/stock.htm +++ b/themes/gokbakja/pages/product/stock.htm @@ -9,8 +9,8 @@ function onStart(){ $this["actions"] = Romanah\Gokbakja\Models\Action::select('romanah_gokbakja_action.*') ->where("stock_id", $stockId) - ->where("status_accountant", "accept") - ->where("status_director", "accept") + //->where("status_accountant", "accept") + //->where("status_director", "accept") ->addSelect(DB::raw("SUM(amount) as quantity")) ->groupBy('romanah_gokbakja_action.product_id') ->get();