Commit 03dfd72a by Azhan Hannan

allow user update data cuti. button sync data l_attendance

parent fe60f677
...@@ -65,6 +65,11 @@ input[type=number] { ...@@ -65,6 +65,11 @@ input[type=number] {
<i class="angle double right icon"></i> <i class="angle double right icon"></i>
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">
......
...@@ -10,7 +10,7 @@ Route::group( ...@@ -10,7 +10,7 @@ Route::group(
'middleware' => ['web', 'auth'], 'middleware' => ['web', 'auth'],
], ],
function () { function () {
//export //export
Route::get('ringkasan/export/', ['uses' => 'ExportController@export', 'as' => 'export.exportsummary']); Route::get('ringkasan/export/', ['uses' => 'ExportController@export', 'as' => 'export.exportsummary']);
Route::get('project/export/', ['uses' => 'ExportController@exportproject', 'as' => 'export.exportproject']); Route::get('project/export/', ['uses' => 'ExportController@exportproject', 'as' => 'export.exportproject']);
...@@ -20,7 +20,7 @@ Route::group( ...@@ -20,7 +20,7 @@ Route::group(
//dashboard //dashboard
Route::get('home',['uses' => 'DashboardController@index', 'as' => 'dashboard.index']); Route::get('home',['uses' => 'DashboardController@index', 'as' => 'dashboard.index']);
Route::get('vwviewer',['uses' => 'DashboardController@vwviewer', 'as' => 'dashboard.vwviewer']); Route::get('vwviewer',['uses' => 'DashboardController@vwviewer', 'as' => 'dashboard.vwviewer']);
//timesheet //timesheet
Route::get('timesheetApproval',['uses' => 'DashboardController@timesheetApproval', 'as' => 'dashboard.timesheetApproval']); Route::get('timesheetApproval',['uses' => 'DashboardController@timesheetApproval', 'as' => 'dashboard.timesheetApproval']);
Route::get('timesheetReport',['uses' => 'DashboardController@timesheetReport', 'as' => 'dashboard.timesheetReport']); Route::get('timesheetReport',['uses' => 'DashboardController@timesheetReport', 'as' => 'dashboard.timesheetReport']);
...@@ -56,18 +56,18 @@ Route::group( ...@@ -56,18 +56,18 @@ Route::group(
Route::post('verificationall', ['uses' => 'DashboardController@verificationall', 'as' => 'dashboard.verificationall']); Route::post('verificationall', ['uses' => 'DashboardController@verificationall', 'as' => 'dashboard.verificationall']);
//laporan //laporan
Route::get('ringkasanLaporan', ['uses' => 'ReportController@ringkasanLaporan', 'as' => 'report.ringkasanLaporan']); Route::get('ringkasanLaporan', ['uses' => 'ReportController@ringkasanLaporan', 'as' => 'report.ringkasanLaporan']);
Route::post('generateRingkasan', ['uses' => 'ReportController@generateRingkasan', 'as' => 'report.generateRingkasan']); Route::post('generateRingkasan', ['uses' => 'ReportController@generateRingkasan', 'as' => 'report.generateRingkasan']);
Route::get('projectreport', ['uses' => 'ReportController@projectreport', 'as' => 'report.projectReport']); Route::get('projectreport', ['uses' => 'ReportController@projectreport', 'as' => 'report.projectReport']);
Route::post('generateprojectreport', ['uses' => 'ReportController@generateprojectreport', 'as' => 'report.generateprojectreport']); Route::post('generateprojectreport', ['uses' => 'ReportController@generateprojectreport', 'as' => 'report.generateprojectreport']);
Route::get('deptreport', ['uses' => 'ReportController@deptreport', 'as' => 'report.deptreport']); Route::get('deptreport', ['uses' => 'ReportController@deptreport', 'as' => 'report.deptreport']);
Route::post('generatedeptreport', ['uses' => 'ReportController@generatedeptreport', 'as' => 'report.generatedeptreport']); Route::post('generatedeptreport', ['uses' => 'ReportController@generatedeptreport', 'as' => 'report.generatedeptreport']);
Route::get('filterOvertime', ['uses' => 'ReportController@filterOvertime', 'as' => 'report.filterOvertime']); Route::get('filterOvertime', ['uses' => 'ReportController@filterOvertime', 'as' => 'report.filterOvertime']);
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']);
...@@ -98,14 +98,14 @@ Route::group( ...@@ -98,14 +98,14 @@ Route::group(
Route::get('deleteproject',['uses' => 'MaintenanceController@deleteproject', 'as' => 'maintenance.deleteproject']); Route::get('deleteproject',['uses' => 'MaintenanceController@deleteproject', 'as' => 'maintenance.deleteproject']);
Route::get('deletePteam',['uses' => 'MaintenanceController@deletePteam', 'as' => 'maintenance.deletePteam']); Route::get('deletePteam',['uses' => 'MaintenanceController@deletePteam', 'as' => 'maintenance.deletePteam']);
Route::get('deleteTeam',['uses' => 'MaintenanceController@deleteTeam', 'as' => 'maintenance.deleteTeam']); Route::get('deleteTeam',['uses' => 'MaintenanceController@deleteTeam', 'as' => 'maintenance.deleteTeam']);
Route::get('deletePeranan',['uses' => 'MaintenanceController@deletePeranan', 'as' => 'maintenance.deletePeranan']); Route::get('deletePeranan',['uses' => 'MaintenanceController@deletePeranan', 'as' => 'maintenance.deletePeranan']);
Route::post('delete',['uses' => 'MaintenanceController@delete', 'as' => 'maintenance.delete']); Route::post('delete',['uses' => 'MaintenanceController@delete', 'as' => 'maintenance.delete']);
Route::get('deleterole',['uses' => 'MaintenanceController@deleterole', 'as' => 'maintenance.deleterole']); Route::get('deleterole',['uses' => 'MaintenanceController@deleterole', 'as' => 'maintenance.deleterole']);
Route::get('deleteOverhead',['uses' => 'MaintenanceController@deleteOverhead', 'as' => 'maintenance.deleteOverhead']); Route::get('deleteOverhead',['uses' => 'MaintenanceController@deleteOverhead', 'as' => 'maintenance.deleteOverhead']);
Route::get('deleteOvhd',['uses' => 'MaintenanceController@deleteOvhd', 'as' => 'maintenance.deleteOvhd']); Route::get('deleteOvhd',['uses' => 'MaintenanceController@deleteOvhd', 'as' => 'maintenance.deleteOvhd']);
//Mail Route //Mail Route
Route::get('mail/editProject', ['uses' => 'MaintenanceController@mailEditProject', 'as' => 'maintenance.mailEditProject']); Route::get('mail/editProject', ['uses' => 'MaintenanceController@mailEditProject', 'as' => 'maintenance.mailEditProject']);
Route::get('mail/addProjectTeam', ['uses' => 'MaintenanceController@mailAddProjectTeam', 'as' => 'maintenance.mailAddProjectTeam']); Route::get('mail/addProjectTeam', ['uses' => 'MaintenanceController@mailAddProjectTeam', 'as' => 'maintenance.mailAddProjectTeam']);
Route::get('reminder', ['uses' => 'MaintenanceController@reminder', 'as' => 'maintenance.reminder']); Route::get('reminder', ['uses' => 'MaintenanceController@reminder', 'as' => 'maintenance.reminder']);
...@@ -135,14 +135,15 @@ Route::group( ...@@ -135,14 +135,15 @@ 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']);
// Route::post('savenonchargeablehours',['uses' => 'FormController@savenonchargeablehours', 'as' => 'form.savenonchargeablehours']); // Route::post('savenonchargeablehours',['uses' => 'FormController@savenonchargeablehours', 'as' => 'form.savenonchargeablehours']);
// Route::get('filterNonChargeable',['uses' => 'FormController@filterNonChargeable', 'as' => 'form.filterNonChargeable']); // Route::get('filterNonChargeable',['uses' => 'FormController@filterNonChargeable', 'as' => 'form.filterNonChargeable']);
// Route::post('nonchargeableselectmonthphase', ['uses' => 'FormController@nonchargeableselectmonthphase', 'as' => 'form.nonchargeableselectmonthphase']); // Route::post('nonchargeableselectmonthphase', ['uses' => 'FormController@nonchargeableselectmonthphase', 'as' => 'form.nonchargeableselectmonthphase']);
// Route::post('addnonchargeabletask',['uses' => 'FormController@addnonchargeabletask', 'as' => 'form.addnonchargeabletask']); // Route::post('addnonchargeabletask',['uses' => 'FormController@addnonchargeabletask', 'as' => 'form.addnonchargeabletask']);
//calendar //calendar
// Route::get('kalendarCharge',['uses' => 'CalendarController@kalendarCharge', 'as' => 'kalendar.kalendarCharge']); // Route::get('kalendarCharge',['uses' => 'CalendarController@kalendarCharge', 'as' => 'kalendar.kalendarCharge']);
// Route::get('kalendarNonCharge',['uses' => 'CalendarController@kalendarNonCharge', 'as' => 'kalendar.kalendarNonCharge']); // Route::get('kalendarNonCharge',['uses' => 'CalendarController@kalendarNonCharge', 'as' => 'kalendar.kalendarNonCharge']);
...@@ -151,11 +152,14 @@ Route::group( ...@@ -151,11 +152,14 @@ 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']);
} }
); );
//enable this if you want //enable this if you want
// Route::group( // Route::group(
// 'namespace' => '\Portal\Timesheet\Http\Controllers', // 'namespace' => '\Portal\Timesheet\Http\Controllers',
// 'prefix' => '', // 'prefix' => '',
...@@ -163,7 +167,7 @@ Route::group( ...@@ -163,7 +167,7 @@ Route::group(
// 'middleware' => ['web'], // 'middleware' => ['web'],
// ], // ],
// function () { // function () {
// Route::get('/', ['uses' => 'HomeController@index', 'as' => 'home.index']); // Route::get('/', ['uses' => 'HomeController@index', 'as' => 'home.index']);
......
...@@ -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