Commit 8f784e21 by hannan

completion of nonchargeable form, add description button in overhead form

parent d1a8e31e
......@@ -83,7 +83,7 @@ input[type=number] {
<?php $total = 0; ?>
<tr>
<td class="single line">
{{$project['td_project_code']}}
{{ $project['td_project_code']}}
</td>
<td class="single line">
{{$project['td_project_name']}}
......
......@@ -30,14 +30,14 @@ input[type=number] {
<i class="dropdown icon"></i>
<div class="default text">Task</div>
<div class="menu">
@foreach($chargeables as $key => $chargeable)
<div class="item" data-value="{{$chargeable->p_project_description}}">{{$chargeable->p_project_description}}</div>
@foreach($nonchargeables as $key => $nonchargeable)
<div class="item" data-value="{{ $nonchargeable->id }}">{{$nonchargeable->p_project_description}}</div>
@endforeach
</div>
</div>
</div>
<div class="field">
<label>Non-Chargeable Task (**optional)</label>
<label>Non-Chargeable Task</label>
<input type="text" name="nonChargeableProject" placeholder="Add New Task">
</div>
<div class="field">
......@@ -92,7 +92,7 @@ input[type=number] {
Phase 1
</button>
@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()}}
<input type="hidden" name="userId" value="{{$userId}}">
<input type="hidden" name="year" value="{{$year}}">
......
......@@ -49,7 +49,7 @@ input[type=number] {
<thead>
<tr>
<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>
<button type="submit" class="fluid center aligned ui blue compact labeled icon button">
<i class="save icon"></i>
......@@ -58,7 +58,7 @@ input[type=number] {
</th>
</tr>
<tr>
<th class="single line">Task</th>
<th>Task</th>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
......@@ -70,18 +70,16 @@ input[type=number] {
@endfor
@endif
<th>Description</th>
<th>Total Hours</th>
</tr>
<tr>
</tr>
</thead>
<tbody>
@foreach($projectlist as $key => $project)
<?php $total = 0; ?>
<tr>
<td class="single line">
<td>
{{$project['td_project_name']}}
</td>
@if($phase == 1)
......@@ -132,6 +130,11 @@ input[type=number] {
@endfor
@endif
<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}}>
</td>
</tr>
......
......@@ -47,11 +47,9 @@ Route::group(
Route::get('timesheet_viewer',['uses' => 'DashboardController@timesheetViewer', 'as' => 'dashboard.timesheetViewer']);
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::get('pengurusan',['uses' => 'DashboardController@pengurusan', 'as' => 'dashboard.pengurusan']);
Route::get('perkhidmatan',['uses' => 'DashboardController@perkhidmatan', 'as' => 'dashboard.perkhidmatan']);
......
......@@ -118,12 +118,15 @@ class DashboardController extends Controller
public function addnewproject(Request $request)
{
$chargeable = 1;
$userId = users::find(Auth::id())
->u_staffID;
$project = new Project;
$project->p_project_code = $request->projectcode;
$project->p_project_description = $request->projectname;
$project->p_project_type = $chargeable;
$project->p_project_task_team = $request->projectmanager;
$project->p_project_sts = $request->status;
$project->updated_by = $userId;
......@@ -206,7 +209,8 @@ class DashboardController extends Controller
$pt->fk_project_id = $request->pid;
$pt->pt_project_description = $request->pname;
$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->role_id = $request->role;
$pt->updated_by = $userId;
......@@ -343,10 +347,13 @@ class DashboardController extends Controller
public function chargeableForm(Request $request)
{
$chargeable = 1;
$userId = users::find(Auth::id())
->u_staffID;
$project = Pteam::where('pt_staff_id',$userId)
->where('pt_project_type', $chargeable)
->get();
$projectlist = [];
......@@ -415,14 +422,16 @@ class DashboardController extends Controller
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())
->u_staffID;
$chargeables = Project::all();
$nonchargeables = Project::all();
$project = Pteam::where('pt_staff_id',$userId)
->where('pt_project_type', 2)
->get();
$projectlist = [];
......@@ -433,7 +442,6 @@ class DashboardController extends Controller
$projectlist[] = [
'td_project' => $value->fk_project_id,
'td_project_code' => $value->toProject->p_project_code,
'td_project_name' => $value->toProject->p_project_description,
];
......@@ -478,6 +486,7 @@ class DashboardController extends Controller
if($check)
{
$hour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $nonchargeable)
// ->with('project:p_project_code')
->get();
// dd($hour);
......@@ -487,7 +496,7 @@ class DashboardController extends Controller
{
$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)
......@@ -497,30 +506,94 @@ class DashboardController extends Controller
->where('id',Auth::id())
->first();
// dd($user->name);
if ($request->chargeableProject != null && $request->nonChargeableProject == null) {
dd('select only');
// $data = new Pteam;
// $data->pt_project_description = $request->chargeableProject;
// $data->pt_team = $user->name;
// $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;
// dd('select only');
$project = Project::where('id', $request->chargeableProject)
->first();
$data = new Pteam;
$data->fk_project_id = $request->chargeableProject;
$data->pt_project_description = $project->p_project_description;
$data->pt_team = $user->name;
$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) {
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) {
dd('input ja');
}else {
dd('blank');
}
// dd('input ja');
$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();
// $data = new Pteam;
// $data =
} else {
return redirect()->route('timesheet::dashboard.nonChargeableForm')->withErrors('You did not select any task or enter any input!');
}
return redirect()->route('timesheet::dashboard.nonChargeableForm')->withSuccess('Successfully Added New Task');
}
......@@ -626,7 +699,6 @@ class DashboardController extends Controller
->where('tm_year', $request->year)
->where('tm_month', $request->month)
->where('tm_phase', $request->phase)
->whereNotNull('tm_chargeable_hrs')
->first();
//kalau ada, update().
......@@ -644,6 +716,7 @@ class DashboardController extends Controller
$check->tm_year = $request->year;
$check->tm_month = $request->month;
$check->tm_phase = $request->phase;
$check->updated_by = $userId;
// $check ->tm_chargeable_hrs = ;
$check->save();
}
......@@ -665,7 +738,7 @@ class DashboardController extends Controller
$date = $request->year.'-'.$request->month.'-'.sprintf('%02d', $keyday);
$checkTimesheetDetail = Ts_detail::where('td_project', $projectid)
// ->where('td_project_type', $project_type)
->where('td_project_type', $nonchargeable)
->where('td_date', $date)
->where('tm_phase', $request->phase)
->first();
......@@ -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');
}
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)
{
// 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