function ExecuteQuery() { $this->data = array(); $date = new DateTimeValue(Time()); $notYet = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND ( due_date = \'0000-00-00 00:00:00\' OR due_date > \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "')")); $today = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND due_date = \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "'")); $past = ProjectTasks::findAll(array('conditions' => 'created_by_id = ' . logged_user()->getId() . ' AND due_date > \'1900-01-01 00:00:00\' AND due_date < \'' . substr($date->toMySQL(), 0, strpos($date->toMySQL(), ' ')) . "'")); $value = 0; if (isset($past)) { $value = count($past); } $this->data['values'][0]['labels'][] = 'Overdue'; $this->data['values'][0]['values'][] = $value; $value = 0; if (isset($notYet)) { $value = count($notYet); } $this->data['values'][0]['labels'][] = 'Not yet due'; $this->data['values'][0]['values'][] = $value; $value = 0; if (isset($today)) { $value = count($today); } $this->data['values'][0]['labels'][] = 'Due today'; $this->data['values'][0]['values'][] = $value; }
/** * * @author Ignacio Vazquez - elpepe.uy@gmail.com * @param ProjectTask $object */ function addObject($object) { if ($this->hasObject($object)) { return; } if (!$object->isTemplate() && $object->canBeTemplate()) { // the object isn't a template but can be, create a template copy $copy = $object->copy(); $copy->setColumnValue('is_template', true); if ($copy instanceof ProjectTask) { // don't copy milestone and parent task $copy->setMilestoneId(0); $copy->setParentId(0); } $copy->save(); //Also copy members.. // $memberIds = json_decode(array_var($_POST, 'members')); // $controller = new ObjectController() ; // $controller->add_to_members($copy, $memberIds); // copy subtasks if ($copy instanceof ProjectTask) { ProjectTasks::copySubTasks($object, $copy, true); } else { if ($copy instanceof ProjectMilestone) { ProjectMilestones::copyTasks($object, $copy, true); } } // copy custom properties $copy->copyCustomPropertiesFrom($object); // copy linked objects $linked_objects = $object->getAllLinkedObjects(); if (is_array($linked_objects)) { foreach ($linked_objects as $lo) { $copy->linkObject($lo); } } // copy reminders $reminders = ObjectReminders::getByObject($object); foreach ($reminders as $reminder) { $copy_reminder = new ObjectReminder(); $copy_reminder->setContext($reminder->getContext()); $copy_reminder->setDate(EMPTY_DATETIME); $copy_reminder->setMinutesBefore($reminder->getMinutesBefore()); $copy_reminder->setObject($copy); $copy_reminder->setType($reminder->getType()); // $copy_reminder->setContactId($reminder->getContactId()); //TODO Feng 2 - No anda $copy_reminder->save(); } $template = $copy; } else { // the object is already a template or can't be one, use it as it is $template = $object; } $to = new TemplateObject(); $to->setObject($template); $to->setTemplate($this); $to->save(); return $template->getObjectId(); }
static function getPreviousTasks($task_id) { $previous_tasks = array(); $deps = self::getDependenciesForTask($task_id); foreach ($deps as $dep) { /* @var $dep ProjectTaskDependency */ $task = ProjectTasks::findById($dep->getPreviousTaskId()); if ($task instanceof ProjectTask) { $previous_tasks[] = $task; } } return $previous_tasks; }
function findByTaskAndRelated($task_id,$original_task_id) { return ProjectTasks::findAll(array('conditions' => array('(`original_task_id` = ? OR `object_id` = ?) AND `object_id` <> ?', $original_task_id,$original_task_id,$task_id))); }
/** * This function will return paginated result. Result is an array where first element is * array of returned object and second populated pagination object that can be used for * obtaining and rendering pagination data using various helpers. * * Items and pagination array vars are indexed with 0 for items and 1 for pagination * because you can't use associative indexing with list() construct * * @access public * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! * @param integer $items_per_page Number of items per page * @param integer $current_page Current page number * @return array */ function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { if (isset($this) && instance_of($this, 'ProjectTasks')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return ProjectTasks::instance()->paginate($arguments, $items_per_page, $current_page); //$instance =& ProjectTasks::instance(); //return $instance->paginate($arguments, $items_per_page, $current_page); } // if }
function change_start_due_date() { $task = ProjectTasks::findById(get_id()); if (!$task->canEdit(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } $tochange = array_var($_GET, 'tochange', ''); if (($tochange == 'both' || $tochange == 'due') && $task->getDueDate() instanceof DateTimeValue) { $year = array_var($_GET, 'year', $task->getDueDate()->getYear()); $month = array_var($_GET, 'month', $task->getDueDate()->getMonth()); $day = array_var($_GET, 'day', $task->getDueDate()->getDay()); $new_date = new DateTimeValue(mktime(0, 0, 0, $month, $day, $year)); $task->setDueDate($new_date); } if (($tochange == 'both' || $tochange == 'start') && $task->getStartDate() instanceof DateTimeValue) { $year = array_var($_GET, 'year', $task->getStartDate()->getYear()); $month = array_var($_GET, 'month', $task->getStartDate()->getMonth()); $day = array_var($_GET, 'day', $task->getStartDate()->getDay()); $new_date = new DateTimeValue(mktime(0, 0, 0, $month, $day, $year)); $task->setStartDate($new_date); } try { DB::beginWork(); $task->save(); DB::commit(); } catch (Exception $e) { DB::rollback(); flash_error(lang('error change date')); } // try ajx_current("empty"); }
function total_task_times_by_task_print() { $this->setLayout("html"); $task = ProjectTasks::findById(get_id()); $st = DateTimeValueLib::make(0, 0, 0, 1, 1, 1900); $et = DateTimeValueLib::make(23, 59, 59, 12, 31, 2036); $timeslotsArray = Timeslots::getTaskTimeslots(active_context(), null, null, $st, $et, get_id()); tpl_assign('columns', array()); tpl_assign('user', array()); tpl_assign('group_by', array()); tpl_assign('grouped_timeslots', array()); tpl_assign('template_name', 'total_task_times'); tpl_assign('estimate', $task->getTimeEstimate()); tpl_assign('timeslotsArray', $timeslotsArray); tpl_assign('title', lang('task time report')); tpl_assign('task_title', $task->getTitle()); tpl_assign('start_time', $st); tpl_assign('end_time', $et); $this->setTemplate('report_printer'); }
} echo stylesheet_tag('event/day.css'); $today = DateTimeValueLib::now(); $today->add('h', logged_user()->getTimezone()); $currentday = $today->format("j"); $currentmonth = $today->format("n"); $currentyear = $today->format("Y"); $drawHourLine = $day == $currentday && $month == $currentmonth && $year == $currentyear; $dtv = DateTimeValueLib::make(0, 0, 0, $month, $day, $year); $result = ProjectEvents::getDayProjectEvents($dtv, $tags, active_project(), $user_filter, $status_filter); if (!$result) { $result = array(); } $alldayevents = array(); $milestones = ProjectMilestones::getRangeMilestonesByUser($dtv, $dtv, $user_filter != -1 ? $user : null, $tags, active_project()); $tasks = ProjectTasks::getRangeTasksByUser($dtv, $dtv, $user_filter != -1 ? $user : null, $tags, active_project()); $birthdays = Contacts::instance()->getRangeContactsByBirthday($dtv, $dtv); foreach ($result as $key => $event) { if ($event->getTypeId() > 1) { $alldayevents[] = $event; unset($result[$key]); } } if ($milestones) { $alldayevents = array_merge($alldayevents, $milestones); } if ($tasks) { $tmp_tasks = array(); $dtv_end = new DateTimeValue($dtv->getTimestamp() + 60 * 60 * 24); foreach ($tasks as $task) { $tmp_tasks = array_merge($tmp_tasks, replicateRepetitiveTaskForCalendar($task, $dtv, $dtv_end));
/** * Copies tasks from milestoneFrom to milestoneTo. * * @param ProjectMilestone $milestoneFrom * @param ProjectMilestone $milestoneTo */ function copyTasks(ProjectMilestone $milestoneFrom, ProjectMilestone $milestoneTo, $as_template = false) { //FIXME foreach ($milestoneFrom->getTasks($as_template) as $sub) { if ($sub->getParentId() != 0) { continue; } $new = ProjectTasks::createTaskCopy($sub); $new->setMilestoneId($milestoneTo->getId()); $new->save(); $object_controller = new ObjectController(); $members = $milestoneFrom->getMemberIds(); if (count($members)) { $object_controller->add_to_members($new, $members); } /* foreach ($sub->getWorkspaces() as $workspace) { if (ProjectTask::canAdd(logged_user(), $workspace)) { $new->addToWorkspace($workspace); } } if (!$as_template && active_project() instanceof Project && ProjectTask::canAdd(logged_user(), active_project())) { $new->removeFromAllWorkspaces(); $new->addToWorkspace(active_project()); } */ $new->copyCustomPropertiesFrom($sub); $new->copyLinkedObjectsFrom($sub); ProjectTasks::copySubTasks($sub, $new, $as_template); } }
<th width="14%"></th> <th width="15%"></th> <?php if (user_config_option("start_monday")) { ?> <th width='15%'></th> <?php } ?> <th id="ie_scrollbar_adjust" style="display:none;width:15px;padding:0px;margin:0px;"></th> </tr> <?php $date_start = new DateTimeValue(mktime(0, 0, 0, $month - 1, $firstday, $year)); $date_end = new DateTimeValue(mktime(0, 0, 0, $month + 1, $lastday, $year)); $milestones = ProjectMilestones::getRangeMilestonesByUser($date_start, $date_end, $user_filter != -1 ? $user : null, $tags, active_project()); $tasks = ProjectTasks::getRangeTasksByUser($date_start, $date_end, $user_filter != -1 ? $user : null, $tags, active_project()); $birthdays = Contacts::instance()->getRangeContactsByBirthday($date_start, $date_end); $result = array(); if ($milestones) { $result = array_merge($result, $milestones); } if ($tasks) { foreach ($tasks as $task) { $result = array_merge($result, replicateRepetitiveTaskForCalendar($task, $date_start, $date_end)); } } if ($birthdays) { $result = array_merge($result, $birthdays); } // Loop to render the calendar for ($week_index = 0;; $week_index++) {
function check_related_task() { ajx_current("empty"); //I find all those related to the task to find out if the original $task_related = ProjectTasks::findByRelated(array_var($_REQUEST, 'related_id')); if (!$task_related) { $task_related = ProjectTasks::findById(array_var($_REQUEST, 'related_id')); //is not the original as the original look plus other related if ($task_related->getOriginalTaskId() != "0") { ajx_extra_data(array("status" => true)); } else { ajx_extra_data(array("status" => false)); } } else { ajx_extra_data(array("status" => true)); } }
/** * @deprecated * @author Ignacio Vazquez - elpepe.uy@gmail.com */ static function _findAllowed() { //1. Find members where user can add tasks //$sqlMembers = " $sql = "\n\t\t\tSELECT distinct(id) AS id\n\t\t\tFROM " . TABLE_PREFIX . "object_members om\n\t\t\tINNER JOIN " . TABLE_PREFIX . "templates t ON t.object_id = om.object_id\n\t\t\tINNER JOIN " . TABLE_PREFIX . "objects o ON om.object_id = o.id\n\t\t\tWHERE\n\t\t\t member_id IN ( \n\t\t\t \tSELECT distinct(member_id) \n\t\t\t\t\tFROM " . TABLE_PREFIX . "contact_member_permissions o \n\t\t\t\t\tWHERE object_type_id = " . ProjectTasks::instance()->getObjectTypeId() . " \n\t\t\t\t\tAND permission_group_id IN ( " . ContactPermissionGroups::getPermissionGroupIdsByContactCSV(logged_user()->getId()) . " ) AND can_write= 1 \n\t\t\t\t)\n\t\t\t\tAND is_optimization = 0\n\t\t\tGROUP BY om.object_id\t\t\n\t\t"; $res = DB::execute($sql); $tpls = array(); // Iterate on the results and make som filtering while ($row = $res->fetchRow()) { $tpl = COTemplates::instance()->findById($row['id']); $tpls[] = $tpl; } return $tpls; }
function instantiate() { $selected_members = array(); $id = get_id(); $template = COTemplates::findById($id); if (!$template instanceof COTemplate) { flash_error(lang("template dnx")); ajx_current("empty"); return; } $parameters = TemplateParameters::getParametersByTemplate($id); $parameterValues = array_var($_POST, 'parameterValues'); if (count($parameters) > 0 && !isset($parameterValues)) { ajx_current("back"); return; } if (array_var($_POST, 'members')) { $selected_members = json_decode(array_var($_POST, 'members')); } else { $context = active_context(); foreach ($context as $selection) { if ($selection instanceof Member) { $selected_members[] = $selection->getId(); } } } $objects = $template->getObjects(); $controller = new ObjectController(); if (count($selected_members > 0)) { $selected_members_instances = Members::findAll(array('conditions' => 'id IN (' . implode($selected_members) . ')')); } else { $selected_members_instances = array(); } DB::beginWork(); $active_context = active_context(); foreach ($objects as $object) { if (!$object instanceof ContentDataObject) { continue; } // copy object $copy = $object->copy(); if ($copy->columnExists('is_template')) { $copy->setColumnValue('is_template', false); } if ($copy instanceof ProjectTask) { // don't copy parent task and milestone $copy->setMilestoneId(0); $copy->setParentId(0); } $copy->save(); /* if (!can_write(logged_user(), $selected_members_instances, $copy->getObjectTypeId()) ) { flash_error(lang('no context permissions to add', $copy instanceof ProjectTask ? lang("tasks") : ($copy instanceof ProjectMilestone ? lang('milestones') : ''))); DB::rollback(); ajx_current("empty"); return; }*/ // Copy members from origial object, if it doesn't have then use active context members /* $template_object_members = $object->getMemberIds(); if (count($template_object_members) == 0) { $object_member_ids = active_context_members(false); if (count($object_member_ids) > 0) { $template_object_members = Members::findAll(array("id" => true, "conditions" => "id IN (".implode(",", $object_member_ids).")")); } }*/ /* Set instantiated object members: * foreach dimension: * if no member is active then the instantiated object is put in the same members as the original for current dimension * if a member is selected in current dimension then the instantiated object will be put in that member */ $template_object_members = $object->getMembers(); $object_members = array(); foreach ($active_context as $selection) { if ($selection instanceof Member) { // member selected $object_members[] = $selection->getId(); } else { if ($selection instanceof Dimension) { // no member selected foreach ($template_object_members as $tom) { if ($tom->getDimensionId() == $selection->getId()) { $object_members[] = $tom->getId(); } } } } } $controller->add_to_members($copy, $object_members); // copy linked objects $copy->copyLinkedObjectsFrom($object); // copy subtasks if applicable if ($copy instanceof ProjectTask) { ProjectTasks::copySubTasks($object, $copy, false); foreach ($copy->getOpenSubTasks(false) as $m_task) { $controller->add_to_members($m_task, $object_members); } $manager = $copy->manager(); } else { if ($copy instanceof ProjectMilestone) { ProjectMilestones::copyTasks($object, $copy, false); foreach ($copy->getTasks(false) as $m_task) { $controller->add_to_members($m_task, $object_members); } $manager = $copy->manager(); } } // copy custom properties $copy->copyCustomPropertiesFrom($object); // set property values as defined in template $objProp = TemplateObjectProperties::getPropertiesByTemplateObject($id, $object->getId()); foreach ($objProp as $property) { $propName = $property->getProperty(); $value = $property->getValue(); if ($manager->getColumnType($propName) == DATA_TYPE_STRING || $manager->getColumnType($propName) == DATA_TYPE_INTEGER) { if (is_array($parameterValues)) { foreach ($parameterValues as $param => $val) { if (strpos($value, '{' . $param . '}') !== FALSE) { $value = str_replace('{' . $param . '}', $val, $value); } } } } else { if ($manager->getColumnType($propName) == DATA_TYPE_DATE || $manager->getColumnType($propName) == DATA_TYPE_DATETIME) { $operator = '+'; if (strpos($value, '+') === false) { $operator = '-'; } $opPos = strpos($value, $operator); if ($opPos !== false) { // Is parametric $dateParam = substr($value, 1, strpos($value, '}') - 1); $date = $parameterValues[$dateParam]; $dateUnit = substr($value, strlen($value) - 1); // d, w or m (for days, weeks or months) if ($dateUnit == 'm') { $dateUnit = 'M'; // make month unit uppercase to call DateTimeValue::add with correct parameter } $dateNum = (int) substr($value, strpos($value, $operator), strlen($value) - 2); $date = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $date); $date = new DateTimeValue($date->getTimestamp() - logged_user()->getTimezone() * 3600); // set date to GMT 0 $value = $date->add($dateUnit, $dateNum); } else { $value = DateTimeValueLib::dateFromFormatAndString(user_config_option('date_format'), $value); } } } if ($value != '') { if (!$copy->setColumnValue($propName, $value)) { $copy->object->setColumnValue($propName, $value); } $copy->save(); } } // subscribe assigned to if ($copy instanceof ProjectTask) { foreach ($copy->getOpenSubTasks(false) as $m_task) { if ($m_task->getAssignedTo() instanceof Contact) { $m_task->subscribeUser($copy->getAssignedTo()); } } if ($copy->getAssignedTo() instanceof Contact) { $copy->subscribeUser($copy->getAssignedTo()); } } else { if ($copy instanceof ProjectMilestone) { foreach ($copy->getTasks(false) as $m_task) { if ($m_task->getAssignedTo() instanceof Contact) { $m_task->subscribeUser($copy->getAssignedTo()); } } } } // copy reminders $reminders = ObjectReminders::getByObject($object); foreach ($reminders as $reminder) { $copy_reminder = new ObjectReminder(); $copy_reminder->setContext($reminder->getContext()); $reminder_date = $copy->getColumnValue($reminder->getContext()); if ($reminder_date instanceof DateTimeValue) { $reminder_date = new DateTimeValue($reminder_date->getTimestamp()); $reminder_date->add('m', -$reminder->getMinutesBefore()); } $copy_reminder->setDate($reminder_date); $copy_reminder->setMinutesBefore($reminder->getMinutesBefore()); $copy_reminder->setObject($copy); $copy_reminder->setType($reminder->getType()); $copy_reminder->setUserId($reminder->getUserId()); $copy_reminder->save(); } } DB::commit(); if (is_array($parameters) && count($parameters) > 0) { ajx_current("back"); } else { if (!$choose_ctx) { ajx_current("back"); } else { ajx_current("reload"); } } }
/** * Reopen completed project task * * @access public * @param void * @return null */ function edit_score() { $task = ProjectTasks::findById(get_id()); if (!$task instanceof ProjectTask) { flash_error(lang('task dnx')); //$this->redirectTo('task'); } // if include '../views/editscore.html'; }
function allowed_users_to_assign_all_mobile($member_id = null) { if ($member_id == null) { $context = active_context(); }else{ $member = Members::findById($member_id); if ($member instanceof Member){ $context[] = $member; } } // only companies with users $companies = Contacts::findAll(array("conditions" => "is_company = 1 AND object_id IN (SELECT company_id FROM ".TABLE_PREFIX."contacts WHERE user_type>0 AND disabled=0)", "order" => "first_name ASC")); $comp_ids = array("0"); $comp_array = array("0" => array('id' => "0", 'name' => lang('without company'), 'users' => array() )); foreach ($companies as $company) { $comp_ids[] = $company->getId(); $comp_array[$company->getId()] = array('id' => $company->getId(), 'name' => $company->getObjectName(), 'users' => array() ); } if(!can_manage_tasks(logged_user()) && can_task_assignee(logged_user())) { $contacts = array(logged_user()); } else if (can_manage_tasks(logged_user())) { $contacts = allowed_users_in_context(ProjectTasks::instance()->getObjectTypeId(), $context, ACCESS_LEVEL_READ, "AND `is_company`=0 AND `company_id` IN (".implode(",", $comp_ids).")"); } else { $contacts = array(); } foreach ($contacts as $contact) { /* @var $contact Contact */ if ( TabPanelPermissions::instance()->count( array( "conditions" => "permission_group_id = ".$contact->getPermissionGroupId(). " AND tab_panel_id = 'tasks-panel' " ))){ $comp_array[$contact->getCompanyId()]['users'][] = array('id' => $contact->getId(), 'name' => $contact->getObjectName(), 'isCurrent' => $contact->getId() == logged_user()->getId()); } } foreach ($comp_array as $company_id => &$comp_data) { if (count($comp_data['users']) == 0) { unset($comp_array[$company_id]); } } return array_values($comp_array); }
/** * Drop all tasks that are in this list * * @access public * @param void * @return boolean */ function deleteTasks() { return ProjectTasks::delete(DB::escapeField('task_list_id') . ' = ' . DB::escape($this->getId())); }
/** * Show and process edit time form * * @access public * @param void * @return null */ function edit() { $this->setTemplate('add_time'); $time = ProjectTimes::findById(get_id()); if (!$time instanceof ProjectTime) { flash_error(lang('time dnx')); $this->redirectTo('time', 'index'); } // if if (!$time->canEdit(logged_user())) { flash_error(lang('no access permissions')); $this->redirectToReferer(get_url('time')); } $time_data = array_var($_POST, 'time'); if (!is_array($time_data)) { $time_data = array('name' => $time->getName(), 'hours' => $time->getHours(), 'is_billable' => $time->getBillable(), 'done_date' => $time->getDoneDate(), 'description' => $time->getDescription(), 'assigned_to' => $time->getAssignedToCompanyId() . ':' . $time->getAssignedToUserId(), 'is_private' => $time->isPrivate(), 'task_id' => $time->getTaskId(), 'task_list_id' => $time->getTaskListId()); // array } // if tpl_assign('time_data', $time_data); tpl_assign('time', $time); // Attiks - BEGIN tpl_assign('open_task_lists', active_project()->getOpenTaskLists()); // Attiks - END if (is_array(array_var($_POST, 'time'))) { $old_owner = $time->getAssignedTo(); // remember the old owner if (isset($_POST['time_done_date'])) { $time_data['done_date'] = DateTimeValueLib::makeFromString($_POST['time_done_date']); } else { $time_data['done_date'] = DateTimeValueLib::make(0, 0, 0, array_var($_POST, 'time_done_date_month', 1), array_var($_POST, 'time_done_date_day', 1), array_var($_POST, 'time_done_date_year', 1970)); } // Attiks - BEGIN if (isset($time_data['task_id'])) { if (substr($time_data['task_id'], 0, 5) == 'task_') { $time_data['task_id'] = substr($time_data['task_id'], 5); $t = ProjectTasks::findById($time_data['task_id']); if (!$t instanceof ProjectTask) { flash_error(lang('task dnx')); $this->redirectTo('task'); } // if $time_data['task_list_id'] = $t->getTaskListId(); } else { $time_data['task_list_id'] = $time_data['task_id']; $time_data['task_id'] = null; } } // Attiks - END $assigned_to = explode(':', array_var($time_data, 'assigned_to', '')); $old_is_private = $time->isPrivate(); $time->setFromAttributes($time_data); if (!logged_user()->isMemberOfOwnerCompany()) { $time->setIsPrivate($old_is_private); } $time->setProjectId(active_project()->getId()); $time->setAssignedToCompanyId(array_var($assigned_to, 0, 0)); $time->setAssignedToUserId(array_var($assigned_to, 1, 0)); try { DB::beginWork(); $time->save(); ApplicationLogs::createLog($time, active_project(), ApplicationLogs::ACTION_EDIT); DB::commit(); flash_success(lang('success edit time', $time->getName())); $this->redirectTo('time'); } catch (Exception $e) { DB::rollback(); tpl_assign('error', $e); } // try } // if }
/** * Return manager instance * * @access protected * @param void * @return ProjectTasks */ function manager() { if (!$this->manager instanceof ProjectTasks) { $this->manager = ProjectTasks::instance(); } return $this->manager; }
function total_task_times_by_task_print() { $this->setLayout("html"); $task = ProjectTasks::findById(get_id()); $st = DateTimeValueLib::make(0, 0, 0, 1, 1, 1900); $et = DateTimeValueLib::make(23, 59, 59, 12, 31, 2036); $timeslotsArray = Timeslots::getTaskTimeslots(null, null, null, $st, $et, get_id()); tpl_assign('estimate', $task->getTimeEstimate()); //tpl_assign('timeslots', $timeslots); tpl_assign('timeslotsArray', $timeslotsArray); tpl_assign('workspace', $task->getProject()); tpl_assign('template_name', 'total_task_times'); tpl_assign('title', lang('task time report')); tpl_assign('task_title', $task->getTitle()); $this->setTemplate('report_printer'); }
/** * Return manager instance * * @access protected * @param void * @return ProjectTasks */ function manager() { if(!($this->manager instanceof ProjectTasks)) $this->manager = ProjectTasks::instance(); return $this->manager; } // manager
// end of week $today = DateTimeValueLib::now(); $today->add('h', logged_user()->getTimezone()); $currentday = $today->format("j"); $currentmonth = $today->format("n"); $currentyear = $today->format("Y"); $drawHourLine = false; $lastday = date("t", mktime(0, 0, 0, $month, 1, $year)); // # of days in the month $date_start = new DateTimeValue(mktime(0, 0, 0, $month, $startday, $year)); $date_end = new DateTimeValue(mktime(0, 0, 0, $month, $endday, $year)); // $date_start->add('h', logged_user()->getTimezone()); // $date_end->add('h', logged_user()->getTimezone()); $milestones = ProjectMilestones::getRangeMilestones($date_start, $date_end); if ($task_filter != "hide") { $tasks = ProjectTasks::getRangeTasksByUser($date_start, $date_end, $user_filter != -1 ? $user : null, $task_filter); } // FIXME $birthdays = array(); //Contacts::instance()->getRangeContactsByBirthday($date_start, $date_end); $tmp_tasks = array(); foreach ($tasks as $task) { $tmp_tasks = array_merge($tmp_tasks, replicateRepetitiveTaskForCalendar($task, $date_start, $date_end)); } $dates = array(); //datetimevalue for each day of week $results = array(); $allday_events_count = array(); $alldayevents = array(); $today_style = array(); $task_starts = array();
$today = DateTimeValueLib::now(); //user today // $today->add('h', logged_user()->getTimezone()); $currentday = $today->format("j"); $currentmonth = $today->format("n"); $currentyear = $today->format("Y"); $drawHourLine = $day == $currentday && $month == $currentmonth && $year == $currentyear; $dtv = DateTimeValueLib::make(0, 0, 0, $month, $day, $year); $result = ProjectEvents::getDayProjectEvents($dtv, active_context(), $user_filter, $status_filter); if (!$result) { $result = array(); } $alldayevents = array(); $milestones = ProjectMilestones::getRangeMilestones($dtv, $dtv); if ($task_filter != "hide") { $tasks = ProjectTasks::getRangeTasksByUser($dtv, $dtv, $user_filter != -1 ? $user : null, $task_filter); } if (user_config_option('show_birthdays_in_calendar')) { $birthdays = Contacts::instance()->getRangeContactsByBirthday($dtv, $dtv, active_context_members(false)); } else { $birthdays = array(); } foreach ($result as $key => $event) { if ($event->getTypeId() > 1) { $alldayevents[] = $event; unset($result[$key]); } } if ($milestones) { $alldayevents = array_merge($alldayevents, $milestones); }
/** * Execute a report and return results * * @param $id * @param $params * * @return array */ static function executeReport($id, $params, $order_by_col = '', $order_by_asc = true, $offset = 0, $limit = 50, $to_print = false) { if (is_null(active_context())) { CompanyWebsite::instance()->setContext(build_context_array(array_var($_REQUEST, 'context'))); } $results = array(); $report = self::getReport($id); $show_archived = false; if ($report instanceof Report) { $conditionsFields = ReportConditions::getAllReportConditionsForFields($id); $conditionsCp = ReportConditions::getAllReportConditionsForCustomProperties($id); $ot = ObjectTypes::findById($report->getReportObjectTypeId()); $table = $ot->getTableName(); if ($ot->getType() == 'dimension_object' || $ot->getType() == 'dimension_group') { $hook_parameters = array('report' => $report, 'params' => $params, 'order_by_col' => $order_by_col, 'order_by_asc' => $order_by_asc, 'offset' => $offset, 'limit' => $limit, 'to_print' => $to_print); $report_result = null; Hook::fire('replace_execute_report_function', $hook_parameters, $report_result); if ($report_result) { return $report_result; } } eval('$managerInstance = ' . $ot->getHandlerClass() . "::instance();"); eval('$item_class = ' . $ot->getHandlerClass() . '::instance()->getItemClass(); $object = new $item_class();'); $order_by = ''; if (is_object($params)) { $params = get_object_vars($params); } $report_columns = ReportColumns::getAllReportColumns($id); $allConditions = ""; $contact_extra_columns = self::get_extra_contact_columns(); if (count($conditionsFields) > 0) { foreach ($conditionsFields as $condField) { if ($condField->getFieldName() == "archived_on") { $show_archived = true; } $skip_condition = false; $model = $ot->getHandlerClass(); $model_instance = new $model(); $col_type = $model_instance->getColumnType($condField->getFieldName()); $allConditions .= ' AND '; $dateFormat = 'm/d/Y'; if (isset($params[$condField->getId()])) { $value = $params[$condField->getId()]; if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME) { $dateFormat = user_config_option('date_format'); } } else { $value = $condField->getValue(); } if ($ot->getHandlerClass() == 'Contacts' && in_array($condField->getFieldName(), $contact_extra_columns)) { $allConditions .= self::get_extra_contact_column_condition($condField->getFieldName(), $condField->getCondition(), $value); } else { if ($value == '' && $condField->getIsParametrizable()) { $skip_condition = true; } if (!$skip_condition) { $field_name = $condField->getFieldName(); if (in_array($condField->getFieldName(), Objects::getColumns())) { $field_name = 'o`.`' . $condField->getFieldName(); } if ($condField->getCondition() == 'like' || $condField->getCondition() == 'not like') { $value = '%' . $value . '%'; } if ($col_type == DATA_TYPE_DATE || $col_type == DATA_TYPE_DATETIME) { if ($value == date_format_tip($dateFormat)) { $value = EMPTY_DATE; } else { $dtValue = DateTimeValueLib::dateFromFormatAndString($dateFormat, $value); $value = $dtValue->format('Y-m-d'); } } if ($condField->getCondition() != '%') { if ($col_type == DATA_TYPE_INTEGER || $col_type == DATA_TYPE_FLOAT) { $allConditions .= '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value); } else { if ($condField->getCondition() == '=' || $condField->getCondition() == '<=' || $condField->getCondition() == '>=') { if ($col_type == DATA_TYPE_DATETIME || $col_type == DATA_TYPE_DATE) { $equal = 'datediff(' . DB::escape($value) . ', `' . $field_name . '`)=0'; } else { $equal = '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value); } switch ($condField->getCondition()) { case '=': $allConditions .= $equal; break; case '<=': case '>=': $allConditions .= '(`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value) . ' OR ' . $equal . ') '; break; } } else { $allConditions .= '`' . $field_name . '` ' . $condField->getCondition() . ' ' . DB::escape($value); } } } else { $allConditions .= '`' . $field_name . '` like ' . DB::escape("%{$value}"); } } else { $allConditions .= ' true'; } } } } if (count($conditionsCp) > 0) { $dateFormat = user_config_option('date_format'); $date_format_tip = date_format_tip($dateFormat); foreach ($conditionsCp as $condCp) { $cp = CustomProperties::getCustomProperty($condCp->getCustomPropertyId()); $skip_condition = false; if (isset($params[$condCp->getId() . "_" . $cp->getName()])) { $value = $params[$condCp->getId() . "_" . $cp->getName()]; } else { $value = $condCp->getValue(); } if ($value == '' && $condCp->getIsParametrizable()) { $skip_condition = true; } if (!$skip_condition) { $current_condition = ' AND '; $current_condition .= 'o.id IN ( SELECT object_id as id FROM ' . TABLE_PREFIX . 'custom_property_values cpv WHERE '; $current_condition .= ' cpv.custom_property_id = ' . $condCp->getCustomPropertyId(); $fieldType = $object->getColumnType($condCp->getFieldName()); if ($condCp->getCondition() == 'like' || $condCp->getCondition() == 'not like') { $value = '%' . $value . '%'; } if ($cp->getType() == 'date') { if ($value == $date_format_tip) { continue; } $dtValue = DateTimeValueLib::dateFromFormatAndString($dateFormat, $value); $value = $dtValue->format('Y-m-d H:i:s'); } if ($condCp->getCondition() != '%') { if ($cp->getType() == 'numeric') { $current_condition .= ' AND cpv.value ' . $condCp->getCondition() . ' ' . DB::escape($value); } else { if ($cp->getType() == 'boolean') { $current_condition .= ' AND cpv.value ' . $condCp->getCondition() . ' ' . ($value ? '1' : '0'); if (!$value) { $current_condition .= ') OR o.id NOT IN (SELECT object_id as id FROM ' . TABLE_PREFIX . 'custom_property_values cpv2 WHERE cpv2.object_id=o.id AND cpv2.value=1 AND cpv2.custom_property_id = ' . $condCp->getCustomPropertyId(); } } else { $current_condition .= ' AND cpv.value ' . $condCp->getCondition() . ' ' . DB::escape($value); } } } else { $current_condition .= ' AND cpv.value like ' . DB::escape("%{$value}"); } $current_condition .= ')'; $allConditions .= $current_condition; } } } $select_columns = array('*'); $join_params = null; if ($order_by_col == '') { $order_by_col = $report->getOrderBy(); } if ($ot->getHandlerClass() == 'Contacts' && in_array($order_by_col, $contact_extra_columns)) { $join_params = self::get_extra_contact_column_order_by($order_by_col, $order_by_col, $select_columns); } $original_order_by_col = $order_by_col; if (in_array($order_by_col, self::$external_columns)) { $order_by_col = 'name_order'; $join_params = array('table' => Objects::instance()->getTableName(), 'jt_field' => 'id', 'e_field' => $original_order_by_col, 'join_type' => 'left'); $select_columns = array(); $tmp_cols = $managerInstance->getColumns(); foreach ($tmp_cols as $col) { $select_columns[] = "e.{$col}"; } $tmp_cols = Objects::instance()->getColumns(); foreach ($tmp_cols as $col) { $select_columns[] = "o.{$col}"; } $select_columns[] = 'jt.name as name_order'; } if ($order_by_asc == null) { $order_by_asc = $report->getIsOrderByAsc(); } if ($ot->getName() == 'task' && !SystemPermissions::userHasSystemPermission(logged_user(), 'can_see_assigned_to_other_tasks')) { $allConditions .= " AND assigned_to_contact_id = " . logged_user()->getId(); } if ($managerInstance) { if ($order_by_col == "order") { $order_by_col = "`{$order_by_col}`"; } $listing_parameters = array("select_columns" => $select_columns, "order" => "{$order_by_col}", "order_dir" => $order_by_asc ? "ASC" : "DESC", "extra_conditions" => $allConditions, "count_results" => true, "join_params" => $join_params); if ($limit > 0) { $listing_parameters["start"] = $offset; $listing_parameters["limit"] = $limit; } if ($show_archived) { $listing_parameters["archived"] = true; } $result = $managerInstance->listing($listing_parameters); } else { // TODO Performance Killer $result = ContentDataObjects::getContentObjects(active_context(), $ot, $order_by_col, $order_by_asc ? "ASC" : "DESC", $allConditions); } $objects = $result->objects; $totalResults = $result->total; $results['pagination'] = Reports::getReportPagination($id, $params, $original_order_by_col, $order_by_asc, $offset, $limit, $totalResults); $dimensions_cache = array(); foreach ($report_columns as $column) { if ($column->getCustomPropertyId() == 0) { $field = $column->getFieldName(); if (str_starts_with($field, 'dim_')) { $dim_id = str_replace("dim_", "", $field); $dimension = Dimensions::getDimensionById($dim_id); $dimensions_cache[$dim_id] = $dimension; $column_name = $dimension->getName(); $results['columns'][$field] = $column_name; $results['db_columns'][$column_name] = $field; } else { if ($managerInstance->columnExists($field) || Objects::instance()->columnExists($field)) { $column_name = Localization::instance()->lang('field ' . $ot->getHandlerClass() . ' ' . $field); if (is_null($column_name)) { $column_name = lang('field Objects ' . $field); } $results['columns'][$field] = $column_name; $results['db_columns'][$column_name] = $field; } else { if ($ot->getHandlerClass() == 'Contacts') { if (in_array($field, $contact_extra_columns)) { $results['columns'][$field] = lang($field); $results['db_columns'][lang($field)] = $field; } } else { if ($ot->getHandlerClass() == 'Timeslots') { if (in_array($field, array('time', 'billing'))) { $results['columns'][$field] = lang('field Objects ' . $field); $results['db_columns'][lang('field Objects ' . $field)] = $field; } } else { if ($ot->getHandlerClass() == 'MailContents') { if (in_array($field, array('to', 'cc', 'bcc', 'body_plain', 'body_html'))) { $results['columns'][$field] = lang('field Objects ' . $field); $results['db_columns'][lang('field Objects ' . $field)] = $field; } } } } } } } else { $results['columns'][$column->getCustomPropertyId()] = $column->getCustomPropertyId(); } } $report_rows = array(); foreach ($objects as &$object) { /* @var $object Object */ $obj_name = $object->getObjectName(); $icon_class = $object->getIconClass(); $row_values = array('object_type_id' => $object->getObjectTypeId()); if (!$to_print) { $row_values['link'] = '<a class="link-ico ' . $icon_class . '" title="' . clean($obj_name) . '" target="new" href="' . $object->getViewUrl() . '"> </a>'; } foreach ($report_columns as $column) { if ($column->getCustomPropertyId() == 0) { $field = $column->getFieldName(); if (str_starts_with($field, 'dim_')) { $dim_id = str_replace("dim_", "", $field); if (!array_var($dimensions_cache, $dim_id) instanceof Dimension) { $dimension = Dimensions::getDimensionById($dim_id); $dimensions_cache[$dim_id] = $dimension; } else { $dimension = array_var($dimensions_cache, $dim_id); } $om_object_id = $object instanceof Timeslot ? $object->getRelObjectId() : $object->getId(); $members = ObjectMembers::getMembersByObjectAndDimension($om_object_id, $dim_id, " AND om.is_optimization=0"); $value = ""; foreach ($members as $member) { /* @var $member Member */ $val = $member->getPath(); $val .= ($val == "" ? "" : "/") . $member->getName(); if ($value != "") { $val = " - {$val}"; } $value .= $val; } $row_values[$field] = $value; } else { if ($object instanceof Timeslot) { if ($field == 'id') { $value = $object->getObjectId(); } else { $value = $object->getColumnValue($field); // if it is a task column if (in_array($field, ProjectTasks::instance()->getColumns())) { $task = ProjectTasks::findById($object->getRelObjectId()); // if task exists if ($task instanceof ProjectTask) { $value = $task->getColumnValue($field); // if it is an external task column if (in_array($field, ProjectTasks::instance()->getExternalColumns())) { $value = self::instance()->getExternalColumnValue($field, $value, ProjectTasks::instance()); } else { // if is a date then use format if (ProjectTasks::instance()->getColumnType($field) == DATA_TYPE_DATETIME && $value instanceof DateTimeValue) { $value = format_value_to_print($field, $value->toMySQL(), DATA_TYPE_DATETIME, $report->getReportObjectTypeId()); } } } $results['columns'][$field] = lang('field ProjectTasks ' . $field); $results['db_columns'][lang('field ProjectTasks ' . $field)] = $field; } } } else { $value = $object->getColumnValue($field); } if ($value instanceof DateTimeValue) { $dateFormat = user_config_option('date_format'); Hook::fire("custom_property_date_format", null, $dateFormat); $tz = logged_user()->getTimezone(); if ($object instanceof ProjectTask) { if ($field == 'due_date' && !$object->getUseDueTime() || $field == 'start_date' && !$object->getUseStartTime()) { $dateFormat = user_config_option('date_format'); $tz = 0; } } $value = format_date($value, $dateFormat, $tz * 3600); } if (in_array($field, $managerInstance->getExternalColumns())) { if ($object instanceof Timeslot && $field == 'time') { $lastStop = $object->getEndTime() != null ? $object->getEndTime() : ($object->isPaused() ? $object->getPausedOn() : DateTimeValueLib::now()); $seconds = $lastStop->getTimestamp() - $object->getStartTime()->getTimestamp(); $hours = number_format($seconds / 3600, 2, ',', '.'); $value = $hours; //$value = DateTimeValue::FormatTimeDiff($object->getStartTime(), $lastStop, "hm", 60, $object->getSubtract()); } else { if ($object instanceof Timeslot && $field == 'billing') { $value = config_option('currency_code', '$') . ' ' . $object->getFixedBilling(); } else { $value = self::instance()->getExternalColumnValue($field, $value, $managerInstance); } } } else { if ($field != 'link') { //$value = html_to_text(html_entity_decode($value)); if ($object->getColumnType($field) == DATA_TYPE_STRING) { // change html block end tags and brs to \n, then remove all other html tags, then replace \n with <br>, to remove all styles and keep the enters $value = str_replace(array("</div>", "</p>", "<br>", "<br />", "<br/>"), "\n", $value); $value = nl2br(strip_tags($value)); } } } if (self::isReportColumnEmail($value)) { if (logged_user()->hasMailAccounts()) { $value = '<a class="internalLink" href="' . get_url('mail', 'add_mail', array('to' => clean($value))) . '">' . clean($value) . '</a></div>'; } else { $value = '<a class="internalLink" target="_self" href="mailto:' . clean($value) . '">' . clean($value) . '</a></div>'; } } $row_values[$field] = $value; if ($ot->getHandlerClass() == 'Contacts') { if ($managerInstance instanceof Contacts) { $contact = Contacts::findOne(array("conditions" => "object_id = " . $object->getId())); if ($field == "email_address") { $row_values[$field] = $contact->getEmailAddress(); } if ($field == "is_user") { $row_values[$field] = $contact->getUserType() > 0 && !$contact->getIsCompany(); } if ($field == "im_values") { $str = ""; foreach ($contact->getAllImValues() as $type => $value) { $str .= ($str == "" ? "" : " | ") . "{$type}: {$value}"; } $row_values[$field] = $str; } if (in_array($field, array("mobile_phone", "work_phone", "home_phone"))) { if ($field == "mobile_phone") { $row_values[$field] = $contact->getPhoneNumber('mobile', null, false); } else { if ($field == "work_phone") { $row_values[$field] = $contact->getPhoneNumber('work', null, false); } else { if ($field == "home_phone") { $row_values[$field] = $contact->getPhoneNumber('home', null, false); } } } } if (in_array($field, array("personal_webpage", "work_webpage", "other_webpage"))) { if ($field == "personal_webpage") { $row_values[$field] = $contact->getWebpageUrl('personal'); } else { if ($field == "work_webpage") { $row_values[$field] = $contact->getWebpageUrl('work'); } else { if ($field == "other_webpage") { $row_values[$field] = $contact->getWebpageUrl('other'); } } } } if (in_array($field, array("home_address", "work_address", "other_address"))) { if ($field == "home_address") { $row_values[$field] = $contact->getStringAddress('home'); } else { if ($field == "work_address") { $row_values[$field] = $contact->getStringAddress('work'); } else { if ($field == "other_address") { $row_values[$field] = $contact->getStringAddress('other'); } } } } } } else { if ($ot->getHandlerClass() == 'MailContents') { if (in_array($field, array('to', 'cc', 'bcc', 'body_plain', 'body_html'))) { $mail_data = MailDatas::findById($object->getId()); $row_values[$field] = $mail_data->getColumnValue($field); if ($field == "body_html") { if (class_exists("DOMDocument")) { $d = new DOMDocument(); $mock = new DOMDocument(); $d->loadHTML(remove_css_and_scripts($row_values[$field])); $body = $d->getElementsByTagName('body')->item(0); foreach ($body->childNodes as $child) { $mock->appendChild($mock->importNode($child, true)); } // if css is inside an html comment => remove it $row_values[$field] = preg_replace('/<!--(.*)-->/Uis', '', remove_css($row_values[$field])); } else { $row_values[$field] = preg_replace('/<!--(.*)-->/Uis', '', remove_css_and_scripts($row_values[$field])); } } } } } if (!$to_print && $field == "name") { $row_values[$field] = '<a target="new-' . $object->getId() . '" href="' . $object->getViewUrl() . '">' . $value . '</a>'; } } } else { $colCp = $column->getCustomPropertyId(); $cp = CustomProperties::getCustomProperty($colCp); if ($cp instanceof CustomProperty) { /* @var $cp CustomProperty */ $row_values[$cp->getName()] = get_custom_property_value_for_listing($cp, $object); $results['columns'][$colCp] = $cp->getName(); $results['db_columns'][$cp->getName()] = $colCp; } } } Hook::fire("report_row", $object, $row_values); $report_rows[] = $row_values; } if (!$to_print) { if (is_array($results['columns'])) { array_unshift($results['columns'], ''); } else { $results['columns'] = array(''); } Hook::fire("report_header", $ot, $results['columns']); } $results['rows'] = $report_rows; } return $results; }
function format_value_to_print($col, $value, $type, $obj_type_id, $textWrapper = '', $dateformat = 'Y-m-d') { switch ($type) { case DATA_TYPE_STRING: if (preg_match(EMAIL_FORMAT, strip_tags($value))) { $formatted = strip_tags($value); } else { if ($col == 'is_user') { $formatted = $value == 1 ? lang('yes') : lang('no'); } else { if (strpos($value, "�") !== false) { $value = preg_replace('/\\xA0/s', ' ', $value); } $value = utf8_safe($value); $formatted = $textWrapper . $value . $textWrapper; } } break; case DATA_TYPE_INTEGER: if ($col == 'priority') { switch ($value) { case 100: $formatted = lang('low priority'); break; case 200: $formatted = lang('normal priority'); break; case 300: $formatted = lang('high priority'); break; case 400: $formatted = lang('urgent priority'); break; default: $formatted = clean($value); } } elseif ($col == 'time_estimate') { if ($value > 0) { $formatted = DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($value * 60), 'hm', 60); } else { $formatted = clean($value); } } else { $formatted = clean($value); } break; case DATA_TYPE_BOOLEAN: $formatted = $value == 1 ? lang('yes') : lang('no'); break; case DATA_TYPE_DATE: if ($value != 0) { if (str_ends_with($value, "00:00:00")) { $dateformat .= " H:i:s"; } try { $dtVal = DateTimeValueLib::dateFromFormatAndString($dateformat, $value); } catch (Exception $e) { $formatted = $value; } if (!isset($formatted)) { $formatted = format_date($dtVal, null, 0); } } else { $formatted = ''; } break; case DATA_TYPE_DATETIME: if ($value != 0) { try { $dtVal = DateTimeValueLib::dateFromFormatAndString("{$dateformat} H:i:s", $value); } catch (Exception $e) { $formatted = $value; } if ($dtVal instanceof DateTimeValue) { if ($obj_type_id == ProjectEvents::instance()->getObjectTypeId() || $obj_type_id == ProjectTasks::instance()->getObjectTypeId()) { $dtVal->advance(logged_user()->getTimezone() * 3600, true); } if ($obj_type_id == ProjectEvents::instance()->getObjectTypeId() && ($col == 'start' || $col == 'duration')) { $formatted = format_datetime($dtVal); } else { $formatted = format_date($dtVal, null, 0); } } } else { $formatted = ''; } break; default: $formatted = $value; } if ($formatted == '') { $formatted = '--'; } return $formatted; }
<?php $not_overdue_limit = 5; $overdue_limit = 20; $show_more = false; // Not due tasks $not_due_tasks = ProjectTasks::getUpcomingWithoutDate($not_overdue_limit + 1); if (count($not_due_tasks) > $not_overdue_limit) { $show_more = true; array_pop($not_due_tasks); } // Due Tasks $overdue_upcoming_objects = ProjectTasks::getOverdueAndUpcomingObjects($overdue_limit + 1); // FIXME: performance Killer if (count($overdue_upcoming_objects) > $overdue_limit) { $show_more = true; array_pop($overdue_upcoming_objects); } $overdue_upcoming_objects = array_merge($not_due_tasks, $overdue_upcoming_objects); $users = array(); // Render only when the context isnt 'all' and you have perms $render_add = active_context_members(false) && ProjectTask::canAdd(logged_user(), active_context()); if ($render_add) { $users[] = array(0, lang('dont assign')); foreach (allowed_users_to_assign() as $company) { foreach ($company['users'] as $user) { $name = logged_user()->getId() == $user['id'] ? lang('me') : $user['name']; $users[] = array($user['id'], $name); } } }
if (!(isset($tasks) || $userPreferences['groupBy'] == 'milestone')) { ?> <div style="font-size:130%;width:100%;text-align:center;padding-top:10px;color:#777;"><?php echo lang('no tasks to display'); ?> </div> <?php } ?> </div> </div> </div> <script type="text/javascript"> if (!ogTasks.tasks_object_type_id) ogTasks.tasks_object_type_id = '<?php echo ProjectTasks::instance()->getObjectTypeId(); ?> '; if (rx__TasksDrag) rx__TasksDrag.initialize(); ogTasks.userPreferences = Ext.util.JSON.decode(document.getElementById('hfUserPreferences').value); var mili = 0; if (og.TasksTopToolbar == 'undefined') { mili = 500; } // to prevent js execution before the js files are received setTimeout(function () { var ogTasksTT = new og.TasksTopToolbar({
/** * Return array of task that are assigned to specific user or his company * * @param User $user * @return array */ function getUsersTasks(User $user) { $task_lists = $this->getTaskLists(); if (!is_array($task_lists)) { return false; } // if $task_list_ids = array(); foreach ($task_lists as $task_list) { if (!$user->isMemberOfOwnerCompany() && $task_list->isPrivate()) { continue; } // if $task_list_ids[] = $task_list->getId(); } // if return ProjectTasks::findAll(array('conditions' => array('`task_list_id` IN (?) AND ((`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?) OR (`assigned_to_user_id` = ? AND `assigned_to_company_id` = ?)) AND `completed_on` = ?', $task_list_ids, $user->getId(), $user->getCompanyId(), 0, $user->getCompanyId(), 0, 0, EMPTY_DATETIME), 'order' => '`created_on`')); // findAll }
/** * List all templates * * @param void * @return null */ function task_templates() { if (!can_manage_templates(logged_user())) { flash_error(lang('no access permissions')); ajx_current("empty"); return; } // if tpl_assign('task_templates', ProjectTasks::getAllTaskTemplates()); }
<div id="tasksPanelContent" style="background-color:white;padding:7px;padding-top:0px;overflow-y:scroll;position:relative;"> <?php if (isset($displayTooManyTasks) && $displayTooManyTasks){ ?> <div class="tasksPanelWarning ico-warning32" style="font-size:10px;color:#666;background-repeat:no-repeat;padding-left:40px;max-width:920px; margin:20px;border:1px solid #E3AD00;background-color:#FFF690;background-position:4px 4px;"> <div style="font-weight:bold;width:99%;text-align:center;padding:4px;color:#AF8300;"><?php echo lang('too many tasks to display', user_config_option('task_display_limit')) ?></div> </div> <?php } ?> <div id="tasksPanelContainer" style="background-color:white;padding:7px;padding-top:0px;"> <?php if(!(isset($tasks) || $userPreferences['groupBy'] == 'milestone')) { ?> <div style="font-size:130%;width:100%;text-align:center;padding-top:10px;color:#777;"><?php echo lang('no tasks to display') ?></div> <?php } ?> </div> </div> </div> <script type="text/javascript"> if (!ogTasks.tasks_object_type_id) ogTasks.tasks_object_type_id = '<?php echo ProjectTasks::instance()->getObjectTypeId() ?>'; if (rx__TasksDrag) rx__TasksDrag.initialize(); ogTasks.userPreferences = Ext.util.JSON.decode(document.getElementById('hfUserPreferences').value); var mili = 0; if (og.TasksTopToolbar == 'undefined') { mili = 500; } // to prevent js execution before the js files are received setTimeout(function () { var ogTasksTT = new og.TasksTopToolbar({ projectTemplatesHfId:'hfProjectTemplates', allTemplatesHfId:'hfAllTemplates',
// beginning of the week, sunday } user_config_option('show_two_weeks_calendar', null, logged_user()->getId()) ? $my_weeks = 2 : ($my_weeks = 1); $endday = $startday + 7 * $my_weeks; $today = DateTimeValueLib::now()->add('h', logged_user()->getTimezone()); $currentday = $today->getDay(); $currentmonth = $today->getMonth(); $currentyear = $today->getYear(); $user_comp_filter = user_config_option('pending tasks widget assigned to filter'); $exploded = explode(":", $user_comp_filter); $user_filter_id = array_var($exploded, 1); $user_filter = $user_filter_id > 0 ? Users::findById($user_filter_id) : null; $date_start = new DateTimeValue(mktime(0, 0, 0, $currentmonth, $startday, $currentyear)); $date_end = new DateTimeValue(mktime(0, 0, 0, $currentmonth, $endday, $currentyear)); //FIXME $milestones = ProjectMilestones::getRangeMilestones($date_start, $date_end); $tmp_tasks = ProjectTasks::getRangeTasksByUser($date_start, $date_end, $user_filter); //FIXME $birthdays = array(); //Contacts::instance()->getRangeContactsByBirthday($date_start, $date_end); $tasks = array(); if ($tmp_tasks) { foreach ($tmp_tasks as $task) { $tasks = array_merge($tasks, replicateRepetitiveTaskForCalendar($task, $date_start, $date_end)); } } $use_24_hours = user_config_option('time_format_use_24'); if ($use_24_hours) { $timeformat = 'G:i'; } else { $timeformat = 'g:i A'; }