Commit 28f2e7b3 by Azhan Hannan

changes

parent 4d313346
@extends('ui::layouts.app')
@section('content')
<div class="ui segment">
<a class="ui blue left ribbon label">Rejected Project</a>
<br>
<br>
<form class="ui form" action="{{ route('timesheet::form.resubmit' )}}" method="POST">
{{csrf_field()}}
<input type="hidden" name="tpid" value="{{data_get($profile,'id')}}">
<table class="ui celled structured table unstackable">
<thead>
<tr>
<th colspan="2" rowspan="2" class="center aligned">Chargeable</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th rowspan="2">
<button type="submit" class="ui fluid center aligned ui blue button">
<!-- <i class="save icon"></i> -->
Resubmit
</button>
</th>
</tr>
<tr>
@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
</tr>
<tr>
<th class="single line">Project Code</th>
<th class="single line">Project Name</th>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<th>{{ $strdays[$i] }}</th>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<th>{{ $strdays[$i] }}</th>
@endfor
@endif
<th>Total Hours</th>
</tr>
</thead>
<tbody>
@foreach($projectlist as $key => $project)
<?php $total = 0; ?>
<tr>
<td class="single line">
{{ $project['td_project_code']}}
</td>
<td class="single line">
{{$project['td_project_name']}}
</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('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
@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
<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}}>
</td>
</tr>
@endforeach
</tbody>
</table>
</form>
</div>
@endsection
\ No newline at end of file
@extends('ui::layouts.app')
@section('content')
<div class="ui segment">
<a class="ui purple left ribbon label">Rejected Overhead</a>
<br>
<br>
<form class="ui form" action="" method="POST">
<table class="ui celled structured unstackable table" >
<thead>
<tr>
<th rowspan="2" class="center aligned">Overhead</th>
<th colspan="@if($phase == 1) 15 @else {{$daymonth-15}} @endif" class="center aligned">Date</th>
<th rowspan="2">
<button type="submit" class="fluid center aligned ui blue button">
<!-- <i class="save icon"></i> -->
Resubmit
</button>
</th>
</tr>
<tr>
@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
</tr>
<tr>
<th>Task</th>
@if($phase == 1)
@for($i = 0; $i < 15 ; $i++)
<th>{{ $strdays[$i] }}</th>
@endfor
@else
@for($i = 15; $i < $daymonth; $i++)
<th>{{ $strdays[$i] }}</th>
@endfor
@endif
<th>Total Hours</th>
</tr>
</thead>
<tbody>
@foreach($projectlist as $key => $project)
<?php $total = 0; ?>
<tr>
<td>
{{$project['td_project_name']}}
</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
<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}}>
</td>
</tr>
@endforeach
</tbody>
</table>
</form>
<br>
</div>
@endsection
@push('script')
<script>
$(document).ready(function()
{
$('.view_button').click(function()
{
$('.view').modal(
{
blurring: true
}).modal('show');
var id = $(this).data('overheadid');
var month = $(this).data('month');
var year = $(this).data('year');
var phase = $(this).data('phase');
var staffid = $(this).data('tmstaffid');
$.ajax(
{
type: "GET",
url: "{{ URL::to('ajax/overheadnote')}}"+"/"+id+"/"+month+"/"+year+"/"+staffid+"/"+phase,
beforeSend: function ()
{
document.getElementById('zone2').style.display = "block";
},
success: function(html)
{
document.getElementById('zone2').style.display = "block";
$('#zone2').html( html );
// window.location.replace("{{ URL::to('ad/typeanjuran')}}")
}
});
});
});
</script>
<script>
$(function(){
$("#view").click(function()
{
$(".view").modal('show');
});
$(".view").modal(
{
closable: true
});
$(".view").modal('attach events', '.close.button');
});
</script>
<script>
$(function(){
$("#description").click(function()
{
$(".description").modal('show');
});
$(".description").modal(
{
closable: true
});
$(".description").modal('attach events', '.close.button');
});
</script>
<script>
function onlynumber(evt)
{
var theEvent = evt || window.event;
var key = theEvent.keyCode || theEvent.which;
key = String.fromCharCode(key);
var regex = /[0-9]|\./;
if( !regex.test(key) )
{
theEvent.returnValue = false;
if(theEvent.preventDefault) theEvent.preventDefault();
}
}
</script>
<script>
$().ready(function() {
});
function limiter(input,pid) {
var currenttotal = 0;
if (input.value < 0) input.value = 0;
if (input.value > 24) input.value = 24;
input.value = parseFloat(parseFloat(input.value).toFixed(1));
for(var i = 0; i < 32; i++){
var value = 0;
var hourValue = document.getElementById('hour['+pid+']['+i+']');
if(hourValue){
hourValue = hourValue.value;
value = parseFloat(parseFloat(hourValue).toFixed(1));
console.log(isNaN(value));
if(isNaN(value)){
value = 0;
}
if(typeof value === 'number'){
// console.log(value);
currenttotal += value;
}
}
}
console.log("currenttotal --> " + currenttotal);
document.getElementById('total-'+pid).value = currenttotal;
}
</script>
@endpush
\ No newline at end of file
......@@ -92,6 +92,10 @@ Route::group(
Route::post('overheadselectmonthphase', ['uses' => 'FormController@overheadselectmonthphase', 'as' => 'form.overheadselectmonthphase']);
Route::post('noteselectmonthphase', ['uses' => 'FormController@noteselectmonthphase', 'as' => 'form.noteselectmonthphase']);
Route::post('action/upload', ['uses' => 'FormController@uploadAttachement', 'as' => 'form.upload']);
Route::get('rejected',['uses' => 'FormController@rejected', 'as' => 'form.rejected']);
Route::post('resubmit',['uses' => 'FormController@resubmit', 'as' => 'form.resubmit']);
Route::post('resubmitoverhead',['uses' => 'FormController@resubmitoverhead', 'as' => 'form.resubmitoverhead']);
// nonChargeableForm
// Route::get('nonChargeableForm',['uses' => 'FormController@nonChargeableForm', 'as' => 'form.nonChargeableForm']);
......
......@@ -1365,7 +1365,256 @@ class FormController extends Controller
}
return redirect()->back()->withSuccess('Berjaya mengemaskini attachment');
}
public function rejected(Request $request)
{
$userId = users::find(Auth::id())
->u_staffID;
$profile = Tproject::where('id', $request->tpid)
->with('project')
->with('overhead')
->first();
$month = data_get($profile,'tp_month');
$year = data_get($profile,'tp_year');
$phase = data_get($profile,'tp_phase');
$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);
}
$projectlist = [];
if ($profile->tp_project_type == 1)
{
$projectlist[] = [
'td_project' => $profile->td_project,
'td_project_code' => $profile->project->p_project_code,
'td_project_name' => $profile->project->p_project_description,
];
}
else
{
$projectlist[] = [
'td_project' => $profile->fk_o_id,
'td_project_name' => $profile->overhead->o_overhead_desc,
];
}
$check = Ts_master::where('id', $profile->fk_tm_id)
->first();
if($check)
{
if($profile->tp_project_type == 1)
{
$hour = Ts_detail::where('fk_tm_id',$check->id)
->where('td_project', $profile->td_project)
->get();
}
else
{
$hour = Ts_detail::where('fk_tm_id',$check->id)
->where('fk_o_id', $profile->fk_o_id)
->get();
// dd($hour);
}
}
else
{
$hour = null;
}
if($profile->tp_project_type == 1)
{
return view('timesheet::form.rejected', compact('month', 'phase', 'year', 'profile', 'strdays', 'daymonth', 'projectlist', 'check' ,'hour'));
}
else
{
return view('timesheet::form.rejectedoverhead', compact('month', 'phase', 'year', 'profile', 'strdays', 'daymonth', 'projectlist', 'check' ,'hour'));
}
}
public function resubmit(Request $request)
{
$profile = Tproject::where('id', $request->tpid)
->first();
// dd($profile);
$chargeable = 1;
$userId = users::find(Auth::id())
->u_staffID;
$check = Ts_master::where('id', $profile->fk_tm_id)
->first();
// dd($check);
if($check)
{
}
else
{
$check = new Ts_master;
$check->tm_staff_id = $userId;
$check->tm_year = $profile->tp_year;
$check->tm_month = $profile->tp_month;
$check->tm_phase = $profile->tp_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)
{
$date = $profile->tp_year.'-'.$profile->tp_month.'-'.sprintf('%02d', $keyday);
$checkTimesheetDetail = Ts_detail::where('fk_tm_id', $tmasterid)
->where('td_project', $projectid)
->where('td_project_type', $chargeable)
->where('td_date', $date)
->where('tm_phase', $profile->tp_phase)
->first();
$valuehour = $day;
if($valuehour == null)
{
$valuehour = 0;
}
// dd($checkTimesheetDetail);
if($checkTimesheetDetail)
{
$checkTimesheetDetail->td_hours = $valuehour;
$checkTimesheetDetail->updated_by = $userId;
$checkTimesheetDetail->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();
}
}
$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->save();
}
else
{
$tpdetail = new Tproject;
$tpdetail->td_project = $projectid;
$tpdetail->staffid = $userId;
$tpdetail->fk_tm_id = $tmasterid;
$tpdetail->tp_project_type = 1;
$tpdetail->tp_year = $profile->tp_year;
$tpdetail->tp_month = $profile->tp_month;
$tpdetail->tp_phase = $profile->tp_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_pd = $project->p_project_director;
$tpdetail->tp_timesheet_sts = 1;
$tpdetail->updated_by = $userId;
$tpdetail->save();
}
$zeroedproject = Tproject::where('fk_tm_id', $tmasterid)
->where('td_project', $projectid)
->where('tp_hours', 0)
->first();
if ($zeroedproject)
{
Tproject::where('fk_tm_id', $tmasterid)
->where('td_project', $projectid)
->delete();
Ts_detail::where('fk_tm_id', $tmasterid)
->where('td_project', $projectid)
->delete();
}
}
$sumdetailhour = Ts_detail::where('td_project_type', $chargeable)
->where('tm_staff_id', $userId)
->where('fk_tm_id', $tmasterid)
->where('tm_phase', $request->phase)
->sum('td_hours');
$checktotalhours = Ts_master::where('id', $tmasterid)->first();
$checktotalhours->tm_chargeable_hrs = $sumdetailhour;
$checktotalhours->tm_chargeable_days = $sumdetailhour/8.0;
$checktotalhours->save();
Tproject::where('id', $profile->id)
->update(['tp_timesheet_sts' => 2]);
Ts_detail::where('fk_tm_id', $profile->fk_tm_id)
->where('td_project', $profile->td_project)
->update(['td_timesheet_sts' => 2]);
return redirect()->route('timesheet::dashboard.index');
}
}
\ No newline at end of file
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