production

This commit is contained in:
Shohrat 2023-09-19 01:22:50 +05:00
parent 9065d818bd
commit 88e6915828
9 changed files with 340 additions and 42 deletions

View File

@ -8,6 +8,7 @@ class Plugin extends PluginBase
{
return [
'Romanah\Gokbakja\Components\Action' => 'action',
'Romanah\Gokbakja\Components\Production' => 'production',
];
}

View File

@ -3,6 +3,7 @@
namespace Romanah\Gokbakja\Components;
use Cms\Classes\ComponentBase;
use Romanah\Gokbakja\Models\Product as ProductModel;
use Romanah\Gokbakja\Models\Production as ProductionModel;
use Romanah\Gokbakja\Models\PivotProduction as PivotProductionModel;
use Redirect;
@ -27,6 +28,33 @@ class Production extends ComponentBase
$data = post();
$createProduction = new ProductionModel();
$createProduction->all_amount = $data["all_amount"];
$createProduction->note = $data["note"];
$createProduction->user_id = $user->id;
$createProduction->save();
$products = ProductModel::where("report", "simple")->get();
for ($x = 0; $x < count($products); $x++) {
$fieldName = "product_".$products[$x]->code;
$createPivotProduction = new PivotProductionModel();
$createPivotProduction->production_id = $createProduction->id;
$createPivotProduction->product_id = $products[$x]->id;
$createPivotProduction->amount_percentage = $data[$fieldName];
$createPivotProduction->product_name = $products[$x]->name;
$createPivotProduction->product_code = $products[$x]->code;
$createPivotProduction->amount = ($data[$fieldName] / 100) * ($createProduction->all_amount);
$createPivotProduction->save();
}
if ($createProduction && $createPivotProduction) {
Flash::success("Hasabat Ustunlikli Goşuldy");
return Redirect::refresh();
}
}
public function onUpdateProduction()

View File

@ -1,7 +1,8 @@
<?php namespace Romanah\Gokbakja\Models;
use Model;
use Carbon\Carbon;
use DB;
/**
* Model
*/
@ -20,6 +21,13 @@ class Production extends Model
]
];
public function scopeGetByGroup($query)
{
return $query->select('id', 'created_at', 'all_amount', 'note', DB::raw('count(id) as `data`'), DB::raw("DATE_FORMAT(created_at, '%d-%m-%Y') new_date"), DB::raw('YEAR(created_at) year, MONTH(created_at) month, DAY(created_at) day'))
->orderBy('id', 'DESC')
->groupby('year','month', 'day');
}
/**

View File

@ -0,0 +1,23 @@
<?php namespace Romanah\Gokbakja\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableUpdateRomanahGokbakjaPivotProduction4 extends Migration
{
public function up()
{
Schema::table('romanah_gokbakja_pivot_production', function($table)
{
$table->renameColumn('amout', 'amount');
});
}
public function down()
{
Schema::table('romanah_gokbakja_pivot_production', function($table)
{
$table->renameColumn('amount', 'amout');
});
}
}

View File

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

View File

@ -0,0 +1,23 @@
<?php namespace Romanah\Gokbakja\Updates;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableUpdateRomanahGokbakjaProduction4 extends Migration
{
public function up()
{
Schema::table('romanah_gokbakja_production', function($table)
{
$table->dateTime('date')->nullable()->change();
});
}
public function down()
{
Schema::table('romanah_gokbakja_production', function($table)
{
$table->dateTime('date')->nullable(false)->change();
});
}
}

View File

@ -93,3 +93,12 @@
1.0.32:
- 'Updated table romanah_gokbakja_pivot_production'
- builder_table_update_romanah_gokbakja_pivot_production_3.php
1.0.33:
- 'Updated table romanah_gokbakja_production'
- builder_table_update_romanah_gokbakja_production_3.php
1.0.34:
- 'Updated table romanah_gokbakja_production'
- builder_table_update_romanah_gokbakja_production_4.php
1.0.35:
- 'Updated table romanah_gokbakja_pivot_production'
- builder_table_update_romanah_gokbakja_pivot_production_4.php

View File

@ -0,0 +1,165 @@
title = "All Productions"
url = "/all-productions"
layout = "platform_main"
is_hidden = 0
[builderList]
modelClass = "Romanah\Gokbakja\Models\Production"
scope = "scopeGetByGroup"
scopeValue = "{{ :scope }}"
displayColumn = "id"
noRecordsMessage = "No records found"
detailsPage = "-"
detailsUrlParameter = "id"
pageNumber = "{{ :page }}"
==
{% set productions = builderList.records %}
{% set displayColumn = builderList.displayColumn %}
{% set noRecordsMessage = builderList.noRecordsMessage %}
{% set detailsPage = builderList.detailsPage %}
{% set detailsKeyColumn = builderList.detailsKeyColumn %}
{% set detailsUrlParameter = builderList.detailsUrlParameter %}
{% put styles %}
<link href="{{'assets/libs/datatables.net-bs4/css/dataTables.bootstrap4.min.css'|theme}}" rel="stylesheet"
type="text/css" />
<link href="{{'assets/libs/datatables.net-buttons-bs4/css/buttons.bootstrap4.min.css'|theme}}" rel="stylesheet"
type="text/css" />
<link href="{{'assets/libs/datatables.net-select-bs4/css/select.bootstrap4.min.css'|theme}}" rel="stylesheet"
type="text/css" />
{% endput %}
<div class="container-fluid">
<div class="row">
<!-- <div class="col-lg-4">
<div class="card bg-primary text-white-50">
<div class="card-body">
<h5 class="mb-4 text-white"><i class="mdi mdi-bullseye-arrow me-3"></i> Primary Card</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="card bg-primary text-white-50">
<div class="card-body">
<h5 class="mb-4 text-white"><i class="mdi mdi-bullseye-arrow me-3"></i> Primary Card</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="card bg-primary text-white-50">
<div class="card-body">
<h5 class="mb-4 text-white"><i class="mdi mdi-bullseye-arrow me-3"></i> Primary Card</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
</div>
</div>
</div> -->
</div>
<!-- end row -->
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-6">
<h3 class="card-title" style="font-size: 22px;color: #1e2038;">Çig Mallar Boýunça Ähli</h3>
<p class="card-title-desc" style="color: #6c6ff5;">Hasabat</p>
</div>
<!-- <div class="col-md-6" style="text-align: right;">
<button type="button" class="btn btn-primary waves-effect waves-light"
data-bs-toggle="offcanvas" data-bs-target="#offcanvasBottom"
aria-controls="offcanvasBottom">
<i class="ri-add-line align-middle ms-2" style="font-size: 17px;"></i> Добавить
</button>
</div> -->
</div>
<table id="datatable-buttons" class="table table-striped table-bordered dt-responsive nowrap"
style="border-collapse: collapse; border-spacing: 0; width: 100%;">
<thead>
<tr>
<th style="width: 5%;"></th>
<th>Senesi</th>
<th>Mukdary</th>
<th>Bellik</th>
<!-- <th>Настройки</th> -->
</tr>
</thead>
<tbody>
{% for key, report in productions %}
<tr>
<td style="font-weight: bold;width: 5%;">{{key + 1}}</td>
<td><a href="#" style="font-weight: bold;color: #0005c5;">{{report.created_at|date("d.m.Y | H:i")}}</a></td>
<td>{{report.all_amount|number_format}}</td>
<td>{{report.note}}</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr>
<th style="width: 5%;"></th>
<th>Senesi</th>
<th>Mukdary</th>
<th>Bellik</th>
</tr>
</tfoot>
</table>
</div>
<div class="offcanvas offcanvas-top" tabindex="-1" id="offcanvasBottom"
aria-labelledby="offcanvasBottomLabel">
<div class="offcanvas-header">
<h5 id="offcanvasBottomLabel">Добавить Склад</h5>
<button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas"
aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<form class="needs-validation" novalidate action="/stocks/create" method="POST">
<div class="row">
<div class="col-md-6">
<div class="mb-3">
<label for="validationCustom01" class="form-label">Имя Склад</label>
<input type="text" class="form-control" id="validationCustom01"
placeholder="Имя Склад" name="name" required>
<div class="valid-feedback">
Правильно
</div>
</div>
</div>
<div class="col-md-6">
<div class="mb-3">
<label for="validationCustom02" class="form-label">Описание</label>
<input type="text" class="form-control" name="desc" id="validationCustom02"
placeholder="Описание" required>
<div class="valid-feedback">
Правильно
</div>
</div>
</div>
</div>
<div>
<button class="btn btn-primary" type="submit">Добавить</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
{% partial 'dataTableJs' %}

View File

@ -6,17 +6,24 @@ is_hidden = 0
[builderList]
modelClass = "Romanah\Gokbakja\Models\Product"
scope = "scopeGetReport"
scopeValue = "{{ :scope }}"
displayColumn = "id"
noRecordsMessage = "No records found"
detailsPage = "-"
detailsUrlParameter = "id"
pageNumber = "{{ :page }}"
[production]
==
<?php
function onStart(){
$this["productions"] = Romanah\Gokbakja\Models\Production::with(['pivot_production'])->get();
$this["currentDate"] = Carbon\Carbon::now();
$currentDate = Carbon\Carbon::now()->timezone('UTC +05:00');
$currentDateFormat = Carbon\Carbon::now()->format('Y-m-d');
$this["currentDate"] = $currentDate;
$this["productions"] = Romanah\Gokbakja\Models\Production::whereDate('created_at', date($currentDateFormat))->with(['pivot_production'])->get();
}
?>
==
@ -41,7 +48,23 @@ function onStart(){
<div class="container-fluid">
<div class="row">
<div class="col-lg-4">
<div class="col-lg-6">
<a href="/all-productions" class="card bg-primary text-white-50">
<div class="card-body">
<h5 class="mb-4 text-white"><i class="mdi mdi-bullseye-arrow me-3"></i> HEMMESI</h5>
<p class="card-text">Bu bölümde hasabatyň aýlar boýunça ählisini görüp bilersiňiz.</p>
</div>
</a>
</div>
<div class="col-lg-6">
<div class="card bg-primary text-white-50">
<div class="card-body">
<h5 class="mb-4 text-white"><i class="mdi mdi-bullseye-arrow me-3"></i> ORTAÇA ÖNÜMÇILIK</h5>
<p class="card-text">Bu bölümde ortaça önümçilik boýunça hasabat.</p>
</div>
</div>
</div>
<!-- <div class="col-lg-4">
<div class="card bg-primary text-white-50">
<div class="card-body">
<h5 class="mb-4 text-white"><i class="mdi mdi-bullseye-arrow me-3"></i> Primary Card</h5>
@ -49,25 +72,7 @@ function onStart(){
card's content.</p>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="card bg-primary text-white-50">
<div class="card-body">
<h5 class="mb-4 text-white"><i class="mdi mdi-bullseye-arrow me-3"></i> Primary Card</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
</div>
</div>
</div>
<div class="col-lg-4">
<div class="card bg-primary text-white-50">
<div class="card-body">
<h5 class="mb-4 text-white"><i class="mdi mdi-bullseye-arrow me-3"></i> Primary Card</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the
card's content.</p>
</div>
</div>
</div>
</div> -->
</div>
<!-- end row -->
@ -78,7 +83,7 @@ function onStart(){
<div class="row">
<div class="col-md-6">
<h3 class="card-title" style="font-size: 22px;color: #1e2038;">Çig Mallar Boýunça
({{currentDate|date('d.m.Y')}})</h3>
({{currentDate|date('d.m.Y | H:i')}})</h3>
<p class="card-title-desc" style="color: #6c6ff5;">Hasabat</p>
</div>
<!-- <div class="col-md-6" style="text-align: right;">
@ -90,27 +95,40 @@ function onStart(){
</div> -->
</div>
<h1>{{productions}}</h1>
<form>
<div class="table-responsive">
<table class="table mb-0">
<thead class="table-light">
<div class="table-responsive" style="margin-bottom: 20px;">
<table class="table mb-0">
<thead class="table-light">
<form data-request="onCreateProduction">
<tr>
<th style="width: 5%;"></th>
<th>Senesi</th>
<th>Hemmesi</th>
<th style="background: #daddff;">Täze maglumat</th>
<th style="background: #daddff;">
<input type="number" name="all_amount" class="form-control"
placeholder="JEMI">
</th>
{% for key, record in records %}
<th>{{record.name}}</th>
<th style="background: #daddff;">
<input type="number" name="product_{{record.code}}" class="form-control"
placeholder="{{record.name}} %">
</th>
{% endfor %}
<th>Bellik</th>
<th style="background: #daddff;">
<input type="text" name="note" class="form-control" placeholder="Bellik">
</th>
<th style="background: #daddff;">
<button type="submit"
class="btn btn-primary waves-effect waves-light">Goş</button>
</th>
</tr>
</form>
</thead>
</table>
</div>
</thead>
</table>
</div>
</form>
<table id="datatable-buttons" class="table table-striped table-bordered dt-responsive nowrap"
style="border-collapse: collapse; border-spacing: 0; width: 100%;">
<thead>
@ -127,21 +145,21 @@ function onStart(){
</thead>
<tbody>
{% for report in productions %}
{% for key, report in productions %}
<tr>
<td style="font-weight: bold;width: 5%;">{{key + 1}}</td>
<td><a href="#" style="font-weight: bold;color: #0005c5;">{{report.date|date('d.m.Y |
<td><a href="#" style="font-weight: bold;color: #0005c5;">{{report.created_at|date('d.m.Y |
H:i')}}</a></td>
<td style="text-align: center;">
<span class="badge badge-soft-success"
style="font-size: 14px;">{{report.all_amount|number_format}} kg</span>
</td>
{% for product in record.pivot_production %}
{% for product in report.pivot_production %}
<td>{{product.amount_percentage}} %</td>
{% endfor %}
<td>{{record.note}}</td>
<td style="font-weight: bold;color: #0005c5;">{{report.note}}</td>
</tr>
{% endfor %}