Пример #1
0
 public function getTaskList($userId, $days = 30)
 {
     /*
      * This list of fields - id, name, description, startDate, endDate,
      * updatedDate - are named specifically for the iCal creation.
      * If you change them, it's probably going to break.  So don't do that.
      */
     $q = new w2p_Database_Query();
     $q->addQuery('t.task_id as id');
     $q->addQuery('task_name as name');
     $q->addQuery('task_description as description');
     $q->addQuery('task_start_date as startDate');
     $q->addQuery('task_end_date as endDate');
     $q->addQuery('task_updated as updatedDate');
     $q->addQuery('CONCAT(\'' . W2P_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . '\', t.task_id) as url');
     $q->addQuery('p.project_id, p.project_name');
     $q->addTable('tasks', 't');
     $q->addWhere('(task_start_date < ' . $q->dbfnDateAdd($q->dbfnNow(), $days, 'DAY') . ' OR task_end_date < ' . $q->dbfnDateAdd($q->dbfnNow(), $days, 'DAY') . ')');
     $q->addWhere('task_percent_complete < 100');
     $q->addWhere('task_dynamic <> 1');
     $q->innerJoin('user_tasks', 'ut', 'ut.task_id = t.task_id');
     $q->addWhere('ut.user_id = ' . $userId);
     $q->innerJoin('projects', 'p', 'p.project_id = t.task_project');
     $q->addWhere('project_active > 0');
     if (($template_status = w2PgetConfig('template_projects_status_id')) != '') {
         $q->addWhere('project_status <> ' . $template_status);
     }
     $q->addOrder('task_start_date, task_end_date');
     return $q->loadList();
 }
Пример #2
0
/**
 * @param $user_id
 * @param $showArcProjs
 * @param $showLowTasks
 * @param $showInProgress
 * @param $showHoldProjs
 * @param $showDynTasks
 * @param $showPinned
 * @param $showEmptyDate
 * @param $task_type
 * @param $allowedTasks
 * @param $allowedProjects
 *
 * @return Array
 */
function __extract_from_todo($user_id, $showArcProjs, $showLowTasks, $showInProgress, $showHoldProjs, $showDynTasks, $showPinned, $showEmptyDate, $task_type, $allowedTasks, $allowedProjects)
{
    // query my sub-tasks (ignoring task parents)
    $q = new w2p_Database_Query();
    $q->addQuery('distinct(ta.task_id), ta.*, ta.task_start_date as task_start_datetime, ta.task_end_date as task_end_datetime');
    $q->addQuery('project_name, pr.project_id, project_color_identifier');
    $q->addQuery('tp.task_pinned');
    $q->addQuery('ut.user_task_priority');
    $dateDiffString = $q->dbfnDateDiff('ta.task_end_date', $q->dbfnNow()) . ' AS task_due_in';
    $q->addQuery($dateDiffString);
    $q->addTable('projects', 'pr');
    $q->addTable('tasks', 'ta');
    $q->addTable('user_tasks', 'ut');
    $q->leftJoin('user_task_pin', 'tp', 'tp.task_id = ta.task_id and tp.user_id = ' . (int) $user_id);
    $q->addWhere('ut.task_id = ta.task_id');
    $q->addWhere('ut.user_id = ' . (int) $user_id);
    $q->addWhere('( ta.task_percent_complete < 100 or ta.task_percent_complete is null)');
    $q->addWhere('ta.task_status = 0');
    $q->addWhere('pr.project_id = ta.task_project');
    if (!$showArcProjs) {
        $q->addWhere('project_active = 1');
        if (($template_status = w2PgetConfig('template_projects_status_id')) != '') {
            $q->addWhere('project_status <> ' . (int) $template_status);
        }
    }
    if (!$showLowTasks) {
        $q->addWhere('task_priority >= 0');
    }
    if ($showInProgress) {
        $q->addWhere('project_status = 3');
    }
    if (!$showHoldProjs) {
        if (($on_hold_status = w2PgetConfig('on_hold_projects_status_id')) != '') {
            $q->addWhere('project_status <> ' . (int) $on_hold_status);
        }
    }
    if (!$showDynTasks) {
        $q->addWhere('task_dynamic <> 1');
    }
    if ($showPinned) {
        $q->addWhere('task_pinned = 1');
    }
    if (!$showEmptyDate) {
        $q->addWhere('ta.task_start_date <> \'\' AND ta.task_start_date <> \'0000-00-00 00:00:00\'');
    }
    if ($task_type != '') {
        $q->addWhere('ta.task_type = ' . (int) $task_type);
    }
    if (count($allowedTasks)) {
        $q->addWhere($allowedTasks);
    }
    if (count($allowedProjects)) {
        $q->addWhere($allowedProjects);
    }
    $q->addOrder('task_end_date, task_start_date, task_priority');
    $tasks = $q->loadList();
    return $tasks;
}
Пример #3
0
        echo db_error();
        $q->clear();
    }
}
$AppUI->savePlace();
$proj = new CProject();
$tobj = new CTask();
$allowedProjects = $proj->getAllowedSQL($AppUI->user_id, 'pr.project_id');
$allowedTasks = $tobj->getAllowedSQL($AppUI->user_id, 'ta.task_id');
// query my sub-tasks (ignoring task parents)
$q = new w2p_Database_Query();
$q->addQuery('ta.*');
$q->addQuery('project_name, pr.project_id, project_color_identifier');
$q->addQuery('tp.task_pinned');
$q->addQuery('ut.user_task_priority');
$dateDiffString = $q->dbfnDateDiff('ta.task_end_date', $q->dbfnNow()) . ' AS task_due_in';
$q->addQuery($dateDiffString);
$q->addTable('projects', 'pr');
$q->addTable('tasks', 'ta');
$q->addTable('user_tasks', 'ut');
$q->leftJoin('user_task_pin', 'tp', 'tp.task_id = ta.task_id and tp.user_id = ' . (int) $user_id);
$q->leftJoin('project_departments', 'project_departments', 'pr.project_id = project_departments.project_id OR project_departments.project_id IS NULL');
$q->leftJoin('departments', 'departments', 'departments.dept_id = project_departments.department_id OR dept_id IS NULL');
$q->addWhere('ut.task_id = ta.task_id');
$q->addWhere('ut.user_id = ' . (int) $user_id);
$q->addWhere('( ta.task_percent_complete < 100 or ta.task_percent_complete is null)');
$q->addWhere('ta.task_status = 0');
$q->addWhere('pr.project_id = ta.task_project');
if (!$showArcProjs) {
    $q->addWhere('project_active = 1');
    if (($template_status = w2PgetConfig('template_projects_status_id')) != '') {
Пример #4
0
 public function getCalendarEvents($userId, $days = 30)
 {
     /*
      * This list of fields - id, name, description, startDate, endDate,
      * updatedDate - are named specifically for the iCal creation.
      * If you change them, it's probably going to break.  So don't do that.
      */
     $q = new w2p_Database_Query();
     $q->addQuery('e.event_id as id');
     $q->addQuery('event_title as name');
     $q->addQuery('event_description as description');
     $q->addQuery('event_start_date as startDate');
     $q->addQuery('event_end_date as endDate');
     $q->addQuery("'" . $q->dbfnNowWithTZ() . "' as updatedDate");
     $q->addQuery('CONCAT(\'' . W2P_BASE_URL . '/index.php?m=calendar&a=view&event_id=' . '\', e.event_id) as url');
     $q->addQuery('projects.project_id, projects.project_name');
     $q->addTable('events', 'e');
     $q->leftJoin('projects', 'projects', 'e.event_project = projects.project_id');
     $q->addWhere('(event_start_date > ' . $q->dbfnNow() . ' OR event_end_date > ' . $q->dbfnNow() . ')');
     $q->addWhere('(event_start_date < ' . $q->dbfnDateAdd($q->dbfnNow(), $days, 'DAY') . ' OR event_end_date < ' . $q->dbfnDateAdd($q->dbfnNow(), $days, 'DAY') . ')');
     $q->innerJoin('user_events', 'ue', 'ue.event_id = e.event_id');
     $q->addWhere('ue.user_id = ' . $userId);
     $q->addOrder('event_start_date');
     return $q->loadList();
 }