Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
timesheet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
web2project
timesheet
Commits
23df88df
Commit
23df88df
authored
Jan 23, 2014
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show selected timesheet
parent
4be46f9b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
87 additions
and
85 deletions
+87
-85
addedit.php
addedit.php
+75
-80
timesheet.class.php
timesheet.class.php
+12
-5
No files found.
addedit.php
View file @
23df88df
...
@@ -30,25 +30,22 @@ $timesheet_id = (int)w2PgetParam($_GET, "timesheet_id", 0);
...
@@ -30,25 +30,22 @@ $timesheet_id = (int)w2PgetParam($_GET, "timesheet_id", 0);
$timesheet
=
new
CTimesheet
();
$timesheet
=
new
CTimesheet
();
$timesheet
->
timesheet_id
=
$timesheet_id
;
$timesheet
->
timesheet_id
=
$timesheet_id
;
$obj
=
$timesheet
;
// we check for permissions on this module
$canEdit
=
$obj
->
canEdit
();
$perms
=
$AppUI
->
acl
();
$canDelete
=
$obj
->
canDelete
();
if
(
!
$perms
->
checkModuleItem
(
'timesheet'
,
'access'
))
{
// check permissions for this record
if
(
!
$canEdit
)
{
$AppUI
->
redirect
(
ACCESS_DENIED
);
$AppUI
->
redirect
(
ACCESS_DENIED
);
}
}
$canView
=
$perms
->
checkModule
(
$m
,
'view'
);
$obj
=
$AppUI
->
restoreObject
();
$canEdit
=
$perms
->
checkModule
(
$m
,
'edit'
);
if
(
$obj
)
{
$canDelete
=
$perms
->
checkModule
(
$m
,
'delete'
);
$timesheet
=
$obj
;
if
(
!
$canEdit
||
!
$canView
)
{
$timesheet_id
=
$timesheet
->
timesheet_id
;
$AppUI
->
redirect
(
ACCESS_DENIED
);
}
else
{
$timesheet
->
load
(
null
,
$timesheet_id
);
}
}
// load the record data in case of that this script is used to edit the timesheet(timesheet_id(
// Load object
$timesheet
->
load
(
null
,
$timesheet_id
);
// load the record data in case of that this script is used to edit the timesheet(timesheet_id)
if
(
!
$timesheet
&&
$timesheet_id
>
0
)
{
if
(
!
$timesheet
&&
$timesheet_id
>
0
)
{
$AppUI
->
setMsg
(
'Timesheet'
);
$AppUI
->
setMsg
(
'Timesheet'
);
$AppUI
->
setMsg
(
'invalidID'
,
UI_MSG_ERROR
,
true
);
$AppUI
->
setMsg
(
'invalidID'
,
UI_MSG_ERROR
,
true
);
...
@@ -56,13 +53,11 @@ if (!$timesheet && $timesheet_id > 0) {
...
@@ -56,13 +53,11 @@ if (!$timesheet && $timesheet_id > 0) {
}
}
// Read in all configuration data from timesheet_config
// Read in all configuration data from timesheet_config
print
"configuration options loading"
;
$config_options
=
$timesheet
->
get_config
();
$config_options
=
$obj
->
get_config
();
if
(
!
$config_options
)
{
if
(
!
$config_options
)
{
$AppUI
->
setMsg
(
'no configuration options found'
,
UI_MSG_ERROR
);
$AppUI
->
setMsg
(
'no configuration options found'
,
UI_MSG_ERROR
);
$AppUI
->
redirect
();
$AppUI
->
redirect
();
}
}
print
"configuration options loaded"
;
// setup the title block
// setup the title block
// Fill the title block either with 'Edit' or with 'New' depending on
// Fill the title block either with 'Edit' or with 'New' depending on
...
@@ -110,7 +105,7 @@ $titleBlock->show();
...
@@ -110,7 +105,7 @@ $titleBlock->show();
// create a form providing to add/edit a timesheet
// create a form providing to add/edit a timesheet
//Pull all users
//Pull all users
$q
=
new
DB
Query
();
$q
=
new
w2p_Database_
Query
();
$q
->
addQuery
(
'user_id, contact_first_name, contact_last_name'
);
$q
->
addQuery
(
'user_id, contact_first_name, contact_last_name'
);
$q
->
addTable
(
'users'
);
$q
->
addTable
(
'users'
);
$q
->
addTable
(
'contacts'
);
$q
->
addTable
(
'contacts'
);
...
@@ -122,47 +117,47 @@ while ( $row = $q->fetchRow()) {
...
@@ -122,47 +117,47 @@ while ( $row = $q->fetchRow()) {
$users
[
$row
[
'user_id'
]]
=
$row
[
'contact_last_name'
]
.
', '
.
$row
[
'contact_first_name'
];
$users
[
$row
[
'user_id'
]]
=
$row
[
'contact_last_name'
]
.
', '
.
$row
[
'contact_first_name'
];
}
}
// Get current submitter name
// Get current submitter name
if
(
"
$
obj
->timesheet_creator
"
==
""
)
{
if
(
"
$
timesheet
->timesheet_creator
"
==
""
)
{
$submitter
=
$users
[
$AppUI
->
user_id
];
$submitter
=
$users
[
$AppUI
->
user_id
];
$
obj
->
timesheet_creator
=
$AppUI
->
user_id
;
$
timesheet
->
timesheet_creator
=
$AppUI
->
user_id
;
}
else
{
}
else
{
$submitter
=
$users
[
$
obj
->
timesheet_creator
];
$submitter
=
$users
[
$
timesheet
->
timesheet_creator
];
}
}
$q
->
Clear
();
$q
->
Clear
();
// Get the current timesheet period
// Get the current timesheet period
$period
=
new
C
Date
();
$period
=
new
w2p_Utilities_
Date
();
if
(
intval
(
$
obj
->
timesheet_period
))
{
if
(
intval
(
$
timesheet
->
timesheet_period
))
{
$period
->
setDate
(
$
obj
->
timesheet_period
,
DATE_FORMAT_UNIXTIME
);
$period
->
setDate
(
$
timesheet
->
timesheet_period
,
DATE_FORMAT_UNIXTIME
);
}
else
{
}
else
{
// Set the correct year
// Set the correct year
if
(
$config_options
[
'book_year'
][
'value'
]
!=
''
)
{
if
(
$config_options
[
'book_year'
][
'value'
]
!=
''
)
{
$period
->
setYear
(
intval
(
$config_options
[
'book_year'
][
'value'
])
);
$period
->
setYear
(
intval
(
$config_options
[
'book_year'
][
'value'
])
);
}
}
$
obj
->
timesheet_period
=
$period
->
getTime
();
$
timesheet
->
timesheet_period
=
$period
->
getTime
();
}
}
// Get the current timesheet status
// Get the current timesheet status
$status
=
$
obj
->
timesheet_status
;
$status
=
$
timesheet
->
timesheet_status
;
// Get the current timesheet creation date
// Get the current timesheet creation date
$creation_date
=
new
C
Date
();
$creation_date
=
new
w2p_Utilities_
Date
();
if
(
intval
(
$
obj
->
timesheet_date
))
{
if
(
intval
(
$
timesheet
->
timesheet_date
))
{
$creation_date
->
setDate
(
$
obj
->
timesheet_date
,
DATE_FORMAT_UNIXTIME
);
$creation_date
->
setDate
(
$
timesheet
->
timesheet_date
,
DATE_FORMAT_UNIXTIME
);
}
else
{
}
else
{
$
obj
->
timesheet_date
=
$creation_date
->
getTime
();
$
timesheet
->
timesheet_date
=
$creation_date
->
getTime
();
}
}
if
(
intval
(
$
obj
->
timesheet_worked
))
{
if
(
intval
(
$
timesheet
->
timesheet_worked
))
{
$timesheet_worked
=
$
obj
->
timesheet_worked
;
$timesheet_worked
=
$
timesheet
->
timesheet_worked
;
}
else
{
}
else
{
$
obj
->
timesheet_worked
=
0
;
$
timesheet
->
timesheet_worked
=
0
;
}
}
// function TimesheetEditForm()
// function TimesheetEditForm()
echo
'<table cellspacing="0" cellpadding="4" border="0" width="100%" class="std">'
;
echo
'<table cellspacing="0" cellpadding="4" border="0" width="100%" class="std">'
;
echo
'<form name="editFrm" action="./index.php?m=timesheet" method="post">'
;
echo
'<form name="editFrm" action="./index.php?m=timesheet" method="post">'
;
// if set, the value of dosql is automatically executed by the
d
P core application
// if set, the value of dosql is automatically executed by the
w2
P core application
// do_timesheet_aed.php will be the target of this form
// do_timesheet_aed.php will be the target of this form
// it will execute all database relevant commands
// it will execute all database relevant commands
echo
'<input type="hidden" name="dosql" value="do_timesheet_aed" />'
;
echo
'<input type="hidden" name="dosql" value="do_timesheet_aed" />'
;
...
@@ -177,9 +172,9 @@ if (intval($obj->timesheet_worked)) {
...
@@ -177,9 +172,9 @@ if (intval($obj->timesheet_worked)) {
// the value of timesheet_id will be the id of the timesheet to edit
// the value of timesheet_id will be the id of the timesheet to edit
// or in case of addition of a new timesheet it will contain '0' as value
// or in case of addition of a new timesheet it will contain '0' as value
echo
'<input type="hidden" name="timesheet_id" value="'
.
$timesheet_id
.
'" />'
;
echo
'<input type="hidden" name="timesheet_id" value="'
.
$timesheet_id
.
'" />'
;
echo
'<input type="hidden" name="timesheet_date" value="'
.
$
obj
->
timesheet_date
.
'" />'
;
echo
'<input type="hidden" name="timesheet_date" value="'
.
$
timesheet
->
timesheet_date
.
'" />'
;
echo
'<input type="hidden" name="timesheet_creator" value="'
.
$
obj
->
timesheet_creator
.
'" />'
;
echo
'<input type="hidden" name="timesheet_creator" value="'
.
$
timesheet
->
timesheet_creator
.
'" />'
;
echo
'<input type="hidden" name="timesheet_worked" value="'
.
$
obj
->
timesheet_worked
.
'" />'
;
echo
'<input type="hidden" name="timesheet_worked" value="'
.
$
timesheet
->
timesheet_worked
.
'" />'
;
// please notice that html tags that have no </closing tag> should be closed
// please notice that html tags that have no </closing tag> should be closed
// like you find it here (<tag />) for xhtml compliance
// like you find it here (<tag />) for xhtml compliance
...
@@ -195,38 +190,38 @@ if (intval($obj->timesheet_worked)) {
...
@@ -195,38 +190,38 @@ if (intval($obj->timesheet_worked)) {
echo
'<td width="100%">'
;
echo
'<td width="100%">'
;
if
(
(
$canEdit
)
&&
(
$status
<
1
)
&&
(
$timesheet_id
==
0
)
)
{
if
(
(
$canEdit
)
&&
(
$status
<
1
)
&&
(
$timesheet_id
==
0
)
)
{
$newdate
=
new
C
Date
();
$newdate
=
new
w2p_Utilities_
Date
();
$newdate
->
setDate
(
$
obj
->
timesheet_period
,
DATE_FORMAT_UNIXTIME
);
$newdate
->
setDate
(
$
timesheet
->
timesheet_period
,
DATE_FORMAT_UNIXTIME
);
$newdate
->
setMonth
(
1
);
$newdate
->
setMonth
(
1
);
?>
?>
<select
name=
"timesheet_period"
size=
"1"
class=
"text"
onChange=
"periodChange();"
>
<select
name=
"timesheet_period"
size=
"1"
class=
"text"
onChange=
"periodChange();"
>
<option
<?php
if
(
$period
->
getMonth
()
==
1
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
d
PformSafe
(
'January'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
2
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
1
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
w2
PformSafe
(
'January'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
2
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
2
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
d
PformSafe
(
'February'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
3
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
2
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
w2
PformSafe
(
'February'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
3
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
3
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
d
PformSafe
(
'March'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
4
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
3
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
w2
PformSafe
(
'March'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
4
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
4
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
d
PformSafe
(
'April'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
5
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
4
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
w2
PformSafe
(
'April'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
5
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
5
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
d
PformSafe
(
'May'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
6
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
5
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
w2
PformSafe
(
'May'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
6
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
6
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
d
PformSafe
(
'June'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
7
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
6
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
w2
PformSafe
(
'June'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
7
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
7
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
d
PformSafe
(
'July'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
8
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
7
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
w2
PformSafe
(
'July'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
8
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
8
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
d
PformSafe
(
'August'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
9
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
8
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
w2
PformSafe
(
'August'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
9
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
9
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
d
PformSafe
(
'September'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
10
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
9
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
w2
PformSafe
(
'September'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
10
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
10
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
d
PformSafe
(
'October'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
11
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
10
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
w2
PformSafe
(
'October'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
11
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
11
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
d
PformSafe
(
'November'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
12
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
11
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
w2
PformSafe
(
'November'
);
?>
</option
>
<?php
$newdate
->
setMonth
(
12
);
?>
<option
<?php
if
(
$period
->
getMonth
()
==
12
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
d
PformSafe
(
'December'
);
?>
</option
>
<option
<?php
if
(
$period
->
getMonth
()
==
12
)
echo
"selected"
;
?>
value=
<?php
echo
'"'
.
$newdate
->
getTime
()
.
'"'
;
?>
>
<?php
echo
w2
PformSafe
(
'December'
);
?>
</option
>
</select>
</select>
<?php
<?php
}
else
{
}
else
{
if
(
$period
->
getMonth
()
==
1
)
echo
d
PformSafe
(
'January'
);
if
(
$period
->
getMonth
()
==
1
)
echo
w2
PformSafe
(
'January'
);
else
if
(
$period
->
getMonth
()
==
2
)
echo
d
PformSafe
(
'February'
);
else
if
(
$period
->
getMonth
()
==
2
)
echo
w2
PformSafe
(
'February'
);
else
if
(
$period
->
getMonth
()
==
3
)
echo
d
PformSafe
(
'March'
);
else
if
(
$period
->
getMonth
()
==
3
)
echo
w2
PformSafe
(
'March'
);
else
if
(
$period
->
getMonth
()
==
4
)
echo
d
PformSafe
(
'April'
);
else
if
(
$period
->
getMonth
()
==
4
)
echo
w2
PformSafe
(
'April'
);
else
if
(
$period
->
getMonth
()
==
5
)
echo
d
PformSafe
(
'May'
);
else
if
(
$period
->
getMonth
()
==
5
)
echo
w2
PformSafe
(
'May'
);
else
if
(
$period
->
getMonth
()
==
6
)
echo
d
PformSafe
(
'June'
);
else
if
(
$period
->
getMonth
()
==
6
)
echo
w2
PformSafe
(
'June'
);
else
if
(
$period
->
getMonth
()
==
7
)
echo
d
PformSafe
(
'July'
);
else
if
(
$period
->
getMonth
()
==
7
)
echo
w2
PformSafe
(
'July'
);
else
if
(
$period
->
getMonth
()
==
8
)
echo
d
PformSafe
(
'August'
);
else
if
(
$period
->
getMonth
()
==
8
)
echo
w2
PformSafe
(
'August'
);
else
if
(
$period
->
getMonth
()
==
9
)
echo
d
PformSafe
(
'September'
);
else
if
(
$period
->
getMonth
()
==
9
)
echo
w2
PformSafe
(
'September'
);
else
if
(
$period
->
getMonth
()
==
10
)
echo
d
PformSafe
(
'October'
);
else
if
(
$period
->
getMonth
()
==
10
)
echo
w2
PformSafe
(
'October'
);
else
if
(
$period
->
getMonth
()
==
11
)
echo
d
PformSafe
(
'November'
);
else
if
(
$period
->
getMonth
()
==
11
)
echo
w2
PformSafe
(
'November'
);
else
if
(
$period
->
getMonth
()
==
12
)
echo
d
PformSafe
(
'December'
);
else
if
(
$period
->
getMonth
()
==
12
)
echo
w2
PformSafe
(
'December'
);
}
}
echo
'</td>'
;
echo
'</td>'
;
echo
'</tr>'
;
echo
'</tr>'
;
...
@@ -243,21 +238,21 @@ if (intval($obj->timesheet_worked)) {
...
@@ -243,21 +238,21 @@ if (intval($obj->timesheet_worked)) {
(
$config_options
[
'approval_by'
][
'value'
]
==
$AppUI
->
user_id
))
)
{
(
$config_options
[
'approval_by'
][
'value'
]
==
$AppUI
->
user_id
))
)
{
?>
?>
<select
name=
"timesheet_status"
size=
"1"
class=
"text"
onChange=
"changeIt()"
>
<select
name=
"timesheet_status"
size=
"1"
class=
"text"
onChange=
"changeIt()"
>
<option
<?php
if
(
intval
(
$status
)
==
'0'
)
{
echo
"selected"
;
}
?>
value=
"0"
>
<?php
echo
d
PformSafe
(
'Open for Editing'
);
?>
</option>
<option
<?php
if
(
intval
(
$status
)
==
'0'
)
{
echo
"selected"
;
}
?>
value=
"0"
>
<?php
echo
w2
PformSafe
(
'Open for Editing'
);
?>
</option>
<option
<?php
if
(
intval
(
$status
)
==
'1'
)
{
echo
"selected"
;
}
?>
value=
"1"
>
<?php
echo
d
PformSafe
(
'Submitted'
);
?>
</option>
<option
<?php
if
(
intval
(
$status
)
==
'1'
)
{
echo
"selected"
;
}
?>
value=
"1"
>
<?php
echo
w2
PformSafe
(
'Submitted'
);
?>
</option>
<?php
<?php
// Only the user with Timesheet Approval rights may set a timesheet to approved status.
// Only the user with Timesheet Approval rights may set a timesheet to approved status.
if
(
$config_options
[
'approval_by'
][
'value'
]
==
$AppUI
->
user_id
)
{
if
(
$config_options
[
'approval_by'
][
'value'
]
==
$AppUI
->
user_id
)
{
?>
?>
<option
<?php
if
(
$status
==
'2'
)
{
echo
"selected"
;
}
?>
value=
"2"
>
<?php
echo
d
PformSafe
(
'Approved'
);
?>
</option>
<option
<?php
if
(
$status
==
'2'
)
{
echo
"selected"
;
}
?>
value=
"2"
>
<?php
echo
w2
PformSafe
(
'Approved'
);
?>
</option>
<?php
<?php
}
}
echo
"</select>"
;
echo
"</select>"
;
}
else
{
}
else
{
if
(
$status
==
1
)
if
(
$status
==
1
)
echo
d
PformSafe
(
'Submitted'
);
echo
w2
PformSafe
(
'Submitted'
);
else
if
(
$status
==
2
)
else
if
(
$status
==
2
)
echo
d
PformSafe
(
'Approved'
);
echo
w2
PformSafe
(
'Approved'
);
}
}
echo
'</td>'
;
echo
'</td>'
;
echo
'</tr>'
;
echo
'</tr>'
;
...
@@ -287,15 +282,15 @@ if (intval($obj->timesheet_worked)) {
...
@@ -287,15 +282,15 @@ if (intval($obj->timesheet_worked)) {
echo
'</table>'
;
echo
'</table>'
;
// Get Project Status information.
// Get Project Status information.
$project_types
=
d
PgetSysVal
(
"ProjectStatus"
);
$project_types
=
w2
PgetSysVal
(
"ProjectStatus"
);
// FIXME: Move this function to the Timesheet class
// FIXME: Move this function to the Timesheet class
// Find all tasks in this timesheet period and account them to the project.
// Find all tasks in this timesheet period and account them to the project.
function
showproject
()
function
showproject
()
{
{
global
$AppUI
,
$period
,
$
obj
,
$project_types
;
global
$AppUI
,
$period
,
$
timesheet
,
$project_types
;
$q
=
new
DB
Query
();
$q
=
new
w2p_Database_
Query
();
$q
->
addQuery
(
'project_id'
);
$q
->
addQuery
(
'project_id'
);
$q
->
addQuery
(
'project_name'
);
$q
->
addQuery
(
'project_name'
);
$q
->
addQuery
(
'project_company'
);
$q
->
addQuery
(
'project_company'
);
...
@@ -306,7 +301,7 @@ function showproject()
...
@@ -306,7 +301,7 @@ function showproject()
$timesheet_worked
=
0
;
$timesheet_worked
=
0
;
foreach
(
$projects
as
$row
)
{
foreach
(
$projects
as
$row
)
{
$project_id
=
$row
[
"project_id"
];
$project_id
=
$row
[
"project_id"
];
$t
=
new
DBQuery
;
$t
=
new
w2p_Database_Query
()
;
$t
->
addQuery
(
'task_id'
);
$t
->
addQuery
(
'task_id'
);
$t
->
addQuery
(
'task_name'
);
$t
->
addQuery
(
'task_name'
);
$t
->
addQuery
(
'task_owner'
);
$t
->
addQuery
(
'task_owner'
);
...
@@ -347,7 +342,7 @@ function showproject()
...
@@ -347,7 +342,7 @@ function showproject()
$log
=
$t
->
LoadList
();
$log
=
$t
->
LoadList
();
foreach
(
$log
as
$logitem
)
{
foreach
(
$log
as
$logitem
)
{
if
(
intval
(
$logitem
[
'task_log_date'
]))
{
if
(
intval
(
$logitem
[
'task_log_date'
]))
{
$taskDate
=
new
C
Date
(
$logitem
[
'task_log_date'
]);
$taskDate
=
new
w2p_Utilities_
Date
(
$logitem
[
'task_log_date'
]);
if
(
(
$period
->
GetMonth
()
==
$taskDate
->
GetMonth
())
&&
if
(
(
$period
->
GetMonth
()
==
$taskDate
->
GetMonth
())
&&
(
$period
->
GetYear
()
==
$taskDate
->
GetYear
())
)
{
(
$period
->
GetYear
()
==
$taskDate
->
GetYear
())
)
{
$amount
=
$amount
+
$logitem
[
'task_log_hours'
];
$amount
=
$amount
+
$logitem
[
'task_log_hours'
];
...
@@ -368,8 +363,8 @@ function showproject()
...
@@ -368,8 +363,8 @@ function showproject()
echo
'</tr>'
;
echo
'</tr>'
;
}
}
}
}
$
obj
->
timesheet_worked
=
$timesheet_worked
;
$
timesheet
->
timesheet_worked
=
$timesheet_worked
;
echo
'<tr><td> </td><td> </td><td><b>'
.
d
PformSafe
(
'Total'
)
.
'</b></td><td><b>'
.
$timesheet_worked
.
'</b></td><td> </td></tr>'
;
echo
'<tr><td> </td><td> </td><td><b>'
.
w2
PformSafe
(
'Total'
)
.
'</b></td><td><b>'
.
$timesheet_worked
.
'</b></td><td> </td></tr>'
;
}
// end of function showproject()
}
// end of function showproject()
// Print the overview table
// Print the overview table
...
@@ -387,13 +382,13 @@ function showproject()
...
@@ -387,13 +382,13 @@ function showproject()
echo
'<input type="hidden" name="projects" value="0" />'
;
echo
'<input type="hidden" name="projects" value="0" />'
;
echo
'<input type="hidden" name="timesheet_id" value="'
.
$timesheet_id
.
'" />'
;
echo
'<input type="hidden" name="timesheet_id" value="'
.
$timesheet_id
.
'" />'
;
echo
'<input type="hidden" name="timesheet_date" value="'
.
$
obj
->
timesheet_date
.
'" />'
;
echo
'<input type="hidden" name="timesheet_date" value="'
.
$
timesheet
->
timesheet_date
.
'" />'
;
echo
'<input type="hidden" name="timesheet_creator" value="'
.
$
obj
->
timesheet_creator
.
'" />'
;
echo
'<input type="hidden" name="timesheet_creator" value="'
.
$
timesheet
->
timesheet_creator
.
'" />'
;
echo
'<input type="hidden" name="timesheet_worked" value="'
.
$
obj
->
timesheet_worked
.
'" />'
;
echo
'<input type="hidden" name="timesheet_worked" value="'
.
$
timesheet
->
timesheet_worked
.
'" />'
;
showproject
();
showproject
();
echo
'<script language="javascript">workedHoursChange('
.
$
obj
->
timesheet_worked
.
');</script>'
;
echo
'<script language="javascript">workedHoursChange('
.
$
timesheet
->
timesheet_worked
.
');</script>'
;
echo
"</form>"
;
echo
"</form>"
;
echo
"</table>"
;
echo
"</table>"
;
?>
?>
timesheet.class.php
View file @
23df88df
...
@@ -45,7 +45,6 @@ class CTimesheet extends w2p_Core_BaseObject {
...
@@ -45,7 +45,6 @@ class CTimesheet extends w2p_Core_BaseObject {
// the constructor of the CTimesheet class, always combined with the table name and the unique key of the table
// the constructor of the CTimesheet class, always combined with the table name and the unique key of the table
public
function
__construct
()
{
public
function
__construct
()
{
parent
::
__construct
(
'timesheet'
,
'timesheet_id'
);
parent
::
__construct
(
'timesheet'
,
'timesheet_id'
);
$this
->
timesheet_id
=
$_POST
[
"timesheet_id"
];
}
}
public
function
isValid
()
{
public
function
isValid
()
{
...
@@ -56,8 +55,16 @@ class CTimesheet extends w2p_Core_BaseObject {
...
@@ -56,8 +55,16 @@ class CTimesheet extends w2p_Core_BaseObject {
return
(
count
(
$this
->
_error
))
?
false
:
true
;
return
(
count
(
$this
->
_error
))
?
false
:
true
;
}
}
public
function
loadFull
()
{
public
function
loadFull
(
$notUsed
=
null
,
$timesheet_id
)
{
// loadFull information for this timesheet
// loadFull information for this timesheet\
}
public
function
load
(
$notUsed
=
null
,
$timesheet_id
)
{
$q
=
$this
->
_getQuery
();
$q
->
addQuery
(
'*'
);
$q
->
addTable
(
'timesheet'
);
$q
->
addWhere
(
'timesheet_id ='
.
(
int
)
$timesheet_id
);
$q
->
loadObject
(
$this
,
true
,
false
);
}
}
protected
function
init
()
{
protected
function
init
()
{
...
@@ -80,7 +87,7 @@ class CTimesheet extends w2p_Core_BaseObject {
...
@@ -80,7 +87,7 @@ class CTimesheet extends w2p_Core_BaseObject {
{
{
$q
=
$this
->
_getQuery
();
$q
=
$this
->
_getQuery
();
$q
->
setDelete
(
'timesheet_project'
);
$q
->
setDelete
(
'timesheet_project'
);
$q
->
addWhere
(
'timesheet_id = '
.
$this
->
timesheet_id
);
$q
->
addWhere
(
'timesheet_id = '
.
(
int
)
$this
->
timesheet_id
);
if
(
!
(
$q
->
exec
()))
{
if
(
!
(
$q
->
exec
()))
{
$this
->
_error
[
'project-purge-timesheet'
]
=
db_error
();
$this
->
_error
[
'project-purge-timesheet'
]
=
db_error
();
return
false
;
return
false
;
...
@@ -92,7 +99,7 @@ class CTimesheet extends w2p_Core_BaseObject {
...
@@ -92,7 +99,7 @@ class CTimesheet extends w2p_Core_BaseObject {
{
{
// Get the current timesheet period
// Get the current timesheet period
$period
=
new
w2p_UtilitiesDate
(
$_POST
[
'timesheet_period'
]);
$period
=
new
w2p_UtilitiesDate
(
$_POST
[
'timesheet_period'
]);
//
$period->setDate($_POST['timesheet_period'],DATE_FORMAT_UNIXTIME);
$period
->
setDate
(
$_POST
[
'timesheet_period'
],
DATE_FORMAT_UNIXTIME
);
$q
=
$this
->
_getQuery
();
$q
=
$this
->
_getQuery
();
$q
->
addQuery
(
'project_id'
);
$q
->
addQuery
(
'project_id'
);
...
...
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