Commit 014ea218 by Azhan Hannan

chargeable hours, only saved filled hours.

parent 7e887fe9
......@@ -224,6 +224,8 @@ class FormController extends Controller
{
$date = $request->year.'-'.$request->month.'-'.sprintf('%02d', $keyday);
// dd($date);
$checkTimesheetDetail = Ts_detail::where('fk_tm_id', $tmasterid)
->where('td_project', $projectid)
->where('td_project_type', $chargeable)
......@@ -238,36 +240,44 @@ class FormController extends Controller
$valuehour = 0;
}
if($checkTimesheetDetail)
if($valuehour == 0)
{
$checkTimesheetDetail->td_hours = $valuehour;
$checkTimesheetDetail->updated_by = $userId;
$checkTimesheetDetail->save();
}
else
}
else
{
$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 = $chargeable;
$project = Project::where('id', $projectid)
->first();
if($checkTimesheetDetail)
{
$checkTimesheetDetail->td_hours = $valuehour;
$checkTimesheetDetail->updated_by = $userId;
$checkTimesheetDetail->save();
$tmdetail->td_project_name = $project->p_project_description;
$tmdetail->td_hours = $valuehour;
$tmdetail->td_timesheet_sts = 1;
$tmdetail->updated_by = $userId;
$tmdetail->save();
}
else
{
$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 = $chargeable;
$project = Project::where('id', $projectid)
->first();
$tmdetail->td_project_name = $project->p_project_description;
$tmdetail->td_hours = $valuehour;
$tmdetail->td_timesheet_sts = 1;
$tmdetail->updated_by = $userId;
$tmdetail->save();
}
}
}
......
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