function updatestatus_ALL(Web &$w) { // check for required REQUEST elements if ($w->request('id') && $w->request('status')) { // task is to get updated so gather relevant data $task = $w->Task->getTask($w->request('id')); // if task exists, first gather changes for display in comments if ($task) { $comments = "status updated to: " . $w->request('status') . "\n"; $task->fill($_REQUEST); // if task has a 'closed' status, set flag so task no longer appear in dashboard count or task list if ($task->getisTaskClosed()) { $task->is_closed = 1; $task->dt_completed = date("d/m/Y"); } else { $task->is_closed = 0; } $task->update(); // we have comments, so add them $comm = new TaskComment($w); $comm->obj_table = $task->getDbTableName(); $comm->obj_id = $task->id; $comm->comment = $comments; $comm->dt_created = Date("c"); $comm->is_deleted = 0; $comm->insert(); // add to context for notifications post listener $w->ctx("TaskComment", $comm); $w->ctx("TaskEvent", "task_details"); } // return $w->msg("Task: " . $task->title . " updated.", "/task/tasklist/?assignee=" . $w->request('assignee') . "&creator=" . $w->request('creator') . "&taskgroups=" . $w->request('taskgroups') . "&tasktypes=" . $w->request('tasktypes') . "&tpriority=" . $w->request('tpriority') . "&status=" . $w->request('tstatus') . "&dt_from=" . $w->request('dt_from') . "&dt_to=" . $w->request('dt_to')); } // return $w->msg("There was a problem.", "/task/tasklist/"); }
function endtimelog_ALL(Web &$w) { // get time log $log = $w->Task->getTimeLogEntry($_REQUEST['logid']); // get the task $task = $w->Task->getTask($_REQUEST["taskid"]); $tasktitle = $task->title; if ($log) { // set log end. used in comment $log->dt_end = date("Y-m-d G:i"); // set comment $comment = "Time Log Entry: " . $w->Task->getUserById($log->user_id) . " - " . formatDateTime($log->dt_start) . " to " . formatDateTime($log->dt_end); if ($_REQUEST['comments'] != "") { $comment .= " - Comments: " . htmlspecialchars($_REQUEST['comments']); } // add comment $comm = new TaskComment($w); $comm->obj_table = $task->getDbTableName(); $comm->obj_id = $_REQUEST["taskid"]; $comm->comment = $comment; $comm->insert(); // add to context for notifications post listener $w->ctx("TaskComment", $comm); $w->ctx("TaskEvent", "time_log"); // update time log entry $log->dt_end = date("Y-m-d G:i"); $log->comment_id = $comm->id; $log->update(); } // if 'Save Comment' display current entry and restart time log if ($_REQUEST['restart'] == "yes") { // create page $html = "<html><head><title>Task Time Log - " . $task->title . "</title>" . "<style type=\"text/css\">" . "body { background-color: #8ad228; }" . "td { background-color: #ffffff; color: #000000; font-family: verdana, arial; font-weight: bold; font-size: .8em; }" . "td.startend { background-color: #d2efab; color: #000000; font-family: verdana, arial; font-weight: bold; font-size: .9em; }" . "td.timelog { background-color: #75ba4d; color: #000000; font-family: verdana, arial; font-weight: bold; font-size: .9em; }" . "td.tasktitle { background-color: #9fea72; color: #000000; font-family: verdana, arial; font-weight: bold; font-size: .8em; }" . "a { text-decoration: none; } " . "a:hover { color: #ffffff; } " . "</style>" . "<script language=\"javascript\">" . "function reStart() {" . "\tlocation.href = \"/task/starttimelog/" . $_REQUEST["taskid"] . "\";" . "}" . "var c = setTimeout('reStart()',2000);" . "</script></head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>" . "<table cellpadding=2 cellspacing=2 border=0 width=100%>" . "<tr align=center><td colspan=2 class=timelog>Task Time Log</td></tr>" . "<tr align=center><td colspan=2 class=tasktitle><a title=\"View Task\" href=\"javascript: goTask();\">" . $tasktitle . "</a></td></tr>" . "<tr align=center><td width=50% class=startend>Start</td><td width=50% class=startend>Stop</td></tr>" . "<tr align=center><td>" . date("g:i a", $log->dt_start) . "</td><td>" . date("g:i a", strtotime($log->dt_end)) . "</td></tr>" . "<tr align=center><td colspan=2 class=timelog> </td></tr>" . "<tr><td colspan=2 class=startend>Comments</td></tr>" . "<tr><td colspan=2>" . str_replace("\n", "<br>", $_POST['comments']) . "</td></tr>" . "</table>" . "</body></html>"; } else { $html = "<html><head>" . "<script language=\"javascript\">" . "self.close();" . "</script></head></html>"; } // output page $w->setLayout(null); $w->out($html); }
function updatetask_POST(Web &$w) { $p = $w->pathMatch("id"); // task is to get updated so gather relevant data $task = $w->Task->getTask($p['id']); $taskdata = $w->Task->getTaskData($p['id']); // if task exists, first gather changes for display in comments if ($task) { // if no due date, make 1 month from now $dt_due = $w->request('dt_due'); if (empty($dt_due)) { $_POST['dt_due'] = $w->Task->getNextMonth(); } // convert dates to d/m/y for display. if assignee changes, get name of new assignee $comments = ""; foreach ($_POST as $name => $value) { if (startsWith($name, "dt_")) { list($d, $m, $y) = preg_split('/\\//', $value); $value = Date("U", strtotime($y . "-" . $m . "-" . $d)); } if ($name != "FLOW_SID" && $task->{$name} && $value != $task->{$name}) { if (startsWith($name, "dt_")) { $value = Date("d/m/Y", $value); } if ($name == "assignee_id") { $value = $w->Task->getUserById($value); } $comments .= $name . " updated to: " . $value . "\n"; } } // update the task $_POST['dt_assigned'] = Date('c'); $task->fill($_POST); // if task has a 'closed' status, set flag so task no longer appear in dashboard count or task list if ($task->getisTaskClosed()) { $task->is_closed = 1; $task->dt_completed = date("d/m/Y"); } else { $task->is_closed = 0; } $task->update(); // if we have comments, add them if (!empty($comments)) { $comm = new TaskComment($w); $comm->fill($_POST); $comm->obj_table = $task->getDbTableName(); $comm->obj_id = $task->id; $comm->comment = $comments; $comm->insert(); // add to context for notifications post listener $w->ctx("TaskComment", $comm); $w->ctx("TaskEvent", "task_details"); } } // if there is task data, update it also // if there is current no task data, but relevant input in the REQUEST object, create the task data if ($taskdata) { foreach ($taskdata as $td) { $arr = array("value" => $w->request($td->key)); $td->fill($arr); $td->update(); unset($arr); } } else { foreach ($_POST as $name => $value) { // This is broken plus what is this? // if (($name != "FLOW_SID") && ($name != "task_id") && ($name !== CSRF::getTokenID())) { // $tdata = new TaskData($w); // $arr = array("task_id"=>$task->id,"key"=>$name,"value"=>$value); // $tdata->fill($arr); // $tdata->insert(); // unset($arr); // } } } // return $w->msg("Task: " . $task->title . " updated.", "/task/edit/" . $task->id . "?tab=1"); }
/** * (non-PHPdoc) * @see DbObject::insert() */ function insert($force_validation = false) { try { $this->startTransaction(); // 1. Call on_before_insert of the TaskGroupType $tg = $this->getTaskGroup(); if (!empty($tg)) { // if no assignee selected for newly created task, use task group default assignee if (empty($this->assignee_id)) { $this->first_assignee_id = $this->assignee_id = $tg->default_assignee_id; } else { $this->first_assignee_id = $this->assignee_id; } $tg_type = $tg->getTaskGroupTypeObject(); // check for and set default status if (empty($this->status)) { $this->status = $tg_type->getDefaultStatus(); } $tg_type->on_before_insert($this); } // 2. Call on_before_update of the Tasktype if ($this->task_type) { $this->getTaskTypeObject()->on_before_insert($this); } // 3. insert task into database $validation_response = parent::insert($force_validation); if ($validation_response !== true) { $this->rollbackTransaction(); $this->w->errorMessage($this, "Task", $validation_response, false, "/tasks/edit"); } // run any post-insert routines // add a comment upon task creation $comm = new TaskComment($this->w); $comm->obj_table = $this->getDbTableName(); $comm->obj_id = $this->id; $comm->comment = "Task Created"; $comm->insert(); // add to context for notifications post listener $this->w->ctx("TaskComment", $comm); $this->w->ctx("TaskEvent", "task_creation"); // 4. Call on_after_insert of TaskType if ($this->task_type) { $this->getTaskTypeObject()->on_after_insert($this); } // 5. Call on_after_update of the TaskGroupType if (!empty($tg_type)) { $tg_type->on_after_insert($this); } $this->commitTransaction(); } catch (Exception $ex) { $this->Log->error("Inserting Task: " . $ex->getMessage()); $this->rollbackTransaction(); } }