/**
  * Renders owner box
  * @param string $form
  * @return string
  */
 protected function renderStatusContent($form)
 {
     $content = '<div id="status-box">';
     $element = new TaskStatusDropDownElement($this->getModel(), 'status', $form);
     $content .= $element->render();
     $content .= '<span id="completionDate">';
     if ($this->model->status == Task::STATUS_COMPLETED) {
         $content .= TasksUtil::renderCompletionDateTime($this->model);
     }
     $content .= '</span>';
     $content .= '</div>';
     return $content;
 }
Пример #2
0
 /**
  * @covers renderCompletionDateTime
  */
 public function testRenderCompletionDateTime()
 {
     $tasks = Task::getByName('MyTest');
     $task = $tasks[0];
     $content = TasksUtil::renderCompletionDateTime($task);
     $this->assertContains('Completed On:', $content);
 }
 /**
  * Process status update via ajax
  * @param int $id
  * @param int $status
  * @param bool $showCompletionDate whether to show completion date
  */
 protected function processStatusUpdateViaAjax(Task $task, $status, $showCompletionDate = true)
 {
     $currentStatus = $task->status;
     $task->status = intval($status);
     //check for owner in case a user start the task
     if ($currentStatus == Task::STATUS_NEW && $currentStatus != $task->status) {
         $task->owner = Yii::app()->user->userModel;
     }
     if (intval($status) == Task::STATUS_COMPLETED) {
         foreach ($task->checkListItems as $checkItem) {
             $checkItem->completed = true;
             $checkItem->unrestrictedSave();
         }
         $task->status = Task::STATUS_COMPLETED;
         $task->completedDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
         $task->completed = true;
         $task->save();
         if ($showCompletionDate) {
             echo TasksUtil::renderCompletionDateTime($task);
         }
     } else {
         $task->completedDateTime = null;
         $task->completed = false;
         $task->save();
     }
     if ($task->project->id > 0) {
         ProjectsUtil::logTaskStatusChangeEvent($task, Task::getStatusDisplayName(intval($currentStatus)), Task::getStatusDisplayName(intval($status)));
     }
 }