<?php echo select_task_priority('task[priority]', array_var($task_data, 'priority', ProjectTasks::PRIORITY_NORMAL), array('tabindex' => '90')) ?> </div> <?php if(array_var($task_data, 'time_estimate') == 0){?> <div style="padding-top:4px"> <?php echo label_tag(lang('percent completed')) ?> <?php echo input_field('task[percent_completed]', array_var($task_data, 'percent_completed', 0), array('tabindex' => '100', 'class' => 'short')) ?> </div> <?php }?> <?php if (config_option('use tasks dependencies')) { ?> <div style="padding-top:4px"> <?php echo label_tag(lang('previous tasks')) ?> <?php if (!$task->isNew()) $previous_tasks = ProjectTaskDependencies::findAll(array('conditions' => 'task_id = '.$task->getId())); else $previous_tasks = array(); ?> <div> <?php if (count($previous_tasks) == 0) { ?> <span id="<?php echo $genid?>no_previous_selected"><?php echo lang('none') ?></span> <script>if (!og.previousTasks) og.previousTasks = []; og.previousTasksIdx = og.previousTasks.length;</script> <?php } else { $k=0; ?> <script> og.previousTasks=[]; og.previousTasksIdx = '<?php echo count($previous_tasks)?>'; </script> <input type="hidden" name="task[clean_dep]" value="1" /> <?php foreach ($previous_tasks as $task_dep) {
function repetitive_task_related_edit($task, $task_data) { $was_template = $task->getIsTemplate(); $task->setFromAttributes($task_data); $task->setIsTemplate($was_template); // is_template value must not be changed from ui $totalMinutes = array_var($task_data, 'time_estimate_hours') * 60 + array_var($task_data, 'time_estimate_minutes'); $task->setTimeEstimate($totalMinutes); if ($task->getParentId() > 0 && $task->hasChild($task->getParentId())) { flash_error(lang('task child of child error')); ajx_current("empty"); return; } DB::beginWork(); $task->save(); $task->setObjectName(array_var($task_data, 'name')); $task->save(); // dependencies if (config_option('use tasks dependencies')) { $previous_tasks = array_var($task_data, 'previous'); if (is_array($previous_tasks)) { foreach ($previous_tasks as $ptask) { if ($ptask == $task->getId()) { continue; } $dep = ProjectTaskDependencies::findById(array('previous_task_id' => $ptask, 'task_id' => $task->getId())); if (!$dep instanceof ProjectTaskDependency) { $dep = new ProjectTaskDependency(); $dep->setPreviousTaskId($ptask); $dep->setTaskId($task->getId()); $dep->save(); } } $saved_ptasks = ProjectTaskDependencies::findAll(array('conditions' => 'task_id = ' . $task->getId())); foreach ($saved_ptasks as $pdep) { if (!in_array($pdep->getPreviousTaskId(), $previous_tasks)) { $pdep->delete(); } } } else { ProjectTaskDependencies::delete('task_id = ' . $task->getId()); } } // Add assigned user to the subscibers list if ($task->getAssignedToContactId() > 0 && Contacts::instance()->findById($task->getAssignedToContactId())) { if (!isset($_POST['subscribers'])) { $_POST['subscribers'] = array(); } $_POST['subscribers']['user_' . $task->getAssignedToContactId()] = 'checked'; } $object_controller = new ObjectController(); $object_controller->add_to_members($task, array_var($task_data, 'members')); $object_controller->add_subscribers($task); $object_controller->link_to_new_object($task); $object_controller->add_custom_properties($task); $object_controller->add_reminders($task); // apply values to subtasks $assigned_to = $task->getAssignedToContactId(); $subtasks = $task->getAllSubTasks(); $milestone_id = $task->getMilestoneId(); $apply_ms = array_var($task_data, 'apply_milestone_subtasks') == "checked"; $apply_at = array_var($task_data, 'apply_assignee_subtasks', '') == "checked"; foreach ($subtasks as $sub) { $modified = false; if ($apply_at || !($sub->getAssignedToContactId() > 0)) { $sub->setAssignedToContactId($assigned_to); $modified = true; } if ($apply_ms) { $sub->setMilestoneId($milestone_id); $modified = true; } if ($modified) { $sub->save(); } } $task->resetIsRead(); ApplicationLogs::createLog($task, ApplicationLogs::ACTION_EDIT); DB::commit(); }
/** * Open this task and check if we need to reopen list again * * @access public * @param void * @return null */ function openTask() { if (!$this->canChangeStatus(logged_user())) { flash_error('no access permissions'); ajx_current("empty"); return; } $this->setCompletedOn(null); $this->setCompletedById(0); $this->save(); $this->calculatePercentComplete(); $log_info = ""; if (config_option('use tasks dependencies')) { //Seeking the subscribers of the open task not to repeat in the notifications $contact_notification = array(); foreach ($this->getSubscribers() as $task_sub) { $contact_notification[] = $task_sub->getId(); } $saved_stasks = ProjectTaskDependencies::findAll(array('conditions' => 'previous_task_id = ' . $this->getId())); foreach ($saved_stasks as $sdep) { $stask = ProjectTasks::findById($sdep->getTaskId()); if ($stask instanceof ProjectTask && $stask->isCompleted()) { $stask->openTask(); } foreach ($stask->getSubscribers() as $task_dep) { if (!in_array($task_dep->getId(), $contact_notification)) { $log_info .= $task_dep->getId() . ","; } } } } /* * this is done in the controller $task_list = $this->getParent(); if(($task_list instanceof ProjectTask) && $task_list->isCompleted()) { $open_tasks = $task_list->getOpenSubTasks(); if(!empty($open_tasks)) $task_list->open(); } // if*/ ApplicationLogs::createLog($this, ApplicationLogs::ACTION_OPEN, false, false, true, substr($log_info, 0, -1)); }