106 lines
3.0 KiB
PHP
106 lines
3.0 KiB
PHP
<?php
|
|
|
|
namespace Romanah\Gokbakja\Components;
|
|
|
|
use Cms\Classes\ComponentBase;
|
|
use Romanah\Gokbakja\Models\Production as ProductionModel;
|
|
use Romanah\Gokbakja\Models\PivotProduction as PivotProductionModel;
|
|
use Romanah\Gokbakja\Models\SewerProduction as SewerModel;
|
|
use Redirect;
|
|
use Carbon\Carbon;
|
|
use Flash;
|
|
use DB;
|
|
|
|
class Sewer extends ComponentBase
|
|
{
|
|
|
|
public $sewers;
|
|
|
|
public function componentDetails()
|
|
{
|
|
return [
|
|
'name' => 'Sewer',
|
|
'description' => 'Sewer settings'
|
|
];
|
|
}
|
|
|
|
|
|
|
|
// public function onRun() {
|
|
// $this->sewers = $this->loadSewers();
|
|
// }
|
|
|
|
|
|
|
|
public function onRender(){
|
|
|
|
$html_data = '';
|
|
|
|
$sewerDatas = SewerModel::with("employee")->orderBy('id', 'DESC')->get();
|
|
|
|
for ($x = 0; $x < count($sewerDatas); $x++) {
|
|
$html_data .= '<tr>
|
|
<td style="font-weight: bold;">'.($x+1).'</td>
|
|
<td><a href="#" style="font-weight: bold;">'.$sewerDatas[$x]->employee->name.'</a></td>
|
|
<td>'.$sewerDatas[$x]->created_at->format('m.d.Y').'</td>
|
|
<td><span class="badge badge-soft-success"
|
|
style="font-size: 14px;">'.$sewerDatas[$x]->amount.' kg</span>
|
|
</td>
|
|
<td>'.$sewerDatas[$x]->produced_bag_qty.'</td>
|
|
<td>'.$sewerDatas[$x]->note.'</td>
|
|
</tr>';
|
|
}
|
|
|
|
return $html_data;
|
|
}
|
|
|
|
|
|
public function onCreateSewerProduction()
|
|
{
|
|
$currentDate = Carbon::now()->timezone('UTC +05:00');
|
|
|
|
$currentDateFormat = $currentDate->format('Y-m-d');
|
|
|
|
$data = post();
|
|
|
|
$createSewer = new SewerModel();
|
|
$createSewer->employee_id = $data["employee_id"];
|
|
$createSewer->amount = $data["amount"];
|
|
$createSewer->produced_bag_qty = $data["produced_bag_qty"];
|
|
$createSewer->note = $data["note"];
|
|
$createSewer->save();
|
|
|
|
|
|
$html_data = '';
|
|
|
|
$sewerDatas = SewerModel::with("employee")->orderBy('id', 'DESC')->get();
|
|
|
|
for ($x = 0; $x < count($sewerDatas); $x++) {
|
|
$html_data .= '<tr>
|
|
<td style="font-weight: bold;">'.($x+1).'</td>
|
|
<td><a href="#" style="font-weight: bold;">'.$sewerDatas[$x]->employee->name.'</a></td>
|
|
<td>'.$sewerDatas[$x]->created_at->format('m.d.Y').'</td>
|
|
<td><span class="badge badge-soft-success"
|
|
style="font-size: 14px;">'.$sewerDatas[$x]->amount.' kg</span>
|
|
</td>
|
|
<td>'.$sewerDatas[$x]->produced_bag_qty.'</td>
|
|
<td>'.$sewerDatas[$x]->note.'</td>
|
|
</tr>';
|
|
}
|
|
|
|
if($createSewer){
|
|
|
|
Flash::success("Hasabat Ustunlikli Goşuldy");
|
|
return [
|
|
'#sewer_datas' => $html_data,
|
|
];
|
|
}else{
|
|
return Flash::error("Yalnyshlyk bar!!");
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|