function getFolderSelectList() { global $AppUI; $folders = array(0 => ''); $q = new DBQuery(); $q->addTable('file_folders'); $q->addQuery('file_folder_id, file_folder_name, file_folder_parent'); $q->addOrder('file_folder_name'); $sql = $q->prepare(); // $sql = "SELECT file_folder_id, file_folder_name, file_folder_parent FROM file_folders"; $vfolders = arrayMerge(array('0' => array(0, $AppUI->_('Root'), -1)), db_loadHashList($sql, 'file_folder_id')); $folders = array_filter($vfolders, "check_perm"); return $folders; }
/** 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 DBQuery(); $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(); } }
/** 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 DBQuery(); $q->addTable('tasks'); $q->addWhere("task_project = {$project_id} AND !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(); } }
function getAllUsersGroupByDept() { $q = new DBQuery(); $q->addTable('users'); $q->addQuery('user_id, contact_department, concat_ws(", ", contact_last_name, contact_first_name) as contact_name'); $q->addJoin('contacts', 'con', 'contact_id = user_contact'); $q->addOrder('contact_last_name'); $res = $q->exec(); $userlist = array(); while ($row = $q->fetchRow()) { if ($row['contact_department'] == null) { $row['contact_department'] = 0; } if (!isset($userlist[$row['contact_department']])) { $userlist[$row['contact_department']] = array(); } $userlist[$row['contact_department']][$row['user_id']] = $row['contact_name']; } $q->clear(); return $userlist; }
if ($company_id) { $q = new DBQuery(); $q->addTable('departments', 'dep'); $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) {
break; 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") {
$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 DBQuery(); $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 = (int) dPgetParam($_REQUEST, 'tab', 0); ?> <script language="JavaScript" type="text/javascript"> //<![CDATA[ function logoutSession(sessionID, logID, userID, userName) { var frm; frm = document.getElementById("frmSessions"); frm.out_session.value = sessionID; frm.out_user_log_id.value = logID; frm.out_user_id.value = userID; frm.out_name.value = userName; frm.submit(); }
if (!$canEdit) { $AppUI->redirect("m=public&a=access_denied"); } // use the object oriented design of dP for loading the log that should be edited // 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
$q->addWhere('task_project = ' . $task_project); $q->addWhere('task_id = task_parent'); $q->addOrder('task_start_date'); $sql = $q->prepare(); $q->clear(); $root_tasks = db_loadHashList($sql, 'task_id'); $projTasks = array(); global $task_parent_options; $task_parent_options = ""; // Now lets get non-root tasks, grouped by the task parent $q = new DBQuery(); $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 = ' . $task_project); $q->addWhere('task_id <> task_parent'); $q->addOrder('task_start_date'); $sql = $q->prepare(); $q->clear(); $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 = db_exec($sql); if ($sub_tasks) { while ($sub_task = db_fetch_assoc($sub_tasks)) { // 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); }
/** * Calculate the extent of utilization of user assignments * @param string hash a hash for the returned hashList * @param array users an array of user_ids calculating their assignment capacity * @return array returns hashList of extent of utilization for assignment of the users */ function getAllocation($hash = NULL, $users = NULL) { // if (! dPgetConfig('check_overallocation') && ! dPgetConfig('direct_edit_assignment')) { return array(); //} $q = new DBQuery(); // retrieve the systemwide default preference for the assignment maximum $q->addTable('user_preferences'); $q->addQuery('pref_value'); $q->addWhere("pref_user = 0 AND pref_name = 'TASKASSIGNMAX'"); $sql = $q->prepare(); $q->clear(); $result = db_loadHash($sql, $sysChargeMax); if (!$result) { $scm = 0; } else { $scm = $sysChargeMax['pref_value']; } /* * provide actual assignment charge, individual chargeMax * and freeCapacity of users' assignments to tasks */ $q->addTable('users', 'u'); $q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact'); $q->leftJoin('user_tasks', 'ut', 'ut.user_id = u.user_id'); $q->leftJoin('user_preferences', 'up', 'up.pref_user = u.user_id'); $q->addQuery("u.user_id, CONCAT(CONCAT_WS(' [', CONCAT_WS(' '" . ', contact_first_name, contact_last_name), IF(IFNULL((IFNULL(up.pref_value' . ', ' . $scm . ') - SUM(ut.perc_assignment)), up.pref_value) > 0' . ', IFNULL((IFNULL(up.pref_value, ' . $scm . ') - SUM(ut.perc_assignment))' . ', up.pref_value), 0)), ' . "'%]')" . ' AS userFC' . ', IFNULL(SUM(ut.perc_assignment), 0) AS charge, u.user_username' . ', IFNULL(up.pref_value,' . $scm . ') AS chargeMax' . ', IF(IFNULL((IFNULL(up.pref_value, ' . $scm . ') ' . '- SUM(ut.perc_assignment)), up.pref_value) > 0' . ', IFNULL((IFNULL(up.pref_value, ' . $scm . ') - SUM(ut.perc_assignment))' . ', up.pref_value), 0) AS freeCapacity'); if (!empty($users)) { // use userlist if available otherwise pull data for all users $q->addWhere('u.user_id IN (' . implode(',', $users) . ')'); } $q->addGroup('u.user_id'); $q->addOrder('contact_last_name, contact_first_name'); $sql = $q->prepare(); $q->clear(); //echo "<pre>$sql</pre>"; return db_loadHashList($sql, $hash); }
die('You should not access this file directly.'); } $AppUI->savePlace(); $canEdit = getPermission($m, 'edit'); $canRead = getPermission($m, 'view'); if (!$canRead) { $AppUI->redirect('m=public&a=access_denied'); } $hidden_modules = array('public', 'install'); $q = new DBQuery(); $q->addQuery('*'); $q->addTable('modules'); foreach ($hidden_modules as $no_show) { $q->addWhere('mod_directory != \'' . $no_show . '\''); } $q->addOrder('mod_ui_order'); $modules = db_loadList($q->prepare()); // 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="98%" class="tbl"> <tr> <th colspan="2"><?php echo $AppUI->_('Module'); ?> </th> <th><?php
<?php /* COMPANIES $Id: vw_depts.php,v 1.15.2.1 2006/07/31 11:54:15 nybod Exp $ */ ## ## Companies: View Projects sub-table ## global $AppUI, $company_id, $canEdit; $q = new DBQuery(); $q->addTable('departments'); $q->addQuery('departments.*, COUNT(contact_department) dept_users'); $q->addJoin('contacts', 'c', 'c.contact_department = dept_id'); $q->addWhere('dept_company = ' . $company_id); $q->addGroup('dept_id'); $q->addOrder('dept_parent, dept_name'); $sql = $q->prepare(); $q->clear(); // function renamed to avoid naming clash function showchilddept_comp(&$a, $level = 0) { global $AppUI; $s = ' <td> <a href="index.php?m=departments&a=addedit&dept_id=' . $a['dept_id'] . '" title="' . $AppUI->_('edit') . '"> ' . dPshowImage('images/edit.gif', 12, 12, '') . ' </td> <td>'; for ($y = 0; $y < $level; $y++) { if ($y + 1 == $level) { $s .= '<img src="images/corner-dots.gif" width="16" height="12" border="0">'; } else { $s .= '<img src="images/shim.gif" width="16" height="12" border="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(); }
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(' ', $spaces) . $dept_info['dept_name'] . '</option>'; $parsed .= getDepartmentSelectionList($company_id, $checked_array, $dept_id, $spaces + 5); } return $parsed; }
function displayFiles($folder_id) { global $AppUI, $m, $a, $tab, $page; global $current_uri; global $canAccess, $canRead, $canEdit, $canAuthor, $canDelete; global $canAccess_folders, $canRead_folders, $canEdit_folders; global $canAuthor_folders, $canDelete_folders; global $company_id, $project_id, $task_id; global $allowedCompanies, $allowedProjects, $allowedTasks, $allowedFolders; global $showProject, $cfObj, $dPconfig; $df = $AppUI->getPref('SHDATEFORMAT'); $tf = $AppUI->getPref('TIMEFORMAT'); $file_types = dPgetSysVal('FileType'); $xpg_pagesize = 30; //TODO?: Set by System Config Value ... $xpg_totalrecs = countFiles($folder_id); //get file count for folder $xpg_total_pages = $xpg_totalrecs > $xpg_pagesize ? ceil($xpg_totalrecs / $xpg_pagesize) : 1; $xpg_min = $xpg_pagesize * ($page - 1); // This is where we start our record set from $q = new DBQuery(); // most recent version info per file_project and file_version_id $q->createTemp('files_count_max' . $folder_id); $q->addTable('files', 'f'); $q->addQuery('DISTINCT count(f.file_id) as file_versions' . ', max(f.file_version) as file_lastversion' . ', file_version_id, f.file_project'); $q->addJoin('projects', 'p', 'p.project_id = f.file_project'); $q->addJoin('tasks', 't', 't.task_id = f.file_task'); $q->addJoin('file_folders', 'ff', 'ff.file_folder_id = f.file_folder'); $q->addWhere('f.file_folder = ' . $folder_id); if (count($allowedProjects)) { $q->addWhere('((' . implode(' AND ', $allowedProjects) . ') OR f.file_project = 0)'); } if (count($allowedTasks)) { $q->addWhere('((' . implode(' AND ', $allowedTasks) . ') OR f.file_task = 0)'); } if (count($allowedFolders)) { $q->addWhere('((' . implode(' AND ', $allowedFolders) . ') OR f.file_folder = 0)'); } if ($company_id) { $q->innerJoin('companies', 'co', 'co.company_id = p.project_company'); $q->addWhere('co.company_id = ' . $company_id); if (count($allowedCompanies)) { $q->addWhere('(' . implode(' AND ', $allowedCompanies) . ')'); } } $q->addGroup('f.file_version_id'); $q->addGroup('f.file_project'); $file_version_max_counts = $q->exec(); $q->clear(); // most recent version $q->addTable('files', 'f'); $q->addQuery('f.*, fmc.file_versions, round(fmc.file_lastversion, 2) as file_lastversion' . ', u.user_username as file_owner, ff.file_folder_name' . ', ff.file_folder_id, ff.file_folder_name, p.project_name' . ', p.project_color_identifier, p.project_owner, c.contact_first_name' . ', c.contact_last_name, t.task_name, u.user_username as file_owner' . ', cc.contact_first_name as checkout_first_name' . ', cc.contact_last_name as checkout_last_name'); $q->addJoin('files_count_max' . $folder_id, 'fmc', '(fmc.file_lastversion=f.file_version AND fmc.file_version_id=f.file_version_id' . ' AND fmc.file_project=f.file_project)', 'inner'); $q->addJoin('projects', 'p', 'p.project_id = f.file_project'); $q->addJoin('users', 'u', 'u.user_id = f.file_owner'); $q->addJoin('contacts', 'c', 'c.contact_id = u.user_contact'); $q->addJoin('tasks', 't', 't.task_id = f.file_task'); $q->addJoin('file_folders', 'ff', 'ff.file_folder_id = f.file_folder'); $q->leftJoin('users', 'cu', 'cu.user_id = f.file_checkout'); $q->leftJoin('contacts', 'cc', 'cc.contact_id = cu.user_contact'); $q->addWhere('f.file_folder = ' . $folder_id); if (count($allowedProjects)) { $q->addWhere('((' . implode(' AND ', $allowedProjects) . ') OR f.file_project = 0)'); } if (count($allowedTasks)) { $q->addWhere('((' . implode(' AND ', $allowedTasks) . ') OR f.file_task = 0)'); } if (count($allowedFolders)) { $q->addWhere('((' . implode(' AND ', $allowedFolders) . ') OR f.file_folder = 0)'); } if ($project_id) { $q->addWhere('f.file_project = ' . $project_id); } if ($task_id) { $q->addWhere('f.file_task = ' . $task_id); } if ($company_id) { $q->innerJoin('companies', 'co', 'co.company_id = p.project_company'); $q->addWhere('co.company_id = ' . $company_id); if (count($allowedCompanies)) { $q->addWhere('(' . implode(' AND ', $allowedCompanies) . ')'); } } $q->addOrder('p.project_name'); $q->setLimit($xpg_pagesize, $xpg_min); $files_sql = $q->prepare(); $q->clear(); // all versions $q->addTable('files', 'f'); $q->addQuery('f.*, ff.file_folder_id, ff.file_folder_name, p.project_name' . ', p.project_color_identifier, p.project_owner, c.contact_first_name' . ', c.contact_last_name, t.task_name, u.user_username as file_owner'); $q->addJoin('projects', 'p', 'p.project_id = f.file_project'); $q->addJoin('users', 'u', 'u.user_id = f.file_owner'); $q->addJoin('contacts', 'c', 'c.contact_id = u.user_contact'); $q->addJoin('tasks', 't', 't.task_id = f.file_task'); $q->addJoin('file_folders', 'ff', 'ff.file_folder_id = f.file_folder'); $q->addWhere('f.file_folder = ' . $folder_id); if (count($allowedProjects)) { $q->addWhere('((' . implode(' AND ', $allowedProjects) . ') OR f.file_project = 0)'); } if (count($allowedTasks)) { $q->addWhere('((' . implode(' AND ', $allowedTasks) . ') OR f.file_task = 0)'); } if (count($allowedFolders)) { $q->addWhere('((' . implode(' AND ', $allowedFolders) . ') OR f.file_folder = 0)'); } if ($project_id) { $q->addWhere('f.file_project = ' . $project_id); } if ($task_id) { $q->addWhere('f.file_task = ' . $task_id); } if ($company_id) { $q->innerJoin('companies', 'co', 'co.company_id = p.project_company'); $q->addWhere('co.company_id = ' . $company_id); if (count($allowedCompanies)) { $q->addWhere('(' . implode(' AND ', $allowedCompanies) . ')'); } } $file_versions_sql = $q->prepare(); $q->clear(); //file arrays $files = array(); $file_versions = array(); if ($canRead) { $files = db_loadList($files_sql); $file_versions = db_loadHashList($file_versions_sql, 'file_id'); } $q->dropTemp('files_count_max' . $folder_id); $q->exec(); if ($files == array()) { return; } ?> <table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl"> <tr> <th nowrap="nowrap"><?php echo $AppUI->_('File Name'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Description'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Versions'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Category'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Task Name'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Owner'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Size'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Date'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('co Reason'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('co'); ?> </th> <th nowrap width="1"></th> <th nowrap width="1"></th> </tr> <?php $fp = -1; $file_date = new CDate(); $id = 0; foreach ($files as $row) { $file_date = new CDate($row['file_date']); $canEdit_file = getPermission('files', 'edit', $row['file_id']); //single file if ($fp != $row['file_project']) { if (!$row['file_project']) { $row['project_name'] = $AppUI->_('Not associated to projects'); $row['project_color_identifier'] = 'f4efe3'; } if ($showProject) { $style = 'background-color:#' . $row['project_color_identifier'] . ';color:' . bestColor($row['project_color_identifier']); ?> <tr> <td colspan="20" style="border: outset 2px #eeeeee;<?php echo $style; ?> "> <a href="?m=projects&a=view&project_id=<?php echo $row['file_project']; ?> "> <span style="<?php echo $style; ?> "><?php echo $row['project_name']; ?> </span></a> </td> </tr> <?php } } $fp = $row['file_project']; ?> <form name="frm_remove_file_<?php echo $row['file_id']; ?> " action="?m=files" method="post"> <input type="hidden" name="dosql" value="do_file_aed" /> <input type="hidden" name="del" value="1" /> <input type="hidden" name="file_id" value="<?php echo $row['file_id']; ?> " /> <input type="hidden" name="redirect" value="<?php echo $current_uri; ?> " /> </form> <form name="frm_duplicate_file_<?php echo $row['file_id']; ?> " action="?m=files" method="post"> <input type="hidden" name="dosql" value="do_file_aed" /> <input type="hidden" name="duplicate" value="1" /> <input type="hidden" name="file_id" value="<?php echo $row['file_id']; ?> " /> <input type="hidden" name="redirect" value="<?php echo $current_uri; ?> " /> </form> <tr> <td nowrap="8%"> <?php $file_icon = getIcon($row['file_type']); ?> <a href="./fileviewer.php?file_id=<?php echo $row['file_id']; ?> " title="<?php echo $row['file_description']; ?> "> <?php echo dPshowImage(DP_BASE_URL . '/modules/files/images/' . $file_icon, '16', '16'); ?> <?php echo $row['file_name']; ?> </a> </td> <td width="20%"><?php echo $row['file_description']; ?> </td> <td width="5%" nowrap="nowrap" align="center"> <?php $hidden_table = ''; echo $row['file_lastversion']; if ($row['file_versions'] > 1) { ?> <a href="#" onClick="expand('versions_<?php echo $row['file_id']; ?> ');"> (<?php echo $row['file_versions']; ?> ) </a> <?php } ?> </td> <td width="10%" nowrap="nowrap" align="center"> <?php echo $file_types[$row['file_category']]; ?> </td> <td width="5%" align="center"> <a href="./index.php?m=tasks&a=view&task_id=<?php echo $row['file_task']; ?> "> <?php echo $row['task_name']; ?> </a> </td> <td width="15%" nowrap="nowrap"> <?php echo $row["contact_first_name"] . ' ' . $row["contact_last_name"]; ?> </td> <td width="5%" nowrap="nowrap" align="right"> <?php echo file_size(intval($row['file_size'])); ?> </td> <td width="15%" nowrap="nowrap" align="right"> <?php echo $file_date->format($df . ' ' . $tf); ?> </td> <td width="10%"><?php echo $row['file_co_reason']; ?> </td> <td nowrap="nowrap" align="center"> <?php if ($canEdit && empty($row['file_checkout'])) { ?> <a href="?m=files&a=co&file_id=<?php echo $row['file_id']; ?> "> <?php echo dPshowImage(DP_BASE_URL . '/modules/files/images/up.png', '16', '16', 'checkout', 'checkout file'); ?> </a> <?php } else { if ($row['file_checkout'] == $AppUI->user_id) { ?> <a href="?m=files&a=addedit&ci=1&file_id=<?php echo $row['file_id']; ?> "> <?php echo dPshowImage(DP_BASE_URL . '/modules/files/images/down.png', '16', '16', 'checkin', 'checkin file'); ?> </a> <?php } else { if ($file['file_checkout'] == 'final') { echo ' ' . $AppUI->_('final'); } else { echo ' ' . $row['checkout_first_name'] . ' ' . $row['checkout_last_name'] . '<br />(' . $row['co_user'] . ')'; } } } ?> </td> <td nowrap="nowrap" align="right" width="48"> <?php if (empty($row['file_checkout']) || $row['file_checkout'] == 'final') { // Edit File if ($canEdit || $row['project_owner'] == $AppUI->user_id) { ?> <a href="./index.php?m=files&a=addedit&file_id=<?php echo $row['file_id']; ?> "> <?php echo dPshowImage(DP_BASE_URL . '/modules/files/images/kedit.png', '16', '16', 'edit file', 'edit file'); ?> </a> <?php } // Duplicate File if ($canAuthor || $row['project_owner'] == $AppUI->user_id) { ?> <a href="#" onclick="document.frm_duplicate_file_<?php echo $row['file_id']; ?> .submit()"> <?php echo dPshowImage(DP_BASE_URL . '/modules/files/images/duplicate.png', '16', '16', 'duplicate file', 'duplicate file'); ?> </a> <?php } // Delete File if ($canDelete || $row['project_owner'] == $AppUI->user_id) { ?> <a href="#" onclick="if (confirm('Are you sure you want to delete this file?')) {document.frm_remove_file_<?php echo $row['file_id']; ?> .submit()}"> <?php echo dPshowImage(DP_BASE_URL . '/modules/files/images/remove.png', '16', '16', 'delete file', 'delete file'); ?> </a> <?php } } ?> </td> <td nowrap="nowrap" align="center" width="1"> <?php if ((empty($row['file_checkout']) || $row['file_checkout'] == 'final') && ($canEdit || $row['project_owner'] == $AppUI->user_id)) { $bulk_op = 'onchange="(this.checked) ? addBulkComponent(' . $row['file_id'] . ') : removeBulkComponent(' . $row['file_id'] . ')"'; ?> <input type="checkbox" <?php echo $bulk_op; ?> name="chk_sub_sel_file_<?php echo $file_row['file_id']; ?> " /> <?php } ?> </td> </tr> <?php if ($row['file_versions'] > 1) { ?> <tr><td colspan="20"> <table style="display: none" id="versions_<?php echo $row['file_id']; ?> " width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl"> <tr> <th nowrap="nowrap"><?php echo $AppUI->_('File Name'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Description'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Versions'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Category'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Task Name'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Owner'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Size'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Type'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Date'); ?> </th> <th nowrap="nowrap"width="1"> </th> <th nowrap="nowrap"width="1"> </th> </tr> <?php foreach ($file_versions as $file) { if ($file['file_version_id'] == $row['file_version_id']) { $file_icon = getIcon($file['file_type']); $file_version_date = new Date($file['file_date']); ?> <form name="frm_delete_sub_file_<?php echo $file['file_id']; ?> " action="?m=files" method="post"> <input type="hidden" name="dosql" value="do_file_aed" /> <input type="hidden" name="del" value="1" /> <input type="hidden" name="file_id" value="<?php echo $file['file_id']; ?> " /> <input type="hidden" name="redirect" value="<?php echo $current_uri; ?> " /> </form> <form name="frm_duplicate_sub_file_<?php echo $file['file_id']; ?> " action="?m=files" method="post"> <input type="hidden" name="dosql" value="do_file_aed" /> <input type="hidden" name="duplicate" value="1" /> <input type="hidden" name="file_id" value="<?php echo $file['file_id']; ?> " /> <input type="hidden" name="redirect" value="<?php echo $current_uri; ?> " /> </form> <tr> <td nowrap="8%"> <a href="./fileviewer.php?file_id=<?php echo $file['file_id']; ?> " title="<?php echo $file['file_description']; ?> "> <?php echo dPshowImage(DP_BASE_URL . '/modules/files/images/' . $file_icon, '16', '16'); ?> <?php echo $file['file_name']; ?> </a> </td> <td width="20%"><?php echo $file['file_description']; ?> </td> <td width="5%" nowrap="nowrap" align="center"><?php echo $file['file_version']; ?> </td> <td width="10%" nowrap="nowrap" align="center"> <?php echo $file_types[$file['file_category']]; ?> </td> <td width="5%" align="center"> <a href="./index.php?m=tasks&a=view&task_id=<?php echo $file['file_task']; ?> "> <?php echo $file['task_name']; ?> </a> </td> <td width="15%" nowrap="nowrap"> <?php echo $file["contact_first_name"] . ' ' . $file["contact_last_name"]; ?> </td> <td width="5%" nowrap="nowrap" align="right"> <?php echo file_size(intval($file['file_size'])); ?> </td> <td nowrap="nowrap"> <?php echo $row['file_type']; ?> </td> <td width="15%" nowrap="nowrap" align="right"> <?php echo $file_version_date->format($df . ' ' . $tf); ?> </td> <td nowrap="nowrap" align="right" width="48"> <?php if (empty($file['file_checkout']) || $file['file_checkout'] == 'final') { // Edit File if ($canEdit || $row['project_owner'] == $AppUI->user_id) { ?> <a href="./index.php?m=files&a=addedit&file_id=<?php echo $row['file_id']; ?> "> <?php echo dPshowImage(DP_BASE_URL . '/modules/files/images/kedit.png', '16', '16', 'edit file', 'edit file'); ?> </a> <?php } // Duplicate File if ($canAuthor) { ?> <a href="#" onclick="document.frm_duplicate_file_<?php echo $row['file_id']; ?> .submit()"> <?php echo dPshowImage(DP_BASE_URL . '/modules/files/images/duplicate.png', '16', '16', 'duplicate file', 'duplicate file'); ?> </a> <?php } // Delete File if ($canDelete) { ?> <a href="#" onclick="if (confirm('<?php echo $AppUI->_('Are you sure you want to delete this file?'); ?> ')) {document.frm_remove_file_<?php echo $row['file_id']; ?> .submit()}"> <?php echo dPshowImage(DP_BASE_URL . '/modules/files/images/remove.png', '16', '16', 'delete file', $AppUI->_('delete file')); ?> </a> <?php } } ?> </td> <td nowrap="nowrap" align="center" width="1"> <?php if ((empty($row['file_checkout']) || $row['file_checkout'] == 'final') && ($canEdit || $row['project_owner'] == $AppUI->user_id)) { $bulk_op = 'onchange="(this.checked) ? addBulkComponent(' . $row['file_id'] . ') : removeBulkComponent(' . $row['file_id'] . ')"'; ?> <input type="checkbox" <?php echo $bulk_op; ?> name="chk_sub_sel_file_<?php echo $file_row['file_id']; ?> " /> <?php } ?> </td> </tr> <?php } } ?> </table> </td></tr> <?php } } ?> </table> <?php shownavbar($xpg_totalrecs, $xpg_pagesize, $xpg_total_pages, $page, $folder_id); echo "<br />"; }
public function getAllowedTaskList($AppUI, $task_project = 0) { $q = new DBQuery(); $q->addQuery('task_id, task_name, task_parent, task_access, task_owner'); $q->addOrder('task_parent, task_parent = task_id desc'); $q->addTable('tasks', 't'); if ($task_project) { $q->addWhere('task_project = ' . (int) $task_project); } $task_list = $q->loadList(); foreach ($task_list as $task) { if (canTaskAccess($task['task_id'], $task['task_access'], $task['task_owner'])) { $results[] = $task; } } return $results; }
function getCriticalTasks($project_id = NULL, $limit = 1) { $project_id = !empty($project_id) ? $project_id : $this->project_id; $q = new DBQuery(); $q->addTable('tasks'); if ($project_id) { $q->addWhere('task_project = ' . $project_id); } $q->addWhere("!isnull(task_end_date) AND task_end_date != '0000-00-00 00:00:00'"); $q->addOrder('task_end_date DESC'); $q->setLimit($limit); return $q->loadList(); }
echo db_error(); //pull message information $q = new DBQuery(); $q->addTable('forum_messages'); $q->addQuery('forum_messages.*, user_username'); $q->addJoin('users', 'u', 'message_author = u.user_id'); $q->addWhere('message_id = ' . ($message_id ? $message_id : $message_parent)); $res = $q->exec(); echo db_error(); $message_info = $q->fetchRow(); $q->clear(); //pull message information from last response if ($message_parent != -1) { $q->addTable('forum_messages'); $q->addWhere('message_parent = ' . ($message_id ? $message_id : $message_parent)); $q->addOrder('message_id DESC'); // fetch last message first $q->setLimit(1); $res = $q->exec(); echo db_error(); $last_message_info = $q->fetchRow(); if (!$last_message_info) { // if it's first response, use original message $last_message_info =& $message_info; $last_message_info["message_body"] = wordwrap(@$last_message_info["message_body"], 50, "\n> "); } else { $last_message_info["message_body"] = str_replace("\n", "\n> ", @$last_message_info["message_body"]); } $q->clear(); } $crumbs = array();
$q->addJoin('contacts', 'con', 'u.user_contact = con.contact_id'); $q->addJoin('projects', 'p2', 'c.company_id = p2.project_company AND p2.project_status = 7'); if (count($allowedCompanies) > 0) { $q->addWhere('c.company_id IN (' . implode(',', array_keys($allowedCompanies)) . ')'); } if ($companiesType) { $q->addWhere('c.company_type = ' . $company_type_filter); } if ($search_string != "") { $q->addWhere("c.company_name LIKE '%{$search_string}%'"); } if ($owner_filter_id > 0) { $q->addWhere("c.company_owner = {$owner_filter_id} "); } $q->addGroup('c.company_id'); $q->addOrder($orderby . ' ' . $orderdir); $rows = $q->loadList(); ?> <table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl"> <tr> <td nowrap="nowrap" width="60" align="right"> <?php echo $AppUI->_('sort by'); ?> : </td> <th nowrap="nowrap"> <a href="?m=companies&orderby=company_name" class="hdr"><?php echo $AppUI->_('Company Name'); ?> </a> </th> <th nowrap="nowrap">
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"); }
//Pull forum information $q = new DBQuery(); $q->addTable('forums'); $q->addWhere("forums.forum_id = {$forum_id}"); $res = $q->exec(); echo db_error(); $forum_info = db_fetch_assoc($res); $status = isset($forum_info["forum_status"]) ? $forum_info["forum_status"] : -1; // get any project records denied from viewing $projObj = new CProject(); //Pull project Information $q = new DBQuery(); $q->addTable('projects'); $q->addQuery('project_id, project_name'); $q->addWhere('project_status <> 7'); $q->addOrder('project_name'); $projObj->setAllowedSQL($AppUI->user_id, $q); if (isset($company_id)) { $q->addWhere("project_company = {$company_id}"); } $projects = array('0' => '') + $q->loadHashList(); echo db_error(); if (!in_array($forum_project, array_keys($projects))) { $forum_project = 0; } $perms =& $AppUI->acl(); $permittedUsers =& $perms->getPermittedUsers(); $users = array('0' => '') + $permittedUsers; // setup the title block $ttl = $forum_id > 0 ? "Edit Forum" : "Add Forum"; $titleBlock = new CTitleBlock($ttl, 'support.png', $m, "{$m}.{$a}");
function CustomFields($m, $a, $obj_id = NULL, $mode = "edit") { $this->m = $m; $this->a = 'addedit'; // only addedit pages can carry the custom field for now $this->obj_id = $obj_id; $this->mode = $mode; // Get Custom Fields for this Module $q = new DBQuery(); $q->addTable('custom_fields_struct'); $q->addWhere("field_module = '" . $this->m . "' AND\tfield_page = '" . $this->a . "'"); $q->addOrder('field_order ASC'); $rows = $q->loadList(); if ($rows == NULL) { // No Custom Fields Available } else { foreach ($rows as $row) { switch ($row["field_htmltype"]) { case "checkbox": $this->fields[$row["field_name"]] = new CustomFieldCheckbox($row["field_id"], $row["field_name"], $row["field_order"], stripslashes($row["field_description"]), stripslashes($row["field_extratags"])); break; case "textarea": $this->fields[$row["field_name"]] = new CustomFieldTextArea($row["field_id"], $row["field_name"], $row["field_order"], stripslashes($row["field_description"]), stripslashes($row["field_extratags"])); break; case "select": $this->fields[$row["field_name"]] = new CustomFieldSelect($row["field_id"], $row["field_name"], $row["field_order"], stripslashes($row["field_description"]), stripslashes($row["field_extratags"])); break; case "label": $this->fields[$row["field_name"]] = new CustomFieldLabel($row["field_id"], $row["field_name"], $row["field_order"], stripslashes($row["field_description"]), stripslashes($row["field_extratags"])); break; case "separator": $this->fields[$row["field_name"]] = new CustomFieldSeparator($row["field_id"], $row["field_name"], $row["field_order"], stripslashes($row["field_description"]), stripslashes($row["field_extratags"])); break; default: $this->fields[$row["field_name"]] = new CustomFieldText($row["field_id"], $row["field_name"], $row["field_order"], stripslashes($row["field_description"]), stripslashes($row["field_extratags"])); break; } } if ($obj_id > 0) { //Load Values foreach ($this->fields as $key => $cfield) { $this->fields[$key]->load($this->obj_id); } } } }
$forum_id = (int) dPgetParam($_REQUEST, 'forum_id', 0); $message_id = (int) dPgetParam($_REQUEST, 'message_id', 0); if (!getPermission('forums', 'view', $message_id)) { $AppUI->redirect("m=public&a=access_denied"); } $q = new DBQuery(); $q->addTable('forums'); $q->addTable('forum_messages', 'msg'); $q->addQuery('msg.*, contact_first_name, contact_last_name, contact_email, user_username, forum_moderated, visit_user'); $q->addJoin('forum_visits', 'v', "visit_user = {$AppUI->user_id} AND visit_forum = {$forum_id} AND visit_message = msg.message_id"); $q->addJoin('users', 'u', 'message_author = u.user_id'); $q->addJoin('contacts', 'con', 'contact_id = user_contact'); $q->addWhere("forum_id = message_forum AND (message_id = {$message_id} OR message_parent = {$message_id})"); if (dPgetConfig('forum_descendent_order') || dPgetCleanParam($_REQUEST, 'sort', 0)) { $q->addOrder("message_date {$sort}"); } $messages = $q->loadList(); $x = false; $date = new CDate(); $pdfdata = array(); $pdfhead = array('Date', 'User', 'Message'); $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 DBQuery(); $q->addTable('forum_messages'); $q->addTable('users', 'u');
$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('contact_email, ut.perc_assignment, SUM(ut.perc_assignment) AS assign_extent'); $q->addQuery('contact_first_name, contact_last_name'); $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');
</table> </form> <?php echo $AppUI->_('P') . ' = ' . $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') {
$q->addGroup('ta.task_id'); if ($sortByName) { $q->addOrder('ta.task_name, ta.task_end_date'); } else { $q->addOrder('ta.task_end_date'); } $q->addOrder('task_priority DESC'); ############################################################## } else { // pull tasks $q = new DBQuery(); $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_name, task_dynamic'); $q->addJoin('projects', 'p', 'project_id = t.task_project', 'inner'); if ($sortByName) { $q->addOrder('project_id, t.task_name, task_start_date'); } else { $q->addOrder('project_id, task_start_date'); } if ($project_id) { $q->addWhere('task_project = ' . (int) $project_id); } switch ($f) { case 'all': $q->addWhere('task_status > -1'); break; case 'myproj': $q->addWhere('task_status > -1'); $q->addWhere('project_owner = ' . (int) $AppUI->user_id); break; case 'mycomp':
} if ($showInactive != '1') { $filter1[] = ' project_status <> 7'; } $pjobj =& new CProject(); $allowed_projects = $pjobj->getAllowedSQL($AppUI->user_id); $where = array_merge($filter1, $allowed_projects); // pull valid projects and their percent complete information $q = new DBQuery(); $q->addTable('tasks', 't'); $q->addJoin('user_tasks', 'ut', 't.task_id = ut.task_id'); $q->addJoin('users', 'u', 'u.user_id = ut.user_id'); $q->addJoin('projects', 'p', 'p.project_id = t.task_project'); $q->addJoin('companies', 'c', 'p.project_company = c.company_id'); $q->addQuery('u.user_username, t.task_name, t.task_start_date, t.task_milestone' . ', ut.perc_assignment, t.task_end_date, t.task_dynamic' . ', p.project_color_identifier, p.project_name'); $q->addOrder('t.task_name, t.task_start_date, t.task_end_date, ut.perc_assignment'); $tasks = $q->loadList(); $q->clear(); $q->addTable('user_tasks', 'ut'); $q->innerJoin('users', 'u', 'u.user_id = ut.user_id'); $q->innerJoin('tasks', 't', 't.task_id = ut.task_id'); $q->addQuery('min(t.task_start_date) AS task_min_date, max(t.task_end_date) AS task_max_date'); $taskMinMax = $q->loadList(); $q->clear(); $width = dPgetParam($_GET, 'width', 600); $start_date = dPgetParam($_GET, 'start_date', 0); $end_date = dPgetParam($_GET, 'end_date', 0); $showTaskGantt = dPgetParam($_GET, 'showTaskGantt', 0); $graph2 = new GanttGraph($width); $graph2->ShowHeaders(GANTT_HYEAR | GANTT_HMONTH | GANTT_HDAY | GANTT_HWEEK); $graph2->SetFrame(false);
function displayFiles($folder) { global $m, $a, $tab, $AppUI, $xpg_min, $xpg_pagesize; global $deny1, $deny2, $project_id, $task_id, $showProject, $file_types, $cfObj; global $xpg_totalrecs, $xpg_total_pages, $page; global $company_id, $allowed_companies, $current_uri, $dPconfig; $canEdit = !getDenyEdit($m, $folder); $canRead = !getDenyRead($m, $folder); $df = $AppUI->getPref('SHDATEFORMAT'); $tf = $AppUI->getPref('TIMEFORMAT'); // SETUP FOR FILE LIST $q = new DBQuery(); $q->addTable('files'); $q->addQuery('files.*,count(file_version) as file_versions,round(max(file_version), 2) as file_lastversion,file_folder_id, file_folder_name,project_name, project_color_identifier,contact_first_name, contact_last_name,task_name,task_id'); $q->addJoin('projects', 'p', 'p.project_id = file_project'); $q->addJoin('users', 'u', 'u.user_id = file_owner'); $q->addJoin('contacts', 'c', 'c.contact_id = u.user_contact'); $q->addJoin('tasks', 't', 't.task_id = file_task'); $q->addJoin('file_folders', 'ff', 'ff.file_folder_id = file_folder'); $q->addWhere('file_folder = ' . $folder); if (count($deny1) > 0) { $q->addWhere('file_project NOT IN (' . implode(',', $deny1) . ')'); } if (count($deny2) > 0) { $q->addWhere('file_task NOT IN (' . implode(',', $deny2) . ')'); } if ($project_id) { $q->addWhere('file_project = ' . $project_id); } if ($task_id) { $q->addWhere('file_task = ' . $task_id); } if ($company_id) { $q->innerJoin('companies', 'co', 'co.company_id = p.project_company'); $q->addWhere('company_id = ' . $company_id); $q->addWhere('company_id IN (' . $allowed_companies . ')'); } $q->addGroup('file_folder'); $q->addGroup('project_name'); $q->addGroup('file_name'); $q->addOrder('file_folder'); $q->addOrder('project_name'); $q->addOrder('file_name'); $q->setLimit($xpg_pagesize, $xpg_min); $files_sql = $q->prepare(); $q->clear(); $q = new DBQuery(); $q->addTable('files'); $q->addQuery('files.file_id, file_version, file_project, file_name, file_task, file_description, user_username as file_owner, file_size, file_category, file_type, file_date, file_folder_name'); $q->addJoin('projects', 'p', 'p.project_id = file_project'); $q->addJoin('users', 'u', 'u.user_id = file_owner'); $q->addJoin('tasks', 't', 't.task_id = file_task'); $q->addJoin('file_folders', 'ff', 'ff.file_folder_id = file_folder'); $q->addWhere('file_folder = ' . $folder); if ($project_id) { $q->addWhere('file_project = ' . $project_id); } if ($task_id) { $q->addWhere('file_task = ' . $task_id); } if ($company_id) { $q->innerJoin('companies', 'co', 'co.company_id = p.project_company'); $q->addWhere('company_id = ' . $company_id); $q->addWhere('company_id IN (' . $allowed_companies . ')'); } $file_versions_sql = $q->prepare(); $q->clear(); $files = array(); $file_versions = array(); if ($canRead) { $files = db_loadList($files_sql); $file_versions = db_loadList($file_versions_sql); } if ($files === array()) { return 0; } ?> <table width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl"> <tr> <th nowrap="nowrap"><?php echo $AppUI->_('File Name'); ?> </th> <th><?php echo $AppUI->_('Description'); ?> </th> <th><?php echo $AppUI->_('Versions'); ?> </th> <th><?php echo $AppUI->_('Category'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('Task Name'); ?> </th> <th><?php echo $AppUI->_('Owner'); ?> </th> <th><?php echo $AppUI->_('Size'); ?> </th> <th><?php echo $AppUI->_('Type'); ?> </a></th> <th><?php echo $AppUI->_('Date'); ?> </th> <th nowrap="nowrap"><?php echo $AppUI->_('co Reason'); ?> </th> <th><?php echo $AppUI->_('co'); ?> </th> <th nowrap width="1"></th> <th nowrap width="1"></th> </tr> <?php $fp = -1; $file_date = new CDate(); $id = 0; foreach ($files as $row) { $file_date = new CDate($row['file_date']); if ($fp != $row["file_project"]) { if (!$row["project_name"]) { $row["project_name"] = $AppUI->_('All Projects'); $row["project_color_identifier"] = 'f4efe3'; } if ($showProject) { $s = '<tr>'; $s .= '<td colspan="20" style="background-color:#' . $row["project_color_identifier"] . '">'; $s .= '<font color="' . bestColor($row["project_color_identifier"]) . '">'; if ($row['file_project'] > 0) { $href = './index.php?m=projects&a=view&project_id=' . $row['file_project']; } else { $href = './index.php?m=projects'; } $s .= '<a href="' . $href . '">' . $row["project_name"] . '</a>'; $s .= '</font></td></tr>'; echo $s; } } $fp = $row["file_project"]; if ($row['file_versions'] > 1) { $file = last_file($file_versions, $row['file_name'], $row['file_project']); } else { $file = $row; } ?> <form name="frm_remove_file_<?php echo $file['file_id']; ?> " action="?m=files" method="post"> <input type="hidden" name="dosql" value="do_file_aed" /> <input type="hidden" name="del" value="1" /> <input type="hidden" name="file_id" value="<?php echo $file['file_id']; ?> " /> <input type="hidden" name="redirect" value="<?php echo $current_uri; ?> " /> </form> <form name="frm_duplicate_file_<?php echo $file['file_id']; ?> " action="?m=files" method="post"> <input type="hidden" name="dosql" value="do_file_aed" /> <input type="hidden" name="duplicate" value="1" /> <input type="hidden" name="file_id" value="<?php echo $file['file_id']; ?> " /> <input type="hidden" name="redirect" value="<?php echo $current_uri; ?> " /> </form> <tr> <td nowrap="8%"> <?php $file_icon = getIcon($row['file_type']); echo "<a href=\"./fileviewer.php?file_id={$file['file_id']}\" title=\"{$file['file_description']}\"><img border=\"0\" width=\"16\" heigth=\"16\" src=\"" . DP_BASE_URL . "/modules/files/images/{$file_icon}\" /> {$row['file_name']}</a>"; ?> </td> <td width="20%"><?php echo $file['file_description']; ?> </td> <td width="5%" nowrap="nowrap" align="center"> <?php $hidden_table = ''; echo $row['file_lastversion']; if ($row['file_versions'] > 1) { echo ' <a href="#" onClick="expand(\'versions_' . $file['file_id'] . '\'); ">(' . $row['file_versions'] . ')</a>'; $hidden_table = '<tr><td colspan="20"> <table style="display: none" id="versions_' . $file['file_id'] . '" width="100%" border="0" cellpadding="2" cellspacing="1" class="tbl"> <tr> <th nowrap="nowrap">' . $AppUI->_('File Name') . '</th> <th>' . $AppUI->_('Description') . '</th> <th>' . $AppUI->_('Versions') . '</th> <th>' . $AppUI->_('Category') . '</th> <th nowrap="nowrap">' . $AppUI->_('Task Name') . '</th> <th>' . $AppUI->_('Owner') . '</th> <th>' . $AppUI->_('Size') . '</th> <th>' . $AppUI->_('Type') . '</a></th> <th>' . $AppUI->_('Date') . '</th> <th nowrap="nowrap">' . $AppUI->_('co Reason') . '</th> <th>' . $AppUI->_('co') . '</th> <th nowrap width="1"></th> <th nowrap width="1"></th> </tr> '; foreach ($file_versions as $file_row) { if ($file_row['file_name'] == $row['file_name'] && $file_row['file_project'] == $row['file_project']) { $file_icon = getIcon($file_row['file_type']); $file_date = new CDate($file_row['file_date']); $hidden_table .= ' <form name="frm_delete_sub_file_' . $file_row['file_id'] . '" action="?m=files" method="post"> <input type="hidden" name="dosql" value="do_file_aed" /> <input type="hidden" name="del" value="1" /> <input type="hidden" name="file_id" value="' . $file_row['file_id'] . '" /> <input type="hidden" name="redirect" value="' . $current_uri . '" /> </form>'; $hidden_table .= ' <form name="frm_duplicate_sub_file_' . $file_row['file_id'] . '" action="?m=files" method="post"> <input type="hidden" name="dosql" value="do_file_aed" /> <input type="hidden" name="duplicate" value="1" /> <input type="hidden" name="file_id" value="' . $file_row['file_id'] . '" /> <input type="hidden" name="redirect" value="' . $current_uri . '" /> </form>'; $hidden_table .= ' <tr> <td nowrap="8%"><a href="./fileviewer.php?file_id=' . $file_row['file_id'] . '" title="' . $file_row['file_description'] . '">' . "<img border=\"0\" width=\"16\" heigth=\"16\" src=\"" . DP_BASE_URL . "/modules/files/images/{$file_icon}\" /> " . $file_row['file_name'] . ' </a></td> <td width="20%">' . $file_row['file_description'] . '</td> <td width="5%" nowrap="nowrap" align="center">' . $file_row['file_version'] . '</td> <td width="10%" nowrap="nowrap" align="center"><a href="./index.php?m=' . $m . '&a=' . $a . '&tab=' . ($file_row['file_category'] + 1) . '">' . $file_types[$file_row['file_category'] + 1] . '</a></td> <td width="5%" align="center"><a href="./index.php?m=tasks&a=view&task_id=' . $file_row["file_task"] . '">' . $row["task_name"] . '</a></td> <td width="15%" nowrap="nowrap">' . $row["contact_first_name"] . ' ' . $row["contact_last_name"] . '</td> <td width="5%" nowrap="nowrap" align="right">' . intval($file_row['file_size'] / 1024) . 'kb </td> <td width="15%" nowrap="nowrap">' . $file_row['file_type'] . '</td> <td width="15%" nowrap="nowrap" align="right">' . $file_date->format("{$df} {$tf}") . '</td> <td width="10%">' . $row['file_co_reason'] . '</td> <td nowrap="nowrap" align="center">'; if ($canEdit && empty($file_row['file_checkout'])) { $hidden_table .= '<a href="?m=files&a=co&file_id=' . $file_row['file_id'] . '">' . dPshowImage('./modules/files/images/up.png', '16', '16', 'checkout', 'checkout file') . '</a>'; } else { if ($row['file_checkout'] == $AppUI->user_id) { $hidden_table .= '<a href="?m=files&a=addedit&ci=1&file_id=' . $file_row['file_id'] . '">' . dPshowImage('./modules/files/images/down.png', '16', '16', 'checkin', 'checkin file') . '</a>'; } else { if ($file_row['file_checkout'] == 'final') { $hidden_table .= 'final'; } else { $q4 = new DBQuery(); $q4->addQuery("file_id, file_checkout, user_username as co_user, contact_first_name, contact_last_name"); $q4->addTable('files'); $q4->leftJoin('users', 'cu', 'cu.user_id = file_checkout'); $q4->leftJoin('contacts', 'co', 'co.contact_id = cu.user_contact'); $q4->addWhere('file_id = ' . $file_row['file_id']); $co_user = array(); $co_user = $q4->loadList(); $co_user = $co_user[0]; $q4->clear(); $hidden_table .= $co_user['contact_first_name'] . ' ' . $co_user['contact_last_name'] . '<br>(' . $co_user['co_user'] . ')'; } } } $hidden_table .= '</td>'; $hidden_table .= '<td nowrap="nowrap" align="right" width="48">'; if ($canEdit && (empty($file_row['file_checkout']) || $file_row['file_checkout'] == 'final' && ($canEdit || $row['project_owner'] == $AppUI->user_id))) { $hidden_table .= '<a href="./index.php?m=files&a=addedit&file_id=' . $file_row["file_id"] . '">' . dPshowImage('./modules/files/images/kedit.png', '16', '16', 'edit file', 'edit file') . "</a>" . '<a href="#" onclick="document.frm_duplicate_sub_file_' . $file_row['file_id'] . '.submit()">' . dPshowImage('./modules/files/images/duplicate.png', '16', '16', 'duplicate file', 'duplicate file') . "</a>" . '<a href="#" onclick="if (confirm(\'Are you sure you want to delete this file?\')) {document.frm_delete_sub_file_' . $file_row['file_id'] . '.submit()}">' . dPshowImage('./modules/files/images/remove.png', '16', '16', 'delete file', 'delete file') . "</a>"; } $hidden_table .= '</td>'; $hidden_table .= '<td nowrap="nowrap" align="right" width="1">'; if ($canEdit && (empty($row['file_checkout']) || $row['file_checkout'] == 'final' && ($canEdit || $row['project_owner'] == $AppUI->user_id))) { $bulk_op = 'onchange="(this.checked) ? addBulkComponent(' . $file_row['file_id'] . ') : removeBulkComponent(' . $file_row['file_id'] . ')"'; $hidden_table .= '<input type="checkbox" ' . $bulk_op . ' name="chk_sub_sel_file_' . $file_row['file_id'] . '" />'; } $hidden_table .= '</td>'; $hidden_table .= '</tr>'; } } $hidden_table .= '</table>'; //$hidden_table .= '</span>'; } ?> </td> <td width="10%" nowrap="nowrap" align="center"><a href="./index.php?m=<?php echo $m; ?> &a=<?php echo $a; ?> &view=categories&tab=<?php echo $file['file_category']; ?> "><?php echo $file_types[$file["file_category"]]; ?> </a></td> <td width="5%" align="center"><a href="./index.php?m=tasks&a=view&task_id=<?php echo $file["task_id"]; ?> "><?php echo $file["task_name"]; ?> </a></td> <td width="15%" nowrap="nowrap"><?php echo $file["contact_first_name"] . ' ' . $file["contact_last_name"]; ?> </td> <td width="5%" nowrap="nowrap" align="right"><?php echo intval($file["file_size"] / 1024); ?> kb</td> <td width="15%" nowrap="nowrap"><?php echo $file["file_type"]; ?> </td> <td width="15%" nowrap="nowrap" align="right"><?php echo $file_date->format("{$df} {$tf}"); ?> </td> <td width="10%"><?php echo $file['file_co_reason']; ?> </td> <td nowrap="nowrap" align="center"> <?php if ($canEdit && empty($row['file_checkout'])) { ?> <a href="?m=files&a=co&file_id=<?php echo $file['file_id']; ?> "><?php echo dPshowImage('./modules/files/images/up.png', '16', '16', 'checkout', 'checkout file'); ?> </a> <?php } else { if ($row['file_checkout'] == $AppUI->user_id) { ?> <a href="?m=files&a=addedit&ci=1&file_id=<?php echo $file['file_id']; ?> "><?php echo dPshowImage('./modules/files/images/down.png', '16', '16', 'checkin', 'checkin file'); ?> </a> <?php } else { if ($file['file_checkout'] == 'final') { echo 'final'; } else { $q4 = new DBQuery(); $q4->addQuery("file_id, file_checkout, user_username as co_user, contact_first_name, contact_last_name"); $q4->addTable('files'); $q4->leftJoin('users', 'cu', 'cu.user_id = file_checkout'); $q4->leftJoin('contacts', 'co', 'co.contact_id = cu.user_contact'); $q4->addWhere('file_id = ' . $file['file_id']); $co_user = array(); $co_user = $q4->loadList(); $co_user = $co_user[0]; $q4->clear(); echo $co_user['contact_first_name'] . ' ' . $co_user['contact_last_name'] . '<br>(' . $co_user['co_user'] . ')'; } } } ?> </td> <td nowrap="nowrap" align="center" width="48"> <?php if ($canEdit && (empty($file['file_checkout']) || $file['file_checkout'] == 'final' && ($canEdit || $file['project_owner'] == $AppUI->user_id))) { echo '<a href="./index.php?m=files&a=addedit&file_id=' . $file["file_id"] . '">'; echo dPshowImage('./modules/files/images/kedit.png', '16', '16', 'edit file', 'edit file'); echo "</a>"; echo '<a href="#" onclick="document.frm_duplicate_file_' . $file['file_id'] . '.submit()">' . dPshowImage('./modules/files/images/duplicate.png', '16', '16', 'duplicate file', 'duplicate file') . '</a>'; echo '<a href="#" onclick="if (confirm(\'Are you sure you want to delete this file?\')) {document.frm_remove_file_' . $file['file_id'] . '.submit()}">' . dPshowImage('./modules/files/images/remove.png', '16', '16', 'delete file', 'delete file') . '</a>'; } ?> <td nowrap="nowrap" align="center" width="1"> <?php if ($canEdit && (empty($file['file_checkout']) || $file['file_checkout'] == 'final' && ($canEdit || $file['project_owner'] == $AppUI->user_id))) { $bulk_op = 'onchange="(this.checked) ? addBulkComponent(' . $file['file_id'] . ') : removeBulkComponent(' . $file['file_id'] . ')"'; echo '<input type="checkbox" ' . $bulk_op . ' name="chk_sel_file_' . $file['file_id'] . '" />'; } ?> </td> </tr> <?php echo $hidden_table; ?> <?php $hidden_table = ''; } ?> </table> <?php if ($xpg_totalrecs > $xpg_pagesize) { showfnavbar($xpg_totalrecs, $xpg_pagesize, $xpg_total_pages, $page, $folder); } echo "<br />"; }
$q->addWhere('companies.company_id = ' . $company_id); $sql = $q->prepare(); $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;
// This should now work on company ID, but we need to be able to handle both $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;