Commit 416672cb by hannan

add others option in notes

parent fdada6dc
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
@foreach($task as $key => $value) @foreach($task as $key => $value)
<option value="{{$value->id}}">{{$value->o_overhead_desc}}</option> <option value="{{$value->id}}">{{$value->o_overhead_desc}}</option>
@endforeach @endforeach
<option value="0">Others</option>
</select> </select>
</div> </div>
</div> </div>
......
...@@ -806,7 +806,58 @@ class FormController extends Controller ...@@ -806,7 +806,58 @@ class FormController extends Controller
$userId = Users::find(Auth::id()) $userId = Users::find(Auth::id())
->u_staffID; ->u_staffID;
// dd($request); $day = Carbon::createFromFormat('Y-m-d', $request->date)->day;
$month = Carbon::createFromFormat('Y-m-d', $request->date)->month;
$year = Carbon::createFromFormat('Y-m-d', $request->date)->year;
if ($day < 15) {
$phase = 1;
} else {
$phase = 2;
}
$check = Ts_master::where('tm_staff_id', $userId)
->where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->first();
$checkOthers = Ts_detail::where('td_date', $request->date)
->where('fk_tm_id', $check->id)
->where('fk_o_id', 0)
->first();
if ($request->task == 0) {
if ($checkOthers) {
$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();
} else {
$data = new Ts_detail;
$data->td_date = $request->date;
$data->fk_tm_id = $check->id;
$data->tm_staff_id = $userId;
$data->tm_month = $month;
$data->tm_year = $year;
$data->tm_phase = $phase;
$data->td_project_type = $overhead;
$data->fk_o_id = $request->task;
$data->td_overhead_desc = "OTHERS";
$data->td_overhead_note = $request->description;
$data->save();
}
} else {
$data = Ts_detail::where('tm_staff_id', $userId) $data = Ts_detail::where('tm_staff_id', $userId)
->where('td_project_type', $overhead) ->where('td_project_type', $overhead)
...@@ -817,6 +868,8 @@ class FormController extends Controller ...@@ -817,6 +868,8 @@ class FormController extends Controller
$data->td_overhead_note = $request->description; $data->td_overhead_note = $request->description;
$data->update(); $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');; 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');;
} }
......
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