Commit 99a941fd authored by Jean-Paul Saman's avatar Jean-Paul Saman

Fix timesheet creation and month selection.

After initial creation timesheet_period can be changed. The second time it is edited this is no longer possible. Either:
1) Fix 2nd time editing, or
2) Make checkbox non-modifiable for 2nd time opening.

BUGS:
1) Changing from "submitted" to "open for editing" by administrator doesn't work
2) Changing from "approved" to "open for editing" by adminstrator doesn't work
3) Status combobox show always "open for editing" as status even when it is one of the other statuses
4) Inserting 2 timesheets with the exact same month and year is not considered an error, while this should not be allowed.
5) Delete icon from timesheet overview doesn't work. It will forward you to timesheet details instead. You can delete the timesheet from there.

TODO:
- Remove debug statements
- Show Customer in timesheet details
- Show Customer in timesheet overview
- Show total amount of hours worked in timesheet details
- Show total amount of days worked in timesheet details
- Show total amount of days worked in timesheet overview
parent 5abe59c3
This diff is collapsed.
......@@ -36,7 +36,7 @@ $del = dPgetParam($_POST, 'del', 0);
$obj->timesheet_id = $_POST["timesheet_id"];
$obj->timesheet_status = $_POST["timesheet_status"];
$obj->timesheet_period = $_POST["ts_period"];
$obj->timesheet_period = $_POST["timesheet_period"];
$obj->timesheet_date = $_POST["timesheet_date"];
$obj->timesheet_creator = $_POST["timesheet_creator"];
$obj->timesheet_worked = $_POST["timesheet_worked"];
......
......@@ -66,10 +66,12 @@ class CTimesheet extends CDpObject {
$q = new DBQuery();
$q->addTable('timesheet');
$q->addInsert('timesheet_period,timesheet_status,timesheet_date,timesheet_creator,timesheet_worked',
$this->timesheet_period.','.$_POST['timesheet_status'].','.
$_POST['timesheet_period'].','.$_POST['timesheet_status'].','.
$_POST['timesheet_date'].','.$_POST['timesheet_creator'].','.
$_POST['timesheet_worked'], true);
$q->exec();
if (!$q->exec()) {
return dberror();
}
$this->timesheet_id = db_insert_id();
}
......@@ -85,12 +87,10 @@ class CTimesheet extends CDpObject {
function project_store()
{
// Get the current timesheet period
if (intval($_POST['ts_period'])) {
$period = new CDate();
$period->setMonth($_POST['ts_period']);
$period = new CDate();
if (intval($_POST['timesheet_period'])) {
$period->setDate($_POST['timesheet_period'],DATE_FORMAT_UNIXTIME);
}
else
$period = new CDate();
$q = new DBQuery();
$q->addQuery('project_id');
......@@ -143,7 +143,7 @@ class CTimesheet extends CDpObject {
$sheet->addInsert('timesheet_id,timesheet_project,timesheet_project_amount',
$this->timesheet_id.','.$row["project_id"].','.$amount, true);
if (!$sheet->exec()) {
echo db_error();
return db_error();
}
}
}
......@@ -156,7 +156,7 @@ class CTimesheet extends CDpObject {
$q->addUpdate('timesheet_worked', $this->timesheet_worked);
$q->addWhere('timesheet_id = ' . $this->timesheet_id);
if (!$q->exec()) {
echo db_error();
return db_error();
}
}
else {
......@@ -169,7 +169,7 @@ class CTimesheet extends CDpObject {
$this->timesheet_date.','.$this->timesheet_creator.',' .
$this->timesheet_worked, true);
if (!$q->exec())
echo db_error();
return db_error();
}
}
......
......@@ -149,7 +149,7 @@ function timesheets($type)
echo "<td>";
echo "\n".'<a href="?m=timesheet&a=addedit&timesheet_id=' . $row["timesheet_id"] . '">';
$period = new CDate();
if (intval($row["timesheet_period"])<=12) {
if (intval($row["timesheet_period"])<=12) { // << hack for previouse timesheet versions
$period->setMonth($row["timesheet_period"]);
$period->setYear(2007);
}
......
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