Commit 9ecc5ff7 by fezrul

update sample chargeable

parent 25bc4e7a
...@@ -239,99 +239,97 @@ class DashboardController extends Controller ...@@ -239,99 +239,97 @@ class DashboardController extends Controller
public function saveHours(Request $request) public function saveHours(Request $request)
{ {
//filter function save atau update akan buat kat blade.
//Form Baru
//Form Edit after rejected
//Form Baru
//check dalam db table ts-detail. Kalau dah ada details dalam td_hours -> update().
//Kalau tak ada detail hours -> save()
$user = users::where('id', Auth::id())->first(); $user = users::where('id', Auth::id())->first();
//me - check dalam db, table ts_detail, kalau dah ada detail hours, edit.
$checkTimesheetDetail = Ts_detail::where('tm_staff_id', $user->u_staffID) // check table master. untuk total chargeable hours.
$check = Ts_master::where('tm_staff_id', $user->u_staffID)
->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('td_hours') ->whereNotNull('tm_chargeable_hrs')
->first(); ->first();
//update total chargeable hrs //kalau ada, update().
if($checkTimesheetDetail) //staff kena edit bila submission timesheet kena reject.
if($check)
{ {
$data = Ts_detail::where('tm_staff_id', $user->u_staffID)
->where('tm_year', $request->year)
->where('tm_month', $request->month)
->where('tm_phase', $request->phase)
->first();
$data ->td_hours = 10;
$data ->update();
} }
//kalau takda, save(). // kalau takda, save().
else else
{ {
// dd($checkTimesheetDetail); $check = new Ts_master;
$data = new Ts_detail; $check ->tm_year = $request ->year;
$data ->id = $request ->id; $check ->tm_month = $request ->month;
$data ->tm_year = $request ->year; $check ->tm_phase = $request ->phase;
$data ->tm_month = $request ->month; // $check ->tm_chargeable_hrs = ;
$data ->tm_phase = $request ->phase; $check ->save();
$data ->td_hours = 8;
$data ->save();
} }
$tmasterid = $check->id;
// check table master. untuk total chargeable hours. // semak detail dari form
// $check = Ts_master::where('tm_staff_id', $user->u_staffID)
// ->where('tm_year', $request->year)
// ->where('tm_month', $request->month)
// ->where('tm_phase', $request->phase)
// ->whereNotNull('tm_chargeable_hrs')
// ->first();
// //kalau ada, update(). //untuk project type : 1=chargeable,2 nonchargeable, 3=overhead;
// //staff kena edit bila submission timesheet kena reject. $detail = $request->hour;
// if($check) foreach ($detail as $key => $value)
// { {
// $data = Ts_master::where('id',$request->id)->first(); foreach ($value as $keyday => $day)
// //update total chargeable hrs {
// $data -> tm_chargeable_hrs = 10; $projectid = $key;
// $data -> update(); $date = $request->year.'-'.$request->month.'-'.sprintf('%02d', $keyday);
// }
// //kalau takda, save(). $checkTimesheetDetail = Ts_detail::where('fk_p_project_code', $projectid)
// else ->where('td_project_type',1)
// { ->where('td_date', $date)
// $data = new Ts_master; ->where('tm_phase', $request->phase)
// $data ->id = $request ->id; ->first();
// $data ->tm_year = $request ->year;
// $data ->tm_month = $request ->month; if($checkTimesheetDetail)
// $data ->tm_phase = $request ->phase; {
// $data ->tm_chargeable_hrs = 8; //update hours
// $data ->save(); $valuehour = $day;
// } if($valuehour == null)
{
$valuehour = 0;
}
//kalau ada juga = bawak data details $checkTimesheetDetail->td_hours = $valuehour;
$checkTimesheetDetail->update();
}else
{
//isi semua
$tmdetail = new Ts_detail;
//$tmdetail -> kjhdiwhdf;
//project = Project::where('id','project')->first();
//
// /lepas save ();
}
}
}
//update total ke master;
//buat query sum td_hour where condition :
// $sumdetailhour = Ts_detail::where('fk_p_project_code', $projectid)
// ->where('td_project_type',1)
// ->where('td_date', $date)
// ->where('tm_phase', $request->phase)
// ->sum();
// tm_master = Ts_master::where('tm_staff_id','=',Auth::id())
// ->where('tm_month','=',$tm_month)
// ->get();
// if(isset(tm_master))
// {
// }
//first = check dah ade ke belum // $check = Ts_master::where('id', $tmasterid)->first();
// $check->totaloiwfwoei = udaoe
//mula2 masuk dalam table master untuk dapat id master.php // return redirect::to('mobile/profile');
//pakai id master untuk update ke detail. return redirect()->route('timesheet::dashboard.borangBolehCaj', ['phase' => $request->phase, 'month' =>$request->month,'year',$request->year])->with('success', 'Timesheet Updated');
// $data = new Ts_master;
// $data -> tm_chargeable_hrs = $request -> tm_chargeable_hrs;
// $data -> save();
// return redirect('home');
} }
public function timesheetApproval() public function timesheetApproval()
......
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