rulon report
This commit is contained in:
parent
379ee8bf07
commit
c370c735e8
|
|
@ -21,32 +21,23 @@ function onStart() {
|
||||||
|
|
||||||
|
|
||||||
if($year){
|
if($year){
|
||||||
|
$startDateOfYear = Carbon\Carbon::now()->startOfYear();
|
||||||
|
$formattedStartDateYear = $startDateOfYear->format('Y-m-d');
|
||||||
|
|
||||||
$startDate = Carbon\Carbon::create($year, $this["month"], 1);
|
$startDate = Carbon\Carbon::create($year, $this["month"], 1);
|
||||||
$endDate = $startDate->endOfMonth();
|
|
||||||
|
|
||||||
$formattedStartDate = $startDate->format('Y-m-d');
|
$formattedStartDate = $startDate->format('Y-m-d');
|
||||||
$formattedEndDate = $endDate->format('Y-m-d');
|
|
||||||
|
$endMonthDate = $startDate->endOfMonth();
|
||||||
|
$formattedEndDate = $endMonthDate->format('Y-m-d');
|
||||||
|
|
||||||
$reportDatas = [];
|
$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')
|
$rulonProds = Romanah\Gokbakja\Models\ProductionMachine::select('gram', 'width')
|
||||||
->whereMonth('date', $this["month"])
|
->whereMonth('date', $this["month"])
|
||||||
->whereYear('date', $year)
|
->whereYear('date', $year)
|
||||||
->groupBy('gram')->groupBy('width')
|
->groupBy('gram')->groupBy('width')
|
||||||
|
->orderBy('gram', 'ASC')
|
||||||
->orderBy('width', 'ASC')
|
->orderBy('width', 'ASC')
|
||||||
->distinct()
|
->distinct()
|
||||||
->get();
|
->get();
|
||||||
|
|
@ -55,16 +46,22 @@ function onStart() {
|
||||||
|
|
||||||
$action = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
|
$action = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
|
||||||
->with('product')
|
->with('product')
|
||||||
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDate, $formattedEndDate){
|
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDateYear, $formattedStartDate){
|
||||||
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
|
$qq->where('gram', $rulonProds[$x]->gram)
|
||||||
|
->where('width', $rulonProds[$x]->width)
|
||||||
|
->whereBetween('date', [$formattedStartDateYear, $formattedStartDate]);
|
||||||
})
|
})
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
|
|
||||||
|
//dd($rulonProds[$x]->width);
|
||||||
|
|
||||||
$endAction = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
|
$endAction = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
|
||||||
->with('product')
|
->with('product')
|
||||||
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDate, $formattedEndDate){
|
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDateYear, $formattedEndDate){
|
||||||
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
|
$qq->where('gram', $rulonProds[$x]->gram)
|
||||||
|
->where('width', $rulonProds[$x]->width)
|
||||||
|
->whereBetween('date', [$formattedStartDateYear, $formattedEndDate]);
|
||||||
})
|
})
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
|
|
@ -73,7 +70,9 @@ function onStart() {
|
||||||
->with('product')
|
->with('product')
|
||||||
->where('type', 'inbox')
|
->where('type', 'inbox')
|
||||||
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
|
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
|
||||||
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
|
$qq->where('gram', $rulonProds[$x]->gram)
|
||||||
|
->where('width', $rulonProds[$x]->width)
|
||||||
|
->whereBetween('date', [$formattedStartDate, $formattedEndDate]);
|
||||||
})
|
})
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
|
|
@ -82,7 +81,9 @@ function onStart() {
|
||||||
->with('product')
|
->with('product')
|
||||||
->where('type', 'outbox')
|
->where('type', 'outbox')
|
||||||
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
|
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
|
||||||
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '>', $formattedEndDate);
|
$qq->where('gram', $rulonProds[$x]->gram)
|
||||||
|
->where('width', $rulonProds[$x]->width)
|
||||||
|
->whereBetween('date', [$formattedStartDate, $formattedEndDate]);
|
||||||
})
|
})
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
|
|
@ -99,11 +100,14 @@ function onStart() {
|
||||||
|
|
||||||
$this['reportDatas'] = $reportDatas;
|
$this['reportDatas'] = $reportDatas;
|
||||||
}else{
|
}else{
|
||||||
$startDate = Carbon\Carbon::create($year, $this["month"], 1);
|
$startDateOfYear = Carbon\Carbon::now()->startOfYear();
|
||||||
$endDate = $startDate->endOfMonth();
|
$formattedStartDateYear = $startDateOfYear->format('Y-m-d');
|
||||||
|
|
||||||
|
$startDate = Carbon\Carbon::create($currentDate->year, $this["month"], 1);
|
||||||
$formattedStartDate = $startDate->format('Y-m-d');
|
$formattedStartDate = $startDate->format('Y-m-d');
|
||||||
$formattedEndDate = $endDate->format('Y-m-d');
|
|
||||||
|
$endMonthDate = $startDate->endOfMonth();
|
||||||
|
$formattedEndDate = $endMonthDate->format('Y-m-d');
|
||||||
|
|
||||||
$reportDatas = [];
|
$reportDatas = [];
|
||||||
|
|
||||||
|
|
@ -111,24 +115,33 @@ function onStart() {
|
||||||
->whereMonth('date', $this["month"])
|
->whereMonth('date', $this["month"])
|
||||||
->whereYear('date', $currentDate->year)
|
->whereYear('date', $currentDate->year)
|
||||||
->groupBy('gram')->groupBy('width')
|
->groupBy('gram')->groupBy('width')
|
||||||
|
->orderBy('gram', 'ASC')
|
||||||
->orderBy('width', 'ASC')
|
->orderBy('width', 'ASC')
|
||||||
->distinct()
|
->distinct()
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ($x = 0; $x < count($rulonProds); $x++) {
|
for ($x = 0; $x < count($rulonProds); $x++) {
|
||||||
|
|
||||||
$action = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
|
$action = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
|
||||||
->with('product')
|
->with('product')
|
||||||
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDate, $formattedEndDate){
|
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDateYear, $formattedStartDate){
|
||||||
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
|
$qq->where('gram', $rulonProds[$x]->gram)
|
||||||
|
->where('width', $rulonProds[$x]->width)
|
||||||
|
->whereBetween('date', [$formattedStartDateYear, $formattedStartDate]);
|
||||||
})
|
})
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
|
|
||||||
|
//dd($rulonProds[$x]->width);
|
||||||
|
|
||||||
$endAction = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
|
$endAction = Romanah\Gokbakja\Models\RulonAction::select('romanah_gokbakja_rulon_action.*')
|
||||||
->with('product')
|
->with('product')
|
||||||
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDate, $formattedEndDate){
|
->whereHas('product', function($qq) use($rulonProds, $x, $formattedStartDateYear, $formattedEndDate){
|
||||||
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '>', $formattedEndDate);
|
$qq->where('gram', $rulonProds[$x]->gram)
|
||||||
|
->where('width', $rulonProds[$x]->width)
|
||||||
|
->whereBetween('date', [$formattedStartDateYear, $formattedEndDate]);
|
||||||
})
|
})
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
|
|
@ -137,7 +150,9 @@ function onStart() {
|
||||||
->with('product')
|
->with('product')
|
||||||
->where('type', 'inbox')
|
->where('type', 'inbox')
|
||||||
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
|
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
|
||||||
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '<', $formattedStartDate);
|
$qq->where('gram', $rulonProds[$x]->gram)
|
||||||
|
->where('width', $rulonProds[$x]->width)
|
||||||
|
->whereBetween('date', [$formattedStartDate, $formattedEndDate]);
|
||||||
})
|
})
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
|
|
@ -146,7 +161,9 @@ function onStart() {
|
||||||
->with('product')
|
->with('product')
|
||||||
->where('type', 'outbox')
|
->where('type', 'outbox')
|
||||||
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
|
->whereHas('product', function($qq) use($rulonProds, $x, $year, $formattedStartDate, $formattedEndDate){
|
||||||
$qq->where('gram', $rulonProds[$x]->gram)->where('width', $rulonProds[$x]->width)->where('date', '>', $formattedEndDate);
|
$qq->where('gram', $rulonProds[$x]->gram)
|
||||||
|
->where('width', $rulonProds[$x]->width)
|
||||||
|
->whereBetween('date', [$formattedStartDate, $formattedEndDate]);
|
||||||
})
|
})
|
||||||
->sum('amount');
|
->sum('amount');
|
||||||
|
|
||||||
|
|
@ -255,10 +272,10 @@ function onStart() {
|
||||||
<td style="font-weight: bold;">{{key + 1}}</td>
|
<td style="font-weight: bold;">{{key + 1}}</td>
|
||||||
<td><a href="#" style="font-weight: bold;">{{report.gram}}</a></td>
|
<td><a href="#" style="font-weight: bold;">{{report.gram}}</a></td>
|
||||||
<td>{{report.width}}</td>
|
<td>{{report.width}}</td>
|
||||||
<td>{{report.start_month}}</td>
|
<td>{{report.start_month|number_format(2)}}</td>
|
||||||
<td style="color: darkgreen;">{{report.in}}</td>
|
<td style="color: darkgreen;">{{report.in|number_format(2)}}</td>
|
||||||
<td style="color: darkred;">{{report.out}}</td>
|
<td style="color: darkred;">{{report.out == 0 ? '' : report.out|number_format(2)}}</td>
|
||||||
<td>{{report.end_month}}</td>
|
<td>{{report.end_month|number_format(2)}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue