Commit 57937b94 by fezrul

update edit / display

parent 926b586a
...@@ -77,12 +77,18 @@ input[type=number] { ...@@ -77,12 +77,18 @@ input[type=number] {
</td> </td>
@if($phase == 1) @if($phase == 1)
@for($i = 0; $i < 15 ; $i++) @for($i = 0; $i < 15 ; $i++)
<?php
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
$valuehour = $hour->where('td_date','=',$date)->where('td_project',$project['td_project'])
->where('tm_phase',$phase)
->first();
?>
<td > <td >
@if($project['td_date'] == $i+1) <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']}}');">
<input type="text" onkeypress="onlynumber(event)" name="hour[{{$project['td_project']}}][{{$i+1}}]" id="hour[{{$project['td_project']}}][{{$i+1}}]" value="{{$project['td_hours']}}" min="0" max="24" style="padding:2px;margin:unset;color:#A0A0A0;" onchange="limiter(this,'{{$project['td_project']}}');" readonly="readonly">
@else
<input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$i+1}}]" name="hour[{{$project['td_project']}}][{{$i+1}}]" value="" min="0" max="24" style="padding:2px;margin:unset" onchange="limiter(this,'{{$project['td_project']}}');">
@endif
</td> </td>
@endfor @endfor
@else @else
......
...@@ -79,6 +79,7 @@ class DashboardController extends Controller ...@@ -79,6 +79,7 @@ class DashboardController extends Controller
public function borangBolehCaj(Request $request) public function borangBolehCaj(Request $request)
{ {
$userId = Auth::id(); $userId = Auth::id();
$user = users::where('id', Auth::id())->first();
$projectcode = 'Project Code'; $projectcode = 'Project Code';
$projectname = 'Project Name'; $projectname = 'Project Name';
...@@ -179,18 +180,19 @@ class DashboardController extends Controller ...@@ -179,18 +180,19 @@ class DashboardController extends Controller
->where('tm_year', $year) ->where('tm_year', $year)
->where('tm_month', $month) ->where('tm_month', $month)
->where('tm_phase', $phase) ->where('tm_phase', $phase)
->whereNotNull('tm_chargeable_hrs')
->first(); ->first();
// dd($check);
//kalau ada, dia gi ke edit //kalau ada, dia gi ke edit
if($check) if($check)
{ {
$data = Ts_master::where('id',$request->id)->first(); $hour = Ts_detail::where('fk_tm_id',$check->id)->get();
} }
//klu xde g create.php //klu xde g create.php
else else
{ {
$data = []; $hour = null;
} }
//kalau ada juga = bawak data details //kalau ada juga = bawak data details
...@@ -216,8 +218,8 @@ class DashboardController extends Controller ...@@ -216,8 +218,8 @@ class DashboardController extends Controller
// } // }
// dd($checkTimesheetDetail); // dd($checkTimesheetDetail);
// dd($hour);
return view('timesheet::dashboard.borangBolehCaj', compact('userId','projectcode', 'projectname','month','phase','samplequery','daymonth','year','sampleTimesheet_dtl','day','data')); return view('timesheet::dashboard.borangBolehCaj', compact('userId','projectcode', 'projectname','month','phase','samplequery','daymonth','year','sampleTimesheet_dtl','day','hour'));
} }
public function kalendarCharge() public function kalendarCharge()
...@@ -292,15 +294,17 @@ class DashboardController extends Controller ...@@ -292,15 +294,17 @@ class DashboardController extends Controller
->where('tm_phase', $request->phase) ->where('tm_phase', $request->phase)
->first(); ->first();
if($checkTimesheetDetail)
{
//update hours to null
$valuehour = $day; $valuehour = $day;
if($valuehour == null) if($valuehour == null)
{ {
$valuehour = 0; $valuehour = 0;
} }
if($checkTimesheetDetail)
{
//update hours to null
$checkTimesheetDetail->td_hours = $valuehour; $checkTimesheetDetail->td_hours = $valuehour;
$checkTimesheetDetail->update(); $checkTimesheetDetail->update();
...@@ -321,7 +325,7 @@ class DashboardController extends Controller ...@@ -321,7 +325,7 @@ class DashboardController extends Controller
$project = Project::where('id', $projectid)->first(); $project = Project::where('id', $projectid)->first();
$tmdetail->td_project_name = $project->p_project_description; $tmdetail->td_project_name = $project->p_project_description;
$tmdetail->td_hours = $day; $tmdetail->td_hours = $valuehour;
$tmdetail->save(); $tmdetail->save();
//$tmdetail -> kjhdiwhdf; //$tmdetail -> kjhdiwhdf;
...@@ -342,11 +346,12 @@ class DashboardController extends Controller ...@@ -342,11 +346,12 @@ class DashboardController extends Controller
// ->where('td_date', $date) // ->where('td_date', $date)
->where('tm_phase', $request->phase) ->where('tm_phase', $request->phase)
->sum('td_hours'); ->sum('td_hours');
dd($sumdetailhour); // dd($sumdetailhour);
// checktotalhours
$checktotalhours = Ts_master::where('id', $tmasterid) $checktotalhours = Ts_master::where('id', $tmasterid)->first();
->where('tm_chargeable_hrs', $sumdetailhour) $checktotalhours->tm_chargeable_hrs = $sumdetailhour;
->update(); $checktotalhours->update();
// return redirect::to('mobile/profile'); // return redirect::to('mobile/profile');
......
...@@ -15,7 +15,7 @@ class Ts_master extends Model ...@@ -15,7 +15,7 @@ class Ts_master extends Model
public function Details() public function Details()
{ {
return $this->hasMany('App\Models\Ts_detail','tm_id','id'); return $this->hasMany('Portal\Timesheet\Model\Ts_detail','fk_tm_id','id');
} }
/** /**
......
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