Beispiel #1
0
 public function getProjectTaskLinksByCategory($AppUI, $project_id = 0, $task_id = 0, $category_id = 0, $search = '')
 {
     // load the following classes to retrieved denied records
     $project = new CProject();
     $task = new CTask();
     // SETUP FOR LINK LIST
     $q = new DBQuery();
     $q->addQuery('links.*');
     $q->addQuery('contact_first_name, contact_last_name');
     $q->addQuery('project_name, project_color_identifier, project_status');
     $q->addQuery('task_name, task_id');
     $q->addTable('links');
     $q->leftJoin('users', 'u', 'user_id = link_owner');
     $q->leftJoin('contacts', 'c', 'user_contact = contact_id');
     if ($search != '') {
         $q->addWhere('(link_name LIKE \'%' . $search . '%\' OR link_description LIKE \'%' . $search . '%\')');
     }
     if ($project_id > 0) {
         // Project
         $q->addWhere('link_project = ' . (int) $project_id);
     }
     if ($task_id > 0) {
         // Task
         $q->addWhere('link_task = ' . (int) $task_id);
     }
     if ($category_id >= 0) {
         // Category
         $q->addWhere('link_category = ' . $category_id);
     }
     // Permissions
     $project->setAllowedSQL($AppUI->user_id, $q, 'link_project');
     $task->setAllowedSQL($AppUI->user_id, $q, 'link_task and task_project = link_project');
     $q->addOrder('project_name, link_name');
     return $q->loadList();
 }
 public function getAllowedForums($user_id, $company_id, $filter = -1, $orderby = 'forum_name', $orderdir = 'asc', $max_msg_length = 30)
 {
     $project = new CProject();
     $project->overrideDatabase($this->_query);
     $q = $this->_getQuery();
     $q->addTable('forums');
     $q->addQuery('forum_id, forum_project, forum_description, forum_owner, forum_name');
     $q->addQuery('forum_moderated, forum_create_date, forum_last_date');
     $q->addQuery('sum(if(c.message_parent=-1,1,0)) as forum_topics, sum(if(c.message_parent>0,1,0)) as forum_replies');
     $q->addQuery('user_username, project_name, project_color_identifier, contact_display_name as owner_name, user_id');
     $q->addQuery('SUBSTRING(l.message_body,1,' . $max_msg_length . ') message_body');
     $q->addQuery('LENGTH(l.message_body) message_length, watch_user, l.message_parent, l.message_id');
     $q->addQuery('count(distinct v.visit_message) as visit_count, count(distinct c.message_id) as message_count');
     $q->addJoin('users', 'u', 'u.user_id = forum_owner');
     $q->addJoin('projects', 'pr', 'pr.project_id = forum_project');
     $q->addJoin('forum_messages', 'l', 'l.message_id = forum_last_id');
     $q->addJoin('forum_messages', 'c', 'c.message_forum = forum_id');
     $q->addJoin('forum_watch', 'w', 'watch_user = '******' AND watch_forum = forum_id');
     $q->addJoin('forum_visits', 'v', 'visit_user = '******' AND visit_forum = forum_id and visit_message = c.message_id');
     $q->addJoin('contacts', 'cts', 'contact_id = u.user_contact');
     $q = $project->setAllowedSQL($user_id, $q, null, 'pr');
     $q = $this->setAllowedSQL($user_id, $q);
     switch ($filter) {
         case 1:
             $q->addWhere('forum_owner = ' . $user_id);
             break;
         case 2:
             $q->addWhere('watch_user = '******'project_owner = ' . $user_id);
             break;
         case 4:
             $q->addWhere('project_company = ' . $company_id);
             break;
         case 5:
             $q->addWhere('(project_active = 0 OR forum_project = 0)');
             break;
         default:
             $q->addWhere('(project_active = 1 OR forum_project = 0)');
             break;
     }
     $q->addGroup('forum_id');
     $orderby = property_exists($this, $orderby) ? $orderby : 'forum_name';
     $q->addOrder($orderby . ' ' . $orderdir);
     return $q->loadList();
 }
 public function getProjectTaskLinksByCategory($notUsed = null, $project_id = 0, $task_id = 0, $category_id = 0, $search = '')
 {
     // load the following classes to retrieved denied records
     $project = new CProject();
     $project->overrideDatabase($this->_query);
     $task = new CTask();
     $task->overrideDatabase($this->_query);
     // SETUP FOR LINK LIST
     $q = $this->_getQuery();
     $q->addQuery('links.*');
     $q->addTable('links');
     $q->leftJoin('projects', 'pr', 'project_id = link_project');
     $q->leftJoin('tasks', 't', 'task_id = link_task');
     if ($search != '') {
         $q->addWhere('(link_name LIKE \'%' . $search . '%\' OR link_description LIKE \'%' . $search . '%\')');
     }
     if ($project_id > 0) {
         // Project
         $q->addQuery('project_name, project_color_identifier, project_status');
         $q->addWhere('link_project = ' . (int) $project_id);
     }
     if ($task_id > 0) {
         // Task
         $q->addQuery('task_name, task_id');
         $q->addWhere('link_task = ' . (int) $task_id);
     }
     if ($category_id >= 0) {
         // Category
         $q->addWhere('link_category = ' . $category_id);
     }
     // Permissions
     $q = $project->setAllowedSQL($this->_AppUI->user_id, $q, 'link_project');
     $q = $task->setAllowedSQL($this->_AppUI->user_id, $q, 'link_task and task_project = link_project');
     $q->addOrder('project_name, link_name');
     return $q->loadList();
 }
Beispiel #4
0
 public static function getProjects($AppUI, $companyId, $active = 1, $sort = 'project_name')
 {
     $fields = 'pr.project_id, project_name, project_start_date, ' . 'project_status, project_target_budget, project_start_date, ' . 'project_priority, contact_first_name, contact_last_name';
     $q = new DBQuery();
     $q->addTable('projects', 'pr');
     $q->addQuery($fields);
     $q->leftJoin('users', 'u', 'u.user_id = pr.project_owner');
     $q->leftJoin('contacts', 'con', 'u.user_contact = con.contact_id');
     if ((int) $companyId > 0) {
         $q->addWhere('pr.project_company = ' . (int) $companyId);
     }
     $projObj = new CProject();
     $projObj->setAllowedSQL($AppUI->user_id, $q, null, 'pr');
     $q->addWhere('pr.project_active = ' . (int) $active);
     if (strpos($fields, $sort) !== false) {
         $q->addOrder($sort);
     }
     return $q->loadList();
 }
Beispiel #5
0
 $query->clear();
 $proj = new CProject();
 $task = new CTask();
 $ss = $start_date->format(FMT_DATETIME_MYSQL);
 $se = $end_date->format(FMT_DATETIME_MYSQL);
 $query->addTable('tasks', 't');
 $query->leftJoin('projects', 'p', 'p.project_id = t.task_project');
 $query->addQuery('t.*');
 if ($use_period) {
     $query->addWhere("((task_start_date >= '{$ss}' AND task_start_date <= '{$se}') " . " OR (task_end_date <= '{$se}' AND task_end_date >= '{$ss}'))");
 }
 if ($project_id) {
     $query->addWhere('t.task_project = ' . $project_id);
 }
 // Now add the required restrictions.
 $proj->setAllowedSQL($AppUI->user_id, $query, null, 'p');
 $task->setAllowedSQL($AppUI->user_id, $query, null, 't');
 $query->addOrder('task_end_date');
 $task_list_hash = $query->loadHashList('task_id');
 $query->clear();
 $task_list = array();
 $task_assigned_users = array();
 foreach ($task_list_hash as $task_id => $task_data) {
     $task = new CTask();
     $task->bind($task_data);
     $task_list[$task_id] = $task;
     $task_assigned_users[$task_id] = $task->getAssignedUsers();
 }
 $user_usage = array();
 $task_dates = array();
 $actual_date = $start_date;
Beispiel #6
0
foreach ($deptList as $dept) {
    $department_selection_list[$dept['dept_id']] = $dept['dept_name'];
}
$department_selection_list = arrayMerge(array('0' => ''), $department_selection_list);
//Dynamic tasks are by default now off because of dangerous behavior if incorrectly used
if (is_null($task->task_dynamic)) {
    $task->task_dynamic = 0;
}
$can_edit_time_information = $task->canUserEditTimeInformation();
//get list of projects, for task move drop down list.
$pq = new DBQuery();
$pq->addQuery('pr.project_id, project_name');
$pq->addTable('projects', 'pr');
$pq->addWhere('( project_active = 1 or pr.project_id = ' . (int) $task_project . ')');
$pq->addOrder('project_name');
$project->setAllowedSQL($AppUI->user_id, $pq, null, 'pr');
$projects = $pq->loadHashList();
?>
<script language="JavaScript">
var selected_contacts_id = '<?php 
echo $task->task_contacts;
?>
';
var task_id = '<?php 
echo $task->task_id;
?>
';

var check_task_dates = <?php 
if (isset($w2Pconfig['check_task_dates']) && $w2Pconfig['check_task_dates']) {
    echo 'true';
function projects_list_data($user_id = false)
{
    global $AppUI, $addPwOiD, $buffer, $company, $company_id, $company_prefix, $deny, $department, $dept_ids, $w2Pconfig, $orderby, $orderdir, $tasks_problems, $owner, $projectTypeId, $search_text, $project_type;
    $addProjectsWithAssignedTasks = $AppUI->getState('addProjWithTasks') ? $AppUI->getState('addProjWithTasks') : 0;
    // get any records denied from viewing
    $obj = new CProject();
    $deny = $obj->getDeniedRecords($AppUI->user_id);
    // Let's delete temproary tables
    $q = new w2p_Database_Query();
    $q->setDelete('tasks_problems');
    $q->exec();
    $q->clear();
    $q->setDelete('tasks_users');
    $q->exec();
    $q->clear();
    // support task problem logs
    $q->addInsertSelect('tasks_problems');
    $q->addTable('tasks');
    $q->addQuery('task_project, task_log_problem');
    $q->addJoin('task_log', 'tl', 'tl.task_log_task = task_id', 'inner');
    $q->addWhere('task_log_problem = 1');
    $q->addGroup('task_project');
    $tasks_problems = $q->exec();
    $q->clear();
    if ($addProjectsWithAssignedTasks) {
        // support users tasks
        $q->addInsertSelect('tasks_users');
        $q->addTable('tasks');
        $q->addQuery('task_project');
        $q->addQuery('ut.user_id');
        $q->addJoin('user_tasks', 'ut', 'ut.task_id = tasks.task_id');
        if ($user_id) {
            $q->addWhere('ut.user_id = ' . (int) $user_id);
        }
        $q->addOrder('task_end_date DESC');
        $q->addGroup('task_project');
        $tasks_users = $q->exec();
        $q->clear();
    }
    // add Projects where the Project Owner is in the given department
    if ($addPwOiD && isset($department)) {
        $owner_ids = array();
        $q->addTable('users');
        $q->addQuery('user_id');
        $q->addJoin('contacts', 'c', 'c.contact_id = user_contact', 'inner');
        $q->addWhere('c.contact_department = ' . (int) $department);
        $owner_ids = $q->loadColumn();
        $q->clear();
    }
    if (isset($department)) {
        //If a department is specified, we want to display projects from the department, and all departments under that, so we need to build that list of departments
        $dept_ids = array();
        $q->addTable('departments');
        $q->addQuery('dept_id, dept_parent');
        $q->addOrder('dept_parent,dept_name');
        $rows = $q->loadList();
        addDeptId($rows, $department);
        $dept_ids[] = isset($department->dept_id) ? $department->dept_id : 0;
        $dept_ids[] = $department > 0 ? $department : 0;
    }
    $q->clear();
    // retrieve list of records
    // modified for speed
    // by Pablo Roca (pabloroca@mvps.org)
    // 16 August 2003
    // get the list of permitted companies
    $obj = new CCompany();
    $companies = $obj->getAllowedRecords($AppUI->user_id, 'companies.company_id,companies.company_name', 'companies.company_name');
    if (count($companies) == 0) {
        $companies = array();
    }
    $q->addTable('projects', 'pr');
    $q->addQuery('pr.project_id, project_status, project_color_identifier,
		project_type, project_name, project_description, project_scheduled_hours as project_duration,
		project_parent, project_original_parent, project_percent_complete,
		project_color_identifier, project_company,
        company_name, project_status, project_last_task as critical_task,
        tp.task_log_problem, user_username, project_active');
    $fields = w2p_Core_Module::getSettings('projects', 'index_list');
    unset($fields['department_list']);
    // added as an alias below
    foreach ($fields as $field => $text) {
        $q->addQuery($field);
    }
    $q->addQuery('CONCAT(ct.contact_first_name, \' \', ct.contact_last_name) AS owner_name');
    $q->addJoin('users', 'u', 'pr.project_owner = u.user_id');
    $q->addJoin('contacts', 'ct', 'ct.contact_id = u.user_contact');
    $q->addJoin('tasks_problems', 'tp', 'pr.project_id = tp.task_project');
    if ($addProjectsWithAssignedTasks) {
        $q->addJoin('tasks_users', 'tu', 'pr.project_id = tu.task_project');
    }
    if (!isset($department) && $company_id && !$addPwOiD) {
        $q->addWhere('pr.project_company = ' . (int) $company_id);
    }
    if ($project_type > -1) {
        $q->addWhere('pr.project_type = ' . (int) $project_type);
    }
    if (isset($department) && !$addPwOiD) {
        $q->addWhere('project_departments.department_id in ( ' . implode(',', $dept_ids) . ' )');
    }
    if ($user_id && $addProjectsWithAssignedTasks) {
        $q->addWhere('(tu.user_id = ' . (int) $user_id . ' OR pr.project_owner = ' . (int) $user_id . ' )');
    } elseif ($user_id) {
        $q->addWhere('pr.project_owner = ' . (int) $user_id);
    }
    if ($owner > 0) {
        $q->addWhere('pr.project_owner = ' . (int) $owner);
    }
    if (mb_trim($search_text)) {
        $q->addWhere('pr.project_name LIKE \'%' . $search_text . '%\' OR pr.project_description LIKE \'%' . $search_text . '%\'');
    }
    // Show Projects where the Project Owner is in the given department
    if ($addPwOiD && !empty($owner_ids)) {
        $q->addWhere('pr.project_owner IN (' . implode(',', $owner_ids) . ')');
    }
    $orderby = 'project_company' == $orderby ? 'company_name' : $orderby;
    $q->addGroup('pr.project_id');
    $q->addOrder($orderby . ' ' . $orderdir);
    $prj = new CProject();
    $prj->setAllowedSQL($AppUI->user_id, $q, null, 'pr');
    $dpt = new CDepartment();
    $projects = $q->loadList();
    // get the list of permitted companies
    $companies = arrayMerge(array('0' => $AppUI->_('All')), $companies);
    $company_array = $companies;
    //get list of all departments, filtered by the list of permitted companies.
    $q->clear();
    $q->addTable('companies');
    $q->addQuery('company_id, company_name, dep.*');
    $q->addJoin('departments', 'dep', 'companies.company_id = dep.dept_company');
    $q->addOrder('company_name,dept_parent,dept_name');
    $obj->setAllowedSQL($AppUI->user_id, $q);
    $dpt->setAllowedSQL($AppUI->user_id, $q);
    $rows = $q->loadList();
    //display the select list
    $buffer = '<select name="department" id="department" onChange="document.pickCompany.submit()" class="text" style="width: 200px;">';
    $company = '';
    foreach ($company_array as $key => $c_name) {
        $buffer .= '<option value="' . $company_prefix . $key . '" style="font-weight:bold;"' . ($company_id == $key ? 'selected="selected"' : '') . '>' . $c_name . '</option>' . "\n";
        foreach ($rows as $row) {
            if ($row['dept_parent'] == 0) {
                if ($key == $row['company_id']) {
                    if ($row['dept_parent'] != null) {
                        findchilddept($rows, $row['dept_id']);
                    }
                }
            }
        }
    }
    $buffer .= '</select>';
    return $projects;
}
// pull valid projects and their percent complete information
// GJB: Note that we have to special case duration type 24 and this refers to the hours in a day, NOT 24 hours
$q = new w2p_Database_Query();
$q->addTable('projects', 'pr');
$q->addQuery('DISTINCT pr.project_id, project_color_identifier, project_name, project_start_date, project_end_date,
                max(t1.task_end_date) AS project_actual_end_date, project_percent_complete, project_status, project_active');
$q->addJoin('tasks', 't1', 'pr.project_id = t1.task_project');
$q->addJoin('companies', 'c1', 'pr.project_company = c1.company_id');
if ($department > 0) {
    $q->addWhere('project_departments.department_id = ' . (int) $department);
}
if (!($department > 0) && $company_id != 0) {
    $q->addWhere('project_company = ' . (int) $company_id);
}
$q->addWhere('project_original_parent = ' . (int) $original_project_id);
$pjobj->setAllowedSQL($AppUI->user_id, $q, null, 'pr');
$q->addGroup('pr.project_id');
$q->addOrder('project_start_date, project_end_date, project_name');
$projects = $q->loadHashList('project_id');
$q->clear();
$width = w2PgetParam($_GET, 'width', 600);
$start_date = w2PgetParam($_GET, 'start_date', 0);
$end_date = w2PgetParam($_GET, 'end_date', 0);
$showAllGantt = w2PgetParam($_REQUEST, 'showAllGantt', '1');
$gantt = new w2p_Output_GanttRenderer($AppUI, $width);
$gantt->localize();
$original_project = new CProject();
$original_project->load($original_project_id);
$tableTitle = $original_project->project_name . ': ' . $AppUI->_('Multi-Project Gantt');
$gantt->setTitle($tableTitle, '#eeeeee');
$columnNames = array('Project name', 'Start Date', 'Finish', 'Actual End');
Beispiel #9
0
$q = new DBQuery();
$q->addTable('forums');
$q->addWhere("forums.forum_id = {$forum_id}");
$res = $q->exec();
echo db_error();
$forum_info = db_fetch_assoc($res);
$status = isset($forum_info["forum_status"]) ? $forum_info["forum_status"] : -1;
// get any project records denied from viewing
$projObj = new CProject();
//Pull project Information
$q = new DBQuery();
$q->addTable('projects');
$q->addQuery('project_id, project_name');
$q->addWhere('project_status <> 7');
$q->addOrder('project_name');
$projObj->setAllowedSQL($AppUI->user_id, $q);
if (isset($company_id)) {
    $q->addWhere("project_company = {$company_id}");
}
$projects = array('0' => '') + $q->loadHashList();
echo db_error();
if (!in_array($forum_project, array_keys($projects))) {
    $forum_project = 0;
}
$perms =& $AppUI->acl();
$permittedUsers =& $perms->getPermittedUsers();
$users = array('0' => '') + $permittedUsers;
// setup the title block
$ttl = $forum_id > 0 ? "Edit Forum" : "Add Forum";
$titleBlock = new CTitleBlock($ttl, 'support.png', $m, "{$m}.{$a}");
$titleBlock->addCrumb("?m=forums", "forums list");
/**
**	Provide Projects Selectbox sorted by Companies
**	@author gregorerhardt with special thanks to original author aramis
**	@param	int			userID
**	@param	string	HTML select box name identifier
**	@param	string	HTML attributes
**	@param	int			Proejct ID for preselection
**	@param	int			Project ID which will be excluded from the list
**									(e.g. in the tasks import list exclude the project to import into)
**	@return	string	HTML selectbox
*/
function projectSelectWithOptGroup($user_id, $select_name, $select_attribs, $selected, $excludeProjWithId = null)
{
    global $AppUI;
    $q = new DBQuery();
    $q->addTable('projects');
    $q->addQuery('project_id, co.company_name, project_name');
    if (!empty($excludeProjWithId)) {
        $q->addWhere('project_id != ' . $excludeProjWithId);
    }
    $proj = new CProject();
    $proj->setAllowedSQL($user_id, $q);
    $q->addOrder('co.company_name, project_name');
    $projects = $q->loadList();
    $s = "\n" . '<select name="' . $select_name . '"' . ($select_attribs ? ' ' . $select_attribs : '') . '>';
    $s .= "\n\t" . '<option value="0"' . ($selected == 0 ? ' selected="selected"' : '') . ' >' . $AppUI->_('None') . '</option>';
    $current_company = '';
    foreach ($projects as $p) {
        if ($p['company_name'] != $current_company) {
            $current_company = $AppUI->___($p['company_name']);
            $s .= "\n" . '<optgroup label="' . $current_company . '" >' . $current_company . '</optgroup>';
        }
        $s .= "\n\t" . '<option value="' . $p['project_id'] . '"' . ($selected == $p['project_id'] ? ' selected="selected"' : '') . '>&nbsp;&nbsp;&nbsp;' . $AppUI->___($p['project_name']) . '</option>';
    }
    $s .= "\n</select>\n";
    return $s;
}
Beispiel #11
0
/**
**	Provide Projects Selectbox sorted by Companies
**	@author gregorerhardt with special thanks to original author aramis
**	@param 	int 		userID
**	@param 	string 	HTML select box name identifier
**	@param	string	HTML attributes
**	@param	int			Proejct ID for preselection
**	@param 	int			Project ID which will be excluded from the list 
**									(e.g. in the tasks import list exclude the project to import into)
**	@return	string 	HTML selectbox
*/
function projectSelectWithOptGroup($user_id, $select_name, $select_attribs, $selected, $excludeProjWithId = null)
{
    global $AppUI;
    $q = new DBQuery();
    $q->addTable('projects');
    $q->addQuery('project_id, co.company_name, project_name');
    if (!empty($excludeProjWithId)) {
        $q->addWhere('project_id != ' . $excludeProjWithId);
    }
    $proj = new CProject();
    $proj->setAllowedSQL($user_id, $q);
    $q->addOrder('co.company_name, project_name');
    $projects = $q->loadList();
    $s = "\n<select name=\"{$select_name}\" {$select_attribs}>";
    $s .= "\n\t<option value=\"0\" " . ($selected == 0 ? "selected=\"selected\"" : "") . " >" . $AppUI->_('None') . "</option>";
    $current_company = "";
    foreach ($projects as $p) {
        if ($p['company_name'] != $current_company) {
            $current_company = $p['company_name'];
            $s .= "\n<optgroup label=\"" . $current_company . "\" >" . $current_company . "</optgroup>";
        }
        $s .= "\n\t<option value=\"" . $p['project_id'] . "\"" . ($selected == $p['project_id'] ? " selected=\"selected\"" : '') . ">&nbsp;&nbsp;&nbsp;" . $p['project_name'] . "</option>";
    }
    $s .= "\n</select>\n";
    return $s;
}
Beispiel #12
0
$q->addTable('tasks', 'a');
$q->addTable('projects', 'pr');
$q->addWhere('a.task_project = pr.project_id');
$q->addJoin('users', 'b', 'a.task_owner = b.user_id', 'inner');
$q->addJoin('contacts', 'ct', 'ct.contact_id = b.user_contact', 'inner');
$q->addWhere('task_percent_complete = 100');
$q->addWhere('pr.project_active = 1');
if (($template_status = w2PgetConfig('template_projects_status_id')) != '') {
    $q->addWhere('pr.project_status <> ' . $template_status);
}
if ($project_id != 0) {
    $q->addWhere('task_project = ' . (int) $project_id);
}
$q->addWhere('task_end_date BETWEEN \'' . $last_week->format(FMT_DATETIME_MYSQL) . '\' AND \'' . $date->format(FMT_DATETIME_MYSQL) . '\'');
$proj = new CProject();
$q = $proj->setAllowedSQL($AppUI->user_id, $q, null, 'pr');
$obj = new CTask();
$q = $obj->setAllowedSQL($AppUI->user_id, $q);
$tasks = $q->loadHashList('task_id');
if ($err = db_error()) {
    $AppUI->setMsg($err, UI_MSG_ERROR);
    $AppUI->redirect('m=' . $m);
}
// Now grab the resources allocated to the tasks.
$task_list = array_keys($tasks);
$assigned_users = array();
// Build the array
foreach ($task_list as $tid) {
    $assigned_users[$tid] = array();
}
if (count($tasks)) {
/**
 **	Provide Projects Selectbox sorted by Companies
 **	@author gregorerhardt with special thanks to original author aramis
 **	@param 	int 		userID
 **	@param 	string 	HTML select box name identifier
 **	@param	string	HTML attributes
 **	@param	int			Proejct ID for preselection
 **	@param 	int			Project ID which will be excluded from the list
 **									(e.g. in the tasks import list exclude the project to import into)
 **	@return	string 	HTML selectbox
 */
function projectSelectWithOptGroup($user_id, $select_name, $select_attribs, $selected, $excludeProjWithId = null)
{
    global $AppUI;
    $q = new w2p_Database_Query();
    $q->addTable('projects', 'pr');
    $q->addQuery('DISTINCT pr.project_id, co.company_name, project_name');
    $q->addJoin('companies', 'co', 'co.company_id = pr.project_company');
    if (!empty($excludeProjWithId)) {
        $q->addWhere('pr.project_id <> ' . $excludeProjWithId);
    }
    $proj = new CProject();
    $q = $proj->setAllowedSQL($user_id, $q, null, 'pr');
    $q->addOrder('co.company_name, project_name');
    $projects = $q->loadList();
    $s = '<select name="' . $select_name . '" ' . $select_attribs . '>';
    $s .= '<option value="0" ' . ($selected == 0 ? 'selected="selected"' : '') . ' >' . $AppUI->_('None') . '</option>';
    $current_company = '';
    foreach ($projects as $p) {
        if ($p['company_name'] != $current_company) {
            $current_company = $p['company_name'];
            $s .= '<optgroup label="' . $current_company . '" >' . $current_company . '</optgroup>';
        }
        $s .= '<option value="' . $p['project_id'] . '" ' . ($selected == $p['project_id'] ? 'selected="selected"' : '') . '>&nbsp;&nbsp;&nbsp;' . $p['project_name'] . '</option>';
    }
    $s .= '</select>';
    return $s;
}
Beispiel #14
0
function projects_list_data($user_id = false)
{
    global $AppUI, $addPwOiD, $buffer, $company, $company_id, $company_prefix, $deny, $department, $dept_ids, $w2Pconfig, $orderby, $orderdir, $projects, $tasks_critical, $tasks_problems, $tasks_sum, $tasks_summy, $tasks_total, $owner, $projectTypeId, $search_text, $project_type;
    $addProjectsWithAssignedTasks = $AppUI->getState('addProjWithTasks') ? $AppUI->getState('addProjWithTasks') : 0;
    // get any records denied from viewing
    $obj = new CProject();
    $deny = $obj->getDeniedRecords($AppUI->user_id);
    // Let's delete temproary tables
    $q = new DBQuery();
    // Let's delete support tables data
    $q->setDelete('tasks_sum');
    $q->exec();
    $q->clear();
    //BEGIN: Deprecated in v2.0
    $q->setDelete('tasks_total');
    $q->exec();
    $q->clear();
    //END: Deprecated in v2.0
    $q->setDelete('tasks_summy');
    $q->exec();
    $q->clear();
    $q->setDelete('tasks_critical');
    $q->exec();
    $q->clear();
    $q->setDelete('tasks_problems');
    $q->exec();
    $q->clear();
    $q->setDelete('tasks_users');
    $q->exec();
    $q->clear();
    // support task sum table
    // by Pablo Roca (pabloroca@mvps.org)
    // 16 August 2003
    $working_hours = $w2Pconfig['daily_working_hours'] ? $w2Pconfig['daily_working_hours'] : 8;
    // GJB: Note that we have to special case duration type 24 and this refers to the hours in a day, NOT 24 hours
    $q->addInsertSelect('tasks_sum');
    $q->addTable('tasks');
    $q->addQuery('task_project, COUNT(distinct tasks.task_id) AS total_tasks');
    $q->addQuery('-1 AS project_percent_complete');
    $q->addQuery('SUM(task_duration * IF(task_duration_type = 24, ' . $working_hours . ', task_duration_type)) AS project_duration');
    if ($user_id) {
        $q->addJoin('user_tasks', 'ut', 'ut.task_id = tasks.task_id');
        $q->addWhere('ut.user_id = ' . (int) $user_id);
    }
    $q->addWhere('tasks.task_id = tasks.task_parent');
    $q->addGroup('task_project');
    $tasks_sum = $q->exec();
    $q->clear();
    //BEGIN: Deprecated in v2.0
    // support task total table
    $q->addInsertSelect('tasks_total');
    $q->addTable('tasks');
    $q->addQuery('task_project, COUNT(distinct tasks.task_id) AS total_tasks');
    if ($user_id) {
        $q->addJoin('user_tasks', 'ut', 'ut.task_id = tasks.task_id');
        $q->addWhere('ut.user_id = ' . (int) $user_id);
    }
    $q->addGroup('task_project');
    $tasks_total = $q->exec();
    $q->clear();
    //END: Deprecated in v2.0
    // support My Tasks
    $q->addInsertSelect('tasks_summy');
    $q->addTable('tasks');
    $q->addQuery('task_project, COUNT(distinct task_id) AS my_tasks');
    if ($user_id) {
        $q->addWhere('task_owner = ' . (int) $user_id);
    } else {
        $q->addWhere('task_owner = ' . (int) $AppUI->user_id);
    }
    $q->addGroup('task_project');
    $tasks_summy = $q->exec();
    $q->clear();
    // support critical tasks
    $q->addInsertSelect('tasks_critical');
    $q->addTable('tasks', 't');
    $q->addQuery('task_project, task_id AS critical_task, task_end_date AS project_actual_end_date');
    $sq = new DBQuery();
    $sq->addTable('tasks', 'st');
    $sq->addQuery('MAX(task_end_date)');
    $sq->addWhere('st.task_project = t.task_project');
    $q->addWhere('task_end_date = (' . $sq->prepare() . ')');
    $q->addGroup('task_project');
    $tasks_critical = $q->exec();
    $q->clear();
    // support task problem logs
    $q->addInsertSelect('tasks_problems');
    $q->addTable('tasks');
    $q->addQuery('task_project, task_log_problem');
    $q->addJoin('task_log', 'tl', 'tl.task_log_task = task_id', 'inner');
    $q->addWhere('task_log_problem = 1');
    $q->addGroup('task_project');
    $tasks_problems = $q->exec();
    $q->clear();
    if ($addProjectsWithAssignedTasks) {
        // support users tasks
        $q->addInsertSelect('tasks_users');
        $q->addTable('tasks');
        $q->addQuery('task_project');
        $q->addQuery('ut.user_id');
        $q->addJoin('user_tasks', 'ut', 'ut.task_id = tasks.task_id');
        if ($user_id) {
            $q->addWhere('ut.user_id = ' . (int) $user_id);
        }
        $q->addOrder('task_end_date DESC');
        $q->addGroup('task_project');
        $tasks_users = $q->exec();
        $q->clear();
    }
    // add Projects where the Project Owner is in the given department
    if ($addPwOiD && isset($department)) {
        $owner_ids = array();
        $q->addTable('users');
        $q->addQuery('user_id');
        $q->addJoin('contacts', 'c', 'c.contact_id = user_contact', 'inner');
        $q->addWhere('c.contact_department = ' . (int) $department);
        $owner_ids = $q->loadColumn();
        $q->clear();
    }
    if (isset($department)) {
        //If a department is specified, we want to display projects from the department, and all departments under that, so we need to build that list of departments
        $dept_ids = array();
        $q->addTable('departments');
        $q->addQuery('dept_id, dept_parent');
        $q->addOrder('dept_parent,dept_name');
        $rows = $q->loadList();
        addDeptId($rows, $department);
        $dept_ids[] = isset($department->dept_id) ? $department->dept_id : 0;
        $dept_ids[] = $department > 0 ? $department : 0;
    }
    $q->clear();
    // retrieve list of records
    // modified for speed
    // by Pablo Roca (pabloroca@mvps.org)
    // 16 August 2003
    // get the list of permitted companies
    $obj = new CCompany();
    $companies = $obj->getAllowedRecords($AppUI->user_id, 'companies.company_id,companies.company_name', 'companies.company_name');
    if (count($companies) == 0) {
        $companies = array();
    }
    $q->addTable('projects', 'pr');
    $q->addQuery('pr.project_id, project_status, project_color_identifier, project_type, project_name, project_description, project_duration, project_parent, project_original_parent,
		project_start_date, project_end_date, project_color_identifier, project_company, company_name, company_description, project_status,
		project_priority, tc.critical_task, tc.project_actual_end_date, tp.task_log_problem, pr.project_task_count, tsy.my_tasks,
		pr.project_percent_complete, user_username, project_active');
    $q->addQuery('CONCAT(ct.contact_first_name, \' \', ct.contact_last_name) AS owner_name');
    $q->addJoin('users', 'u', 'pr.project_owner = u.user_id');
    $q->addJoin('contacts', 'ct', 'ct.contact_id = u.user_contact');
    $q->addJoin('tasks_critical', 'tc', 'pr.project_id = tc.task_project');
    $q->addJoin('tasks_problems', 'tp', 'pr.project_id = tp.task_project');
    $q->addJoin('tasks_sum', 'ts', 'pr.project_id = ts.task_project');
    $q->addJoin('tasks_summy', 'tsy', 'pr.project_id = tsy.task_project');
    if ($addProjectsWithAssignedTasks) {
        $q->addJoin('tasks_users', 'tu', 'pr.project_id = tu.task_project');
    }
    if (!isset($department) && $company_id && !$addPwOiD) {
        $q->addWhere('pr.project_company = ' . (int) $company_id);
    }
    if ($project_type > -1) {
        $q->addWhere('pr.project_type = ' . (int) $project_type);
    }
    if (isset($department) && !$addPwOiD) {
        $q->addWhere('project_departments.department_id in ( ' . implode(',', $dept_ids) . ' )');
    }
    if ($user_id && $addProjectsWithAssignedTasks) {
        $q->addWhere('(tu.user_id = ' . (int) $user_id . ' OR pr.project_owner = ' . (int) $user_id . ' )');
    } elseif ($user_id) {
        $q->addWhere('pr.project_owner = ' . (int) $user_id);
    }
    if ($owner > 0) {
        $q->addWhere('pr.project_owner = ' . (int) $owner);
    }
    if (mb_trim($search_text)) {
        $q->addWhere('pr.project_name LIKE \'%' . $search_text . '%\' OR pr.project_description LIKE \'%' . $search_text . '%\'');
    }
    // Show Projects where the Project Owner is in the given department
    if ($addPwOiD && !empty($owner_ids)) {
        $q->addWhere('pr.project_owner IN (' . implode(',', $owner_ids) . ')');
    }
    $q->addGroup('pr.project_id');
    $q->addOrder($orderby . ' ' . $orderdir);
    $prj = new CProject();
    $prj->setAllowedSQL($AppUI->user_id, $q, null, 'pr');
    $dpt = new CDepartment();
    $projects = $q->loadList();
    // get the list of permitted companies
    $companies = arrayMerge(array('0' => $AppUI->_('All')), $companies);
    $company_array = $companies;
    //get list of all departments, filtered by the list of permitted companies.
    $q->clear();
    $q->addTable('companies');
    $q->addQuery('company_id, company_name, dep.*');
    $q->addJoin('departments', 'dep', 'companies.company_id = dep.dept_company');
    $q->addOrder('company_name,dept_parent,dept_name');
    $obj->setAllowedSQL($AppUI->user_id, $q);
    $dpt->setAllowedSQL($AppUI->user_id, $q);
    $rows = $q->loadList();
    //display the select list
    $buffer = '<select name="department" id="department" onChange="document.pickCompany.submit()" class="text" style="width: 200px;">';
    $company = '';
    foreach ($company_array as $key => $c_name) {
        $buffer .= '<option value="' . $company_prefix . $key . '" style="font-weight:bold;"' . ($company_id == $key ? 'selected="selected"' : '') . '>' . $c_name . '</option>' . "\n";
        foreach ($rows as $row) {
            if ($row['dept_parent'] == 0) {
                if ($key == $row['company_id']) {
                    if ($row['dept_parent'] != null) {
                        showchilddept($row);
                        findchilddept($rows, $row['dept_id']);
                    }
                }
            }
        }
    }
    $buffer .= '</select>';
}
Beispiel #15
0
$df = $AppUI->getPref('SHDATEFORMAT');
require_once $AppUI->getModuleClass('projects');
$project = new CProject();
if ($project_id > 0) {
    $criticalTasks = $project->getCriticalTasks($project_id);
    $project->load($project_id);
}
// pull valid projects and their percent complete information
$q = new DBQuery();
$q->addTable('projects');
$q->addQuery('project_id, project_color_identifier, project_name' . ', project_start_date, project_end_date');
$q->addJoin('tasks', 't1', 'projects.project_id = t1.task_project');
$q->addWhere('project_status != 7');
$q->addGroup('project_id');
$q->addOrder('project_name');
$project->setAllowedSQL($AppUI->user_id, $q);
$projects = $q->loadHashList('project_id');
$q->clear();
$caller = defVal(@$_REQUEST['caller'], null);
/**
 * if task filtering has been requested create the list of task_ids
 * which will be used to filter the query
 */
if ($ganttTaskFilter > 0) {
    $task_child_search = new CTask();
    $task_child_search->peek($ganttTaskFilter);
    //$childrenlist[] = $ganttTaskFilter;
    //print_r($childrenlist);
    $childrenlist = $task_child_search->getDeepChildren();
    //print_r($childrenlist);
    $where .= ' t.task_id IN (' . $ganttTaskFilter . ', ' . implode(', ', $childrenlist) . ')';
Beispiel #16
0
function projects_list_data($user_id = false)
{
    global $AppUI, $addPwOiD, $cBuffer, $company, $company_id, $company_prefix, $deny, $department;
    global $dept_ids, $dPconfig, $orderby, $orderdir, $projects, $tasks_critical, $tasks_problems;
    global $tasks_sum, $tasks_summy, $tasks_total, $owner, $projectTypeId, $project_status;
    global $currentTabId;
    $addProjectsWithAssignedTasks = $AppUI->getState('addProjWithTasks') ? $AppUI->getState('addProjWithTasks') : 0;
    //for getting permissions on project records
    $obj_project = new CProject();
    // Let's delete temproary tables
    $q = new DBQuery();
    $table_list = array('tasks_sum', 'tasks_total', 'tasks_summy', 'tasks_critical', 'tasks_problems', 'tasks_users');
    $q->dropTemp($table_list);
    $q->exec();
    $q->clear();
    // Task sum table
    // by Pablo Roca (pabloroca@mvps.org)
    // 16 August 2003
    $working_hours = $dPconfig['daily_working_hours'] ? $dPconfig['daily_working_hours'] : 8;
    // GJB: Note that we have to special case duration type 24
    // and this refers to the hours in a day, NOT 24 hours
    $q->createTemp('tasks_sum');
    $q->addTable('tasks', 't');
    $q->addQuery('t.task_project, SUM(t.task_duration * t.task_percent_complete' . ' * IF(t.task_duration_type = 24, ' . $working_hours . ', t.task_duration_type)) / SUM(t.task_duration' . ' * IF(t.task_duration_type = 24, ' . $working_hours . ', t.task_duration_type)) AS project_percent_complete, SUM(t.task_duration' . ' * IF(t.task_duration_type = 24, ' . $working_hours . ', t.task_duration_type)) AS project_duration');
    if ($user_id) {
        $q->addJoin('user_tasks', 'ut', 'ut.task_id = t.task_id');
        $q->addWhere('ut.user_id = ' . $user_id);
    }
    $q->addWhere('t.task_id = t.task_parent');
    $q->addGroup('t.task_project');
    $tasks_sum = $q->exec();
    $q->clear();
    // At this stage tasks_sum contains the project id, and the total of tasks as percentage complate and project duration.
    // I.e. one record per project
    // Task total table
    $q->createTemp('tasks_total');
    $q->addTable('tasks', 't');
    $q->addQuery('t.task_project, COUNT(distinct t.task_id) AS total_tasks');
    if ($user_id) {
        $q->addJoin('user_tasks', 'ut', 'ut.task_id = t.task_id');
        $q->addWhere('ut.user_id = ' . $user_id);
    }
    $q->addGroup('t.task_project');
    $tasks_total = $q->exec();
    $q->clear();
    // tasks_total contains the total number of tasks for each project.
    // temporary My Tasks
    // by Pablo Roca (pabloroca@mvps.org)
    // 16 August 2003
    $q->createTemp('tasks_summy');
    $q->addTable('tasks', 't');
    $q->addQuery('t.task_project, COUNT(DISTINCT t.task_id) AS my_tasks');
    $q->addWhere('t.task_owner = ' . ($user_id ? $user_id : $AppUI->user_id));
    $q->addGroup('t.task_project');
    $tasks_summy = $q->exec();
    $q->clear();
    // tasks_summy contains total count of tasks for each project that I own.
    // temporary critical tasks
    $q->createTemp('tasks_critical');
    $q->addTable('tasks', 't');
    $q->addQuery('t.task_project, t.task_id AS critical_task' . ', MAX(t.task_end_date) AS project_actual_end_date');
    // MerlinYoda: we don't join tables if we don't get anything out of the process
    // $q->addJoin('projects', 'p', 'p.project_id = t.task_project');
    $q->addOrder('t.task_end_date DESC');
    $q->addGroup('t.task_project');
    $tasks_critical = $q->exec();
    $q->clear();
    // tasks_critical contains the latest ending task and its end date.
    // temporary task problem logs
    $q->createTemp('tasks_problems');
    $q->addTable('tasks', 't');
    $q->addQuery('t.task_project, tl.task_log_problem');
    $q->addJoin('task_log', 'tl', 'tl.task_log_task = t.task_id');
    $q->addWhere('tl.task_log_problem > 0');
    $q->addGroup('t.task_project');
    $tasks_problems = $q->exec();
    $q->clear();
    // tasks_problems contains an indication of any projects that have task logs set to problem.
    if ($addProjectsWithAssignedTasks) {
        // temporary users tasks
        $q->createTemp('tasks_users');
        $q->addTable('tasks', 't');
        $q->addQuery('t.task_project, ut.user_id');
        $q->addJoin('user_tasks', 'ut', 'ut.task_id = t.task_id');
        if ($user_id) {
            $q->addWhere('ut.user_id = ' . $user_id);
        }
        $q->addOrder('t.task_end_date DESC');
        $q->addGroup('t.task_project');
        $tasks_users = $q->exec();
        $q->clear();
    }
    // tasks_users contains all projects with tasks that have user assignments. (isn't this getting pointless?)
    // add Projects where the Project Owner is in the given department
    if ($addPwOiD && isset($department)) {
        $owner_ids = array();
        $q->addTable('users', 'u');
        $q->addQuery('u.user_id');
        $q->addJoin('contacts', 'c', 'c.contact_id = u.user_contact');
        $q->addWhere('c.contact_department = ' . $department);
        $owner_ids = $q->loadColumn();
        $q->clear();
    }
    if (isset($department)) {
        /*
         * If a department is specified, we want to display projects from the department
         * and all departments under that, so we need to build that list of departments
         */
        $dept_ids = array();
        $q->addTable('departments');
        $q->addQuery('dept_id, dept_parent');
        $q->addOrder('dept_parent,dept_name');
        $rows = $q->loadList();
        addDeptId($rows, $department);
        $dept_ids[] = $department;
    }
    $q->clear();
    $q->addTable('projects', 'p');
    $q->addQuery('p.project_id, p.project_status, p.project_color_identifier, p.project_type' . ', p.project_name, p.project_description, p.project_start_date' . ', p.project_end_date, p.project_color_identifier, p.project_company' . ', p.project_status, p.project_priority, com.company_name' . ', com.company_description, tc.critical_task, tc.project_actual_end_date' . ', if (tp.task_log_problem IS NULL, 0, tp.task_log_problem) AS task_log_problem' . ', tt.total_tasks, tsy.my_tasks, ts.project_percent_complete' . ', ts.project_duration, u.user_username');
    $q->addJoin('companies', 'com', 'p.project_company = com.company_id');
    $q->addJoin('users', 'u', 'p.project_owner = u.user_id');
    $q->addJoin('tasks_critical', 'tc', 'p.project_id = tc.task_project');
    $q->addJoin('tasks_problems', 'tp', 'p.project_id = tp.task_project');
    $q->addJoin('tasks_sum', 'ts', 'p.project_id = ts.task_project');
    $q->addJoin('tasks_total', 'tt', 'p.project_id = tt.task_project');
    $q->addJoin('tasks_summy', 'tsy', 'p.project_id = tsy.task_project');
    if ($addProjectsWithAssignedTasks) {
        $q->addJoin('tasks_users', 'tu', 'p.project_id = tu.task_project');
    }
    if (isset($project_status) && $currentTabId != 500) {
        $q->addWhere('p.project_status = ' . $project_status);
    }
    if (isset($department)) {
        $q->addJoin('project_departments', 'pd', 'pd.project_id = p.project_id');
        if (!$addPwOiD) {
            $q->addWhere('pd.department_id in (' . implode(',', $dept_ids) . ')');
        } else {
            // Show Projects where the Project Owner is in the given department
            $q->addWhere('p.project_owner IN (' . (!empty($owner_ids) ? implode(',', $owner_ids) : 0) . ')');
        }
    } else {
        if ($company_id && !$addPwOiD) {
            $q->addWhere('p.project_company = ' . $company_id);
        }
    }
    if ($projectTypeId > -1) {
        $q->addWhere('p.project_type = ' . $projectTypeId);
    }
    if ($user_id && $addProjectsWithAssignedTasks) {
        $q->addWhere('(tu.user_id = ' . $user_id . ' OR p.project_owner = ' . $user_id . ')');
    } else {
        if ($user_id) {
            $q->addWhere('p.project_owner = ' . $user_id);
        }
    }
    if ($owner > 0) {
        $q->addWhere('p.project_owner = ' . $owner);
    }
    $q->addGroup('p.project_id');
    $q->addOrder($orderby . ' ' . $orderdir);
    $obj_project->setAllowedSQL($AppUI->user_id, $q, null, 'p');
    $projects = $q->loadList();
    // retrieve list of records
    // modified for speed
    // by Pablo Roca (pabloroca@mvps.org)
    // 16 August 2003
    // get the list of permitted companies
    $obj_company = new CCompany();
    $companies = $obj_company->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name');
    if (count($companies) == 0) {
        $companies = array(0);
    }
    // get the list of permitted companies
    $companies = arrayMerge(array('0' => $AppUI->_('All')), $companies);
    //get list of all departments, filtered by the list of permitted companies.
    $q->clear();
    $q->addTable('companies', 'c');
    $q->addQuery('c.company_id, c.company_name, dep.*');
    $q->addJoin('departments', 'dep', 'c.company_id = dep.dept_company');
    $q->addJoin('projects', 'p', 'p.project_company = c.company_id');
    $q->addWhere('p.project_status NOT IN (1, 4, 5, 6, 7)');
    $q->addOrder('c.company_name, dep.dept_parent, dep.dept_name');
    $obj_company->setAllowedSQL($AppUI->user_id, $q);
    $active_companies = $q->loadList();
    $q->clear();
    $q->addTable('companies', 'c');
    $q->addQuery('c.company_id, c.company_name, dep.*');
    $q->addJoin('departments', 'dep', 'c.company_id = dep.dept_company');
    $q->addJoin('projects', 'p', 'p.project_company = c.company_id');
    $q->addOrder('c.company_name, dep.dept_parent, dep.dept_name');
    $obj_company->setAllowedSQL($AppUI->user_id, $q);
    $all_companies = $q->loadList();
    //display the select list
    $cBuffer = '<select name="department" onchange="javascript:document.pickCompany.submit()" class="text">';
    $cBuffer .= '<option value="company_0" style="font-weight:bold;">' . $AppUI->_('All') . '</option>' . "\n";
    $company = '';
    $active_company_ids = array();
    // Active companies first
    $cBuffer .= '<optgroup label="Active">';
    foreach ($active_companies as $row) {
        if ($row['dept_parent'] == 0) {
            if ($company != $row['company_id']) {
                $cBuffer .= '<option value="' . $AppUI->___($company_prefix . $row['company_id']) . '" style="font-weight:bold;"' . ($company_id == $row['company_id'] ? 'selected="selected"' : '') . '>' . $AppUI->___($row['company_name']) . '</option>' . "\n";
                $company = $row['company_id'];
                $active_company_ids[] = $company;
            }
            if ($row['dept_parent'] != null) {
                showchilddept($row);
                findchilddept($rows, $row['dept_id']);
            }
        }
    }
    $cBuffer .= '</optgroup>';
    // Inactive companies
    $cBuffer .= '<optgroup label="Inactive">';
    foreach ($all_companies as $row) {
        if ($row['dept_parent'] == 0 and !in_array($row['company_id'], $active_company_ids)) {
            if ($company != $row['company_id']) {
                $cBuffer .= '<option value="' . $AppUI->___($company_prefix . $row['company_id']) . '" style="font-weight:bold;"' . ($company_id == $row['company_id'] ? 'selected="selected"' : '') . '>' . $AppUI->___($row['company_name']) . '</option>' . "\n";
                $company = $row['company_id'];
            }
            if ($row['dept_parent'] != null) {
                showchilddept($row);
                findchilddept($rows, $row['dept_id']);
            }
        }
    }
    $cBuffer .= '</optgroup>';
    $cBuffer .= '</select>';
}
Beispiel #17
0
//$q->addJoin('projects', 'p', 'task_project = p.project_id');
$q->addWhere("task_project = {$project_id} ");
if ($user_id > 0) {
    $q->addWhere("task_log_creator={$user_id}");
}
if ($hide_inactive) {
    $q->addWhere('task_status >= 0');
}
if ($hide_complete) {
    $q->addWhere('task_percent_complete < 100');
}
if ($cost_code != 0) {
    $q->addWhere("task_log_costcode = '{$cost_code}'");
}
$q->addOrder('task_log_date');
$project->setAllowedSQL($AppUI->user_id, $q, 'task_project');
$logs = $q->loadList();
$s = '';
$hrs = 0;
foreach ($logs as $row) {
    $task_log_date = intval($row['task_log_date']) ? new CDate($row['task_log_date']) : null;
    $s .= '<tr bgcolor="white" valign="top">';
    $s .= "\n\t<td>";
    if (getPermission('tasks', 'edit', $row['task_id'])) {
        $s .= "\n\t\t" . '<a href="?m=tasks&amp;a=view&amp;task_id=' . $row['task_id'] . "&amp;tab=1&amp;task_log_id=" . @$row['task_log_id'] . '">' . "\n\t\t\t" . dPshowImage('./images/icons/stock_edit-16.png', 16, 16, '') . "\n\t\t</a>";
    }
    $s .= "\n\t</td>";
    $s .= '<td nowrap="nowrap">' . ($task_log_date ? $task_log_date->format($df) : '-') . '</td>';
    $s .= '<td width="30%"><a href="?m=tasks&a=view&task_id=' . $row['task_id'] . '&tab=0">' . @$row["task_log_name"] . '</a></td>';
    $s .= '<td width="100">' . $row["user_username"] . '</td>';
    $s .= '<td width="100" align="right">' . sprintf("%.2f", $row["task_log_hours"]) . '</td>';
     $sql->addWhere("p.project_company='{$company_id}'");
 }
 if ($log_userfilter != 0) {
     $sql->addWhere('ut.user_id = ' . $log_userfilter);
 }
 $task = new CTask();
 $allowedTasks = $task->getAllowedSQL($AppUI->user_id, 't.task_id');
 if (count($allowedTasks)) {
     $sql->addWhere(implode(' AND ', $allowedTasks));
 }
 $allowedChildrenTasks = $task->getAllowedSQL($AppUI->user_id, 't.task_parent');
 if (count($allowedChildrenTasks)) {
     $sql->addWhere(implode(' AND ', $allowedChildrenTasks));
 }
 // Now add the required restrictions.
 $proj->setAllowedSQL($AppUI->user_id, $sql, null, 'p');
 $sql->addOrder('task_project, task_end_date, task_start_date');
 $task_list_hash = $sql->loadHashList('task_id');
 $task_list = array();
 $task_assigned_users = array();
 $user_assigned_tasks = array();
 foreach ($task_list_hash as $task_id => $task_data) {
     $task = new CTask();
     $task->bind($task_data);
     $task_users = $task->getAssignedUsers();
     foreach (array_keys($task_users) as $uid) {
         $user_assigned_tasks[$uid][] = $task_id;
     }
     $task->task_assigned_users = $task_users;
     $task_list[$task_id] = $task;
 }
Beispiel #19
0
// setup the title block
$titleBlock = new CTitleBlock('Projects', 'applet3-48.png', $m, $m . '.' . $a);
$titleBlock->addCell($AppUI->_('Owner') . ':');
$titleBlock->addCell('<form action="?m=projects" method="post" name="pickUser">' . "\n" . $bufferUser . "\n" . '</form>' . "\n");
$titleBlock->addCell($AppUI->_('Company') . '/' . $AppUI->_('Division') . ':');
$titleBlock->addCell('<form action="?m=projects" method="post" name="pickCompany">' . "\n" . $cBuffer . "\n" . '</form>' . "\n");
$titleBlock->addCell();
if ($canAuthor) {
    $titleBlock->addCell('<form action="?m=projects&amp;a=addedit" method="post">' . "\n" . '<input type="submit" class="button" value="' . $AppUI->_('new project') . '" />' . "\n" . '</form>' . "\n");
}
$titleBlock->show();
$project_types = dPgetSysVal('ProjectStatus');
// count number of projects per project_status
$q->addTable('projects', 'p');
$q->addQuery('p.project_status, COUNT(p.project_id) as count');
$obj_project->setAllowedSQL($AppUI->user_id, $q, null, 'p');
if ($owner > 0) {
    $q->addWhere('p.project_owner = ' . $owner);
}
if (isset($department)) {
    $q->addJoin('project_departments', 'pd', 'pd.project_id = p.project_id');
    if (!$addPwOiD) {
        $q->addWhere('pd.department_id in (' . implode(',', $dept_ids) . ')');
    }
} else {
    if ($company_id && !$addPwOiD) {
        $q->addWhere('p.project_company = ' . $company_id);
    }
}
$q->addGroup('project_status');
$statuses = $q->loadHashList('project_status');
Beispiel #20
0
if ($file_id) {
    // projects tat are denied access
    require_once $AppUI->getModuleClass('projects');
    require_once $AppUI->getModuleClass('files');
    $project = new CProject();
    $allowedProjects = $project->getAllowedRecords($AppUI->user_id, 'project_id, project_name');
    $fileclass = new CFile();
    $fileclass->load($file_id);
    $allowedFiles = $fileclass->getAllowedRecords($AppUI->user_id, 'file_id, file_name');
    if (count($allowedFiles) && !array_key_exists($file_id, $allowedFiles)) {
        $AppUI->redirect('m=public&a=access_denied');
    }
    $q = new DBQuery();
    $q->addTable('files');
    if ($fileclass->file_project) {
        $project->setAllowedSQL($AppUI->user_id, $q, 'file_project');
    }
    $q->addWhere('file_id = ' . $file_id);
    $sql = $q->prepare();
    if (!db_loadHash($sql, $file)) {
        $AppUI->redirect('m=public&a=access_denied');
    }
    /*
     * DISABLED LINES TO FIX A NEWER BUG 914075 WITH IE 6 (GREGORERHARDT 20040612)
    
    // BEGIN extra headers to resolve IE caching bug (JRP 9 Feb 2003)
    // [http://bugs.php.net/bug.php?id=16173]
    header('Pragma: ');
    header('Cache-Control: ');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
 /**
  * @param w2p_Core_CAppUI $AppUI
  * @param                 $companyId
  * @param int             $active
  * @param string          $sort
  *
  * @return Array
  */
 public function projects(w2p_Core_CAppUI $AppUI, $companyId, $active = 1, $sort = 'project_name')
 {
     $fields = 'DISTINCT pr.project_id, pr.*, contact_first_name, ' . 'contact_last_name, contact_display_name as contact_name, ' . 'contact_display_name as project_owner, contact_display_name as user_username, user_id';
     $q = $this->_getQuery();
     $q->addTable('projects', 'pr');
     $q->addQuery($fields);
     $q->leftJoin('users', 'u', 'u.user_id = pr.project_owner');
     $q->leftJoin('contacts', 'con', 'u.user_contact = con.contact_id');
     if ((int) $companyId > 0) {
         $q->addWhere('pr.project_company = ' . (int) $companyId);
     }
     $projObj = new CProject();
     //TODO: We need to convert this from static to use ->overrideDatabase() for testing.
     $q = $projObj->setAllowedSQL($AppUI->user_id, $q, null, 'pr');
     $q->addWhere('pr.project_active = ' . (int) $active);
     if (property_exists('CProject', $sort) || strpos($fields, $sort) !== false) {
         $q->addOrder($sort);
     } else {
         $q->addOrder('project_name');
     }
     return $q->loadList();
 }