new database

This commit is contained in:
Shohrat 2023-12-27 15:23:59 +05:00
parent 8eb7c745f2
commit 379ee8bf07
1 changed files with 67 additions and 14 deletions

View File

@ -21,8 +21,28 @@ function onStart() {
if($year){
$startDate = Carbon\Carbon::create($year, $this["month"], 1);
$endDate = $startDate->endOfMonth();
$formattedStartDate = $startDate->format('Y-m-d');
$formattedEndDate = $endDate->format('Y-m-d');
$reportDatas = [];
//dd($action);
//$action = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
//->join('romanah_gokbakja_production_machine', 'romanah_gokbakja_rulon_action.product_id', 'romanah_gokbakja_production_machine.id')
//->where('romanah_gokbakja_production_machine.date', '<', $formattedStartDate)
//->addSelect('romanah_gokbakja_production_machine.width', 'romanah_gokbakja_production_machine.gram')
//->groupBy('romanah_gokbakja_production_machine.width')
//->groupBy('romanah_gokbakja_production_machine.gram')
//->addSelect(DB::raw('SUM(romanah_gokbakja_rulon_action.amount) as startDateSum'))
//->orderBy('romanah_gokbakja_production_machine.width', 'ASC')
//->get()->toArray();
$rulonProds = Romanah\Gokbakja\Models\ProductionMachine::select('gram', 'width')
->whereMonth('date', $this["month"])
->whereYear('date', $year)
@ -35,16 +55,25 @@ function onStart() {
$action = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
->with('product')
->whereHas('product', function($qq) use($rulonProds, $x){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->whereYear('date', $year)->whereMonth('date', $this["month"]);
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
})
->sum('amount');
$endAction = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
->with('product')
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
})
->sum('amount');
$actionIn = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
->with('product')
->where('type', 'inbox')
->whereHas('product', function($qq) use($rulonProds, $x){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->whereYear('date', $year)->whereMonth('date', $this["month"]);
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
})
->sum('amount');
@ -52,14 +81,17 @@ function onStart() {
$actionOut = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
->with('product')
->where('type', 'outbox')
->whereHas('product', function($qq) use($rulonProds, $x){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->whereYear('date', $year)->whereMonth('date', $this["month"]);
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '>', $formattedEndDate);
})
->sum('amount');
$reportDatas[$x]["gram"] = $rulonProds[$x]->gram;
$reportDatas[$x]["width"] = $rulonProds[$x]->width;
$reportDatas[$x]["start_month"] = $action;
$reportDatas[$x]["end_month"] = $endAction;
$reportDatas[$x]["in"] = $actionIn;
$reportDatas[$x]["out"] = $actionOut;
@ -67,11 +99,17 @@ function onStart() {
$this['reportDatas'] = $reportDatas;
}else{
$startDate = Carbon\Carbon::create($year, $this["month"], 1);
$endDate = $startDate->endOfMonth();
$formattedStartDate = $startDate->format('Y-m-d');
$formattedEndDate = $endDate->format('Y-m-d');
$reportDatas = [];
$rulonProds = Romanah\Gokbakja\Models\ProductionMachine::select('gram', 'width')
->whereMonth('created_at', $this["month"])
->whereYear('created_at', $currentDate->year)
->whereMonth('date', $this["month"])
->whereYear('date', $currentDate->year)
->groupBy('gram')->groupBy('width')
->orderBy('width', 'ASC')
->distinct()
@ -81,16 +119,25 @@ function onStart() {
$action = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
->with('product')
->whereHas('product', function($qq) use($rulonProds, $x, $currentDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->whereYear('date', $currentDate->year)->whereMonth('date', $this["month"]);
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
})
->sum('amount');
$endAction = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
->with('product')
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '>', $formattedEndDate);
})
->sum('amount');
$actionIn = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
->with('product')
->where('type', 'inbox')
->whereHas('product', function($qq) use($rulonProds, $x, $currentDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->whereYear('date', $currentDate->year)->whereMonth('date', $this["month"]);
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
})
->sum('amount');
@ -98,14 +145,17 @@ function onStart() {
$actionOut = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
->with('product')
->where('type', 'outbox')
->whereHas('product', function($qq) use($rulonProds, $x, $currentDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->whereYear('date', $currentDate->year)->whereMonth('date', $this["month"]);
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '>', $formattedEndDate);
})
->sum('amount');
$reportDatas[$x]["gram"] = $rulonProds[$x]->gram;
$reportDatas[$x]["width"] = $rulonProds[$x]->width;
$reportDatas[$x]["start_month"] = $action;
$reportDatas[$x]["end_month"] = $endAction;
$reportDatas[$x]["in"] = $actionIn;
$reportDatas[$x]["out"] = $actionOut;
@ -194,6 +244,7 @@ function onStart() {
<th>Aýyň Başyna</th>
<th>Gelen</th>
<th>Giden</th>
<th>Aýyň Soňuna</th>
<!-- <th>Настройки</th> -->
</tr>
</thead>
@ -207,6 +258,7 @@ function onStart() {
<td>{{report.start_month}}</td>
<td style="color: darkgreen;">{{report.in}}</td>
<td style="color: darkred;">{{report.out}}</td>
<td>{{report.end_month}}</td>
</tr>
{% endfor %}
@ -222,6 +274,7 @@ function onStart() {
<th>Aýyň Başyna</th>
<th>Gelen</th>
<th>Giden</th>
<th>Aýyň Soňuna</th>
</tr>
</tfoot>
</table>