Beispiel #1
0
 public function getData($id = false)
 {
     $rez = array('success' => true);
     if (empty(parent::getData($id))) {
         return $rez;
     }
     $params = array('pid' => $this->id, 'fq' => array('(template_type:task) OR (target_type:task)'), 'fl' => 'id,pid,name,template_id,date,date_end,cid,cdate,status', 'sort' => 'cdate', 'dir' => 'desc');
     $s = new \CB\Search();
     $sr = $s->query($params);
     foreach ($sr['data'] as $d) {
         $d['ago_text'] = @Util\formatDateTimePeriod($d['date'], null, @$_SESSION['user']['cfg']['timezone']);
         $d['user'] = User::getDisplayName($d['cid'], true);
         \CB\Tasks::setTaskActionFlags($d);
         $rez['data'][] = $d;
     }
     return $rez;
 }
Beispiel #2
0
 /**
  * generate html preview for a task
  * @param  int   $id task id
  * @return array
  */
 public function getPreviewBlocks()
 {
     $pb = parent::getPreviewBlocks();
     $data = $this->getData();
     $sd =& $data['sys_data'];
     $template = $this->getTemplate();
     $actionsLine = 'Actions<hr />';
     $dateLines = '';
     $ownerRow = '';
     $assigneeRow = '';
     $contentRow = '';
     //create actions line
     $flags = $this->getActionFlags();
     $actions = array();
     if (!empty($flags['complete'])) {
         $actions[] = '<a action="complete" class="task-action ib-done">' . L\get('Complete') . '</a>';
     }
     if (!empty($flags['close'])) {
         $actions[] = '<a action="close" class="task-action ib-done-all">' . L\get('Close') . '</a>';
     }
     if (!empty($flags['reopen'])) {
         $actions[] = '<a action="reopen" class="task-action ib-repeat">' . L\get('Reopen') . '</a>';
     }
     $actionsLine = '<div class="task-actions">' . implode(' ', $actions) . '</div>';
     //create date and status row
     $ed = $this->getEndDate();
     $status = $this->getStatus();
     if (!empty($ed)) {
         $endDate = Util\formatTaskTime($ed, !$sd['task_allday']);
         // $endDate = empty($sd['task_allday'])
         //     ? Util\formatDateTimePeriod($ed, null, @$_SESSION['user']['cfg']['timezone'])
         //     : Util\formatDatePeriod($ed, null, @$_SESSION['user']['cfg']['timezone']);
         $dateLines = '<tr><td class="prop-key">' . L\get('Due') . ':</td><td>' . $endDate . '</td></tr>';
         // $dateLine .= '<div class="date">' . $endDate . '</div>';
     }
     if (!empty($sd['task_d_closed'])) {
         $dateLines .= '<tr><td class="prop-key">' . L\get('Completed') . ':</td><td>' . Util\formatAgoTime($sd['task_d_closed']) . '</td></tr>';
     }
     //create owner row
     $v = $this->getOwner();
     if (!empty($v)) {
         $cn = User::getDisplayName($v);
         $cdt = Util\formatAgoTime($data['cdate']);
         $cd = Util\formatDateTimePeriod($data['cdate'], null, @$_SESSION['user']['cfg']['timezone']);
         $ownerRow = '<tr><td class="prop-key">' . L\get('Owner') . ':</td><td>' . '<table class="prop-val people"><tbody>' . '<tr><td class="user"><img class="photo32" src="photo/' . $v . '.jpg?32=' . User::getPhotoParam($v) . '" style="width:32px; height: 32px" alt="' . $cn . '" title="' . $cn . '"></td>' . '<td><b>' . $cn . '</b><p class="gr">' . L\get('Created') . ': ' . '<span class="dttm" title="' . $cd . '">' . $cdt . '</span></p></td></tr></tbody></table>' . '</td></tr>';
     }
     //create assignee row
     $v = $this->getFieldValue('assigned', 0);
     if (!empty($v['value'])) {
         $isOwner = $this->isOwner();
         $assigneeRow .= '<tr><td class="prop-key">' . L\get('TaskAssigned') . ':</td><td><table class="prop-val people"><tbody>';
         $v = Util\toNumericArray($v['value']);
         $dateFormat = \CB\getOption('long_date_format') . ' H:i:s';
         foreach ($v as $id) {
             $un = User::getDisplayName($id);
             $completed = $this->getUserStatus($id) == static::$USERSTATUS_DONE;
             $flags = $this->getActionFlags($id);
             $cdt = '';
             //completed date title
             $dateText = '';
             if ($completed && !empty($sd['task_u_d_closed'][$id])) {
                 $cdt = Util\formatMysqlDate($sd['task_u_d_closed'][$id], $dateFormat);
                 $dateText = ': ' . Util\formatAgoTime($sd['task_u_d_closed'][$id]);
             }
             $assigneeRow .= '<tr><td class="user"><div style="position: relative">' . '<img class="photo32" src="photo/' . $id . '.jpg?32=' . User::getPhotoParam($id) . '" style="width:32px; height: 32px" alt="' . $un . '" title="' . $un . '">' . ($completed ? '<img class="done icon icon-tick-circle" src="/css/i/s.gif" />' : "") . '</div></td><td><b>' . $un . '</b>' . '<p class="gr" title="' . $cdt . '">' . ($completed ? L\get('Completed') . $dateText . ($isOwner ? ' <a class="bt task-action click" action="markincomplete" uid="' . $id . '">' . L\get('revoke') . '</a>' : '') : L\get('waitingForAction') . ($isOwner ? ' <a class="bt task-action click" action="markcomplete" uid="' . $id . '">' . L\get('complete') . '</a>' : '')) . '</p></td></tr>';
         }
         $assigneeRow .= '</tbody></table></td></tr>';
     }
     //create description row
     $v = $this->getFieldValue('description', 0);
     if (!empty($v['value'])) {
         $tf = $template->getField('description');
         $v = $template->formatValueForDisplay($tf, $v);
         $contentRow = '<tr><td class="prop-val" colspan="2">' . $v . '</td></tr>';
     }
     //insert rows
     $p = $pb[0];
     $pos = strrpos($p, '<tbody>');
     $p = substr($p, $pos + 7);
     $pos = strrpos($p, '</tbody>');
     if ($pos !== false) {
         $p = substr($p, 0, $pos);
     }
     $pb[0] = $actionsLine . '<table class="obj-preview"><tbody>' . $dateLines . $p . $ownerRow . $assigneeRow . $contentRow . '<tbody></table>';
     return $pb;
 }