Commit 4fc7ea03 by Azhan Hannan

Report department buang redundant data

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