Commit 0b78a1ff by Azhan Hannan

report project & summary. fix calculation. set pm only see their project. set…

report project & summary. fix calculation. set pm only see their project. set summary can filter by department
parent e1fdda4a
......@@ -89,6 +89,7 @@ class ProjectExport implements FromView, ShouldAutoSize, WithColumnWidths, WithS
'pteam' => VwProject::where('pid', $project)
->where('roleid', '<>', '7')
->orderby('roleid')
->groupby('name')
->get(),
'ptdetail' => VwProject::where('pid', $project)
......
......@@ -28,20 +28,31 @@
<td>{{data_get($team,'name')}}</td>
<td>{{data_get($team,'role')}}</td>
<td>
<?php $sumhours = 0; ?>
@foreach($ptdetail as $key => $hours)
@if(data_get($hours,'staffid') == data_get($team,'staffid'))
{{data_get($hours,'hours')}}
<?php $sumhours += data_get($hours,'hours'); ?>
<?php $totalhours += data_get($hours,'hours'); ?>
@endif
@endforeach
@if($sumhours == 0)
@else
{{$sumhours}}
@endif
</td>
<td>
<?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, '.', '')}}
<!-- {{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, '.', ''); ?>
@endif
@endforeach
@if($sumdays == 0)
@else
{{$sumdays}}
@endif
</td>
</tr>
@endforeach
......
......@@ -46,20 +46,31 @@
<td style="width: 40%">{{data_get($team,'name')}}</td>
<td style="width: 30%" class="center aligned">{{data_get($team,'role')}}</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'))
{{data_get($hours,'hours')}}
<?php $sumhours += data_get($hours,'hours'); ?>
<?php $totalhours += data_get($hours,'hours'); ?>
@endif
@endforeach
@if($sumhours == 0)
@else
{{$sumhours}}
@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, '.', '')}}
<!-- {{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, '.', ''); ?>
@endif
@endforeach
@if($sumdays == 0)
@else
{{$sumdays}}
@endif
</td>
</tr>
@endforeach
......
......@@ -12,9 +12,13 @@
<div class="five wide field">
<label>Project</label>
<select name="project" class="ui fluid dropdown" required="required">
@if($checkproj)
@foreach($proj as $key => $value)
<option value="{{ data_get($value,'id') }}">{{ data_get($value,'p_project_code') }} | {{ data_get($value,'p_project_description') }}</option>
@endforeach
@else
<option value="noproject">No Project</option>
@endif
</select>
</div>
......
......@@ -9,14 +9,14 @@
<form class="ui form" action="{{ route('timesheet::report.generateRingkasan') }}" method="POST">
{{csrf_field()}}
<!-- <div class="five wide field">
<label>Jabatan</label>
<select name="year" class="ui fluid dropdown" required="required">
<div class="five wide field">
<label>Department</label>
<select name="dept" class="ui fluid dropdown" required="required">
@foreach($dept as $key => $value)
<option value="{{data_get($value, 'id')}}">{{ data_get($value,'description') }}</option>
@endforeach
</select>
</div> -->
</div>
<div class="two fields">
<div class="three wide field">
......
......@@ -62,6 +62,8 @@ class ReportController extends Controller
public function generateRingkasan(Request $request)
{
// dd($request->dept);
$ringkasan = VwRingkasanLaporan::where('month', $request->month)
->where('year', $request->year)
->where('status', 4)
......@@ -84,6 +86,7 @@ class ReportController extends Controller
// $nonchargeproject = VwNonChargeable::all();
$staffs = VwStaff::orderby('deptID')
->where('deptID','!=', 8)
->where('deptID', $request->dept)
->get();
$year = date('Y');
......@@ -99,8 +102,31 @@ class ReportController extends Controller
public function projectreport()
{
$roleid = auth()->user()->roles['0']->id;
// dd($roleid);
$user = Users::find(Auth::id());
// dd(data_get($user, 'u_staffID'));
if($roleid == 8)
{
$checkproj = Project::where('p_project_type', 1)
->where('p_project_task_team', $user->u_staffID)
->first();
$proj = Project::where('p_project_type', 1)
->where('p_project_task_team', $user->u_staffID)
->get();
}
if($roleid != '5' && $roleid != '8')
{
$checkproj = Project::where('p_project_type', 1)
->first();
$proj = Project::where('p_project_type', 1)
->get();
}
$month = [];
......@@ -109,16 +135,23 @@ class ReportController extends Controller
}
$year = Ts_master::select('tm_year')
->where('tm_timesheet_master_sts', 4)
->distinct('tm_year')
->orderby('tm_year','DESC')
->get();
return view('timesheet::report.projectReport', compact('proj', 'month', 'year'));
return view('timesheet::report.projectReport', compact('checkproj' ,'proj', 'month', 'year'));
}
public function generateprojectreport(Request $request)
{
// dd($request);
if($request->project == 'noproject')
{
return redirect()->route('timesheet::report.projectReport')->with('warning', 'You have no ongoing project or the project is not added. Kindly add your project to view the report. Thank you.');
}
$pid = $request->project;
$pdetail = VwProject::where('pid', $request->project)
......@@ -128,6 +161,7 @@ class ReportController extends Controller
$pteam = VwProject::where('pid', $request->project)
->where('roleid', '<>', '7')
->orderby('roleid')
->groupby('name')
->get();
$ptdetail = VwProject::where('pid', $request->project)
......@@ -161,6 +195,7 @@ class ReportController extends Controller
}
$year = Ts_master::select('tm_year')
->where('tm_timesheet_master_sts', 4)
->distinct('tm_year')
->orderby('tm_year','DESC')
->get();
......
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