Commit 89c1ae9a by hannan

add notes as overhead description

parent e5d26e5a
......@@ -136,7 +136,6 @@
@endif
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<?php
......@@ -207,10 +206,79 @@
@endif
<td>Total Hours</td>
</tr>
@foreach($nonchargeablelist as $key => $projectnonchargeable)
<?php $total = 0; ?>
<tr>
<td style="width: 3%;"></td>
<td style="width: 23%;">{{ $projectnonchargeable['pname']}}</td>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<?php
$valnonchargehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($nonchargehour)
{
$valnonchargehour = $nonchargehour->where('td_date','=',$date)
->where('td_project',$projectnonchargeable['pid'])
->where('tm_phase',$phase)
->first();
$total += data_get($valnonchargehour,'td_hours');
}
?>
@if($valnonchargehour)
<td>{{ $valnonchargehour->td_hours }}</td>
@else
<td></td>
@endif
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<?php
$valnonchargehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($nonchargehour)
{
$valnonchargehour = $nonchargehour->where('td_date','=',$date)
->where('td_project',$projectnonchargeable['pid'])
->where('tm_phase',$phase)
->first();
$total += data_get($valnonchargehour,'td_hours');
}
?>
@if($valnonchargehour)
<td>{{ $valnonchargehour->td_hours }}</td>
@else
<td></td>
@endif
@endfor
@endif
@if($valnonchargehour)
<td>{{ $total }}</td>
@else
<td>0</td>
@endif
</tr>
@endforeach
</tbody>
<tfoot>
<th colspan="@if($phase == 1) 17 @else {{$daymonth-13}} @endif">Total</th>
<th>20</th>
<th>@if($totalnonchargehrs){{ $totalnonchargehrs }}@else 0 @endif</th>
</tfoot>
</table>
</div>
......@@ -327,6 +395,12 @@
<td style="width: 13.5%;">Date</td>
<td>Description</td>
</tr>
@foreach($notes as $key => $value)
<tr>
<td>{{ $value->td_date }}</td>
<td>{{ $value->td_overhead_note }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
......
@extends('ui::layouts.app')
@section('content')
<div class="ui unstackable segment">
<a class="ui blue left ribbon label">Senarai Notes</a>
<a href="{{ route('timesheet::form.penambahannote') }}" class="ui right floated small primary labeled icon button">
<i class="plus icon"></i>Add New Project
</a><br>
<table class="ui celled padded table">
<thead>
<tr>
<th style="width: 3%;">No</th>
<th style="width: 10%;">Date</th>
<th style="width: 20%;">Task</th>
<th>Description</th>
</tr>
</thead>
<tbody>
@foreach($notes as $key => $value)
<tr>
<td>{{$key+1}} </td>
<td>{{ data_get($value,'td_date') }} </td>
<td>{{ data_get($value,'td_overhead_desc') }} </td>
<td>{{ data_get($value,'td_overhead_note') }} </td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<th colspan="6">
<div class="ui right floated pagination menu">
<a class="icon item">
<i class="left chevron icon"></i>
</a>
<a class="item">1</a>
<a class="item">2</a>
<a class="item">3</a>
<a class="item">4</a>
<a class="icon item">
<i class="right chevron icon"></i>
</a>
</div>
</th>
</tr>
</tfoot>
</table>
</div>
@endsection
......@@ -26,7 +26,7 @@ input[type=number] {
Overhead Description
</div>
<div class="content">
<form class="ui form" action="{{ route('timesheet::form.addOverheadDescription' )}}" method="POST">
<form class="ui form" action="{{ route('timesheet::form.addOverheadDescription') }}" method="POST">
{{csrf_field()}}
<input type="hidden" name="userId" value="{{$userId}}">
<input type="hidden" name="year" value="{{$year}}">
......@@ -86,6 +86,11 @@ input[type=number] {
Description
</button>
<button class="center aligned ui yellow compact labeled icon button" id="notes" onclick="window.location.href='{{ route('timesheet::form.notelist', ['year'=> $year, 'month'=> $month, 'phase'=> $phase, 'fk_tm_id'=> $check->id] ) }} ';">
<i class="plus icon"></i>
Notes
</button>
<form class="ui form" action="{{ route('timesheet::form.saveoverheadhours' )}}" method="POST">
{{csrf_field()}}
<input type="hidden" name="userId" value="{{$userId}}">
......@@ -97,7 +102,7 @@ input[type=number] {
<thead>
<tr>
<th>Overhead</th>
<th colspan="@if($phase == 1) 16 @else {{$daymonth-14}} @endif" class="center aligned">Date</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>
......@@ -112,13 +117,11 @@ input[type=number] {
@for($i = 0; $i < 15 ; $i++)
<th>{{$i+1}}</th>
@endfor
@else
{{ $daymonth }}
@else
@for($i = 15; $i < $daymonth; $i++)
<th>{{$i+1}}</th>
@endfor
@endif
<th>Description</th>
<th>Total Hours</th>
</tr>
</thead>
......@@ -154,26 +157,6 @@ input[type=number] {
<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
<?php
if ($hour) {
$note = $hour->where('td_overhead_desc', $project['td_project_name'])
->where('tm_phase', $phase)
->where('td_overhead_note', '!=', null)
->first();
} else {
$note = null;
}
?>
<td class="ui center aligned">
@if($note)
<i class="bordered green eye icon view_button" data-overheadid="{{ $project['td_project'] }}" data-month="{{ $month }}" data-year="{{ $year }}" data-tmstaffid="{{ $userId }}" data-phase="{{ $phase }}"></i>
@else
<i class="bordered disabled red eye slash icon"></i>
@endif
</td>
@else
@for($i = 15; $i < $daymonth; $i++)
......@@ -197,25 +180,6 @@ input[type=number] {
<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
<?php
if ($hour) {
$note = $hour->where('td_overhead_desc', $project['td_project_name'])
->where('tm_phase', $phase)
->where('td_overhead_note', '!=', null)
->first();
} else {
$note = null;
}
?>
<td class="ui center aligned">
@if($note)
<i class="bordered green eye icon view_button" data-overheadid="{{ $project['td_project'] }}" data-month="{{ $month }}" data-year="{{ $year }}" data-tmstaffid="{{ $userId }}"></i>
@else
<i class="bordered disabled red eye slash icon"></i>
@endif
</td>
@endif
<td>
......
@extends('ui::layouts.app')
@section('content')
<div class="ui segment">
<a class="ui blue left ribbon label">Penambahan Note</a>
<br><br>
<form class="ui form" action="{{ route('timesheet::form.addnote') }}" method="POST">
{{csrf_field()}}
<div class="two fields">
<div class="three wide field">
<label>Date</label>
<input type="Date" name="date">
</div>
<div class="three wide field">
<label>Task</label>
<select name="task" class="ui fluid dropdown">
@foreach($task as $key => $value)
<option value="{{$value->id}}">{{$value->o_overhead_desc}}</option>
@endforeach
</select>
</div>
</div>
<div class="field">
<label>Description</label>
<textarea name="description" cols="30" rows="10"></textarea>
</div>
<button class="ui button" type="submit">Submit</button>
</form>
</div>
@endsection
\ No newline at end of file
......@@ -47,6 +47,9 @@ Route::group(
Route::post('savenonchargeablehours',['uses' => 'FormController@savenonchargeablehours', 'as' => 'form.savenonchargeablehours']);
Route::post('saveoverheadhours',['uses' => 'FormController@saveoverheadhours', 'as' => 'form.saveoverheadhours']);
Route::post('addOverheadDescription',['uses' => 'FormController@addOverheadDescription', 'as' => 'form.addOverheadDescription']);
Route::get('notelist',['uses' => 'FormController@notelist', 'as' => 'form.notelist']);
Route::get('penambahannote',['uses' => 'FormController@penambahannote', 'as' => 'form.penambahannote']);
Route::post('addnote', ['uses' => 'FormController@addnote', 'as' => 'form.addnote']);
// nonChargeableForm
Route::post('addnonchargeabletask',['uses' => 'FormController@addnonchargeabletask', 'as' => 'form.addnonchargeabletask']);
......
......@@ -135,10 +135,17 @@ class DashboardController extends Controller
->where('pt_project_type', $chargeable)
->get();
$nonchargeableproject = Pteam::where('pt_staff_id',$user->staff_id)
->where('pt_project_type', $nonchargeable)
->get();
$overheadproject = Overhead::where('o_overhead_sts',1)
->get();
->get();
$chargeablelist = [];
$nonchargeablelist = [];
$overheadlist = [];
foreach($chargeableproject as $key => $value) {
......@@ -153,6 +160,17 @@ class DashboardController extends Controller
}
foreach ($nonchargeableproject as $key => $value) {
$nonchargeablelist[] = [
'pid' => $value->fk_project_id,
'pname' => $value->toProject->p_project_description,
];
}
foreach ($overheadproject as $key => $value) {
$overheadlist[] = [
......@@ -175,14 +193,34 @@ class DashboardController extends Controller
$chargehour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $chargeable)
// ->where('td_hours', '!=', 0)
->get();
$nonchargehour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $nonchargeable)
// ->where('td_hours', '!=', 0)
->get();
// $filledoverhead = Ts_detail::where('fk_tm_id',$check->id)
// ->where('td_project_type', $overhead)
// // ->where('td_hours', '!=', 0)
// ->get();
// foreach ($filledoverhead as $key => $value) {
// $temp[$key] =
// if($overheadlist[$key] != $overheadlist[$key+1]) {
// $overheadlist[] = [
// 'pid' => $value->fk_o_id,
// 'pname' => $value->td_overhead_desc,
// ];
// }
// }
// dd($overheadlist);
$overheadhour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $overhead)
// ->where('td_hours', '!=', 0)
->get();
}
......@@ -198,7 +236,17 @@ class DashboardController extends Controller
$totalnonchargehrs = $check->tm_nonchargeable_hrs;
$totaloverheadhrs = $check->tm_overhead_hrs;
return view('timesheet::dashboard.timesheetViewer', compact('user', 'dept', 'hod', 'phase', 'month', 'year', 'day', 'strMonth', 'daymonth', 'chargeablelist', 'overheadlist', 'chargehour', 'totalchargehrs', 'totalnonchargehrs', 'totaloverheadhrs', 'overheadhour'));
$notes = Ts_detail::where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->where('fk_tm_id', $check->id)
->where('tm_staff_id', $user->staff_id)
->where('td_project_type', $overhead)
->whereNotNull('td_overhead_note')
->orderby('td_date')
->get();
return view('timesheet::dashboard.timesheetViewer', compact('user', 'dept', 'hod', 'phase', 'month', 'year', 'day', 'strMonth', 'daymonth', 'chargeablelist', 'nonchargeablelist', 'overheadlist', 'chargehour', 'nonchargehour', 'totalchargehrs', 'totalnonchargehrs', 'totaloverheadhrs', 'overheadhour', 'notes'));
}
......
......@@ -32,8 +32,6 @@ class FormController extends Controller
$userId = users::find(Auth::id())
->u_staffID;
// dd($userId);
$project = Pteam::where('pt_staff_id',$userId)
->where('pt_project_type', $chargeable)
......@@ -41,8 +39,6 @@ class FormController extends Controller
$projectlist = [];
// nanti project code query dari table project:
foreach ($project as $key => $value) {
$projectlist[] = [
......@@ -55,13 +51,17 @@ class FormController extends Controller
}
//sample dulu
$phase = 1;
$month = date('n');
$year = date('Y');
$day = date('j');
if ($day < 16) {
$phase = 1;
} else {
$phase = 2;
}
if(isset($request->phase))
{
$phase = $request->phase;
......@@ -79,25 +79,17 @@ class FormController extends Controller
$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
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;
......@@ -108,27 +100,21 @@ class FormController extends Controller
public function savechargeablehours(Request $request)
{
// chargeable, project type 1.
$chargeable = 1;
$userId = users::find(Auth::id())
->u_staffID;
// 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();
//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;
......@@ -137,16 +123,11 @@ class FormController extends Controller
$check->tm_month = $request->month;
$check->tm_phase = $request->phase;
$check->updated_by = $userId;
// $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;
......@@ -171,16 +152,15 @@ class FormController extends Controller
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;
......@@ -197,12 +177,7 @@ class FormController extends Controller
$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 ();
$tmdetail->save();
}
......@@ -222,8 +197,6 @@ class FormController extends Controller
$checktotalhours->tm_chargeable_days = $sumdetailhour/8.0;
$checktotalhours->update();
// return redirect::to('mobile/profile');
return redirect()->route('timesheet::form.chargeableForm', ['phase' => $request->phase, 'month' =>$request->month,'year',$request->year])->with('success', 'Timesheet Updated');
}
......@@ -242,7 +215,6 @@ class FormController extends Controller
->get();
$projectlist = [];
// nanti project code query dari table project:
foreach ($project as $key => $value) {
......@@ -255,13 +227,17 @@ class FormController extends Controller
}
//sample dulu
$phase = 1;
$month = date('n');
$year = date('Y');
$day = date('j');
if ($day < 16) {
$phase = 1;
} else {
$phase = 2;
}
if(isset($request->phase))
{
$phase = $request->phase;
......@@ -279,30 +255,23 @@ class FormController extends Controller
$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
if($check)
{
$hour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $nonchargeable)
// ->with('project:p_project_code')
->get();
// dd($hour);
}
//klu xde g create.php
else
{
$hour = null;
}
return view('timesheet::form.nonChargeableForm', compact('projectlist','userId','month','phase','daymonth','year','day','hour','nonchargeables'));
}
......@@ -315,7 +284,7 @@ class FormController extends Controller
if ($request->chargeableProject != null && $request->nonChargeableProject == null) {
// dd('select only');
$project = Project::where('id', $request->chargeableProject)
->first();
......@@ -330,7 +299,7 @@ class FormController extends Controller
$data->save();
}else if ($request->chargeableProject != null && $request->nonChargeableProject != null) {
// dd('select and input');
$project = Project::where('id', $request->chargeableProject)
->first();
......@@ -556,6 +525,12 @@ class FormController extends Controller
$year = date('Y');
$day = date('j');
if ($day < 16) {
$phase = 1;
} else {
$phase = 2;
}
if(isset($request->phase))
{
$phase = $request->phase;
......@@ -573,9 +548,6 @@ class FormController extends Controller
$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)
......@@ -595,7 +567,9 @@ class FormController extends Controller
$hour = null;
}
return view('timesheet::form.overheadForm', compact('projectlist','userId','month','phase','daymonth','year','day','hour', 'project'));
// dd($check->id);
return view('timesheet::form.overheadForm', compact('projectlist','userId','month','phase','daymonth','year','day','hour', 'project', 'check'));
}
public function saveoverheadhours(Request $request)
......@@ -716,8 +690,6 @@ class FormController extends Controller
$checktotalhours->tm_overhead_days = $sumdetailhour/8.0;
$checktotalhours->update();
// return redirect::to('mobile/profile');
return redirect()->route('timesheet::form.overheadForm', ['phase' => $request->phase, 'month' =>$request->month,'year',$request->year])->with('success', 'Timesheet Updated');
}
......@@ -785,12 +757,6 @@ class FormController extends Controller
}
return redirect()->route('timesheet::form.overheadForm')->with('success', 'Timesheet Updated');
// $data = Ts_detail::where('td_date', $request->date)
// ->where('')
// $data = new ODesc;
}
// public function loadnotes(Request $request)
......@@ -804,13 +770,54 @@ class FormController extends Controller
->where('tm_staff_id', $staffid)
->paginate(8);
// foreach ($Desc as $key => $value) {
// dd($key);
// $viewDesc = $value;
// }
return view('timesheet::ajax.senarainotes', compact('viewDesc'));
}
public function notelist(Request $request)
{
$overhead = 3;
return view('timesheet::ajax.senarainotes', compact('viewDesc'));
$userId = Users::find(Auth::id())
->u_staffID;
$notes = Ts_detail::where('tm_year', $request->year)
->where('tm_month', $request->month)
->where('tm_phase', $request->phase)
->where('fk_tm_id', $request->fk_tm_id)
->where('tm_staff_id', $userId)
->where('td_project_type', $overhead)
->whereNotNull('td_overhead_note')
->orderby('td_date')
->get();
return view('timesheet::form.notelist', compact('notes'));
}
public function penambahannote()
{
$task = Overhead::where('o_overhead_sts', 1)->get();
// dd($task);
return view('timesheet::form.penambahannote', compact('task'));
}
public function addnote(Request $request)
{
$overhead = 3;
$userId = Users::find(Auth::id())
->u_staffID;
// dd($request);
$data = Ts_detail::where('tm_staff_id', $userId)
->where('td_project_type', $overhead)
->where('fk_o_id', $request->task)
->where('td_date', $request->date)
->first();
$data->td_overhead_note = $request->description;
$data->update();
return redirect()->route('timesheet::form.notelist', ['year'=> $data->tm_year, 'month' =>$data->tm_month, 'phase' => $data->tm_phase, 'fk_tm_id' => $data->fk_tm_id])->with('success', 'Note Added');;
}
}
\ No newline at end of file
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