Commit 2a2b8aad by Azhan Hannan

Report Summary - Hasil filter, jika ada project yang tiada value, hide kan…

Report Summary - Hasil filter, jika ada project yang tiada value, hide kan project tu. overhead x perlu.
parent 89c8cdbc
......@@ -21,7 +21,7 @@
<tr>
<th style="width: 10%"> Month/Year</th>
<th style="width: 1%">:</th>
<th style="width: 89%"> {{ $month}} {{ $year}}</th>
<th style="width: 89%"> {{ $month}} {{ $year }}</th>
</tr>
</thead>
</table>
......@@ -29,7 +29,9 @@
<thead>
<tr>
<th colspan="4"></th>
<th colspan="{{count($chargeproject)+2}}" class="center aligned">Chargeable</th>
@if(count($chargeprojects) > 0)
<th colspan="{{count($chargeprojects)+2}}" class="center aligned">Chargeable</th>
@endif
<th colspan="{{count($overhead)+2}}" class="center aligned">Overhead</th>
<th rowspan="2" class="center aligned">Total (Working Days)</th>
</tr>
......@@ -38,15 +40,19 @@
<th>Department</th>
<th>Staff Id</th>
<th>Staff Name</th>
@foreach($chargeproject as $key => $chargeable)
@if(count($chargeprojects) > 0)
@foreach($chargeprojects as $key => $chargeable)
<th>
{{data_get($chargeable, 'p_project_code')}}
{{data_get($chargeable, 'project.p_project_code')}}
</th>
@endforeach
<th>Total Hours</th>
<th>Total Days</th>
@endif
@foreach($overhead as $key => $value)
<th>{{data_get($value,'o_overhead_desc')}}</th>
<th class="center aligned">
{{ data_get($value,'o_overhead_desc') }}
</th>
@endforeach
<th>Total Hours</th>
<th>Total Days</th>
......@@ -61,29 +67,37 @@
<td>{{data_get($staff,'deptCode')}}</td>
<td>{{data_get($staff,'staffid')}}</td>
<td class="single line">{{data_get($staff,'name')}}</td>
<?php $totalc = 0; ?>
@foreach($chargeproject as $key => $chargeable)
<td>
<?php $monthly_hours = 0; ?>
@foreach($ringkasan as $key => $value)
@if(data_get($value,'staffid') == data_get($staff,'staffid') && data_get($chargeable,'id') == data_get($value,'c_pid'))
<!-- {{data_get($value,'total_c_hours')}} -->
<?php $monthly_hours += data_get($value,'total_c_hours'); ?>
<?php $totalc += data_get($value,'total_c_hours'); ?>
@endif
<?php
$totalc = 0;
$chargehour = $chargehours->where('staffid', data_get($staff,'staffid'));
?>
@if(count($chargeprojects) > 0)
@foreach($chargeprojects as $key => $chargeable)
<td class="center aligned">
<?php
$monthly_hours = 0;
$projecthour = $chargehour->where('td_project', data_get($chargeable,'td_project'));
?>
@foreach($projecthour as $key => $value)
<?php
$monthly_hours += data_get($value,'tp_hours');
$totalc += data_get($value,'tp_hours');
?>
@endforeach
@if($monthly_hours == 0)
@else
{{$monthly_hours}}
{{ number_format($monthly_hours, '1', '.', '') }}
@endif
</td>
@endforeach
<td class="center aligned">{{$totalc}}</td>
<td class="center aligned">{{number_format($totalc/8, 1, '.', '')}}</td>
<td class="center aligned">{{ number_format($totalc, '1', '.', '') }}</td>
<td class="center aligned">{{ number_format($totalc/8, 1, '.', '') }}</td>
@endif
<?php $totalnc = 0; ?>
@foreach($overhead as $key => $value)
<td>
<td class="center aligned">
<?php $monthly_hours = 0; ?>
@foreach($ovhours as $key => $hours)
@if(data_get($staff,'staffid') == data_get($hours,'staffid') && data_get($value,'id') == data_get($hours,'oid'))
......@@ -95,14 +109,14 @@
@if($monthly_hours == 0)
@else
{{$monthly_hours}}
{{ number_format($monthly_hours, '1', '.', '') }}
@endif
</td>
@endforeach
<td class="center aligned">{{$totalnc}}</td>
<td class="center aligned">{{number_format($totalnc/8, 1, '.', '')}}</td>
<td class="center aligned">{{ number_format($totalnc, '1', '.', '') }}</td>
<td class="center aligned">{{ number_format($totalnc/8, 1, '.', '') }}</td>
<?php $totaldays = number_format($totalc/8, 1, '.', '') + number_format($totalnc/8, 1, '.', ''); ?>
<td>{{$totaldays}}</td>
<td class="center aligned">{{ number_format($totaldays, '1', '.', '') }}</td>
</tr>
</tbody>
<?php $totalalldays += $totaldays; ?>
......@@ -114,39 +128,48 @@
<strong>Total</strong>
</th>
<?php $tch = 0; ?>
@foreach($chargeproject as $key => $value)
<?php $currproject = $ringkasan->where('c_pid', data_get($value,'id')) ?>
<th>
<?php $totalp = 0; ?>
@foreach($staffs as $key => $staff)
@foreach($chargeproject as $key => $chargeable)
<?php $monthly_hours = 0; ?>
@foreach($currproject as $key => $value)
@if(data_get($value,'staffid') == data_get($staff,'staffid') && data_get($chargeable,'id') == data_get($value,'c_pid'))
<!-- {{data_get($value,'total_c_hours')}} -->
<?php $monthly_hours += data_get($value,'total_c_hours'); ?>
@endif
@endforeach
<!-- {{$monthly_hours}} -->
<?php $totalp += $monthly_hours; ?>
@endforeach
@foreach($chargeprojects as $key => $value)
<?php
$projecthours = $chargehours->where('td_project', data_get($value,'td_project'));
$monthly_hours = 0;
?>
<th class="center aligned">
@foreach($projecthours as $key => $project)
<?php
$monthly_hours += data_get($project,'tp_hours');
?>
@endforeach
{{$totalp}}
{{ number_format($monthly_hours, '1', '.', '') }}
</th>
<?php $tch += $totalp; ?>
<?php $tch += $monthly_hours; ?>
@endforeach
<th class="text-center">{{$tch}}</th>
<th class="text-center">{{number_format($tch/8, 1, '.', '')}}</th>
<th colspan="{{count($overhead)+2}}"></th>
<th><strong>{{$totalalldays}}</strong></th>
<th class="text-center">{{ number_format($tch, '1', '.', '') }}</th>
<th class="text-center">{{ number_format($tch/8, 1, '.', '') }}</th>
<?php $totaloverhead = 0; ?>
@foreach($overhead as $key => $value)
<?php
$monthly_ov = 0;
$oid = data_get($value,'id');
$ov = $ovhours->where('oid', $oid);
foreach ($ov as $key => $value) {
$monthly_ov += data_get($value,'hours');
}
?>
<th class="center aligned">{{ number_format($monthly_ov, '1', '.', '') }}</th>
<?php $totaloverhead += $monthly_ov; ?>
@endforeach
<th class="text-center">{{ number_format($totaloverhead, '1', '.', '') }}</th>
<th class="text-center">{{ number_format($totaloverhead/8, 1, '.', '') }}</th>
<th class="center aligned"><strong>{{ number_format($totalalldays, '1', '.', '') }}</strong></th>
</tr>
</tfoot>
</table>
</div>
</div>
<br><br>
</div>
<style>
......@@ -205,7 +228,6 @@
width: 1650px;
}
}
</style>
@endsection
\ No newline at end of file
......@@ -65,33 +65,31 @@ class ReportController extends Controller
public function generateRingkasan(Request $request)
{
// dd($request->dept);
$ringkasan = VwRingkasanLaporan::where('month', $request->month)
->where('year', $request->year)
->where('status', 4)
->get();
// dd($ringkasan);
// $projectnc = VwNonchargeSummary::where('month', $request->month)
// ->where('year', $request->year)
// ->get();
$overhead = Overhead::where('o_overhead_sts', 1)->get();
// dd($overhead);
$ovhours = VwOverheadSummary::where('month', $request->month)
->where('year', $request->year)
->where('status', 4)
->get();
// dd($ovhours);
$liststaffs = [];
$chargeproject = VwChargeable::where('deleted_at', null)->get();
// dd($chargeproject);
if ($request->dept == 'all') {
$staffs = VwStaff::orderby('deptID')
->where('deptID','!=', 8)
->get();
foreach ($staffs as $key => $staff)
{
$liststaffs[] = data_get($staff,'staffid');
}
}
else
{
......@@ -99,17 +97,42 @@ class ReportController extends Controller
->where('deptID','!=', 8)
->where('deptID', $request->dept)
->get();
foreach ($staffs as $key => $staff)
{
$liststaffs[] = data_get($staff,'staffid');
}
}
// dd($staffs);
$chargehours = Tproject::where('tp_year', $request->year)
->where('tp_month', $request->month)
->where('tp_hours', '<>', null)
->where('tp_project_type', 1)
->whereIn('staffid', $liststaffs)
->where('tp_timesheet_sts', 4)
->get();
$chargeprojects = Tproject::select('td_project', 'tp_year', 'tp_month', 'tp_project_name')
->where('tp_year', $request->year)
->where('tp_month', $request->month)
->where('tp_hours', '<>', null)
->where('tp_project_type', 1)
->whereIn('staffid', $liststaffs)
->with('project')
->where('tp_timesheet_sts', 4)
->distinct()
->get();
$year = date('Y');
if ($request->year) {
$year = $request->year;
}
$intmonth = $request->month;
$month = date('F', mktime(0,0,0,$request->month, 1, date('Y')));
return view('timesheet::report.ringkasan', compact('intmonth','month', 'year','ringkasan', 'chargeproject', 'staffs', 'overhead', 'ovhours'));
return view('timesheet::report.ringkasan', compact('intmonth','month', 'year','ringkasan', 'chargeproject', 'staffs', 'overhead', 'ovhours', 'chargeprojects', 'chargehours'));
}
public function projectreport()
......
......@@ -23,7 +23,7 @@ class Tproject extends Model
public function project()
{
return $this->hasOne('Portal\Timesheet\Model\Project','id','td_project')->with('projectManager');
return $this->hasOne('Portal\Timesheet\Model\Project','id','td_project')->with('projectManager')->withTrashed();
}
public function overhead()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment