Esempio n. 1
0
 public static function initListeners()
 {
     if (\GO::modules()->isInstalled('calendar')) {
         \GO\Calendar\Model\Event::model()->addListener("delete", "GO\\Caldav\\CaldavModule", "deleteEvent");
     }
     if (\GO::modules()->isInstalled('tasks')) {
         \GO\Tasks\Model\Task::model()->addListener("delete", "GO\\Caldav\\CaldavModule", "deleteTask");
     }
 }
Esempio n. 2
0
 /**
  * Initialize the listeners for the ActiveRecords
  */
 public static function initListeners()
 {
     // Define the ActiveRecord \GO\Files\Model\File
     \GO\Files\Model\File::model()->addListener('save', 'GO\\Workflow\\WorkflowModule', 'save');
     \GO\Files\Model\File::model()->addListener('delete', 'GO\\Workflow\\WorkflowModule', 'delete');
     // Define the ActiveRecord \GO\Tasks\Model\Task
     \GO\Tasks\Model\Task::model()->addListener('save', 'GO\\Workflow\\WorkflowModule', 'save');
     \GO\Tasks\Model\Task::model()->addListener('delete', 'GO\\Workflow\\WorkflowModule', 'delete');
     // Add trigger for folder in the files module
     $c = new \GO\Files\Controller\FolderController();
     $c->addListener('submit', 'GO\\Workflow\\WorkflowModule', 'checkFolderTrigger');
     $c->addListener('load', 'GO\\Workflow\\WorkflowModule', 'loadFolderTrigger');
 }
Esempio n. 3
0
 /**
  * Get the data for the grid that shows all the tasks from the selected tasklists.
  * 
  * @param Array $params
  * @return Array The array with the data for the grid. 
  */
 protected function actionPortletGrid($params)
 {
     $now = \GO\Base\Util\Date::date_add(mktime(0, 0, 0), 1);
     if (isset($params['completed_task_id'])) {
         $updateTask = \GO\Tasks\Model\Task::model()->findByPk($params['completed_task_id']);
         if (isset($params['checked'])) {
             $updateTask->setCompleted($params['checked'] == "true");
         }
     }
     // Find out the sort for the grid
     $sort = !empty($params['sort']) ? $params['sort'] : 'due_time';
     $dir = !empty($params['dir']) ? $params['dir'] : 'ASC';
     $store = \GO\Base\Data\Store::newInstance(\GO\Tasks\Model\Task::model());
     $findCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('start_time', $now, '<')->addCondition('status', \GO\Tasks\Model\Task::STATUS_COMPLETED, '<>', 't');
     $joinCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('user_id', \GO::user()->id, '=', 'pt')->addCondition('tasklist_id', 'pt.tasklist_id', '=', 't', true, true);
     $tasklistJoinCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition('tasklist_id', 'tl.id', '=', 't', true, true);
     $findParams = $store->getDefaultParams($params)->select('t.*, tl.name AS tasklist_name')->criteria($findCriteria)->order(array('tasklist_name', $sort), $dir)->ignoreAcl()->join(\GO\Tasks\Model\PortletTasklist::model()->tableName(), $joinCriteria, 'pt')->join(\GO\Tasks\Model\Tasklist::model()->tableName(), $tasklistJoinCriteria, 'tl');
     $stmt = \GO\Tasks\Model\Task::model()->find($findParams);
     $store->setStatement($stmt);
     $store->getColumnModel()->formatColumn('tasklist_name', '$model->tasklist_name');
     $store->getColumnModel()->formatColumn('late', '$model->isLate();');
     $store->getColumnModel()->formatColumn('is_active', '$model->isActive()');
     return $store->getData();
 }
Esempio n. 4
0
 public function actionDay($date, $calendars)
 {
     $calendarIds = json_decode($calendars);
     $date = \GO\Base\Util\Date::clear_time($date);
     $start = $date - 1;
     $end = $date + 24 * 3600;
     $report = new \GO\Calendar\Reports\Day();
     foreach ($calendarIds as $id) {
         $calendar = \GO\Calendar\Model\Calendar::model()->findByPk($id);
         $events = $calendar->getEventsForPeriod($start, $end);
         if (!empty($calendar->tasklist)) {
             $tasklistId = $calendar->tasklist->id;
             $report->tasks = \GO\Tasks\Model\Task::model()->findByDate($date, $tasklistId)->fetchAll();
         }
         $report->setEvents($events);
         $report->render($date);
         $report->calendarName = $calendar->name;
     }
     $report->Output('day.pdf');
 }
Esempio n. 5
0
 /**
  * Find all tasks that you are going to work on today
  * @param $date unix timestamp
  * @param $tasklist_id the task list to search in
  * @return ActiveStatement
  */
 public static function findByDate($date, $tasklist_id = null)
 {
     $date = \GO\Base\Util\Date::clear_time($date);
     $criteria = \GO\Base\Db\FindCriteria::newInstance();
     if (!empty($tasklist_id)) {
         $criteria->addCondition('tasklist_id', $tasklist_id);
     }
     $criteria1 = \GO\Base\Db\FindCriteria::newInstance()->addCondition('start_time', $date + 24 * 3600, '<')->addCondition('start_time', $date, '>=');
     $criteria2 = \GO\Base\Db\FindCriteria::newInstance()->addCondition('due_time', $date + 24 * 3600, '<')->addCondition('due_time', $date, '>=');
     $tasks = \GO\Tasks\Model\Task::model()->find(\GO\Base\Db\FindParams::newInstance()->criteria($criteria->mergeWith($criteria1->mergeWith($criteria2, false), true)));
     return $tasks;
 }
Esempio n. 6
0
 private function _processTasksDisplay($model, $response)
 {
     //$startOfDay = \GO\Base\Util\Date::clear_time(time());
     $findParams = \GO\Base\Db\FindParams::newInstance()->order('due_time', 'DESC');
     //$findParams->getCriteria()->addCondition('start_time', $startOfDay, '<=')->addCondition('status', \GO\Tasks\Model\Task::STATUS_COMPLETED, '!=');
     $stmt = \GO\Tasks\Model\Task::model()->findLinks($model, $findParams);
     $store = \GO\Base\Data\Store::newInstance(\GO\Tasks\Model\Task::model());
     $store->setStatement($stmt);
     $store->getColumnModel()->setFormatRecordFunction(array($this, 'formatTaskLinkRecord'))->formatColumn('late', '$model->due_time<time() ? 1 : 0;')->formatColumn('tasklist_name', '$model->tasklist->name')->formatColumn('link_count', '$model->countLinks()')->formatColumn('link_description', '$model->link_description');
     $data = $store->getData();
     $response['data']['tasks'] = $data['results'];
     return $response;
 }
Esempio n. 7
0
 /**
  * Move the selected tasks to an other addressbook.
  * 
  * @param array $params
  * @return string $response
  */
 protected function actionMove($params)
 {
     $response = array();
     if (!empty($params['items']) && !empty($params['tasklist_id'])) {
         $items = json_decode($params['items']);
         $num_updated = 0;
         $success = true;
         foreach ($items as $taskId) {
             $task = \GO\Tasks\Model\Task::model()->findByPk($taskId);
             $task->tasklist_id = $params['tasklist_id'];
             $success = $success && $task->save();
             $num_updated++;
         }
         if ($num_updated > 0) {
             $response['reload_store'] = true;
         }
         $response['success'] = $success;
     }
     return $response;
 }
Esempio n. 8
0
 /**
  * Fill the response array with the tasks thas are in the visible tasklists 
  * for this calendar between the start and end time
  * 
  * @param array $response
  * @param \GO\Calendar\Model\Calendar $calendar
  * @param string $startTime
  * @param string $endTime
  * @return array 
  */
 private function _getTaskResponseForPeriod($response, $calendar, $startTime, $endTime)
 {
     $resultCount = 0;
     $dayString = \GO::t('full_days');
     $tasklists = $calendar->visible_tasklists;
     $this->_tasklists = array();
     while ($tasklist = $tasklists->fetch()) {
         $lists[$tasklist->id] = $tasklist->name;
     }
     if (!empty($lists)) {
         // If the calendar_tasklist_show is set to 1 task will display only on the due date in the calendar
         switch (\GO::config()->calendar_tasklist_show) {
             case 2:
                 //start date only
                 $dueQ = 'due_time';
                 $startQ = 'due_time';
                 break;
             case 1:
                 // due date only
                 $dueQ = 'start_time';
                 $startQ = 'start_time';
                 break;
             default:
                 // entirely
                 $dueQ = 'due_time';
                 $startQ = 'start_time';
         }
         $taskFindCriteria = \GO\Base\Db\FindCriteria::newInstance()->addCondition($dueQ, strtotime($startTime), '>=')->addCondition($startQ, strtotime($endTime), '<=');
         // Remove tasks that are completed
         if (!$calendar->show_completed_tasks) {
             $taskFindCriteria->addCondition('percentage_complete', 100, '<');
         }
         $taskFindCriteria->addInCondition('tasklist_id', array_keys($lists));
         $taskFindParams = \GO\Base\Db\FindParams::newInstance()->criteria($taskFindCriteria);
         $tasks = \GO\Tasks\Model\Task::model()->find($taskFindParams);
         while ($task = $tasks->fetch()) {
             // If the start_time is empty, then get the due_time as start time.
             // This displays the task only on the due_date
             if (empty($task->start_time)) {
                 $startTime = date('Y-m-d', $task->due_time) . ' 00:00';
             } else {
                 $startTime = date('Y-m-d', $task->start_time) . ' 00:00';
             }
             $endTime = date('Y-m-d', $task->due_time) . ' 23:59';
             if (\GO::config()->calendar_tasklist_show == 1) {
                 $startTime = $endTime;
             } elseif (\GO::config()->calendar_tasklist_show == 2) {
                 $endTime = $startTime;
             }
             $resultCount++;
             $taskname = $task->name . ' (' . $task->percentage_complete . '%)';
             $response['results'][$this->_getIndex($response['results'], $task->due_time) . 'task' . $task->id] = array('id' => $response['count']++, 'link_count' => $task->countLinks(), 'name' => $taskname, 'description' => $lists[$task->tasklist_id], 'time' => '00:00', 'start_time' => $startTime, 'end_time' => $endTime, 'all_day_event' => 1, 'model_name' => 'GO\\Tasks\\Model\\Task', 'background' => 'EBF1E2', 'day' => $dayString[date('w', $task->due_time)] . ' ' . \GO\Base\Util\Date::get_timestamp($task->due_time, false), 'read_only' => true, 'task_id' => $task->id);
         }
     }
     // Set the count of the tasks
     $response['count_tasks_only'] = $resultCount;
     return $response;
 }
 /**
  * Render the task row in the PDF
  * 
  * @param \GO\Tasks\Model\Task $task
  */
 private function _renderTaskRow($task)
 {
     $html = '';
     $html .= '<tcpdf method="renderLine" />';
     $html .= '<b><font style="font-size:' . $this->_nameFontSize . 'px">' . \GO\Base\Util\String::text_to_html($task->getAttribute('name', 'html'), true) . '</font></b>';
     if (!empty($task->description)) {
         $html .= '<br /><font style="font-size:' . $this->_descriptionFontSize . 'px">' . $task->getAttribute('description', 'html') . '</font>';
     }
     $this->writeHTML($html, true, false, false, false, 'L');
 }