Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
3
3f-timesheet
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dockers
3f-timesheet
Commits
9ecc5ff7
Commit
9ecc5ff7
authored
Jun 07, 2022
by
fezrul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update sample chargeable
parent
25bc4e7a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
71 deletions
+69
-71
packages/portal/timesheet/src/Http/Controllers/DashboardController.php
+69
-71
No files found.
packages/portal/timesheet/src/Http/Controllers/DashboardController.php
View file @
9ecc5ff7
...
@@ -239,99 +239,97 @@ class DashboardController extends Controller
...
@@ -239,99 +239,97 @@ class DashboardController extends Controller
public
function
saveHours
(
Request
$request
)
public
function
saveHours
(
Request
$request
)
{
{
//filter function save atau update akan buat kat blade.
//Form Baru
//Form Edit after rejected
//Form Baru
//check dalam db table ts-detail. Kalau dah ada details dalam td_hours -> update().
//Kalau tak ada detail hours -> save()
$user
=
users
::
where
(
'id'
,
Auth
::
id
())
->
first
();
$user
=
users
::
where
(
'id'
,
Auth
::
id
())
->
first
();
//me - check dalam db, table ts_detail, kalau dah ada detail hours, edit.
$checkTimesheetDetail
=
Ts_detail
::
where
(
'tm_staff_id'
,
$user
->
u_staffID
)
// check table master. untuk total chargeable hours.
$check
=
Ts_master
::
where
(
'tm_staff_id'
,
$user
->
u_staffID
)
->
where
(
'tm_year'
,
$request
->
year
)
->
where
(
'tm_year'
,
$request
->
year
)
->
where
(
'tm_month'
,
$request
->
month
)
->
where
(
'tm_month'
,
$request
->
month
)
->
where
(
'tm_phase'
,
$request
->
phase
)
->
where
(
'tm_phase'
,
$request
->
phase
)
->
whereNotNull
(
't
d_hou
rs'
)
->
whereNotNull
(
't
m_chargeable_h
rs'
)
->
first
();
->
first
();
//update total chargeable hrs
//kalau ada, update().
if
(
$checkTimesheetDetail
)
//staff kena edit bila submission timesheet kena reject.
if
(
$check
)
{
{
$data
=
Ts_detail
::
where
(
'tm_staff_id'
,
$user
->
u_staffID
)
->
where
(
'tm_year'
,
$request
->
year
)
->
where
(
'tm_month'
,
$request
->
month
)
->
where
(
'tm_phase'
,
$request
->
phase
)
->
first
();
$data
->
td_hours
=
10
;
$data
->
update
();
}
}
//kalau takda, save().
//
kalau takda, save().
else
else
{
{
// dd($checkTimesheetDetail);
$check
=
new
Ts_master
;
$data
=
new
Ts_detail
;
$check
->
tm_year
=
$request
->
year
;
$data
->
id
=
$request
->
id
;
$check
->
tm_month
=
$request
->
month
;
$data
->
tm_year
=
$request
->
year
;
$check
->
tm_phase
=
$request
->
phase
;
$data
->
tm_month
=
$request
->
month
;
// $check ->tm_chargeable_hrs = ;
$data
->
tm_phase
=
$request
->
phase
;
$check
->
save
();
$data
->
td_hours
=
8
;
$data
->
save
();
}
}
$tmasterid
=
$check
->
id
;
// check table master. untuk total chargeable hours.
// semak detail dari form
// $check = Ts_master::where('tm_staff_id', $user->u_staffID)
// ->where('tm_year', $request->year)
// ->where('tm_month', $request->month)
// ->where('tm_phase', $request->phase)
// ->whereNotNull('tm_chargeable_hrs')
// ->first();
// //kalau ada, update().
//untuk project type : 1=chargeable,2 nonchargeable, 3=overhead;
// //staff kena edit bila submission timesheet kena reject.
$detail
=
$request
->
hour
;
// if($check)
foreach
(
$detail
as
$key
=>
$value
)
// {
{
// $data = Ts_master::where('id',$request->id)->first();
foreach
(
$value
as
$keyday
=>
$day
)
// //update total chargeable hrs
{
// $data -> tm_chargeable_hrs = 10;
$projectid
=
$key
;
// $data -> update();
$date
=
$request
->
year
.
'-'
.
$request
->
month
.
'-'
.
sprintf
(
'%02d'
,
$keyday
);
// }
// //kalau takda, save().
$checkTimesheetDetail
=
Ts_detail
::
where
(
'fk_p_project_code'
,
$projectid
)
// else
->
where
(
'td_project_type'
,
1
)
// {
->
where
(
'td_date'
,
$date
)
// $data = new Ts_master;
->
where
(
'tm_phase'
,
$request
->
phase
)
// $data ->id = $request ->id;
->
first
();
// $data ->tm_year = $request ->year;
// $data ->tm_month = $request ->month;
if
(
$checkTimesheetDetail
)
// $data ->tm_phase = $request ->phase;
{
// $data ->tm_chargeable_hrs = 8;
//update hours
// $data ->save();
$valuehour
=
$day
;
// }
if
(
$valuehour
==
null
)
{
$valuehour
=
0
;
}
//kalau ada juga = bawak data details
$checkTimesheetDetail
->
td_hours
=
$valuehour
;
$checkTimesheetDetail
->
update
();
}
else
{
//isi semua
$tmdetail
=
new
Ts_detail
;
//$tmdetail -> kjhdiwhdf;
//project = Project::where('id','project')->first();
//
// /lepas save ();
}
}
}
//update total ke master;
//buat query sum td_hour where condition :
// $sumdetailhour = Ts_detail::where('fk_p_project_code', $projectid)
// ->where('td_project_type',1)
// ->where('td_date', $date)
// ->where('tm_phase', $request->phase)
// ->sum();
// tm_master = Ts_master::where('tm_staff_id','=',Auth::id())
// ->where('tm_month','=',$tm_month)
// ->get();
// if(isset(tm_master))
// {
// }
//first = check dah ade ke belum
// $check = Ts_master::where('id', $tmasterid)->first();
// $check->totaloiwfwoei = udaoe
//
mula2 masuk dalam table master untuk dapat id master.php
//
return redirect::to('mobile/profile');
//pakai id master untuk update ke detail.
return
redirect
()
->
route
(
'timesheet::dashboard.borangBolehCaj'
,
[
'phase'
=>
$request
->
phase
,
'month'
=>
$request
->
month
,
'year'
,
$request
->
year
])
->
with
(
'success'
,
'Timesheet Updated'
);
// $data = new Ts_master;
// $data -> tm_chargeable_hrs = $request -> tm_chargeable_hrs;
// $data -> save();
// return redirect('home');
}
}
public
function
timesheetApproval
()
public
function
timesheetApproval
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment