X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/5d4953bb5ec09e6e79a114c71f53f410c6064f2e..bcd76a04871724775c3b648bffa56e6d4ea4551c:/timesheet_edit.php diff --git a/timesheet_edit.php b/timesheet_edit.php index 84461546..1708bdf7 100644 --- a/timesheet_edit.php +++ b/timesheet_edit.php @@ -64,33 +64,35 @@ $form->addInput(array('type'=>'textarea','name'=>'comment','style'=>'width: 250p $form->addInput(array('type'=>'combobox','name'=>'status','value'=>$cl_status, 'data'=>array(ACTIVE=>$i18n->get('dropdown.status_active'),INACTIVE=>$i18n->get('dropdown.status_inactive')))); $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save'))); +$form->addInput(array('type'=>'submit','name'=>'btn_delete','value'=>$i18n->get('label.delete'))); if ($request->isPost()) { // Validate user input. if (!ttValidString($cl_name)) $err->add($i18n->get('error.field'), $i18n->get('label.thing_name')); if (!ttValidString($cl_comment, true)) $err->add($i18n->get('error.field'), $i18n->get('label.comment')); - if ($err->no()) { - /* - // TODO: coding ongoing down from here. - if ($request->getParameter('btn_save')) { - $existing_project = ttProjectHelper::getProjectByName($cl_name); - if (!$existing_project || ($cl_project_id == $existing_project['id'])) { - // Update project information. - if (ttProjectHelper::update(array( - 'id' => $cl_project_id, + if ($request->getParameter('btn_save')) { + if ($err->no()) { + $existing_timesheet = ttTimesheetHelper::getTimesheetByName($cl_name, $timesheet['user_id']); + if (!$existing_timesheet || ($cl_timesheet_id == $existing_timesheet['id'])) { + // Update timesheet information. + if (ttTimesheetHelper::update(array( + 'id' => $cl_timesheet_id, 'name' => $cl_name, - 'description' => $cl_description, - 'status' => $cl_status, - 'users' => $cl_users, - 'tasks' => $cl_tasks))) { - header('Location: projects.php'); + 'submitter_comment' => $cl_comment, + 'status' => $cl_status))) { + header('Location: timesheets.php'); exit(); } else $err->add($i18n->get('error.db')); } else $err->add($i18n->get('error.object_exists')); - }*/ + } + } + + if ($request->getParameter('btn_delete')) { + header("Location: timesheet_delete.php?id=$cl_timesheet_id"); + exit(); } } // isPost