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 ...@@ -89,6 +89,7 @@ class ProjectExport implements FromView, ShouldAutoSize, WithColumnWidths, WithS
'pteam' => VwProject::where('pid', $project) 'pteam' => VwProject::where('pid', $project)
->where('roleid', '<>', '7') ->where('roleid', '<>', '7')
->orderby('roleid') ->orderby('roleid')
->groupby('name')
->get(), ->get(),
'ptdetail' => VwProject::where('pid', $project) 'ptdetail' => VwProject::where('pid', $project)
......
...@@ -28,20 +28,31 @@ ...@@ -28,20 +28,31 @@
<td>{{data_get($team,'name')}}</td> <td>{{data_get($team,'name')}}</td>
<td>{{data_get($team,'role')}}</td> <td>{{data_get($team,'role')}}</td>
<td> <td>
<?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($team,'staffid'))
{{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)
@else
{{$sumhours}}
@endif
</td> </td>
<td> <td>
<?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($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, '.', ''); ?> <?php $totaldays += number_format(data_get($hours,'hours')/8, 1, '.', ''); ?>
@endif @endif
@endforeach @endforeach
@if($sumdays == 0)
@else
{{$sumdays}}
@endif
</td> </td>
</tr> </tr>
@endforeach @endforeach
......
...@@ -46,20 +46,31 @@ ...@@ -46,20 +46,31 @@
<td style="width: 40%">{{data_get($team,'name')}}</td> <td style="width: 40%">{{data_get($team,'name')}}</td>
<td style="width: 30%" class="center aligned">{{data_get($team,'role')}}</td> <td style="width: 30%" class="center aligned">{{data_get($team,'role')}}</td>
<td style="width: 15%" class="center aligned"> <td style="width: 15%" class="center aligned">
<?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($team,'staffid'))
{{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)
@else
{{$sumhours}}
@endif
</td> </td>
<td style="width: 15%" class="center aligned"> <td style="width: 15%" class="center aligned">
<?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($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, '.', ''); ?> <?php $totaldays += number_format(data_get($hours,'hours')/8, 1, '.', ''); ?>
@endif @endif
@endforeach @endforeach
@if($sumdays == 0)
@else
{{$sumdays}}
@endif
</td> </td>
</tr> </tr>
@endforeach @endforeach
......
...@@ -12,9 +12,13 @@ ...@@ -12,9 +12,13 @@
<div class="five wide field"> <div class="five wide field">
<label>Project</label> <label>Project</label>
<select name="project" class="ui fluid dropdown" required="required"> <select name="project" class="ui fluid dropdown" required="required">
@if($checkproj)
@foreach($proj as $key => $value) @foreach($proj as $key => $value)
<option value="{{ data_get($value,'id') }}">{{ data_get($value,'p_project_code') }} | {{ data_get($value,'p_project_description') }}</option> <option value="{{ data_get($value,'id') }}">{{ data_get($value,'p_project_code') }} | {{ data_get($value,'p_project_description') }}</option>
@endforeach @endforeach
@else
<option value="noproject">No Project</option>
@endif
</select> </select>
</div> </div>
......
...@@ -9,14 +9,14 @@ ...@@ -9,14 +9,14 @@
<form class="ui form" action="{{ route('timesheet::report.generateRingkasan') }}" method="POST"> <form class="ui form" action="{{ route('timesheet::report.generateRingkasan') }}" method="POST">
{{csrf_field()}} {{csrf_field()}}
<!-- <div class="five wide field"> <div class="five wide field">
<label>Jabatan</label> <label>Department</label>
<select name="year" class="ui fluid dropdown" required="required"> <select name="dept" class="ui fluid dropdown" required="required">
@foreach($dept as $key => $value) @foreach($dept as $key => $value)
<option value="{{data_get($value, 'id')}}">{{ data_get($value,'description') }}</option> <option value="{{data_get($value, 'id')}}">{{ data_get($value,'description') }}</option>
@endforeach @endforeach
</select> </select>
</div> --> </div>
<div class="two fields"> <div class="two fields">
<div class="three wide field"> <div class="three wide field">
......
...@@ -62,6 +62,8 @@ class ReportController extends Controller ...@@ -62,6 +62,8 @@ class ReportController extends Controller
public function generateRingkasan(Request $request) public function generateRingkasan(Request $request)
{ {
// dd($request->dept);
$ringkasan = VwRingkasanLaporan::where('month', $request->month) $ringkasan = VwRingkasanLaporan::where('month', $request->month)
->where('year', $request->year) ->where('year', $request->year)
->where('status', 4) ->where('status', 4)
...@@ -84,6 +86,7 @@ class ReportController extends Controller ...@@ -84,6 +86,7 @@ class ReportController extends Controller
// $nonchargeproject = VwNonChargeable::all(); // $nonchargeproject = VwNonChargeable::all();
$staffs = VwStaff::orderby('deptID') $staffs = VwStaff::orderby('deptID')
->where('deptID','!=', 8) ->where('deptID','!=', 8)
->where('deptID', $request->dept)
->get(); ->get();
$year = date('Y'); $year = date('Y');
...@@ -99,8 +102,31 @@ class ReportController extends Controller ...@@ -99,8 +102,31 @@ class ReportController extends Controller
public function projectreport() 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) $proj = Project::where('p_project_type', 1)
->get(); ->get();
}
$month = []; $month = [];
...@@ -109,16 +135,23 @@ class ReportController extends Controller ...@@ -109,16 +135,23 @@ class ReportController extends Controller
} }
$year = Ts_master::select('tm_year') $year = Ts_master::select('tm_year')
->where('tm_timesheet_master_sts', 4)
->distinct('tm_year') ->distinct('tm_year')
->orderby('tm_year','DESC') ->orderby('tm_year','DESC')
->get(); ->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) public function generateprojectreport(Request $request)
{ {
// dd($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; $pid = $request->project;
$pdetail = VwProject::where('pid', $request->project) $pdetail = VwProject::where('pid', $request->project)
...@@ -128,6 +161,7 @@ class ReportController extends Controller ...@@ -128,6 +161,7 @@ class ReportController extends Controller
$pteam = VwProject::where('pid', $request->project) $pteam = VwProject::where('pid', $request->project)
->where('roleid', '<>', '7') ->where('roleid', '<>', '7')
->orderby('roleid') ->orderby('roleid')
->groupby('name')
->get(); ->get();
$ptdetail = VwProject::where('pid', $request->project) $ptdetail = VwProject::where('pid', $request->project)
...@@ -161,6 +195,7 @@ class ReportController extends Controller ...@@ -161,6 +195,7 @@ class ReportController extends Controller
} }
$year = Ts_master::select('tm_year') $year = Ts_master::select('tm_year')
->where('tm_timesheet_master_sts', 4)
->distinct('tm_year') ->distinct('tm_year')
->orderby('tm_year','DESC') ->orderby('tm_year','DESC')
->get(); ->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