update 19_12

This commit is contained in:
Shohrat 2023-12-19 01:54:55 +05:00
parent aa1019314c
commit dfa54182b1
6 changed files with 227 additions and 100 deletions

View File

@ -29,6 +29,20 @@ class Production extends ComponentBase
];
}
public function calculateHoursAndMinutes($date, $time)
{
// Assuming $this->date_column and $this->time_column are your actual column names
$dateTime = Carbon::parse($date." ".$time);
// Get the current date and time
$now = Carbon::now();
// Calculate the difference in hours and minutes
$diffInHours = $dateTime->diffInHours($now);
$diffInMinutes = $dateTime->diffInMinutes($now) % 60;
return ['hours' => $diffInHours, 'minutes' => $diffInMinutes];
}
public function onReportProduction()
{
@ -80,6 +94,9 @@ class Production extends ComponentBase
$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);
$productionsCalcPivot->whereBetween('date', [$start, $end]);
@ -97,7 +114,7 @@ class Production extends ComponentBase
$pivotIds = PivotProductionModel::whereIn('production_id', $calculationAmountqq)->get()->pluck('id')->toArray();
$calculationAmount = ProductionCalculateModel::whereIn('prev_pivot_id', $pivotIds)->sum("amount_calc");
$calculationAmount = ProductionCalculateModel::whereIn('production_id', $calculationAmountqq)->sum("amount_calc");
//dd($pivotIds);
@ -105,15 +122,15 @@ class Production extends ComponentBase
$html_data = '';
for ($x = 0; $x < count($productionsFiltered); $x++) {
$date = "";
if($productionsFiltered[$x]->date != null){
$date = Carbon::parse($productionsFiltered[$x]->date)->format('d.m.Y').' | '.$productionsFiltered[$x]->time;
}else{
if ($productionsFiltered[$x]->date != null) {
$date = Carbon::parse($productionsFiltered[$x]->date)->format('d.m.Y') . ' | ' . $productionsFiltered[$x]->time;
} else {
$date = "";
}
// dd($productionsFiltered[0]->shift->desc);
$html_data .= '<tr>
<td style="font-weight: bold;width: 5%;">' . ($x + 1) . '</td>
<td><a href="#'.$productionsFiltered[$x]->id.'" style="font-weight: bold;color: #0005c5;">' . $date . '</a></td>
<td><a href="#' . $productionsFiltered[$x]->id . '" style="font-weight: bold;color: #0005c5;">' . $date . '</a></td>
<td><a href="#" style="font-weight: bold;color: #1e2038;">' . $productionsFiltered[$x]->shift->desc . '</a></td>
<td style="text-align: center;">
<span class="badge badge-soft-info"
@ -144,7 +161,7 @@ class Production extends ComponentBase
<div class="col-md-4">
<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>Sarp Edilen Wagt: ' . $calcTimeDiff . ' sany</h5>
<h5 class="text-white" style="text-transform: uppercase;margin-bottom: 0;"><i class="mdi mdi-bullseye-arrow me-3"></i>Sarp Edilen Wagt: ' . $calcTimeDiff . '</h5>
</div>
</div>
</div>
@ -413,9 +430,9 @@ class Production extends ComponentBase
$productionPivot = PivotProductionModel::where('production_id', $todayProductionsGet->id)->where("product_id", $data["prod_id"])->first();
if(!$productionPivot){
if (!$productionPivot) {
$amountPERC = 0;
}else{
} else {
$amountPERC = $productionPivot->amount_percentage;
}
@ -469,7 +486,6 @@ class Production extends ComponentBase
$productionCalulate->amount_calc = (float)(((float) $data[$fieldName] ?? 0) / 100) * ((float) $diffCalc);
$productionCalulate->amount_percentage = (float) $data[$fieldName] ?? 0;
$productionCalulate->save();
}
if ($updatePivotProduction) {
@ -492,43 +508,46 @@ class Production extends ComponentBase
Flash::error("Ekstrudor Saýla!");
return Redirect::refresh();
} else {
$createProduction = new ProductionModel();
$todayProductionsGet = ProductionModel::where("excruiter_id", $excruiter)->orderBy("id", "DESC")->first();
//dd($todayProductionsGet);
if ($todayProductionsGet) {
// Flash::error("1");
// return Redirect::refresh();
$createProduction = new ProductionModel();
$createProduction->all_amount = $data["all_amount"];
$createProduction->note = $data["note"];
$createProduction->user_id = $user->id;
$createProduction->date = Carbon::parse($data["date"])->format('Y-m-d');
$createProduction->time = Carbon::parse($data["time"])->format('H:i:s');
$createProduction->excruiter_id = $excruiter;
$createProduction->shift_id = $data["shift_id"];
$createProduction->save();
$products = ProductModel::where("report", "simple")->orderBy('order', 'ASC')->get();
for ($x = 0; $x < count($products); $x++) {
$fieldName = "product_" . $products[$x]->id;
$createPivotProduction = new PivotProductionModel();
$createPivotProduction->production_id = $createProduction->id;
$createPivotProduction->product_id = $products[$x]->id;
$createPivotProduction->amount_percentage = (float) $data[$fieldName] ?? 0;
$createPivotProduction->product_name = $products[$x]->name;
$createPivotProduction->product_code = $products[$x]->code;
$createProduction->all_amount = $data["all_amount"];
$createProduction->note = $data["note"];
$createProduction->user_id = $user->id;
$createProduction->date = Carbon::parse($data["date"])->format('Y-m-d');
$createProduction->time = Carbon::parse($data["time"])->format('H:i:s');
$createProduction->excruiter_id = $excruiter;
$createPivotProduction->amount = (float)(((float) $data[$fieldName] ?? 0) / 100) * ((float) $createProduction->all_amount);
$createProduction->shift_id = $data["shift_id"];
$createProduction->save();
$createPivotProduction->date = Carbon::parse($data["date"])->format('Y-m-d');
$createPivotProduction->time = Carbon::parse($data["time"])->format('H:i:s');
$createPivotProduction->save();
}
$products = ProductModel::where("report", "simple")->orderBy('order', 'ASC')->get();
for ($x = 0; $x < count($products); $x++) {
$fieldName = "product_" . $products[$x]->id;
$todayProductionsCount = ProductionModel::whereDate('date', date($createProduction->date))->where("excruiter_id", $excruiter)->count();
$createPivotProduction = new PivotProductionModel();
$createPivotProduction->production_id = $createProduction->id;
$createPivotProduction->product_id = $products[$x]->id;
$createPivotProduction->amount_percentage = (float) $data[$fieldName] ?? 0;
$createPivotProduction->product_name = $products[$x]->name;
$createPivotProduction->product_code = $products[$x]->code;
$createPivotProduction->excruiter_id = $excruiter;
$createPivotProduction->amount = (float)(((float) $data[$fieldName] ?? 0) / 100) * ((float) $createProduction->all_amount);
if ($todayProductionsCount > 1) {
$createPivotProduction->date = Carbon::parse($data["date"])->format('Y-m-d');
$createPivotProduction->time = Carbon::parse($data["time"])->format('H:i:s');
$createPivotProduction->save();
}
// if ($todayProductionsCount > 1) {
// $todayProductionsGetLast = ProductionModel::whereDate('date', date($createProduction->date))->where("excruiter_id", $excruiter)->orderBy("id", "DESC")->first();
$todayProductionsGet = ProductionModel::whereDate('date', date($createProduction->date))->where("excruiter_id", $excruiter)->orderBy("id", "DESC")->skip(1)->first();
$productionPivots = PivotProductionModel::where('production_id', $todayProductionsGet->id)->get();
@ -550,14 +569,52 @@ class Production extends ComponentBase
$createCalculate->current_pivot_id = $currentPivot->id;
$createCalculate->prev_pivot_id = $productionPivots[$x]->id;
$createCalculate->date = $productionPivots[$x]->date;
$createCalculate->time = $productionPivots[$x]->time;
$createCalculate->date = $todayProductionsGet->date;
$createCalculate->time = $todayProductionsGet->time;
$createCalculate->save();
}
} else {
// Flash::error("2");
// return Redirect::refresh();
$createProduction = new ProductionModel();
$createProduction->all_amount = $data["all_amount"];
$createProduction->note = $data["note"];
$createProduction->user_id = $user->id;
$createProduction->date = Carbon::parse($data["date"])->format('Y-m-d');
$createProduction->time = Carbon::parse($data["time"])->format('H:i:s');
$createProduction->excruiter_id = $excruiter;
$createProduction->shift_id = $data["shift_id"];
$createProduction->save();
$products = ProductModel::where("report", "simple")->orderBy('order', 'ASC')->get();
for ($x = 0; $x < count($products); $x++) {
$fieldName = "product_" . $products[$x]->id;
$createPivotProduction = new PivotProductionModel();
$createPivotProduction->production_id = $createProduction->id;
$createPivotProduction->product_id = $products[$x]->id;
$createPivotProduction->amount_percentage = (float) $data[$fieldName] ?? 0;
$createPivotProduction->product_name = $products[$x]->name;
$createPivotProduction->product_code = $products[$x]->code;
$createPivotProduction->excruiter_id = $excruiter;
$createPivotProduction->amount = (float)(((float) $data[$fieldName] ?? 0) / 100) * ((float) $createProduction->all_amount);
$createPivotProduction->date = Carbon::parse($data["date"])->format('Y-m-d');
$createPivotProduction->time = Carbon::parse($data["time"])->format('H:i:s');
$createPivotProduction->save();
}
}
// }
if ($createProduction && $createPivotProduction) {
Flash::success("Hasabat Ustunlikli Goşuldy");
return Redirect::refresh();
@ -608,7 +665,4 @@ class Production extends ComponentBase
return Redirect::refresh();
}
}
}

View File

@ -16,7 +16,7 @@ class PivotProduction extends Model
public $hasMany = [
'pivot_production_calculate' => [
'Romanah\Gokbakja\Models\ProductionCalculate',
'key' => 'prev_pivot_id',
'key' => 'current_pivot_id',
'softDelete' => true
]
];

View File

@ -22,8 +22,7 @@ class Production extends Model
],
'pivot_production_calculation' => [
'Romanah\Gokbakja\Models\ProductionCalculate',
'key' => 'production_id',
'softDelete' => true
'key' => 'production_id'
]
];

View File

@ -229,9 +229,18 @@ function onStart() {
</tr>
</thead>
<tbody>
{% set allCalc = 0 %}
{% set allCalcDefect = 0 %}
{% set allCalcDefectRep = 0 %}
{% set allAmountSum = 0 %}
{% for key, report in reportDatas %}
{% set allCalc = (allCalc + report.amount) %}
{% set allCalcDefect = (allCalcDefect + report.defective) %}
{% set allCalcDefectRep = (allCalcDefectRep + report.defectiveRepair) %}
{% set allAmountSum = (allAmountSum + report.all) %}
<tr>
<td style="font-weight: bold;">{{key + 1}}</td>
<td><a href="#" style="font-weight: bold;">{{report.bag_gram}}</a></td>
@ -255,16 +264,13 @@ function onStart() {
</tbody>
<tfoot>
<tr>
<th style="width: 5%;"></th>
<th>Gram</th>
<th>Ini</th>
<th>Boýy</th>
<th>Reňki</th>
<th>Öndürilen Haltasy (arassa)</th>
<th>Öndürilen Haltasy (brak)</th>
<th>Sürülmedik haltalar</th>
<th>Jemi öndüren haltasy</th>
<th>Şuwagtky Ýagdaýy</th>
<th colspan="5" style="width: 5%;">Jemi</th>
<th>{{allCalc|number_format(2)}}</th>
<th>{{allCalcDefect|number_format(2)}}</th>
<th>{{allCalcDefectRep|number_format(2)}}</th>
<th>{{allAmountSum|number_format(2)}}</th>
<th></th>
</tr>
</tfoot>
</table>

View File

@ -16,6 +16,27 @@ function onStart(){
->orderBy('id', 'DESC')
->get();
if($filter == 'filter'){
$start = Carbon\Carbon::parse(post("start"))->format('Y-m-d');
$end = Carbon\Carbon::parse(post("end"))->format('Y-m-d');
$this["rulons"] = Romanah\Gokbakja\Models\BagAction::select('romanah_gokbakja_bag_actions.*')
->with(['product.rulon_action.product.bag_type', 'product.rulon_action.product.color', 'product.pivot_sewer', 'product.pivot_sewer_lst', 'product.rulon_action.product'])
->whereHas('product', function($q){
$q->where('is_sewed', 1);
})
->whereHas('product.rulon_action.product', function($qq) use ($start, $end){
$qq->whereBetween('date', [$start, $end]);
})
->orderBy('id', 'DESC')
->groupBy('romanah_gokbakja_bag_actions.product_id')
->get();
}
//dd($this["rulons"]);
}
?>
@ -48,7 +69,7 @@ function onStart(){
<div class="col-md-12">
<div class="card">
<div class="card-body">
<form action="/machine/rulon-bags/filter">
<form action="/machine/rulon-bags/filter" method="POST">
<div class="row">
<div class="col">
@ -139,6 +160,14 @@ function onStart(){
</tr>
</thead>
<tbody>
{% set allCalc = 0 %}
{% set allCalcDefective = 0 %}
{% set allCalcDefectiveRep = 0 %}
{% set allCalcAmount = 0 %}
{% set allCalcKg = 0 %}
{% set pipeAllCalc = 0 %}
{% set allLeft = 0 %}
{% set allBrakPerc = 0 %}
{% for key, report in rulons %}
@ -150,9 +179,25 @@ function onStart(){
{% set percentDefective = ((report.product.defective_bag_qty * 100) / report.amount) %}
{% set allCalc = (allCalc + report.amount) %}
{% set allCalcDefective = (allCalcDefective + report.product.defective_bag_qty) %}
{% set allCalcDefectiveRep = (allCalcDefectiveRep + report.product.defective_repair_qty) %}
{% set allCalcAmount = (allCalcAmount + sumOfBags) %}
{% set allCalcKg = (allCalcKg + allInKg) %}
{% set pipeAllCalc = (pipeAllCalc + report.product.pipe_weight) %}
{% set allLeft = (allLeft + report.product.pivot_sewer_lst.left_amount) %}
{% set allBrakPerc = (allBrakPerc + percentDefective) %}
<tr>
<td style="font-weight: bold;">{{key+1}}</td>
<td><a href="#" style="font-weight: bold;">{{report.product.rulon_action.created_at|date('d.m.Y')}}</a></td>
<td><a href="#" style="font-weight: bold;">{{report.product.rulon_action.product.date|date('d.m.Y')}}</a></td>
<td>{{report.product.rulon_action.product.machine.name}}</td>
<td>{{report.product.rulon_action.product.color.name}}</td>
<td>{{report.product.rulon_action.product.width}}</td>
@ -183,6 +228,25 @@ function onStart(){
{% endfor %}
</tbody>
<tfoot>
<tr>
<th colspan="10">JEMI</th>
<th>{{allCalc|number_format(2)}}</th>
<th>{{allCalcDefective|number_format(2)}}</th>
<th>{{allCalcDefectiveRep|number_format(2)}}</th>
<th>{{allCalcAmount|number_format(2)}}</th>
<th>{{allCalcKg|number_format(2)}}</th>
<th>{{pipeAllCalc|number_format(2)}}</th>
<th>{{allLeft|number_format(2)}}</th>
<th>{{allBrakPerc|number_format(2)}}</th>
</tr>
</tfoot>
</table>
<!-- <table class="table table-bordered dt-responsive nowrap">
<tfoot>
<tr>
<th>NO</th>
@ -210,7 +274,7 @@ function onStart(){
<th>Brak %</th>
</tr>
</tfoot>
</table>
</table> -->
</div>

View File

@ -64,7 +64,7 @@ function onStart(){
{% if crudExtrudor %}
<div class="collapse multi-collapse show" id="multiCollapseExample1">
<div class="row">
<div class="col-lg" data-bs-toggle="collapse" href="#multiCollapseExample1" role="button"
<div class="col-md-3" data-bs-toggle="collapse" href="#multiCollapseExample1" role="button"
aria-expanded="false" aria-controls="multiCollapseExample1">
<a class="card bg-success text-white-50">
<div class="card-body">
@ -197,9 +197,9 @@ function onStart(){
<th>Smen</th>
<th>Ekskruiter</th>
<th>Hemmesi</th>
{% for key, record in records %}
<th>{{record.code}}</th>
{% endfor %}
<th>HARYTLAR</th>
<th>Bellik</th>
<th>Sazlama</th>
<!-- <th>Настройки</th> -->
@ -221,15 +221,18 @@ function onStart(){
<span class="badge badge-soft-success"
style="font-size: 14px;">{{report.all_amount|number_format}} kg</span>
</td>
{% for product in report.pivot_production %}
<td>
<div class="row">
{% for product in report.pivot_production %}
<div class="col">
{% if report.user_id == user.id %}
{{product.product_code}}:
<a href="#" data-bs-toggle="modal"
data-bs-target=".bs-example-modal-sm-{{product.id}}">
{% if product.amount_percentage %}
{{product.amount_percentage|number_format(2)}} %
{{product.amount_percentage|number_format(2)}} %
{% else %}
0 %
{% endif %}
@ -237,10 +240,10 @@ function onStart(){
{% else %}
<a href="#">{{product.amount_percentage|number_format(2)}} %</a>
{{product.product_code}}: <a href="#">{{product.amount_percentage|number_format(2)}} %</a>
{% endif %}
</td>
</div>
{% if crudExtrudor %}
{% if report.user_id == user.id %}
@ -276,7 +279,8 @@ function onStart(){
{% endif %}
{% endfor %}
</div>
</td>
<td style="font-weight: bold;color: #0005c5;">{{report.note}}</td>
<td>
{% if crudExtrudor %}
@ -300,7 +304,7 @@ function onStart(){
</tbody>
<tfoot>
<!-- <tfoot>
<tr>
<th style="width: 5%;"></th>
<th>Senesi</th>
@ -313,7 +317,7 @@ function onStart(){
<th>Bellik</th>
<th>Sazlama</th>
</tr>
</tfoot>
</tfoot> -->
</table>
</div>
@ -333,41 +337,41 @@ function onStart(){
<script>
$(document).ready(function () {
var prodCount = document.getElementById('product_count').innerHTML;
// $(document).ready(function () {
// var prodCount = document.getElementById('product_count').innerHTML;
for (let i = 0; i < prodCount; i++) {
// for (let i = 0; i < prodCount; i++) {
$("#product_" + i).hover(function () {
$(this).attr("ishoveredin", 1);
$(this).stop(true, false).animate({
width: "200px"
});
}, function () {
$(this).attr("ishoveredin", 0);
if ($(this).attr("isfocusedin") != 1)
$(this).stop(true, false).animate({
width: "100%"
});
});
// $("#product_" + i).hover(function () {
// $(this).attr("ishoveredin", 1);
// $(this).stop(true, false).animate({
// width: "200px"
// });
// }, function () {
// $(this).attr("ishoveredin", 0);
// if ($(this).attr("isfocusedin") != 1)
// $(this).stop(true, false).animate({
// width: "100%"
// });
// });
$("#product_" + i).focus(function () {
$(this).attr("isfocusedin", 1);
$(this).stop(true, false).animate({
width: "200px"
});
});
// $("#product_" + i).focus(function () {
// $(this).attr("isfocusedin", 1);
// $(this).stop(true, false).animate({
// width: "200px"
// });
// });
$("#product_" + i).blur(function () {
$(this).attr("isfocusedin", 0);
$(this).stop(true, false).animate({
width: "100%"
});
});
// $("#product_" + i).blur(function () {
// $(this).attr("isfocusedin", 0);
// $(this).stop(true, false).animate({
// width: "100%"
// });
// });
}
// }
});
// });
function backStep1() {
document.getElementById("step1").setAttribute("style", "display:contents");