function add()
 {
     $pt = DB::escape(array_var($_GET, 'pt'));
     $t = DB::escape(array_var($_GET, 't'));
     $dep = ProjectTaskDependencies::findOne(array('conditions' => "`previous_task_id` = {$pt} AND `task_id` = {$t}"));
     if (!$dep instanceof ProjectTaskDependency) {
         try {
             DB::beginWork();
             $dep = new ProjectTaskDependency();
             $dep->setPreviousTaskId(array_var($_GET, 'pt'));
             $dep->setTaskId(array_var($_GET, 't'));
             $dep->save();
             DB::commit();
         } catch (Exception $e) {
             flash_error($e->getMessage());
             DB::rollback();
         }
     }
     flash_success(lang('success add task dependency'));
     $reload = array_var($_GET, 'reload', true);
     if ($reload) {
         ajx_current("reload");
     } else {
         ajx_current("empty");
     }
 }
 /**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return ProjectTaskDependency 
  */
 function manager()
 {
     if (!$this->manager instanceof ProjectTaskDependencies) {
         $this->manager = ProjectTaskDependencies::instance();
     }
     return $this->manager;
 }
 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();
 }
 /**
  * When a task is completed, sends a notification to the assigned users of all the 
  * dependant tasks of the completed task to inform that the previous task has been completed.
  * @param $object The task that has been completed
  */
 static function notifyDependantTaskAssignedUsersOfTaskCompletion($object)
 {
     /* @var $object ProjectTask */
     $emails = array();
     // get dependant tasks
     $dependant_tasks = ProjectTaskDependencies::getDependantTasks($object->getId());
     // set sender user as the one who completed the task
     $sender = $object->getCompletedBy();
     if ($sender instanceof Contact) {
         $sendername = $sender->getObjectName();
         $senderemail = $sender->getEmailAddress();
     } else {
         return;
     }
     foreach ($dependant_tasks as $dep_task) {
         /* @var $dep_task ProjectTask */
         $assigned_user = $dep_task->getAssignedTo();
         // check that dependant task is assigned to a valid user
         if ($assigned_user instanceof Contact && $assigned_user->isUser()) {
             // check that all previous tasks are completed
             $all_previous_completed = true;
             $previous_tasks = ProjectTaskDependencies::getPreviousTasks($dep_task->getId());
             foreach ($previous_tasks as $pt) {
                 if ($pt->getId() == $object->getId()) {
                     continue;
                 }
                 if ($pt->getCompletedById() == 0) {
                     $all_previous_completed = false;
                     break;
                 }
             }
             // send the notification only if all previous tasks of this task are completed
             if ($all_previous_completed) {
                 // set notificated user localization
                 Localization::instance()->loadSettings($assigned_user->getLocale(), ROOT . '/language');
                 // format notification data
                 $assigned_by_name = $dep_task->getAssignedBy() instanceof Contact ? $dep_task->getAssignedBy()->getObjectName() : "";
                 $assigned_to_name = $dep_task->getAssignedToName();
                 tpl_assign('object', $dep_task);
                 tpl_assign('title', lang('task x can be started', $dep_task->getObjectName()));
                 tpl_assign('by', $assigned_by_name);
                 tpl_assign('asigned', $assigned_to_name);
                 tpl_assign('description', $dep_task->getDescription());
                 $contexts = self::buildContextObjectForNotification($dep_task);
                 tpl_assign('contexts', $contexts);
                 $priority_data = self::getTaskPriorityData($dep_task);
                 tpl_assign('priority', $priority_data);
                 $start_date = self::getTaskDateFormatted($dep_task, 'start_date', $assigned_user->getTimezone());
                 tpl_assign('start_date', $start_date);
                 $due_date = self::getTaskDateFormatted($dep_task, 'due_date', $assigned_user->getTimezone());
                 tpl_assign('due_date', $due_date);
                 $attachments = array();
                 $attachments['logo'] = self::getLogoAttachmentData($assigned_user->getEmailAddress());
                 tpl_assign('attachments', $attachments);
                 // send notification
                 $to_addresses = array();
                 $to_addresses[$assigned_user->getId()] = self::prepareEmailAddress($assigned_user->getEmailAddress(), $assigned_user->getObjectName());
                 $subject = lang('all previous tasks have been completed', $dep_task->getObjectName());
                 $recipients_field = config_option('notification_recipients_field', 'to');
                 $emails[] = array("{$recipients_field}" => $to_addresses, "from" => self::prepareEmailAddress($senderemail, $sendername), "subject" => $subject, "body" => tpl_fetch(get_template_path('previous_task_completed', 'notifier')), "attachments" => $attachments);
             }
         }
     }
     if (count($emails) > 0) {
         self::queueEmails($emails);
         $locale = logged_user() instanceof Contact ? logged_user()->getLocale() : DEFAULT_LOCALIZATION;
         Localization::instance()->loadSettings($locale, ROOT . '/language');
     }
 }
 function instantiate($arguments = null)
 {
     $selected_members = array();
     $id = array_var($arguments, '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($arguments, 'parameterValues', array_var($_POST, 'parameterValues'));
     if (count($parameters) > 0 && !isset($parameterValues)) {
         ajx_current("back");
         return;
     }
     $instantiation_id = 0;
     if (count($parameters) > 0) {
         $instantiation_id = $this->save_instantiated_parameters($template, $parameters, $parameterValues);
     }
     if (array_var($_POST, 'members') || array_var($arguments, 'members')) {
         $selected_members = array_var($arguments, 'members', json_decode(array_var($_POST, 'members')));
     } else {
         $context = active_context();
         foreach ($context as $selection) {
             if ($selection instanceof Member) {
                 $selected_members[] = $selection->getId();
             }
         }
     }
     if (array_var($_POST, 'additional_member_ids')) {
         $add_mem_ids = explode(',', array_var($_POST, 'additional_member_ids'));
         if (is_array($add_mem_ids)) {
             foreach ($add_mem_ids as $add_mem_id) {
                 if (is_numeric($add_mem_id)) {
                     $selected_members[] = $add_mem_id;
                 }
             }
         }
     }
     $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();
     $copies = array();
     $copiesIds = array();
     $dependencies = array();
     Hook::fire("verify_objects_before_template_instantiation", $template, $objects);
     foreach ($objects as $object) {
         if (!$object instanceof ContentDataObject) {
             continue;
         }
         // copy object
         if ($object instanceof TemplateTask) {
             //dependencies
             $ptasks = ProjectTaskDependencies::getDependenciesForTemplateTask($object->getId());
             if (!empty($ptasks)) {
                 foreach ($ptasks as $d) {
                     $dependencies[] = $d;
                 }
             }
             $copy = $object->copyToProjectTask($instantiation_id);
             //if is subtask
             if ($copy->getParentId() > 0) {
                 foreach ($copies as $c) {
                     if ($c instanceof ProjectTask) {
                         if ($c->getFromTemplateObjectId() == $object->getParentId()) {
                             $copy->setParentId($c->getId());
                         }
                     }
                 }
             }
         } else {
             if ($object instanceof TemplateMilestone) {
                 $copy = $object->copyToProjectMilestone();
             } else {
                 $copy = $object->copy(false);
                 if ($copy->columnExists('from_template_id')) {
                     $copy->setColumnValue('from_template_id', $object->getId());
                 }
             }
         }
         if ($copy->columnExists('is_template')) {
             $copy->setColumnValue('is_template', false);
         }
         $copy->save();
         $copies[] = $copy;
         $copiesIds[$object->getId()] = $copy->getId();
         $ret = null;
         Hook::fire('after_template_object_instantiation', array('template' => $template, 'original' => $object, 'copy' => $copy), $ret);
         /* Set instantiated object members:
          * 		if no member is active then the instantiated object is put in the same members as the original
          * 		if any members are selected then the instantiated object will be put in those members  
          */
         $template_object_members = $object->getMembers();
         $object_members = array();
         if (count($selected_members) == 0) {
             //change members according to context
             foreach ($active_context as $selection) {
                 if ($selection instanceof Member) {
                     // member selected
                     foreach ($template_object_members as $i => $object_member) {
                         if ($object_member instanceof Member && $object_member->getObjectTypeId() == $selection->getObjectTypeId()) {
                             unset($template_object_members[$i]);
                         }
                     }
                     $object_members[] = $selection->getId();
                 }
             }
         } else {
             $object_members = $selected_members;
         }
         foreach ($template_object_members as $object_member) {
             $object_members[] = $object_member->getId();
         }
         $controller->add_to_members($copy, $object_members);
         // set property values as defined in template
         instantiate_template_task_parameters($object, $copy, $parameterValues);
         // subscribe assigned to
         if ($copy instanceof ProjectTask) {
             foreach ($copy->getOpenSubTasks(false) as $m_task) {
                 if ($m_task->getAssignedTo() instanceof Contact) {
                     $m_task->subscribeUser($m_task->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($m_task->getAssignedTo());
                     }
                 }
             }
         }
     }
     foreach ($copies as $c) {
         if ($c instanceof ProjectTask) {
             if ($c->getMilestoneId() > 0) {
                 // find milestone in copies
                 foreach ($copies as $m) {
                     if ($m instanceof ProjectMilestone && $m->getFromTemplateObjectId() == $c->getMilestoneId()) {
                         $c->setMilestoneId($m->getId());
                         $c->save();
                         break;
                     }
                 }
             }
         }
     }
     //copy dependencies
     foreach ($dependencies as $dependencie) {
         if ($dependencie instanceof ProjectTaskDependency) {
             $dep = new ProjectTaskDependency();
             $dep->setPreviousTaskId($copiesIds[$dependencie->getPreviousTaskId()]);
             $dep->setTaskId($copiesIds[$dependencie->getTaskId()]);
             $dep->save();
         }
     }
     DB::commit();
     foreach ($copies as $c) {
         if ($c instanceof ProjectTask) {
             ApplicationLogs::createLog($c, ApplicationLogs::ACTION_ADD);
         }
     }
     if (is_array($parameters) && count($parameters) > 0) {
         ajx_current("back");
     } else {
         ajx_current("back");
     }
 }
示例#6
0
		<?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) {
 /**
  * Delete this task lists
  *
  * @access public
  * @param boolean $delete_childs
  * @return boolean
  */
 function delete($delete_children = true)
 {
     if ($delete_children) {
         $children = $this->getSubTasks();
         foreach ($children as $child) {
             $child->delete(true);
         }
     }
     ProjectTaskDependencies::delete('( task_id = ' . $this->getId() . ' OR previous_task_id = ' . $this->getId() . ')');
     TemplateObjects::removeObjectFromTemplates($this);
     $task_list = $this->getParent();
     if ($task_list instanceof TemplateTask) {
         $task_list->detachTask($this);
     }
     return parent::delete();
 }
 static function getArrayInfo($raw_data, $full = false)
 {
     $desc = "";
     if ($full) {
         if (config_option("wysiwyg_tasks")) {
             if ($raw_data['type_content'] == "text") {
                 $desc = nl2br(htmlspecialchars($raw_data['text']));
             } else {
                 $desc = purify_html(nl2br($raw_data['text']));
             }
         } else {
             if ($raw_data['type_content'] == "text") {
                 $desc = htmlspecialchars($raw_data['text']);
             } else {
                 $desc = html_to_text(html_entity_decode(nl2br($raw_data['text']), null, "UTF-8"));
             }
         }
     }
     $member_ids = ObjectMembers::instance()->getCachedObjectMembers($raw_data['id']);
     $tmp_task = new ProjectTask();
     $tmp_task->setObjectId($raw_data['id']);
     $tmp_task->setId($raw_data['id']);
     $tmp_task->setAssignedToContactId($raw_data['assigned_to_contact_id']);
     $result = array('id' => (int) $raw_data['id'], 'name' => $raw_data['name'], 'description' => $desc, 'members' => $member_ids, 'createdOn' => strtotime($raw_data['created_on']), 'createdById' => (int) $raw_data['created_by_id'], 'otype' => $raw_data['object_subtype'], 'percentCompleted' => (int) $raw_data['percent_completed'], 'memPath' => str_replace('"', "'", escape_character(json_encode($tmp_task->getMembersIdsToDisplayPath()))));
     if (isset($raw_data['isread'])) {
         $result['isread'] = $raw_data['isread'];
     }
     $result['multiAssignment'] = (int) array_var($raw_data, 'multi_assignment');
     if ($raw_data['completed_by_id'] > 0) {
         $result['status'] = 1;
     }
     if ($raw_data['parent_id'] > 0) {
         $result['parentId'] = (int) $raw_data['parent_id'];
     }
     $result['subtasksIds'] = $tmp_task->getSubTasksIds();
     //if ($this->getPriority() != 200)
     $result['priority'] = (int) $raw_data['priority'];
     if ($raw_data['milestone_id'] > 0) {
         $result['milestoneId'] = (int) $raw_data['milestone_id'];
     }
     if ($raw_data['assigned_by_id'] > 0) {
         $result['assignedById'] = (int) $raw_data['assigned_by_id'];
     }
     if ($raw_data['assigned_to_contact_id'] > 0) {
         $result['assignedToContactId'] = (int) $raw_data['assigned_to_contact_id'];
     }
     $result['atName'] = $tmp_task->getAssignedToName();
     if ($raw_data['completed_by_id'] > 0) {
         $result['completedById'] = (int) $raw_data['completed_by_id'];
         $result['completedOn'] = strtotime($raw_data['completed_on']);
     }
     if ($raw_data['due_date'] != EMPTY_DATETIME) {
         $result['useDueTime'] = $raw_data['use_due_time'] ? 1 : 0;
         if ($result['useDueTime']) {
             $result['dueDate'] = strtotime($raw_data['due_date']) + logged_user()->getTimezone() * 3600;
         } else {
             $result['dueDate'] = strtotime($raw_data['due_date']);
         }
     }
     if ($raw_data['start_date'] != EMPTY_DATETIME) {
         $result['useStartTime'] = $raw_data['use_start_time'] ? 1 : 0;
         if ($result['useStartTime']) {
             $result['startDate'] = strtotime($raw_data['start_date']) + logged_user()->getTimezone() * 3600;
         } else {
             $result['startDate'] = strtotime($raw_data['start_date']);
         }
     }
     $time_estimate = $raw_data['time_estimate'];
     $result['timeEstimate'] = $raw_data['time_estimate'];
     if ($time_estimate > 0) {
         $result['timeEstimateString'] = str_replace(',', ',<br>', DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($time_estimate * 60), 'hm', 60));
     }
     $result['timeZone'] = logged_user()->getTimezone() * 3600;
     $ot = $tmp_task->getOpenTimeslots();
     if ($ot) {
         $users = array();
         $time = array();
         $paused = array();
         foreach ($ot as $t) {
             if (!$t instanceof Timeslot) {
                 continue;
             }
             $time[] = $t->getSeconds();
             $users[] = $t->getContactId();
             $paused[] = $t->isPaused() ? 1 : 0;
             if ($t->isPaused() && $t->getContactId() == logged_user()->getId()) {
                 $result['pauseTime'] = $t->getPausedOn()->getTimestamp();
             }
         }
         $result['workingOnTimes'] = $time;
         $result['workingOnIds'] = $users;
         $result['workingOnPauses'] = $paused;
     }
     $total_minutes = $tmp_task->getTotalMinutes();
     if ($total_minutes > 0) {
         $result['worked_time'] = $total_minutes;
         $result['worked_time_string'] = str_replace(',', ',<br>', DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($total_minutes * 60), 'hm', 60));
     } else {
         $result['worked_time'] = 0;
     }
     $pending_time = $time_estimate - $total_minutes;
     if ($pending_time > 0) {
         $result['pending_time'] = $pending_time;
         $result['pending_time_string'] = str_replace(',', ',<br>', DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($pending_time * 60), 'hm', 60));
     } else {
         $result['pending_time'] = 0;
     }
     if ($raw_data['repeat_forever'] > 0 || $raw_data['repeat_num'] > 0 || $raw_data['repeat_end'] != EMPTY_DATETIME && $raw_data['repeat_end'] != '') {
         $result['repetitive'] = 1;
     }
     $tmp_members = array();
     if (count($member_ids) > 0) {
         $tmp_members = Members::findAll(array("conditions" => "id IN (" . implode(',', $member_ids) . ")"));
     }
     $result['can_add_timeslots'] = can_add_timeslots(logged_user(), $tmp_members);
     //tasks dependencies
     if (config_option('use tasks dependencies')) {
         //get all dependant tasks ids, not completed yet
         $pending_tasks_ids = ProjectTaskDependencies::getDependenciesForTaskOnlyPendingIds($tmp_task->getId());
         //get the total of previous tasks
         $result['dependants'] = $pending_tasks_ids;
         $result['previous_tasks_total'] = ProjectTaskDependencies::countPendingPreviousTasks($tmp_task->getId());
     }
     return $result;
 }
 /**
 * Return manager instance
 *
 * @access protected
 * @param void
 * @return ProjectTaskDependency 
 */
 function manager() {
   if(!($this->manager instanceof ProjectTaskDependencies )) $this->manager =  ProjectTaskDependencies::instance();
   return $this->manager;
 } // manager
示例#10
0
	/**
	 * 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));
	} // openTask
 /**
 * 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, 'ProjectTaskDependencies')) {
     return parent::paginate($arguments, $items_per_page, $current_page);
   } else {
     return  ProjectTaskDependencies::instance()->paginate($arguments, $items_per_page, $current_page);
     //$instance =&  ProjectTaskDependencies::instance();
     //return $instance->paginate($arguments, $items_per_page, $current_page);
   } // if
 } // paginate
示例#12
0
<div class="adminMainBlock">
<table><tr><th><?php echo lang('task') ?></th><th><?php echo lang('status') ?></th><th><?php echo lang('actions') ?></th><th></th></tr>
<?php
	$row_cls = "dashAltRow";
	foreach ($previous_tasks as $pt) {
		$ptask = ProjectTasks::findById($pt->getPreviousTaskId());
		if (!$ptask instanceof ProjectTask) {
			$pt->delete();
			continue;
		}
		$status_cls = $ptask->isCompleted() ? "og-wsname-color-24" : "og-wsname-color-18";
		$incomplete_previous += $ptask->isCompleted() ? 0 : 1;
		$task_link = get_url('task','view',array('id'=>$ptask->getId()));
		
		$ptask_deps = ProjectTaskDependencies::getDependenciesForTask($ptask->getId());
		$all_dep_completed = true;
		foreach ($ptask_deps as $pt_dep) {
			$pptask = ProjectTasks::findById($pt_dep->getPreviousTaskId());
			if (!$pptask->isCompleted()) {
				$all_dep_completed = false;
				break;
			}
		}
		if (!$all_dep_completed) $status_cls = "og-wsname-color-19";
		$row_cls = $row_cls == "" ? "dashAltRow" : "";
?>
	<tr class="<?php echo $row_cls ?>">
		<td style="padding:2px 10px;">
			<a class="internalLink coViewAction ico-task" href="<?php echo $task_link ?>"><?php echo $ptask->getTitle() ?></a>
		</td><td style="padding:2px 10px;">
 /**
  * Delete this task lists
  *
  * @access public
  * @param boolean $delete_childs
  * @return boolean
  */
 function delete($delete_children = true)
 {
     if ($delete_children) {
         $children = $this->getSubTasks();
         foreach ($children as $child) {
             $child->setDontMakeCalculations($this->getDontMakeCalculations());
             $child->delete(true);
         }
     }
     ProjectTaskDependencies::delete('( task_id = ' . $this->getId() . ' OR previous_task_id = ' . $this->getId() . ')');
     $task_list = $this->getParent();
     if ($task_list instanceof ProjectTask) {
         $task_list->detachTask($this);
     }
     return parent::delete();
 }