Commit 8f784e21 by hannan

completion of nonchargeable form, add description button in overhead form

parent d1a8e31e
...@@ -83,7 +83,7 @@ input[type=number] { ...@@ -83,7 +83,7 @@ input[type=number] {
<?php $total = 0; ?> <?php $total = 0; ?>
<tr> <tr>
<td class="single line"> <td class="single line">
{{$project['td_project_code']}} {{ $project['td_project_code']}}
</td> </td>
<td class="single line"> <td class="single line">
{{$project['td_project_name']}} {{$project['td_project_name']}}
......
...@@ -30,14 +30,14 @@ input[type=number] { ...@@ -30,14 +30,14 @@ input[type=number] {
<i class="dropdown icon"></i> <i class="dropdown icon"></i>
<div class="default text">Task</div> <div class="default text">Task</div>
<div class="menu"> <div class="menu">
@foreach($chargeables as $key => $chargeable) @foreach($nonchargeables as $key => $nonchargeable)
<div class="item" data-value="{{$chargeable->p_project_description}}">{{$chargeable->p_project_description}}</div> <div class="item" data-value="{{ $nonchargeable->id }}">{{$nonchargeable->p_project_description}}</div>
@endforeach @endforeach
</div> </div>
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<label>Non-Chargeable Task (**optional)</label> <label>Non-Chargeable Task</label>
<input type="text" name="nonChargeableProject" placeholder="Add New Task"> <input type="text" name="nonChargeableProject" placeholder="Add New Task">
</div> </div>
<div class="field"> <div class="field">
...@@ -92,7 +92,7 @@ input[type=number] { ...@@ -92,7 +92,7 @@ input[type=number] {
Phase 1 Phase 1
</button> </button>
@endif @endif
<form class="ui form" action="{{ route('timesheet::dashboard.savechargeablehours' )}}" method="POST"> <form class="ui form" action="{{ route('timesheet::dashboard.savenonchargeablehours' )}}" method="POST">
{{csrf_field()}} {{csrf_field()}}
<input type="hidden" name="userId" value="{{$userId}}"> <input type="hidden" name="userId" value="{{$userId}}">
<input type="hidden" name="year" value="{{$year}}"> <input type="hidden" name="year" value="{{$year}}">
......
...@@ -49,7 +49,7 @@ input[type=number] { ...@@ -49,7 +49,7 @@ input[type=number] {
<thead> <thead>
<tr> <tr>
<th>Overhead</th> <th>Overhead</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th> <th colspan="@if($phase == 1) 16 @else {{$daymonth-16}} @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">
<i class="save icon"></i> <i class="save icon"></i>
...@@ -58,7 +58,7 @@ input[type=number] { ...@@ -58,7 +58,7 @@ input[type=number] {
</th> </th>
</tr> </tr>
<tr> <tr>
<th class="single line">Task</th> <th>Task</th>
@if($phase == 1) @if($phase == 1)
@for($i = 0; $i < 15 ; $i++) @for($i = 0; $i < 15 ; $i++)
...@@ -70,18 +70,16 @@ input[type=number] { ...@@ -70,18 +70,16 @@ input[type=number] {
@endfor @endfor
@endif @endif
<th>Description</th>
<th>Total Hours</th> <th>Total Hours</th>
</tr> </tr>
<tr>
</tr>
</thead> </thead>
<tbody> <tbody>
@foreach($projectlist as $key => $project) @foreach($projectlist as $key => $project)
<?php $total = 0; ?> <?php $total = 0; ?>
<tr> <tr>
<td class="single line"> <td>
{{$project['td_project_name']}} {{$project['td_project_name']}}
</td> </td>
@if($phase == 1) @if($phase == 1)
...@@ -132,6 +130,11 @@ input[type=number] { ...@@ -132,6 +130,11 @@ input[type=number] {
@endfor @endfor
@endif @endif
<td> <td>
<button class="ui center blue button">
<i class="ui center edit white icon"></i>
</button>
</td>
<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}}> <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> </td>
</tr> </tr>
......
...@@ -47,11 +47,9 @@ Route::group( ...@@ -47,11 +47,9 @@ 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('savenonchargeablehours',['uses' => 'DashboardController@savenonchargeablehours', 'as' => 'dashboard.savenonchargeablehours']);
Route::post('saveoverheadhours',['uses' => 'DashboardController@saveoverheadhours', 'as' => 'dashboard.saveoverheadhours']); Route::post('saveoverheadhours',['uses' => 'DashboardController@saveoverheadhours', 'as' => 'dashboard.saveoverheadhours']);
Route::get('pengurusan',['uses' => 'DashboardController@pengurusan', 'as' => 'dashboard.pengurusan']); Route::get('pengurusan',['uses' => 'DashboardController@pengurusan', 'as' => 'dashboard.pengurusan']);
Route::get('perkhidmatan',['uses' => 'DashboardController@perkhidmatan', 'as' => 'dashboard.perkhidmatan']); Route::get('perkhidmatan',['uses' => 'DashboardController@perkhidmatan', 'as' => 'dashboard.perkhidmatan']);
......
...@@ -118,12 +118,15 @@ class DashboardController extends Controller ...@@ -118,12 +118,15 @@ class DashboardController extends Controller
public function addnewproject(Request $request) public function addnewproject(Request $request)
{ {
$chargeable = 1;
$userId = users::find(Auth::id()) $userId = users::find(Auth::id())
->u_staffID; ->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_type = $chargeable;
$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 = $userId; $project->updated_by = $userId;
...@@ -206,7 +209,8 @@ class DashboardController extends Controller ...@@ -206,7 +209,8 @@ class DashboardController extends Controller
$pt->fk_project_id = $request->pid; $pt->fk_project_id = $request->pid;
$pt->pt_project_description = $request->pname; $pt->pt_project_description = $request->pname;
$pt->pt_team = $staff->fullname; $pt->pt_team = $staff->fullname;
$pt->pt_staff_id = $value; $pt->pt_staff_id = $staff->staff_id;
// $pt->pt_staff_id = $value;
$pt->pt_project_task_sts = $request->status; $pt->pt_project_task_sts = $request->status;
$pt->role_id = $request->role; $pt->role_id = $request->role;
$pt->updated_by = $userId; $pt->updated_by = $userId;
...@@ -343,10 +347,13 @@ class DashboardController extends Controller ...@@ -343,10 +347,13 @@ class DashboardController extends Controller
public function chargeableForm(Request $request) public function chargeableForm(Request $request)
{ {
$chargeable = 1;
$userId = users::find(Auth::id()) $userId = users::find(Auth::id())
->u_staffID; ->u_staffID;
$project = Pteam::where('pt_staff_id',$userId) $project = Pteam::where('pt_staff_id',$userId)
->where('pt_project_type', $chargeable)
->get(); ->get();
$projectlist = []; $projectlist = [];
...@@ -415,14 +422,16 @@ class DashboardController extends Controller ...@@ -415,14 +422,16 @@ 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)
{ {
$nonchargeable = 2;
$userId = users::find(Auth::id()) $userId = users::find(Auth::id())
->u_staffID; ->u_staffID;
$chargeables = Project::all(); $nonchargeables = Project::all();
$project = Pteam::where('pt_staff_id',$userId) $project = Pteam::where('pt_staff_id',$userId)
->where('pt_project_type', 2)
->get(); ->get();
$projectlist = []; $projectlist = [];
...@@ -433,7 +442,6 @@ class DashboardController extends Controller ...@@ -433,7 +442,6 @@ class DashboardController extends Controller
$projectlist[] = [ $projectlist[] = [
'td_project' => $value->fk_project_id, 'td_project' => $value->fk_project_id,
'td_project_code' => $value->toProject->p_project_code,
'td_project_name' => $value->toProject->p_project_description, 'td_project_name' => $value->toProject->p_project_description,
]; ];
...@@ -478,6 +486,7 @@ class DashboardController extends Controller ...@@ -478,6 +486,7 @@ class DashboardController extends Controller
if($check) if($check)
{ {
$hour = Ts_detail::where('fk_tm_id',$check->id) $hour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $nonchargeable)
// ->with('project:p_project_code') // ->with('project:p_project_code')
->get(); ->get();
// dd($hour); // dd($hour);
...@@ -487,7 +496,7 @@ class DashboardController extends Controller ...@@ -487,7 +496,7 @@ class DashboardController extends Controller
{ {
$hour = null; $hour = null;
} }
return view('timesheet::dashboard.nonchargeableForm', compact('projectlist','userId','month','phase','daymonth','year','day','hour','chargeables')); return view('timesheet::dashboard.nonChargeableForm', compact('projectlist','userId','month','phase','daymonth','year','day','hour','nonchargeables'));
} }
public function addnonchargeabletask(Request $request) public function addnonchargeabletask(Request $request)
...@@ -497,30 +506,94 @@ class DashboardController extends Controller ...@@ -497,30 +506,94 @@ class DashboardController extends Controller
->where('id',Auth::id()) ->where('id',Auth::id())
->first(); ->first();
// dd($user->name);
if ($request->chargeableProject != null && $request->nonChargeableProject == null) { if ($request->chargeableProject != null && $request->nonChargeableProject == null) {
dd('select only'); // dd('select only');
$project = Project::where('id', $request->chargeableProject)
// $data = new Pteam; ->first();
// $data->pt_project_description = $request->chargeableProject;
// $data->pt_team = $user->name; $data = new Pteam;
// $data->pt_staff_id = $user->u_staffID; $data->fk_project_id = $request->chargeableProject;
// $data->pt_project_task_sts = $request->status; $data->pt_project_description = $project->p_project_description;
// $data->updated_by = $user->u_staffID; $data->pt_team = $user->name;
// $data->pt_project_type = $nonchargeable; $data->pt_staff_id = $user->u_staffID;
$data->pt_project_task_sts = $request->status;
$data->updated_by = $user->u_staffID;
$data->pt_project_type = $nonchargeable;
$data->save();
}else if ($request->chargeableProject != null && $request->nonChargeableProject != null) { }else if ($request->chargeableProject != null && $request->nonChargeableProject != null) {
dd('select and input'); // dd('select and input');
$project = Project::where('id', $request->chargeableProject)
->first();
$select = new Pteam;
$select->fk_project_id = $request->chargeableProject;
$select->pt_project_description = $project->p_project_description;
$select->pt_team = $user->name;
$select->pt_staff_id = $user->u_staffID;
$select->pt_project_task_sts = $request->status;
$select->updated_by = $user->u_staffID;
$select->pt_project_type = $nonchargeable;
$select->save();
$task = new Project;
$task->p_project_description = $request->nonChargeableProject;
$task->pt_project_type = $nonchargeable;
$task->p_project_sts = $request->status;
$task->updated_by = $user->u_staffID;
$task->save();
$taskId = Project::select('id')
->where('p_project_description', $request->nonChargeableProject)
->first();
// dd($taskId->id);
$pt = new Pteam;
$pt->pt_project_description = $request->nonChargeableProject;
$pt->fk_project_id = $taskId->id;
$pt->pt_team = $user->name;
$pt->pt_staff_id = $user->u_staffID;
$pt->pt_project_task_sts = $request->status;
$pt->updated_by = $user->u_staffID;
$pt->pt_project_type = $nonchargeable;
$pt->save();
}else if ($request->chargeableProject == null && $request->nonChargeableProject != null) { }else if ($request->chargeableProject == null && $request->nonChargeableProject != null) {
dd('input ja'); // dd('input ja');
}else {
dd('blank'); $task = new Project;
$task->p_project_description = $request->nonChargeableProject;
$task->p_project_type = $nonchargeable;
$task->p_project_sts = $request->status;
$task->updated_by = $user->u_staffID;
$task->save();
$taskId = Project::select('id')
->where('p_project_description', $request->nonChargeableProject)
->first();
// dd($taskId->id);
$pt = new Pteam;
$pt->pt_project_description = $request->nonChargeableProject;
$pt->fk_project_id = $taskId->id;
$pt->pt_team = $user->name;
$pt->pt_staff_id = $user->u_staffID;
$pt->pt_project_task_sts = $request->status;
$pt->updated_by = $user->u_staffID;
$pt->pt_project_type = $nonchargeable;
$pt->save();
} else {
return redirect()->route('timesheet::dashboard.nonChargeableForm')->withErrors('You did not select any task or enter any input!');
} }
// $data = new Pteam;
// $data =
return redirect()->route('timesheet::dashboard.nonChargeableForm')->withSuccess('Successfully Added New Task');
} }
...@@ -626,7 +699,6 @@ class DashboardController extends Controller ...@@ -626,7 +699,6 @@ class DashboardController extends Controller
->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')
->first(); ->first();
//kalau ada, update(). //kalau ada, update().
...@@ -644,6 +716,7 @@ class DashboardController extends Controller ...@@ -644,6 +716,7 @@ class DashboardController extends Controller
$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->updated_by = $userId;
// $check ->tm_chargeable_hrs = ; // $check ->tm_chargeable_hrs = ;
$check->save(); $check->save();
} }
...@@ -665,10 +738,10 @@ class DashboardController extends Controller ...@@ -665,10 +738,10 @@ class DashboardController extends Controller
$date = $request->year.'-'.$request->month.'-'.sprintf('%02d', $keyday); $date = $request->year.'-'.$request->month.'-'.sprintf('%02d', $keyday);
$checkTimesheetDetail = Ts_detail::where('td_project', $projectid) $checkTimesheetDetail = Ts_detail::where('td_project', $projectid)
// ->where('td_project_type', $project_type) ->where('td_project_type', $nonchargeable)
->where('td_date', $date) ->where('td_date', $date)
->where('tm_phase', $request->phase) ->where('tm_phase', $request->phase)
->first(); ->first();
$valuehour = $day; $valuehour = $day;
if($valuehour == null) if($valuehour == null)
...@@ -734,6 +807,129 @@ class DashboardController extends Controller ...@@ -734,6 +807,129 @@ class DashboardController extends Controller
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 savenonchargeablehours(Request $request)
{
// chargeable, project type 1.
$nonchargeable = 2;
$userId = users::find(Auth::id())
->u_staffID;
// dd($request->phase);
// check table master. untuk total chargeable hours.
$check = Ts_master::where('tm_staff_id', $userId)
->where('tm_year', $request->year)
->where('tm_month', $request->month)
->where('tm_phase', $request->phase)
->first();
// dd($check);
//kalau ada, update().
//staff kena edit bila timesheet kena reject.
//kalau ada, biar dlu.
if($check)
{
// dd('tmaster dah ada');
}
// kalau takda, save() baru.
else
{
// dd('null, gi sini');
$check = new Ts_master;
$check->tm_staff_id = $userId;
$check->tm_year = $request->year;
$check->tm_month = $request->month;
$check->tm_phase = $request->phase;
$check->updated_by = $userId;
$check->save();
}
$tmasterid = $check->id;
// dd($tmasterid);
// 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;
// dd($projectid);
$date = $request->year.'-'.$request->month.'-'.sprintf('%02d', $keyday);
$checkTimesheetDetail = Ts_detail::where('td_project', $projectid)
->where('td_project_type', $nonchargeable)
->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 = $userId;
$checkTimesheetDetail->update();
} //kalau takde, isi semua.
else
{
//isi semua
$tmdetail = new Ts_detail;
$tmdetail->td_date = $date;
$tmdetail->td_project = $projectid;
$tmdetail->fk_tm_id = $tmasterid;
$tmdetail->tm_staff_id = $userId;
$tmdetail->tm_month = $check->tm_month;
$tmdetail->tm_year = $check->tm_year;
$tmdetail->tm_phase = $check->tm_phase;
$tmdetail->td_project_type = $nonchargeable;
$project = Project::where('id', $projectid)
->first();
$tmdetail->td_project_name = $project->p_project_description;
$tmdetail->td_hours = $valuehour;
$tmdetail->updated_by = $userId;
$tmdetail->save();
//$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', $nonchargeable)
->where('tm_phase', $request->phase)
->sum('td_hours');
// checktotalhours
$checktotalhours = Ts_master::where('id', $tmasterid)->first();
$checktotalhours->tm_nonchargeable_hrs = $sumdetailhour;
$checktotalhours->tm_nonchargeable_days = $sumdetailhour/8.0;
$checktotalhours->update();
// return redirect::to('mobile/profile');
return redirect()->route('timesheet::dashboard.nonChargeableForm', ['phase' => $request->phase, 'month' =>$request->month,'year',$request->year])->with('success', 'Timesheet Updated');
}
public function saveoverheadhours(Request $request) public function saveoverheadhours(Request $request)
{ {
// overhead, project type 3. // overhead, project type 3.
......
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