/**
  * AjaxTaskController constructor.
  * @param Site $site Site object
  * @param array $post $_POST
  * @param array $session $_SESSION
  */
 public function __construct(Site $site, $post, &$session)
 {
     $tasks = new Tasks($site);
     if (isset($post['getTask'])) {
         $id = strip_tags($post['id']);
         $task = $tasks->getTaskById($id);
         if ($task !== null) {
             $this->result = json_encode(array('ok' => true, 'title' => $task->getTitle(), 'notes' => $task->getNotes(), 'priority' => $task->getPriority(), 'day' => $task->getDay()));
             return;
         }
         $this->result = json_encode(array('ok' => false, 'message' => 'Task not found'));
     }
 }
Example #2
0
 public function executeGoto(sfWebRequest $request)
 {
     $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');
     $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') . "'");
     }
     $q = Tasks::addFiltersToQuery($q, $this->getUser()->getAttribute('tasks_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : '')));
     $q = app::addListingOrder($q, 'tasks', $this->getUser(), (int) $request->getParameter('projects_id'));
     $this->menu = array();
     $tasks_ids = array();
     foreach ($q->fetchArray() as $tasks) {
         if (strlen($sn = app::getArrayName($tasks, 'TasksStatus')) > 0) {
             $sn = $sn . ': ';
         } else {
             $sn = '';
         }
         if ($request->getParameter('tasks_id') == $tasks['id']) {
             $tasks['name'] = '<b>' . $tasks['name'] . '</b>';
         }
         $this->menu[] = array('title' => $sn . $tasks['name'], 'url' => 'tasksComments/index?projects_id=' . $request->getParameter('projects_id') . '&tasks_id=' . $tasks['id']);
         $tasks_ids[] = $tasks['id'];
     }
     $current_key = array_search($request->getParameter('tasks_id'), $tasks_ids);
     $this->previous_tasks_id = false;
     $this->next_tasks_id = false;
     if (isset($tasks_ids[$current_key - 1])) {
         $this->previous_tasks_id = $tasks_ids[$current_key - 1];
     }
     if (isset($tasks_ids[$current_key + 1])) {
         $this->next_tasks_id = $tasks_ids[$current_key + 1];
     }
 }
Example #3
0
/**
 * Handle on prepare project overview event
 *
 * @param NamedList $tabs
 * @param User $logged_user
 * @param Project $project
 * @param array $tabs_settings
 * @param string $interface
 */
function frosso_project_tab_handle_on_project_tabs(&$tabs, &$logged_user, &$project, &$tabs_settings, $interface)
{
    if ($interface == AngieApplication::INTERFACE_DEFAULT && Tasks::canAccess($logged_user, $project, false) && in_array('fred_pt', $tabs_settings)) {
        $tabs->addBefore('fred_pt', array('text' => "Fred PT", 'url' => Router::assemble('frosso_tab_route', array('project_slug' => $project->getSlug())), 'icon' => $interface == AngieApplication::INTERFACE_DEFAULT ? AngieApplication::getImageUrl('icons/16x16/tasks-tab-icon.png', TASKS_MODULE) : AngieApplication::getImageUrl('icons/listviews/tasks.png', TASKS_MODULE, AngieApplication::INTERFACE_PHONE)), 'calendar');
    }
    // if
}
Example #4
0
 public function post_uncheck_task()
 {
     $data = Input::all();
     Tasks::where(array('id' => $data['uncheck_task'], 'user_id' => Auth::id()))->update(array('status' => 0, 'updated_at' => new DateTime()));
     $updated_task = Tasks::where(array('id' => $data['uncheck_task'], 'user_id' => Auth::id()))->first();
     return array('task_name' => $updated_task->task_name);
 }
 /**
  * Funzione per ritornare il task array con delle informazioni in più
  */
 private static function getDescribedTaskArray(DBResult $result, Project $active_project, User $logged_user, $items_limit = null)
 {
     $return_value = Tasks::getDescribedTaskArray($result, $active_project, $logged_user, $items_limit);
     // a new array is created
     $nuovo_ritorno = array();
     if ($result instanceof DBResult) {
         $id_assegnatari = array();
         foreach ($result as $row) {
             if ($row['assignee_id'] && !in_array($row['assignee_id'], $id_assegnatari)) {
                 $id_assegnatari[] = $row['assignee_id'];
             }
             //if
         }
         $assegnatari_array = count($id_assegnatari) ? Users::findByIds($id_assegnatari)->toArrayIndexedBy('getId') : array();
         // Referenza &, non c'è copia.
         // Per ognuno aggiungo l'assignee e la data di aggiornamento
         foreach ($return_value as $chiave => &$task) {
             foreach ($result as $row) {
                 //copio i vecchi valori
                 foreach ($task as $k => $v) {
                     $nuovo_ritorno[$chiave][$k] = $v;
                 }
                 //scorro tutto l'array dei risultati per ottenere la riga con il risultato corretto
                 if ($row['id'] == $task['id']) {
                     $nuovo_ritorno[$chiave]['assignee_id'] = $row['assignee_id'] ? $assegnatari_array[$row['assignee_id']] : null;
                     $nuovo_ritorno[$chiave]['updated_on'] = $row['updated_on'] ? datetimeval($row['updated_on']) : $row['created_on'];
                 }
             }
         }
     }
     // if
     return $nuovo_ritorno;
 }
Example #6
0
 public function task_Management()
 {
     $data['task'] = Tasks::getThemAll();
     $data['vaccine'] = Vaccines::getThemAll();
     $data['content_view'] = "add_task_view";
     $data['title'] = "New task";
     $this->base_params($data);
 }
Example #7
0
 public function run()
 {
     Model::unguard();
     $times = 5;
     for ($i = 0; $i < $times; $i++) {
         Tasks::create(array('name' => Str::random(), 'active' => rand(0, 1)));
     }
 }
Example #8
0
 public static function get_instance()
 {
     if (!isset(self::$instance)) {
         $object = __CLASS__;
         self::$instance = new $object();
     }
     return self::$instance;
 }
Example #9
0
 public function rememberWork()
 {
     $table = new Tasks();
     $select = $table->select()->where('Server = ?', $this->session->id)->order('Created DESC')->limit(2);
     $rows = $table->fetchAll($select);
     $count = count($rows);
     if ($count > 0) {
         $this->view->message .= '<div class = "notice">';
         $i = 0;
         foreach ($rows as $row) {
             $date = new Zend_Date($row->Created);
             $this->view->message .= '<strong><u>Liste des tâches du ' . $date . '</u></strong><br />' . nl2br($row->Message);
             if (++$i < $count) {
                 $this->view->message .= '<br /><br />';
             }
         }
         $this->view->message .= '</div>';
     } else {
         //$this->view->message .= '<div class = "notice">Aucune tâche pour le moment</div>';
     }
 }
 public function actionMilestonesPending()
 {
     $Milestones = Milestones::model()->MilestoneWithPendingTasks();
     foreach ($Milestones as $milestone) {
         $Tasks = Tasks::model()->findTaskByMilestone($milestone->milestone_id);
         $str = CBaseController::renderInternal(Yii::app()->params['templatesPath'] . '/milestones/overdueMilestones.php', array('user' => $milestone->Users->completeName, 'tasks' => $Tasks, 'applicationName' => Yii::app()->name, 'applicationUrl' => "http://localhost/celestic/" . Yii::app()->request->baseUrl), true);
         $subject = Yii::t('email', 'overdueMilestone');
         Yii::import('application.extensions.phpMailer.yiiPhpMailer');
         $mailer = new yiiPhpMailer();
         $mailer->pushMail($subject, $str, array('name' => $milestone->Users->CompleteName, 'email' => $milestone->Users->user_email), Emails::PRIORITY_NORMAL);
     }
 }
 /**
  * Prepare controller
  */
 function __before()
 {
     parent::__before();
     if (!Tasks::canAccess($this->logged_user, $this->active_project)) {
         $this->response->forbidden();
     }
     // if
     // load project tabs
     //$project_tabs = $this->active_project->getTabs($this->logged_user, AngieApplication::INTERFACE_DEFAULT);
     $this->wireframe->tabs->setCurrentTab('fred_pt');
     $this->wireframe->breadcrumbs->add('frosso_tab_route', lang('FRed tab'), Router::assemble('frosso_tab_route', array('project_slug' => $this->active_project->getSlug())));
 }
Example #12
0
 protected function createDefaultFilter()
 {
     parent::createDefaultFilter();
     //add case_id filter
     $node = $this->lastNode;
     while (!$node instanceof Dbnode && !empty($node->parent)) {
         $node = $node->parent;
     }
     if ($node instanceof Dbnode) {
         $this->fq[] = 'pids:' . $node->id;
     }
 }
Example #13
0
 public function executeListing(sfWebRequest $request)
 {
     if (!isset($this->reports_id)) {
         $this->reports_id = false;
     }
     $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');
     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') . "'");
         }
     }
     if ($this->reports_id > 0) {
         $q = UserReports::addFiltersToQuery($q, $this->reports_id, $this->getUser()->getAttribute('id'));
     } elseif ($request->hasParameter('search')) {
         $q = app::addSearchQuery($q, $request->getParameter('search'), 'TasksComments', 't', $request->getParameter('search_by_extrafields'));
         $q = app::addListingOrder($q, 'tasks', $this->getUser());
     } else {
         $q = Tasks::addFiltersToQuery($q, $this->getUser()->getAttribute('tasks_filter' . ((int) $request->getParameter('projects_id') > 0 ? $request->getParameter('projects_id') : '')));
         $q = app::addListingOrder($q, 'tasks', $this->getUser(), (int) $request->getParameter('projects_id'));
     }
     $this->pager = false;
     if (sfConfig::get('app_rows_limit') > 0) {
         $this->pager = new sfDoctrinePager('Tasks', sfConfig::get('app_rows_limit'));
         $this->pager->setQuery($q);
         $this->pager->setPage($request->getParameter('page', 1));
         $this->pager->init();
     }
     $this->tasks_list = $q->fetchArray();
     if (isset($this->is_dashboard)) {
         $this->url_params = 'redirect_to=dashboard';
         $this->display_insert_button = true;
     } elseif ($this->reports_id > 0) {
         $this->url_params = 'redirect_to=userReports' . $this->reports_id;
         $this->display_insert_button = true;
     } else {
         $this->url_params = 'redirect_to=tasksList';
         if ($request->hasParameter('projects_id')) {
             $this->url_params = 'projects_id=' . $request->getParameter('projects_id');
         }
         $this->display_insert_button = true;
     }
     $this->tlId = rand(1111111, 9999999);
     $this->users_schema = Users::getSchema();
 }
Example #14
0
 public function executeIndex(sfWebRequest $request)
 {
     $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->forward404Unless($this->tasks = Doctrine_Core::getTable('Tasks')->createQuery()->addWhere('id=?', $request->getParameter('tasks_id'))->addWhere('projects_id=?', $request->getParameter('projects_id'))->fetchOne(), sprintf('Object tasks does not exist (%s).', $request->getParameter('id')));
     $this->checkProjectsAccess($this->projects);
     $this->checkTasksAccess('view', $this->tasks, $this->projects);
     if (!$this->getUser()->hasAttribute('tasks_filter' . $request->getParameter('projects_id'))) {
         $this->getUser()->setAttribute('tasks_filter' . $request->getParameter('projects_id'), Tasks::getDefaultFilter($request, $this->getUser()));
     }
     $this->tasks_comments = Doctrine_Core::getTable('TasksComments')->createQuery('tc')->leftJoin('tc.Users u')->addWhere('tc.tasks_id=?', $request->getParameter('tasks_id'))->orderBy('tc.created_at desc')->fetchArray();
     $this->more_actions = $this->getMoreActions($request);
     app::setPageTitle(t::__('Task') . ' | ' . ($this->tasks->getTasksLabelId() > 0 ? $this->tasks->getTasksLabels()->getName() . ': ' : '') . $this->tasks->getName(), $this->getResponse());
 }
Example #15
0
    public function present()
    {
        $html = '<form class="tasksForm">';
        $tasks = new Tasks($this->site);
        $days = new Days($this->site);
        $userId = $this->session[User::SESSION_NAME]->getId();
        for ($i = 1; $i <= 7; $i++) {
            $day = $days->getDayName($i);
            $html .= '<div class="day"><a href=""><img src="images/plus.png" alt="Add button"></a>
			<h2>' . $day . '</h2><p class="message">&nbsp;</p>';
            $taskList = $tasks->getTasksByDay($userId, $i);
            if ($taskList !== null) {
                $html .= '<div class="day-tasks"><ul class="day-list">';
                foreach ($taskList as $taskItem) {
                    $html .= '<li><a href="">' . $taskItem['title'] . '</a><input type="hidden" name="taskId" value="' . $taskItem['id'] . '"/><input type="hidden" name="taskPriority" value="' . $taskItem['priority'] . '"/></li>';
                }
                $html .= '</ul></div>';
            }
            $html .= '</div>';
        }
        $html .= '<div class="clear"></div></form>';
        return $html;
    }
/**
 * @param Project $project
 * @param Milestone $milestone
 * @param User $user
 * @param NamedList $sections
 * @param string $interface
 */
function frosso_handle_on_milestone_sections(&$project, &$milestone, &$user, &$sections, $interface)
{
    //uncomment these lines to add a new tab, instead
    if (Tasks::canAccess($user, $project)) {
        Router::assemble('milestone_tasks', array('project_slug' => $project->getSlug(), 'milestone_id' => $milestone->getId()));
        //   		$section = array(
        //         'text' => lang('FRed'),
        //         'url' => Router::assemble('tasks_frosso', array('project_slug' => $project->getSlug(), 'milestone_id' => $milestone->getId())),
        //         'options' => array(),
        //       );
        //       $sections->add('frosso', $section);
    }
    // if
}
Example #17
0
 public static function reindex_concept($args)
 {
     $taxon_concept_id = $args['taxon_concept_id'];
     if (!$taxon_concept_id || !is_numeric($taxon_concept_id)) {
         throw new \Exception("The TaxonConceptID was missing or was not a number");
         return;
     }
     Tasks::update_taxon_concept_names(array($taxon_concept_id));
     $he = new FlattenHierarchies();
     $he->flatten_hierarchies_from_concept_id($taxon_concept_id);
     TaxonConcept::reindex_descendants_objects($taxon_concept_id);
     TaxonConcept::reindex_for_search($taxon_concept_id);
     TaxonConcept::unlock_classifications_by_id($taxon_concept_id);
 }
Example #18
0
 public function __construct(Site $site, &$session, $post)
 {
     $tasks = new Tasks($site);
     $user = $session[User::SESSION_NAME];
     $root = $site->getRoot();
     if (isset($post['add'])) {
         $day = strip_tags($post['day']);
         $title = strip_tags($post['title']);
         $notes = strip_tags($post['notes']);
         $notes = $notes === null ? '' : $notes;
         $priority = strip_tags($post['priority']);
         $row = array("id" => 0, "day" => $day, "title" => $title, "notes" => $notes, "priority" => $priority);
         $task = new Task($row);
         $tasks->addTask($user->getId(), $task);
         $this->redirect = "/tasks.php";
         return;
     }
     if (isset($post['edit'])) {
         $id = strip_tags($post['id']);
         $day = strip_tags($post['day']);
         $title = strip_tags($post['title']);
         $notes = strip_tags($post['notes']);
         $notes = $notes === null ? '' : $notes;
         $priority = strip_tags($post['priority']);
         $row = array("id" => $id, "day" => $day, "title" => $title, "notes" => $notes, "priority" => $priority);
         $task = new Task($row);
         $tasks->updateTask($user->getId(), $task);
         $this->redirect = "/tasks.php";
         return;
     }
     if (isset($post['delete'])) {
         $id = strip_tags($post['id']);
         $tasks->deleteTask($user->getId(), $id);
         $this->redirect = "/tasks.php";
         return;
     }
 }
function check_user_permission($task_id_or_value)
{
    if (empty(PA::$login_uid)) {
        return FALSE;
    }
    if (is_numeric($task_id_or_value)) {
        $task_id = $task_id_or_value;
    } else {
        $task_id = Tasks::get_id_from_task_value($task_id_or_value);
    }
    if (empty($task_id)) {
        throw new PAException(INVALID_ID, "Invalid task ID or value: " . print_r($task_id_or_value, TRUE));
    }
    return Roles::check_permission(PA::$login_uid, $task_id);
}
Example #20
0
 function adhocAssignUsersk($params)
 {
     G::LoadClass('groups');
     G::LoadClass('tasks');
     $oTasks = new Tasks();
     $aAux = $oTasks->getGroupsOfTask($_SESSION['TASK'], 2);
     $aAdhocUsers = array();
     $oGroups = new Groups();
     foreach ($aAux as $aGroup) {
         $aUsers = $oGroups->getUsersOfGroup($aGroup['GRP_UID']);
         foreach ($aUsers as $aUser) {
             if ($aUser['USR_UID'] != $_SESSION['USER_LOGGED']) {
                 $aAdhocUsers[] = $aUser['USR_UID'];
             }
         }
     }
     $aAux = $oTasks->getUsersOfTask($_SESSION['TASK'], 2);
     foreach ($aAux as $aUser) {
         if ($aUser['USR_UID'] != $_SESSION['USER_LOGGED']) {
             $aAdhocUsers[] = $aUser['USR_UID'];
         }
     }
     require_once 'classes/model/Users.php';
     $oCriteria = new Criteria('workflow');
     $oCriteria->addSelectColumn(UsersPeer::USR_UID);
     $oCriteria->addSelectColumn(UsersPeer::USR_FIRSTNAME);
     $oCriteria->addSelectColumn(UsersPeer::USR_LASTNAME);
     $oCriteria->add(UsersPeer::USR_UID, $aAdhocUsers, Criteria::IN);
     $oDataset = UsersPeer::doSelectRS($oCriteria);
     $oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
     $aData = array();
     while ($oDataset->next()) {
         $aData[] = $oDataset->getRow();
     }
     $this->data = $aData;
 }
 public static function update_concept($taxon_concept_id)
 {
     if (!$taxon_concept_id || !is_numeric($taxon_concept_id)) {
         echo "\n\n\t#update_concept([taxon_concept_id])\n\n";
         return false;
     }
     $taxon_concept = TaxonConcept::find($taxon_concept_id);
     Tasks::update_taxon_concept_names($taxon_concept_id);
     $he = new FlattenHierarchies();
     $he->flatten_hierarchies_from_concept_id($taxon_concept_id);
     // make sure hierarchy info is up-to-date
     TaxonConcept::reindex_descendants_objects($taxon_concept_id);
     // make sure objects are indexed for display
     TaxonConcept::reindex_for_search($taxon_concept_id);
     // make sure objects are indexed for search
 }
Example #22
0
 function actionUpdateScheduleTask()
 {
     if (isset($_POST['task_id'])) {
         $task_id = $_POST['task_id'];
         $task_start = $_POST['task_start'];
         $task_end = $_POST['task_end'];
         $model = Tasks::model()->updateSheduleTask($task_id, $task_start, $task_end);
         if ($model) {
             echo '{"status":"success"}';
         } else {
             echo '{"status":"fail"}';
         }
     } else {
         echo '{"status":"fail"}';
     }
 }
Example #23
0
 public function getCategoryOpts()
 {
     // Check if we loaded data already
     if (!is_array(self::$category_opts)) {
         $q = 'SELECT * FROM categories ORDER BY category';
         // Run query and retrieve records (query, bindings, useMaster, fetchAll)
         $qresult = $this->basecoat->db->select($q, null, false, true);
         if ($qresult >= 0) {
             self::$category_opts = $this->basecoat->db->selectResult;
         } else {
             // Something went wrong
             $this->logError($qresult . ' ' . $this->basecoat->db->errorMsg . ' :: ' . $q);
             return $qresult;
         }
     }
     return self::$category_opts;
 }
 function generate_inner_html()
 {
     switch ($this->mode) {
         default:
             $inner_template = dirname(__FILE__) . '/center_inner_private.tpl';
     }
     $inner_html_gen =& new Template($inner_template);
     $role = new Roles();
     $this->links = $role->get_multiple();
     $inner_html_gen->set('links', $this->links);
     $task = Tasks::get_instance();
     $tasklist = $task->get_tasks();
     $inner_html_gen->set('tasklist', $tasklist);
     $inner_html_gen->set('super_user_and_mothership', @$this->super_user_and_mothership);
     $inner_html_gen->set('config_navigation_url', network_config_navigation('manage_tasks_relationship'));
     $inner_html = $inner_html_gen->fetch();
     return $inner_html;
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     //启动之前先检查进程是否还活着,如果还活着咱就退 windows 下 tasklist  /fi "PID eq xxxx"
     if (file_exists($this->filelock) && function_exists('posix_kill') && posix_kill(intval(file_get_contents($this->filelock)), 0)) {
         die("pid exists,exit");
     }
     file_put_contents($this->filelock, getmypid());
     Tasks::where("status", "execute")->update(array("status" => "created"));
     while (true) {
         //获取任务,执行任务
         $tasks = Tasks::where('status', 'created')->lists('id');
         foreach ($tasks as $_id) {
             //TaskHelper
             Task::run($_id);
         }
         sleep(1);
     }
 }
Example #26
0
 public function testEditTask()
 {
     $t = new Tasks();
     $t->add_task('titre', 'description', 'toto');
     $tasks = $t->get_tasks();
     $t->edit_task(count($tasks) - 1, 'titre2', 'description2', 'toto2', 1);
     $tasks = $t->get_tasks();
     $this->assertEquals($tasks[count($tasks) - 1]['title'], 'titre2');
     $this->assertEquals($tasks[count($tasks) - 1]['description'], 'description2');
     $this->assertEquals($tasks[count($tasks) - 1]['user'], 'toto2');
     $this->assertEquals($tasks[count($tasks) - 1]['state'], 1);
     $t->remove_task(count($tasks) - 1);
 }
Example #27
0
 /**
  * 
  * 针对一个任务,调用适当方法进行处理,处理后回写执行结果
  * 任务种类 'checkout', 'update', 'delete', 'rsync'
  * 
  */
 public function run($task_id)
 {
     $task = \Tasks::find($task_id);
     if ($task->status != 'created') {
         return $this->err('供执行的任务必须是初始状态');
     }
     //TODO 检查前置任务pre_task 的状态
     if ($task->pre_task && $task->pre->status != 'success') {
         return $this->err('前置任务尚未完成');
     }
     $task->status = 'execute';
     $task->execute_time = date('Y-m-d H:i:s');
     $task->save();
     $func = '_run' . ucfirst($task->type);
     $result = $this->{$func}($task);
     $task->output = $result['output'];
     $task->status = $result['result'] ? 'success' : 'failed';
     $task->save();
 }
 function generate_inner_html()
 {
     switch ($this->mode) {
         default:
             $inner_template = PA::$blockmodule_path . '/' . get_class($this) . '/center_inner_private.tpl';
     }
     $inner_html_gen = new Template($inner_template);
     $role = new Roles();
     $params = array('sort_by' => 'id', 'direction' => 'ASC', 'cnt' => false);
     $this->links = $role->get_multiple($params);
     $inner_html_gen->set('links', $this->links);
     $task = Tasks::get_instance();
     $tasklist = $task->get_tasks();
     $inner_html_gen->set('tasklist', $tasklist);
     $inner_html_gen->set('super_user_and_mothership', @$this->super_user_and_mothership);
     $inner_html_gen->set('config_navigation_url', network_config_navigation('manage_tasks_relationship'));
     $inner_html = $inner_html_gen->fetch();
     return $inner_html;
 }
Example #29
0
 /**
  *
  *  Показывает для редактирования и сохраняет задание
  * 
  *  @param id 
  *  @return true
  *
  **/
 public function actionEdit_task($id)
 {
     if (!Yii::app()->my->access("edit")) {
         return false;
     }
     $task = Tasks::model()->findByPk($id);
     if (isset($_REQUEST['Tasks'])) {
         foreach ($_REQUEST['Tasks'] as $key => $value) {
             $task->{$key} = $value;
         }
         if ($task->save()) {
             Yii::app()->notify->add("Задание сохранено. <a href='/task/" . $task->id . "' target='blank'>Перейти к заданию</a>");
         } else {
             Yii::app()->notify->add("Не удалось сохранить", "danger");
             print_r($task->getErrors());
         }
     }
     $this->render("task", array("task" => $task));
 }
 public function getProjectDataEffort()
 {
     $criteria = new CDbCriteria();
     $criteria->select = "COUNT(DISTINCT t.task_id) as total, Status.status_id";
     $criteria->condition = "Projects.project_id = :project_id";
     $criteria->params = array(':project_id' => Yii::app()->user->getState('project_selected'));
     $criteria->group = "Stage.taskStage_id";
     $countStages = Tasks::model()->with('Projects', 'Stage')->together()->findAll($criteria);
     $totalTareas = 0;
     foreach ($countStages as $key) {
         $totalTareas += intval($key->total);
     }
     foreach ($countStages as $key) {
         $this->seriesStages[] = array($key->Stage->taskStage_name, round(intval($key->total) / $totalTareas * 100));
     }
     /*echo "<pre>";
     		print_r($this->seriesStages);
     		die("</pre>");*/
     //return $this->seriesStages;
 }