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
28807ad4
Commit
28807ad4
authored
Jan 23, 2014
by
Jean-Paul Saman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix changing of timesheet status
parent
feac3d38
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
16 deletions
+23
-16
addedit.php
addedit.php
+12
-6
do_timesheet_aed.php
do_timesheet_aed.php
+1
-1
timesheet.class.php
timesheet.class.php
+10
-9
No files found.
addedit.php
View file @
28807ad4
...
...
@@ -126,16 +126,22 @@ if ("$timesheet->timesheet_creator" == "") {
$q
->
Clear
();
// Get the current timesheet period
// FIXME: after changing timesheet_status a new timesheet is opened
// instead of the one we changed. All information is then mixed from
// the old timesheet and new timesheet. Luckily the database is not
// updated with the 'new' timesheet
// print "timesheet id " . $timesheet->timesheet_id . "<br";
$period
=
new
w2p_Utilities_Date
();
if
(
intval
(
$timesheet
->
timesheet_period
)
)
{
if
(
$timesheet
->
timesheet_period
)
{
$period
->
setDate
(
$timesheet
->
timesheet_period
,
DATE_FORMAT_UNIXTIME
);
}
else
{
// Set the correct year
if
(
$config_options
[
'
book_year'
][
'value
'
]
!=
''
)
{
$period
->
setYear
(
intval
(
$config_options
[
'
book_year'
][
'value
'
])
);
if
(
$config_options
[
'
timesheet_book_year
'
]
!=
''
)
{
$period
->
setYear
(
intval
(
$config_options
[
'
timesheet_book_year
'
])
);
}
$timesheet
->
timesheet_period
=
$period
->
getTime
();
}
print
"timesheet period "
.
$period
->
GetMonth
()
.
"<br>"
;
// Get the current timesheet status
$status
=
$timesheet
->
timesheet_status
;
...
...
@@ -235,14 +241,14 @@ if (intval($timesheet->timesheet_worked)) {
echo
'<td width="100%" align="right"">'
;
if
(
(
$canEdit
)
&&
((
$status
==
0
)
||
(
$config_options
[
'
approval_by'
][
'value
'
]
==
$AppUI
->
user_id
))
)
{
(
$config_options
[
'
timesheet_approval_by
'
]
==
$AppUI
->
user_id
))
)
{
?>
<select
name=
"timesheet_status"
size=
"1"
class=
"text"
onChange=
"changeIt()"
>
<option
<?php
if
(
intval
(
$status
)
==
'0'
)
{
echo
"selected"
;
}
?>
value=
"0"
>
<?php
echo
w2PformSafe
(
'Open for Editing'
);
?>
</option>
<option
<?php
if
(
intval
(
$status
)
==
'1'
)
{
echo
"selected"
;
}
?>
value=
"1"
>
<?php
echo
w2PformSafe
(
'Submitted'
);
?>
</option>
<?php
// 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
[
'
timesheet_approval_by
'
]
==
$AppUI
->
user_id
)
{
?>
<option
<?php
if
(
$status
==
'2'
)
{
echo
"selected"
;
}
?>
value=
"2"
>
<?php
echo
w2PformSafe
(
'Approved'
);
?>
</option>
<?php
...
...
@@ -267,7 +273,7 @@ if (intval($timesheet->timesheet_worked)) {
// If $status is not "Open for Editing" then don't allow to change the status.
// There is one exception to this rule the 'administrator' can always change the status.
if
(
(
$canEdit
)
&&
((
$status
==
0
)
||
(
$config_options
[
'
approval_by'
][
'value
'
]
==
$AppUI
->
user_id
))
)
{
(
$config_options
[
'
timesheet_approval_by
'
]
==
$AppUI
->
user_id
))
)
{
?>
<input
class=
"button"
type=
"button"
name=
"cancel"
value=
"
<?php
echo
$AppUI
->
_
(
'cancel'
);
?>
"
onClick=
"javascript:if(confirm('Are you sure you want to cancel.')){location.href = './index.php?m=timesheet';}"
/>
<?php
...
...
do_timesheet_aed.php
View file @
28807ad4
...
...
@@ -52,7 +52,7 @@ if ($del) {
$AppUI
->
setMsg
(
"Timesheet deleted"
,
UI_MSG_ALERT
);
}
}
else
if
(
$stat
)
{
if
(
!
$obj
->
change_status
())
{
if
(
!
$obj
->
change_status
(
$obj
->
timesheet_status
))
{
$AppUI
->
setMsg
(
"Timesheet changing status failed"
,
UI_MSG_ERROR
);
}
else
{
$AppUI
->
setMsg
(
"Timesheet status updated"
,
UI_MSG_ALERT
);
...
...
timesheet.class.php
View file @
28807ad4
...
...
@@ -215,20 +215,21 @@ class CTimesheet extends w2p_Core_BaseObject {
return
true
;
}
public
function
change_status
()
{
public
function
change_status
(
$status
)
{
$this
->
clearErrors
();
if
(
!
$this
->
canEdit
())
return
false
;
//
if (!$this->canEdit())
//
return false;
if
(
$timesheet_id
==
0
)
{
if
(
!
$this
->
canCreate
())
return
false
;
$this
->
init
();
}
//if ($timesheet_id == 0) {
// if (!$this->canCreate())
// return false;
// $this->init();
// $this->load(null, $timesheet_id);
//}
$q
=
$this
->
_getQuery
();
$q
->
addTable
(
'timesheet'
);
$q
->
addUpdate
(
'timesheet_status'
,
$
this
->
timesheet_
status
);
$q
->
addUpdate
(
'timesheet_status'
,
$status
);
$q
->
addWhere
(
'timesheet_id = '
.
$this
->
timesheet_id
);
if
(
!
(
$q
->
exec
()))
{
$this
->
_error
[
'change-status-timesheet'
]
=
db_error
();
...
...
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