Exemplo n.º 1
0
 function get_defaults()
 {
     $q = new DBQuery();
     $q->addTable('user_preferences');
     $q->addQuery('pref_name, pref_value');
     $q->addWhere('pref_user = 0');
     $this->_default_prefs = $q->loadHashList();
 }
Exemplo n.º 2
0
 protected function _deDynamicLeafNodes($projectId)
 {
     $q = new DBQuery();
     $q->addUpdate('task_dynamic', 0);
     $q->addWhere("task_project = {$projectId}");
     $q->addTable('tasks');
     $q->exec();
     $q->addQuery('distinct(task_parent)');
     $q->addTable('tasks');
     $q->addWhere("task_project = {$projectId}");
     $q->addWhere("task_id <> task_parent");
     $taskList = $q->loadHashList();
     foreach ($taskList as $id => $nothing) {
         $dynamicTasks .= $id . ',';
     }
     $dynamicTasks .= '0';
     $q->clear();
     $q->addUpdate('task_dynamic', 1);
     $q->addWhere("task_project = {$projectId}");
     $q->addWhere("task_id IN ({$dynamicTasks})");
     $q->addTable('tasks');
     $q->exec();
 }
Exemplo n.º 3
0
function getUsersArray()
{
    $q = new DBQuery();
    $q->addTable('users');
    $q->addQuery('user_id, user_username, contact_first_name, contact_last_name');
    $q->addJoin('contacts', 'con', 'contact_id = user_contact');
    $q->addOrder('contact_first_name, contact_last_name');
    return $q->loadHashList("user_id");
}
Exemplo n.º 4
0
/* ADMIN $Id: vw_usr_perms.php 6038 2010-10-03 05:49:01Z ajdonnison $ */
if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
global $AppUI, $user_id, $canEdit, $canDelete, $tab;
$perms =& $AppUI->acl();
$module_list = $perms->getModuleList();
//get list of 'real' modules
$pgos = array();
$q = new DBQuery();
$q->addTable('modules', 'm');
$q->addQuery('mod_id, mod_name, permissions_item_table');
$q->addWhere('permissions_item_table is not null');
$q->addWhere("permissions_item_table <> ''");
$module_pgo_list = $q->loadHashList('mod_name');
$q->clear();
//list of additional 'pseudo-modules'
$pseudo_module_pgo_list = array('File Folders' => array('mod_id' => -1, 'mod_name' => 'file_folders', 'permissions_item_table' => 'file_folders'));
//combine modules and 'pseudo-modules'
$pgo_list = arrayMerge($module_pgo_list, $pseudo_module_pgo_list);
// Build an intersection array for the modules and their listing
$modules = array();
$offset = 0;
foreach ($module_list as $module) {
    $modules[$module['type'] . "," . $module['id']] = $module['name'];
    if ($module['type'] = 'mod' && isset($pgo_list[$module['name']])) {
        $pgos[$offset] = $pgo_list[$module['name']]['permissions_item_table'];
    }
    $offset++;
}
Exemplo n.º 5
0
 public function getAllowedRecords($uid)
 {
     global $AppUI;
     $q = new DBQuery();
     $q->addTable('file_folders');
     $q->addQuery('*');
     $q->addOrder('file_folder_parent');
     $q->addOrder('file_folder_name');
     return $q->loadHashList();
 }
// therefore create a new instance of the Timesheet Class
$obj = new CTimesheet();
$df = $AppUI->getPref('SHDATEFORMAT');
// pull users
// pull users
$q = new DBQuery();
$q->addTable('tasks', 't');
$q->addTable('projects', 'p');
$q->addTable('user_tasks', 'u');
$q->addQuery('t.task_id');
$q->addQuery('CONCAT_WS(" - ",p.project_short_name, t.task_name)');
$q->addOrder('p.project_short_name, t.task_name');
$q->addWhere('t.task_project = p.project_id and t.task_dynamic = 0 and t.task_percent_complete!=100 and u.task_id=t.task_id and u.user_id=' . $user_id);
//Devido a possibilidade de edição de registros, as tarefas de projetos arquivados e em espera serão apresentadas.
//$q->addWhere('p.project_status!=7 and p.project_status!=4');//[7] Projetos Arquivados e [4] Projetos Em Espera
$tasks = $q->loadHashList();
// load the record data in case of that this script is used to edit the log qith task_log_id (transmitted via GET)
if (!$obj->load($task_log_id, false) && $task_log_id > 0) {
    // show some error messages using the dPFramework if loadOperation failed
    // these error messages are nicely integrated with the frontend of dP
    // use detailed error messages as often as possible
    $AppUI->setMsg('Timesheet');
    $AppUI->setMsg("invalidID", UI_MSG_ERROR, true);
    $AppUI->redirect();
    // go back to the calling location
}
// check if this record has dependancies to prevent deletion
$msg = '';
// setup the title block
// Fill the title block either with 'Edit' or with 'New' depending on if task_log_id has been transmitted via GET or is empty
$ttl = $task_log_id > 0 ? "Edit Log" : "New Log";
Exemplo n.º 7
0
</form>
<?php 
echo $AppUI->_('P') . '&nbsp;=&nbsp;' . $AppUI->_('User specific Task Priority');
if ($do_report) {
    // get Users with all Allocation info (e.g. their freeCapacity)
    $tempoTask = new CTask();
    $userAlloc = $tempoTask->getAllocation("user_id");
    // Let's figure out which users we have
    $sql = new DBQuery();
    $sql->addTable('users');
    $sql->addQuery('user_id, user_username');
    if ($log_userfilter != 0) {
        $sql->addWhere('user_id = ' . $log_userfilter);
    }
    $sql->addOrder('user_username');
    $user_list = $sql->loadHashList('user_id');
    $sql->clear();
    $ss = $start_date->format(FMT_DATETIME_MYSQL);
    $se = $end_date->format(FMT_DATETIME_MYSQL);
    $sql->addTable('tasks', 't');
    $sql->innerJoin('projects', 'p', 'p.project_id = t.task_project');
    if ($log_userfilter != 0) {
        $sql->innerJoin('user_tasks', 'ut', 'ut.task_id = t.task_id');
    }
    $sql->addQuery('t.*');
    if ($use_period) {
        $sql->addWhere("((task_start_date >= '{$ss}' AND task_start_date <= '{$se}') " . " OR (task_end_date <= '{$se}' AND task_end_date >= '{$ss}'))");
    }
    $sql->addWhere('task_percent_complete < 100');
    if ($project_id != 'all') {
        $sql->addWhere('t.task_project = \'' . $project_id . '\'');
    case "departments":
        $id_field = "dept_id";
        $name_field = "dept_name";
        $selection_string = "Department";
        $filter = "dept_company = " . $_GET["company_id"];
        $additional_get_information = "company_id=" . $_GET["company_id"];
        break;
}
$q = new DBQuery();
$q->addTable($table_name);
$q->addQuery("{$id_field}, {$name_field}");
if ($filter != null) {
    $q->addWhere($filter);
}
$q->addOrder($name_field);
$company_list = array("0" => "") + $q->loadHashList();
?>

<?php 
if (dPgetParam($_POST, $id_field, 0) != 0) {
    $q = new DBQuery();
    $q->addTable($table_name);
    $q->addQuery('*');
    $q->addWhere("{$id_field}=" . $_POST[$id_field]);
    $sql = $q->prepare();
    $q->clear();
    db_loadHash($sql, $r_data);
    $data_update_script = "";
    $update_address = isset($_POST["overwrite_address"]);
    if ($table_name == "companies") {
        $update_fields = array();
Exemplo n.º 9
0
 /**
 * Gets a list of the active modules
 * @return array Named array list in the form 'module directory'=>'module name'
 */
 function getActiveModules()
 {
     $q = new DBQuery();
     $q->addTable('modules');
     $q->addQuery('mod_directory, mod_ui_name');
     $q->addWhere('mod_active > 0');
     $q->addOrder('mod_directory');
     return $q->loadHashList();
 }
Exemplo n.º 10
0
// Get the list of projects associated with this user.
// We need to get all projects that are owned by the user
// or where the user is a project contact.
// We then need to add all projects where a user is assigned a task, is a
// task contact, or is the owner of a task within that project.
// This should cover all situations that we need to correct.
$projects = array();
$q = new DBQuery();
$q->addQuery('user_contact');
$q->addTable('users');
$q->addWhere('user_id = ' . (int) $user_id);
$contact_id = $q->loadResult();
$q->addQuery('distinct project_id, project_name');
$q->addTable('projects');
$q->addWhere('project_owner = ' . (int) $user_id);
$projects += $q->loadHashList();
$q->addQuery('distinct prj.project_id, prj.project_name');
$q->addTable('projects', 'prj');
$q->innerJoin('project_contacts', 'prc', array('project_id'));
$q->addWhere('prc.contact_id = ' . (int) $contact_id);
$projects += $q->loadHashList();
$q->addQuery('distinct prj.project_id, prj.project_name');
$q->addTable('tasks', 't');
$q->innerJoin('projects', 'prj', 'prj.project_id = t.task_project');
$q->leftJoin('user_tasks', 'ut', 'ut.task_id = t.task_id');
$q->addWhere('t.task_owner = ' . (int) $user_id . ' OR ut.user_id = ' . (int) $user_id);
$projects += $q->loadHashList();
$q->addQuery('distinct prj.project_id, prj.project_name');
$q->addTable('tasks', 't');
$q->innerJoin('projects', 'prj', 'prj.project_id = t.task_project');
$q->innerJoin('task_contacts', 'tc', 'tc.task_id = t.task_id');
Exemplo n.º 11
0
$task_log_costcodes = $q->loadHashList();
// Show deleted codes separately (at the end)
$q->addTable('billingcode');
$q->addQuery('billingcode_id, billingcode_name');
$q->addOrder('billingcode_name');
$q->addWhere('billingcode_status = 1');
$q->addWhere('(company_id = 0 OR company_id = ' . $company_id . ')');
$task_log_costcodes = array_merge(array(0 => 'None'), $task_log_costcodes, $q->loadHashList());
$q = new DBQuery();
$q->addTable('users', 'u');
$q->addQuery('user_id, concat(contact_first_name," ",contact_last_name)');
$q->addJoin('contacts', 'c', 'u.user_contact = c.contact_id');
$q->addJoin('project_contacts', 'p', 'p.contact_id = u.user_id');
$q->addOrder('contact_first_name, contact_last_name');
$q->addWhere('p.project_id = ' . $project_id);
$users = arrayMerge(array('-1' => $AppUI->_('All members')), $q->loadHashList());
$cost_code = dPgetParam($_GET, 'cost_code', '0');
if (isset($_GET['user_id'])) {
    $AppUI->setState('ProjectsTaskLogsUserFilter', $_GET['user_id']);
}
$user_id = $AppUI->getState('ProjectsTaskLogsUserFilter') ? $AppUI->getState('ProjectsTaskLogsUserFilter') : $AppUI->user_id;
if (isset($_GET['hide_inactive'])) {
    $AppUI->setState('ProjectsTaskLogsHideArchived', true);
} else {
    $AppUI->setState('ProjectsTaskLogsHideArchived', false);
}
$hide_inactive = $AppUI->getState('ProjectsTaskLogsHideArchived');
if (isset($_GET['hide_complete'])) {
    $AppUI->setState('ProjectsTaskLogsHideComplete', true);
} else {
    $AppUI->setState('ProjectsTaskLogsHideComplete', false);
Exemplo n.º 12
0
 public function getUsersWithRole()
 {
     $q = new DBQuery();
     $q->addTable($this->_db_acl_prefix . 'groups_aro_map', 'g');
     $q->addQuery('DISTINCT(g.aro_id)');
     $result = $q->loadHashList();
     $q->clear();
     if (count($result)) {
         return $result;
     } else {
         return false;
     }
 }
Exemplo n.º 13
0
$search_text = $AppUI->getState('searchtext') ? $AppUI->getState('searchtext') : '';
$search_text = dPformSafe($search_text);
$titleBlock->addCell('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . $AppUI->_('Search') . ':');
$titleBlock->addCell('<input type="text" class="text" SIZE="20" name="searchtext"' . ' onChange="document.searchfilter.submit();" value="' . $search_text . '"title="' . $AppUI->_('Search in name and description fields') . '"/><!--<input type="submit" class="button" value=">" title="' . $AppUI->_('Search in name and description fields') . '"/>-->', '', '<form action="?m=tasks" method="post" id="searchfilter">', '</form>');
// Let's see if this user has admin privileges
if (getPermission('admin', 'view')) {
    $titleBlock->addCell();
    $titleBlock->addCell($AppUI->_('User') . ':');
    $q = new DBQuery();
    $q->addTable('users', 'u');
    $q->addTable('contacts', 'con');
    $q->addQuery('user_id');
    $q->addQuery("CONCAT(contact_last_name, ', ', contact_first_name, ' (', user_username, ')')" . ' AS label');
    $q->addOrder('contact_last_name');
    $q->addWhere('u.user_contact = con.contact_id');
    $user_list = $q->loadHashList();
    $titleBlock->addCell(arraySelect($user_list, 'user_id', 'size="1" class="text"' . ' onChange="document.userIdForm.submit();"', $user_id, false, true), '', '<form action="?m=tasks" method="post" name="userIdForm">', '</form>');
}
$titleBlock->addCell();
$titleBlock->addCell($AppUI->_('Company') . '/' . $AppUI->_('Department') . ':');
//get list of all departments, filtered by the list of permitted companies.
$q = new DBQuery();
$q->addTable('companies', 'c');
$q->addQuery('c.company_id, c.company_name, dep.*');
$q->addJoin('departments', 'dep', 'c.company_id = dep.dept_company');
$q->addOrder('c.company_name, dep.dept_parent, dep.dept_name');
$rows = $q->loadList();
//display the select list
$cBuffer = '<select name="department" onChange="document.companyFilter.submit()" class="text">';
$cBuffer .= '<option value="' . $company_prefix . '0" style="font-weight:bold;">' . $AppUI->_('All') . '</option>' . "\n";
$company = '';
Exemplo n.º 14
0
 public function getCompanies($AppUI)
 {
     $q = new DBQuery();
     $q->addTable('companies');
     $q->addQuery('company_id, company_name');
     $where = $this->getAllowedSQL($AppUI->user_id, 'company_id');
     $q->addWhere($where);
     return $q->loadHashList('company_id');
 }
Exemplo n.º 15
0
</table>
</form>
<center>
	<table class="std">
<?php 
if ($do_report) {
    // Let's figure out which users we have
    $query = new DBQuery();
    $query->addTable('users', 'u');
    $query->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
    $query->addQuery('u.user_id, u.user_username, c.contact_first_name, c.contact_last_name');
    if ($log_userfilter) {
        $query->addWhere('user_id = ' . $log_userfilter);
    }
    $query->addOrder('user_username');
    $user_list = $query->loadHashList('user_id');
    $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.
Exemplo n.º 16
0
Arquivo: edit.php Projeto: n2i/xvnkb
        // check only owner can edit
        $AppUI->setMsg('Access denied', UI_MSG_ERROR);
        $AppUI->redirect();
    }
}
$company_detail = $row->getCompanyDetails();
$dept_detail = $row->getDepartmentDetails();
if ($contact_id == 0 && $company_id > 0) {
    $company_detail['company_id'] = $company_id;
    $company_detail['company_name'] = $company_name;
}
$birthday = isset($row->contact_birthday) && $row->contact_birthday != '0000-00-00' ? new CDate($row->contact_birthday) : null;
$q = new DBQuery();
$q->addTable('companies');
$q->addQuery('company_id, company_name');
$companies = array_merge(array(0 => ''), $q->loadHashList());
if (!$view) {
    ?>
<form name="ContactForm" action="?m=contacts" method="post">
	<input type="hidden" name="dosql" value="do_contact_aed" />
	<input type="hidden" name="contact_project" value="0" />
	<input type="hidden" name="contact_unique_update" value="<?php 
    echo uniqid('');
    ?>
" />
	<input type="hidden" name="contact_id" value="<?php 
    echo $contact_id;
    ?>
" />
	<input type="hidden" name="contact_owner" value="<?php 
    echo $row->contact_owner ? $row->contact_owner : $AppUI->user_id;
Exemplo n.º 17
0
		<tr>
			<td align="right" nowrap><?php 
echo $AppUI->_('Project Hours');
?>
:</td>
			<td class="hilite" width="100%"><?php 
echo $total_project_hours;
?>
</td>
		</tr>				
		<?php 
$q->addTable('departments', 'a');
$q->addTable('project_departments', 'b');
$q->addQuery('a.dept_id, a.dept_name, a.dept_phone');
$q->addWhere('a.dept_id = b.department_id AND b.project_id = ' . $project_id);
$depts = $q->loadHashList('dept_id');
$q->clear();
if (count($depts) > 0) {
    ?>
		<tr>
			<td><strong><?php 
    echo $AppUI->_('Departments');
    ?>
</strong></td>
		</tr>
		<tr>
			<td colspan='3' class="hilite">
				<?php 
    foreach ($depts as $dept_id => $dept_info) {
        echo '<div>' . $dept_info['dept_name'];
        if ($dept_info['dept_phone'] != '') {
Exemplo n.º 18
0
 /**
  * Called by the Event Queue processor to process a reminder
  * on a task.
  * @access		  public
  * @param		 string		   $module		  Module name (not used)
  * @param		 string		   $type Type of event (not used)
  * @param		 integer		$id ID of task being reminded
  * @param		 integer		$owner		  Originator of event
  * @param		 mixed		  $args event-specific arguments.
  * @return		  mixed		   true, dequeue event, false, event stays in queue.
  -1, event is destroyed.
 */
 function remind($module, $type, $id, $owner, &$args)
 {
     global $locale_char_set, $AppUI;
     $q = new DBQuery();
     $df = $AppUI->getPref('SHDATEFORMAT');
     $tf = $AppUI->getPref('TIMEFORMAT');
     // If we don't have preferences set for these, use ISO defaults.
     if (!$df) {
         $df = '%Y-%m-%d';
     }
     if (!$tf) {
         $tf = '%H:%m';
     }
     $df .= ' ' . $tf;
     // At this stage we won't have an object yet
     if (!$this->load($id)) {
         return -1;
         // No point it trying again later.
     }
     $this->htmlDecode();
     // Only remind on working days.
     $today = new CDate();
     if (!$today->isWorkingDay()) {
         return true;
     }
     // Check if the task is completed
     if ($this->task_percent_complete == 100) {
         return -1;
     }
     // Grab the assignee list
     $q->addTable('user_tasks', 'ut');
     $q->leftJoin('users', 'u', 'u.user_id = ut.user_id');
     $q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
     $q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email');
     $q->addWhere('ut.task_id = ' . $id);
     $contacts = $q->loadHashList('contact_id');
     $q->clear();
     // Now we also check the owner of the task, as we will need
     // to notify them as well.
     $owner_is_not_assignee = false;
     $q->addTable('users', 'u');
     $q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
     $q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email');
     $q->addWhere('u.user_id = ' . $this->task_owner);
     if ($q->exec(ADODB_FETCH_NUM)) {
         list($owner_contact, $owner_first_name, $owner_last_name, $owner_email) = $q->fetchRow();
         if (!isset($contacts[$owner_contact])) {
             $owner_is_not_assignee = true;
             $contacts[$owner_contact] = array('contact_id' => $owner_contact, 'contact_first_name' => $owner_first_name, 'contact_last_name' => $owner_last_name, 'contact_email' => $owner_email);
         }
     }
     $q->clear();
     // build the subject line, based on how soon the
     // task will be overdue.
     $starts = new CDate($this->task_start_date);
     $expires = new CDate($this->task_end_date);
     $now = new CDate();
     $diff = $expires->dateDiff($now);
     $prefix = $AppUI->_('Task Due', UI_OUTPUT_RAW);
     if ($diff == 0) {
         $msg = $AppUI->_('TODAY', UI_OUTPUT_RAW);
     } else {
         if ($diff == 1) {
             $msg = $AppUI->_('TOMORROW', UI_OUTPUT_RAW);
         } else {
             if ($diff < 0) {
                 $msg = $AppUI->_(array('OVERDUE', abs($diff), 'DAYS'));
                 $prefix = $AppUI->_('Task', UI_OUTPUT_RAW);
             } else {
                 $msg = $AppUI->_(array($diff, 'DAYS'));
             }
         }
     }
     $q->addTable('projects');
     $q->addQuery('project_name');
     $q->addWhere('project_id = ' . $this->task_project);
     $project_name = htmlspecialchars_decode($q->loadResult());
     $q->clear();
     $subject = $prefix . ' ' . $msg . ' ' . $this->task_name . '::' . $project_name;
     $body = $AppUI->_('Task Due', UI_OUTPUT_RAW) . ': ' . $msg . "\n" . $AppUI->_('Project', UI_OUTPUT_RAW) . ': ' . $project_name . "\n" . $AppUI->_('Task', UI_OUTPUT_RAW) . ': ' . $this->task_name . "\n" . $AppUI->_('Start Date', UI_OUTPUT_RAW) . ': ' . $starts->format($df) . "\n" . $AppUI->_('Finish Date', UI_OUTPUT_RAW) . ': ' . $expires->format($df) . "\n" . $AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . DP_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->task_id . '&reminded=1' . "\n\n" . $AppUI->_('Resources', UI_OUTPUT_RAW) . ":\n";
     foreach ($contacts as $contact) {
         if ($owner_is_not_assignee || $contact['contact_id'] != $owner_contact) {
             $body .= $contact['contact_first_name'] . ' ' . $contact['contact_last_name'] . ' <' . $contact['contact_email'] . ">\n";
         }
     }
     $body .= "\n" . $AppUI->_('Description', UI_OUTPUT_RAW) . ":\n" . $this->task_description . "\n";
     $mail = new Mail();
     foreach ($contacts as $contact) {
         if ($mail->ValidEmail($contact['contact_email'])) {
             $mail->To($contact['contact_email']);
         }
     }
     $mail->From('"' . $owner_first_name . ' ' . $owner_last_name . '" <' . $owner_email . '>');
     $mail->Subject($subject, $locale_char_set);
     $mail->Body($body, $locale_char_set);
     return $mail->Send();
 }
Exemplo n.º 19
0
$q->addTable('contacts', 'a');
$q->leftJoin('companies', 'b', 'b.company_id = a.contact_company');
$q->leftJoin('departments', 'c', 'c.dept_id = a.contact_department');
$q->leftJoin('users', 'u', 'u.user_contact=a.contact_id');
$q->addQuery('a.contact_id, a.contact_first_name, a.contact_last_name,' . ' a.contact_company, a.contact_department');
$q->addQuery('b.company_name');
$q->addQuery('c.dept_name');
$q->addQuery('u.user_id');
if ($where) {
    // Don't assume where is set. Change needed to fix Mantis Bug 0002056
    $q->addWhere($where);
}
$q->addWhere('(contact_owner = ' . $AppUI->user_id . ' OR contact_private = 0)');
//May need to review this order.
$q->addOrder('company_name, contact_company, dept_name, contact_department' . ', contact_last_name');
$contacts = $q->loadHashList('contact_id');
global $task_id, $project_id;
$perms =& $AppUI->acl();
foreach ($contacts as $key => $row) {
    if ($row['user_id'] && !$perms->checkLogin($row['user_id'])) {
        $contacts[$key]['contact_extra'] .= ' (' . $AppUI->_('Inactive') . ')';
    }
}
?>

<form action="index.php?m=public&a=contact_selector&dialog=1<?php 
echo !is_null($call_back) ? '&call_back=' . $call_back : '';
?>
&company_id=<?php 
echo $company_id;
?>
Exemplo n.º 20
0
 function checkClash($userlist = null)
 {
     global $AppUI;
     if (!isset($userlist)) {
         return false;
     }
     $users = explode(',', $userlist);
     // Now, remove the owner from the list, as we will always clash on this.
     $key = array_search($AppUI->user_id, $users);
     if (isset($key) && $key !== false) {
         // Need both for change in php 4.2.0
         unset($users[$key]);
     }
     if (!count($users)) {
         return false;
     }
     $start_date =& new CDate($this->event_start_date);
     $end_date =& new CDate($this->event_end_date);
     // Now build a query to find matching events.
     $q = new DBQuery();
     $q->addTable('events', 'e');
     $q->addQuery('e.event_owner, ue.user_id, e.event_cwd, e.event_id, e.event_start_date, e.event_end_date');
     $q->addJoin('user_events', 'ue', 'ue.event_id = e.event_id');
     $q->addWhere("event_start_date <= '" . $end_date->format(FMT_DATETIME_MYSQL) . "'");
     $q->addWhere("event_end_date >= '" . $start_date->format(FMT_DATETIME_MYSQL) . "'");
     $q->addWhere("(e.event_owner IN (" . implode(',', $users) . ") OR ue.user_id IN (" . implode(',', $users) . "))");
     $q->addWhere('e.event_id != ' . $this->event_id);
     $result = $q->exec();
     if (!$result) {
         return false;
     }
     $clashes = array();
     while ($row = db_fetch_assoc($result)) {
         array_push($clashes, $row['event_owner']);
         if ($row['user_id']) {
             array_push($clashes, $row['user_id']);
         }
     }
     $clash = array_unique($clashes);
     $q->clear();
     if (count($clash)) {
         $q->addTable('users', 'u');
         $q->addTable('contacts', 'con');
         $q->addQuery('user_id');
         $q->addQuery('CONCAT_WS(" ",contact_first_name,contact_last_name)');
         $q->addWhere("user_id in (" . implode(",", $clash) . ")");
         $q->addWhere('user_contact = contact_id');
         return $q->loadHashList();
     } else {
         return false;
     }
 }
Exemplo n.º 21
0
        $q->addQuery('dept_id, dept_name, dept_parent');
        $q->addWhere('dep.dept_company = ' . $company_id);
        $q->addWhere('dep.dept_id != ' . $dept_id);
        $depts = $q->loadArrayList();
        $depts['0'] = array(0, '- ' . $AppUI->_('Select Unit') . ' -', -1);
    }
    // collect all the users for the department owner list
    $q = new DBQuery();
    $q->addTable('users', 'u');
    $q->addTable('contacts', 'con');
    $q->addQuery('user_id');
    $q->addQuery('CONCAT_WS(", ",contact_last_name, contact_first_name)');
    $q->addOrder('contact_first_name');
    $q->addWhere('u.user_contact = con.contact_id');
    $q->addOrder('contact_last_name, contact_first_name');
    $owners = arrayMerge(array('0' => ''), $q->loadHashList());
    // setup the title block
    $ttl = $company_id > 0 ? "Edit Department" : "Add Department";
    $titleBlock = new CTitleBlock($ttl, 'users.gif', $m, "{$m}.{$a}");
    $titleBlock->addCrumb("?m=companies", "companies list");
    $titleBlock->addCrumb("?m=companies&a=view&company_id={$company_id}", "view this company");
    $titleBlock->show();
    ?>
<script language="javascript">
function testURL( x ) {
	var test = "document.editFrm.dept_url.value";
	test = eval(test);
	if (test.length > 6) {
		newwin = window.open( "http://" + test, 'newwin', '' );
	}
}
Exemplo n.º 22
0
		document.AddEdit.submit();
	}	
</script>
	
<tr>
	<td align="right" nowrap="nowrap"><?php 
echo $AppUI->_('Project');
?>
:</td>
	<td width="60%">
<?php 
// pull the projects list
$q->addTable('projects');
$q->addQuery('project_id, project_name');
$q->addOrder('project_name');
$projects = arrayMerge(array(0 => '(' . $AppUI->_('any', UI_OUTPUT_RAW) . ')'), $q->loadHashList());
echo arraySelect($projects, 'history_project', 'class="text"', $history["history_project"]);
?>
	</td>
</tr>
	
<tr>
	<td align="right" nowrap="nowrap"><?php 
echo $AppUI->_('Description');
?>
:</td>
	<td width="60%">
		<textarea name="history_description" class="textarea" cols="60" rows="5" wrap="virtual"><?php 
echo $history["history_description"];
?>
</textarea>
Exemplo n.º 23
0
    }
}
// let's iterate root tasks
foreach ($root_tasks as $root_task) {
    build_date_list($projTasksWithEndDates, $root_task);
    if ($root_task['task_id'] != $task_id) {
        constructTaskTree($root_task, $parents, $all_tasks);
    }
}
$project = new CProject();
$sprojects = $project->getAllowedRecords($AppUI->user_id, 'project_id,project_name', 'project_name', null, $extra);
$q = new DBQuery();
$q->addTable('projects');
$q->addQuery('project_id, company_name');
$q->addJoin("companies", 'co', 'co.company_id = project_company');
$idx_companies = $q->loadHashList();
$q->clear();
foreach ($sprojects as $prj_id => $prj_name) {
    $sprojects[$prj_id] = $idx_companies[$prj_id] . ': ' . $prj_name;
}
asort($sprojects);
$sprojects = arrayMerge(array('' => '(' . $AppUI->_('Move to Project', UI_OUTPUT_RAW) . ')'), $sprojects);
//lets addthe reference to percent
@(include_once "./functions/tasks_func.php");
$spercent = arrayMerge(array('' => '(Progress)'), $percent);
?>
            <form name='frm_bulk' method='POST' action='?m=projectdesigner&a=do_task_bulk_aed'>
	      <input type="hidden" name="project_id" value="<?php 
echo $project_id;
?>
" />
Exemplo n.º 24
0
 public function &getAssigned()
 {
     $q = new DBQuery();
     $q->addTable('users', 'u');
     $q->addTable('user_tasks', 'ut');
     $q->addTable('contacts', 'con');
     $q->addQuery('u.user_id, CONCAT_WS(\' \',contact_first_name, contact_last_name) AS user_name, perc_assignment');
     $q->addWhere('ut.task_id = ' . (int) $this->task_id);
     $q->addWhere('user_contact = contact_id');
     $q->addWhere('ut.user_id = u.user_id');
     $assigned = $q->loadHashList('user_id');
     return $assigned;
 }
Exemplo n.º 25
0
echo $AppUI->_('submit');
?>
" />
	</td>
</tr>
</table>
</form>

<?php 
if ($do_report) {
    // Let's figure out which users we have
    $q = new DBQuery();
    $q->addTable('users', 'u');
    $q->addQuery('u.user_id, u.user_username, contact_first_name, contact_last_name');
    $q->addJoin('contacts', 'c', 'u.user_contact = contact_id');
    $user_list = $q->loadHashList('user_id');
    $q->clear();
    $q = new DBQuery();
    $q->addTable('tasks', 't');
    $q->addTable('user_tasks', 'ut');
    $q->addTable('projects', 'p');
    $q->addQuery('t.*, ut.*, p.project_name');
    $q->addWhere("( task_start_date\n\t\t\t   BETWEEN \"" . $start_date->format(FMT_DATETIME_MYSQL) . "\"\n\t                AND \"" . $end_date->format(FMT_DATETIME_MYSQL) . "\"\n\t           OR task_end_date\tBETWEEN \"" . $start_date->format(FMT_DATETIME_MYSQL) . "\"\n\t                AND \"" . $end_date->format(FMT_DATETIME_MYSQL) . "\"\n\t\t   OR ( task_start_date <= \"" . $start_date->format(FMT_DATETIME_MYSQL) . "\"\n\t                AND task_end_date >= \"" . $end_date->format(FMT_DATETIME_MYSQL) . "\") )");
    $q->addWhere('task_end_date IS NOT NULL');
    $q->addWhere("task_end_date != '0000-00-00 00:00:00'");
    $q->addWhere('task_start_date IS NOT NULL');
    $q->addWhere("task_start_date != '0000-00-00 00:00:00'");
    $q->addWhere("task_dynamic !='1'");
    $q->addWhere("task_milestone = '0'");
    $q->addWhere('task_duration  > 0');
    $q->addWhere('t.task_project = p.project_id');
Exemplo n.º 26
0
/*
 * Add drop-downs for "bulk" changes
 * Used 'O' (uppercase letter) instead of 0 (number) 
 * for "header option" ids so things would print right
 */
//project drop-down: allowed Projects only
//get list of allowed projects
$project = new CProject();
$projects_list = $project->getAllowedRecords($AppUI->user_id, 'project_id,project_name', 'project_name', null, $extra);
//getting company names (to go with project name in drop-down)
$q = new DBQuery();
$q->addTable('projects', 'p');
$q->addJoin('companies', 'co', 'co.company_id = p.project_company');
$q->addQuery('p.project_id, co.company_name');
$q->addWhere('p.project_id IN (0' . (count($projects_list) ? ',' . implode(',', array_keys($projects_list)) : '') . ')');
$proj_companies = $q->loadHashList();
$q->clear();
//folder drop-down: allowed Folders only
$folders_list = getFolderSelectList();
$folders_list = arrayMerge(array('O' => array('O', '(' . $AppUI->_('Move to Folder') . ')', -1)), $folders_list);
foreach ($projects_list as $prj_id => $prj_name) {
    $projects_list[$prj_id] = $proj_companies[$prj_id] . ': ' . $prj_name;
}
asort($projects_list);
$projects_list = arrayMerge(array('O' => '(' . $AppUI->_('Move to Project') . ')', '0' => '(' . $AppUI->_('No Project Association') . ')'), $projects_list);
?>
	<tr>
		<td colspan="50" align="right">
			<form name='frm_bulk' method='POST' action='?m=files&a=do_files_bulk_aed'>
			<input type="hidden" name="redirect" value="<?php 
echo $current_uri;
Exemplo n.º 27
0
        }
        echo "</div>";
    }
    ?>
		    	</td>
		    </tr>
	 		<?php 
}
$q = new DBQuery();
$q->addTable('contacts', 'a');
$q->addTable('project_contacts', 'b');
$q->addJoin('departments', 'c', 'a.contact_department = c.dept_id', 'left outer');
$q->addQuery('a.contact_id, a.contact_first_name, a.contact_last_name,
					a.contact_email, a.contact_phone, c.dept_name');
$q->addWhere("a.contact_id = b.contact_id and b.project_id = {$project_id}\n\t\t\t\t\tand (contact_owner = '{$AppUI->user_id}' or contact_private='0')");
$contacts = $q->loadHashList("contact_id");
if (count($contacts) > 0) {
    ?>
			    <tr>
			    	<td><strong><?php 
    echo $AppUI->_("Contacts");
    ?>
</strong></td>
			    </tr>
			    <tr>
			    	<td colspan='3' class="hilite">
			    		<?php 
    echo "<table cellspacing='1' cellpadding='2' border='0' width='100%' class='tbl'>";
    echo "<tr><th>" . $AppUI->_("Name") . "</th><th>" . $AppUI->_("Email") . "</th><th>" . $AppUI->_("Phone") . "</th><th>" . $AppUI->_("Department") . "</th></tr>";
    foreach ($contacts as $contact_id => $contact_data) {
        echo "<tr>";
Exemplo n.º 28
0
function getDepartmentSelectionList($company_id, $checked_array = array(), $dept_parent = 0, $spaces = 0)
{
    global $departments_count;
    $parsed = '';
    if ($departments_count < 6) {
        $departments_count++;
    }
    $q = new DBQuery();
    $q->addTable('departments');
    $q->addQuery('dept_id, dept_name');
    $q->addWhere("dept_parent = '{$dept_parent}' and dept_company = '{$company_id}'");
    $q->addOrder('dept_name');
    $depts_list = $q->loadHashList("dept_id");
    foreach ($depts_list as $dept_id => $dept_info) {
        $selected = in_array($dept_id, $checked_array) ? ' selected="selected"' : '';
        $parsed .= '<option value="' . $dept_id . '"' . $selected . '>' . str_repeat('&nbsp;', $spaces) . $dept_info['dept_name'] . '</option>';
        $parsed .= getDepartmentSelectionList($company_id, $checked_array, $dept_id, $spaces + 5);
    }
    return $parsed;
}
Exemplo n.º 29
0
$q->clear();
$obj = null;
if (!db_loadObject($sql, $obj) && $company_id > 0) {
    // $AppUI->setMsg( '	$qid =& $q->exec(); Company' ); // What is this for?
    $AppUI->setMsg("invalidID", UI_MSG_ERROR, true);
    $AppUI->redirect();
}
// collect all the users for the company owner list
$q = new DBQuery();
$q->addTable('users', 'u');
$q->addTable('contacts', 'con');
$q->addQuery('user_id');
$q->addQuery('CONCAT_WS(", ",contact_last_name,contact_first_name)');
$q->addOrder('contact_last_name');
$q->addWhere('u.user_contact = con.contact_id');
$owners = $q->loadHashList();
// setup the title block
$ttl = $company_id > 0 ? "Edit Company" : "Add Company";
$titleBlock = new CTitleBlock($ttl, 'handshake.png', $m, "{$m}.{$a}");
$titleBlock->addCrumb("?m=companies", "companies list");
if ($company_id != 0) {
    $titleBlock->addCrumb("?m=companies&a=view&company_id={$company_id}", "view this company");
}
$titleBlock->show();
?>

<script language="javascript">
function submitIt() {
	var form = document.changeclient;
	if (form.company_name.value.length < 3) {
		alert( "<?php 
Exemplo n.º 30
0
if ($hasResources) {
    $columns[] = $AppUI->_('Assigned Resources');
}
$columns[] = $AppUI->_('Finish Date');
// Grab the completed items in the last week
$q = new DBQuery();
$q->addQuery('a.*');
$q->addQuery('b.user_username');
$q->addTable('tasks', 'a');
$q->leftJoin('users', 'b', 'a.task_owner = b.user_id');
$q->addWhere('task_percent_complete < 100');
if ($project_id != 0) {
    $q->addWhere('task_project = ' . $project_id);
}
$q->addWhere("task_end_date <  '" . $date->format(FMT_DATETIME_MYSQL) . "'");
$tasks = $q->loadHashList('task_id');
if ($err = db_error()) {
    $AppUI->setMsg($err, UI_MSG_ERROR);
    $AppUI->redirect();
}
// 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)) {
    $q->clear();
    $q->addQuery('a.task_id, a.perc_assignment, b.*, c.*');
    $q->addTable('user_tasks', 'a');