Commit b69fac21 by Azhan Hannan

Report by Project

parent 55395b27
......@@ -3,8 +3,58 @@
@section('content')
<div class="ui segment">
<a class="ui green left ribbon label">Report by Project</a>
<br><br>
<form class="ui form" action="{{ route('timesheet::report.generateprojectreport') }}" method="POST">
{{csrf_field()}}
<div class="one fields">
<div class="six 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') }}" @if(data_get($value,'id') == data_get($pdetail,'pid')) selected="selected" @endif>{{ data_get($value,'p_project_code') }} | {{ data_get($value,'p_project_description') }}</option>
@endforeach
@else
<option value="noproject">No Project</option>
@endif
</select>
</div>
</div>
<?php
// dd($year);
?>
<div class="two fields">
<div class="three wide field">
<label>Year</label>
<select name="year" class="ui fluid dropdown" required="required">
@if($checkyear)
@foreach($listyear as $key => $value)
<option value="{{ data_get($value,'tm_year') }}" @if(data_get($value,'tm_year') == $year) selected="selected" @endif>{{ data_get($value,'tm_year') }}</option>
@endforeach
@else
<option value="{{ $year }}">{{ $year }}</option>
@endif
</select>
</div>
<div class="three wide field">
<label>Month</label>
<select name="month" class="ui fluid dropdown" required="required">
@foreach($listmonth as $key => $value)
<option value="{{ $key+1 }}" @if($value == $month) selected="selected" @endif>{{ $value }}</option>
@endforeach
</select>
</div>
</div>
<button class="ui olive button" type="submit">Generate Report</button>
</form>
</div>
<div class="ui segment">
<div class="ui purple left ribbon label">
Report by Project
Reporting
</div>
<button class="right floated center aligned ui violet compact labeled icon button" onclick="window.location.href='{{ route('timesheet::export.exportproject', ['month'=> $intmonth, 'year'=> $year, 'pid'=> $pid ]) }}';">
......@@ -48,96 +98,73 @@
</tr>
</thead>
<tbody>
<?php $totalhours = $totaldays = 0;?>
@foreach($pteam as $key => $team)
<?php
// dd($pteam);
$balhours = 0;
foreach ($ptstaffs as $key => $value) {
if (data_get($team,'pm_roles') == data_get($value,'roleid')) {
$count = $ptstaffs->where('roleid', data_get($team,'pm_roles'));
}
}
$pteam = [];
?>
<!-- <tr>
<td style="width: 10%" rowspan="{{count($count)+1}}" class="center aligned">{{data_get($team,'role.role')}}</td>
</tr> -->
@foreach($ptstaffs as $key => $staff)
@if(data_get($team,'pm_roles') == data_get($staff,'roleid'))
@foreach($roles as $key => $role)
<?php
$count = $ptstaffs->where('roleid', data_get($team,'pm_roles'));
$acc = $accumulate->where('staffid', data_get($staff,'staffid'));
// dd($team);
$pteam = $pteams->where('role_id', data_get($role,'pm_roles'));
// dump($role);
// dump($pteams);
?>
<tr>
<td 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 rowspan="{{count($pteam)+1}}" class="center aligned">{{data_get($role,'role.role')}}</td>
<td rowspan="{{count($pteam)+1}}" class="center aligned">
{{data_get($role,'pm_hours')}} Hours <br>
{{data_get($role,'pm_days')}} Days
</td>
<td class="center aligned">
<td rowspan="{{count($pteam)+1}}" class="center aligned">
<?php
$sum = 0;
foreach ($acc as $key => $value) {
$sum += data_get($value, 'tp_hours');
$accumulatehours = 0;
$staffaccumulateshours = $accumulates->where('tp_roles', data_get($role,'pm_roles'));
foreach ($staffaccumulateshours as $key => $accumulateshours) {
// dump(data_get($accumulateshours,'tp_hours'));
$accumulatehours += data_get($accumulateshours,'tp_hours');
}
?>
{{ number_format($sum/8, 1, '.', '') }} Days <br>
{{ number_format($sum, 1, '.', '') }} Hours
<?php $balhours -= $sum; ?>
{{ number_format($accumulatehours, 1, '.', '') }} Hours <br>
{{ number_format($accumulatehours/8, 1, '.', '') }} Days
</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($staff,'staffid'))
<?php $sumhours += data_get($hours,'hours'); ?>
<?php $totalhours += data_get($hours,'hours'); ?>
@endif
@endforeach
@if($sumhours == 0)
@else
{{ number_format($sumhours, 1, '.', '') }}
@endif
@foreach($pteam as $key => $team)
<tr>
<td>
{{ data_get($team,'pt_team') }}
</td>
<td style="width: 15%" class="center aligned">
<?php $sumdays = 0; ?>
@foreach($ptdetail as $key => $hours)
@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
{{ number_format($sumdays, 1, '.', '') }}
@endif
<td class="center aligned">
<?php
// dd($team);
$currhour = 0;
$currmonthhours = $currentmonthhours->where('staffid', data_get($team,'pt_staff_id'));
foreach ($currmonthhours as $key => $hours) {
$currhour = data_get($hours,'tp_hours');
}
// dd($currmonthhours);
?>
{{ number_format($currhour, '1', '.', '') }} Hours
</td>
<td class="center aligned">
{{ number_format($balhours/8, 1, '.', '') }} Days <br>
{{ number_format($balhours, 1, '.', '') }} Hours
{{ number_format($currhour/8, '1', '.', '') }} Days
</td>
<td class="center aligned">
<?php
$balancehours = data_get($role,'pm_hours') - $accumulatehours;
?>
{{ number_format($balancehours, '1', '.', '') }} Hours <br>
{{ number_format($balancehours/8, '1', '.', '') }} Days
</td>
</tr>
@endif
@endforeach
</tr>
@endforeach
</tbody>
<!-- <tfoot class="full-width">
<tr>
<th style="width: %"><strong>Total</strong></th>
<th style="width: %"></th>
<th style="width: 15%" class="center aligned"><strong>{{$totalhours}} / {{data_get($pdetail,'mandays.p_total_hours')}}</strong></th>
<th style="width: 15%" class="center aligned"><strong>{{$totaldays}} / {{data_get($pdetail,'mandays.p_total_days')}}</strong></th>
</tr>
</tfoot> -->
</table>
</div>
</div>
</div>
@endsection
@push('script')
......
......@@ -760,15 +760,25 @@ class MaintenanceController extends Controller
public function deleteTeam(Request $request)
{
// dd($request);
$team = Pteam::where('id', $request->id)
->first();
$pid = $team->fk_project_id;
$roleid = data_get($team,'role_id');
Pteam::where('id', $request->id)
$pid = data_get($team,'fk_project_id');
$checkmandays = Pmandays::where('pm_roles', $roleid)
->where('fk_project', $pid)
->get();
if (count($checkmandays) == 1) {
Pmandays::where('pm_roles', $roleid)
->where('fk_project', $pid)
->delete();
}
Pteam::where('id', $request->id)
->delete();
return redirect()->route('timesheet::maintenance.senaraiProjectTeam', ['id' => $pid ])->withSuccess('Team member has been deleted');
}
......
......@@ -28,6 +28,7 @@ use Portal\Timesheet\Model\VwProject;
use Portal\Timesheet\Model\VwNonchargeSummary;
use Portal\Timesheet\Model\VwOverheadSummary;
use Portal\Timesheet\Model\VwNotSubmit;
use Portal\Timesheet\Model\VwProjectStaffRoles;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;
use File;
......@@ -175,6 +176,56 @@ class ReportController extends Controller
public function generateprojectreport(Request $request)
{
// dd($request);
$roleid = auth()->user()->roles['0']->id;
$user = Users::find(Auth::id());
if($roleid == 8)
{
$checkproj = Project::where('p_project_type', 1)
->where('p_project_task_team', $user->u_staffID)
->where('deleted_at', null)
->first();
$proj = Project::where('p_project_type', 1)
->where('p_project_task_team', $user->u_staffID)
->where('deleted_at', null)
->get();
}
if($roleid != '5' && $roleid != '8')
{
$checkproj = Project::where('p_project_type', 1)
->where('deleted_at', null)
->first();
$proj = Project::where('p_project_type', 1)
->where('deleted_at', null)
->get();
}
$listmonth = [];
for ($m=1; $m<=12; $m++) {
$listmonth[] = date('F', mktime(0,0,0,$m, 1, date('Y')));
}
$checkyear = Ts_master::select('tm_year')
->where('tm_timesheet_master_sts', 4)
->distinct('tm_year')
->orderby('tm_year','DESC')
->first();
if ($checkyear) {
$listyear = Ts_master::select('tm_year')
->where('tm_timesheet_master_sts', 4)
->distinct('tm_year')
->orderby('tm_year','DESC')
->get();
}
else
{
$listyear = date('Y');
}
if($request->project == 'noproject')
{
......@@ -198,7 +249,30 @@ class ReportController extends Controller
->orderby('pm_roles', 'ASC')
->get();
// dd($pteam);
$roles = Pmandays::where('fk_project', $pid)
->with('role')
->orderby('pm_roles', 'ASC')
->get();
// dd($roles);
$pteams = Pteam::where('fk_project_id', $pid)
->orderby('role_id')
// ->where('pt_project_task_sts', 1)
->get();
// dd($pteams);
$accumulates = VwProjectStaffRoles::where('td_project', $pid)
->where('tp_year', '<=' ,$request->year)
->where('tp_month', '<=', $request->month)
->orderby('tp_month', 'ASC')
->get();
$currentmonthhours = Tproject::where('td_project', $pid)
->where('tp_year', $request->year)
->where('tp_month', $request->month)
->get();
// dd($currentmonthhours);
$ptdetail = VwProject::where('pid', $request->project)
->where('MONTH', $request->month)
->where('year', $request->year)
......@@ -221,7 +295,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', 'ptstaffs', 'accumulate'));
return view('timesheet::report.project', compact('month', 'intmonth', 'year', 'pteam', 'pdetail', 'ptdetail', 'pid', 'ptstaffs', 'accumulate', 'listmonth', 'checkproj', 'checkyear', 'listyear', 'proj', 'roles', 'pteams', 'accumulates', 'currentmonthhours'));
}
public function deptreport()
......
......@@ -3,6 +3,7 @@
namespace Portal\Timesheet\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Pmandays extends Model
{
......@@ -11,6 +12,9 @@ class Pmandays extends Model
*
* @var string
*/
use SoftDeletes;
protected $table = 'project_mandays';
// public function project()
......
......@@ -66,5 +66,4 @@ class Tproject extends Model
}
}
<?php
namespace Portal\Timesheet\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;
class VwProjectStaffRoles extends Model
{
use Notifiable;
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'vw_project_staff_roles';
/**
* undocumented function
*
* @return void
* @author
**/
public function info()
{
}
public function project()
{
return $this->hasOne('Portal\Timesheet\Model\Project','id','td_project')->with('projectManager');
}
public function overhead()
{
return $this->hasOne('Portal\Timesheet\Model\Overhead','id','fk_o_id');
}
public function pm()
{
return $this->hasOne('Portal\Timesheet\Model\Staff_info','staff_id','tp_pm');
}
public function hod()
{
return $this->hasOne('Portal\Timesheet\Model\Staff_info','id','tp_pm');
}
public function bod()
{
return $this->hasOne('Portal\Timesheet\Model\Staff_info','id','tp_pd');
}
public function team()
{
return $this->hasOne('Portal\Timesheet\Model\Staff_info','staff_id','staffid');
}
use \Awobaz\Compoships\Compoships;
public function notes()
{
// return $this->hasMany('Portal\Timesheet\Model\Ts_detail','fk_tm_id','fk_tm_id')->where('td_project_type', 3);
return $this->hasMany('Portal\Timesheet\Model\Ts_detail',['fk_tm_id','fk_o_id'],['fk_tm_id','fk_o_id'])->orderby('td_date');
}
}
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