Commit 0ef4746b by Azhan Hannan

detect hari bekerja

parent c9613c8d
...@@ -66,38 +66,58 @@ input[type=number] { ...@@ -66,38 +66,58 @@ input[type=number] {
</th> </th>
</tr> </tr>
<tr> <tr>
<?php @if(count($lat) > 0)
$cday = []; @foreach($lat as $key => $date)
for ($i=0; $i < $daymonth; $i++) { @if(data_get($date,'day_type') == 1 )
$cday[] = 0; <th>{{date_parse_from_format('Y-m-d', data_get($date,'DATE'))['day']}}</th>
} @else
?> <th style="background-color: #DCDCDC;">
@if($phase == 1) {{date_parse_from_format('Y-m-d', data_get($date,'DATE'))['day']}}
</th>
@for($i = 0; $i < 15 ; $i++) @endif
<th>{{$i+1}}</th> @endforeach
@endfor @else
@else @if($phase == 1)
@for($i = 15; $i < $daymonth; $i++)
<th>{{$i+1}}</th> @for($i = 0; $i < 15 ; $i++)
@endfor <th>{{$i+1}}</th>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<th>{{$i+1}}</th>
@endfor
@endif
@endif @endif
</tr> </tr>
<tr> <tr>
<th class="single line">Project Code</th> <th class="single line">Project Code</th>
<th class="single line">Project Name</th> <th class="single line">Project Name</th>
@if($phase == 1) @if(count($lat) > 0)
@foreach($lat as $key => $date)
@if(data_get($date,'day_type') == 1)
<th>
{{ date('D', strtotime(data_get($date,'DATE')) ) }}
</th>
@else
<th style="background-color: #DCDCDC;">
{{ date('D', strtotime(data_get($date,'DATE')) ) }}
</th>
@endif
@endforeach
@else
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++) @for($i = 0; $i < 15 ; $i++)
<th>{{ $strdays[$i] }}</th> <th>{{ $strdays[$i] }}</th>
@endfor @endfor
@else @else
@for($i = 15; $i < $daymonth; $i++) @for($i = 15; $i < $daymonth; $i++)
<th>{{ $strdays[$i] }}</th> <th>{{ $strdays[$i] }}</th>
@endfor @endfor
@endif @endif
@endif
<th>Hours</th> <th>Hours</th>
</tr> </tr>
</thead> </thead>
...@@ -111,59 +131,93 @@ input[type=number] { ...@@ -111,59 +131,93 @@ input[type=number] {
<?php $total = 0;?> <?php $total = 0;?>
<tr> <tr>
<td class="single line"> <td class="single line">
{{ $project['td_project_code']}} {{$project['td_project_code']}}
</td> </td>
<td class="single line"> <td class="single line">
{{$project['td_project_name']}} {{$project['td_project_name']}}
</td> </td>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<?php
$valuehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($hour) @if(count($lat) > 0)
{ @foreach($lat as $key => $value)
$valuehour = $hour->where('td_date','=',$date) <?php
->where('td_project',$project['td_project']) // dd($value);
->where('tm_phase',$phase) $day = date_parse_from_format('Y-m-d', data_get($value,'DATE'))['day'];
->first(); // dd($day);
$valuehour = '';
$total += data_get($valuehour,'td_hours');
} $date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $day);
?> if($hour)
{
<td > $valuehour = $hour->where('td_date','=',$date)
<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'] }}');"> ->where('td_project',$project['td_project'])
</td> ->where('tm_phase',$phase)
@endfor ->first();
@else
@for($i = 15; $i < $daymonth; $i++) $total += data_get($valuehour,'td_hours');
}
<?php ?>
$valuehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1); @if(data_get($value,'day_type') == 1)
<td>
if($hour) <input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$day}}]" name="hour[{{$project['td_project']}}][{{$day}}]" value="@if($valuehour){{data_get($valuehour,'td_hours')}}@else @endif" min="0" max="24" style="padding:2px;margin:unset" onchange="limiter(this,'{{ $project['td_project'] }}');">
{ </td>
$valuehour = $hour->where('td_date','=',$date) @else
->where('td_project',$project['td_project']) <td style="background-color: #DCDCDC;">
->where('tm_phase',$phase) <input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$day}}]" name="hour[{{$project['td_project']}}][{{$day}}]" value="@if($valuehour){{data_get($valuehour,'td_hours')}}@else @endif" min="0" max="24" style="padding:2px;margin:unset;background-color: #DCDCDC;" onchange="limiter(this,'{{ $project['td_project'] }}');">
->first(); </td>
@endif
$total += data_get($valuehour,'td_hours'); @endforeach
} @else
?> @if($phase == 1)
<td> @for($i = 0; $i < 15 ; $i++)
<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']}}');">
</td> <?php
$valuehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($hour)
{
$valuehour = $hour->where('td_date','=',$date)
->where('td_project',$project['td_project'])
->where('tm_phase',$phase)
->first();
$total += data_get($valuehour,'td_hours');
}
?>
<td>
<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'] }}');">
</td>
@endfor @endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<?php
$valuehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($hour)
{
$valuehour = $hour->where('td_date','=',$date)
->where('td_project',$project['td_project'])
->where('tm_phase',$phase)
->first();
$total += data_get($valuehour,'td_hours');
}
?>
<td>
<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']}}');">
</td>
@endfor
@endif
@endif @endif
<td> <td>
<input class="center aligned" type="text" name="total-{{$project['td_project']}}" id="total-{{$project['td_project']}}" style="padding-right: 4px;padding-left: 4px;" onchange="limiter(this,'{{$project['td_project']}}');" readonly="readonly" value={{$total}}> <input class="center aligned" type="text" name="total-{{$project['td_project']}}" id="total-{{$project['td_project']}}" style="padding-right: 4px;padding-left: 4px;" onchange="limiter(this,'{{$project['td_project']}}');" readonly="readonly" value="{{number_format($total,'1','.','')}}">
</td> </td>
</tr> </tr>
<?php $all += $total; ?> <?php $all += $total; ?>
......
...@@ -70,28 +70,52 @@ input[type=number] { ...@@ -70,28 +70,52 @@ input[type=number] {
</th> </th>
</tr> </tr>
<tr> <tr>
@if($phase == 1) @if(count($lat) > 0)
@foreach($lat as $key => $date)
@for($i = 0; $i < 15 ; $i++) @if(data_get($date,'day_type') == 1 )
<th>{{$i+1}}</th> <th>{{date_parse_from_format('Y-m-d', data_get($date,'DATE'))['day']}}</th>
@endfor @else
@else <th style="background-color: #DCDCDC;">
@for($i = 15; $i < $daymonth; $i++) {{date_parse_from_format('Y-m-d', data_get($date,'DATE'))['day']}}
<th>{{$i+1}}</th> </th>
@endfor @endif
@endforeach
@else
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<th>{{$i+1}}</th>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<th>{{$i+1}}</th>
@endfor
@endif
@endif @endif
</tr> </tr>
<tr> <tr>
@if(count($lat) > 0)
@foreach($lat as $key => $date)
@if(data_get($date,'day_type') == 1)
<th>
{{ date('D', strtotime(data_get($date,'DATE')) ) }}
</th>
@else
<th style="background-color: #DCDCDC;">
{{ date('D', strtotime(data_get($date,'DATE')) ) }}
</th>
@endif
@endforeach
@else
<!-- <th>Task</th> --> <!-- <th>Task</th> -->
@if($phase == 1) @if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
@for($i = 0; $i < 15 ; $i++) <th>{{ $strdays[$i] }}</th>
<th>{{ $strdays[$i] }}</th> @endfor
@endfor @else
@else @for($i = 15; $i < $daymonth; $i++)
@for($i = 15; $i < $daymonth; $i++) <th>{{ $strdays[$i] }}</th>
<th>{{ $strdays[$i] }}</th> @endfor
@endfor @endif
@endif @endif
<th>Hours</th> <th>Hours</th>
</tr> </tr>
...@@ -104,55 +128,84 @@ input[type=number] { ...@@ -104,55 +128,84 @@ input[type=number] {
<td> <td>
{{$project['td_project_name']}} {{$project['td_project_name']}}
</td> </td>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<?php
$valuehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($hour)
{
$valuehour = $hour->where('td_date','=',$date)
->where('fk_o_id',$project['td_project'])
->where('tm_phase',$phase)
->first();
$total += data_get($valuehour,'td_hours');
}
?>
<td >
<input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$i+1}}]" name="hour[{{$project['td_project']}}][{{$i+1}}]" value="@if($valuehour){{data_get($valuehour,'td_hours')}}@else @endif" min="0" max="24" style="padding:2px;margin:unset" onchange="limiter(this,'{{$project['td_project']}}');">
</td>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<?php
$valuehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($hour)
{
$valuehour = $hour->where('td_date','=',$date)
->where('fk_o_id',$project['td_project'])
->where('tm_phase',$phase)
->first();
$total += data_get($valuehour,'td_hours');
}
?>
<td>
<input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$i+1}}]" name="hour[{{$project['td_project']}}][{{$i+1}}]" value="@if($valuehour){{data_get($valuehour,'td_hours')}}@else @endif" min="0" max="24" style="padding:2px;margin:unset" onchange="limiter(this,'{{$project['td_project']}}');">
</td>
@endfor
@endif @if(count($lat) > 0)
@foreach($lat as $key => $value)
<?php
// dd($value);
$day = date_parse_from_format('Y-m-d', data_get($value,'DATE'))['day'];
// dd($day);
$valuehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $day);
if($hour)
{
$valuehour = $hour->where('td_date','=',$date)
->where('fk_o_id',$project['td_project'])
->where('tm_phase',$phase)
->first();
$total += data_get($valuehour,'td_hours');
}
?>
@if(data_get($value,'day_type') == 1)
<td>
<input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$day}}]" name="hour[{{$project['td_project']}}][{{$day}}]" value="@if($valuehour){{$valuehour->td_hours}}@else @endif" min="0" max="24" style="padding:2px;margin:unset" onchange="limiter(this,'{{ $project['td_project'] }}');">
</td>
@else
<td style="background-color: #DCDCDC;">
<input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$day}}]" name="hour[{{$project['td_project']}}][{{$day}}]" value="@if($valuehour){{$valuehour->td_hours}}@else @endif" min="0" max="24" style="padding:2px;margin:unset;background-color: #DCDCDC;" onchange="limiter(this,'{{ $project['td_project'] }}');">
</td>
@endif
@endforeach
@else
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<?php
$valuehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($hour)
{
$valuehour = $hour->where('td_date','=',$date)
->where('fk_o_id',$project['td_project'])
->where('tm_phase',$phase)
->first();
$total += data_get($valuehour,'td_hours');
}
?>
<td >
<input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$i+1}}]" name="hour[{{$project['td_project']}}][{{$i+1}}]" value="@if($valuehour){{data_get($valuehour,'td_hours')}}@else @endif" min="0" max="24" style="padding:2px;margin:unset" onchange="limiter(this,'{{$project['td_project']}}');">
</td>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<?php
$valuehour = '';
$date = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
if($hour)
{
$valuehour = $hour->where('td_date','=',$date)
->where('fk_o_id',$project['td_project'])
->where('tm_phase',$phase)
->first();
$total += data_get($valuehour,'td_hours');
}
?>
<td>
<input type="text" onkeypress="onlynumber(event)" id="hour[{{$project['td_project']}}][{{$i+1}}]" name="hour[{{$project['td_project']}}][{{$i+1}}]" value="@if($valuehour){{data_get($valuehour,'td_hours')}}@else @endif" min="0" max="24" style="padding:2px;margin:unset" onchange="limiter(this,'{{$project['td_project']}}');">
</td>
@endfor
@endif
@endif
<td> <td>
<input type="text" onkeypress="onlynumber(event)" name="total-{{$project['td_project']}}" id="total-{{$project['td_project']}}" style="padding-right: 4px;padding-left: 4px;" onchange="limiter(this,'{{$project['td_project']}}');" readonly="" value={{$total}}> <input type="text" onkeypress="onlynumber(event)" name="total-{{$project['td_project']}}" id="total-{{$project['td_project']}}" style="padding-right: 4px;padding-left: 4px;" onchange="limiter(this,'{{$project['td_project']}}');" readonly="" value={{$total}}>
</td> </td>
......
...@@ -11,6 +11,7 @@ use Portal\Timesheet\Model\Ts_detail; ...@@ -11,6 +11,7 @@ use Portal\Timesheet\Model\Ts_detail;
use Portal\Timesheet\Model\Project; use Portal\Timesheet\Model\Project;
use Portal\Timesheet\Model\Tproject; use Portal\Timesheet\Model\Tproject;
use Portal\Timesheet\Model\Department; use Portal\Timesheet\Model\Department;
use Portal\Timesheet\Model\LAttendance;
use Portal\Timesheet\Model\Pteam; use Portal\Timesheet\Model\Pteam;
use Portal\Timesheet\Model\Staff_info; use Portal\Timesheet\Model\Staff_info;
use Portal\Timesheet\Model\Overhead; use Portal\Timesheet\Model\Overhead;
...@@ -112,6 +113,7 @@ class FormController extends Controller ...@@ -112,6 +113,7 @@ class FormController extends Controller
$userId = users::find(Auth::id()) $userId = users::find(Auth::id())
->u_staffID; ->u_staffID;
$project = Pteam::where('pt_staff_id',$userId) $project = Pteam::where('pt_staff_id',$userId)
->where('pt_project_type', $chargeable) ->where('pt_project_type', $chargeable)
->where('pt_project_task_sts', 1) ->where('pt_project_task_sts', 1)
...@@ -150,13 +152,14 @@ class FormController extends Controller ...@@ -150,13 +152,14 @@ class FormController extends Controller
} }
$daymonth=cal_days_in_month(CAL_GREGORIAN,$month,$year); $daymonth=cal_days_in_month(CAL_GREGORIAN,$month,$year);
// dd($daymonth);
$strdays = []; $strdays = [];
for ($i=0; $i < $daymonth; $i++) { for ($i=0; $i < $daymonth; $i++) {
$tempdate = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1); $tempdate = $year.'-'.sprintf('%02d', $month).'-'.sprintf('%02d', $i+1);
$strday = Carbon::createFromFormat('Y-m-d', $tempdate)->format('l'); $strday = Carbon::createFromFormat('Y-m-d', $tempdate)->format('l');
// dd($strday);
$strdays[$i] = substr($strday, 0, 3); $strdays[$i] = substr($strday, 0, 3);
} }
...@@ -177,9 +180,33 @@ class FormController extends Controller ...@@ -177,9 +180,33 @@ class FormController extends Controller
$hour = null; $hour = null;
} }
// dd($projectlist); $dt = [];
if($phase == 1){
for ($i=0; $i < 15; $i++) {
$temp = Carbon::create($year, $month, $i+1, );
$dt[] = $temp->toDateString();
}
}
else
{
for ($j=15; $j < $daymonth; $j++) {
$temp = Carbon::create($year, $month, $j+1, );
$dt[] = $temp->toDateString();
}
}
// dd($dt);
// echo $dt->toDateTimeString();
$lat = LAttendance::where('staff_id', $userId)
->whereIn('DATE', $dt)
->get();
// dd($lat);
// dd(date('w', strtotime(data_get($lat1,'DATE'))));
// dd(date_parse_from_format('Y-m-d', data_get($lat1,'DATE'))['day']);
// dd(date('d'));
return view('timesheet::form.chargeableForm', compact('projectlist','userId','month','phase','daymonth','year', 'hour', 'strdays')); return view('timesheet::form.chargeableForm', compact('projectlist','userId','month','phase','daymonth','year', 'hour', 'strdays', 'lat'));
} }
public function savechargeablehours(Request $request) public function savechargeablehours(Request $request)
...@@ -814,7 +841,30 @@ class FormController extends Controller ...@@ -814,7 +841,30 @@ class FormController extends Controller
// dd($checkoverhead->id); // dd($checkoverhead->id);
return view('timesheet::form.overheadForm', compact('checkoverhead','projectlist','userId','month','phase','daymonth','year', 'hour', 'project', 'fk_tm_id', 'strdays')); $dt = [];
if($phase == 1){
for ($i=0; $i < 15; $i++) {
$temp = Carbon::create($year, $month, $i+1, );
$dt[] = $temp->toDateString();
}
}
else
{
for ($j=15; $j < $daymonth; $j++) {
$temp = Carbon::create($year, $month, $j+1, );
$dt[] = $temp->toDateString();
}
}
// dd($dt);
// echo $dt->toDateTimeString();
$lat = LAttendance::where('staff_id', $userId)
->whereIn('DATE', $dt)
->get();
// dd($lat);
return view('timesheet::form.overheadForm', compact('checkoverhead','projectlist','userId','month','phase','daymonth','year', 'hour', 'project', 'fk_tm_id', 'strdays', 'lat'));
} }
public function saveoverheadhours(Request $request) public function saveoverheadhours(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