Commit b69fac21 by Azhan Hannan

Report by Project

parent 55395b27
...@@ -2,9 +2,59 @@ ...@@ -2,9 +2,59 @@
@section('content') @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 segment">
<div class="ui purple left ribbon label"> <div class="ui purple left ribbon label">
Report by Project Reporting
</div> </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 ]) }}';"> <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,95 +98,72 @@ ...@@ -48,95 +98,72 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php $totalhours = $totaldays = 0;?> <?php
@foreach($pteam as $key => $team) $pteam = [];
<?php ?>
// dd($pteam); @foreach($roles as $key => $role)
$balhours = 0; <?php
foreach ($ptstaffs as $key => $value) { $pteam = $pteams->where('role_id', data_get($role,'pm_roles'));
if (data_get($team,'pm_roles') == data_get($value,'roleid')) { // dump($role);
$count = $ptstaffs->where('roleid', data_get($team,'pm_roles')); // dump($pteams);
}
}
?> ?>
<!-- <tr> <tr>
<td style="width: 10%" rowspan="{{count($count)+1}}" class="center aligned">{{data_get($team,'role.role')}}</td> <td rowspan="{{count($pteam)+1}}" class="center aligned">{{data_get($role,'role.role')}}</td>
</tr> --> <td rowspan="{{count($pteam)+1}}" class="center aligned">
@foreach($ptstaffs as $key => $staff) {{data_get($role,'pm_hours')}} Hours <br>
@if(data_get($team,'pm_roles') == data_get($staff,'roleid')) {{data_get($role,'pm_days')}} Days
</td>
<td rowspan="{{count($pteam)+1}}" class="center aligned">
<?php <?php
$count = $ptstaffs->where('roleid', data_get($team,'pm_roles')); $accumulatehours = 0;
$acc = $accumulate->where('staffid', data_get($staff,'staffid')); $staffaccumulateshours = $accumulates->where('tp_roles', data_get($role,'pm_roles'));
// dd($team); foreach ($staffaccumulateshours as $key => $accumulateshours) {
// dump(data_get($accumulateshours,'tp_hours'));
$accumulatehours += data_get($accumulateshours,'tp_hours');
}
?> ?>
<tr> {{ number_format($accumulatehours, 1, '.', '') }} Hours <br>
<td class="center aligned">{{data_get($team,'role.role')}}</td> {{ number_format($accumulatehours/8, 1, '.', '') }} Days
<td class="center aligned"> </td>
{{data_get($team,'pm_days')}} Days <br> @foreach($pteam as $key => $team)
{{data_get($team,'pm_hours')}} Hours <tr>
<td>
<?php $balhours = data_get($team,'pm_hours'); ?> {{ data_get($team,'pt_team') }}
</td> </td>
<td class="center aligned"> <td class="center aligned">
<?php <?php
$sum = 0; // dd($team);
foreach ($acc as $key => $value) { $currhour = 0;
$sum += data_get($value, 'tp_hours'); $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($sum/8, 1, '.', '') }} Days <br> {{ number_format($currhour, '1', '.', '') }} Hours
{{ 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($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
</td> </td>
<td style="width: 15%" class="center aligned"> <td class="center aligned">
<?php $sumdays = 0; ?> {{ number_format($currhour/8, '1', '.', '') }} Days
@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> </td>
<td class="center aligned"> <td class="center aligned">
{{ number_format($balhours/8, 1, '.', '') }} Days <br> <?php
{{ number_format($balhours, 1, '.', '') }} Hours $balancehours = data_get($role,'pm_hours') - $accumulatehours;
?>
{{ number_format($balancehours, '1', '.', '') }} Hours <br>
{{ number_format($balancehours/8, '1', '.', '') }} Days
</td> </td>
</tr> </tr>
@endforeach
@endif </tr>
@endforeach
@endforeach @endforeach
</tbody> </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> </table>
</div> </div>
</div> </div>
</div> </div>
@endsection @endsection
......
...@@ -760,16 +760,26 @@ class MaintenanceController extends Controller ...@@ -760,16 +760,26 @@ class MaintenanceController extends Controller
public function deleteTeam(Request $request) public function deleteTeam(Request $request)
{ {
// dd($request);
$team = Pteam::where('id', $request->id) $team = Pteam::where('id', $request->id)
->first(); ->first();
$pid = $team->fk_project_id; $roleid = data_get($team,'role_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) Pteam::where('id', $request->id)
->delete(); ->delete();
return redirect()->route('timesheet::maintenance.senaraiProjectTeam', ['id' => $pid ])->withSuccess('Team member has been deleted'); return redirect()->route('timesheet::maintenance.senaraiProjectTeam', ['id' => $pid ])->withSuccess('Team member has been deleted');
} }
......
...@@ -28,6 +28,7 @@ use Portal\Timesheet\Model\VwProject; ...@@ -28,6 +28,7 @@ use Portal\Timesheet\Model\VwProject;
use Portal\Timesheet\Model\VwNonchargeSummary; use Portal\Timesheet\Model\VwNonchargeSummary;
use Portal\Timesheet\Model\VwOverheadSummary; use Portal\Timesheet\Model\VwOverheadSummary;
use Portal\Timesheet\Model\VwNotSubmit; use Portal\Timesheet\Model\VwNotSubmit;
use Portal\Timesheet\Model\VwProjectStaffRoles;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input; use Illuminate\Support\Facades\Input;
use File; use File;
...@@ -175,6 +176,56 @@ class ReportController extends Controller ...@@ -175,6 +176,56 @@ class ReportController extends Controller
public function generateprojectreport(Request $request) public function generateprojectreport(Request $request)
{ {
// dd($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') if($request->project == 'noproject')
{ {
...@@ -198,7 +249,30 @@ class ReportController extends Controller ...@@ -198,7 +249,30 @@ class ReportController extends Controller
->orderby('pm_roles', 'ASC') ->orderby('pm_roles', 'ASC')
->get(); ->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) $ptdetail = VwProject::where('pid', $request->project)
->where('MONTH', $request->month) ->where('MONTH', $request->month)
->where('year', $request->year) ->where('year', $request->year)
...@@ -221,7 +295,7 @@ class ReportController extends Controller ...@@ -221,7 +295,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', '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() public function deptreport()
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Portal\Timesheet\Model; namespace Portal\Timesheet\Model;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class Pmandays extends Model class Pmandays extends Model
{ {
...@@ -11,6 +12,9 @@ class Pmandays extends Model ...@@ -11,6 +12,9 @@ class Pmandays extends Model
* *
* @var string * @var string
*/ */
use SoftDeletes;
protected $table = 'project_mandays'; protected $table = 'project_mandays';
// public function project() // public function project()
......
...@@ -66,5 +66,4 @@ class Tproject extends Model ...@@ -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