Commit 4fc7ea03 by Azhan Hannan

Report department buang redundant data

parent 61c17bf6
......@@ -39,9 +39,6 @@
<br>
<br>
@foreach($timesheet as $key => $value)
<!-- <?php
// dd($value->tm_timesheet_master_sts);
?> -->
<div class="ui styled fluid accordion">
<?php $page = 1; ?>
<div class="title">
......
......@@ -44,7 +44,7 @@
@foreach($staffs as $key => $staff)
<tbody>
<?php
$countproject = $project->where('staffid', data_get($staff,'staffid'));
$countproject = $projecttitle->where('staffid', data_get($staff,'staffid'));
?>
<tr>
<td colspan="6">{{data_get($staff,'name')}}</td>
......@@ -52,8 +52,8 @@
<?php
// $chargeproject = $project->where('ptype', 1);
$chargeproject = $project->where('ptype', 1);
// dd($chargeproject);
$chargeproject = $projecttitle->where('ptype', 1);
// dump($chargeproject);
$chargehours = $chargedays = 0;
?>
......@@ -64,12 +64,24 @@
<td style="width: 5%" class="center aligned">C</td>
<td style="width: 15%" class="center aligned">{{data_get($chargeable,'pcode')}}</td>
<td style="width: 25%">{{data_get($chargeable,'pname')}}</td>
<td style="width: 10%" class="center aligned">{{ number_format(data_get($chargeable,'hours'), '1', '.', '') }}</td>
<td style="width: 10%" class="center aligned">{{ number_format(data_get($chargeable,'hours')/8, '1', '.', '') }}</td>
<td style="width: 10%" class="center aligned">
<?php $projectvaluehours = 0; ?>
@foreach($project as $key => $projecthours)
@if(data_get($chargeable,'staffid') == data_get($projecthours,'staffid') && data_get($chargeable,'pid') == data_get($projecthours,'pid'))
<?php
$projectvaluehours += data_get($projecthours,'hours');
?>
@endif
@endforeach
{{ number_format($projectvaluehours, '1', '.', '') }}
</td>
<td style="width: 10%" class="center aligned">
{{ number_format($projectvaluehours/8, '1', '.', '') }}
</td>
</tr>
<?php
$chargehours += data_get($chargeable,'hours');
$chargedays += number_format(data_get($chargeable,'hours')/8, '1', '.', '');
$chargehours += $projectvaluehours;
$chargedays += number_format($projectvaluehours/8, '1', '.', '');
?>
@endif
@endforeach
......@@ -78,19 +90,31 @@
$overheadhours = $overheaddays = 0;
?>
@foreach($overhead as $key => $value)
@foreach($overheadtitle as $key => $value)
@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">{{ number_format(data_get($value,'hours'), '1', '.', '') }}</td>
<td style="width: 10%" class="center aligned">{{ number_format(data_get($value,'hours')/8, '1', '.', '') }}</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 += data_get($value,'hours');
$overheaddays += number_format(data_get($value,'hours')/8, '1', '.', '');
$overheadhours += $overheadvaluehours;
$overheaddays += number_format($overheadvaluehours/8, '1', '.', '');
?>
@endif
@endforeach
......
......@@ -248,17 +248,35 @@ class ReportController extends Controller
$dept = Department::where('id', $request->dept)->first();
// dd($dept);
$staffs = VwStaff::where('deptID', $request->dept)->get();
$approve = 4;
$project = VwProject::where('deptid', $request->dept)
->where('month', $request->month)
->where('year', $request->year)
->where('status', $approve)
->get();
// dd($project);
$projecttitle = VwProject::select('year', 'month', 'pcode', 'pname', 'staffid', 'deptid', 'ptype', 'pid')
->where('deptid', $request->dept)
->where('month', $request->month)
->where('year', $request->year)
->distinct()
->get();
// dd($projecttitle);
$overhead = VwOverhead::where('deptid', $request->dept)
->where('month', $request->month)
->where('year', $request->year)
->where('status', $approve)
->get();
// dd($overhead);
$overheadtitle = VwOverhead::select('staffid', 'deptid', 'oid', 'ptype', 'year', 'month', 'pname')
->where('deptid', $request->dept)
->where('month', $request->month)
->where('year', $request->year)
->distinct()
->get();
// dd($overheadtitle);
$year = date('Y');
if ($request->year) {
......@@ -269,7 +287,7 @@ class ReportController extends Controller
$month = date('F', mktime(0,0,0,$request->month, 1, date('Y')));
return view('timesheet::report.department', compact('intmonth','year', 'month', 'dept', 'staffs', 'project', 'overhead'));
return view('timesheet::report.department', compact('intmonth','year', 'month', 'dept', 'staffs', 'project', 'overhead', 'overheadtitle', 'projecttitle'));
}
public function filterOvertime()
......
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