public function getStructure($moduleName)
 {
     $q = new w2p_Database_Query();
     $q->addTable('custom_fields_struct');
     $q->addWhere("field_module = '{$moduleName}'");
     $q->addOrder('field_order ASC');
     return $q->loadList();
 }
예제 #2
0
 public function getMessages(CAppUI $AppUI, $forum_id = 0, $message_id = 0, $sortDir = 'asc')
 {
     $q = new w2p_Database_Query();
     $q->addTable('forums');
     $q->addTable('forum_messages');
     $q->addQuery('forum_messages.*,	contact_first_name, contact_last_name, contact_email,
         contact_display_name, user_username, forum_moderated, visit_user');
     $q->addJoin('forum_visits', 'v', 'visit_user = '******' AND visit_forum = ' . (int) $forum_id . ' AND visit_message = forum_messages.message_id');
     $q->addJoin('users', 'u', 'message_author = u.user_id', 'inner');
     $q->addJoin('contacts', 'con', 'contact_id = user_contact', 'inner');
     $q->addWhere('forum_id = message_forum AND (message_id = ' . (int) $message_id . ' OR message_parent = ' . (int) $message_id . ')');
     $q->addOrder('message_date ' . $sortDir);
     return $q->loadList();
 }
 public function load()
 {
     global $db;
     $q = new w2p_Database_Query();
     $q->addTable('custom_fields_lists');
     $q->addWhere('field_id = ' . $this->field_id);
     $q->addOrder('list_value');
     if (!$q->exec()) {
         return $db->ErrorMsg();
     }
     while ($opt_row = $q->fetchRow()) {
         $this->options[$opt_row['list_option_id']] = $opt_row['list_value'];
     }
 }
예제 #4
0
/** Retrieve tasks with first task_end_dates within given project
 * @param int Project_id
 * @param int SQL-limit to limit the number of returned tasks
 * @return array List of criticalTasks
 */
function getCriticalTasksInverted($project_id = null, $limit = 1)
{
    if (!$project_id) {
        $result = array();
        $result[0]['task_end_date'] = '0000-00-00 00:00:00';
        return $result;
    } else {
        $q = new w2p_Database_Query();
        $q->addTable('tasks');
        $q->addWhere('task_project = ' . (int) $project_id . ' AND NOT ISNULL( task_end_date ) AND task_end_date <>  \'0000-00-00 00:00:00\'');
        $q->addOrder('task_start_date ASC');
        $q->setLimit($limit);
        return $q->loadList();
    }
}
예제 #5
0
 public function w2Psearch_acl($application = 'application', $op, $user = '******', $userid, $module)
 {
     global $w2p_performance_acltime, $w2p_performance_aclchecks;
     $q = new w2p_Database_Query();
     $q->addTable($this->_db_acl_prefix . 'permissions');
     $q->addQuery('acl_id, access, item_id');
     $q->addWhere('module = \'' . $module . '\'');
     $q->addWhere('action = \'' . $op . '\'');
     $q->addWhere('user_id = ' . (int) $userid);
     $q->addOrder('acl_id DESC');
     if (W2P_PERFORMANCE_DEBUG) {
         $startTime = array_sum(explode(' ', microtime()));
     }
     $res = $q->loadList();
     if (W2P_PERFORMANCE_DEBUG) {
         ++$w2p_performance_aclchecks;
         $w2p_performance_acltime += array_sum(explode(' ', microtime())) - $startTime;
     }
     return $res;
 }
예제 #6
0
    if (!$log_all) {
        $q->addWhere('task_log_date >= \'' . $start_date->format(FMT_DATETIME_MYSQL) . '\'');
        $q->addWhere('task_log_date <= \'' . $end_date->format(FMT_DATETIME_MYSQL) . '\'');
    }
    if ($log_ignore) {
        $q->addWhere('task_log_hours > 0');
    }
    if ($log_userfilter) {
        $q->addWhere('task_log_creator = ' . (int) $log_userfilter);
    }
    $proj = new CProject();
    $allowedProjects = $proj->getAllowedSQL($AppUI->user_id, 'task_project');
    if (count($allowedProjects)) {
        $q->addWhere(implode(' AND ', $allowedProjects));
    }
    $q->addOrder('creator');
    $q->addOrder('company_name');
    $q->addOrder('project_name');
    $q->addOrder('task_log_date');
    $logs = $q->loadList();
    echo db_error();
    ?>
	<table cellspacing="1" cellpadding="4" border="0" class="tbl">
	<tr>
		<th><?php 
    echo $AppUI->_('Creator');
    ?>
</th>
		<th><?php 
    echo $AppUI->_('Company');
    ?>
예제 #7
0
function getStructuredProjects($original_project_id = 0, $project_status = -1, $active_only = false)
{
    global $AppUI, $st_projects_arr;
    $st_projects = array(0 => '');
    $q = new w2p_Database_Query();
    $q->addTable('projects');
    $q->addJoin('companies', '', 'projects.project_company = company_id', 'inner');
    $q->addQuery('DISTINCT(projects.project_id), project_name, project_parent');
    if ($original_project_id) {
        $q->addWhere('project_original_parent = ' . (int) $original_project_id);
    }
    if ($project_status >= 0) {
        $q->addWhere('project_status = ' . (int) $project_status);
    }
    if ($active_only) {
        $q->addWhere('project_active = 1');
    }
    $q->addOrder('project_start_date, project_end_date');
    $obj = new CCompany();
    $obj->setAllowedSQL($AppUI->user_id, $q);
    $dpt = new CDepartment();
    $dpt->setAllowedSQL($AppUI->user_id, $q);
    $q->leftJoin('project_departments', 'pd', 'pd.project_id = projects.project_id');
    $q->leftJoin('departments', 'd', 'd.dept_id = pd.department_id');
    $st_projects = $q->loadList();
    $tnums = count($st_projects);
    for ($i = 0; $i < $tnums; $i++) {
        $st_project = $st_projects[$i];
        if ($st_project['project_parent'] == $st_project['project_id']) {
            show_st_project($st_project);
            find_proj_child($st_projects, $st_project['project_id']);
        }
    }
}
예제 #8
0
$showIncomplete = $AppUI->getState('TaskListShowIncomplete', 0);
$project = new CProject();
$allowedProjects = $project->getAllowedSQL($AppUI->user_id, 'p.project_id');
$where_list = count($allowedProjects) ? implode(' AND ', $allowedProjects) : '';
$working_hours = $w2Pconfig['daily_working_hours'] ? $w2Pconfig['daily_working_hours'] : 8;
$q = new w2p_Database_Query();
$q->addTable('projects', 'p');
$q->addQuery('company_name, p.project_id, project_color_identifier, project_name, project_percent_complete');
$q->addJoin('companies', 'com', 'company_id = project_company', 'inner');
$q->addJoin('tasks', 't1', 'p.project_id = t1.task_project', 'inner');
$q->leftJoin('project_departments', 'project_departments', 'p.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($where_list . ($where_list ? ' AND ' : '') . 't1.task_id = t1.task_parent');
$q->addGroup('p.project_id');
if (!$project_id && !$task_id) {
    $q->addOrder('project_name');
}
if ($project_id > 0) {
    $q->addWhere('p.project_id = ' . $project_id);
}
$q2 = new w2p_Database_Query();
$q2->addTable('projects');
$q2->addQuery('project_id, COUNT(t1.task_id) AS total_tasks');
$q2->addJoin('tasks', 't1', 'projects.project_id = t1.task_project', 'inner');
if ($where_list) {
    $q2->addWhere($where_list);
}
if ($project_id > 0) {
    $q2->addWhere('project_id = ' . $project_id);
}
$q2->addGroup('project_id');
 public function getAllTasksForPeriod($start_date, $end_date, $company_id = 0, $user_id = null)
 {
     global $AppUI;
     $q = new w2p_Database_Query();
     // convert to default db time stamp
     $db_start = $start_date->format(FMT_DATETIME_MYSQL);
     $db_end = $end_date->format(FMT_DATETIME_MYSQL);
     // Allow for possible passing of user_id 0 to stop user filtering
     if (!isset($user_id)) {
         $user_id = $AppUI->user_id;
     }
     // check permissions on projects
     $proj = new CProject();
     $task_filter_where = $proj->getAllowedSQL($AppUI->user_id, 't.task_project');
     // exclude read denied projects
     $deny = $proj->getDeniedRecords($AppUI->user_id);
     // check permissions on tasks
     $obj = new CTask();
     $allow = $obj->getAllowedSQL($AppUI->user_id, 't.task_id');
     $q->addTable('tasks', 't');
     if ($user_id) {
         $q->innerJoin('user_tasks', 'ut', 't.task_id=ut.task_id');
     }
     $q->innerJoin('projects', 'projects', 't.task_project = projects.project_id');
     $q->innerJoin('companies', 'companies', 'projects.project_company = companies.company_id');
     $q->leftJoin('project_departments', '', 'projects.project_id = project_departments.project_id');
     $q->leftJoin('departments', '', 'departments.dept_id = project_departments.department_id');
     $q->addQuery('DISTINCT t.task_id, t.task_name, t.task_start_date, t.task_end_date, t.task_percent_complete, t.task_duration' . ', t.task_duration_type, projects.project_color_identifier AS color, projects.project_name, t.task_milestone, task_description, task_type, company_name, task_access, task_owner');
     $q->addWhere('task_status > -1' . ' AND (task_start_date <= \'' . $db_end . '\'  AND t.task_percent_complete<100  OR task_end_date = \'0000-00-00 00:00:00\' OR task_end_date = NULL )');
     $q->addWhere('project_active = 1');
     if (($template_status = w2PgetConfig('template_projects_status_id')) != '') {
         $q->addWhere('project_status <> ' . $template_status);
     }
     if ($user_id) {
         $q->addWhere('ut.user_id = ' . (int) $user_id);
     }
     if ($company_id) {
         $q->addWhere('projects.project_company = ' . (int) $company_id);
     }
     if (count($task_filter_where) > 0) {
         $q->addWhere('(' . implode(' AND ', $task_filter_where) . ')');
     }
     if (count($deny) > 0) {
         $q->addWhere('(t.task_project NOT IN (' . implode(', ', $deny) . '))');
     }
     if (count($allow) > 0) {
         $q->addWhere('(' . implode(' AND ', $allow) . ')');
     }
     $q->addOrder('t.task_start_date');
     // assemble query
     $tasks = $q->loadList(-1, 'task_id');
     // check tasks access
     $result = array();
     foreach ($tasks as $key => $row) {
         $obj->load($row['task_id']);
         $canAccess = $obj->canAccess();
         if (!$canAccess) {
             continue;
         }
         $result[$key] = $row;
     }
     // execute and return
     return $result;
 }
예제 #10
0
// Check permissions
$perms =& $AppUI->acl();
if (!canEdit('system')) {
    $AppUI->redirect('m=public&a=access_denied');
}
$q = new w2p_Database_Query();
$q->addTable('billingcode', 'bc');
$q->addQuery('billingcode_id, billingcode_name, billingcode_value, billingcode_desc, billingcode_status');
$q->addOrder('billingcode_name ASC');
$q->addWhere('company_id = ' . (int) $company_id);
$billingcodes = $q->loadList();
$q->clear();
$q = new w2p_Database_Query();
$q->addTable('companies', 'c');
$q->addQuery('company_id, company_name');
$q->addOrder('company_name ASC');
$company_list = $q->loadHashList();
$company_list[0] = $AppUI->_('Select Company');
$q->clear();
$company_name = $company_list[$company_id];
$titleBlock = new CTitleBlock('Edit Billing Codes', 'myevo-weather.png', $m, $m . '.' . $a);
$titleBlock->addCrumb('?m=system', 'system admin');
$titleBlock->show();
?>
<script language="javascript" type="text/javascript">
<!--
function submitIt(){
	var form = document.changeuser;
	form.submit();
}
예제 #11
0
 public function getAllowedTaskList($AppUI, $task_project = 0)
 {
     $results = array();
     $q = new w2p_Database_Query();
     $q->addQuery('task_id, task_name, task_parent, task_access, task_owner');
     $q->addQuery('task_start_date, task_end_date, task_percent_complete');
     $q->addOrder('task_parent, task_parent = task_id desc');
     $q->addTable('tasks', 't');
     if ($task_project) {
         $q->addWhere('task_project = ' . (int) $task_project);
     }
     if ($orderby == '') {
         $q->addOrder('task_parent, task_parent = task_id desc');
     } else {
         $q->addOrder($orderby);
     }
     $task_list = $q->loadList();
     foreach ($task_list as $task) {
         if (canTaskAccess($task['task_id'], $task['task_access'], $task['task_owner'])) {
             $results[] = $task;
         }
     }
     return $results;
 }
예제 #12
0
// check permissions
$perms =& $AppUI->acl();
$canEdit = canEdit('system');
$canRead = canView('system');
if (!$canRead) {
    $AppUI->redirect('m=public&a=access_denied');
}
$AppUI->savePlace();
$hidden_modules = array('public', 'install');
$q = new w2p_Database_Query();
$q->addQuery('*');
$q->addTable('modules');
foreach ($hidden_modules as $no_show) {
    $q->addWhere('mod_directory <> \'' . $no_show . '\'');
}
$q->addOrder('mod_ui_order');
$modules = $q->loadList();
// get the modules actually installed on the file system
$modFiles = $AppUI->readDirs('modules');
$titleBlock = new CTitleBlock('Modules', 'power-management.png', $m, "{$m}.{$a}");
$titleBlock->addCrumb('?m=system', 'System Admin');
$titleBlock->show();
?>

<table border="0" cellpadding="2" cellspacing="1" width="100%" class="tbl">
    <tr>
        <th colspan="2"><?php 
echo $AppUI->_('Module');
?>
</th>
        <th><?php 
예제 #13
0
                $r->clear();
            }
        }
    } while ($boot_query_row);
    $msg = $boot_user_name . ' logged out by ' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name;
    $AppUI->setMsg($msg, UI_MSG_OK);
    $AppUI->redirect('m=admin&tab=3');
}
$q = new w2p_Database_Query();
$q->addTable('sessions', 's');
$q->addQuery('DISTINCT(session_id), user_access_log_id, u.user_id as u_user_id, user_username, contact_last_name, contact_first_name, company_name, contact_company, date_time_in, user_ip');
$q->addJoin('user_access_log', 'ual', 'session_user = user_access_log_id');
$q->addJoin('users', 'u', 'ual.user_id = u.user_id');
$q->addJoin('contacts', 'con', 'u.user_contact = contact_id');
$q->addJoin('companies', 'com', 'contact_company = company_id');
$q->addOrder($orderby);
$rows = $q->loadList();
$q->clear();
$tab = w2PgetParam($_REQUEST, 'tab', 0);
?>

<table cellpadding="2" cellspacing="1" border="0" width="100%" class="tbl">
    <tr>
        <th colspan="2">&nbsp; <?php 
echo $AppUI->_('sort by');
?>
:&nbsp;</th>
        <?php 
$fieldList = array('user_username', 'contact_last_name', 'company_name', 'date_time_in', 'user_ip');
$fieldNames = array('Login Name', 'Real Name', 'Company', 'Date Time IN', 'Internet Address');
foreach ($fieldNames as $index => $name) {
예제 #14
0
 public function _buildQuery()
 {
     $q = new w2p_Database_Query();
     if ($this->table_alias) {
         $q->addTable($this->table, $this->table_alias);
     } else {
         $q->addTable($this->table);
     }
     $q->addQuery('DISTINCT(' . $this->table_key . ')');
     if (isset($this->table_key2)) {
         $q->addQuery($this->table_key2);
     }
     //--MSy--
     foreach ($this->table_joins as $join) {
         $q->addJoin($join['table'], $join['alias'], $join['join']);
     }
     foreach ($this->display_fields as $fld) {
         $q->addQuery($fld);
     }
     $q->addOrder($this->table_orderby);
     if ($this->table_groupby) {
         $q->addGroup($this->table_groupby);
     }
     if ($this->table_extra) {
         $q->addWhere($this->table_extra);
     }
     $ignore = w2PgetSysVal('FileIndexIgnoreWords');
     $ignore = explode(',', $ignore['FileIndexIgnoreWords']);
     $this->keywords = array_diff(array_keys($this->keywords), $ignore);
     $sql = '';
     foreach ($this->keywords as $keyword) {
         $sql .= '(';
         foreach ($this->search_fields as $field) {
             //OR treatment to each keyword
             // Search for semi-colons, commas or spaces and allow any to be separators
             $or_keywords = preg_split('/[\\s,;]+/', $keyword);
             foreach ($or_keywords as $or_keyword) {
                 if ($this->search_options['ignore_specchar'] == 'on') {
                     $tmppattern = recode2regexp_utf8($or_keyword);
                     if ($this->search_options['ignore_case'] == 'on') {
                         $sql .= ' ' . $field . ' REGEXP \'' . $tmppattern . '\' or ';
                     } else {
                         $sql .= ' ' . $field . ' REGEXP BINARY \'' . $tmppattern . '\' or ';
                     }
                 } else {
                     if ($this->search_options['ignore_case'] == 'on') {
                         $sql .= ' ' . $field . ' LIKE "%' . $or_keyword . '%" or ';
                     } else {
                         $sql .= ' ' . $field . ' LIKE BINARY "%' . $or_keyword . '%" or ';
                     }
                 }
             }
         }
         // foreach $field
         $sql = substr($sql, 0, -4);
         if ($this->search_options['all_words'] == 'on') {
             $sql .= ') and ';
         } else {
             $sql .= ') or ';
         }
     }
     // foreach $keyword
     //--MSy--
     $sql = substr($sql, 0, -4);
     if ($sql) {
         $q->addWhere($sql);
         return $q;
     } else {
         return null;
     }
 }
예제 #15
0
 public function getTaskLogs(CAppUI $AppUI = null, $projectId, $user_id = 0, $hide_inactive = false, $hide_complete = false, $cost_code = 0)
 {
     global $AppUI;
     $q = new w2p_Database_Query();
     $q->addTable('task_log');
     $q->addQuery('DISTINCT task_log.*, user_username, task_id');
     $q->addQuery("CONCAT(contact_first_name, ' ', contact_last_name) AS real_name");
     $q->addQuery('billingcode_name as task_log_costcode');
     $q->addJoin('users', 'u', 'user_id = task_log_creator');
     $q->addJoin('tasks', 't', 'task_log_task = t.task_id');
     $q->addJoin('contacts', 'ct', 'contact_id = user_contact');
     $q->addJoin('billingcode', 'b', 'task_log.task_log_costcode = billingcode_id');
     $q->addWhere('task_project = ' . (int) $projectId);
     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("billingcode_id = {$cost_code}");
     }
     $q->addOrder('task_log_date');
     $q->addOrder('task_log_created');
     $this->setAllowedSQL($AppUI->user_id, $q, 'task_project');
     return $q->loadList();
 }
예제 #16
0
    $log->load($task_log_id);
} else {
    if (!$canAdd || !$canViewTask) {
        $AppUI->redirect('m=public&a=access_denied');
    }
    $log->task_log_task = $obj->task_id;
    $log->task_log_name = $obj->task_name;
}
$proj = new CProject();
$proj->load($obj->task_project);
$q = new w2p_Database_Query();
$q->addTable('billingcode');
$q->addQuery('billingcode_id, billingcode_name');
$q->addWhere('billingcode_status=0');
$q->addWhere('(company_id=' . $proj->project_company . ' OR company_id = 0)');
$q->addOrder('billingcode_name');
$task_log_costcodes[0] = '';
$rows = $q->loadList();
echo db_error();
$nums = 0;
foreach ($rows as $key => $row) {
    $task_log_costcodes[$row['billingcode_id']] = $row['billingcode_name'];
}
$taskLogReference = w2PgetSysVal('TaskLogReference');
// Task Update Form
$df = $AppUI->getPref('SHDATEFORMAT');
$log_date = new w2p_Utilities_Date($log->task_log_date);
?>

<!-- TIMER RELATED SCRIPTS -->
<script language="javascript" type="text/javascript">
예제 #17
0
 }
 if ($use_period) {
     $q->addWhere('(( task_start_date >= ' . $ss . ' AND task_start_date <= ' . $se . ' ) OR ' . '  ( task_end_date <= ' . $se . ' AND task_end_date >= ' . $ss . ' ))');
 }
 $q->addWhere('(task_percent_complete < 100)');
 $q->addJoin('user_tasks', 'ut', 'ut.task_id = t.task_id');
 if ($log_userfilter > -1) {
     $q->addWhere('ut.user_id = ' . $log_userfilter);
 }
 if ($project_id != 'all') {
     $q->addWhere('t.task_project=' . (int) $project_id);
 }
 if ($company_id != 'all') {
     $q->addWhere('pr.project_company = ' . (int) $company_id);
 }
 $q->addOrder('task_project');
 $q->addOrder('task_end_date');
 $q->addOrder('task_start_date');
 $proj->setAllowedSQL($AppUI->user_id, $q, null, 'pr');
 $task_list_hash = $q->loadHashList('task_id');
 $q->clear();
 $task_list = array();
 $task_assigned_users = array();
 $user_assigned_tasks = array();
 $i = 0;
 foreach ($task_list_hash as $task_id => $task_data) {
     $task = new CTask();
     $task->load($task_id);
     $task_users = $task->getAssignedUsers($task_id);
     foreach (array_keys($task_users) as $key => $uid) {
         $user_assigned_tasks[$uid][] = $task_id;
<?php

/* $Id: tasks_tab.addedit.other_resources.php 1595 2011-01-17 07:37:10Z caseydk $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/tags/version2.4/modules/resources/tasks_tab.addedit.other_resources.php $ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
global $AppUI, $users, $task_id, $task_project, $obj;
global $projTasksWithEndDates, $tab, $loadFromTab;
// Need to get all of the resources that this user is allowed to view
$resource = new CResource();
$resource_types =& $resource->typeSelect();
$q = new w2p_Database_Query();
$q->addTable('resources');
$q->addOrder('resource_type', 'resource_name');
$res = $q->exec(ADODB_FETCH_ASSOC);
$all_resources = array();
$resource_max = array();
while ($row = $q->fetchRow()) {
    $type = $row['resource_type'];
    $all_resources[$row['resource_id']] = $resource_types[$row['resource_type']] . ': ' . $row['resource_name'];
    $resource_max[$row['resource_id']] = $row['resource_max_allocation'];
}
$q->clear();
$assigned_resources = array();
$resources = array();
if ($loadFromTab && isset($_SESSION['tasks_subform']['hresource_assign'])) {
    $initResAssignment = '';
    foreach (explode(';', $_SESSION['tasks_subform']['hresource_assign']) as $perc) {
        if ($perc) {
            list($rid, $perc) = explode('=', $perc);
            $assigned_resources[$rid] = $perc;
예제 #19
0
 public static function getOwners()
 {
     $q = new w2p_Database_Query();
     $q->addTable('projects', 'p');
     $q->addQuery('user_id, contact_display_name');
     $q->leftJoin('users', 'u', 'u.user_id = p.project_owner');
     $q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
     $q->addOrder('contact_first_name, contact_last_name');
     $q->addWhere('user_id > 0');
     $q->addWhere('p.project_owner IS NOT NULL');
     return $q->loadHashList();
 }
예제 #20
0
    $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->addGroup('ta.task_id');
$q->addOrder('ta.task_end_date');
$q->addOrder('task_priority DESC');
$tasks = $q->loadList();
/* we have to calculate the end_date via start_date+duration for
** end='0000-00-00 00:00:00'
*/
for ($j = 0, $j_cmp = count($tasks); $j < $j_cmp; $j++) {
    if ($tasks[$j]['task_end_date'] == '0000-00-00 00:00:00' || $tasks[$j]['task_end_date'] == '') {
        if ($tasks[$j]['task_start_date'] == '0000-00-00 00:00:00' || $tasks[$j]['task_start_date'] == '') {
            $tasks[$j]['task_start_date'] = '0000-00-00 00:00:00';
            //just to be sure start date is "zeroed"
            $tasks[$j]['task_end_date'] = '0000-00-00 00:00:00';
        } else {
            $tasks[$j]['task_end_date'] = calcEndByStartAndDuration($tasks[$j]);
        }
    }
예제 #21
0
<?php

/* $Id$ $URL$ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
// check permissions
$perms =& $AppUI->acl();
if (!canEdit('system')) {
    $AppUI->redirect('m=public&a=access_denied');
}
$q = new w2p_Database_Query();
$q->addTable('syskeys');
$q->addQuery('*');
$q->addOrder('syskey_name');
$keys = $q->loadList();
$q->clear();
$syskey_id = (int) w2PgetParam($_GET, 'syskey_id', 0);
$titleBlock = new CTitleBlock('System Lookup Keys', 'myevo-weather.png', $m, $m . '.' . $a);
$titleBlock->addCrumb('?m=system', 'System Admin');
$titleBlock->show();
?>
<script language="javascript" type="text/javascript">
<?php 
// security improvement:
// some javascript functions may not appear on client side in case of user not having write permissions
// else users would be able to arbitrarily run 'bad' functions
if ($canEdit) {
    ?>
function delIt(id) {
	if (confirm( 'Are you sure you want to delete this?' )) {
예제 #22
0
 public static function getDepartments(CAppUI $AppUI, $companyId)
 {
     $perms = $AppUI->acl();
     if ($AppUI->isActiveModule('departments') && canView('departments')) {
         $q = new w2p_Database_Query();
         $q->addTable('departments');
         $q->addQuery('departments.*, COUNT(contact_department) dept_users');
         $q->addJoin('contacts', 'c', 'c.contact_department = dept_id');
         $q->addWhere('dept_company = ' . (int) $companyId);
         $q->addGroup('dept_id');
         $q->addOrder('dept_parent, dept_name');
         $department = new CDepartment();
         $department->setAllowedSQL($AppUI->user_id, $q);
         return $q->loadList();
     }
 }
예제 #23
0
    // Don't assume where is set. Change needed to fix Mantis Bug 0002056
    $q->addWhere($where);
}
if ($where_dept) {
    // Don't assume where is set. Change needed to fix Mantis Bug 0002056
    $q->addWhere($where_dept);
}
$oCpy = new CCompany();
$aCpies = $oCpy->getAllowedRecords($AppUI->user_id, 'company_id, company_name', 'company_name');
$where = $oCpy->getAllowedSQL($AppUI->user_id, 'contact_company');
$q->addWhere($where);
$oDpt = new CDepartment();
$where = $oDpt->getAllowedSQL($AppUI->user_id, 'contact_department');
$q->addWhere($where);
$q->addWhere('(contact_owner = ' . (int) $AppUI->user_id . ' OR contact_private = 0)');
$q->addOrder('company_name, contact_company, dept_name, contact_department, contact_last_name');
// May need to review this.
$contacts = $q->loadHashList('contact_id');
?>

<form action="index.php?m=public&a=contact_selector&dialog=1&<?php 
if (!is_null($call_back)) {
    echo 'call_back=' . $call_back . '&';
}
?>
company_id=<?php 
echo $company_id;
?>
" method="post" name="frmContactSelect" accept-charset="utf-8">

	<?php 
예제 #24
0
$q->addTable('tasks');
$q->addWhere('task_project = ' . (int) $task_project);
$q->addWhere('task_id = task_parent');
$q->addOrder('task_start_date');
$root_tasks = $q->loadHashList('task_id');
$q->clear();
$projTasks = array();
global $task_parent_options;
$task_parent_options = '';
// Now lets get non-root tasks, grouped by the task parent
$q = new w2p_Database_Query();
$q->addQuery('task_id, task_name, task_end_date, task_start_date, task_milestone, task_parent, task_dynamic');
$q->addTable('tasks');
$q->addWhere('task_project = ' . (int) $task_project);
$q->addWhere('task_id <> task_parent');
$q->addOrder('task_start_date');
$parents = array();
$projTasksWithEndDates = array(0 => $AppUI->_('None'));
//arrays contains task end date info for setting new task start date as maximum end date of dependenced tasks
global $all_tasks;
$all_tasks = array();
$sub_tasks = $q->exec();
if ($sub_tasks) {
    while ($sub_task = $q->fetchRow()) {
        // Build parent/child task list
        $parents[$sub_task['task_parent']][] = $sub_task['task_id'];
        $all_tasks[$sub_task['task_id']] = $sub_task;
        build_date_list($projTasksWithEndDates, $sub_task);
    }
}
$q->clear();
예제 #25
0
$q->leftJoin('user_task_pin', 'pin', 'tasks.task_id = pin.task_id AND pin.user_id = ' . (int) $AppUI->user_id);
$q->leftJoin('event_queue', 'evtq', 'tasks.task_id = evtq.queue_origin_id AND evtq.queue_module = "tasks"');
$q->leftJoin('project_departments', 'project_departments', 'projects.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('task_project = ' . (int) $project_id);
$allowedProjects = $project->getAllowedSQL($AppUI->user_id, 'task_project');
if (count($allowedProjects)) {
    $q->addWhere($allowedProjects);
}
$obj = new CTask();
$allowedTasks = $obj->getAllowedSQL($AppUI->user_id, 'tasks.task_id');
if (count($allowedTasks)) {
    $q->addWhere($allowedTasks);
}
$q->addGroup('tasks.task_id');
$q->addOrder('task_start_date');
if ($canViewTasks) {
    $tasks = $q->loadList();
}
// POST PROCESSING TASKS
foreach ($tasks as $row) {
    //add information about assigned users into the page output
    $q->clear();
    $q->addQuery('ut.user_id,	u.user_username');
    $q->addQuery('ut.perc_assignment, SUM(ut.perc_assignment) AS assign_extent');
    $q->addQuery('contact_first_name, contact_last_name, contact_email');
    $q->addTable('user_tasks', 'ut');
    $q->leftJoin('users', 'u', 'u.user_id = ut.user_id');
    $q->leftJoin('contacts', 'c', 'u.user_contact = c.contact_id');
    $q->addWhere('ut.task_id = ' . (int) $row['task_id']);
    $q->addGroup('ut.user_id');
예제 #26
0
 /**
  * Gets a list of the active modules
  * @return array Named array list in the form 'module directory'=>'module name'
  */
 public function getLoadableModuleList()
 {
     $q = new w2p_Database_Query();
     $q->addTable('modules', 'm');
     $q->addQuery('mod_directory, mod_main_class, mod_version');
     $q->addWhere('mod_active = 1');
     $q->addWhere("mod_main_class <> ''");
     $q->addOrder('mod_ui_order');
     return $q->loadList();
 }
예제 #27
0
     $q->addWhere('( (task_start_date >= ' . $ss . ' AND task_start_date <= ' . $se . ') OR ' . '(task_end_date <= ' . $se . ' AND task_end_date >= ' . $ss . ') )');
 }
 if ($project_id != 0) {
     $q->addWhere('task_project=' . $project_id);
 }
 $proj = new CProject();
 $obj = new CTask();
 $allowedProjects = $proj->getAllowedSQL($AppUI->user_id, 'task_project');
 $allowedTasks = $obj->getAllowedSQL($AppUI->user_id);
 if (count($allowedProjects)) {
     $q->addWhere(implode(' AND ', $allowedProjects));
 }
 if (count($allowedTasks)) {
     $q->addWhere(implode(' AND ', $allowedTasks));
 }
 $q->addOrder('task_end_date');
 $task_list_hash = $q->loadHashList('task_id');
 $q->clear();
 $task_list = array();
 $task_assigned_users = array();
 $i = 0;
 foreach ($task_list_hash as $task_id => $task_data) {
     $task = new CTask();
     $task->bind($task_data);
     $task_list[$i] = $task;
     $task_assigned_users[$i] = $task->assignees($task_id);
     $i++;
 }
 $Ntasks = $i;
 $user_usage = array();
 $task_dates = array();
예제 #28
0
}
$debug = false;
$callback = w2PgetParam($_GET, 'callback', 0);
$table = w2PgetParam($_GET, 'table', 0);
$user_id = w2PgetParam($_GET, 'user_id', 0);
$ok = $callback & $table;
$title = 'Generic Selector';
$q = new w2p_Database_Query();
$q->addTable($table);
$query_result = false;
switch ($table) {
    case 'companies':
        $obj = new CCompany();
        $title = 'Company';
        $q->addQuery('company_id, company_name');
        $q->addOrder('company_name');
        $q->addWhere(selPermWhere($obj, 'company_id', 'company_name'));
        $resultList = $q->loadHashList();
        break;
    case 'departments':
        // known issue: does not filter out denied companies
        $title = 'Department';
        $company_id = w2PgetParam($_GET, 'company_id', 0);
        $obj = new CDepartment();
        $q->addWhere(selPermWhere($obj, 'dept_id', 'dept_name'));
        $q->addWhere('dept_company = company_id ');
        $q->addTable('companies', 'b');
        $company = new CCompany();
        $allowed = $company->getAllowedRecords($AppUI->user_id, 'company_id, company_name');
        if (count($allowed)) {
            $q->addWhere('company_id IN (' . implode(',', array_keys($allowed)) . ') ');
예제 #29
0
if (!is_array($projects) || sizeof($projects) == 0) {
    $d = new w2p_Utilities_Date();
    $columnValues = array('project_name' => $AppUI->_('No projects found'), 'start_date' => $d->getDate(), 'end_date' => $d->getDate(), 'actual_end' => '');
    $gantt->addBar($columnValues, ' ', 0.6, 'red');
} else {
    if (is_array($projects)) {
        //pull all tasks into an array keyed by the project id, and get the tasks in hierarchy
        if ($showAllGantt) {
            // insert tasks into Gantt Chart
            // select for tasks for each project
            // pull tasks
            $q = new w2p_Database_Query();
            $q->addTable('tasks', 't');
            $q->addQuery('t.task_id, task_parent, task_name, task_start_date, task_end_date, task_duration, task_duration_type, task_priority, task_percent_complete, task_order, task_project, task_milestone, project_id, project_name, task_dynamic');
            $q->addJoin('projects', 'p', 'project_id = t.task_project');
            $q->addOrder('project_id, task_start_date');
            $q->addWhere('project_original_parent = ' . (int) $original_project_id);
            //$tasks = $q->loadList();
            $task = new CTask();
            $task->setAllowedSQL($AppUI->user_id, $q);
            $proTasks = $q->loadHashList('task_id');
            $orrarr[] = array('task_id' => 0, 'order_up' => 0, 'order' => '');
            $end_max = '0000-00-00 00:00:00';
            $start_min = date('Y-m-d H:i:s');
            //pull the tasks into an array
            foreach ($proTasks as $rec) {
                if ($rec['task_start_date'] == '0000-00-00 00:00:00') {
                    $rec['task_start_date'] = date('Y-m-d H:i:s');
                }
                $tsd = new w2p_Utilities_Date($rec['task_start_date']);
                if ($tsd->before(new w2p_Utilities_Date($start_min))) {
예제 #30
0
		</tr>
		</table>
<?php 
    }
    ?>
	</td>
	<?php 
    if (w2PgetParam($_REQUEST, 'tab', 0) == 0) {
        ?>
	<td>
	       <?php 
        $q = new w2p_Database_Query();
        $q->addTable('user_access_log', 'ual');
        $q->addQuery('user_access_log_id, ( unix_timestamp( \'' . $q->dbfnNowWithTZ() . '\' ) - unix_timestamp( date_time_in ) ) / 3600 as 		hours, ( unix_timestamp( \'' . $q->dbfnNowWithTZ() . '\' ) - unix_timestamp( date_time_last_action ) ) / 3600 as idle, if(isnull(date_time_out) or date_time_out =\'0000-00-00 00:00:00\',\'1\',\'0\') as online');
        $q->addWhere('user_id = ' . (int) $row['user_id']);
        $q->addOrder('user_access_log_id DESC');
        $q->setLimit(1);
        $user_logs = $q->loadList();
        if ($user_logs) {
            foreach ($user_logs as $row_log) {
                if ($row_log['online'] == '1') {
                    echo '<span style="color: green">' . $row_log['hours'] . ' ' . $AppUI->_('hrs.') . '( ' . $row_log['idle'] . ' ' . $AppUI->_('hrs.') . ' ' . $AppUI->_('idle') . ') - ' . $AppUI->_('Online');
                } else {
                    echo '<span style="color: red">' . $AppUI->_('Offline');
                }
            }
        } else {
            echo '<span style="color: grey">' . $AppUI->_('Never Visited');
        }
        echo '</span>';
    }