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
926b586a
Commit
926b586a
authored
Jun 08, 2022
by
hannan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
insert data chargeable
parent
1cb89676
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
187 additions
and
52 deletions
+187
-52
database/migrations/2022_06_08_094226_rename_column_in_timesheet_dtl_table.php
+42
-0
database/migrations/2022_06_08_105540_alter_timesheet_dtl_table.php
+42
-0
database/migrations/2022_06_08_110607_rename_table_project_task.php
+32
-0
packages/portal/timesheet/resources/views/dashboard/borangBolehCaj.blade.php
+1
-1
packages/portal/timesheet/routes/web.php
+1
-4
packages/portal/timesheet/src/Http/Controllers/DashboardController.php
+67
-45
packages/portal/timesheet/src/Model/Pteam.php
+2
-2
No files found.
database/migrations/2022_06_08_094226_rename_column_in_timesheet_dtl_table.php
0 → 100644
View file @
926b586a
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
class
RenameColumnInTimesheetDtlTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'timesheet_dtl'
,
function
(
Blueprint
$table
)
{
$table
->
renameColumn
(
'tm_id'
,
'fk_tm_id'
);
$table
->
renameColumn
(
'tm_staff_id'
,
'fk_tm_staff_id'
);
$table
->
renameColumn
(
'tm_month'
,
'fk_tm_month'
);
$table
->
renameColumn
(
'tm_year'
,
'fk_tm_year'
);
$table
->
renameColumn
(
'tm_phase'
,
'fk_tm_phase'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'timesheet_dtl'
,
function
(
Blueprint
$table
)
{
$table
->
renameColumn
(
'fk_tm_id'
,
'tm_id'
);
$table
->
renameColumn
(
'fk_tm_staff_id'
,
'tm_staff_id'
);
$table
->
renameColumn
(
'fk_tm_month'
,
'tm_month'
);
$table
->
renameColumn
(
'fk_tm_year'
,
'tm_year'
);
$table
->
renameColumn
(
'fk_tm_phase'
,
'tm_phase'
);
});
}
}
database/migrations/2022_06_08_105540_alter_timesheet_dtl_table.php
0 → 100644
View file @
926b586a
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
class
AlterTimesheetDtlTable
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'timesheet_dtl'
,
function
(
Blueprint
$table
)
{
$table
->
renameColumn
(
'fk_tm_staff_id'
,
'tm_staff_id'
);
$table
->
renameColumn
(
'fk_tm_month'
,
'tm_month'
);
$table
->
renameColumn
(
'fk_tm_year'
,
'tm_year'
);
$table
->
renameColumn
(
'fk_tm_phase'
,
'tm_phase'
);
$table
->
dropColumn
(
'fk_p_project_code'
);
$table
->
integer
(
'td_project'
)
->
after
(
'td_date'
)
->
unsigned
()
->
nullable
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'timesheet_dtl'
,
function
(
Blueprint
$table
)
{
$table
->
renameColumn
(
'tm_staff_id'
,
'fk_tm_staff_id'
);
$table
->
renameColumn
(
'tm_month'
,
'fk_tm_month'
);
$table
->
renameColumn
(
'tm_year'
,
'fk_tm_year'
);
$table
->
renameColumn
(
'tm_phase'
,
'fk_tm_phase'
);
$table
->
string
(
'fk_p_project_code'
);
$table
->
dropColumn
(
'td_project'
);
});
}
}
database/migrations/2022_06_08_110607_rename_table_project_task.php
0 → 100644
View file @
926b586a
<?php
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Database\Migrations\Migration
;
class
RenameTableProjectTask
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'project_task'
,
function
(
Blueprint
$table
)
{
Schema
::
rename
(
'project_task'
,
'project_team'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'project_task'
,
function
(
Blueprint
$table
)
{
//
});
}
}
packages/portal/timesheet/resources/views/dashboard/borangBolehCaj.blade.php
View file @
926b586a
...
@@ -28,7 +28,7 @@ input[type=number] {
...
@@ -28,7 +28,7 @@ input[type=number] {
Phase =
{
{$phase}
}
Phase =
{
{$phase}
}
<br>
<br>
<hr>
<hr>
<form class="
ui
form
" action="
{{
url
(
'saveH
ours'
)}}
" method="
POST
">
<form class="
ui
form
" action="
{{
route
(
'timesheet::dashboard.savechargeableh
ours'
)}}
" method="
POST
">
{
{csrf_field()}
}
{
{csrf_field()}
}
<input type="
hidden
" name="
userId
" value="
{{
$userId
}}
">
<input type="
hidden
" name="
userId
" value="
{{
$userId
}}
">
<input type="
hidden
" name="
year
" value="
{{
$year
}}
">
<input type="
hidden
" name="
year
" value="
{{
$year
}}
">
...
...
packages/portal/timesheet/routes/web.php
View file @
926b586a
...
@@ -20,10 +20,7 @@ Route::group(
...
@@ -20,10 +20,7 @@ Route::group(
Route
::
get
(
'timesheet_report'
,[
'uses'
=>
'DashboardController@timesheetReport'
,
'as'
=>
'dashboard.timesheetReport'
]);
Route
::
get
(
'timesheet_report'
,[
'uses'
=>
'DashboardController@timesheetReport'
,
'as'
=>
'dashboard.timesheetReport'
]);
Route
::
get
(
'timesheet_review'
,[
'uses'
=>
'DashboardController@timesheetReview'
,
'as'
=>
'dashboard.timesheetReview'
]);
Route
::
get
(
'timesheet_review'
,[
'uses'
=>
'DashboardController@timesheetReview'
,
'as'
=>
'dashboard.timesheetReview'
]);
Route
::
get
(
'timesheet_viewer'
,[
'uses'
=>
'DashboardController@timesheetViewer'
,
'as'
=>
'dashboard.timesheetViewer'
]);
Route
::
get
(
'timesheet_viewer'
,[
'uses'
=>
'DashboardController@timesheetViewer'
,
'as'
=>
'dashboard.timesheetViewer'
]);
// Route::get('phase1/{phase}',['uses' => 'DashboardController@phase1', 'as' => 'dashboard.phase1']);
Route
::
post
(
'savechargeablehours'
,[
'uses'
=>
'DashboardController@savechargeablehours'
,
'as'
=>
'dashboard.savechargeablehours'
]);
// Route::get('phase2/{phase}',['uses' => 'DashboardController@phase2', 'as' => 'dashboard.phase2']);
Route
::
post
(
'saveHours'
,[
'uses'
=>
'DashboardController@saveHours'
,
'as'
=>
'dashboard.saveHours'
]);
}
}
);
);
...
...
packages/portal/timesheet/src/Http/Controllers/DashboardController.php
View file @
926b586a
...
@@ -8,6 +8,7 @@ use DB;
...
@@ -8,6 +8,7 @@ use DB;
use
Portal\Timesheet\Model\Users
;
use
Portal\Timesheet\Model\Users
;
use
Portal\Timesheet\Model\Ts_master
;
use
Portal\Timesheet\Model\Ts_master
;
use
Portal\Timesheet\Model\Ts_detail
;
use
Portal\Timesheet\Model\Ts_detail
;
use
Portal\Timesheet\Model\Project
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Input
;
use
Illuminate\Support\Facades\Input
;
use
File
;
use
File
;
...
@@ -105,8 +106,7 @@ class DashboardController extends Controller
...
@@ -105,8 +106,7 @@ class DashboardController extends Controller
'td_id'
=>
'1'
,
'td_id'
=>
'1'
,
'td_date'
=>
date
(
'j-n-Y'
,
strtotime
(
'6/5/2022'
)),
'td_date'
=>
date
(
'j-n-Y'
,
strtotime
(
'6/5/2022'
)),
'td_project'
=>
'1'
,
'td_project'
=>
'1'
,
'tm_id'
=>
'1'
,
'fk_tm_id'
=>
'1'
,
'tm_staff_id'
=>
'1000'
,
'project_type'
=>
'1'
,
'project_type'
=>
'1'
,
'fk_o_id'
=>
''
,
'fk_o_id'
=>
''
,
'tm_year'
=>
'2022'
,
'tm_year'
=>
'2022'
,
...
@@ -123,8 +123,7 @@ class DashboardController extends Controller
...
@@ -123,8 +123,7 @@ class DashboardController extends Controller
'td_id'
=>
'2'
,
'td_id'
=>
'2'
,
'td_date'
=>
date
(
'j-n-Y'
,
strtotime
(
'6/5/2022'
)),
'td_date'
=>
date
(
'j-n-Y'
,
strtotime
(
'6/5/2022'
)),
'td_project'
=>
'2'
,
'td_project'
=>
'2'
,
'tm_id'
=>
'1'
,
'fk_tm_id'
=>
'1'
,
'tm_staff_id'
=>
'1000'
,
'project_type'
=>
'1'
,
'project_type'
=>
'1'
,
'fk_o_id'
=>
''
,
'fk_o_id'
=>
''
,
'tm_year'
=>
'2022'
,
'tm_year'
=>
'2022'
,
...
@@ -174,19 +173,19 @@ class DashboardController extends Controller
...
@@ -174,19 +173,19 @@ class DashboardController extends Controller
$user
=
users
::
where
(
'id'
,
Auth
::
id
())
->
first
();
$user
=
users
::
where
(
'id'
,
Auth
::
id
())
->
first
();
// dd($user);
// dd($user);
// check timesheet
detail
// check timesheet
master
$check
TimesheetDetail
=
Ts_detail
::
where
(
'tm_staff_id'
,
$user
->
u_staffID
)
$check
=
Ts_master
::
where
(
'tm_staff_id'
,
$user
->
u_staffID
)
->
where
(
'tm_year'
,
$year
)
->
where
(
'tm_year'
,
$year
)
->
where
(
'tm_month'
,
$month
)
->
where
(
'tm_month'
,
$month
)
->
where
(
'tm_phase'
,
$phase
)
->
where
(
'tm_phase'
,
$phase
)
->
whereNotNull
(
't
d_hou
rs'
)
->
whereNotNull
(
't
m_chargeable_h
rs'
)
->
first
();
->
first
();
//
kalau ada, dia gi ke edit
//kalau ada, dia gi ke edit
if
(
$check
TimesheetDetail
)
if
(
$check
)
{
{
$data
=
Ts_
detail
::
where
(
'id'
,
$request
->
id
)
->
first
();
$data
=
Ts_
master
::
where
(
'id'
,
$request
->
id
)
->
first
();
}
}
//klu xde g create.php
//klu xde g create.php
else
else
...
@@ -194,21 +193,21 @@ class DashboardController extends Controller
...
@@ -194,21 +193,21 @@ class DashboardController extends Controller
$data
=
[];
$data
=
[];
}
}
//
dd($checkTimesheetDetail);
//
kalau ada juga = bawak data details
//
check timesheet master
//
check timesheet detail
// $check
= Ts_master::where('
tm_staff_id', $user->u_staffID)
// $check
TimesheetDetail = Ts_detail::where('fk_
tm_staff_id', $user->u_staffID)
// ->where('tm_year', $year)
// ->where('
fk_
tm_year', $year)
// ->where('tm_month', $month)
// ->where('
fk_
tm_month', $month)
// ->where('tm_phase', $phase)
// ->where('tm_phase', $phase)
// ->whereNotNull('t
m_chargeable_h
rs')
// ->whereNotNull('t
d_hou
rs')
// ->first();
// ->first();
// //kalau ada, dia gi ke edit
// //
kalau ada, dia gi ke edit
// if($check)
// if($check
TimesheetDetail
)
// {
// {
// $data = Ts_
master
::where('id',$request->id)->first();
// $data = Ts_
detail
::where('id',$request->id)->first();
// }
// }
// //klu xde g create.php
// //klu xde g create.php
// else
// else
...
@@ -216,7 +215,7 @@ class DashboardController extends Controller
...
@@ -216,7 +215,7 @@ class DashboardController extends Controller
// $data = [];
// $data = [];
// }
// }
//
kalau ada juga = bawak data details
//
dd($checkTimesheetDetail);
return
view
(
'timesheet::dashboard.borangBolehCaj'
,
compact
(
'userId'
,
'projectcode'
,
'projectname'
,
'month'
,
'phase'
,
'samplequery'
,
'daymonth'
,
'year'
,
'sampleTimesheet_dtl'
,
'day'
,
'data'
));
return
view
(
'timesheet::dashboard.borangBolehCaj'
,
compact
(
'userId'
,
'projectcode'
,
'projectname'
,
'month'
,
'phase'
,
'samplequery'
,
'daymonth'
,
'year'
,
'sampleTimesheet_dtl'
,
'day'
,
'data'
));
}
}
...
@@ -236,12 +235,15 @@ class DashboardController extends Controller
...
@@ -236,12 +235,15 @@ class DashboardController extends Controller
return
view
(
'timesheet::dashboard.kalendar'
);
return
view
(
'timesheet::dashboard.kalendar'
);
}
}
public
function
save
H
ours
(
Request
$request
)
public
function
save
chargeableh
ours
(
Request
$request
)
{
{
// chargeable, project type 1.
$chargeable
=
1
;
$nonchargeable
=
2
;
$overhead
=
3
;
$user
=
users
::
where
(
'id'
,
Auth
::
id
())
->
first
();
$user
=
users
::
where
(
'id'
,
Auth
::
id
())
->
first
();
// check table master. untuk total chargeable hours.
// check table master. untuk total chargeable hours.
$check
=
Ts_master
::
where
(
'tm_staff_id'
,
$user
->
u_staffID
)
$check
=
Ts_master
::
where
(
'tm_staff_id'
,
$user
->
u_staffID
)
->
where
(
'tm_year'
,
$request
->
year
)
->
where
(
'tm_year'
,
$request
->
year
)
...
@@ -251,27 +253,32 @@ class DashboardController extends Controller
...
@@ -251,27 +253,32 @@ class DashboardController extends Controller
->
first
();
->
first
();
//kalau ada, update().
//kalau ada, update().
//staff kena edit bila submission timesheet kena reject.
//staff kena edit bila timesheet kena reject.
//kalau ada, biar dlu.
if
(
$check
)
if
(
$check
)
{
{
}
}
// kalau takda, save().
// kalau takda, save()
baru
.
else
else
{
{
$check
=
new
Ts_master
;
$check
=
new
Ts_master
;
$check
->
tm_year
=
$request
->
year
;
$check
->
tm_year
=
$request
->
year
;
$check
->
tm_month
=
$request
->
month
;
$check
->
tm_month
=
$request
->
month
;
$check
->
tm_phase
=
$request
->
phase
;
$check
->
tm_phase
=
$request
->
phase
;
// $check ->tm_chargeable_hrs = ;
// $check ->tm_chargeable_hrs = ;
$check
->
save
();
$check
->
save
();
}
}
$tmasterid
=
$check
->
id
;
$tmasterid
=
$check
->
id
;
// semak detail dari form
// semak detail dari form
//untuk project type : 1=chargeable,2 nonchargeable, 3=overhead;
// untuk project type : 1 = chargeable, 2 = nonchargeable, 3 = overhead;
// . . .
$detail
=
$request
->
hour
;
$detail
=
$request
->
hour
;
foreach
(
$detail
as
$key
=>
$value
)
foreach
(
$detail
as
$key
=>
$value
)
{
{
foreach
(
$value
as
$keyday
=>
$day
)
foreach
(
$value
as
$keyday
=>
$day
)
...
@@ -279,15 +286,15 @@ class DashboardController extends Controller
...
@@ -279,15 +286,15 @@ class DashboardController extends Controller
$projectid
=
$key
;
$projectid
=
$key
;
$date
=
$request
->
year
.
'-'
.
$request
->
month
.
'-'
.
sprintf
(
'%02d'
,
$keyday
);
$date
=
$request
->
year
.
'-'
.
$request
->
month
.
'-'
.
sprintf
(
'%02d'
,
$keyday
);
$checkTimesheetDetail
=
Ts_detail
::
where
(
'
fk_p_project_code
'
,
$projectid
)
$checkTimesheetDetail
=
Ts_detail
::
where
(
'
td_project
'
,
$projectid
)
->
where
(
'td_project_type'
,
1
)
// ->where('td_project_type', $project_type
)
->
where
(
'td_date'
,
$date
)
->
where
(
'td_date'
,
$date
)
->
where
(
'tm_phase'
,
$request
->
phase
)
->
where
(
'tm_phase'
,
$request
->
phase
)
->
first
();
->
first
();
if
(
$checkTimesheetDetail
)
if
(
$checkTimesheetDetail
)
{
{
//update hours
//update hours
to null
$valuehour
=
$day
;
$valuehour
=
$day
;
if
(
$valuehour
==
null
)
if
(
$valuehour
==
null
)
{
{
...
@@ -297,15 +304,30 @@ class DashboardController extends Controller
...
@@ -297,15 +304,30 @@ class DashboardController extends Controller
$checkTimesheetDetail
->
td_hours
=
$valuehour
;
$checkTimesheetDetail
->
td_hours
=
$valuehour
;
$checkTimesheetDetail
->
update
();
$checkTimesheetDetail
->
update
();
}
else
}
//kalau takde, isi semua.
else
{
{
//isi semua
//isi semua
$tmdetail
=
new
Ts_detail
;
$tmdetail
=
new
Ts_detail
;
$tmdetail
->
td_date
=
$date
;
$tmdetail
->
td_project
=
$projectid
;
$tmdetail
->
fk_tm_id
=
$tmasterid
;
$tmdetail
->
tm_staff_id
=
$user
->
u_staffID
;
$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
=
$day
;
$tmdetail
->
save
();
//$tmdetail -> kjhdiwhdf;
//$tmdetail -> kjhdiwhdf;
//project = Project::where('id','project')->first();
//project = Project::where('id','project')->first();
//
//
// /lepas save ();
// /lepas save ();
}
}
...
@@ -314,17 +336,17 @@ class DashboardController extends Controller
...
@@ -314,17 +336,17 @@ class DashboardController extends Controller
}
}
//update total ke master;
//update total ke master;
//buat query sum td_hour where condition :
//buat query sum td_hours where condition :
// $sumdetailhour = Ts_detail::where('fk_p_project_code', $projectid)
$sumdetailhour
=
Ts_detail
::
where
(
'td_project'
,
$projectid
)
// ->where('td_project_type',1)
->
where
(
'td_project_type'
,
$chargeable
)
// ->where('td_date', $date)
// ->where('td_date', $date)
// ->where('tm_phase', $request->phase)
->
where
(
'tm_phase'
,
$request
->
phase
)
// ->sum();
->
sum
(
'td_hours'
);
dd
(
$sumdetailhour
);
// $check = Ts_master::where('id', $tmasterid)->first();
$checktotalhours
=
Ts_master
::
where
(
'id'
,
$tmasterid
)
// $check->totaloiwfwoei = udaoe
->
where
(
'tm_chargeable_hrs'
,
$sumdetailhour
)
->
update
();
// return redirect::to('mobile/profile');
// return redirect::to('mobile/profile');
...
...
packages/portal/timesheet/src/Model/P
_task
.php
→
packages/portal/timesheet/src/Model/P
team
.php
View file @
926b586a
...
@@ -4,14 +4,14 @@ namespace Portal\Timesheet\Model;
...
@@ -4,14 +4,14 @@ namespace Portal\Timesheet\Model;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
P
_task
extends
Model
class
P
team
extends
Model
{
{
/**
/**
* The database table used by the model.
* The database table used by the model.
*
*
* @var string
* @var string
*/
*/
protected
$table
=
'project_t
ask
'
;
protected
$table
=
'project_t
eam
'
;
/**
/**
...
...
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