Commit 527ffcba by Azhan Hannan

changes in department report

parent dfc70aea
...@@ -64,6 +64,7 @@ class DepartmentExport implements FromView, ShouldAutoSize, WithColumnWidths, Wi ...@@ -64,6 +64,7 @@ class DepartmentExport implements FromView, ShouldAutoSize, WithColumnWidths, Wi
$month = $this->request['month']; $month = $this->request['month'];
$year = $this->request['year']; $year = $this->request['year'];
$dept = $this->request['dept']; $dept = $this->request['dept'];
$approve = 4;
return view('timesheet::exports.exportDepartment', [ return view('timesheet::exports.exportDepartment', [
...@@ -71,15 +72,32 @@ class DepartmentExport implements FromView, ShouldAutoSize, WithColumnWidths, Wi ...@@ -71,15 +72,32 @@ class DepartmentExport implements FromView, ShouldAutoSize, WithColumnWidths, Wi
'month'=> $month, 'month'=> $month,
'year' => $year, 'year' => $year,
'staffs' => VwStaff::where('deptID', $dept)->get(), 'staffs' => VwStaff::where('deptID', $dept)->get(),
'project' => VwProject::where('deptid', $dept) 'project' => VwProject::where('deptid', $dept)
->where('month', $month) ->where('month', $month)
->where('year', $year) ->where('year', $year)
->get(), ->where('status', $approve)
->get(),
'overhead' => VwOverhead::where('deptid', $dept) 'overhead' => VwOverhead::where('deptid', $dept)
->where('month', $month) ->where('month', $month)
->where('year', $year) ->where('year', $year)
->where('status', $approve)
->get(), ->get(),
'projecttitle' => VwProject::select('year', 'month', 'pcode', 'pname', 'staffid', 'deptid', 'ptype', 'pid')
->where('deptid', $dept)
->where('month', $month)
->where('year', $year)
->distinct()
->get(),
'overheadtitle' => VwOverhead::select('staffid', 'deptid', 'oid', 'ptype', 'year', 'month', 'pname')
->where('deptid', $dept)
->where('month', $month)
->where('year', $year)
->distinct()
->get(),
]); ]);
} }
} }
...@@ -12,112 +12,119 @@ ...@@ -12,112 +12,119 @@
</tr> </tr>
</thead> </thead>
</table> </table>
<table> <table class="ui unstackable celled table">
<thead> <thead>
<tr> <tr>
<th>{{strtoupper('staff')}}</th> <th style="width: 35%">staff</th>
<th>{{strtoupper('project type')}}</th> <th style="width: 5%" class="center aligned">project type</th>
<th>{{strtoupper('project code / task')}}</th> <th style="width: 15%" class="center aligned">project code / task</th>
<th>{{strtoupper('description')}}</th> <th style="width: 25%" class="center aligned">description</th>
<th>{{strtoupper('total hours')}}</th> <th style="width: 10%" class="center aligned">total hours</th>
<th>{{strtoupper('total days')}}</th> <th style="width: 10%" class="center aligned">total days</th>
</tr> </tr>
</thead> </thead>
<?php $totalhours = $totaldays = $staffhours = $staffdays = 0; ?> <?php $totalhours = $totaldays = $staffhours = $staffdays = 0; ?>
@foreach($staffs as $key => $staff) @foreach($staffs as $key => $staff)
<tbody> <tbody>
<tr> <?php
<td colspan="6">{{data_get($staff,'name')}}</td> $countproject = $projecttitle->where('staffid', data_get($staff,'staffid'));
</tr> ?>
<tr>
<td colspan="6">{{data_get($staff,'name')}}</td>
</tr>
<?php <?php
$chargeproject = $project->where('ptype', 1); // $chargeproject = $project->where('ptype', 1);
$chargehours = $chargedays = 0; $chargeproject = $projecttitle->where('ptype', 1);
?> // dump($chargeproject);
$chargehours = $chargedays = 0;
?>
@foreach($chargeproject as $key => $chargeable) @foreach($chargeproject as $key => $chargeable)
@if(data_get($chargeable,'staffid') == data_get($staff,'staffid')) @if(data_get($chargeable,'staffid') == data_get($staff,'staffid'))
<tr> <tr>
<td></td> <td style="width: 35%"></td>
<td>C</td> <td style="width: 5%" class="center aligned">C</td>
<td>{{data_get($chargeable,'pcode')}}</td> <td style="width: 15%" class="center aligned">{{data_get($chargeable,'pcode')}}</td>
<td>{{data_get($chargeable,'pname')}}</td> <td style="width: 25%">{{data_get($chargeable,'pname')}}</td>
<td>{{data_get($chargeable,'hours')}}</td> <td style="width: 10%" class="center aligned">
<td>{{number_format(data_get($chargeable,'hours')/8, '1', '.', '')}}</td> <?php $projectvaluehours = 0; ?>
</tr> @foreach($project as $key => $projecthours)
<?php @if(data_get($chargeable,'staffid') == data_get($projecthours,'staffid') && data_get($chargeable,'pid') == data_get($projecthours,'pid'))
$chargehours += data_get($chargeable,'hours'); <?php
$chargedays += number_format(data_get($chargeable,'hours')/8, '1', '.', ''); $projectvaluehours += data_get($projecthours,'hours');
?> ?>
@endif @endif
@endforeach @endforeach
{{ number_format($projectvaluehours, '1', '.', '') }}
<?php </td>
$nonchargeproject = $project->where('ptype', 2); <td style="width: 10%" class="center aligned">
$nonchargehours = $nonchargedays = 0; {{ number_format($projectvaluehours/8, '1', '.', '') }}
?> </td>
</tr>
<?php
$chargehours += $projectvaluehours;
$chargedays += number_format($projectvaluehours/8, '1', '.', '');
?>
@endif
@endforeach
@foreach($nonchargeproject as $key => $nonchargeable) <?php
@if(data_get($nonchargeable,'staffid') == data_get($staff,'staffid')) $overheadhours = $overheaddays = 0;
<tr> ?>
<td></td>
<td>NC</td>
<td>{{data_get($nonchargeable,'pcode')}}</td>
<td>{{data_get($nonchargeable,'pname')}}</td>
<td>{{data_get($nonchargeable,'hours')}}</td>
<td>{{number_format(data_get($nonchargeable,'hours')/8, '1', '.', '')}}</td>
</tr>
<?php
$nonchargehours += data_get($nonchargeable,'hours');
$nonchargedays += number_format(data_get($nonchargeable,'hours')/8, '1', '.', '');
?>
@endif
@endforeach
<?php @foreach($overheadtitle as $key => $value)
$overheadhours = $overheaddays = 0; @if(data_get($value,'staffid') == data_get($staff,'staffid'))
?> <tr>
<td style="width: 35%"></td>
<td style="width: 5%" class="center aligned">NC</td>
<td style="width: 15%" class="center aligned"></td>
<td style="width: 25%">{{data_get($value,'pname')}}</td>
<td style="width: 10%" class="center aligned">
<?php $overheadvaluehours = 0 ?>
@foreach($overhead as $key => $valuehours)
@if(data_get($value,'staffid') == data_get($valuehours,'staffid') && data_get($value,'oid') == data_get($valuehours,'oid') )
<?php
$overheadvaluehours += data_get($valuehours,'hours');
?>
@endif
@endforeach
{{ number_format($overheadvaluehours, '1', '.', '') }}
</td>
<td style="width: 10%" class="center aligned">
{{ number_format($overheadvaluehours/8, '1', '.', '') }}
</td>
</tr>
<?php
$overheadhours += $overheadvaluehours;
$overheaddays += number_format($overheadvaluehours/8, '1', '.', '');
?>
@endif
@endforeach
@foreach($overhead as $key => $value) <?php
@if(data_get($value,'staffid') == data_get($staff,'staffid')) $staffhours = $chargehours+$overheadhours;
<tr> $staffdays = $chargedays+$overheaddays;
<td></td> ?>
<td>NC</td> <tr>
<td></td> <td colspan="3"></td>
<td>{{data_get($value,'pname')}}</td> <td style="width: 25%" class="center aligned">Total</td>
<td>{{data_get($value,'hours')}}</td> <td style="width: 10%" class="center aligned">{{ number_format($staffhours, '1', '.', '') }}</td>
<td>{{number_format(data_get($value,'hours')/8, '1', '.', '')}}</td> <td style="width: 10%" class="center aligned">{{ number_format($staffdays, '1', '.', '') }}</td>
</tr> </tr>
<?php
$overheadhours += data_get($value,'hours');
$overheaddays += number_format(data_get($value,'hours')/8, '1', '.', '');
?>
@endif
@endforeach
<?php </tbody>
$staffhours = $chargehours+$nonchargehours+$overheadhours; <?php
$staffdays = $chargedays+$nonchargedays+$overheaddays; $totalhours += $staffhours;
?> $totaldays += $staffdays;
<tr> ?>
<td colspan="3"></td> @endforeach
<td>Total</td> <tfoot class="full-width">
<td>{{$staffhours}}</td> <tr>
<td>{{$staffdays}}</td> <th colspan="3"><strong>Total</strong></th>
</tr> <th style="width: 25%" class="center aligned"></th>
<th style="width: 10%" class="center aligned"><strong>{{ number_format($totalhours, '1', '.', '') }}</strong></th>
</tbody> <th style="width: 10%" class="center aligned"><strong>{{ number_format($totaldays, '1', '.', '') }}</strong></th>
<?php </tr>
$totalhours += $staffhours; </tfoot>
$totaldays += $staffdays;
?>
@endforeach
<tfoot>
<tr>
<th colspan="3"><strong>Total</strong></th>
<th></th>
<th><strong>{{$totalhours}}</strong></th>
<th><strong>{{$totaldays}}</strong></th>
</tr>
</tfoot>
</table> </table>
\ No newline at end of file
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