This commit is contained in:
Shohrat 2023-11-02 02:07:33 +05:00
parent a26469f63d
commit 8a342b6ee5
10 changed files with 214 additions and 88 deletions

View File

@ -13,6 +13,10 @@ use Flash;
// use Illuminate\Validation\Validator;
use \Validator;
use DB;
use Romanah\Gokbakja\Models\BagColor;
use Romanah\Gokbakja\Models\BagSize;
use Romanah\Gokbakja\Models\BagType;
use Romanah\Gokbakja\Models\Machine;
use Romanah\Gokbakja\Models\PivotSewer;
class MachineProduction extends ComponentBase
@ -112,6 +116,11 @@ class MachineProduction extends ComponentBase
$production = ProductionMachineModel::where("id", $machinProdId)->first();
$colors = BagColor::get();
$types = BagType::get();
$sizes = BagSize::get();
$machines = Machine::get();
$html_data = '<div class="modal-header">
<h5 class="modal-title" id="mySmallModalLabel">#Rulon' . $machinProdId . ' Agramy: ' . $production->produced_weight . ' kg</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"
@ -121,58 +130,65 @@ class MachineProduction extends ComponentBase
$html_data .= '<form data-request="onUpdateMachineProduction" data-request-flash>
<div class="row">
<div class="col">
<div class="col-md-12 mt-3">
<label style="color: black;">Enjam</label>
<select class="form-control select2" name="machine_id">
<option value="0">Enjam Saýla</option>
{% for machine in machines %}
<option value="{{machine.id}}">{{machine.name}}</option>
{% endfor %}
</select>
</div>
<div class="col">
<!-- <input type="date" name="date" class="form-control" placeholder="Sene"> -->
<div class="input-group" id="datepicker2">
<input type="text" class="form-control" name="date" placeholder="Sene"
data-date-format="d.m.yyyy" data-date-container="#datepicker2"
data-provide="datepicker" data-date-autoclose="true">
<option value="0">Enjam Saýla</option>';
for ($x = 0; $x < count($machines); $x++) {
$html_data .='<option value="'.$machines[$x]->id.'" '.($production->machine_id == $machines[$x]->id ? 'selected' : '').'>'.$machines[$x]->name.'</option>';
}
<span class="input-group-text"><i class="mdi mdi-calendar"></i></span>
</div>
$html_data .='</select>
</div>
<div class="col">
<div class="col-md-12 mt-3">
<label style="color: black;">Sene</label>
<input type="date" name="date" class="form-control" placeholder="Sene" value="'.($production->date != null ? Carbon::parse($production->date)->format('Y-m-d') : "").'">
</div>
<div class="col-md-12 mt-3">
<label style="color: black;">Ölçeg</label>
<select class="form-control select2" name="size_id">
<option value="0">Ölçeg Saýla</option>
{% for size in sizes %}
<option value="{{size.id}}">{{size.name}}</option>
{% endfor %}
</select>
<option value="0">Ölçeg Saýla</option>';
for ($x = 0; $x < count($sizes); $x++) {
$html_data .='<option value="'.$sizes[$x]->id.'" '.($production->size_id == $sizes[$x]->id ? 'selected' : '').'>'.$sizes[$x]->name.'</option>';
}
$html_data .='</select>
</div>
<div class="col">
<div class="col-md-12 mt-3">
<label style="color: black;">Görnüşi</label>
<select class="form-control select2" name="type_id">
<option value="0">Görnüş Saýla</option>
{% for type in types %}
<option value="{{type.id}}">{{type.name}}</option>
{% endfor %}
</select>
<option value="0">Görnüş Saýla</option>';
for ($x = 0; $x < count($types); $x++) {
$html_data .='<option value="'.$types[$x]->id.'" '.($production->type_id == $types[$x]->id ? 'selected' : '').'>'.$types[$x]->name.'</option>';
}
$html_data .='</select>
</div>
<div class="col">
<div class="col-md-12 mt-3">
<label style="color: black;">Reňki</label>
<select class="form-control select2" name="color_id">
<option value="0">Reňk Saýla</option>
{% for color in colors %}
<option value="{{color.id}}">{{color.name}}</option>
{% endfor %}
</select>
<option value="0">Reňk Saýla</option>';
for ($x = 0; $x < count($colors); $x++) {
$html_data .='<option value="'.$colors[$x]->id.'" '.($production->color_id == $colors[$x]->id ? 'selected' : '').'>'.$colors[$x]->name.'</option>';
}
$html_data .='</select>
</div>
<div class="col">
<div class="col-md-12 mt-3">
<label style="color: black;">Öndürlen önüm (kg)</label>
<input type="number" name="produced_weight" class="form-control"
placeholder="Mukdar (kg)">
placeholder="Mukdar (kg)" value="'.$production->produced_weight.'">
</div>
<div class="col">
<input type="text" name="note" class="form-control" placeholder="Bellik">
<div class="col-md-12 mt-3">
<label style="color: black;">Bellik</label>
<input type="text" name="note" class="form-control" placeholder="Bellik" value="'.$production->note.'">
</div>
<div class="col">
<input type="hidden" name="production_id" value="'.$production->id.'">
<div class="col-md-12 mt-3">
<button type="submit" class="btn btn-primary waves-effect waves-light"
style="width: 100%;">Goş</button>
style="width: 100%;">Üýtget</button>
</div>
</div>
</div>
</form>';
@ -183,6 +199,21 @@ class MachineProduction extends ComponentBase
];
}
public function onDeleteProductionMachine(){
$id = post('production_id');
$productionDelete = ProductionMachineModel::Find($id);
$productionDelete->delete();
if ($productionDelete) {
Flash::success("Hasabat Ustunlikli Pozuldy");
return Redirect::refresh();
} else {
Flash::error("Yalnyshlyk bar!!");
return Redirect::refresh();
}
}
public function onRender()
{
@ -398,6 +429,30 @@ class MachineProduction extends ComponentBase
}
}
public function onUpdateMachineProduction(){
$data = post();
$updateProductionMachine = ProductionMachineModel::where("id", $data["production_id"])->first();
$updateProductionMachine->type_id = $data["type_id"];
$updateProductionMachine->size_id = $data["size_id"];
$updateProductionMachine->machine_id = $data["machine_id"];
$updateProductionMachine->color_id = $data["color_id"];
$updateProductionMachine->produced_weight = $data["produced_weight"];
$updateProductionMachine->note = $data["note"];
$updateProductionMachine->date = Carbon::parse($data["date"])->format('Y-m-d');
$updateProductionMachine->save();
if ($updateProductionMachine) {
Flash::success("Hasabat Ustunlikli Uytgedildi");
return Redirect::refresh();
} else {
Flash::error("Yalnyshlyk bar!!");
return Redirect::refresh();
}
}
public function onCreateMachineProduction()
{
$user = \Auth::user();
@ -435,38 +490,15 @@ class MachineProduction extends ComponentBase
));
}
$currentDateFormat = Carbon::now()->format('Y-m-d');
$machineProductions = ProductionMachineModel::with(['bag_type', 'bag_size', 'machine.building', 'employee', 'mechanic', 'color'])->orderBy('id', 'DESC')->get();
$html_data = '';
for ($x = 0; $x < count($machineProductions); $x++) {
$html_data .= '<tr>
<td style="font-weight: bold;">' . ($x + 1) . '</td>
<td><a href="#">' . ($machineProductions[$x]->date == null ? "" : Carbon::parse($machineProductions[$x]->date)->format('d.m.Y')) . '</a></td>
<td><a href="#" style="font-weight: bold;">' . $machineProductions[$x]->building_name . '</a></td>
<td>' . $machineProductions[$x]->machine->name . '</td>
<td>' . $machineProductions[$x]->bag_size->name . '</td>
<td>' . $machineProductions[$x]->bag_type->name . '</td>
<td>' . ($machineProductions[$x]->color->name ?? "") . '</td>
<td><span class="badge badge-soft-success"
style="font-size: 14px;">' . number_format($machineProductions[$x]->produced_weight) . ' kg</span>
</td>
<td>' . $machineProductions[$x]->employee_name . '</td>
<td>' . $machineProductions[$x]->mechanic_name . '</td>
<td>' . $machineProductions[$x]->note . '</td>
</tr>';
}
if ($createProductionMachine && $updateResult) {
Flash::success("Hasabat Ustunlikli Goşuldy");
return [
'#machine_datas' => $html_data,
];
return Redirect::refresh();
} else {
Flash::error("Yalnyshlyk bar!!");
return Redirect::refresh();
}
}
}

View File

@ -77,6 +77,7 @@ class OrderItem extends ComponentBase
}else{
$colorId = $orderItems[$x]->color_id;
$bag_gram = $orderItems[$x]->bag_gram;
$sewerProductions = SewerModel::where("width", $orderItems[$x]->bag_width)
->where("height", $orderItems[$x]->bag_height)
@ -84,6 +85,9 @@ class OrderItem extends ComponentBase
->whereHas('machin_production', function ($query) use($colorId) {
$query->where('color_id', $colorId);
})
->whereHas('pivot_sewer', function ($query) use($bag_gram) {
$query->where('bag_gram', $bag_gram);
})
->sum("produced_bag_qty");
$stockCalc= $sewerProductions;
@ -97,13 +101,13 @@ class OrderItem extends ComponentBase
$html_data .= '<tr>
<td style="font-weight: bold;">'.($x+1).'</td>
<td style="font-weight: bold;">'.($x+1).', #'.$orderItems[$x]->id.'</td>
<td><a href="#" style="font-weight: bold;">';
if ($orderItems[$x]->order_item_type == 'rulon'){
$html_data .= 'Rulon, '.$orderItems[$x]->type->name ?? "" .','. $orderItems[$x]->color->name ?? "";
}else{
$html_data .= 'Halta, '. $orderItems[$x]->color->name ?? "";
$html_data .= 'Halta, '. ($orderItems[$x]->color->name ?? "") .', '. (number_format($orderItems[$x]->bag_gram ?? 0, 2)) .' gr';
}
$html_data .='</a></td>
@ -271,6 +275,7 @@ class OrderItem extends ComponentBase
$createOrderItem->type_id = $data["type_id"];
$createOrderItem->size_id = $data["size_id"];
$createOrderItem->color_id = $data["color_id"];
$createOrderItem->bag_gram = $data["bag_gram"];
$createOrderItem->bag_width = $data["bag_width"];
$createOrderItem->bag_height = $data["bag_height"];
$createOrderItem->price = $data["price"];

View File

@ -27,11 +27,6 @@ class Sewer extends ComponentBase
}
// public function onRun() {
// $this->sewers = $this->loadSewers();
// }
public function onModalSetSewer()
{
@ -103,16 +98,6 @@ class Sewer extends ComponentBase
</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"
placeholder="Galyndy (kg)" value="' . ($sewerProd->pivot_sewer[0]->left_amount) . '" ' . ($sewerProd->pivot_sewer[0]->status == 'complated' ? "disabled" : "") . '>
</div>
</div>
<div class="col-md-12 mt-3">
<div>
<label class="form-label">Bellik</label>
@ -161,10 +146,13 @@ class Sewer extends ComponentBase
return Redirect::refresh();
}
} else {
$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"]);
// $spentCalc = (float)((float) $pivotSewer->amount - (float) $data["left_amount"]);
$spentCalc = (float)((float) $data["produced_bag_qty"] * (float) $pivotSewer->bag_gram) / 1000;
$leftCalc = (float)((float)$pivotSewer->amount - $spentCalc);
$sewer->produced_bag_qty = (float) $data["produced_bag_qty"];
$sewer->width = (float) $data["width"];
@ -173,16 +161,16 @@ class Sewer extends ComponentBase
$sewer->note = $data["note"];
$sewer->save();
$pivotSewer->left_amount = (float) $data["left_amount"];
$pivotSewer->left_amount = (float) $leftCalc;
$pivotSewer->spent_amount = (float) $spentCalc;
$pivotSewer->status = $data["status"];
$pivotSewer->save();
if ($data["left_amount"] == 0 && $data["status"] == "complated") {
if ($leftCalc == 0 && $data["status"] == "complated") {
$machinProduction = ProductionMachine::where("id", $pivotSewer->machine_production_id)->first();
$machinProduction->is_finished = true;
$machinProduction->save();
}else{
}elseif($data["status"] != "complated"){
Flash::error("Status tamamlamaly!");
return Redirect::refresh();
}
@ -225,6 +213,7 @@ class Sewer extends ComponentBase
</td>
<td><a href="#" style="font-weight: bold;">' . $sewerDatas[$x]->employee->name . '</a></td>
<td>' . $dateTitle . '</td>
<td>' . (number_format($sewerDatas[$x]->pivot_sewer[0]->bag_gram ?? 0, 2)) . ' gr</td>
<td><span class="badge badge-soft-success"
style="font-size: 14px;">' . number_format($sewerDatas[$x]->pivot_sewer[0]->amount, 2) . ' kg</span>
</td>
@ -280,6 +269,7 @@ class Sewer extends ComponentBase
$width = $data["width"];
$height = $data["height"];
$color_id = $data["color_id"];
$bag_gram = $data["bag_gram"];
@ -301,12 +291,20 @@ class Sewer extends ComponentBase
});
}
if ($bag_gram) {
$sewerProductions->with("pivot_sewer")->whereHas('pivot_sewer', function ($query) use($bag_gram) {
$query->where('bag_gram', $bag_gram);
});
}
if ($color_id) {
$sewerProductions->with("machin_production")->whereHas('machin_production', function ($query) use($color_id) {
$query->where('color_id', $color_id);
});
}
if ($min) {
$sewerProductions->whereRaw('produced_bag_qty >' . ($min - 1));
}
@ -352,6 +350,7 @@ class Sewer extends ComponentBase
</td>
<td><a href="#" style="font-weight: bold;">' . $sewerDatas[$x]->employee->name . '</a></td>
<td>' . $dateTitle . '</td>
<td>' . (number_format($sewerDatas[$x]->pivot_sewer[0]->bag_gram ?? 0, 2)) . ' gr</td>
<td><span class="badge badge-soft-success"
style="font-size: 14px;">' . number_format($sewerDatas[$x]->pivot_sewer[0]->amount, 2) . ' kg</span>
</td>
@ -405,6 +404,7 @@ class Sewer extends ComponentBase
$machineProductionSpent = PivotSewer::where("machine_production_id", $data["machine_production_id"])->sum('spent_amount');
$leftAmount = 0;
if ($machineProduction->produced_weight > $machineProductionSpent) {
$calcLeft = ((float) $machineProduction->produced_weight - (float) $machineProductionSpent);
@ -431,6 +431,7 @@ class Sewer extends ComponentBase
$createPivotSewer->machine_production_id = $createSewer->machine_production_id;
$createPivotSewer->sewer_production_id = $createSewer->id;
$createPivotSewer->left_amount = 0;
$createPivotSewer->bag_gram = (float) $data["bag_gram"];
$createPivotSewer->amount = $leftAmount;
$createPivotSewer->save();

View File

@ -0,0 +1,23 @@
<?php namespace Romanah\Gokbakja\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableUpdateRomanahGokbakjaOrderItem8 extends Migration
{
public function up()
{
Schema::table('romanah_gokbakja_order_item', function($table)
{
$table->double('bag_gram', 10, 0);
});
}
public function down()
{
Schema::table('romanah_gokbakja_order_item', function($table)
{
$table->dropColumn('bag_gram');
});
}
}

View File

@ -0,0 +1,23 @@
<?php namespace Romanah\Gokbakja\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableUpdateRomanahGokbakjaPivotSewer3 extends Migration
{
public function up()
{
Schema::table('romanah_gokbakja_pivot_sewer', function($table)
{
$table->double('bag_gram', 10, 0)->nullable();
});
}
public function down()
{
Schema::table('romanah_gokbakja_pivot_sewer', function($table)
{
$table->dropColumn('bag_gram');
});
}
}

View File

@ -303,3 +303,9 @@
1.0.102:
- 'Created table romanah_gokbakja_journal'
- builder_table_create_romanah_gokbakja_journal.php
1.0.103:
- 'Updated table romanah_gokbakja_pivot_sewer'
- builder_table_update_romanah_gokbakja_pivot_sewer_3.php
1.0.104:
- 'Updated table romanah_gokbakja_order_item'
- builder_table_update_romanah_gokbakja_order_item_8.php

View File

@ -85,6 +85,12 @@ function onStart(){
</select>
</div>
<div class="col" id="bag_gram">
<label class="form-label">Halta Gramy (gr)</label>
<input type="number" name="bag_gram" step="0.01" class="form-control"
placeholder="Halta Gramy" value="0">
</div>
<div class="col" id="bag_width">
<label class="form-label">Halta Ini</label>
<input type="number" name="bag_width" step="0.01" class="form-control"
@ -258,9 +264,11 @@ function onStart(){
$("#bag_width").hide();
$("#bag_height").hide();
$("#bag_gram").hide();
}else{
$("#bag_width").show();
$("#bag_height").show();
$("#bag_gram").show();
$("#rulon_type").hide();
$("#rulon_size").hide();

View File

@ -21,6 +21,8 @@ function onStart(){
}])
->first();
$this["orderItems"] = Romanah\Gokbakja\Models\OrderItem::where("order_id", $orderId)->get();
$this["all"] = ($this["order"]->order_all_amount * $this["order"]->order_all_price);
$this["transports"] = Romanah\Gokbakja\Models\ShippingTransport::where("shipping_id", $this["order"]->shipping_id)->orderBy("id", "DESC")->get();
@ -83,6 +85,24 @@ function onStart(){
</select>
</div>
<div class="col">
<label class="form-label">Sargyt Harytlary</label>
<select class="form-control select2" name="order_item_id">
<option value="0">Saýla</option>
{% for item in orderItems %}
<option value="{{item.id}}">#{{item.id}}
{% if item.order_item_type == 'rulon' %}
Rulon
{% else %}
Halta
{% endif %}
</option>
{% endfor %}
</select>
</div>
<div class="col">
<div>
<label class="form-label">Ýüklenen Mukdar (kg)</label>

View File

@ -111,10 +111,10 @@ function onStart(){
</div>
<div class="col">
<div>
<label class="form-label">Tikilen Halta</label>
<label class="form-label">Halta agramy (gr)</label>
<input type="number" name="produced_bag_qty" class="form-control"
placeholder="tikilen halta sany">
<input type="number" step="0.01" name="bag_gram" class="form-control"
placeholder="Halta gramy">
</div>
</div>
@ -170,6 +170,7 @@ function onStart(){
<th>Rulon Görnüş</th>
<th>Tikinçi</th>
<th>Senesi</th>
<th>Gram</th>
<th>Çig mal mukdary</th>
<th>Tikilen Halta</th>
<th>Ulanylan</th>
@ -193,6 +194,7 @@ function onStart(){
<th>Rulon Görnüş</th>
<th>Tikinçi</th>
<th>Senesi</th>
<th>Gram</th>
<th>Çig mal mukdary</th>
<th>Tikilen Halta</th>
<th>Ulanylan</th>

View File

@ -101,6 +101,10 @@ function onStart(){
</select>
</div>
<div class="col">
<label class="form-label">Halta Gram</label>
<input name="bag_gram" class="form-control" placeholder="Halta gramy">
</div>
<div class="col">
<label class="form-label">Minimum San</label>
<input name="min" class="form-control" placeholder="Minimum Halta San">
@ -153,6 +157,7 @@ function onStart(){
<th>Rulon Görnüş</th>
<th>Tikinçi</th>
<th>Senesi</th>
<th>Gram</th>
<th>Çig mal mukdary</th>
<th>Tikilen Halta</th>
<th>Ulanylan</th>
@ -174,6 +179,7 @@ function onStart(){
<th>Rulon Görnüş</th>
<th>Tikinçi</th>
<th>Senesi</th>
<th>Gram</th>
<th>Çig mal mukdary</th>
<th>Tikilen Halta</th>
<th>Ulanylan</th>