Commit 1ba1c7d7 by Azhan Hannan

Log Kak Shikin #41.1) revamp - Table project report with mandays

parent 106366c5
......@@ -18,7 +18,7 @@
</thead>
<tbody>
<?php $limit = count($limitrole);
// dd($limitrole);
// dd($role);
?>
@foreach($role as $key => $value)
......@@ -59,6 +59,7 @@
onchange="calcDays(this.value,{{$limit}},{{data_get($value,'role.id')}})">
</td>
</tr>
@endforeach
<tr>
<td class="single line"></td>
......
......@@ -48,42 +48,71 @@
</tr>
</thead>
<tbody>
<?php $totalhours = $totaldays = 0; ?>
<?php $totalhours = $totaldays = 0;?>
@foreach($pteam as $key => $team)
<?php $balhours = 0; ?>
@foreach($ptstaffs as $key => $staff)
@if(data_get($team,'pm_roles') == data_get($staff,'roleid'))
<?php
// dump($staff->staffid);
$count = $ptstaffs->where('roleid', data_get($team,'pm_roles'));
$acc = $accumulate->where('staffid', data_get($staff,'staffid'));
// dump($acc);
?>
<tr>
<td style="width: 10%" class="center aligned">{{data_get($team,'role')}}</td>
<td class="center aligned">allocation</td>
<td class="center aligned">accumulate</td>
<td style="width: 10%">{{data_get($team,'name')}}</td>
<td style="width: 10%" class="center aligned">{{data_get($team,'role.role')}}</td>
<td class="center aligned">
{{data_get($team,'pm_days')}} Days <br>
{{data_get($team,'pm_hours')}} Hours
<?php $balhours = data_get($team,'pm_hours'); ?>
</td>
<td class="center aligned">
<?php
$sum = 0;
foreach ($acc as $key => $value) {
$sum += data_get($value, 'tp_hours');
}
?>
{{ number_format($sum/8, 1, '.', '') }} Days <br>
{{ number_format($sum, 1, '.', '') }} Hours
<?php $balhours -= $sum; ?>
</td>
<td style="width: 10%">{{data_get($staff,'name')}}</td>
<td style="width: 15%" class="center aligned">
<?php $sumhours = 0; ?>
@foreach($ptdetail as $key => $hours)
@if(data_get($hours,'staffid') == data_get($team,'staffid'))
@if(data_get($hours,'staffid') == data_get($staff,'staffid'))
<?php $sumhours += data_get($hours,'hours'); ?>
<?php $totalhours += data_get($hours,'hours'); ?>
@endif
@endforeach
@if($sumhours == 0)
@else
{{$sumhours}}
{{ number_format($sumhours, 1, '.', '') }}
@endif
</td>
<td style="width: 15%" class="center aligned">
<?php $sumdays = 0; ?>
@foreach($ptdetail as $key => $hours)
@if(data_get($hours,'staffid') == data_get($team,'staffid'))
<!-- {{number_format(data_get($hours,'hours')/8, 1, '.', '')}} -->
@if(data_get($hours,'staffid') == data_get($staff,'staffid'))
<?php $sumdays += number_format(data_get($hours,'hours')/8, 1, '.', ''); ?>
<?php $totaldays += number_format(data_get($hours,'hours')/8, 1, '.', ''); ?>
@endif
@endforeach
@if($sumdays == 0)
@else
{{$sumdays}}
{{ number_format($sumdays, 1, '.', '') }}
@endif
</td>
<td class="center aligned">balance</td>
<td class="center aligned">
{{ number_format($balhours/8, 1, '.', '') }} Days <br>
{{ number_format($balhours, 1, '.', '') }} Hours
</td>
</tr>
@endif
@endforeach
@endforeach
</tbody>
<!-- <tfoot class="full-width">
......
......@@ -12,6 +12,7 @@ use Portal\Timesheet\Model\Project;
use Portal\Timesheet\Model\Tproject;
use Portal\Timesheet\Model\Department;
use Portal\Timesheet\Model\Pteam;
use Portal\Timesheet\Model\Pmandays;
use Portal\Timesheet\Model\Staff_info;
use Portal\Timesheet\Model\Overhead;
use Portal\Timesheet\Model\Role;
......@@ -144,14 +145,14 @@ class ReportController extends Controller
}
$checkyear = Ts_master::select('tm_year')
->where('tm_timesheet_master_sts', 4)
// ->where('tm_timesheet_master_sts', 4)
->distinct('tm_year')
->orderby('tm_year','DESC')
->first();
if ($checkyear) {
$year = Ts_master::select('tm_year')
->where('tm_timesheet_master_sts', 4)
// ->where('tm_timesheet_master_sts', 4)
->distinct('tm_year')
->orderby('tm_year','DESC')
->get();
......@@ -176,16 +177,22 @@ class ReportController extends Controller
}
$pid = $request->project;
// dd($pid);
$pdetail = VwProject::where('pid', $request->project)
->with('mandays')
->first();
// dd($pdetail);
$pteam = VwProject::where('pid', $request->project)
$ptstaffs = VwProject::where('pid', $request->project)
->where('roleid', '<>', '7')
->orderby('roleid')
->groupby('name')
->get();
$pteam = Pmandays::where('fk_project', $pid)
->with('role')
->orderby('pm_roles', 'ASC')
->get();
// dd($pteam);
$ptdetail = VwProject::where('pid', $request->project)
->where('MONTH', $request->month)
......@@ -193,6 +200,12 @@ class ReportController extends Controller
->where('roleid', '<>', '7')
->orderby('roleid')
->get();
// dd($ptdetail);
$accumulate = Tproject::where('td_project', $pid)
->where('tp_year', $request->year)
->where('tp_month', $request->month)
->get();
// dd($accumulate);
$year = date('Y');
if ($request->year) {
......@@ -203,7 +216,7 @@ class ReportController extends Controller
$month = date('F', mktime(0,0,0,$request->month, 1, date('Y')));
return view('timesheet::report.project', compact('month', 'intmonth', 'year', 'pteam', 'pdetail', 'ptdetail', 'pid'));
return view('timesheet::report.project', compact('month', 'intmonth', 'year', 'pteam', 'pdetail', 'ptdetail', 'pid', 'ptstaffs', 'accumulate'));
}
public function deptreport()
......
......@@ -24,6 +24,13 @@ class Pmandays extends Model
* @return void
* @author
**/
public function role()
{
// dd('1');
return $this->hasOne('Portal\Timesheet\Model\Role','id', 'pm_roles');
}
public function info()
{
......
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