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();
 }
예제 #3
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();
    }
}
예제 #4
0
}
if ($catsql) {
    $q->addWhere($catsql);
}
if ($company_id) {
    $q->addWhere('project_company = ' . (int) $company_id);
}
if ($project_id) {
    $q->addWhere('file_project = ' . (int) $project_id);
}
if ($task_id) {
    $q->addWhere('file_task = ' . (int) $task_id);
}
$q->addGroup('file_version_id');
// counts total recs from selection
$xpg_totalrecs = count($q->loadList());
$pageNav = buildPaginationNav($AppUI, $m, $tab, $xpg_totalrecs, $xpg_pagesize, $page);
echo $pageNav;
?>
<script language="javascript" type="text/javascript">
function expand(id){
  var element = document.getElementById(id);
  element.style.display = (element.style.display == '' || element.style.display == 'none') ? 'block' : 'none';
}
</script>
<table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl list">
    <?php 
global $showProject;
$showProject = true;
echo displayFiles($AppUI, 0, $task_id, $project_id, $company_id);
?>
예제 #5
0
    $q->addWhere($allowedTasks);
}
// Filter by company
if (!$min_view && $f2 != 'allcompanies') {
    $q->addJoin('companies', 'c', 'c.company_id = p.project_company', 'inner');
    $q->addWhere('company_id = ' . (int) $f2);
}
$q->addGroup('tasks.task_id');
if (!$project_id && !$task_id) {
    $q->addOrder('p.project_id, task_start_date, task_end_date');
} else {
    $q->addOrder('task_start_date, task_end_date');
}
//print_r($q->prepare());
if ($canViewTask) {
    $tasks = $q->loadList();
}
// POST PROCESSING TASKS
if (count($tasks) > 0) {
    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');
        $q->addQuery('CONCAT(contact_first_name, \' \',contact_last_name) AS assignee, contact_email');
        $q->addTable('user_tasks', 'ut');
        $q->addJoin('users', 'u', 'u.user_id = ut.user_id', 'inner');
        $q->addJoin('contacts', 'c', 'u.user_contact = c.contact_id', 'inner');
        $q->addWhere('ut.task_id = ' . (int) $row['task_id']);
        $q->addOrder('perc_assignment desc, contact_first_name, contact_last_name');
        $assigned_users = array();
예제 #6
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;
 }
예제 #7
0
// check permissions for this module
$perms =& $AppUI->acl();
$canView = canView($m);
$canAddProject = $perms->checkModuleItem('projects', 'add', $project_id);
if (!$canView) {
    $AppUI->redirect('m=public&a=access_denied');
}
$AppUI->loadCalendarJS();
$today = new w2p_Utilities_Date();
$today->convertTZ($AppUI->getPref('TIMEZONE'));
//Lets load the users panel viewing options
$q = new w2p_Database_Query();
$q->addTable('project_designer_options', 'pdo');
$q->addQuery('pdo.*');
$q->addWhere('pdo.pd_option_user = '******'project_id', 0);
$project_id = (int) w2PgetParam($_GET, 'project_id', $project_id);
$extra = array('where' => 'project_active = 1');
$project = new CProject();
$projects = $project->getAllowedRecords($AppUI->user_id, 'projects.project_id,project_name', 'project_name', null, $extra, 'projects');
$q = new w2p_Database_Query();
$q->addTable('projects');
$q->addQuery('projects.project_id, company_name');
$q->addJoin('companies', 'co', 'co.company_id = project_company');
$idx_companies = $q->loadHashList();
$q->clear();
foreach ($projects as $prj_id => $prj_name) {
    $projects[$prj_id] = $idx_companies[$prj_id] . ': ' . $prj_name;
}
asort($projects);
예제 #8
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?' )) {
예제 #9
0
 public static function getFileList($AppUI = null, $company_id = 0, $project_id = 0, $task_id = 0, $category_id = 0)
 {
     global $AppUI;
     $q = new w2p_Database_Query();
     $q->addQuery('f.*');
     $q->addTable('files', 'f');
     $q->addJoin('projects', 'p', 'p.project_id = file_project');
     $q->addJoin('project_departments', 'pd', 'p.project_id = pd.project_id');
     $q->addJoin('departments', '', 'pd.department_id = dept_id');
     $q->addJoin('tasks', 't', 't.task_id = file_task');
     $project = new CProject();
     //TODO: We need to convert this from static to use ->overrideDatabase() for testing.
     $allowedProjects = $project->getAllowedSQL($AppUI->user_id, 'file_project');
     if (count($allowedProjects)) {
         $q->addWhere('( ( ' . implode(' AND ', $allowedProjects) . ') OR file_project = 0 )');
     }
     if (isset($company_id) && (int) $company_id > 0) {
         $q->addWhere('project_company = ' . (int) $company_id);
     }
     if (isset($project_id) && (int) $project_id > 0) {
         $q->addWhere('file_project = ' . (int) $project_id);
     }
     if (isset($task_id) && (int) $task_id > 0) {
         $q->addWhere('file_task = ' . (int) $task_id);
     }
     if ($category_id >= 0) {
         $q->addWhere('file_category = ' . (int) $category_id);
     }
     return $q->loadList();
 }
예제 #10
0
 /** Retrieve tasks with latest 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
  */
 public function getCriticalTasks($project_id = null, $limit = 1)
 {
     $project_id = !empty($project_id) ? $project_id : $this->project_id;
     $q = new w2p_Database_Query();
     $q->addTable('tasks');
     $q->addWhere('task_project = ' . (int) $project_id . ' AND task_end_date IS NOT NULL AND task_end_date <>  \'0000-00-00 00:00:00\'');
     $q->addOrder('task_end_date DESC');
     $q->setLimit($limit);
     return $q->loadList();
 }
예제 #11
0
     $s .= 'No contacts were found.';
 } else {
     $s .= 'Total Contacts Found:' . $info['count'] . '<hr />';
     $s .= '<table border="0" cellpadding="1" cellspacing="0" width="98%" class="std">';
     if (isset($test)) {
         foreach ($sql_ldap_mapping as $sql) {
             $s .= '<th>' . $sql . '</th>';
         }
         foreach ($contact_methods_ldap_mapping as $sql) {
             $s .= '<th>' . $sql . '</th>';
         }
     } else {
         $q = new w2p_Database_Query();
         $q->addTable($sql_table);
         $q->addQuery('contact_id, contact_first_name, contact_last_name');
         $contacts = $q->loadList();
         $q->clear();
         foreach ($contacts as $contact) {
             $contact_list[$contact['contact_first_name'] . ' ' . $contact['contact_last_name']] = $contact['contact_id'];
         }
         unset($contacts);
     }
     for ($i = 0, $i_cmp = $info['count']; $i < $i_cmp; $i++) {
         $pairs = array();
         $s .= '<tr>';
         foreach ($sql_ldap_mapping as $ldap_name => $sql_name) {
             unset($val);
             if (isset($info[$i][$ldap_name][0])) {
                 $val = clean_value($info[$i][$ldap_name][0]);
             }
             if ($val && $ldap_name == 'postaladdress') {
예제 #12
0
    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');
    ?>
</th>
		<th><?php 
    echo $AppUI->_('Project');
    ?>
예제 #13
0
    $q->addWhere('user_id IN (' . implode(',', array_keys($users)) . ')');
    if (isset($_POST['user']) && (int) $_POST['user'] > 0) {
        $q->addWhere('user_id = ' . (int) $_POST['user']);
    }
    if ($_POST['module']) {
        $q->addWhere('module = \'' . $_POST['module'] . '\'');
    }
    if ($_POST['action']) {
        $q->addWhere('action = \'' . $_POST['action'] . '\'');
    }
    $q->addOrder('user_name');
    $q->addOrder('module');
    $q->addOrder('action');
    $q->addOrder('item_id');
    $q->addOrder('acl_id');
    $permissions = $q->loadList();
} else {
    $permissions = array();
}
$avail_modules = $perms->getModuleList();
$modules = array();
foreach ($avail_modules as $avail_module) {
    $modules[$avail_module['value']] = $avail_module['value'];
}
$modules = array(0 => 'All Modules') + $modules;
$actions = array(0 => 'All Actions', 'access' => 'access', 'add' => 'add', 'delete' => 'delete', 'edit' => 'edit', 'view' => 'view');
$table = '<table class="tbl" width="100%" cellspacing="1" cellpadding="2" border="0">';
$table .= '<tr><th colspan="9"><b>Permission Result Table</b></th></tr>';
$table .= '<tr><th>UserID</th><th>User</th><th>User Name</th><th>Module</th><th>Item</th><th>Item Name</th><th>Action</th><th>Allow</th><th>ACL_ID</th></tr>';
foreach ($permissions as $permission) {
    $item = '';
 private function addDependencies($ganttBar, $task_id)
 {
     $gantt_arr = $this->taskArray;
     $q = new w2p_Database_Query();
     $q->addTable('task_dependencies');
     $q->addQuery('dependencies_task_id');
     $q->addWhere('dependencies_req_task_id=' . (int) $task_id);
     $query = $q->loadList();
     foreach ($query as $dep) {
         for ($d = 0; $d < $this->taskCount; $d++) {
             if ($gantt_arr[$d][0]['task_id'] == $dep['dependencies_task_id']) {
                 $ganttBar->SetConstrain($d, CONSTRAIN_ENDSTART);
             }
         }
     }
     return $ganttBar;
 }
예제 #15
0
$isNewUser = !w2PgetParam($_REQUEST, 'user_id', 0);
if ($isNewUser) {
    // check if a user with the param Username already exists
    if (is_array($contactListByUsername)) {
        $AppUI->setMsg('This username is not available, please try another.', UI_MSG_ERROR, true);
        $AppUI->redirect();
    } else {
        $contact->contact_owner = $AppUI->user_id;
    }
}
$result = $contact->store($AppUI);
if ($result) {
    $user->user_contact = $contact->contact_id;
    if ($msg = $user->store()) {
        $AppUI->setMsg($msg, UI_MSG_ERROR);
    } else {
        if ($isNewUser) {
            notifyNewExternalUser($contact->contact_email, $contact->contact_first_name, $user->user_username, $_POST['user_password']);
        }
        notifyHR(w2PgetConfig('admin_email', '*****@*****.**'), 'w2P System Human Resources', $contact->contact_email, $contact->contact_first_name, $user->user_username, $_POST['user_password'], $user->user_id);
        $q = new w2p_Database_Query();
        $q->addTable('users', 'u');
        $q->addQuery('contact_email');
        $q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
        $q->addWhere('u.user_username = \'admin\'');
        $admin_user = $q->loadList();
    }
} else {
    $AppUI->setMsg($msg, UI_MSG_ERROR);
}
echo "<script language='javascript'>\n\t      alert('The User Administrator has been notified to grant you access to the system and an email message was sent to you with your login info. Thank you very much.');\n\t      history.go(-2);\n      </script>";
예제 #16
0
 /**
  * Tests storing task log in database
  */
 public function testStoreUpdate()
 {
     $this->obj->bind($this->post_data, null, true, true);
     $this->obj->task_log_id = 1;
     unset($this->obj->task_log_created);
     $this->obj->store();
     $xml_file_dataset = $this->createXMLDataSet($this->getDataSetPath() . 'tasklogsTestStoreUpdate.xml');
     $xml_file_filtered_dataset = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($xml_file_dataset, array('task_log' => array('task_log_created', 'task_log_updated')));
     $xml_db_dataset = $this->getConnection()->createDataSet();
     $xml_db_filtered_dataset = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($xml_db_dataset, array('task_log' => array('task_log_created', 'task_log_updated')));
     $this->assertTablesEqual($xml_file_filtered_dataset->getTable('task_log'), $xml_db_filtered_dataset->getTable('task_log'));
     $this->assertTablesEqual($xml_file_filtered_dataset->getTable('tasks'), $xml_db_filtered_dataset->getTable('tasks'));
     $this->assertTablesEqual($xml_file_filtered_dataset->getTable('projects'), $xml_db_filtered_dataset->getTable('projects'));
     /**
      * Get updated dates to test against
      */
     $now_secs = time();
     $min_time = $now_secs - 10;
     $q = new w2p_Database_Query();
     $q->addTable('task_log');
     $q->addQuery('task_log_updated');
     $q->addWhere('task_log_id = 1');
     $results = $q->loadList();
     foreach ($results as $dates) {
         $this->assertGreaterThanOrEqual($min_time, strtotime($dates['task_log_updated']));
         $this->assertLessThanOrEqual($now_secs, strtotime($dates['task_log_updated']));
     }
 }
예제 #17
0
$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 
echo $AppUI->_('Status');
예제 #18
0
	</tr>
	<?php 
}
?>
</table>

<table cellspacing="0" cellpadding="0" border="1" align="center" class="std" width="100%">
    <tr>
        <td valign="top" align="center">
            <?php 
if ($a != 'todo') {
    $q = new w2p_Database_Query();
    $q->addTable('tasks');
    $q->addQuery('COUNT(task_id) AS N');
    $q->addWhere('task_project=' . (int) $project_id);
    $cnt = $q->loadList();
    $q->clear();
} else {
    $cnt[0]['N'] = empty($tasks) ? 0 : 1;
}
if ($cnt[0]['N'] > 0) {
    $src = '?m=tasks&a=gantt&suppressHeaders=1&project_id=' . $project_id . ($display_option == 'all' ? '' : '&start_date=' . $start_date->format('%Y-%m-%d') . '&end_date=' . $end_date->format('%Y-%m-%d')) . "&width=' + ((navigator.appName=='Netscape'" . "?window.innerWidth:document.body.offsetWidth)*0.95) + '" . '&showLabels=' . $showLabels . '&showWork=' . $showWork . '&sortByName=' . $sortByName . '&showTaskNameOnly=' . $showTaskNameOnly . '&showhgrid=' . $showhgrid . '&showPinned=' . $showPinned . '&showArcProjs=' . $showArcProjs . '&showHoldProjs=' . $showHoldProjs . '&showDynTasks=' . $showDynTasks . '&showLowTasks=' . $showLowTasks . '&caller=' . $a . '&user_id=' . $user_id . '&printpdf=' . $printpdf . '&showNoMilestones=' . $showNoMilestones . '&showMilestonesOnly=' . $showMilestonesOnly . '&addLinksToGantt=' . $addLinksToGantt . '&ganttTaskFilter=' . $ganttTaskFilter . '&monospacefont=' . $monospacefont . '&showWork_days=' . $showWork_days;
    ?>
                <script language="javascript" type="text/javascript"> document.write('<img alt="Please wait while the Gantt chart is generated... (this might take a minute or two)" src="<?php 
    echo htmlspecialchars($src);
    ?>
" />') </script>
                <?php 
    //If we have a problem displaying this we need to display a warning.
    //Put it at the bottom just in case
    if (!w2PcheckMem(32 * 1024 * 1024)) {
예제 #19
0
            }
        }
    } 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) {
    ?>
예제 #20
0
    $s = '';
    $first = true;
}
$new_messages = array();
foreach ($messages as $row) {
    // Find the parent message - the topic.
    if ($row['message_id'] == $message_id) {
        $topic = $row['message_title'];
    }
    $q = new w2p_Database_Query();
    $q->addTable('forum_messages');
    $q->addTable('users');
    $q->addQuery('DISTINCT contact_first_name, contact_last_name, contact_display_name as contact_name, user_username, contact_email');
    $q->addJoin('contacts', 'con', 'contact_id = user_contact', 'inner');
    $q->addWhere('users.user_id = ' . (int) $row['message_editor']);
    $editor = $q->loadList();
    $date = intval($row['message_date']) ? new w2p_Utilities_Date($row['message_date']) : null;
    if ($viewtype != 'single') {
        $s = '';
    }
    $style = $x ? 'background-color:#eeeeee' : '';
    //!!! Different table building for the three different views
    // To be cleaned up, and reuse common code at later stage.
    if ($viewtype == 'normal') {
        $s .= '<tr>';
        $s .= '<td valign="top" style="' . $style . '" nowrap="nowrap">';
        $s .= '<a href="?m=admin&a=viewuser&user_id=' . $row['message_author'] . '">';
        $s .= $row['contact_name'];
        $s .= '</a>';
        if (!$hideEmail) {
            $s .= '&nbsp;';
예제 #21
0
</th>
	<th><?php 
echo $AppUI->_('Description');
?>
</th>
</tr>

<?php 
foreach ($billingcodes as $code) {
    echo showcodes($code);
}
if (isset($_GET['billingcode_id'])) {
    $q->addQuery('*');
    $q->addTable('billingcode');
    $q->addWhere('billingcode_id = ' . (int) w2PgetParam($_GET, 'billingcode_id', 0));
    list($obj) = $q->loadList();
    echo '
<tr>
	<td>&nbsp;<input type="hidden" name="billingcode_id" value="' . w2PgetParam($_GET, 'billingcode_id', 0) . '" /></td>
	<td><input type="text" class="text" name="billingcode_name" value="' . $obj['billingcode_name'] . '" /></td>
	<td><input type="text" class="text" name="billingcode_value" value="' . $obj['billingcode_value'] . '" /></td>
	<td><input type="text" class="text" name="billingcode_desc" value="' . $obj['billingcode_desc'] . '" /></td>
</tr>';
} else {
    ?>
<tr>
	<td>&nbsp;</td>
	<td><input type="text" class="text" name="billingcode_name" value="" /></td>
	<td><input type="text" class="text" name="billingcode_value" value="" /></td>
	<td><input type="text" class="text" name="billingcode_desc" value="" /></td>
</tr>
예제 #22
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();
 }
예제 #23
0
if (!canView('tasks')) {
    $AppUI->redirect('m=public&a=access_denied');
}
$proj = (int) w2PgetParam($_GET, 'project', 0);
$userFilter = w2PgetParam($_GET, 'userFilter', false);
$q = new w2p_Database_Query();
$q->addQuery('t.task_id, t.task_name');
$q->addTable('tasks', 't');
if ($userFilter) {
    $q->addJoin('user_tasks', 'ut', 'ut.task_id = t.task_id');
    $q->addWhere('ut.user_id = ' . (int) $AppUI->user_id);
}
if ($proj != 0) {
    $q->addWhere('task_project = ' . (int) $proj);
}
$tasks = $q->loadList();
$q->clear();
?>

<script language="javascript" type="text/javascript">
function loadTasks() {
	var tasks = new Array();
	var sel = parent.document.forms['form'].new_task;
	while (sel.options.length) {
		sel.options[0] = null;
	}
	sel.options[0] = new Option('[top task]', 0);
	
  <?php 
$i = 0;
foreach ($tasks as $task) {
예제 #24
0
 public function notifyContacts($notifyContacts)
 {
     global $AppUI, $w2Pconfig, $locale_char_set;
     if ($notifyContacts) {
         //if no project specified than we will not do anything
         if ($this->file_project != 0) {
             $this->_project = new CProject();
             $this->_project->load($this->file_project);
             $mail = new w2p_Utilities_Mail();
             if ($this->file_task == 0) {
                 //notify all developers
                 $mail->Subject($AppUI->_('Project') . ': ' . $this->_project->project_name . '::' . $this->file_name, $locale_char_set);
             } else {
                 //notify all assigned users
                 $this->_task = new CTask();
                 $this->_task->load($this->file_task);
                 $mail->Subject($AppUI->_('Project') . ': ' . $this->_project->project_name . '::' . $this->_task->task_name . '::' . $this->file_name, $locale_char_set);
             }
             $body = $AppUI->_('Project') . ': ' . $this->_project->project_name;
             $body .= "\n" . $AppUI->_('URL') . ':     ' . W2P_BASE_URL . '/index.php?m=projects&a=view&project_id=' . $this->_project->project_id;
             if (intval($this->_task->task_id) != 0) {
                 $body .= "\n\n" . $AppUI->_('Task') . ':    ' . $this->_task->task_name;
                 $body .= "\n" . $AppUI->_('URL') . ':     ' . W2P_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->_task->task_id;
                 $body .= "\n" . $AppUI->_('Description') . ":\n" . $this->_task->task_description;
                 $q = new w2p_Database_Query();
                 $q->addTable('project_contacts', 'pc');
                 $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name');
                 $q->addJoin('contacts', 'c', 'c.contact_id = pc.contact_id');
                 $q->addWhere('pc.project_id = ' . (int) $this->_project->project_id);
                 $sql = '(' . $q->prepare() . ')';
                 $q->clear();
                 $sql .= ' UNION ';
                 $q->addTable('task_contacts', 'tc');
                 $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name');
                 $q->addJoin('contacts', 'c', 'c.contact_id = tc.contact_id');
                 $q->addWhere('tc.task_id = ' . (int) $this->_task->task_id);
             } else {
                 $q = new w2p_Database_Query();
                 $q->addTable('project_contacts', 'pc');
                 $q->addQuery('pc.project_id, pc.contact_id');
                 $q->addQuery('c.contact_email as contact_email, c.contact_first_name as contact_first_name, c.contact_last_name as contact_last_name');
                 $q->addJoin('contacts', 'c', 'c.contact_id = pc.contact_id');
                 $q->addWhere('pc.project_id = ' . (int) $this->file_project);
             }
             $this->_users = $q->loadList();
             $body .= "\n\nFile " . $this->file_name . ' was ' . $this->_message . ' by ' . $AppUI->user_first_name . ' ' . $AppUI->user_last_name;
             if ($this->_message != 'deleted') {
                 $body .= "\n" . $AppUI->_('URL') . ':     ' . W2P_BASE_URL . '/fileviewer.php?file_id=' . $this->file_id;
                 $body .= "\n" . $AppUI->_('Description') . ":\n" . $this->file_description;
             }
             //send mail
             $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : '');
             foreach ($this->_users as $row) {
                 if ($mail->ValidEmail($row['contact_email'])) {
                     $mail->To($row['contact_email'], true);
                     $mail->Send();
                 }
             }
             return '';
         }
     }
 }
예제 #25
0
 /**
  * Tests that dependent dates are updated properly for current task
  */
 public function testUpdateDepDate()
 {
     $this->obj->update_dep_dates(28);
     $xml_file_dataset = $this->createXMLDataSet($this->getDataSetPath() . 'tasksTestUpdateDepDates.xml');
     $xml_file_filtered_dataset = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($xml_file_dataset, array('tasks' => array('task_updated')));
     $xml_db_dataset = $this->getConnection()->createDataSet();
     $xml_db_filtered_dataset = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($xml_db_dataset, array('tasks' => array('task_updated')));
     $this->assertTablesEqual($xml_file_filtered_dataset->getTable('tasks'), $xml_db_filtered_dataset->getTable('tasks'));
     $now_secs = time();
     $min_time = $now_secs - 10;
     /**
      * Get updated dates to test against
      */
     $q = new w2p_Database_Query();
     $q->addTable('tasks');
     $q->addQuery('task_updated');
     $q->addWhere('task_id IN(28)');
     $results = $q->loadList();
     foreach ($results as $dates) {
         $this->assertGreaterThanOrEqual($min_time, strtotime($dates['task_updated']));
         $this->assertLessThanOrEqual($now_secs, strtotime($dates['task_updated']));
     }
 }
예제 #26
0
<?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>';
    }
    ?>
	</td>
예제 #27
0
 public static function getProjects($contactId)
 {
     $q = new w2p_Database_Query();
     $q->addQuery('p.project_id, p.project_name');
     $q->addTable('project_contacts', 'pc');
     $q->addJoin('projects', 'p', 'p.project_id = pc.project_id', 'inner');
     $q->addWhere("contact_id =  {$contactId}");
     return $q->loadList();
 }
예제 #28
0
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;
}
 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;
 }
예제 #30
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;
 }