function getTasksDropDown($selected, $noDefault = false, $mode = 'options') { global $CONF_NEXTIME; $list = nexlistOptionList($mode, '', $CONF_NEXTIME['nexlist_timesheet_tasks'], 1, $selected, '', -1, $noDefault, 'asc'); return $list; }
function prj_displayAllProjects(&$blockPage) { global $_TABLES, $_CONF, $_USER, $subTaskImg, $progress, $priority, $strings, $labels, $_PRJCONF, $_COOKIE; $limitbase = $_COOKIE['allprjmin']; if ($limitbase == '') { $limitbase = 0; } if (isset($_USER['uid'])) { $userid = $_USER['uid']; } else { $userid = 1; } if ($blockPage == NULL or $blockPage == '') { $blockPage = new block(); } $filter = COM_applyFilter($_COOKIE['filter']); $category_string = substr("{$filter}", 0, 3); // Get a list of groups user is a member of and setup to be used in SQL to test user can view project $groups = SEC_getUserGroups($uid); foreach ($groups as $id) { $aGroups[] = $id; } $prjPermGroups = implode(',', $aGroups); if (SEC_inGroup('Root')) { $querycolumns = "SELECT DISTINCT a.pid, a.progress_id, a.status_id, a.priority_id, a.name, "; $querycolumns .= "a.last_updated_date, a.lhs, a.rhs, a.parent_id "; $queryfrom = "FROM {$_TABLES['prj_projects']} a"; $querywhere = " WHERE 1=1 "; } else { $querycolumns = "SELECT DISTINCT a.pid, a.progress_id, a.status_id, a.priority_id, a.name, "; $querycolumns .= "a.last_updated_date, a.lhs, a.rhs, a.parent_id "; $queryfrom = "FROM {$_TABLES['prj_projects']} a, {$_TABLES['prj_projPerms']} b "; $querywhere .= "WHERE b.pid =a.pid"; $querywhere .= " AND b.taskID=0 AND (b.uid={$userid} OR b.gid in ({$prjPermGroups})) "; } switch ($category_string) { case 'cat': $needle = substr("{$filter}", 3, 3); $queryfrom = $queryfrom . ", {$_TABLES['prj_category']} c "; $querywhere = $querywhere . "AND c.pid=a.pid AND c.category_id={$needle} "; $header = nexlistOptionList('view', '', $_PRJCONF['nexlist_category'], 0, $needle); break; case 'loc': $needle = substr("{$filter}", 3, 3); $queryfrom = $queryfrom . ", {$_TABLES['prj_location']} c "; $querywhere = $querywhere . "AND c.pid=a.pid AND c.location_id={$needle} "; $header = nexlistOptionList('view', '', $_PRJCONF['nexlist_locations'], 0, $needle); break; case 'dep': $needle = substr("{$filter}", 3, 3); $queryfrom = $queryfrom . ", {$_TABLES['prj_department']} c "; $querywhere = $querywhere . "AND c.pid=a.pid AND c.department_id={$needle} "; $header = nexlistOptionList('view', '', $_PRJCONF['nexlist_departments'], 0, $needle); break; case 'pri': $needle = substr("{$filter}", 3, 3); $querywhere = $querywhere . " AND a.priority_id={$needle} "; $header = $strings["filter_priority"] . $priority[$needle]; break; case 'pro': $needle = substr("{$filter}", 3, 3); $querywhere = $querywhere . " AND a.progress_id={$needle} "; $header = $strings["filter_progress"] . $progress[$needle]; break; case 'sta': $needle = substr("{$filter}", 3, 3); $querywhere = $querywhere . " AND a.status_id={$needle} "; $header = $strings["filter_status"] . $status[$needle]; break; case 'ctm': if (SEC_inGroup('Root')) { $querycolumns = "SELECT DISTINCT {$_TABLES['prj_projects']}.pid, {$_TABLES['prj_projects']}.progress_id, {$_TABLES['prj_projects']}.status_id, {$_TABLES['prj_projects']}.priority_id, {$_TABLES['prj_projects']}.name, "; $querycolumns .= "{$_TABLES['prj_projects']}.last_updated_date, {$_TABLES['prj_projects']}.lhs, {$_TABLES['prj_projects']}.rhs, {$_TABLES['prj_projects']}.parent_id "; $querywhere = ""; } else { $querycolumns = "SELECT DISTINCT {$_TABLES['prj_projects']}.pid, {$_TABLES['prj_projects']}.progress_id, {$_TABLES['prj_projects']}.status_id, {$_TABLES['prj_projects']}.priority_id, {$_TABLES['prj_projects']}.name, "; $querycolumns .= "{$_TABLES['prj_projects']}.last_updated_date, {$_TABLES['prj_projects']}.lhs, {$_TABLES['prj_projects']}.rhs, {$_TABLES['prj_projects']}.parent_id, {$_TABLES['prj_projPerms']}.viewRead "; $querywhere = "WHERE b.pid =a.pid"; $querywhere .= " AND b.taskID=0 AND (b.uid={$userid} OR b.gid in ({$prjPermGroups})) "; } $needle = substr("{$filter}", 3, 3); $customFilter = prj_constructFilter($needle); $queryfrom = $customFilter['clause']; $header = $strings["filter_custom"] . $customFilter['name']; break; default: $needle = ''; $customFilter = ''; $header = ''; } $block1 = new block(); $block1->form = "allP"; $block1->openForm($_CONF['site_url'] . "/nexproject/projects.php?" . "#" . $block1->form . "Anchor"); if ($header != '') { $headingTitle = $strings["projects"] . " - {$header}"; } else { $headingTitle = "{$strings['projects']} - {$strings['allprojects']} "; $headingTitle .= "(<a href=\"{$_CONF['site_url']}/nexproject/index.php?mode=add\">{$strings['add']}</a>)"; } $headingStatusArea = '<span id="ajaxstatus_myprojects" class="pluginInfo" style="display:none"> </span>'; $block1->heading($headingTitle, $headingStatusArea); $block1->borne = $blockPage->returnBorne("1"); $block1->rowsLimit = $_PRJCONF['project_block_rows']; if ($category_string == 'ctm') { $queryend = " ORDER BY {$_TABLES['prj_projects']}.lhs"; } else { $queryend = " ORDER BY a.lhs"; } $lim = $limitbase * $block1->rowsLimit; $query = $querycolumns . $queryfrom . $querywhere . $queryend; $countRes = DB_query($query); $block1->recordsTotal = DB_numrows($countRes); $query .= " LIMIT {$lim}, {$block1->rowsLimit} "; $result = DB_query($query); echo '<!--startMyProjects-->'; echo '<div id="divMyProjects" style="padding-bottom:0px;">'; $comptListProjects = DB_numrows($result); if ($comptListProjects != "0") { $block1->openResults('false'); $block1->labels($labels = array(0 => $strings["project"], 1 => $strings["priority"], 2 => $strings["lastupdated"], 3 => $strings["owner"]), false, "false"); for ($i = 0; $i < DB_numrows($result); $i++) { list($id, $idProgress, $idStatus, $idPriority, $projectName, $lastupdated, $lhs, $rhs, $parent_id) = DB_fetchArray($result); $pArray = prj_getProjectPermissions($id, $userid); //based on the projectID, fetch the permissions for this user... if ($pArray['monitor'] == '1' || $pArray['teammember'] == '1' || $pArray['full'] == '1') { $fullname = $projectName; $owner_uid = DB_getItem($_TABLES['prj_users'], 'uid', "pid={$id} AND role='o'"); if ($owner_uid >= 2) { $projectOwner = DB_getItem($_TABLES['users'], 'fullname', "uid={$owner_uid}"); if (strlen($projectOwner) > 15) { $projectOwner = substr($projectOwner, 0, 12) . ".."; } } $block1->openRow(); // $block1->checkboxRow($id); $block1->cellProgress($progress[$idProgress]); $indent = ''; //we need to determine if the user has access to the parent that this item is related to. //we do this by determining which project is on its left hand side. $testparent = DB_getItem($_TABLES['prj_projects'], "parent_id", "pid={$id}"); $aGroups = array(); $groups = SEC_getUserGroups($uid); foreach ($groups as $gid) { $aGroups[] = $gid; } $prjPermGroups = implode(',', $aGroups); $testsql = "SELECT a.* "; $testsql .= "FROM {$_TABLES['prj_projPerms']} a "; $testsql .= "WHERE a.pid={$testparent} "; $testsql .= " AND a.taskID=0 AND (a.uid={$_USER['uid']} OR a.gid in ({$prjPermGroups})) "; $testres = DB_query($testsql); $testrows = DB_numRows($testres); if ($testrows > 0 && $testparent > 0) { if ($parent_id != 0) { $level = prj_getProjectLevel($id); for ($z = 1; $z < $level; $z++) { $indent .= ' '; } $indent .= $subTaskImg; } } if (strlen($projectName) > $_PRJCONF['project_name_length']) { $span = "<span title=\"{$projectName}\">"; $projectName = substr($projectName, 0, $_PRJCONF['project_name_length']) . "...."; $projectName = $span . $projectName . "</span>"; } $block1->cellRow($indent . $blockPage->buildLink("{$_CONF['site_url']}/nexproject/viewproject.php?pid={$id}", $projectName, "context", $fullname, $id)); $block1->cellRow($priority[$idPriority]); //$block1->cellProgress($status[$idStatus]); $block1->cellRow(strftime("%Y/%m/%d %H:%M", $lastupdated)); $block1->cellRow($projectOwner); $block1->closeRow(); } } //end for $block1->closeResults(); //$block1->bornesFooter("1", $blockPage->bornesNumber, "", "typeProjects=$typeProjects"); $pages = intval($block1->recordsTotal / $block1->rowsLimit); if (fmod($block1->recordsTotal, $block1->rowsLimit) > 0) { $pages += 1; } if ($pages > 1) { for ($pagecntr = 0; $pagecntr < $pages; $pagecntr++) { echo '<span style="text-decoration:underline;cursor: hand" onclick=\'setCookie("allprjmin","'; echo $pagecntr; echo '","","");prj_getMyProjects("", "", "allprojects")\'>'; if ($limitbase == $pagecntr) { echo '<span style="color:red">'; echo $pagecntr + 1; echo '</span>'; } else { echo $pagecntr + 1; } echo '</span> '; } } } else { $block1->noresults(); } echo '</div>'; echo '<!--endMyProjects-->'; //$block1->closeToggle(); $block1->closeFormResults(); }
function prj_drawProjectGanttBar(&$graph, &$row, &$count, $pid = 0, $nameIndent = '', $sm, $stm) { global $_TABLES, $_CONF, $showTasksForExpandedProjects, $expandedCookie, $userid, $_PRJCONF, $filterCSV, $proj_query_from, $proj_query_where; // Determine the expanded projects $expanded = split(',', $expandedCookie); $sm = ppApplyFilter($sm, true, true); $stm = ppApplyFilter($stm, true, true); $filter = COM_applyFilter($_COOKIE['filter']); $category_string = substr("{$filter}", 0, 3); // Get a list of groups user is a member of and setup to be used in SQL to test user can view project $groups = SEC_getUserGroups($uid); foreach ($groups as $id) { $aGroups[] = $id; } $prjPermGroups = implode(',', $aGroups); if (SEC_inGroup('Root')) { $queryfrom = "FROM {$_TABLES['prj_projects']} a"; $querywhere = " WHERE 1=1 "; } else { $queryfrom = "FROM {$_TABLES['prj_projects']} a, {$_TABLES['prj_projPerms']} b "; $querywhere .= "WHERE b.pid =a.pid"; $querywhere .= " AND b.taskID=0 AND (b.uid={$userid} OR b.gid in ({$prjPermGroups})) "; } switch ($category_string) { case 'cat': $needle = substr("{$filter}", 3, 3); $queryfrom = $queryfrom . ", {$_TABLES['prj_category']} c "; $querywhere = $querywhere . "AND c.pid=a.pid AND c.category_id={$needle} "; $header = nexlistOptionList('view', '', $_PRJCONF['nexlist_category'], 0, $needle); break; case 'loc': $needle = substr("{$filter}", 3, 3); $queryfrom = $queryfrom . ", {$_TABLES['prj_location']} c "; $querywhere = $querywhere . "AND c.pid=a.pid AND c.location_id={$needle} "; $header = nexlistOptionList('view', '', $_PRJCONF['nexlist_locations'], 0, $needle); break; case 'dep': $needle = substr("{$filter}", 3, 3); $queryfrom = $queryfrom . ", {$_TABLES['prj_department']} c "; $querywhere = $querywhere . "AND c.pid=a.pid AND c.department_id={$needle} "; $header = nexlistOptionList('view', '', $_PRJCONF['nexlist_departments'], 0, $needle); break; case 'pri': $needle = substr("{$filter}", 3, 3); $querywhere = $querywhere . " AND a.priority_id={$needle} "; $header = $strings["filter_priority"] . $priority[$needle]; break; case 'pro': $needle = substr("{$filter}", 3, 3); $querywhere = $querywhere . " AND a.progress_id={$needle} "; $header = $strings["filter_progress"] . $progress[$needle]; break; case 'sta': $needle = substr("{$filter}", 3, 3); $querywhere = $querywhere . " AND a.status_id={$needle} "; $header = $strings["filter_status"] . $status[$needle]; break; default: $needle = ''; $customFilter = ''; $header = ''; } $sql = "SELECT a.pid, a.name, a.start_date, a.estimated_end_date, a.parent_id, a.percent_completion as progress, progress_id "; $sql .= $queryfrom; $sql .= $querywhere; if ($pid == 0) { $sql .= "AND parent_id=0 AND a.pid=c.pid "; } else { $sql .= "AND parent_id='{$pid}' "; } if ($filterCSV != '') { $sql .= "AND pid in ({$filterCSV}) "; } $sql .= " ORDER BY lhs ASC"; $result = DB_query($sql, true); $testrows = DB_numRows($result); if ($testrows == 0) { $sql = "SELECT a.pid, a.name, a.start_date, a.estimated_end_date, a.parent_id, a.percent_completion as progress, progress_id "; $sql .= $queryfrom; $sql .= $querywhere; if ($pid == 0) { $sql .= "AND parent_id=0 "; } else { $sql .= "AND parent_id='{$pid}' "; } $sql .= " ORDER BY lhs ASC"; $result = DB_query($sql); } for ($j = 0; $j < DB_numrows($result); $j++) { list($pid, $name, $startdate, $enddate, $parent_task, $progress, $status) = DB_fetchArray($result); $permsArray = prj_getProjectPermissions($pid, $userid); $ownertoken = getProjectToken($pid, $userid, "{$_TABLES['prj_users']}"); if ($sm == '0' && $stm == '1') { //only show team members (my projects) if ($permsArray['teammember'] == '1' || $permsArray['full'] == '1' || $ownertoken == '1') { prj_paintProjectBar(false, $pid, $name, $startdate, $enddate, $parent_task, $progress, $status, $expanded, $userid, $nameIndent, $graph, $count, $row, $sm, $stm); } //end if for perms checking } elseif ($sm == '1' && $stm == '1') { //show everything you have monitor and upwards access to (all projects) if ($permsArray['monitor'] == '1' || $permsArray['teammember'] == '1' || $permsArray['full'] == '1' || $ownertoken == '1') { prj_paintProjectBar(true, $pid, $name, $startdate, $enddate, $parent_task, $progress, $status, $expanded, $userid, $nameIndent, $graph, $count, $row, $sm, $stm); } } //if this project has no child projects AND it has tasks AND the expansion sign is empty if (DB_count($_TABLES['prj_projects'], 'parent_id', $pid) == 0 && DB_count($_TABLES['prj_tasks'], 'pid', $pid) > 0 && $sign == '') { if ($showTasksForExpandedProjects == 'true') { prj_drawProjectTasksGanttBar($graph, $row, $count, $pid, $nameIndent . ' ', 0, 0, $sm, $stm); } } $tempPerms = prj_getProjectPermissions($pid, $userid); if (array_keys($expanded, $pid) != array() && DB_count($_TABLES['prj_projects'], 'parent_id', $pid) > 0 || $tempPerms['monitor'] == '0' && $tempPerms['teammember'] == '0') { if ($showTasksForExpandedProjects == 'true') { prj_drawProjectTasksGanttBar($graph, $row, $count, $pid, $nameIndent . ' ', 0, 0, $sm, $stm); } prj_drawProjectGanttBar($graph, $row, $count, $pid, $nameIndent . ' ', $sm, $stm); $activity = NULL; } } //end for }
} $q2 = DB_query($sql); list($data) = DB_fetchArray($q2); } $sql = "SELECT field_values from {$_TABLES['nxform_fields']} where id={$fieldID} and value_by_function=1"; $typeRes = DB_query($sql); list($fieldValue) = DB_fetchArray($typeRes); if ($fieldValue != '') { //we have an alist or custom function $fieldValue = str_replace('[', '', $fieldValue); $fieldValue = str_replace(']', '', $fieldValue); $funcArray = explode(':', $fieldValue); if (count($funcArray) > 1) { if (strtolower($funcArray[0]) == 'alist') { //fetch the lookup list value $data = nexlistOptionList('read', '', 4, 0, $data); } else { if (function_exists($funcArray[0])) { $data = $funcArray[0]($funcArray[1], $fieldID, $data); } } } } if (is_numeric($data)) { xlsWriteNumber($row, $col, $data); } else { $data = strip_tags($data); $data = str_replace("\r\n", '', $data); xlsWriteLabel($row, $col, $data); } $col++;
$p->set_var('layout_url', $_CONF['layout_url']); $p->set_var('mode', 'create'); $p->set_var('show_owner', 'none'); $p->set_var('show_changelog', 'none'); $p->set_var('LANG_heading', $pluginLangLabels['LANG_add_project']); $p->set_var('priority_options', selectBox2($priority)); $p->set_var('status_options', selectBox2($status)); $p->set_var('progress_options', selectBox2($progress)); $nexfile = prj_nexFileExists(); $forum = prj_forumExists(); $p->set_var('linked_content_disabled', $nexfile ? '' : 'disabled="disabled"'); $p->set_var('discussion_board_disabled', $forum ? '' : 'disabled="disabled"'); $p->set_var('objective_options', nexlistOptionList('options', '', $_PRJCONF['nexlist_objective'])); $p->set_var('location_options', nexlistOptionList('options', '', $_PRJCONF['nexlist_locations'], 0, '', '', -1, true)); $p->set_var('department_options', nexlistOptionList('options', '', $_PRJCONF['nexlist_departments'], 0, '', '', -1, true)); $p->set_var('category_options', nexlistOptionList('options', '', $_PRJCONF['nexlist_category'], 0, '', '', -1, true)); $p->set_var('resource_options', COM_optionList($_TABLES['users'], 'uid,fullname', $selected = '', $sortcol = 1, "uid>1")); $p->set_var('VALUE_notification_enabled_flag', 'CHECKED'); if ($nexfile) { $p->set_var('VALUE_is_using_docmgmt_flag_on', 'CHECKED'); $p->set_var('VALUE_is_using_docmgmt_flag_off', ''); } else { $p->set_var('VALUE_is_using_docmgmt_flag_on', ''); $p->set_var('VALUE_is_using_docmgmt_flag_off', 'CHECKED'); } if ($forum) { $p->set_var('VALUE_is_using_forum_flag_on', 'CHECKED'); $p->set_var('VALUE_is_using_forum_flag_off', ''); } else { $p->set_var('VALUE_is_using_forum_flag_on', ''); $p->set_var('VALUE_is_using_forum_flag_off', 'CHECKED');
} $departments = nexlistOptionList('alist', '', $_PRJCONF['nexlist_departments']); $selectedDepartments = explode(",", $filter['department']); $selDepartment = ''; foreach ($departments as $key => $value) { $selected = in_array($key, $selectedDepartments) === true ? ' selected' : ''; $selDepartment .= "<option value=\"{$key}\"{$selected}>{$value}</option>"; } $categories = nexlistOptionList('alist', '', $_PRJCONF['nexlist_category']); $selectedCategories = explode(",", $filter['category']); $selCategory = ''; foreach ($categories as $key => $value) { $selected = in_array($key, $selectedCategories) === true ? ' selected' : ''; $selCategory .= "<option value=\"{$key}\"{$selected}>{$value}</option>"; } $objectives = nexlistOptionList('alist', '', $_PRJCONF['nexlist_objective']); $selectedObjectives = explode(",", $filter['objective']); $selObjective = ''; foreach ($objectives as $key => $value) { $selected = in_array($key, $selectedObjectives) === true ? ' selected' : ''; $selObjective .= "<option value=\"{$key}\"{$selected}>{$value}</option>"; } // Display filter selection section $sqlFilter = "SELECT flid, name FROM {$_TABLES['prj_filters']} WHERE uid = {$_USER['uid']}"; $result = DB_query($sqlFilter); $numFilters = DB_numrows($result); echo '<table width="100%" border="0" cellpadding="1" cellspacing="1"><tr><td class="heading2" colspan="2" align="left">Select by your Saved Filters</TD></tr><tr>'; if ($numFilters != "0") { echo '<td><form action="' . $PHP_SELF . '" method="post"><select name="selFilter" Style="width:200px">'; while (list($flid, $fname) = DB_fetchARRAY($result)) { echo '<option value="' . $flid . '"';