softDelete relations

This commit is contained in:
Shohrat 2023-10-30 00:54:41 +05:00
parent 8aa3108887
commit a26469f63d
10 changed files with 178 additions and 84 deletions

View File

@ -39,8 +39,13 @@ class MachineProduction extends ComponentBase
$allSpent = 0;
$allLeft = 0;
$html_data = '<div class="modal-header">
<h5 class="modal-title" id="mySmallModalLabel">#Rulon'.$machinProdId.' Agramy: '.$productions[0]->machin_production->produced_weight.' kg</h5>
// var_dump(count($productions));
if (count($productions) == 0) {
$html_data = '';
} {
$html_data = '<div class="modal-header">
<h5 class="modal-title" id="mySmallModalLabel">#Rulon' . $machinProdId . ' Agramy: ' . $productions[0]->machin_production->produced_weight . ' kg</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="Close"></button>
</div>
@ -64,33 +69,114 @@ class MachineProduction extends ComponentBase
</thead>
';
for ($x = 0; $x < count($productions); $x++) {
$allBagQty += $productions[$x]->sewer_production->produced_bag_qty;
$allSpent += $productions[$x]->spent_amount;
$allLeft += $productions[$x]->left_amount;
for ($x = 0; $x < count($productions); $x++) {
$allBagQty += $productions[$x]->sewer_production->produced_bag_qty;
$allSpent += $productions[$x]->spent_amount;
$allLeft += $productions[$x]->left_amount;
$html_data .='<tr>
<td>'.($x+1).'</td>
<td>#Rulon'.$productions[$x]->machine_production_id.'</td>
<td>#Dikiş'.$productions[$x]->sewer_production_id.'</td>
$html_data .= '<tr>
<td>' . ($x + 1) . '</td>
<td>#Rulon' . $productions[$x]->machine_production_id . '</td>
<td>#Dikiş' . $productions[$x]->sewer_production_id . '</td>
<td>' . ($productions[$x]->sewer_production->date == null ? "" : Carbon::parse($productions[$x]->sewer_production->date)->format('d.m.Y')) . '</td>
<td>' . ($productions[$x]->sewer_production->produced_bag_qty) . '</td>
<td>'.$productions[$x]->amount.' kg</td>
<td>'.$productions[$x]->spent_amount.' kg</td>
<td>'.$productions[$x]->left_amount.' kg</td>
<td>'.$productions[$x]->status.'</td>
<td>' . $productions[$x]->amount . ' kg</td>
<td>' . $productions[$x]->spent_amount . ' kg</td>
<td>' . $productions[$x]->left_amount . ' kg</td>
<td>' . $productions[$x]->status . '</td>
</tr>';
}
$html_data .='<tr style="background: #a2a9ff !important;">
}
$html_data .= '<tr style="background: #a2a9ff !important;">
<td colspan="4" style="font-weight: 700;color: black;">JEMI</td>
<td style="font-weight: 700;color: black;">'.$allBagQty.' sany</td>
<td style="font-weight: 700;color: black;">' . $allBagQty . ' sany</td>
<td></td>
<td style="font-weight: 700;color: black;">'.$allSpent.' kg</td>
<td style="font-weight: 700;color: black;">' . $allSpent . ' kg</td>
<td style="font-weight: 700;color: black;"></td>
<td></td>
</tr>';
$html_data .='</table></div>';
$html_data .= '</table></div>';
}
return [
'#modal-form' => $html_data,
];
}
public function onSetFormUpdate()
{
$data = post();
$machinProdId = $data["machineProdId"];
$production = ProductionMachineModel::where("id", $machinProdId)->first();
$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"
aria-label="Close"></button>
</div>
<div class="modal-body">';
$html_data .= '<form data-request="onUpdateMachineProduction" data-request-flash>
<div class="row">
<div class="col">
<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">
<span class="input-group-text"><i class="mdi mdi-calendar"></i></span>
</div>
</div>
<div class="col">
<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>
</div>
<div class="col">
<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>
</div>
<div class="col">
<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>
</div>
<div class="col">
<input type="number" name="produced_weight" class="form-control"
placeholder="Mukdar (kg)">
</div>
<div class="col">
<input type="text" name="note" class="form-control" placeholder="Bellik">
</div>
<div class="col">
<button type="submit" class="btn btn-primary waves-effect waves-light"
style="width: 100%;">Goş</button>
</div>
</div>
</form>';
$html_data .= '</div>';
return [
'#modal-form' => $html_data,
@ -113,7 +199,7 @@ class MachineProduction extends ComponentBase
<td style="font-weight: bold;">' . ($x + 1) . '</td>
<td style="font-weight: bold;"><a type="button" data-request="onModalSetMachineData"
data-request-data="machineProdId: ' . $machineProductions[$x]->id . '"
data-bs-toggle="modal" data-bs-target=".bs-example-modal-lg"> #Rulon' . ($machineProductions[$x]->id) . '</a></td>
data-bs-toggle="modal" data-bs-target=".bs-example-modal-lg" style="color: darkblue;"> #Rulon' . ($machineProductions[$x]->id) . '</a></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>
@ -126,6 +212,7 @@ class MachineProduction extends ComponentBase
<td>' . $machineProductions[$x]->employee_name . '</td>
<td>' . $machineProductions[$x]->mechanic_name . '</td>
<td>' . $machineProductions[$x]->note . '</td>
<td> <a href="#" data-request="onSetFormUpdate" data-bs-toggle="modal" data-bs-target=".bs-example-modal-lg" data-request-data="machineProdId: ' . $machineProductions[$x]->id . '" style="font-weight: bold;color: darkred;"> ÜÝTGET </a> </td>
</tr>';
}
@ -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 = '<span class="badge badge-soft-warning"
$spent = '<span class="badge badge-soft-warning"
style="font-size: 14px;">' . number_format($machineProductionsFiltered[$x]->spentSum, 2) . ' kg</span>';
$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 .= '<tr>
$html_data .= '<tr>
<td style="font-weight: bold;">' . ($x + 1) . '</td>
<td style="font-weight: bold;"><a type="button" data-request="onModalSetMachineData"
data-request-data="machineProdId: ' . $machineProductionsFiltered[$x]->id . '"
@ -257,26 +344,26 @@ class MachineProduction extends ComponentBase
style="font-size: 14px;">' . number_format($machineProductionsFiltered[$x]->produced_weight) . ' kg</span>
</td>
<td>
'.$spent.'
' . $spent . '
</td>
<td><span class="badge badge-soft-success"
style="font-size: 14px;">' . $left .'</span>
style="font-size: 14px;">' . $left . '</span>
</td>
<td>' . $machineProductionsFiltered[$x]->employee_name . '</td>
<td>' . $machineProductionsFiltered[$x]->mechanic_name . '</td>
<td>' . $machineProductionsFiltered[$x]->note . '</td>
</tr>';
}
}
if ($machineProductionsFiltered) {
return [
'#machine_report_datas' => $html_data,
'#all_amount' => '
if ($machineProductionsFiltered) {
return [
'#machine_report_datas' => $html_data,
'#all_amount' => '
<div class="col-md-3">
<div class="card bg-info text-white-50">
<div class="card-body">
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;">Öndürlen Rulon: '.count($machineProductionsFiltered).'<br>Ulanylan Rulon: ' .$finishedRulons.'<br>Sklatdaky: '.$leftAllRulons.'</h5>
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;">Öndürlen Rulon: ' . count($machineProductionsFiltered) . '<br>Ulanylan Rulon: ' . $finishedRulons . '<br>Sklatdaky: ' . $leftAllRulons . '</h5>
</div>
</div>
</div>
@ -284,7 +371,7 @@ class MachineProduction extends ComponentBase
<div class="card bg-info text-white-50">
<div class="card-body">
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;"><i
class="mdi mdi-bullseye-arrow me-3"></i> Öndürlen: '.number_format($machineProductionsSum, 2).' kg</h5>
class="mdi mdi-bullseye-arrow me-3"></i> Öndürlen: ' . number_format($machineProductionsSum, 2) . ' kg</h5>
</div>
</div>
</div>
@ -292,7 +379,7 @@ class MachineProduction extends ComponentBase
<div class="card bg-primary text-white-50">
<div class="card-body">
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;"><i
class="mdi mdi-bullseye-arrow me-3"></i> Sklatda: '.number_format($machineLeftProductionsSum, 2).' kg</h5>
class="mdi mdi-bullseye-arrow me-3"></i> Sklatda: ' . number_format($machineLeftProductionsSum, 2) . ' kg</h5>
</div>
</div>
@ -301,16 +388,14 @@ class MachineProduction extends ComponentBase
<div class="card bg-danger text-white-50">
<div class="card-body">
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;"><i
class="mdi mdi-bullseye-arrow me-3"></i> Ulanylan: '.number_format($allSpent, 2).' kg</h5>
class="mdi mdi-bullseye-arrow me-3"></i> Ulanylan: ' . number_format($allSpent, 2) . ' kg</h5>
</div>
</div>
</div>',
];
} else {
Flash::error("Yalnyshlyk bar!!");
}
];
} else {
Flash::error("Yalnyshlyk bar!!");
}
}
public function onCreateMachineProduction()

View File

@ -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();
}
}

View File

@ -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
],
];

View File

@ -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',

View File

@ -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
]
];

View File

@ -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
],
];

View File

@ -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
],
];

View File

@ -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 '

View File

@ -187,6 +187,7 @@ pageNumber = "{{ :page }}"
<th>Ady Familiýasy</th>
<th>Mehanik</th>
<th>Bellik</th>
<th>Sazlama</th>
<!-- <th>Настройки</th> -->
</tr>
</thead>
@ -207,6 +208,7 @@ pageNumber = "{{ :page }}"
<th>Ady Familiýasy</th>
<th>Mehanik</th>
<th>Bellik</th>
<th>Sazlama</th>
</tr>
</tfoot>
</table>

View File

@ -185,6 +185,7 @@ function onStart(){
<th>{{record.name}}</th>
{% endfor %}
<th>Bellik</th>
<th>Sazlama</th>
<!-- <th>Настройки</th> -->
</tr>
</thead>
@ -241,6 +242,7 @@ function onStart(){
{% endfor %}
<td style="font-weight: bold;color: #0005c5;">{{report.note}}</td>
<td><a href="#" data-request="onDeleteProduction" data-request-data="id: {{report.id}}" data-request-confirm="Hasabat # {{report.id}} pozmak isleýäňizmi?" style="font-weight: bold;color: darkred;">POZ</a></td>
</tr>
@ -260,6 +262,7 @@ function onStart(){
<th>{{record.name}}</th>
{% endfor %}
<th>Bellik</th>
<th>Sazlama</th>
</tr>
</tfoot>
</table>