Commit 03dfd72a by Azhan Hannan

allow user update data cuti. button sync data l_attendance

parent fe60f677
...@@ -66,6 +66,11 @@ input[type=number] { ...@@ -66,6 +66,11 @@ input[type=number] {
View and Submit Timesheet View and Submit Timesheet
</a> </a>
<a href="{{ route('timesheet::form.sync', ['tmid' => $fk_tm_id]) }}" class="tiny center aligned ui gery compact right labeled icon button">
<i class="sync icon"></i>
Sync from Webtas
</a>
<!-- Table Chargeable Start --> <!-- Table Chargeable Start -->
<table id="printtable2" class="ui celled structured table unstackable"> <table id="printtable2" class="ui celled structured table unstackable">
<thead> <thead>
......
...@@ -66,8 +66,8 @@ Route::group( ...@@ -66,8 +66,8 @@ Route::group(
Route::post('generateOvertimeReport', ['uses' => 'ReportController@generateOvertimeReport', 'as' => 'report.generateOvertimeReport']); Route::post('generateOvertimeReport', ['uses' => 'ReportController@generateOvertimeReport', 'as' => 'report.generateOvertimeReport']);
Route::get('filterNotSubmit', ['uses' => 'ReportController@filterNotSubmit', 'as' => 'report.filterNotSubmit']); Route::get('filterNotSubmit', ['uses' => 'ReportController@filterNotSubmit', 'as' => 'report.filterNotSubmit']);
Route::post('generateNotSubmitReport', ['uses' => 'ReportController@generateNotSubmitReport', 'as' => 'report.generateNotSubmitReport']); Route::post('generateNotSubmitReport', ['uses' => 'ReportController@generateNotSubmitReport', 'as' => 'report.generateNotSubmitReport']);
// Route::get('filterTimesheetStatus', ['uses' => 'ReportController@filterTimesheetStatus', 'as' => 'report.filterTimesheetStatus']); Route::get('filterTimesheetStatus', ['uses' => 'ReportController@filterTimesheetStatus', 'as' => 'report.filterTimesheetStatus']);
// Route::post('generateTimesheetStatus', ['uses' => 'ReportController@generateTimesheetStatus', 'as' => 'report.generateTimesheetStatus']); Route::post('generateTimesheetStatus', ['uses' => 'ReportController@generateTimesheetStatus', 'as' => 'report.generateTimesheetStatus']);
//maintenance //maintenance
Route::get('senaraiProject',['uses' => 'MaintenanceController@senaraiProject', 'as' => 'maintenance.senaraiProject']); Route::get('senaraiProject',['uses' => 'MaintenanceController@senaraiProject', 'as' => 'maintenance.senaraiProject']);
...@@ -135,6 +135,7 @@ Route::group( ...@@ -135,6 +135,7 @@ Route::group(
Route::get('resubmitconfirm',['uses' => 'FormController@resubmitconfirm', 'as' => 'form.resubmitconfirm']); Route::get('resubmitconfirm',['uses' => 'FormController@resubmitconfirm', 'as' => 'form.resubmitconfirm']);
Route::get('deletedraft',['uses' => 'FormController@deletedraft', 'as' => 'form.deletedraft']); Route::get('deletedraft',['uses' => 'FormController@deletedraft', 'as' => 'form.deletedraft']);
Route::get('draftdeleted',['uses' => 'FormController@draftdeleted', 'as' => 'form.draftdeleted']); Route::get('draftdeleted',['uses' => 'FormController@draftdeleted', 'as' => 'form.draftdeleted']);
Route::get('sync',['uses' => 'FormController@sync', 'as' => 'form.sync']);
// nonChargeableForm // nonChargeableForm
// Route::get('nonChargeableForm',['uses' => 'FormController@nonChargeableForm', 'as' => 'form.nonChargeableForm']); // Route::get('nonChargeableForm',['uses' => 'FormController@nonChargeableForm', 'as' => 'form.nonChargeableForm']);
...@@ -151,6 +152,9 @@ Route::group( ...@@ -151,6 +152,9 @@ Route::group(
//php_sqlsrv_80_ts_x86.dll //php_sqlsrv_80_ts_x86.dll
Route::get('ajax/stafflist/{dept}',['uses' => 'MaintenanceController@loadstaff', 'as' => 'maintenance.loadstaff']); Route::get('ajax/stafflist/{dept}',['uses' => 'MaintenanceController@loadstaff', 'as' => 'maintenance.loadstaff']);
Route::get('ajax/overheadnote/{overhead}/{month}/{year}/{staffid}/{phase}',['uses' => 'FormController@loadnotes', 'as' => 'form.loadnotes']); Route::get('ajax/overheadnote/{overhead}/{month}/{year}/{staffid}/{phase}',['uses' => 'FormController@loadnotes', 'as' => 'form.loadnotes']);
// admin management
Route::get('userapproval',['uses' => 'AdminController@userapproval', 'as' => 'admin.userapproval']);
} }
); );
......
...@@ -3057,4 +3057,490 @@ class FormController extends Controller ...@@ -3057,4 +3057,490 @@ class FormController extends Controller
return redirect()->route('timesheet::form.filterChargeable')->withSuccess('Draft Successfully Deleted'); return redirect()->route('timesheet::form.filterChargeable')->withSuccess('Draft Successfully Deleted');
} }
public function sync(Request $request)
{
$tmid = $request->tmid;
$tm = Ts_master::where('id', $tmid)->first();
$staffid = $tm->tm_staff_id;
$month = $tm->tm_month;
$phase = $tm->tm_phase;
$year = $tm->tm_year;
$user = Staff_info::where('staff_id', $staffid)->first();
$number = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$totaldays = null;
$dates = [];
if ($phase == 1) {
$totaldays = 15;
for ($i=0; $i < $totaldays; $i++) {
$strDate = ($i+1).'-'.$month.'-'.$year;
$dates[] = date('Y-m-d', strtotime($strDate));
}
} else {
$totaldays = $number;
for ($i=15; $i < $totaldays; $i++) {
$strDate = ($i+1).'-'.$month.'-'.$year;
$dates[] = date('Y-m-d', strtotime($strDate));
}
}
$training = 5;
$public = 6;
$al = 7;
$mc = 8;
$el = 10;
$lat = LAttendance::where('staff_id', $staffid)
->whereIn('DATE', $dates)
->get();
foreach ($lat as $key => $data_lat) {
if ($data_lat->jenis_cuti) {
$lat_date = $data_lat->DATE;
$lat_cuti = $data_lat->jenis_cuti;
if ($lat_cuti == 'MC') {
$checktd = Ts_detail::where('td_date', $lat_date)
->where('tm_staff_id', $staffid)
->where('fk_o_id', $mc)
->where('fk_tm_id', $tmid)
->first();
if ($checktd) {
$checktd->td_hours = 8;
$checktd->td_overhead_note = 'Medical Leave';
$checktd->save();
} else {
$mcdetail = new Ts_detail;
$mcdetail->td_date = $lat_date;
$mcdetail->fk_o_id = $mc;
$mcdetail->fk_tm_id = $tmid;
$mcdetail->tm_staff_id = $staffid;
$mcdetail->tm_month = $month;
$mcdetail->tm_year = $year;
$mcdetail->tm_phase = $phase;
$mcdetail->td_project_type = 3;
$mcdetail->updated_by = $staffid;
$project = Overhead::where('id', $mc)
->first();
$mcdetail->td_overhead_desc = $project->o_overhead_desc;
$mcdetail->td_overhead_note = 'Medical Leave';
$mcdetail->td_hours = 8;
$mcdetail->td_timesheet_sts = 1;
$mcdetail->save();
}
$checktpmc = Tproject::where('fk_tm_id', $tmid)
->where('fk_o_id', $mc)
->first();
$count = Ts_detail::where('fk_tm_id', $tmid)
->where('fk_o_id', $mc)
->sum('td_hours');
if ($checktpmc)
{
$checktpmc->tp_hours = $count;
$checktpmc->updated_by = $staffid;
$checktpmc->save();
}
else
{
$tpmc = new Tproject;
$tpmc->staffid = $staffid;
$tpmc->fk_o_id = $mc;
$tpmc->fk_tm_id = $tmid;
$tpmc->tp_project_type = 3;
$tpmc->tp_year = $year;
$tpmc->tp_month = $month;
$tpmc->tp_phase = $phase;
$project = Overhead::where('id', $mc)
->first();
$tpmc->tp_project_name = $project->o_overhead_desc;
$tpmc->tp_hours = $count;
$tpmc->tp_timesheet_sts = 1;
$tpmc->tp_pm = data_get($user,'penyokong');
$tpmc->tp_pd = data_get($user,'pelulus');
$tpmc->updated_by = $staffid;
$tpmc->save();
}
}
if ($lat_cuti == 'EL') {
$checktd = Ts_detail::where('td_date', $lat_date)
->where('tm_staff_id', $staffid)
->where('fk_o_id', $el)
->where('fk_tm_id', $tmid)
->first();
if ($checktd) {
$checktd->td_hours = 8;
$checktd->td_overhead_note = 'Emergency Leave';
$checktd->save();
} else {
$eldetail = new Ts_detail;
$eldetail->td_date = $lat_date;
$eldetail->fk_o_id = $el;
$eldetail->fk_tm_id = $tmid;
$eldetail->tm_staff_id = $staffid;
$eldetail->tm_month = $month;
$eldetail->tm_year = $year;
$eldetail->tm_phase = $phase;
$eldetail->td_project_type = 3;
$eldetail->updated_by = $staffid;
$project = Overhead::where('id', $el)
->first();
$eldetail->td_overhead_desc = $project->o_overhead_desc;
$eldetail->td_overhead_note = 'Emergency Leave';
$eldetail->td_hours = 8;
$eldetail->td_timesheet_sts = 1;
$eldetail->save();
}
$checktpel = Tproject::where('fk_tm_id', $tmid)
->where('fk_o_id', $el)
->first();
$count = Ts_detail::where('fk_tm_id', $tmid)
->where('fk_o_id', $el)
->sum('td_hours');
if ($checktpel)
{
$checktpel->tp_hours = $count;
$checktpel->updated_by = $staffid;
$checktpel->save();
}
else
{
$tpel = new Tproject;
$tpel->staffid = $staffid;
$tpel->fk_o_id = $el;
$tpel->fk_tm_id = $tmid;
$tpel->tp_project_type = 3;
$tpel->tp_year = $year;
$tpel->tp_month = $month;
$tpel->tp_phase = $phase;
$project = Overhead::where('id', $el)
->first();
$tpel->tp_project_name = $project->o_overhead_desc;
$tpel->tp_hours = $count;
$tpel->tp_timesheet_sts = 1;
$tpel->tp_pm = data_get($user,'penyokong');
$tpel->tp_pd = data_get($user,'pelulus');
$tpel->updated_by = $staffid;
$tpel->save();
}
}
if ($lat_cuti == 'AL') {
$checktd = Ts_detail::where('td_date', $lat_date)
->where('tm_staff_id', $staffid)
->where('fk_o_id', $al)
->where('fk_tm_id', $tmid)
->first();
if ($checktd) {
$checktd->td_hours = 8;
$checktd->td_overhead_note = 'Annual Leave';
$checktd->save();
} else {
$aldetail = new Ts_detail;
$aldetail->td_date = $lat_date;
$aldetail->fk_o_id = $al;
$aldetail->fk_tm_id = $tmid;
$aldetail->tm_staff_id = $staffid;
$aldetail->tm_month = $month;
$aldetail->tm_year = $year;
$aldetail->tm_phase = $phase;
$aldetail->td_project_type = 3;
$aldetail->updated_by = $staffid;
$project = Overhead::where('id', $al)
->first();
$aldetail->td_overhead_desc = $project->o_overhead_desc;
$aldetail->td_overhead_note = 'Annual Leave';
$aldetail->td_hours = 8;
$aldetail->td_timesheet_sts = 1;
$aldetail->save();
}
$checktpal = Tproject::where('fk_tm_id', $tmid)
->where('fk_o_id', $al)
->first();
$count = Ts_detail::where('fk_tm_id', $tmid)
->where('fk_o_id', $al)
->sum('td_hours');
if ($checktpal)
{
$checktpal->tp_hours = $count;
$checktpal->updated_by = $staffid;
$checktpal->save();
}
else
{
$tpal = new Tproject;
$tpal->staffid = $staffid;
$tpal->fk_o_id = $al;
$tpal->fk_tm_id = $tmid;
$tpal->tp_project_type = 3;
$tpal->tp_year = $year;
$tpal->tp_month = $month;
$tpal->tp_phase = $phase;
$project = Overhead::where('id', $al)
->first();
$tpal->tp_project_name = $project->o_overhead_desc;
$tpal->tp_hours = $count;
$tpal->tp_timesheet_sts = 1;
$tpal->tp_pm = data_get($user,'penyokong');
$tpal->tp_pd = data_get($user,'pelulus');
$tpal->updated_by = $staffid;
$tpal->save();
}
}
if ($lat_cuti == 'AL(m)') {
$checktd = Ts_detail::where('td_date', $lat_date)
->where('tm_staff_id', $staffid)
->where('fk_o_id', $al)
->where('fk_tm_id', $tmid)
->first();
if ($checktd) {
$checktd->td_hours = 4;
$checktd->td_overhead_note = 'Annual Leave Halfday (morning)';
$checktd->save();
} else {
$aldetail = new Ts_detail;
$aldetail->td_date = $lat_date;
$aldetail->fk_o_id = $al;
$aldetail->fk_tm_id = $tmid;
$aldetail->tm_staff_id = $staffid;
$aldetail->tm_month = $month;
$aldetail->tm_year = $year;
$aldetail->tm_phase = $phase;
$aldetail->td_project_type = 3;
$aldetail->updated_by = $staffid;
$project = Overhead::where('id', $al)
->first();
$aldetail->td_overhead_desc = $project->o_overhead_desc;
$aldetail->td_overhead_note = 'Annual Leave Halfday (morning)';
$aldetail->td_hours = 4;
$aldetail->td_timesheet_sts = 1;
$aldetail->save();
}
$checktpal = Tproject::where('fk_tm_id', $tmid)
->where('fk_o_id', $al)
->first();
$count = Ts_detail::where('fk_tm_id', $tmid)
->where('fk_o_id', $al)
->sum('td_hours');
if ($checktpal)
{
$checktpal->tp_hours = $count;
$checktpal->updated_by = $staffid;
$checktpal->save();
}
else
{
$tpal = new Tproject;
$tpal->staffid = $staffid;
$tpal->fk_o_id = $al;
$tpal->fk_tm_id = $tmid;
$tpal->tp_project_type = 3;
$tpal->tp_year = $year;
$tpal->tp_month = $month;
$tpal->tp_phase = $phase;
$project = Overhead::where('id', $al)
->first();
$tpal->tp_project_name = $project->o_overhead_desc;
$tpal->tp_hours = $count;
$tpal->tp_timesheet_sts = 1;
$tpal->tp_pm = data_get($user,'penyokong');
$tpal->tp_pd = data_get($user,'pelulus');
$tpal->updated_by = $staffid;
$tpal->save();
}
}
if ($lat_cuti == 'AL (e)') {
$checktd = Ts_detail::where('td_date', $lat_date)
->where('tm_staff_id', $staffid)
->where('fk_o_id', $al)
->where('fk_tm_id', $tmid)
->first();
if ($checktd) {
$checktd->td_hours = 4;
$checktd->td_overhead_note = 'Annual Leave Halfday (evening)';
$checktd->save();
} else {
$aldetail = new Ts_detail;
$aldetail->td_date = $lat_date;
$aldetail->fk_o_id = $al;
$aldetail->fk_tm_id = $tmid;
$aldetail->tm_staff_id = $staffid;
$aldetail->tm_month = $month;
$aldetail->tm_year = $year;
$aldetail->tm_phase = $phase;
$aldetail->td_project_type = 3;
$aldetail->updated_by = $staffid;
$project = Overhead::where('id', $al)
->first();
$aldetail->td_overhead_desc = $project->o_overhead_desc;
$aldetail->td_overhead_note = 'Annual Leave Halfday (evening)';
$aldetail->td_hours = 4;
$aldetail->td_timesheet_sts = 1;
$aldetail->save();
}
$checktpal = Tproject::where('fk_tm_id', $tmid)
->where('fk_o_id', $al)
->first();
$count = Ts_detail::where('fk_tm_id', $tmid)
->where('fk_o_id', $al)
->sum('td_hours');
if ($checktpal)
{
$checktpal->tp_hours = $count;
$checktpal->updated_by = $staffid;
$checktpal->save();
}
else
{
$tpal = new Tproject;
$tpal->staffid = $staffid;
$tpal->fk_o_id = $al;
$tpal->fk_tm_id = $tmid;
$tpal->tp_project_type = 3;
$tpal->tp_year = $year;
$tpal->tp_month = $month;
$tpal->tp_phase = $phase;
$project = Overhead::where('id', $al)
->first();
$tpal->tp_project_name = $project->o_overhead_desc;
$tpal->tp_hours = $count;
$tpal->tp_timesheet_sts = 1;
$tpal->tp_pm = data_get($user,'penyokong');
$tpal->tp_pd = data_get($user,'pelulus');
$tpal->updated_by = $staffid;
$tpal->save();
}
}
}
if ($data_lat->day_type == 3) {
$lat_date = $data_lat->DATE;
$checktd = Ts_detail::where('td_date', $lat_date)
->where('tm_staff_id', $staffid)
->where('fk_o_id', $public)
->where('fk_tm_id', $tmid)
->first();
if ($checktd) {
$checktd->td_hours = 8;
$checktd->td_overhead_note = 'Public Holiday';
$checktd->save();
} else {
$pubdetail = new Ts_detail;
$pubdetail->td_date = $lat_date;
$pubdetail->fk_o_id = $public;
$pubdetail->fk_tm_id = $tmid;
$pubdetail->tm_staff_id = $staffid;
$pubdetail->tm_month = $month;
$pubdetail->tm_year = $year;
$pubdetail->tm_phase = $phase;
$pubdetail->td_project_type = 3;
$pubdetail->updated_by = $staffid;
$project = Overhead::where('id', $public)
->first();
$pubdetail->td_overhead_desc = $project->o_overhead_desc;
$pubdetail->td_overhead_note = 'Public Holiday';
$pubdetail->td_hours = 8;
$pubdetail->td_timesheet_sts = 1;
$pubdetail->save();
}
$checktppublic = Tproject::where('fk_tm_id', $tmid)
->where('fk_o_id', $public)
->first();
$count = Ts_detail::where('fk_tm_id', $tmid)
->where('fk_o_id', $public)
->sum('td_hours');
if ($checktppublic)
{
$checktppublic->tp_hours = $count;
$checktppublic->updated_by = $staffid;
$checktppublic->save();
}
else
{
$tppublic = new Tproject;
$tppublic->staffid = $staffid;
$tppublic->fk_o_id = $public;
$tppublic->fk_tm_id = $tmid;
$tppublic->tp_project_type = 3;
$tppublic->tp_year = $year;
$tppublic->tp_month = $month;
$tppublic->tp_phase = $phase;
$project = Overhead::where('id', $public)
->first();
$tppublic->tp_project_name = $project->o_overhead_desc;
$tppublic->tp_hours = $count;
$tppublic->tp_timesheet_sts = 1;
$tppublic->tp_pm = data_get($user,'penyokong');
$tppublic->tp_pd = data_get($user,'pelulus');
$tppublic->updated_by = $staffid;
$tppublic->save();
}
}
}
return redirect()->route('timesheet::form.overheadForm', ['phase' => $phase, 'month' =>$month,'year'=>$year])->with('success', 'Leave hours have been sync with Webtas. Thank you');
}
} }
\ 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