diff --git a/plugins/romanah/gokbakja/components/Production.php b/plugins/romanah/gokbakja/components/Production.php index 0aa6ae0..363f203 100644 --- a/plugins/romanah/gokbakja/components/Production.php +++ b/plugins/romanah/gokbakja/components/Production.php @@ -8,6 +8,7 @@ use Romanah\Gokbakja\Models\Production as ProductionModel; use Romanah\Gokbakja\Models\ProductionMachine as ProductionMachineModel; use Romanah\Gokbakja\Models\PivotProduction as PivotProductionModel; use Redirect; +use Carbon\Carbon; use Flash; class Production extends ComponentBase @@ -40,28 +41,63 @@ class Production extends ComponentBase $productionMachine = ProductionMachineModel::where('id', $createProductionMachine->id)->with(['machine.employee', 'machine.mechanic', 'machine.building'])->first(); // dd($productionMachine->machine->name); - if($productionMachine){ + if ($productionMachine) { $updateResult = ProductionMachineModel::where('id', $productionMachine->id) - ->update(array( - 'employee_id' => $productionMachine->machine->employee->id, - 'mechanic_id' => $productionMachine->machine->mechanic->id, - 'employee_name' => $productionMachine->machine->employee->name, - 'mechanic_name' => $productionMachine->machine->mechanic->name, - 'building_name' => $productionMachine->machine->building->name, - )); + ->update(array( + 'employee_id' => $productionMachine->machine->employee->id, + 'mechanic_id' => $productionMachine->machine->mechanic->id, + 'employee_name' => $productionMachine->machine->employee->name, + 'mechanic_name' => $productionMachine->machine->mechanic->name, + 'building_name' => $productionMachine->machine->building->name, + )); } if ($createProductionMachine && $updateResult) { Flash::success("Hasabat Ustunlikli Goşuldy"); return Redirect::refresh(); } + } + function onCalculateAvg(){ + $currentDate = Carbon::now()->timezone('UTC +05:00'); + + $currentDateFormat = $currentDate->format('Y-m-d'); + + $data = post(); + + $sumPercentage = PivotProductionModel::where('product_id', $data["prod_id"])->whereDate('created_at', date($currentDateFormat))->sum('amount_percentage'); + + $sumPercentageCount = PivotProductionModel::where('product_id', $data["prod_id"])->whereDate('created_at', date($currentDateFormat))->count('amount_percentage'); + + $sumAmount = PivotProductionModel::where('product_id', $data["prod_id"])->whereDate('created_at', date($currentDateFormat))->sum('amount'); + + $sumAmountcount = PivotProductionModel::where('product_id', $data["prod_id"])->whereDate('created_at', date($currentDateFormat))->count('amount'); + + dd($sumPercentage / $sumPercentageCount); + dd(($sumPercentage + (int) $data["field_value"]) / ($sumPercentageCount + 1)); + + $calcAvgPerc = ($sumPercentage + (int) $data["field_value"]) / ($sumPercentageCount + 1); + // $calcAvgAmount = ($sumPercentage + (int) $data["field_value"]) / ($sumPercentageCount + 1); + + + $allData = array( + "avg_percentage" => $calcAvgPerc, + "avg_amount" => '000' + ); + + return $allData; + // dd($currentDateFormat); } public function onCreateProduction() { $user = \Auth::user(); + $currentDate = Carbon::now()->timezone('UTC +05:00'); + + // $this["currentMonth"] = $currentDate->format('m'); + + $data = post(); $createProduction = new ProductionModel(); @@ -69,12 +105,15 @@ class Production extends ComponentBase $createProduction->all_amount = $data["all_amount"]; $createProduction->note = $data["note"]; $createProduction->user_id = $user->id; + $createProduction->date = $currentDate->format('Y-m-d'); + $createProduction->time = $currentDate->format('H:i:s'); + $createProduction->excruiter_id = 1; $createProduction->save(); $products = ProductModel::where("report", "simple")->get(); for ($x = 0; $x < count($products); $x++) { - $fieldName = "product_".$products[$x]->code; + $fieldName = "product_" . $products[$x]->code; $createPivotProduction = new PivotProductionModel(); $createPivotProduction->production_id = $createProduction->id; @@ -90,7 +129,6 @@ class Production extends ComponentBase Flash::success("Hasabat Ustunlikli Goşuldy"); return Redirect::refresh(); } - } public function onUpdateProduction() diff --git a/plugins/romanah/gokbakja/controllers/Excruiter.php b/plugins/romanah/gokbakja/controllers/Excruiter.php new file mode 100644 index 0000000..860943b --- /dev/null +++ b/plugins/romanah/gokbakja/controllers/Excruiter.php @@ -0,0 +1,18 @@ + + = e(trans('backend::lang.form.create')) ?> + + diff --git a/plugins/romanah/gokbakja/controllers/excruiter/config_form.yaml b/plugins/romanah/gokbakja/controllers/excruiter/config_form.yaml new file mode 100644 index 0000000..d379764 --- /dev/null +++ b/plugins/romanah/gokbakja/controllers/excruiter/config_form.yaml @@ -0,0 +1,10 @@ +name: Excruiter +form: $/romanah/gokbakja/models/excruiter/fields.yaml +modelClass: Romanah\Gokbakja\Models\Excruiter +defaultRedirect: romanah/gokbakja/excruiter +create: + redirect: 'romanah/gokbakja/excruiter/update/:id' + redirectClose: romanah/gokbakja/excruiter +update: + redirect: romanah/gokbakja/excruiter + redirectClose: romanah/gokbakja/excruiter diff --git a/plugins/romanah/gokbakja/controllers/excruiter/config_list.yaml b/plugins/romanah/gokbakja/controllers/excruiter/config_list.yaml new file mode 100644 index 0000000..e3f8391 --- /dev/null +++ b/plugins/romanah/gokbakja/controllers/excruiter/config_list.yaml @@ -0,0 +1,12 @@ +list: $/romanah/gokbakja/models/excruiter/columns.yaml +modelClass: Romanah\Gokbakja\Models\Excruiter +title: Excruiter +noRecordsMessage: 'backend::lang.list.no_records' +showSetup: true +showCheckboxes: true +recordsPerPage: 20 +toolbar: + buttons: list_toolbar + search: + prompt: 'backend::lang.list.search_prompt' +recordUrl: 'romanah/gokbakja/excruiter/update/:id' diff --git a/plugins/romanah/gokbakja/controllers/excruiter/create.htm b/plugins/romanah/gokbakja/controllers/excruiter/create.htm new file mode 100644 index 0000000..ad164f0 --- /dev/null +++ b/plugins/romanah/gokbakja/controllers/excruiter/create.htm @@ -0,0 +1,46 @@ + +
= e(trans('backend::lang.form.return_to_list')) ?>
+ \ No newline at end of file diff --git a/plugins/romanah/gokbakja/controllers/excruiter/index.htm b/plugins/romanah/gokbakja/controllers/excruiter/index.htm new file mode 100644 index 0000000..ea43a36 --- /dev/null +++ b/plugins/romanah/gokbakja/controllers/excruiter/index.htm @@ -0,0 +1 @@ += $this->listRender() ?> diff --git a/plugins/romanah/gokbakja/controllers/excruiter/preview.htm b/plugins/romanah/gokbakja/controllers/excruiter/preview.htm new file mode 100644 index 0000000..018c70e --- /dev/null +++ b/plugins/romanah/gokbakja/controllers/excruiter/preview.htm @@ -0,0 +1,22 @@ + ++ + = e(trans('backend::lang.form.return_to_list')) ?> + +
\ No newline at end of file diff --git a/plugins/romanah/gokbakja/controllers/excruiter/update.htm b/plugins/romanah/gokbakja/controllers/excruiter/update.htm new file mode 100644 index 0000000..93ed05b --- /dev/null +++ b/plugins/romanah/gokbakja/controllers/excruiter/update.htm @@ -0,0 +1,54 @@ + += e(trans('backend::lang.form.return_to_list')) ?>
+ \ No newline at end of file diff --git a/plugins/romanah/gokbakja/models/Excruiter.php b/plugins/romanah/gokbakja/models/Excruiter.php new file mode 100644 index 0000000..4d0040a --- /dev/null +++ b/plugins/romanah/gokbakja/models/Excruiter.php @@ -0,0 +1,33 @@ + [ + 'Romanah\Gokbakja\Models\Production', + 'key' => 'excruiter_id' + ] + ]; + + /** + * @var string The database table used by the model. + */ + public $table = 'romanah_gokbakja_excruiter'; + + /** + * @var array Validation rules + */ + public $rules = [ + ]; +} diff --git a/plugins/romanah/gokbakja/models/Production.php b/plugins/romanah/gokbakja/models/Production.php index 1e30588..1f19af3 100644 --- a/plugins/romanah/gokbakja/models/Production.php +++ b/plugins/romanah/gokbakja/models/Production.php @@ -21,6 +21,13 @@ class Production extends Model ] ]; + public $belongsTo = [ + 'excruiter' => [ + 'Romanah\Gokbakja\Models\Excruiter', + 'key' => 'excruiter_id' + ] + ]; + 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')) diff --git a/plugins/romanah/gokbakja/models/excruiter/columns.yaml b/plugins/romanah/gokbakja/models/excruiter/columns.yaml new file mode 100644 index 0000000..078925f --- /dev/null +++ b/plugins/romanah/gokbakja/models/excruiter/columns.yaml @@ -0,0 +1,10 @@ +columns: + id: + label: id + type: number + name: + label: name + type: text + note: + label: note + type: text diff --git a/plugins/romanah/gokbakja/models/excruiter/fields.yaml b/plugins/romanah/gokbakja/models/excruiter/fields.yaml new file mode 100644 index 0000000..a3908d3 --- /dev/null +++ b/plugins/romanah/gokbakja/models/excruiter/fields.yaml @@ -0,0 +1,9 @@ +fields: + name: + label: Name + span: auto + type: text + note: + label: Note + span: auto + type: textarea diff --git a/plugins/romanah/gokbakja/models/production/columns.yaml b/plugins/romanah/gokbakja/models/production/columns.yaml index f205905..b169905 100644 --- a/plugins/romanah/gokbakja/models/production/columns.yaml +++ b/plugins/romanah/gokbakja/models/production/columns.yaml @@ -11,3 +11,8 @@ columns: note: label: note type: text + excruiter_id: + label: Ekskruiter + type: text + select: name + relation: excruiter diff --git a/plugins/romanah/gokbakja/models/production/fields.yaml b/plugins/romanah/gokbakja/models/production/fields.yaml index 7ea5558..e854b84 100644 --- a/plugins/romanah/gokbakja/models/production/fields.yaml +++ b/plugins/romanah/gokbakja/models/production/fields.yaml @@ -5,9 +5,21 @@ fields: type: number date: label: Date + mode: date span: auto type: datepicker note: label: Note span: auto type: textarea + time: + label: Time + mode: time + span: auto + type: datepicker + excruiter: + label: Ekskruiter + span: auto + nameFrom: name + descriptionFrom: description + type: relation diff --git a/plugins/romanah/gokbakja/plugin.yaml b/plugins/romanah/gokbakja/plugin.yaml index c2876b9..f152530 100644 --- a/plugins/romanah/gokbakja/plugin.yaml +++ b/plugins/romanah/gokbakja/plugin.yaml @@ -65,3 +65,7 @@ navigation: label: Enjamlar url: romanah/gokbakja/machine icon: icon-codepen + side-menu-item2: + label: Eksruiterler + url: romanah/gokbakja/excruiter + icon: icon-steam diff --git a/plugins/romanah/gokbakja/updates/builder_table_create_romanah_gokbakja_excruiter.php b/plugins/romanah/gokbakja/updates/builder_table_create_romanah_gokbakja_excruiter.php new file mode 100644 index 0000000..3db7768 --- /dev/null +++ b/plugins/romanah/gokbakja/updates/builder_table_create_romanah_gokbakja_excruiter.php @@ -0,0 +1,26 @@ +engine = 'InnoDB'; + $table->increments('id')->unsigned(); + $table->timestamp('created_at')->nullable(); + $table->timestamp('updated_at')->nullable(); + $table->timestamp('deleted_at')->nullable(); + $table->text('name')->nullable(); + $table->text('note')->nullable(); + }); + } + + public function down() + { + Schema::dropIfExists('romanah_gokbakja_excruiter'); + } +} diff --git a/plugins/romanah/gokbakja/updates/builder_table_update_romanah_gokbakja_production_5.php b/plugins/romanah/gokbakja/updates/builder_table_update_romanah_gokbakja_production_5.php new file mode 100644 index 0000000..b02a202 --- /dev/null +++ b/plugins/romanah/gokbakja/updates/builder_table_update_romanah_gokbakja_production_5.php @@ -0,0 +1,25 @@ +time('time'); + $table->date('date')->nullable()->unsigned(false)->default(null)->comment(null)->change(); + }); + } + + public function down() + { + Schema::table('romanah_gokbakja_production', function($table) + { + $table->dropColumn('time'); + $table->dateTime('date')->nullable()->unsigned(false)->default(null)->comment(null)->change(); + }); + } +} diff --git a/plugins/romanah/gokbakja/updates/builder_table_update_romanah_gokbakja_production_6.php b/plugins/romanah/gokbakja/updates/builder_table_update_romanah_gokbakja_production_6.php new file mode 100644 index 0000000..d0d72cb --- /dev/null +++ b/plugins/romanah/gokbakja/updates/builder_table_update_romanah_gokbakja_production_6.php @@ -0,0 +1,23 @@ +integer('excruiter_id'); + }); + } + + public function down() + { + Schema::table('romanah_gokbakja_production', function($table) + { + $table->dropColumn('excruiter_id'); + }); + } +} diff --git a/plugins/romanah/gokbakja/updates/version.yaml b/plugins/romanah/gokbakja/updates/version.yaml index b69ad71..dc910c7 100644 --- a/plugins/romanah/gokbakja/updates/version.yaml +++ b/plugins/romanah/gokbakja/updates/version.yaml @@ -111,3 +111,12 @@ 1.0.38: - 'Updated table romanah_gokbakja_production_machine' - builder_table_update_romanah_gokbakja_production_machine_4.php +1.0.39: + - 'Updated table romanah_gokbakja_production' + - builder_table_update_romanah_gokbakja_production_5.php +1.0.40: + - 'Created table romanah_gokbakja_excruiter' + - builder_table_create_romanah_gokbakja_excruiter.php +1.0.41: + - 'Updated table romanah_gokbakja_production' + - builder_table_update_romanah_gokbakja_production_6.php diff --git a/themes/gokbakja/pages/production.htm b/themes/gokbakja/pages/production.htm index b3624f7..1c5a9d4 100644 --- a/themes/gokbakja/pages/production.htm +++ b/themes/gokbakja/pages/production.htm @@ -26,7 +26,9 @@ function onStart(){ $this["currentMonth"] = $currentDate->format('m'); $this["currentYear"] = $currentDate->format('Y'); - $this["productions"] = Romanah\Gokbakja\Models\Production::whereDate('created_at', date($currentDateFormat))->with(['pivot_production'])->get(); + $this["productions"] = Romanah\Gokbakja\Models\Production::whereDate('created_at', date($currentDateFormat))->with(['pivot_production'])->orderBy('id', 'DESC')->get(); + + $this["productCounts"] = Romanah\Gokbakja\Models\Product::where('report', 'simple')->count(); } ?> @@ -52,7 +54,7 @@ function onStart(){{{productCounts}}
+ {% for key, record in records %} +{{record.id}}
+ {% endfor %}| Täze maglumat | + placeholder="JEMI" onchange="getAllAmount(this.value);"> | {% for key, record in records %}- | {% endfor %} @@ -152,7 +180,8 @@ function onStart(){ {% for key, report in productions %}||||
|---|---|---|---|---|---|---|
| {{key + 1}} | -{{report.created_at|date('d.m.Y | + | {{report.created_at|date('d.m.Y | H:i')}} | {% for product in report.pivot_production %} - | {{product.amount_percentage}} % {% if product.amount != 0 %} {{product.amount|number_format}} kg {% endif %} |
+ {{product.amount_percentage|number_format(2)}} % + + | {% endfor %}{{report.note}} | @@ -191,3 +224,51 @@ function onStart(){ {% partial 'dataTableJs' %} + +{% put scripts %} + + + +{% endput %}