Commit 41b6a554 by hannan

completion of overhead form

parent 5447aded
@extends('ui::layouts.app')
@section('content')
<div class="ui segment">
<a class="ui blue left ribbon label">Add New Role</a>
<br><br>
<form class="ui form" action="{{ route('timesheet::dashboard.updaterole' )}}" method="POST">
{{csrf_field()}}
<input type="hidden" name="id" value="{{$role->id}}">
<div class="field">
<label>Role Description</label>
<input type="text" name="role" value="{{$role->role}} ">
</div>
<div class="field">
<label>Role Status</label>
<select name="status" class="ui fluid dropdown">
<option value=""> {{$status}} </option>
<option value="1">Active</option>
<option value="2">Inactive</option>
</select>
</div>
<button class="ui button" type="submit">Update</button>
</form>
</div>
@endsection
\ No newline at end of file
...@@ -17,7 +17,7 @@ input[type=number] { ...@@ -17,7 +17,7 @@ input[type=number] {
</style> </style>
<div class="ui segment"> <div class="ui segment">
<a class="ui blue left ribbon label">Non Chargeable Form</a> <a class="ui blue left ribbon label">Non-Chargeable Form</a>
<br> <br>
<br> <br>
<form class="ui form"> <form class="ui form">
...@@ -48,7 +48,7 @@ input[type=number] { ...@@ -48,7 +48,7 @@ input[type=number] {
<table class="ui celled structured table"> <table class="ui celled structured table">
<thead> <thead>
<tr> <tr>
<th>Chargeable</th> <th colspan="2">Chargeable</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th> <th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th> <th>
<button type="submit" class="fluid center aligned ui blue compact labeled icon button"> <button type="submit" class="fluid center aligned ui blue compact labeled icon button">
...@@ -58,7 +58,8 @@ input[type=number] { ...@@ -58,7 +58,8 @@ input[type=number] {
</th> </th>
</tr> </tr>
<tr> <tr>
<th class="single line">Task</th> <th class="single line">Project Code</th>
<th class="single line">Project Name</th>
@if($phase == 1) @if($phase == 1)
@for($i = 0; $i < 15 ; $i++) @for($i = 0; $i < 15 ; $i++)
...@@ -82,6 +83,9 @@ input[type=number] { ...@@ -82,6 +83,9 @@ input[type=number] {
<?php $total = 0; ?> <?php $total = 0; ?>
<tr> <tr>
<td class="single line"> <td class="single line">
{{$project['td_project_code']}}
</td>
<td class="single line">
{{$project['td_project_name']}} {{$project['td_project_name']}}
</td> </td>
@if($phase == 1) @if($phase == 1)
......
@extends('ui::layouts.app')
@section('content')
<style>
/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type=number] {
-moz-appearance: textfield;
}
</style>
<div class="ui segment">
<a class="ui blue left ribbon label">Overhead Form</a>
<br>
<br>
<form class="ui form">
<div class="field">
<div class="three fields">
<div class="one wide field">
<label>Phase</label>
<input type="text" placeholder="Year" value="{{$phase}}" readonly="readonly">
</div>
<div class="one wide field">
<label>Month</label>
<input type="text" placeholder="Month" value="{{$month}}" readonly="readonly">
</div>
<div class="two wide field">
<label>Year</label>
<input type="text" placeholder="Year" value="{{$year}}" readonly="readonly">
</div>
</div>
</div>
</form>
<br>
<form class="ui form" action="{{ route('timesheet::dashboard.saveoverheadhours' )}}" method="POST">
{{csrf_field()}}
<input type="hidden" name="userId" value="{{$userId}}">
<input type="hidden" name="year" value="{{$year}}">
<input type="hidden" name="month" value="{{$month}}">
<input type="hidden" name="phase" value="{{$phase}}">
<table class="ui celled structured table">
<thead>
<tr>
<th>Overhead</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th>
<button type="submit" class="fluid center aligned ui blue compact labeled icon button">
<i class="save icon"></i>
Save
</button>
</th>
</tr>
<tr>
<th class="single line">Project Name</th>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<th>{{$i+1}}</th>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<th>{{$i+1}}</th>
@endfor
@endif
<th>Total Hours</th>
</tr>
<tr>
</tr>
</thead>
<tbody>
@foreach($projectlist as $key => $project)
<?php $total = 0; ?>
<tr>
<td class="single line">
{{$project['td_project_name']}}
</td>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<?php
$valuehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($hour)
{
$valuehour = $hour->where('td_date','=',$date)
->where('fk_o_id',$project['td_project'])
->where('tm_phase',$phase)
->first();
$total += data_get($valuehour,'td_hours');
}
?>
<td >
<input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$i+1}}]" name="hour[{{$project['td_project']}}][{{$i+1}}]" value="@if($valuehour){{$valuehour->td_hours}}@else @endif" min="0" max="24" style="padding:2px;margin:unset" onchange="limiter(this,'{{$project['td_project']}}');">
</td>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<?php
$valuehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($hour)
{
$valuehour = $hour->where('td_date','=',$date)
->where('fk_o_id',$project['td_project'])
->where('tm_phase',$phase)
->first();
$total += data_get($valuehour,'td_hours');
}
?>
<td >
<input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$i+1}}]" name="hour[{{$project['td_project']}}][{{$i+1}}]" value="@if($valuehour){{$valuehour->td_hours}}@else @endif" min="0" max="24" style="padding:2px;margin:unset" onchange="limiter(this,'{{$project['td_project']}}');">
</td>
@endfor
@endif
<td>
<input type="text" onkeypress="onlynumber(event)" name="total-{{$project['td_project']}}" id="total-{{$project['td_project']}}" style="padding-right: 4px;padding-left: 4px;" onchange="limiter(this,'{{$project['td_project']}}');" readonly="" value={{$total}}>
</td>
</tr>
@endforeach
</tbody>
</table>
</form>
<br>
@if($phase == 1)
<button class="center aligned ui green compact right labeled icon button" id="phase2" onclick="window.location.href='{{ route('timesheet::dashboard.overheadForm', ['phase' => 2], ['month' => $month], ['year' => $year]) }}';">
<i class="angle double right icon"></i>
Phase 2
</button>
@else
<button class="center aligned ui green compact labeled icon button" id="phase1" onclick="window.location.href='{{ route('timesheet::dashboard.overheadForm', ['phase' => 1], ['month' => $month], ['year' => $year]) }}';">
<i class="angle double left icon"></i>
Phase 1
</button>
@endif
</div>
@endsection
@push('script')
<script>
function onlynumber(evt)
{
var theEvent = evt || window.event;
var key = theEvent.keyCode || theEvent.which;
key = String.fromCharCode(key);
var regex = /[0-9]|\./;
if( !regex.test(key) )
{
theEvent.returnValue = false;
if(theEvent.preventDefault) theEvent.preventDefault();
}
}
</script>
<script>
$().ready(function() {
});
function limiter(input,pid) {
var currenttotal = 0;
if (input.value < 0) input.value = 0;
if (input.value > 24) input.value = 24;
input.value = parseFloat(parseFloat(input.value).toFixed(1));
for(var i = 0; i < 32; i++){
var value = 0;
var hourValue = document.getElementById('hour['+pid+']['+i+']');
if(hourValue){
hourValue = hourValue.value;
value = parseFloat(parseFloat(hourValue).toFixed(1));
console.log(isNaN(value));
if(isNaN(value)){
value = 0;
}
if(typeof value === 'number'){
// console.log(value);
currenttotal += value;
}
}
}
console.log("currenttotal --> " + currenttotal);
// var currentTtotal = document.getElementById('total-'+pid).value;
// var total = document.getElementById('total-'+pid).value;
// if(total == null || total == 0){
// total = 0;
// }else{
// total = document.getElementById('total-'+pid).value;
// }
// if (input.value < 0) input.value = 0;
// if (input.value > 24) input.value = 24
// else total = Number(input.value)+Number(currentTtotal);
document.getElementById('total-'+pid).value = currenttotal;
}
</script>
@endpush
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
{{csrf_field()}} {{csrf_field()}}
<div class="field"> <div class="field">
<label>Role Description</label> <label>Role Description</label>
<input type="text" name="overheadlookup" placeholder="Enter new role"> <input type="text" name="role" placeholder="Enter new role">
</div> </div>
<div class="field"> <div class="field">
<label>Role Status</label> <label>Role Status</label>
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
@section('content') @section('content')
<div class="ui segment"> <div class="ui segment">
<a class="ui blue left ribbon label">Senarai Project</a> <a class="ui blue left ribbon label">Senarai Peranan</a>
<a href="{{ route('timesheet::dashboard.penambahanPeranan')}} " class="ui right floated small primary labeled icon button"><i class="plus icon"></i>Add New Role <a href="{{ route('timesheet::dashboard.penambahanPeranan')}} " class="ui right floated small primary labeled icon button"><i class="plus icon"></i>Add New Role
</a> </a>
<br> <br>
...@@ -22,8 +22,7 @@ ...@@ -22,8 +22,7 @@
<td>{{$key+1}} </td> <td>{{$key+1}} </td>
<td>{{$role['role']}} </td> <td>{{$role['role']}} </td>
<td>{{$role['status']}} </td> <td>{{$role['status']}} </td>
<td><a href="">Edit</a></td> <td><a href="{{ route('timesheet::dashboard.editPeranan', ['id' => $role['id']]) }}">Edit</a></td>
<!-- <td><a href="{{ route('timesheet::dashboard.', ['id' => $project['id']]) }}">Edit</a></td> -->
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>
......
...@@ -25,6 +25,8 @@ Route::group( ...@@ -25,6 +25,8 @@ Route::group(
Route::get('senaraiPeranan',['uses' => 'DashboardController@senaraiPeranan', 'as' => 'dashboard.senaraiPeranan']); Route::get('senaraiPeranan',['uses' => 'DashboardController@senaraiPeranan', 'as' => 'dashboard.senaraiPeranan']);
Route::get('penambahanPeranan',['uses' => 'DashboardController@penambahanPeranan', 'as' => 'dashboard.penambahanPeranan']); Route::get('penambahanPeranan',['uses' => 'DashboardController@penambahanPeranan', 'as' => 'dashboard.penambahanPeranan']);
Route::post('addrole',['uses' => 'DashboardController@addrole', 'as' => 'dashboard.addrole']); Route::post('addrole',['uses' => 'DashboardController@addrole', 'as' => 'dashboard.addrole']);
Route::get('editPeranan',['uses' => 'DashboardController@editPeranan', 'as' => 'dashboard.editPeranan']);
Route::post('updaterole',['uses' => 'DashboardController@updaterole', 'as' => 'dashboard.updaterole']);
Route::get('chargeableForm',['uses' => 'DashboardController@chargeableForm', 'as' => 'dashboard.chargeableForm']); Route::get('chargeableForm',['uses' => 'DashboardController@chargeableForm', 'as' => 'dashboard.chargeableForm']);
Route::get('nonChargeableForm',['uses' => 'DashboardController@nonChargeableForm', 'as' => 'dashboard.nonChargeableForm']); Route::get('nonChargeableForm',['uses' => 'DashboardController@nonChargeableForm', 'as' => 'dashboard.nonChargeableForm']);
...@@ -40,6 +42,7 @@ Route::group( ...@@ -40,6 +42,7 @@ Route::group(
Route::get('timesheet_viewer',['uses' => 'DashboardController@timesheetViewer', 'as' => 'dashboard.timesheetViewer']); Route::get('timesheet_viewer',['uses' => 'DashboardController@timesheetViewer', 'as' => 'dashboard.timesheetViewer']);
Route::post('savechargeablehours',['uses' => 'DashboardController@savechargeablehours', 'as' => 'dashboard.savechargeablehours']); Route::post('savechargeablehours',['uses' => 'DashboardController@savechargeablehours', 'as' => 'dashboard.savechargeablehours']);
Route::post('saveoverheadhours',['uses' => 'DashboardController@saveoverheadhours', 'as' => 'dashboard.saveoverheadhours']);
......
...@@ -88,11 +88,11 @@ class DashboardController extends Controller ...@@ -88,11 +88,11 @@ class DashboardController extends Controller
$projectlist[] = [ $projectlist[] = [
'id' => $value->id, 'id' => $value->id,
'projectcode' => $value->p_project_code, 'projectcode' => $value->p_project_code,
'projectname' => $value->p_project_description, 'projectname' => $value->p_project_description,
'projectmanager' => $value->projectManager->fullname, 'projectmanager' => $value->projectManager->fullname,
'status' => $value->p_project_sts, 'status' => $value->p_project_sts,
]; ];
} }
...@@ -108,17 +108,19 @@ class DashboardController extends Controller ...@@ -108,17 +108,19 @@ class DashboardController extends Controller
public function addnewproject(Request $request) public function addnewproject(Request $request)
{ {
$user = users::where('id', Auth::id())->first(); $userId = users::find(Auth::id())
->u_staffID;
$project = new Project; $project = new Project;
$project->p_project_code = $request->projectcode; $project->p_project_code = $request->projectcode;
$project->p_project_description = $request->projectname; $project->p_project_description = $request->projectname;
$project->p_project_task_team = $request->projectmanager; $project->p_project_task_team = $request->projectmanager;
$project->p_project_sts = $request->status; $project->p_project_sts = $request->status;
$project->updated_by = $user->u_staffID; $project->updated_by = $userId;
$project->save(); $project->save();
return redirect()->route('timesheet::dashboard.penambahanProject'); return redirect()->route('timesheet::dashboard.penambahanProject')
->with('success', 'New Project Added');
} }
public function senaraiProjectTeam(Request $request) public function senaraiProjectTeam(Request $request)
...@@ -134,13 +136,13 @@ class DashboardController extends Controller ...@@ -134,13 +136,13 @@ class DashboardController extends Controller
$projectlist[] = [ $projectlist[] = [
'id' => $value->id, 'id' => $value->id,
'projectcode' => $value->toProject->p_project_code, 'projectcode' => $value->toProject->p_project_code,
'projectname' => $value->pt_project_description, 'projectname' => $value->pt_project_description,
'projectteam' => $value->pt_team, 'projectteam' => $value->pt_team,
'role' => 'Developer', 'role' => 'Developer',
'status' => $value->pt_project_task_sts, 'status' => $value->pt_project_task_sts,
'pid' => $value->fk_project_id, 'pid' => $value->fk_project_id,
]; ];
} }
...@@ -168,8 +170,8 @@ class DashboardController extends Controller ...@@ -168,8 +170,8 @@ class DashboardController extends Controller
public function addprojectteam(Request $request) public function addprojectteam(Request $request)
{ {
$user = Users::where('id', Auth::id()) $userId = users::find(Auth::id())
->first(); ->u_staffID;
$project = Project::where('p_project_code','=',$request->projectcode) $project = Project::where('p_project_code','=',$request->projectcode)
->first(); ->first();
...@@ -187,18 +189,20 @@ class DashboardController extends Controller ...@@ -187,18 +189,20 @@ class DashboardController extends Controller
$pt->pt_team = $staff->fullname; $pt->pt_team = $staff->fullname;
$pt->pt_staff_id = $value; $pt->pt_staff_id = $value;
$pt->pt_project_task_sts = $request->status; $pt->pt_project_task_sts = $request->status;
$pt->updated_by = $user->id; $pt->updated_by = $userId;
$pt->save(); $pt->save();
} }
return redirect()->route('timesheet::dashboard.penambahanProjectTeam'); return redirect()->route('timesheet::dashboard.penambahanProjectTeam')
->with('success', 'Project Team Added Successfully');
} }
public function editprojectteam(Request $request) public function editprojectteam(Request $request)
{ {
$team = Pteam::where('id', $request->id) $team = Pteam::where('id', $request->id)
->first(); ->first();
$pid = $team->fk_project_id; $pid = $team->fk_project_id;
return view('timesheet::dashboard.editprojectteam', compact('team', 'pid')); return view('timesheet::dashboard.editprojectteam', compact('team', 'pid'));
...@@ -207,26 +211,29 @@ class DashboardController extends Controller ...@@ -207,26 +211,29 @@ class DashboardController extends Controller
public function updateprojectteam(Request $request) public function updateprojectteam(Request $request)
{ {
$pid = $request->pid; $pid = $request->pid;
$user = Users::where('id', Auth::id()) $userId = users::find(Auth::id())
->first(); ->u_staffID;
$team = Pteam::where('id', $request->id)->first(); $team = Pteam::where('id', $request->id)->first();
$team->pt_project_task_sts = $request->status; $team->pt_project_task_sts = $request->status;
$team->updated_by = $userId;
// letak query utk update role // letak query utk update role
// $team->pt_role = $request->role; // $team->pt_role = $request->role;
$team->update(); $team->update();
$project = Pteam::where('fk_project_id',$request->pid)->get(); $project = Pteam::where('fk_project_id',$request->pid)
->get();
$projectlist = []; $projectlist = [];
foreach ($project as $key => $value) { foreach ($project as $key => $value) {
$projectlist[] = [ $projectlist[] = [
'id' => $value->id, 'id' => $value->id,
'projectcode' => $value->toProject->p_project_code, 'projectcode' => $value->toProject->p_project_code,
'projectname' => $value->pt_project_description, 'projectname' => $value->pt_project_description,
'projectteam' => $value->pt_team, 'projectteam' => $value->pt_team,
'status' => $value->pt_project_task_sts, 'status' => $value->pt_project_task_sts,
]; ];
} }
...@@ -242,8 +249,8 @@ class DashboardController extends Controller ...@@ -242,8 +249,8 @@ class DashboardController extends Controller
foreach ($peranan as $key => $value) { foreach ($peranan as $key => $value) {
$roles[] = [ $roles[] = [
'id' => $value->id, 'id' => $value->id,
'role' => $value->role, 'role' => $value->role,
'status' => $value->status 'status' => $value->status
]; ];
...@@ -259,10 +266,52 @@ class DashboardController extends Controller ...@@ -259,10 +266,52 @@ class DashboardController extends Controller
public function addrole(Request $request) public function addrole(Request $request)
{ {
dd($request); find($id)->column_name;
return redirect()->route('timesheet::dashboard.senaraiPeranan');
$userId = users::find(Auth::id())
->u_staffID;
$data = new Role;
$data->role = $request->role;
$data->status = $request->status;
$data->updated_by = $userId;
$data->save();
return redirect()->route('timesheet::dashboard.senaraiPeranan')
->with('success', 'Role Added Successfully');
} }
public function editPeranan(Request $request)
{
$role = Role::where('id', $request->id)
->first();
if ($role->status == 1) {
$status = 'Active';
} else {
$status = 'Inactive';
}
return view('timesheet::dashboard.editPeranan', compact('role', 'status'));
}
public function updaterole(Request $request)
{
$userId = users::find(Auth::id())
->u_staffID;
$data = Role::where('id', $request->id)
->first();
$data->role = $request->role;
$data->status = $request->status;
$data->updated_by = $userId;
$data->update();
return redirect()->route('timesheet::dashboard.senaraiPeranan')
->with('success', 'Role Updated Successfully');
}
public function perkhidmatan() public function perkhidmatan()
{ {
...@@ -271,12 +320,12 @@ class DashboardController extends Controller ...@@ -271,12 +320,12 @@ class DashboardController extends Controller
public function chargeableForm(Request $request) public function chargeableForm(Request $request)
{ {
$userId = Auth::id(); $userId = users::find(Auth::id())
$user = users::where('id', Auth::id())->first(); ->u_staffID;
$project = Pteam::where('pt_staff_id',$user->u_staffID)->get();
// dd($project); $project = Pteam::where('pt_staff_id',$userId)
->get();
// dd($project);
$projectlist = []; $projectlist = [];
// nanti project code query dari table project: // nanti project code query dari table project:
...@@ -319,24 +368,20 @@ class DashboardController extends Controller ...@@ -319,24 +368,20 @@ class DashboardController extends Controller
//check dlam db, kalau dah ada detail hours, kuar form edit, kalau belum, kuar form create //check dlam db, kalau dah ada detail hours, kuar form edit, kalau belum, kuar form create
$user = users::where('id', Auth::id())->first();
// check timesheet master // check timesheet master
$check = Ts_master::where('tm_staff_id', $user->u_staffID) $check = Ts_master::where('tm_staff_id', $userId)
->where('tm_year', $year) ->where('tm_year', $year)
->where('tm_month', $month) ->where('tm_month', $month)
->where('tm_phase', $phase) ->where('tm_phase', $phase)
->first(); ->first();
// dd($check);
//kalau ada, dia gi ke edit //kalau ada, dia gi ke edit
if($check) if($check)
{ {
$hour = Ts_detail::where('fk_tm_id',$check->id) $hour = Ts_detail::where('fk_tm_id',$check->id)
// ->with('project:p_project_code') // ->with('project:p_project_code')
->get(); ->get();
// dd($hour); // dd($hour);
} }
//klu xde g create.php //klu xde g create.php
...@@ -347,11 +392,13 @@ class DashboardController extends Controller ...@@ -347,11 +392,13 @@ class DashboardController extends Controller
return view('timesheet::dashboard.chargeableForm', compact('projectlist','userId','month','phase','daymonth','year','day','hour')); return view('timesheet::dashboard.chargeableForm', compact('projectlist','userId','month','phase','daymonth','year','day','hour'));
} }
public function nonChargeableForm(Request $request) public function nonchargeableForm(Request $request)
{ {
$userId = Auth::id(); $userId = users::find(Auth::id())
$user = users::where('id', Auth::id())->first(); ->u_staffID;
$project = Pteam::where('pt_staff_id',$user->u_staffID)->get();
$project = Pteam::where('pt_staff_id',$userId)
->get();
$projectlist = []; $projectlist = [];
...@@ -369,7 +416,9 @@ class DashboardController extends Controller ...@@ -369,7 +416,9 @@ class DashboardController extends Controller
} }
$phase = 2; //sample dulu
$phase = 1;
$month = date('n'); $month = date('n');
$year = date('Y'); $year = date('Y');
$day = date('j'); $day = date('j');
...@@ -393,24 +442,92 @@ class DashboardController extends Controller ...@@ -393,24 +442,92 @@ class DashboardController extends Controller
//check dlam db, kalau dah ada detail hours, kuar form edit, kalau belum, kuar form create //check dlam db, kalau dah ada detail hours, kuar form edit, kalau belum, kuar form create
$user = users::where('id', Auth::id())->first();
// check timesheet master // check timesheet master
$check = Ts_master::where('tm_staff_id', $user->u_staffID) $check = Ts_master::where('tm_staff_id', $userId)
->where('tm_year', $year) ->where('tm_year', $year)
->where('tm_month', $month) ->where('tm_month', $month)
->where('tm_phase', $phase) ->where('tm_phase', $phase)
->first(); ->first();
//kalau ada, dia gi ke edit
if($check)
{
$hour = Ts_detail::where('fk_tm_id',$check->id)
// ->with('project:p_project_code')
->get();
// dd($hour);
}
//klu xde g create.php
else
{
$hour = null;
}
return view('timesheet::dashboard.nonchargeableForm', compact('projectlist','userId','month','phase','daymonth','year','day','hour'));
}
// dd($check); public function overheadForm(Request $request)
{
$userId = users::find(Auth::id())
->u_staffID;
$project = Overhead::where('o_overhead_sts',1)
->get();
$projectlist = [];
// nanti project code query dari table project:
foreach ($project as $key => $value) {
$projectlist[] = [
'td_project' => $value->id,
'td_project_name' => $value->o_overhead_desc,
];
}
//sample dulu
$phase = 1;
$month = date('n');
$year = date('Y');
$day = date('j');
if(isset($request->phase))
{
$phase = $request->phase;
}
if(isset($request->month))
{
$month = $request->month;
}
if(isset($request->year))
{
$year = $request->year;
}
$daymonth=cal_days_in_month(CAL_GREGORIAN,$month,$year);
//check dlam db, kalau dah ada detail hours, kuar form edit, kalau belum, kuar form create
// check timesheet master
$check = Ts_master::where('tm_staff_id', $userId)
->where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->first();
//kalau ada, dia gi ke edit //kalau ada, dia gi ke edit
if($check) if($check)
{ {
$hour = Ts_detail::where('fk_tm_id',$check->id) $hour = Ts_detail::where('fk_tm_id',$check->id)
// ->with('project:p_project_code') // ->with('project:p_project_code')
->get(); ->get();
// dd($hour); // dd($hour);
} }
//klu xde g create.php //klu xde g create.php
...@@ -418,10 +535,11 @@ class DashboardController extends Controller ...@@ -418,10 +535,11 @@ class DashboardController extends Controller
{ {
$hour = null; $hour = null;
} }
return view('timesheet::dashboard.nonChargeableForm', compact('projectlist','userId','month','phase','daymonth','year','day','hour')); return view('timesheet::dashboard.overheadForm', compact('projectlist','userId','month','phase','daymonth','year','day','hour'));
} }
public function kalendarCharge() public function kalendarCharge()
{ {
return view('timesheet::dashboard.kalendarCharge'); return view('timesheet::dashboard.kalendarCharge');
...@@ -441,18 +559,17 @@ class DashboardController extends Controller ...@@ -441,18 +559,17 @@ class DashboardController extends Controller
{ {
// chargeable, project type 1. // chargeable, project type 1.
$chargeable = 1; $chargeable = 1;
$nonchargeable = 2;
$overhead = 3;
$user = users::where('id', Auth::id())->first(); $userId = users::find(Auth::id())
->u_staffID;
// check table master. untuk total chargeable hours. // check table master. untuk total chargeable hours.
$check = Ts_master::where('tm_staff_id', $user->u_staffID) $check = Ts_master::where('tm_staff_id', $userId)
->where('tm_year', $request->year) ->where('tm_year', $request->year)
->where('tm_month', $request->month) ->where('tm_month', $request->month)
->where('tm_phase', $request->phase) ->where('tm_phase', $request->phase)
->whereNotNull('tm_chargeable_hrs') ->whereNotNull('tm_chargeable_hrs')
->first(); ->first();
//kalau ada, update(). //kalau ada, update().
//staff kena edit bila timesheet kena reject. //staff kena edit bila timesheet kena reject.
...@@ -465,10 +582,10 @@ class DashboardController extends Controller ...@@ -465,10 +582,10 @@ class DashboardController extends Controller
else else
{ {
$check = new Ts_master; $check = new Ts_master;
$check->tm_staff_id = $user->u_staffID; $check->tm_staff_id = $userId;
$check->tm_year = $request->year; $check->tm_year = $request->year;
$check->tm_month = $request->month; $check->tm_month = $request->month;
$check->tm_phase = $request->phase; $check->tm_phase = $request->phase;
// $check ->tm_chargeable_hrs = ; // $check ->tm_chargeable_hrs = ;
$check->save(); $check->save();
} }
...@@ -505,27 +622,30 @@ class DashboardController extends Controller ...@@ -505,27 +622,30 @@ class DashboardController extends Controller
{ {
//update hours to null //update hours to null
$checkTimesheetDetail->td_hours = $valuehour; $checkTimesheetDetail->td_hours = $valuehour;
$checkTimesheetDetail->updated_by = $userI;
$checkTimesheetDetail->update(); $checkTimesheetDetail->update();
}//kalau takde, isi semua. } //kalau takde, isi semua.
else else
{ {
//isi semua //isi semua
$tmdetail = new Ts_detail; $tmdetail = new Ts_detail;
$tmdetail->td_date = $date; $tmdetail->td_date = $date;
$tmdetail->td_project = $projectid; $tmdetail->td_project = $projectid;
$tmdetail->fk_tm_id = $tmasterid; $tmdetail->fk_tm_id = $tmasterid;
$tmdetail->tm_staff_id = $user->u_staffID; $tmdetail->tm_staff_id = $userI;
$tmdetail->tm_month = $check->tm_month; $tmdetail->tm_month = $check->tm_month;
$tmdetail->tm_year = $check->tm_year; $tmdetail->tm_year = $check->tm_year;
$tmdetail->tm_phase = $check->tm_phase; $tmdetail->tm_phase = $check->tm_phase;
$tmdetail->td_project_type = $chargeable; $tmdetail->td_project_type = $chargeable;
$project = Project::where('id', $projectid)->first(); $project = Project::where('id', $projectid)
$tmdetail->td_project_name = $project->p_project_description; ->first();
$tmdetail->td_hours = $valuehour; $tmdetail->td_project_name = $project->p_project_description;
$tmdetail->td_hours = $valuehour;
$tmdetail->updated_by = $userI;
$tmdetail->save(); $tmdetail->save();
//$tmdetail -> kjhdiwhdf; //$tmdetail -> kjhdiwhdf;
...@@ -548,12 +668,134 @@ class DashboardController extends Controller ...@@ -548,12 +668,134 @@ class DashboardController extends Controller
$checktotalhours = Ts_master::where('id', $tmasterid)->first(); $checktotalhours = Ts_master::where('id', $tmasterid)->first();
$checktotalhours->tm_chargeable_hrs = $sumdetailhour; $checktotalhours->tm_chargeable_hrs = $sumdetailhour;
$checktotalhours->tm_chargeable_days = $sumdetailhour/8.0;
$checktotalhours->update(); $checktotalhours->update();
// return redirect::to('mobile/profile'); // return redirect::to('mobile/profile');
return redirect()->route('timesheet::dashboard.chargeableForm', ['phase' => $request->phase, 'month' =>$request->month,'year',$request->year])->with('success', 'Timesheet Updated'); return redirect()->route('timesheet::dashboard.chargeableForm', ['phase' => $request->phase, 'month' =>$request->month,'year',$request->year])->with('success', 'Timesheet Updated');
}
public function saveoverheadhours(Request $request)
{
// overhead, project type 3.
$overhead = 3;
$userId = users::find(Auth::id())
->u_staffID;
// check table master. untuk total chargeable hours.
$check = Ts_master::where('tm_staff_id', $userI)
->where('tm_year', $request->year)
->where('tm_month', $request->month)
->where('tm_phase', $request->phase)
->first();
//kalau ada, update().
//staff kena edit bila timesheet kena reject.
//kalau ada, biar dlu.
if($check)
{
}
// kalau takda, save() baru.
else
{
$check = new Ts_master;
$check->tm_staff_id = $userI;
$check->tm_year = $request->year;
$check->tm_month = $request->month;
$check->tm_phase = $request->phase;
$check->updated_by = $userI;
// $check ->tm_chargeable_hrs = ;
$check->save();
}
$tmasterid = $check->id;
// semak detail dari form
// untuk project type : 1 = chargeable, 2 = nonchargeable, 3 = overhead;
// . . .
$detail = $request->hour;
foreach ($detail as $key => $value)
{
foreach ($value as $keyday => $day)
{
$projectid = $key;
$date = $request->year.'-'.$request->month.'-'.sprintf('%02d', $keyday);
$checkTimesheetDetail = Ts_detail::where('fk_o_id', $projectid)
// ->where('td_project_type', $project_type)
->where('td_date', $date)
->where('tm_phase', $request->phase)
->first();
$valuehour = $day;
if($valuehour == null)
{
$valuehour = 0;
}
if($checkTimesheetDetail)
{
//update hours to null
$checkTimesheetDetail->td_hours = $valuehour;
$checkTimesheetDetail->updated_by = $userI;
$checkTimesheetDetail->update();
} //kalau takde, isi semua.
else
{
//isi semua
$tmdetail = new Ts_detail;
$tmdetail->td_date = $date;
$tmdetail->fk_o_id = $projectid;
$tmdetail->fk_tm_id = $tmasterid;
$tmdetail->tm_staff_id = $userI;
$tmdetail->tm_month = $check->tm_month;
$tmdetail->tm_year = $check->tm_year;
$tmdetail->tm_phase = $check->tm_phase;
$tmdetail->td_project_type = $overhead;
$tmdetail->updated_by = $userI;
$project = Overhead::where('id', $projectid)
->first();
$tmdetail->td_overhead_desc = $project->o_overhead_desc;
$tmdetail->td_hours = $valuehour;
$tmdetail->save();
//error kat sini -> done : typo nama column td_overhead_description
//$tmdetail -> kjhdiwhdf;
//project = Project::where('id','project')->first();
//
// /lepas save ();
}
}
}
//update total ke master;
//buat query sum td_hours where condition :
$sumdetailhour = Ts_detail::where('td_project_type', $overhead)
->where('tm_phase', $request->phase)
->sum('td_hours');
// checktotalhours
$checktotalhours = Ts_master::where('id', $tmasterid)->first();
$checktotalhours->tm_overhead_hrs = $sumdetailhour;
$checktotalhours->tm_overhead_days = $sumdetailhour/8.0;
$checktotalhours->update();
// return redirect::to('mobile/profile');
return redirect()->route('timesheet::dashboard.overheadForm', ['phase' => $request->phase, 'month' =>$request->month,'year',$request->year])->with('success', 'Timesheet Updated');
} }
public function senaraiOverhead() public function senaraiOverhead()
...@@ -566,9 +808,9 @@ class DashboardController extends Controller ...@@ -566,9 +808,9 @@ class DashboardController extends Controller
$overheads[] = [ $overheads[] = [
'id' => $value->id, 'id' => $value->id,
'lkp_overhead' => $value->o_overhead_desc, 'lkp_overhead' => $value->o_overhead_desc,
'status' => $value->o_overhead_sts, 'status' => $value->o_overhead_sts,
]; ];
} }
...@@ -582,16 +824,17 @@ class DashboardController extends Controller ...@@ -582,16 +824,17 @@ class DashboardController extends Controller
public function addoverheadlookup(Request $request) public function addoverheadlookup(Request $request)
{ {
$user = Users::where('id', Auth::id()) $userId = users::find(Auth::id())
->first(); ->u_staffID;
$data = new Overhead; $data = new Overhead;
$data->o_overhead_desc = $request->overheadlookup; $data->o_overhead_desc = $request->overheadlookup;
$data->o_overhead_sts = $request->status; $data->o_overhead_sts = $request->status;
$data->updated_by = $user->u_staffID; $data->updated_by = $userI;
$data->save(); $data->save();
return redirect()->route('timesheet::dashboard.senaraiOverhead'); return redirect()->route('timesheet::dashboard.senaraiOverhead')
->with('success', 'Role Updated');
} }
public function timesheetApproval() public function timesheetApproval()
......
...@@ -103,7 +103,11 @@ class ServiceProvider extends BaseServiceProvider ...@@ -103,7 +103,11 @@ class ServiceProvider extends BaseServiceProvider
$pengurusanProject->add(__('Senarai Peranan'), route('timesheet::dashboard.senaraiPeranan')) $pengurusanProject->add(__('Senarai Peranan'), route('timesheet::dashboard.senaraiPeranan'))
->data('icon', 'users icon') ->data('icon', 'users icon')
->active('pengurusan/*') ->active('pengurusan/*')
->data('permission', Permission::pengurusan); ->data('permission', Permission::pengurusan);
$pengurusanProject->add(__('Penambahan Peranan'), route('timesheet::dashboard.penambahanPeranan'))
->data('icon', 'users icon')
->active('pengurusan/*')
->data('permission', Permission::pengurusan);
$calendar = $this->app['laravolt.menu']->add(__('Kalendar'))->data('icon', 'calendar alternate'); $calendar = $this->app['laravolt.menu']->add(__('Kalendar'))->data('icon', 'calendar alternate');
$calendar->add(__('Kalendar'), route('timesheet::dashboard.kalendar')) $calendar->add(__('Kalendar'), route('timesheet::dashboard.kalendar'))
...@@ -132,7 +136,7 @@ class ServiceProvider extends BaseServiceProvider ...@@ -132,7 +136,7 @@ class ServiceProvider extends BaseServiceProvider
->active('nonChargeableForm/*') ->active('nonChargeableForm/*')
->data('permission', Permission::kehadiran); ->data('permission', Permission::kehadiran);
$form->add(__('Overhead'), route('timesheet::dashboard.overheadForm')) $form->add(__('Borang Overhead'), route('timesheet::dashboard.overheadForm'))
->data('icon', 'circle outline') ->data('icon', 'circle outline')
->active('overheadForm/*') ->active('overheadForm/*')
->data('permission', Permission::kehadiran); ->data('permission', Permission::kehadiran);
......
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