Commit 3c95e20b by hannan

remove nonchargeable in form and dashboard controller

parent 9a697d00
......@@ -415,17 +415,6 @@ class DashboardController extends Controller
$dept = Department::where('id', $user->fk_lkp_department)
->first();
// dd(Staff_info::all());
// $hod = Staff_info::find($user->penyokong)
// ->fullname;
// $penyokong = Staff_info::where('penyokong', 0)
// ->get();
// dd($penyokong);
// $bod = Staff_info::select('id', 'fullname')
// ->whereIn('id', [1,45,46,47,48])
// ->get();
$year = date('Y');
if(isset($request->phase))
......@@ -471,7 +460,6 @@ class DashboardController extends Controller
->get();
$chargeablelist = [];
$nonchargeablelist = [];
$overheadlist = [];
foreach($chargeableproject as $key => $value) {
......@@ -486,17 +474,6 @@ class DashboardController extends Controller
}
foreach ($nonchargeableproject as $key => $value) {
$nonchargeablelist[] = [
'pid' => $value->fk_project_id,
'pname' => $value->toProject->p_project_description,
];
}
$check = Ts_master::where('tm_staff_id', $user->staff_id)
->where('tm_year', $year)
->where('tm_month', $month)
......@@ -513,11 +490,6 @@ class DashboardController extends Controller
// ->where('td_hours', '!=', 0)
->get();
$nonchargehour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $nonchargeable)
// ->where('td_hours', '!=', 0)
->get();
$overheadhour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $overhead)
->where('td_hours', '!=', 0)
......@@ -559,7 +531,6 @@ class DashboardController extends Controller
}
$totalchargehrs = $check->tm_chargeable_hrs;
$totalnonchargehrs = $check->tm_nonchargeable_hrs;
$totaloverheadhrs = $check->tm_overhead_hrs;
$notes = Ts_detail::where('tm_year', $year)
......@@ -575,17 +546,15 @@ class DashboardController extends Controller
else
{
$chargehour = null;
$nonchargehour = null;
$overheadhour = null;
$totalchargehrs = null;
$totalnonchargehrs = null;
$totaloverheadhrs = null;
$notes = null;
$check = null;
}
// dd($check->id);
return view('timesheet::dashboard.timesheetViewer', compact('curruser', 'user','profile', 'dept', 'phase', 'month', 'year', 'strMonth', 'daymonth', 'chargeablelist', 'nonchargeablelist', 'overheadlist', 'chargehour', 'nonchargehour', 'totalchargehrs', 'totalnonchargehrs', 'totaloverheadhrs', 'overheadhour', 'notes', 'check', 'strdays'));
return view('timesheet::dashboard.timesheetViewer', compact('curruser', 'user','profile', 'dept', 'phase', 'month', 'year', 'strMonth', 'daymonth', 'chargeablelist', 'overheadlist', 'chargehour', 'totalchargehrs', 'totaloverheadhrs', 'overheadhour', 'notes', 'check', 'strdays'));
}
public function tsubmit(Request $request)
......
......@@ -45,19 +45,19 @@ class FormController extends Controller
return view('timesheet::form.filterChargeable', compact('month', 'currmonth', 'curryear'));
}
public function filterNonChargeable()
{
$currmonth = date('n');
$curryear = date('Y');
// public function filterNonChargeable()
// {
// $currmonth = date('n');
// $curryear = date('Y');
$month = [];
// $month = [];
for ($m=1; $m<=12; $m++) {
$month[] = date('F', mktime(0,0,0,$m, 1, date('Y')));
}
// for ($m=1; $m<=12; $m++) {
// $month[] = date('F', mktime(0,0,0,$m, 1, date('Y')));
// }
return view('timesheet::form.filterNonChargeable', compact('month', 'currmonth', 'curryear'));
}
// return view('timesheet::form.filterNonChargeable', compact('month', 'currmonth', 'curryear'));
// }
public function filterOverhead()
{
......@@ -92,10 +92,10 @@ class FormController extends Controller
return redirect()->route('timesheet::form.chargeableForm', ['phase' => $request->phase, 'month' =>$request->month]);
}
public function nonchargeableselectmonthphase(Request $request){
// public function nonchargeableselectmonthphase(Request $request){
return redirect()->route('timesheet::form.nonChargeableForm', ['phase' => $request->phase, 'month' =>$request->month]);
}
// return redirect()->route('timesheet::form.nonChargeableForm', ['phase' => $request->phase, 'month' =>$request->month]);
// }
public function overheadselectmonthphase(Request $request){
......@@ -319,357 +319,357 @@ class FormController extends Controller
return redirect()->route('timesheet::form.chargeableForm', ['phase' => $request->phase, 'month' =>$request->month,'year',$request->year])->with('success', 'Timesheet Updated');
}
public function nonChargeableForm(Request $request)
{
$nonchargeable = 2;
// public function nonChargeableForm(Request $request)
// {
// $nonchargeable = 2;
$userId = users::find(Auth::id())
->u_staffID;
// $userId = users::find(Auth::id())
// ->u_staffID;
$nonchargeables = Project::where('p_project_type', $nonchargeable)
->get();
// $nonchargeables = Project::where('p_project_type', $nonchargeable)
// ->get();
$pcodes = Project::select('p_project_code', 'p_project_description')
->whereNotNull('p_project_code')
->get();
// $pcodes = Project::select('p_project_code', 'p_project_description')
// ->whereNotNull('p_project_code')
// ->get();
// dd($pcode);
// // dd($pcode);
$project = Pteam::where('pt_staff_id',$userId)
->where('pt_project_type', $nonchargeable)
->get();
// $project = Pteam::where('pt_staff_id',$userId)
// ->where('pt_project_type', $nonchargeable)
// ->get();
$projectlist = [];
// $projectlist = [];
foreach ($project as $key => $value) {
// foreach ($project as $key => $value) {
$projectlist[] = [
// $projectlist[] = [
'td_project' => $value->fk_project_id,
'td_project_name' => $value->toProject->p_project_description,
];
}
$year = date('Y');
if(isset($request->phase))
{
$phase = $request->phase;
}
if(isset($request->month))
{
$month = $request->month;
}
if(isset($request->year))
{
$year = $request->year;
}
$daymonth=cal_days_in_month(CAL_GREGORIAN,$month,$year);
$strdays = [];
for ($i=0; $i < $daymonth; $i++) {
$tempdate = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
$strday = Carbon::createFromFormat('Y-m-d', $tempdate)->format('l');
$strdays[$i] = substr($strday, 0, 3);
}
$check = Ts_master::where('tm_staff_id', $userId)
->where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->first();
if($check)
{
$hour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project_type', $nonchargeable)
->get();
}
else
{
$hour = null;
}
$checkoverhead = Ts_master::where('tm_staff_id', $userId)
->where('tm_year', $year)
->where('tm_month', $month)
->where('tm_phase', $phase)
->first();
if ($checkoverhead) {
$fk_tm_id = $checkoverhead->id;
}
else
{
$fk_tm_id = null;
}
return view('timesheet::form.nonChargeableForm', compact('projectlist','userId','month','phase','daymonth','year','hour','nonchargeables','strdays', 'fk_tm_id', 'pcodes'));
}
public function addnonchargeabletask(Request $request)
{
// dd($request);
if(isset($request->phase))
{
$phase = $request->phase;
}
if(isset($request->month))
{
$month = $request->month;
}
if(isset($request->year))
{
$year = $request->year;
}
$nonchargeable = 2;
$user = Users::select('name','u_staffID')
->where('id',Auth::id())
->first();
if ($request->chargeableProject != null && $request->nonChargeableProject == null) {
$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) {
$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->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();
}else if ($request->chargeableProject == null && $request->nonChargeableProject != null) {
// 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();
} else {
return redirect()->route('timesheet::form.nonChargeableForm', compact('month', 'year', 'phase'))->withErrors('You did not select any task or enter any input!');
}
return redirect()->route('timesheet::form.nonChargeableForm', compact('month', 'year', 'phase'))->withSuccess('Successfully Added New Task');
}
// 'td_project' => $value->fk_project_id,
// 'td_project_name' => $value->toProject->p_project_description,
public function savenonchargeablehours(Request $request)
{
// dd($request);
$nonchargeable = 2;
$userId = users::find(Auth::id())
->u_staffID;
$check = Ts_master::where('tm_staff_id', $userId)
->where('tm_year', $request->year)
->where('tm_month', $request->month)
->where('tm_phase', $request->phase)
->first();
if($check)
{
}
else
{
$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->tm_timesheet_master_sts = 1;
$check->updated_by = $userId;
$check->save();
}
$tmasterid = $check->id;
$detail = $request->hour;
foreach ($detail as $key => $value)
{
$projectid = $key;
// ];
// }
// $year = date('Y');
// if(isset($request->phase))
// {
// $phase = $request->phase;
// }
// if(isset($request->month))
// {
// $month = $request->month;
// }
// if(isset($request->year))
// {
// $year = $request->year;
// }
// $daymonth=cal_days_in_month(CAL_GREGORIAN,$month,$year);
// $strdays = [];
// for ($i=0; $i < $daymonth; $i++) {
// $tempdate = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
// $strday = Carbon::createFromFormat('Y-m-d', $tempdate)->format('l');
// $strdays[$i] = substr($strday, 0, 3);
// }
// $check = Ts_master::where('tm_staff_id', $userId)
// ->where('tm_year', $year)
// ->where('tm_month', $month)
// ->where('tm_phase', $phase)
// ->first();
// if($check)
// {
// $hour = Ts_detail::where('fk_tm_id',$check->id)
// ->where('td_project_type', $nonchargeable)
// ->get();
// }
// else
// {
// $hour = null;
// }
// $checkoverhead = Ts_master::where('tm_staff_id', $userId)
// ->where('tm_year', $year)
// ->where('tm_month', $month)
// ->where('tm_phase', $phase)
// ->first();
// if ($checkoverhead) {
// $fk_tm_id = $checkoverhead->id;
// }
// else
// {
// $fk_tm_id = null;
// }
// return view('timesheet::form.nonChargeableForm', compact('projectlist','userId','month','phase','daymonth','year','hour','nonchargeables','strdays', 'fk_tm_id', 'pcodes'));
// }
// public function addnonchargeabletask(Request $request)
// {
// // dd($request);
// if(isset($request->phase))
// {
// $phase = $request->phase;
// }
// if(isset($request->month))
// {
// $month = $request->month;
// }
// if(isset($request->year))
// {
// $year = $request->year;
// }
// $nonchargeable = 2;
// $user = Users::select('name','u_staffID')
// ->where('id',Auth::id())
// ->first();
// if ($request->chargeableProject != null && $request->nonChargeableProject == null) {
// $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) {
// $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->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();
// }else if ($request->chargeableProject == null && $request->nonChargeableProject != null) {
// // 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();
// } else {
// return redirect()->route('timesheet::form.nonChargeableForm', compact('month', 'year', 'phase'))->withErrors('You did not select any task or enter any input!');
// }
// return redirect()->route('timesheet::form.nonChargeableForm', compact('month', 'year', 'phase'))->withSuccess('Successfully Added New Task');
// }
// public function savenonchargeablehours(Request $request)
// {
// // dd($request);
// $nonchargeable = 2;
// $userId = users::find(Auth::id())
// ->u_staffID;
// $check = Ts_master::where('tm_staff_id', $userId)
// ->where('tm_year', $request->year)
// ->where('tm_month', $request->month)
// ->where('tm_phase', $request->phase)
// ->first();
// if($check)
// {
// }
// else
// {
// $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->tm_timesheet_master_sts = 1;
// $check->updated_by = $userId;
// $check->save();
// }
// $tmasterid = $check->id;
// $detail = $request->hour;
// foreach ($detail as $key => $value)
// {
// $projectid = $key;
foreach ($value as $keyday => $day)
{
// foreach ($value as $keyday => $day)
// {
$date = $request->year.'-'.$request->month.'-'.sprintf('%02d', $keyday);
$checkTimesheetDetail = Ts_detail::where('fk_tm_id', $tmasterid)
->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)
{
// $date = $request->year.'-'.$request->month.'-'.sprintf('%02d', $keyday);
// $checkTimesheetDetail = Ts_detail::where('fk_tm_id', $tmasterid)
// ->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)
// {
$checkTimesheetDetail->td_hours = $valuehour;
$checkTimesheetDetail->updated_by = $userId;
$checkTimesheetDetail->update();
// $checkTimesheetDetail->td_hours = $valuehour;
// $checkTimesheetDetail->updated_by = $userId;
// $checkTimesheetDetail->update();
}
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 = $nonchargeable;
$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();
}
}
$checktproject = Tproject::where('fk_tm_id', $tmasterid)
->where('td_project', $projectid)
->first();
$checkhours = Ts_detail::where('fk_tm_id', $tmasterid)
->where('td_project', $projectid)
->where('td_hours', '!=', '0')
->get();
if ($checktproject) {
$checktproject->tp_hours = $checkhours->sum('td_hours');
$checktproject->update();
}
else
{
$tpdetail = new Tproject;
$tpdetail->td_project = $projectid;
$tpdetail->staffid = $userId;
$tpdetail->fk_tm_id = $tmasterid;
$tpdetail->tp_project_type = 2;
$tpdetail->tp_year = $request->year;
$tpdetail->tp_month = $request->month;
$tpdetail->tp_phase = $request->phase;
$project = Project::where('id', $projectid)
->first();
$tpdetail->tp_project_name = $project->p_project_description;
$tpdetail->tp_hours = $checkhours->sum('td_hours');
$tpdetail->tp_pm = $project->p_project_task_team;
$tpdetail->tp_timesheet_sts = 1;
$tpdetail->updated_by = $userId;
$tpdetail->save();
}
}
$sumdetailhour = Ts_detail::where('td_project_type', $nonchargeable)
->where('fk_tm_id', $tmasterid)
->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::form.nonChargeableForm', ['phase' => $request->phase, 'month' =>$request->month,'year',$request->year])->with('success', 'Timesheet Updated');
}
// $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->td_timesheet_sts = 1;
// $tmdetail->updated_by = $userId;
// $tmdetail->save();
// }
// }
// $checktproject = Tproject::where('fk_tm_id', $tmasterid)
// ->where('td_project', $projectid)
// ->first();
// $checkhours = Ts_detail::where('fk_tm_id', $tmasterid)
// ->where('td_project', $projectid)
// ->where('td_hours', '!=', '0')
// ->get();
// if ($checktproject) {
// $checktproject->tp_hours = $checkhours->sum('td_hours');
// $checktproject->update();
// }
// else
// {
// $tpdetail = new Tproject;
// $tpdetail->td_project = $projectid;
// $tpdetail->staffid = $userId;
// $tpdetail->fk_tm_id = $tmasterid;
// $tpdetail->tp_project_type = 2;
// $tpdetail->tp_year = $request->year;
// $tpdetail->tp_month = $request->month;
// $tpdetail->tp_phase = $request->phase;
// $project = Project::where('id', $projectid)
// ->first();
// $tpdetail->tp_project_name = $project->p_project_description;
// $tpdetail->tp_hours = $checkhours->sum('td_hours');
// $tpdetail->tp_pm = $project->p_project_task_team;
// $tpdetail->tp_timesheet_sts = 1;
// $tpdetail->updated_by = $userId;
// $tpdetail->save();
// }
// }
// $sumdetailhour = Ts_detail::where('td_project_type', $nonchargeable)
// ->where('fk_tm_id', $tmasterid)
// ->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::form.nonChargeableForm', ['phase' => $request->phase, 'month' =>$request->month,'year',$request->year])->with('success', 'Timesheet Updated');
// }
public function overheadForm(Request $request)
{
......
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