Commit 1ba1c7d7 by Azhan Hannan

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

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