public static function getEventsListByDate($timestamp, $users_id = null, $sf_user) { $html = ''; foreach (Events::getEventsListByDateQuery($timestamp, $users_id) as $events) { $edit_action = ''; if ($sf_user->hasCredential('public_scheduler_access_full_access') and $users_id == null or $sf_user->hasCredential('allow_manage_personal_scheduler') and $users_id > 0) { $edit_action = 'onClick="openModalBox(\'' . url_for('scheduler/edit?id=' . $events->getEventId() . '&users_id=' . $users_id) . '\')"'; } if ($users_id == null and $events->getPublicStatus() == 1) { $edit_action = ''; } $event_name = '<a class="jt" href="#" onClick="return false" title="<b>' . __('Start Date') . ':</b> ' . app::dateTimeFormat($events->getStartDate()) . ' - <b>' . __('End Date') . ':</b> ' . app::dateTimeFormat($events->getEndDate()) . '" rel="' . url_for('scheduler/info?id=' . $events->getEventId()) . '">' . $events->getEventName() . '</a>'; $time = date('H:i', app::getDateTimestamp($events->getStartDate())); if ($time != '00:00') { $event_name = $time . ' ' . $event_name; } $html .= '<div class="eventItem" ' . $edit_action . '>' . $event_name . '</div>'; } return $html; }
echo '<span>' . __('Status') . ':</span> ' . app::getNameByTableId('TasksStatus', $c['tasks_status_id']); ?> </li> <?php } if ($c['tasks_priority_id'] > 0) { ?> <li><?php echo '<span>' . __('Priority') . ':</span> ' . app::getNameByTableId('TasksPriority', $c['tasks_priority_id']); ?> </li> <?php } if (strlen($c['due_date']) > 0) { ?> <li><?php echo '<span>' . __('Due Date') . ':</span> ' . app::dateTimeFormat($c['due_date']); ?> </li> <?php } if ($c['worked_hours'] > 0) { ?> <li><?php echo '<span>' . __('Work Hours') . ':</span> ' . $c['worked_hours']; ?> </li> <?php } ?> </ul>
<?php if (in_array('Progress', $in_listing)) { ?> <td><?php echo (int) $tasks['progress']; ?> %</td> <?php } ?> <?php if (in_array('CreatedAt', $in_listing)) { ?> <td><?php echo app::dateTimeFormat($tasks['created_at'], 0, true); ?> </td> <?php } ?> <?php $v = ExtraFieldsList::getValuesList($extra_fields, $tasks['id']); echo ExtraFieldsList::renderListingTbody($extra_fields, $v, array('est_time' => $tasks['estimated_time'])); $totals = ExtraFieldsList::getListingTotals($totals, $extra_fields, $v, array('est_time' => $tasks['estimated_time'])); ?> <?php if (!$sf_request->hasParameter('projects_id')) { ?>
public static function renderFieldValueByType($f, $values, $extra_values = array(), $is_export = false) { $value = isset($values[$f['id']]) ? $values[$f['id']] : ''; switch ($f['type']) { case 'file': $html = ''; if ($a = Doctrine_Core::getTable('Attachments')->find($value)) { if ($is_export) { return app::public_url('attachments/download?id=' . $a->getId()); } else { $html = Attachments::getLink($a); } } return $html; break; case 'date_dropdown': return strlen($value) > 2 ? app::dateFormat($value, 0, $is_export ? false : true) : ''; break; case 'date': return app::dateFormat($value, 0, $is_export ? false : true); break; case 'date_time': return app::dateTimeFormat($value, 0, $is_export ? false : true); break; case 'date_range': if (strlen($value) > 1) { $value = explode('|', $value); return app::dateFormat($value[0], 0, $is_export ? false : true) . ' - ' . app::dateFormat($value[1], 0, $is_export ? false : true); } else { return ''; } break; case 'formula': $formula = $f['default_values']; foreach ($values as $k => $v) { $formula = str_replace('[' . $k . ']', (double) $v, $formula); } foreach ($extra_values as $k => $v) { $formula = str_replace('[' . $k . ']', (double) $v, $formula); } if (!strstr($formula, '[')) { if (strstr($formula, '{')) { $eval_str = 'function getFormulaValue()' . $formula . '; $fv=getFormulaValue();'; } else { $eval_str = '$fv=' . $formula . ';'; } @($r = eval($eval_str)); if ($r !== null) { $fv = $formula; } return $fv; } else { return ''; } break; case 'checkbox': return str_replace("\n", '<br>', $value); break; case 'url': if (strlen($value) > 0) { if (!strstr($value, '://')) { $value = 'http://' . $value; } if ($is_export) { return $value; } else { return '<a href="' . $value . '" target="blank">' . t::__('view') . '</a>'; } } else { return ''; } break; case 'textarea': return nl2br($value); break; default: return $value; break; } }
<tr> <td style="vertical-align: top; font-family: Arial; font-size: 13px; color: black; padding: 2px; border-bottom:1px dashed LightGray"> <?php echo replaceTextToLinks($c->getDescription()); ?> <div><?php include_component('attachments', 'attachmentsList', array('bind_type' => 'discussionsComments', 'bind_id' => $c->getId())); ?> </div> <div><?php include_component('discussionsComments', 'info', array('c' => $c)); ?> </div> </td> <td style="width:25%; vertical-align: top; font-family: Arial; font-size: 13px; color: black; padding: 2px; border-bottom:1px dashed LightGray"><?php echo app::dateTimeFormat($c->getCreatedAt()) . '<br>' . $c->getUsers()->getName() . '<br>' . renderUserPhoto($c->getUsers()->getPhoto()); ?> </td> </tr> <?php } ?> </table> </td> <td width="30%" valign="top"> <?php echo app::setCssForEmailContent('<div>' . get_component('discussions', 'details', array('discussions' => $discussions, 'is_email' => true)) . '</div>'); ?> </td> </tr>
echo ' ' . app::getLastCommentByTable('TicketsComments', 'tickets_id', $tickets['id']); } ?> </td> <td><?php echo app::getArrayName($tickets, 'Departments'); ?> </td> <td><?php echo $tickets['Users']['name']; ?> </td> <td><?php echo app::dateTimeFormat($tickets['created_at'], 0, true); ?> </td> <?php $v = ExtraFieldsList::getValuesList($extra_fields, $tickets['id']); echo ExtraFieldsList::renderListingTbody($extra_fields, $v); $totals = ExtraFieldsList::getListingTotals($totals, $extra_fields, $v); ?> <?php if (!$sf_request->hasParameter('projects_id')) { ?> <td><?php if ($tickets['projects_id'] > 0) { echo link_to(app::getArrayName($tickets, 'Projects'), 'projectsComments/index?projects_id=' . $tickets['projects_id']);
</td> <td style="white-space:normal"> <?php echo replaceTextToLinks($c['description']); ?> <div><?php include_component('attachments', 'attachmentsList', array('bind_type' => 'ticketsComments', 'bind_id' => $c['id'])); ?> </div> <div><?php include_component('ticketsComments', 'info', array('c' => $c)); ?> </div> </td> <td><?php echo app::dateTimeFormat($c['created_at']) . '<br>' . $c['Users']['name'] . '<br>' . renderUserPhoto($c['Users']['photo']); ?> </td> </tr> <?php } ?> <?php if (count($tickets_comments) == 0) { echo '<tr><td colspan="3">' . __('No Records Found') . '</td></tr>'; } ?> </tbody> </table> <?php if ($comments_access['insert']) {
?> <?php if ($tasks->getProgress() > 0) { echo '<tr><th>' . __('Progress') . ':</th><td>' . $tasks->getProgress() . '%</td></tr>'; } ?> <tr><td style="padding-top: 7px;"></td></tr> <tr> <th><?php echo __('Created At'); ?> :</th> <td><?php echo app::dateTimeFormat($tasks->getCreatedAt()); ?> </td> </tr> </table> <br> <h2><?php echo __('Assigned To'); ?> </h2> <table class="contentTable" style="margin-bottom: 7px;"> <?php foreach (explode(',', $tasks->getAssignedTo()) as $users_id) { if ($user = Doctrine_Core::getTable('Users')->find($users_id)) { echo '<tr><th><div style="float:left;">' . renderUserPhoto($user->getPhoto()) . '</div> ' . $user->getName() . '<br>' . '</td></tr>'; }
public function executeExport(sfWebRequest $request) { /*check access*/ if ($request->hasParameter('projects_id')) { $this->forward404Unless($this->projects = Doctrine_Core::getTable('Projects')->createQuery()->addWhere('id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object projects does not exist (%s).', $request->getParameter('projects_id'))); $this->checkProjectsAccess($this->projects); $this->checkTicketsAccess('view', false, $this->projects); } else { $this->checkTicketsAccess('view'); } $this->columns = array('Projects' => t::__('Project Name'), 'id' => t::__('Id'), 'TicketsStatus' => t::__('Status'), 'TicketsTypes' => t::__('Type'), 'name' => t::__('Name'), 'description' => t::__('Description'), 'Departments' => t::__('Department'), 'Users' => t::__('Created By'), 'created_at' => t::__('Created At')); $extra_fields = ExtraFieldsList::getFieldsByType('tickets', $this->getUser(), false, array('all' => true)); foreach ($extra_fields as $v) { $this->columns['extra_field_' . $v['id']] = $v['name']; } if (!$request->hasParameter('projects_id')) { $this->columns['Projects'] = t::__('Project'); } $this->columns['Projects'] = t::__('Project Name'); $this->columns['url'] = t::__('Url'); if ($fields = $request->getParameter('fields')) { $separator = "\t"; $format = $request->getParameter('format', '.csv'); $filename = $request->getParameter('filename', 'tasks'); header("Content-type: Application/octet-stream"); header("Content-disposition: attachment; filename=" . $filename . "." . $format); header("Pragma: no-cache"); header("Expires: 0"); $content = ''; foreach ($fields as $f) { $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $this->columns[$f]) . $separator; } $content .= "\n"; if ($format == 'csv') { echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8'); } else { echo $content; } if (strlen($request->getParameter('selected_items') == 0)) { exit; } $q = Doctrine_Core::getTable('Tickets')->createQuery('t')->leftJoin('t.TicketsStatus ts')->leftJoin('t.TicketsTypes tt')->leftJoin('t.Departments td')->leftJoin('t.Projects p')->leftJoin('t.Users')->whereIn('t.id', explode(',', $request->getParameter('selected_items'))); if ($request->hasParameter('projects_id')) { $q->addWhere('projects_id=?', $request->getParameter('projects_id')); if (Users::hasAccess('view_own', 'tickets', $this->getUser(), $request->getParameter('projects_id'))) { $q->addWhere("t.departments_id in (" . implode(',', Departments::getDepartmentIdByUserId($this->getUser()->getAttribute('id'))) . ") or t.users_id='" . $this->getUser()->getAttribute('id') . "'"); } } else { if (Users::hasAccess('view_own', 'projects', $this->getUser())) { $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',team) or p.users_id='" . $this->getUser()->getAttribute('id') . "'"); } if (Users::hasAccess('view_own', 'tickets', $this->getUser())) { $q->addWhere("t.departments_id in (" . implode(',', Departments::getDepartmentIdByUserId($this->getUser()->getAttribute('id'))) . ") or t.users_id='" . $this->getUser()->getAttribute('id') . "'"); } } if ($request->hasParameter('projects_id')) { $q = app::addListingOrder($q, 'tickets', $this->getUser(), (int) $request->getParameter('projects_id')); } else { $q->orderBy('LTRIM(p.name), ts.sort_order, LTRIM(ts.name), LTRIM(t.name)'); } $tickets = $q->fetchArray(); $totals = array(); $projects_totals = array(); $current_project_id = 0; foreach ($tickets as $t) { $ex_values = ExtraFieldsList::getValuesList($extra_fields, $t['id']); $content = ''; // if ($current_project_id == 0) { $current_project_id = $t['projects_id']; } if ($current_project_id != $t['projects_id']) { //adding totals if (isset($projects_totals[$current_project_id])) { foreach ($fields as $f) { $v = ''; if (strstr($f, 'extra_field_')) { if (isset($projects_totals[$current_project_id][str_replace('extra_field_', '', $f)])) { $v = $projects_totals[$current_project_id][str_replace('extra_field_', '', $f)]; } } $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator; } $content .= "\n\n"; } $current_project_id = $t['projects_id']; } foreach ($fields as $f) { $v = ''; if (in_array($f, array('id', 'name', 'description'))) { $v = $t[$f]; } elseif (strstr($f, 'extra_field_')) { if ($ex = Doctrine_Core::getTable('ExtraFields')->find(str_replace('extra_field_', '', $f))) { $v = ExtraFieldsList::renderFieldValueByType($ex, $ex_values, array(), true); if (in_array($ex->getType(), array('number', 'formula'))) { if (!isset($totals[$ex->getId()])) { $totals[$ex->getId()] = 0; } if (!isset($projects_totals[$t['projects_id']][$ex->getId()])) { $projects_totals[$t['projects_id']][$ex->getId()] = 0; } $totals[$ex->getId()] += $v; $projects_totals[$t['projects_id']][$ex->getId()] += $v; } $v = str_replace('<br>', ', ', $v); } } elseif ($f == 'created_at') { if (strlen($t[$f]) > 0) { $v = app::dateTimeFormat($t[$f]); } } elseif ($f == 'url') { $v = app::public_url('ticketsComments/index?projects_id=' . $t['projects_id'] . '&tickets_id=' . $t['id']); } else { $v = app::getArrayName($t, $f); } $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator; } $content .= "\n"; if ($format == 'csv') { echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8'); } else { echo $content; } } $content = ''; //adding totals if (isset($projects_totals[$current_project_id]) and !$request->hasParameter('projects_id')) { foreach ($fields as $f) { $v = ''; if (strstr($f, 'extra_field_')) { if (isset($projects_totals[$current_project_id][str_replace('extra_field_', '', $f)])) { $v = $projects_totals[$current_project_id][str_replace('extra_field_', '', $f)]; } } $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator; } $content .= "\n\n"; } foreach ($fields as $f) { $v = ''; if (strstr($f, 'extra_field_')) { if (isset($totals[str_replace('extra_field_', '', $f)])) { $v = $totals[str_replace('extra_field_', '', $f)]; } } $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator; } $content .= "\n"; if ($format == 'csv') { echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8'); } else { echo $content; } exit; } }
} ?> <?php echo ExtraFieldsList::renderInfoFileds('tickets', $tickets, $sf_user); ?> <tr><td style="padding-top: 7px;"></td></tr> <tr> <th><?php echo __('Created At'); ?> :</th> <td><?php echo app::dateTimeFormat($tickets->getCreatedAt()); ?> </td> </tr> </table> <br> <h2><?php echo __('Department'); ?> : <?php echo $tickets->getDepartments()->getName(); ?> </h2> <table class="contentTable" style="margin-bottom: 7px;"> <?php if ($tickets->getDepartments_id() > 0) {
</thead> <tbody> <?php foreach ($backups as $file) { ?> <tr> <td><?php echo $file; ?> </td> <td><?php echo number_format(filesize(sfConfig::get('sf_web_dir') . '/backups/' . $file)) . ' ' . __('bytes'); ?> </td> <td><?php echo app::dateTimeFormat('', filemtime(sfConfig::get('sf_web_dir') . '/backups/' . $file)); ?> </td> <td><?php echo button_to(__('Restore'), 'tools/doRestore?restore_file=' . $file, array('confirm' => __('Are you sure?'), 'class' => 'btn')); ?> </td> <td><?php echo button_to(__('Download'), 'tools/backup?download_file=' . $file, array('class' => 'btn')); ?> </td> <td><?php echo button_to(__('Delete'), 'tools/backup?delete_file=' . $file, array('confirm' => __('Are you sure?'), 'class' => 'btn')); ?> </td>
if ($is_filter['type']) { ?> <td><?php echo app::getArrayName($projects, 'ProjectsTypes'); ?> </td> <?php } ?> <td><?php echo app::getArrayName($projects, 'Users'); ?> </td> <td><?php echo app::dateTimeFormat($projects['created_at'], 0, true); ?> </td> <?php $v = ExtraFieldsList::getValuesList($extra_fields, $projects['id']); echo ExtraFieldsList::renderListingTbody($extra_fields, $v); $totals = ExtraFieldsList::getListingTotals($totals, $extra_fields, $v); ?> </tr> <?php } ?> </tbody> <?php
</td> <td><?php echo link_to($comments->getTasks()->getName(), 'tasksComments/index?tasks_id=' . $comments->getTasks()->getId() . '&projects_id=' . $comments->getTasks()->getProjects()->getId(), array('class' => 'jt', 'rel' => url_for('tasks/info?projects_id=' . $comments->getTasks()->getProjects()->getId() . '&id=' . $comments->getTasks()->getId()), 'title' => __('Task Info'), 'target' => 'new')); ?> </td> <td><?php echo $comments->getTasks()->getTasksStatus() ? $comments->getTasks()->getTasksStatus()->getName() : ''; ?> </td> <td><?php echo link_to($comments->getTasks()->getProjects()->getName(), 'projectsComments/index?projects_id=' . $comments->getTasks()->getProjects()->getId(), array('class' => 'jt', 'rel' => url_for('projects/info?id=' . $comments->getTasks()->getProjects()->getId()), 'title' => __('Project Info'), 'target' => 'new')); ?> </td> </tr> <?php $export[] = array(app::dateTimeFormat($comments->getCreatedAt()), $comments->getUsers()->getName(), $comments->getWorkedHours(), $comments->getTasks()->getName(), $comments->getTasks()->getTasksStatus() ? $comments->getTasks()->getTasksStatus()->getName() : '', $comments->getTasks()->getProjects()->getName(), url_for('tasksComments/index?tasks_id=' . $comments->getTasks()->getId() . '&projects_id=' . $comments->getTasks()->getProjects()->getId(), true)); } echo ' <tr> <td></td> <td></td> <td><b>' . $total_worked_hours_per_day . '</b></td> <td></td> <td></td> <td></td> </tr>'; $export[] = array('', '', $total_worked_hours_per_day, '', '', '', ''); $export[] = array('', '', '', '', '', '', ''); ?> </table>
} ?> <?php echo ExtraFieldsList::renderInfoFileds('projects', $projects, $sf_user); ?> <tr><td style="padding-top: 7px;"></td></tr> <tr> <th><?php echo __('Created At'); ?> :</th> <td><?php echo app::dateTimeFormat($projects->getCreatedAt()); ?> </td> </tr> <tr> <th><?php echo __('Created By'); ?> :</th> <td><?php echo $projects->getUsers()->getName(); ?> </td> </tr> </table> <br>
public function executeExport(sfWebRequest $request) { /*check access*/ if ($request->hasParameter('projects_id')) { $this->forward404Unless($this->projects = Doctrine_Core::getTable('Projects')->createQuery()->addWhere('id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object projects does not exist (%s).', $request->getParameter('projects_id'))); $this->checkProjectsAccess($this->projects); $this->checkTasksAccess('view', false, $this->projects); } else { $this->checkTasksAccess('view'); } $this->columns = array('Projects' => t::__('Project Name'), 'id' => t::__('Id'), 'TasksGroups' => t::__('Group'), 'Versions' => t::__('Version'), 'ProjectsPhases' => t::__('Phase'), 'TasksPriority' => t::__('Priority'), 'TasksLabels' => t::__('Label'), 'name' => t::__('Name'), 'TasksStatus' => t::__('Status'), 'TasksTypes' => t::__('Type'), 'assigned_to' => t::__('Assigned To'), 'Users' => t::__('Created By'), 'estimated_time' => t::__('Est. Time'), 'work_hours' => t::__('Work Hours'), 'start_date' => t::__('Start Date'), 'due_date' => t::__('Due Date'), 'progress' => t::__('Progress'), 'created_at' => t::__('Created At')); $extra_fields = ExtraFieldsList::getFieldsByType('tasks', $this->getUser(), false, array('all' => true)); foreach ($extra_fields as $v) { $this->columns['extra_field_' . $v['id']] = $v['name']; } $this->columns['url'] = t::__('Url'); if ($fields = $request->getParameter('fields')) { $separator = "\t"; $format = $request->getParameter('format', '.csv'); $filename = $request->getParameter('filename', 'tasks'); header("Content-type: Application/octet-stream"); header("Content-disposition: attachment; filename=" . $filename . "." . $format); header("Pragma: no-cache"); header("Expires: 0"); $content = ''; foreach ($fields as $f) { $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $this->columns[$f]) . $separator; } $content .= "\n"; if ($format == 'csv') { echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8'); } else { echo $content; } if (strlen($request->getParameter('selected_items') == 0)) { exit; } $q = Doctrine_Core::getTable('Tasks')->createQuery('t')->leftJoin('t.TasksPriority tp')->leftJoin('t.TasksStatus ts')->leftJoin('t.TasksLabels tl')->leftJoin('t.TasksTypes tt')->leftJoin('t.TasksGroups tg')->leftJoin('t.ProjectsPhases pp')->leftJoin('t.Versions v')->leftJoin('t.Projects p')->leftJoin('t.Users')->whereIn('t.id', explode(',', $request->getParameter('selected_items'))); if ($request->hasParameter('projects_id')) { $q->addWhere('projects_id=?', $request->getParameter('projects_id')); if (Users::hasAccess('view_own', 'tasks', $this->getUser(), $request->getParameter('projects_id'))) { $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'"); } } else { if (Users::hasAccess('view_own', 'projects', $this->getUser())) { $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',team) or p.created_by='" . $this->getUser()->getAttribute('id') . "'"); } if (Users::hasAccess('view_own', 'tasks', $this->getUser())) { $q->addWhere("find_in_set('" . $this->getUser()->getAttribute('id') . "',t.assigned_to) or t.created_by='" . $this->getUser()->getAttribute('id') . "'"); } } $tree_order = false; if ($request->hasParameter('projects_id')) { $q = app::addListingOrder($q, 'tasks', $this->getUser(), (int) $request->getParameter('projects_id')); } else { $q->orderBy('LTRIM(p.name), ts.group desc, ts.sort_order, LTRIM(ts.name), LTRIM(t.name)'); } $tasks = $q->fetchArray(); $totals = array(); $projects_totals = array(); $current_project_id = 0; foreach ($tasks as $t) { $content = ''; // if ($current_project_id == 0) { $current_project_id = $t['projects_id']; } if ($current_project_id != $t['projects_id']) { //adding totals if (isset($projects_totals[$current_project_id])) { foreach ($fields as $f) { $v = ''; if (in_array($f, array('estimated_time', 'work_hours'))) { $v = $projects_totals[$current_project_id][$f]; } elseif (strstr($f, 'extra_field_')) { if (isset($projects_totals[$current_project_id][str_replace('extra_field_', '', $f)])) { $v = $projects_totals[$current_project_id][str_replace('extra_field_', '', $f)]; } } $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator; } $content .= "\n\n"; } $current_project_id = $t['projects_id']; } // $name_adding = ''; $ex_values = ExtraFieldsList::getValuesList($extra_fields, $t['id']); foreach ($fields as $f) { $v = ''; if ($f == 'name') { $v = $name_adding . $t[$f]; } elseif (in_array($f, array('id', 'description', 'estimated_time', 'work_hours'))) { if ($f == 'work_hours') { $v = TasksComments::getTotalWorkHours($t['id']); } else { $v = $t[$f]; } if (in_array($f, array('estimated_time', 'work_hours'))) { if (!isset($totals[$f])) { $totals[$f] = 0; } if (!isset($projects_totals[$t['projects_id']][$f])) { $projects_totals[$t['projects_id']][$f] = 0; } $totals[$f] += $v; $projects_totals[$t['projects_id']][$f] += $v; } } elseif (in_array($f, array('start_date', 'due_date', 'created_at'))) { $v = app::dateTimeFormat($t[$f]); } elseif ($f == 'progress') { $v = (int) $t['progress'] . '%'; } elseif (strstr($f, 'extra_field_')) { if ($ex = Doctrine_Core::getTable('ExtraFields')->find(str_replace('extra_field_', '', $f))) { $v = ExtraFieldsList::renderFieldValueByType($ex, $ex_values, array(), true); if (in_array($ex->getType(), array('number', 'formula'))) { if (!isset($totals[$ex->getId()])) { $totals[$ex->getId()] = 0; } if (!isset($projects_totals[$t['projects_id']][$ex->getId()])) { $projects_totals[$t['projects_id']][$ex->getId()] = 0; } $totals[$ex->getId()] += $v; $projects_totals[$t['projects_id']][$ex->getId()] += $v; } $v = str_replace('<br>', ', ', $v); } } elseif ($f == 'assigned_to') { $v = Users::getNameById($t[$f], ', '); } elseif ($f == 'url') { $v = app::public_url('tasksComments/index?projects_id=' . $t['projects_id'] . '&tasks_id=' . $t['id']); } elseif ($f == 'actual_time') { if ($t['work_hours'] > 0 and $t['togo_hours'] == 0) { $v = $t['work_hours']; } else { $v = (double) $t['estimated_time'] - (double) $t['work_hours'] + (double) $t['togo_hours']; } if (!isset($totals[$f])) { $totals[$f] = 0; } $totals[$f] += $v; $projects_totals[$t['projects_id']][$f] += $v; } else { $v = app::getArrayName($t, $f); } $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator; } $content .= "\n"; if ($format == 'csv') { echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8'); } else { echo $content; } } $content = ''; //adding totals if (isset($projects_totals[$current_project_id]) and !$request->hasParameter('projects_id')) { foreach ($fields as $f) { $v = ''; if (in_array($f, array('estimated_time', 'work_hours'))) { $v = $projects_totals[$current_project_id][$f]; } elseif (strstr($f, 'extra_field_')) { if (isset($projects_totals[$current_project_id][str_replace('extra_field_', '', $f)])) { $v = $projects_totals[$current_project_id][str_replace('extra_field_', '', $f)]; } } $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator; } $content .= "\n\n"; } foreach ($fields as $f) { $v = ''; if (in_array($f, array('estimated_time', 'work_hours'))) { $v = $totals[$f]; } elseif (strstr($f, 'extra_field_')) { if (isset($totals[str_replace('extra_field_', '', $f)])) { $v = $totals[str_replace('extra_field_', '', $f)]; } } $content .= str_replace(array("\n\r", "\r", "\n", $separator), ' ', $v) . $separator; } $content .= "\n"; if ($format == 'csv') { echo chr(0xff) . chr(0xfe) . mb_convert_encoding($content, 'UTF-16LE', 'UTF-8'); } else { echo $content; } exit; } }
public static function getLastCommentByTable($t, $bind_field, $bind_id) { $c = Doctrine_Core::getTable($t)->createQuery('t')->leftJoin('t.Users u')->addWhere($bind_field . '=?', $bind_id)->orderBy('t.created_at desc')->fetchOne(array(), Doctrine::HYDRATE_ARRAY); $module = strtolower($t[0]) . substr($t, 1); if ($c) { return '<a class="jt" href="#" onClick="return false" rel="' . url_for($module . '/info?id=' . $c['id']) . '" title="' . app::dateTimeFormat($c['created_at']) . '"><sup>' . image_tag('icons/comment_small.png') . $c['Users']['name'] . '</sup></a>'; } else { return ''; } }