function getAllowedUsers()
{
    global $HELPDESK_CONFIG;
    //populate user list with all users from permitted companies
    $sql = "SELECT user_id, CONCAT(contact_last_name, ',', contact_first_name)\n\t\t\tFROM users\n\t\t   LEFT JOIN contacts ON user_contact = contact_id\n\t\t\tWHERE " . getCompanyPerms("user_company", PERM_EDIT, $HELPDESK_CONFIG['the_company']) . " OR " . getCompanyPerms("contact_company", PERM_EDIT, $HELPDESK_CONFIG['the_company']) . "ORDER BY contact_last_name, contact_first_name";
    $users = db_loadHashList($sql);
    return $users;
}
Exemple #2
0
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;
}
function getAllowedProjects($list = 0)
{
    global $AppUI, $HELPDESK_CONFIG;
    //if helpdeskUseProjectPerms is true, get a list of Projects based on the users standard project permissions
    if ($HELPDESK_CONFIG['use_project_perms']) {
        require_once $AppUI->getModuleClass('projects');
        $project = new CProject();
        $allowedProjects = $project->getAllowedRecords($AppUI->user_id, 'project_id, project_name', 'project_name');
        //echo "!".implode(" AND ",$rowproject>getAllowedSQL( $AppUI->user_id))."!";
        return $allowedProjects;
    } else {
        //otherwise, get a list of all projects associated with the user's permitted companies.
        //the use case here would be that the person assigning or updating the Helpdesk item may not have access to all Projects.  They might just be traffic control.  This will minimise perm maintenance.
        $sql = "SELECT project_id, project_name FROM projects WHERE project_company in (" . implode(",", array_keys(getAllowedCompanies())) . ") ORDER BY project_name";
        if ($list) {
            return db_loadHashList($sql);
        } else {
            return db_loadList($sql);
        }
    }
}
Exemple #4
0
function getDepartmentArrayList($company_id, $checked_array = array(), $dept_parent = 0, $spaces = 0)
{
    global $AppUI;
    $q = new DBQuery();
    $deptsArray = array();
    $coArray = array();
    $distinctCompanyName = "";
    $q->addTable('departments');
    $q->addQuery('dept_id, dept_name, co.company_name');
    $q->addJoin('companies', 'co', 'departments.dept_company = co.company_id');
    $q->addWhere('dept_parent = ' . $dept_parent);
    $q->addOrder('co.company_name');
    //$q->addWhere('dept_company = ' . $company_id);
    require_once $AppUI->getModuleClass('companies');
    $obj = new CCompany();
    $sql = $q->prepare();
    $depts_list = db_loadHashList($sql, 'dept_id');
    $q->clear();
    foreach ($depts_list as $dept_id => $dept_info) {
        if (mb_strlen($dept_info['dept_name']) > 30) {
            $dept_info['dept_name'] = mb_substr($dept_info['dept_name'], 0, 28) . '...';
        }
        $dept_name = str_repeat(' ', $spaces) . $dept_info['dept_name'];
        $deptsArray[$dept_id] = $dept_name;
        if ($distinctCompanyName != $dept_info['company_name']) {
            $coArray[$dept_id] = $dept_info['company_name'];
            $distinctCompanyName = $dept_info['company_name'];
        }
        $childDeptsNCo = getDepartmentArrayList($company_id, $checked_array, $dept_id, $spaces + 5);
        $childDepts = $childDeptsNCo[0];
        if (!empty($childDepts)) {
            foreach ($childDepts as $childDeptId => $childDeptName) {
                $deptsArray[$childDeptId] = $childDeptName;
            }
        }
    }
    $deptsNCoArray = array();
    array_push($deptsNCoArray, $deptsArray, $coArray);
    return $deptsNCoArray;
}
function get_dependencies_pd($task_id)
{
    // Pull tasks dependencies
    $q = new DBQuery();
    $q->addTable('tasks', 't');
    $q->addTable('task_dependencies', 'td');
    $q->addQuery('t.task_id, t.task_name');
    $q->addWhere("td.dependencies_task_id = {$task_id}");
    $q->addWhere('t.task_id = td.dependencies_req_task_id');
    $sql = $q->prepare();
    $taskDep = db_loadHashList($sql);
}
$sassign = array('' => '(' . $AppUI->_('Assign User') . ')') + $users;
$sunassign = array('' => '(' . $AppUI->_('Unassign User') . ')') + $users;
$obj =& new CTask();
$allowedTasks = $obj->getAllowedSQL($AppUI->user_id, 'tasks.task_id');
$obj->load($task_id);
$task_project = $project_id ? $project_id : ($obj->task_project ? $obj->task_project : 0);
// let's get root tasks
$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();
$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
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');
        ?>
		  &nbsp;<?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">&nbsp;</th>
			<th nowrap="nowrap"width="1">&nbsp;</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 />";
}
Exemple #8
0
$actions['c'] = $AppUI->_('Copy', UI_OUTPUT_JS);
if ($canEdit) {
    $actions['m'] = $AppUI->_('Move', UI_OUTPUT_JS);
    $actions['d'] = $AppUI->_('Delete', UI_OUTPUT_JS);
    $actions['f'] = $AppUI->_('Mark as Finished', UI_OUTPUT_JS);
    foreach ($priorities as $k => $v) {
        $actions[$k] = $AppUI->_('set priority to ' . $v, UI_OUTPUT_JS);
    }
}
$deny = $proj->getDeniedRecords($AppUI->user_id);
$sql = 'SELECT p.project_id, p.project_name FROM projects AS p';
if ($deny) {
    $sql .= ' WHERE p.project_id NOT IN (' . implode(',', $deny) . ')';
}
$sql .= ' ORDER BY p.project_name';
$projects = db_loadHashList($sql, 'project_id');
$p[0] = $AppUI->_('[none]');
foreach ($projects as $proj) {
    $p[$proj[0]] = $proj[1];
}
if ($project_id) {
    $p[$project_id] = $AppUI->_('[same project]');
}
natsort($p);
$projects = $p;
$ts[0] = $AppUI->_('[top task]');
foreach ($tasks as $t) {
    $ts[$t['task_id']] = $t['task_name'];
}
?>
    $sql = "SELECT  u.user_id,\n\t \t\t\t\tu.user_username, \n\t\t\t\t\tcontact_first_name, \n\t\t\t\t\tcontact_last_name\n\t        FROM users AS u\n                LEFT JOIN contacts ON u.user_contact = contact_id";
    $user_list = db_loadHashList($sql, "user_id");
    // Now which tasks will we need and the real allocated hours (estimated time / number of users)
    // Also we will use tasks with duration_type = 1 (hours) and those that are not marked
    // as milstones
    // GJB: Note that we have to special case duration type 24 and this refers to the hours in a day, NOT 24 hours
    $working_hours = $dPconfig['daily_working_hours'];
    $sql = "SELECT t.task_id, round(t.task_duration * IF(t.task_duration_type = 24, " . $working_hours . ", t.task_duration_type)/count(ut.task_id),2) as hours_allocated\n\t        FROM tasks as t, user_tasks as ut\n\t        WHERE t.task_id = ut.task_id\n\t\t\t\t  AND t.task_milestone    ='0'";
    if ($project_id != 0) {
        $sql .= " AND t.task_project='{$project_id}'\n";
    }
    if (!$log_all) {
        $sql .= " AND t.task_start_date >= \"" . $start_date->format(FMT_DATETIME_MYSQL) . "\"\n\t\t          AND t.task_start_date <= \"" . $end_date->format(FMT_DATETIME_MYSQL) . "\"";
    }
    $sql .= "GROUP BY t.task_id";
    $task_list = db_loadHashList($sql, "task_id");
    //echo $sql;
    ?>

<table cellspacing="1" cellpadding="4" border="0" class="tbl">
	<tr>
		<th colspan='2'><?php 
    echo $AppUI->_('User');
    ?>
</th>
		<th><?php 
    echo $AppUI->_('Hours allocated');
    ?>
</th>
		<th><?php 
    echo $AppUI->_('Hours worked');
Exemple #10
0
function checkbox($name, $descr, $default = 0, $show = true)
{
    global $AppUI;
    global ${$name};
    if (!isset(${$name})) {
        ${$name} = $default;
    }
    if ($show) {
        echo '<input type="checkbox" name="' . $name . '" id="' . $name . '" value="1"' . (${$name} ? 'checked="checked"' : '') . ' /><label for="' . $name . '">' . $AppUI->_($descr) . '</label><br />';
    } else {
        echo '<input type="hidden" name="' . $name . '" value="' . (${$name} ? '1' : '') . '" />';
    }
}
// pull projects
$sql = "SELECT project_id, project_name FROM projects ORDER BY project_name";
$projects = arrayMerge(array(0 => '(' . $AppUI->_('All') . ')'), db_loadHashList($sql));
echo $AppUI->_('Project') . ": " . arraySelect($projects, 'project_id', 'class="text"', $project_id) . "<br>";
checkbox("option_check_delayed_tasks", "Check delays for fixed tasks", 1, $do == "conf");
checkbox("option_fix_task_group_date_ranges", "Fix date ranges for task groups according to subtasks dates", 1, $do == "conf");
checkbox("option_no_end_date_warning", "Warn of fixed tasks without end dates", 0, $do == "conf");
checkbox("option_advance_if_possible", "Begin new tasks if dependencies are finished before expected", 1, $do == "conf");
checkbox("option_check_vital_users", "Allow two concurrent tasks when there are no vital users", 1, $do == "conf");
checkbox("option_debug", "Show debug info", 0, $do == "conf");
if ($do == "conf") {
    ?>
	</td>
</tr>
</table>
<br />
<?php 
}
Exemple #11
0
}
if (!$canEdit) {
    $AppUI->redirect("m=public&a=access_denied");
}
if (!@$hditem["item_assigned_to"] && $HELPDESK_CONFIG['default_assigned_to_current_user']) {
    @($hditem["item_assigned_to"] = $AppUI->user_id);
    @($hditem["item_status"] = 1);
}
if (!@$hditem["item_company_id"] && $HELPDESK_CONFIG['default_company_current_company']) {
    @($hditem["item_company_id"] = $AppUI->user_company);
}
$users = getAllowedUsers();
$sql = "SELECT company_id, company_name\n        FROM companies\n        WHERE " . getCompanyPerms("company_id") . "ORDER BY company_name";
$companies = arrayMerge(array(0 => ''), db_loadHashList($sql));
$sql = "\n\tSELECT \n\t\thelpdesk_item_watchers.user_id, \n\t\tCONCAT(contact_last_name, ',', contact_first_name) as name,\n\t\tcontact_email\n\tFROM \n\t\thelpdesk_item_watchers\n\t\tLEFT JOIN users ON helpdesk_item_watchers.user_id = users.user_id\n\t\tLEFT JOIN contacts ON user_contact = contact_id\n        WHERE \n        \titem_id = " . $item_id . "\n        ORDER BY contact_last_name, contact_first_name";
$watchers = db_loadHashList($sql);
// Setup the title block
$ttl = $item_id ? 'Editing Help Desk Item' : 'Adding Help Desk Item';
$titleBlock = new CTitleBlock($ttl, 'helpdesk.png', $m, "{$m}.{$a}");
$titleBlock->addCrumb("?m=helpdesk", 'Home');
$titleBlock->addCrumb("?m=helpdesk&a=list", 'List');
if ($item_id) {
    $titleBlock->addCrumb("?m=helpdesk&a=view&item_id={$item_id}", 'View this item');
}
$titleBlock->show();
if ($item_id) {
    $df = $AppUI->getPref('SHDATEFORMAT');
    $tf = $AppUI->getPref('TIMEFORMAT');
    $item_date = new CDate($hditem["item_created"]);
    $tc = $item_date->format("{$df} {$tf}");
} else {
    $sql = 'SELECT u.user_id, u.user_username, contact_first_name, contact_last_name' . ' FROM users AS u' . ' LEFT JOIN contacts ON u.user_contact = contact_id';
    $user_list = db_loadHashList($sql, 'user_id');
    // Now which tasks will we need and the real allocated hours (estimated time / number of users)
    // Also we will use tasks with duration_type = 1 (hours) and those that are not marked
    // as milstones
    // GJB: Note that we have to special case duration type 24 and this refers to the hours in a day, NOT 24 hours
    $working_hours = $dPconfig['daily_working_hours'];
    $sql = 'SELECT t.task_id, round(t.task_duration * IF(t.task_duration_type = 24, ' . $working_hours . ', t.task_duration_type)/count(ut.task_id),2) as hours_allocated' . ' FROM tasks as t, user_tasks as ut' . " WHERE t.task_id = ut.task_id AND t.task_milestone = '0'";
    if ($project_id != 0) {
        $sql .= " AND t.task_project='{$project_id}'";
    }
    if (!$log_all) {
        $sql .= ' AND t.task_start_date >= "' . $start_date->format(FMT_DATETIME_MYSQL) . '" AND t.task_start_date <= "' . $end_date->format(FMT_DATETIME_MYSQL) . '"';
    }
    $sql .= ' GROUP BY t.task_id';
    $task_list = db_loadHashList($sql, 'task_id');
    //echo $sql;
    ?>

<table cellspacing="1" cellpadding="4" border="0" class="tbl">
	<tr>
		<th colspan='2'><?php 
    echo $AppUI->_('User');
    ?>
</th>
		<th><?php 
    echo $AppUI->_('Hours allocated');
    ?>
</th>
		<th><?php 
    echo $AppUI->_('Hours worked');
Exemple #13
0
        $ok = false;
        break;
}
if (!$ok) {
    echo "Incorrect parameters passed\n";
    if ($debug) {
        echo "<br />callback = {$callback} \n";
        echo "<br />table = {$table} \n";
        echo "<br />ok = {$ok} \n";
    }
} else {
    if (!isset($list)) {
        $sql = "SELECT {$select} FROM {$table}";
        $sql .= $where ? " WHERE {$where}" : '';
        $sql .= $order ? " ORDER BY {$order}" : '';
        $list = arrayMerge(array(0 => ''), db_loadHashList($sql));
    }
    echo db_error();
    ?>
<script language="javascript">
	function setClose(key, val){
		window.opener.<?php 
    echo $callback;
    ?>
(key,val);
		window.close();
	}
	function setHeight(){
		window.opener.<?php 
    echo $callback;
    ?>
Exemple #14
0
function doWatchers($list, $hditem)
{
    global $AppUI;
    # Create the watcher list
    $watcherlist = split(',', $list);
    $sql = "SELECT user_id FROM helpdesk_item_watchers WHERE item_id=" . $hditem->item_id;
    $current_users = db_loadHashList($sql);
    $current_users = array_keys($current_users);
    # Delete the existing watchers as the list might have changed
    $sql = "DELETE FROM helpdesk_item_watchers WHERE item_id=" . $hditem->item_id;
    db_exec($sql);
    if (!$del) {
        if ($list) {
            foreach ($watcherlist as $watcher) {
                $sql = "SELECT user_id, contact_email FROM users LEFT JOIN contacts ON user_contact = contact_id WHERE user_id=" . $watcher;
                $rows = db_loadlist($sql);
                foreach ($rows as $row) {
                    # Send the notification that they've been added to a watch list.
                    if (!in_array($row['user_id'], $current_users)) {
                        notify($row['contact_email'], $hditem);
                    }
                }
                $sql = "INSERT INTO helpdesk_item_watchers VALUES(" . $hditem->item_id . "," . $watcher . ",'Y')";
                db_exec($sql);
            }
        }
    }
}
Exemple #15
0
<?php

/* SYSKEYS $Id$ */
if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
$AppUI->savePlace();
// pull all the key types
$sql = "SELECT syskey_id,syskey_name FROM syskeys ORDER BY syskey_name";
$keys = arrayMerge(array(0 => '- Select Type -'), db_loadHashList($sql));
$sql = "SELECT * FROM syskeys, sysvals WHERE sysval_key_id = syskey_id ORDER BY sysval_title";
$values = db_loadList($sql);
$sysval_id = isset($_GET['sysval_id']) ? $_GET['sysval_id'] : 0;
$titleBlock = new CTitleBlock('System Lookup Values', 'myevo-weather.png', $m, "{$m}.{$u}.{$a}");
$titleBlock->addCrumb("?m=system", "System Admin");
$titleBlock->show();
?>
<script language="javascript">
<?php 
// security improvement:
// some javascript functions may not appear on client side in case of user not having write permissions
// else users would be able to arbitrarily run 'bad' functions
if ($canEdit) {
    ?>
function delIt(id, name) {
	if (confirm('Are you sure you want to delete \'' + name + '\'?')) {
		f = document.sysValFrm;
		f.del.value = 1;
		f.sysval_id.value = id;
		f.submit();
	}
 /**
  *	Returns an array, keyed by the key field, of all elements that meet
  *	the where clause provided. Ordered by $order key.
  */
 function loadAll($order = null, $where = null)
 {
     $this->_query->clear();
     $this->_query->addTable($this->_tbl);
     if ($order) {
         $this->_query->addOrder($order);
     }
     if ($where) {
         $this->_query->addWhere($where);
     }
     $sql = $this->_query->prepare();
     $this->_query->clear();
     return db_loadHashList($sql, $this->_tbl_key);
 }
Exemple #17
0
function getDepartmentSelectionList($company_id, $checked_array = array(), $dept_parent = 0, $spaces = 0)
{
    global $departments_count;
    $q = new DBQuery();
    $parsed = '';
    if ($departments_count < 10) {
        $departments_count++;
    }
    $q->addTable('departments');
    $q->addQuery('dept_id, dept_name');
    $q->addWhere('dept_parent = ' . $dept_parent);
    $q->addWhere('dept_company = ' . $company_id);
    $sql = $q->prepare();
    $depts_list = db_loadHashList($sql, 'dept_id');
    $q->clear();
    foreach ($depts_list as $dept_id => $dept_info) {
        if (mb_strlen($dept_info['dept_name']) > 30) {
            $dept_info['dept_name'] = mb_substr($dept_info['dept_name'], 0, 28) . '...';
        }
        $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;
}
Exemple #18
0
// pull all the key types
$perms =& $AppUI->acl();
// Get the permissions for this module
$canAccess = $perms->checkModule('roles', "access");
if (!$canAccess) {
    $AppUI->redirect("m=public&a=access_denied");
}
$canRead = $perms->checkModule('roles', "view");
$canAdd = $perms->checkModule('roles', "add");
$canEdit = $perms->checkModule('roles', "edit");
$canDelete = $perms->checkModule('roles', "delete");
$crole =& new CRole();
$roles = $crole->getRoles();
$role_id = dPgetParam($_GET, 'role_id', 0);
$modules = $sql = "SELECT mod_id, mod_name FROM modules WHERE mod_active > 0 ORDER BY mod_directory";
$modules = arrayMerge(array('0' => 'All'), db_loadHashList($sql));
// setup the title block
$titleBlock = new CTitleBlock('Roles', 'main-settings.png', $m, "{$m}.{$a}");
$titleBlock->addCrumb("?m=system", "System Admin");
$titleBlock->show();
$crumbs = array();
$crumbs["?m=system"] = "System Admin";
?>

<script language="javascript">
<?php 
// security improvement:
// some javascript functions may not appear on client side in case of user not having write permissions
// else users would be able to arbitrarily run 'bad' functions
if ($canDelete) {
    ?>
Exemple #19
0
<?php

if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
// $Id: ae_resource.php,v 1.5.6.3 2007/09/19 13:45:53 theideaman Exp $
global $AppUI, $users, $task_id, $task_project, $obj, $projTasksWithEndDates, $tab, $loadFromTab;
if ($task_id == 0) {
    // Add task creator to assigned users by default
    $assigned_perc = array($AppUI->user_id => "100");
} else {
    // Pull users on this task
    //			 SELECT u.user_id, CONCAT_WS(' ',u.user_first_name,u.user_last_name)
    $sql = "\n\t\t\t SELECT user_id, perc_assignment\n\t\t\t   FROM user_tasks\n\t\t\t WHERE task_id ={$task_id}\n\t\t\t AND task_id <> 0\n\t\t\t ";
    $assigned_perc = db_loadHashList($sql);
}
$initPercAsignment = "";
$assigned = array();
foreach ($assigned_perc as $user_id => $perc) {
    $assigned[$user_id] = $users[$user_id] . " [" . $perc . "%]";
    $initPercAsignment .= "{$user_id}={$perc};";
}
?>
<script language="javascript">
<?php 
echo "var projTasksWithEndDates=new Array();\n";
$keys = array_keys($projTasksWithEndDates);
for ($i = 1; $i < sizeof($keys); $i++) {
    //array[task_is] = end_date, end_hour, end_minutes
    echo "projTasksWithEndDates[" . $keys[$i] . "]=new Array(\"" . $projTasksWithEndDates[$keys[$i]][1] . "\", \"" . $projTasksWithEndDates[$keys[$i]][2] . "\", \"" . $projTasksWithEndDates[$keys[$i]][3] . "\");\n";
}
 function notify($type, $log_id)
 {
     global $AppUI, $ist, $ict, $isa;
     //    if (!$this->item_notify ||
     //        ($this->item_assigned_to == $AppUI->user_id)) {
     //      return;
     //    }
     // Pull up the email address of everyone on the watch list
     $sql = "SELECT contact_email\n            FROM \n            \thelpdesk_item_watchers\n            \tLEFT JOIN users ON helpdesk_item_watchers.user_id = users.user_id\n\t\tLEFT JOIN contacts ON user_contact = contact_id\n            WHERE \n            \thelpdesk_item_watchers.item_id='{$this->item_id}'";
     //if they choose, along with the person who the ticket is assigned to.
     if ($this->item_notify) {
         $sql .= " or users.user_id='{$this->item_assigned_to}'";
     }
     $email_list = db_loadHashList($sql);
     $email_list = array_keys($email_list);
     //echo $sql."\n";
     //print_r($email_list);
     //if there's no one in the list, skip the rest.
     if (count($email_list) <= 0) {
         return;
     }
     if (is_numeric($log_id)) {
         switch ($type) {
             case STATUS_LOG:
                 $sql = "SELECT status_code, status_comment\n                  FROM helpdesk_item_status\n                  WHERE status_id={$log_id}";
                 break;
             case TASK_LOG:
                 $sql = "SELECT task_log_name,task_log_description\n                  FROM task_log\n                  WHERE task_log_id={$log_id}";
                 break;
         }
         db_loadHash($sql, $log);
     }
     foreach ($email_list as $assigned_to_email) {
         $mail = new Mail();
         if ($mail->ValidEmail($assigned_to_email)) {
             $subject = $AppUI->cfg['page_title'] . " " . $AppUI->_('Help Desk Item') . " #{$this->item_id}";
             switch ($type) {
                 case STATUS_LOG:
                     $body = $AppUI->_('Title') . ": {$this->item_title}\n" . $AppUI->_('Call Type') . ": {$ict[$this->item_calltype]}\n" . $AppUI->_('Status') . ": {$ist[$this->item_status]}\n";
                     if ($log['status_code'] == 0) {
                         $mail->Subject("{$subject} " . $AppUI->_('Created'));
                     } else {
                         $mail->Subject("{$subject} " . $AppUI->_('Updated'));
                         $body .= $AppUI->_('Update') . ": {$isa[$log['status_code']]} {$log['status_comment']}\n";
                     }
                     $body .= $AppUI->_('Link') . ": {$AppUI->cfg['base_url']}/index.php?m=helpdesk&a=view&item_id={$this->item_id}\n" . "\n" . $AppUI->_('Summary') . ":\n" . $this->item_summary;
                     break;
                 case TASK_LOG:
                     $mail->Subject("{$subject} " . $AppUI->_('Task Log') . " " . $AppUI->_('Update'));
                     $body = $AppUI->_('Summary') . ": " . $log['task_log_name'] . "\n" . $AppUI->_('Link') . ": {$AppUI->cfg['base_url']}/index.php?m=helpdesk&a=view&item_id={$this->item_id}\n" . "\n" . $AppUI->_('Comments') . ":\n" . $log['task_log_description'];
                     break;
             }
             $body .= "\n\n-- \n" . $AppUI->_('helpdeskSignature');
             if ($mail->ValidEmail($AppUI->user_email)) {
                 $email = $AppUI->user_email;
             } else {
                 $email = "dotproject@" . $AppUI->cfg['site_domain'];
             }
             $mail->From("\"{$AppUI->user_first_name} {$AppUI->user_last_name}\" <{$email}>");
             $mail->To($assigned_to_email);
             $mail->Body($body, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : "");
             $mail->Send();
         }
     }
 }
Exemple #21
0
<?php

if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
// $Id: ae_resource.php 5588 2007-12-20 11:06:21Z ajdonnison $
global $AppUI, $users, $task_id, $task_project, $obj, $projTasksWithEndDates, $tab, $loadFromTab;
// Make sure that we can see users that are allocated to the task.
if ($task_id == 0) {
    // Add task creator to assigned users by default
    $assigned_perc = array($AppUI->user_id => array('contact_name' => $users[$AppUI->user_id], 'perc_assignment' => '100'));
} else {
    // Pull users on this task
    //			 SELECT u.user_id, CONCAT_WS(' ',u.user_first_name,u.user_last_name)
    $sql = "\n\t\t\t SELECT user_tasks.user_id, perc_assignment, concat_ws(', ', contact_last_name, contact_first_name) as contact_name\n\t\t\t   FROM user_tasks\n\t\t\t LEFT JOIN users USING (user_id)\n\t\t\t LEFT JOIN contacts ON contacts.contact_id = users.user_contact\n\t\t\t WHERE task_id ={$task_id}\n\t\t\t AND task_id <> 0\n\t\t\t ";
    $assigned_perc = db_loadHashList($sql, 'user_id');
}
$initPercAsignment = "";
$assigned = array();
foreach ($assigned_perc as $user_id => $data) {
    $assigned[$user_id] = $data['contact_name'] . " [" . $data['perc_assignment'] . "%]";
    $initPercAsignment .= "{$user_id}={$data['perc_assignment']};";
}
?>
<script language="javascript">
<?php 
echo "var projTasksWithEndDates=new Array();\n";
$keys = array_keys($projTasksWithEndDates);
for ($i = 1, $xi = sizeof($keys); $i < $xi; $i++) {
    //array[task_is] = end_date, end_hour, end_minutes
    echo "projTasksWithEndDates[" . $keys[$i] . "]=new Array(\"" . $projTasksWithEndDates[$keys[$i]][1] . "\", \"" . $projTasksWithEndDates[$keys[$i]][2] . "\", \"" . $projTasksWithEndDates[$keys[$i]][3] . "\");\n";
Exemple #22
0
function getDepartmentSelectionList($company_id, $checked_array = array(), $dept_parent = 0, $spaces = 0)
{
    global $departments_count;
    $parsed = '';
    if ($departments_count < 10) {
        $departments_count++;
    }
    $sql = "select dept_id, dept_name\n\t        from departments\n\t        where dept_parent      = '{$dept_parent}'\n\t              and dept_company = '{$company_id}'";
    $depts_list = db_loadHashList($sql, "dept_id");
    foreach ($depts_list as $dept_id => $dept_info) {
        $selected = in_array($dept_id, $checked_array) ? "selected" : "";
        if (strlen($dept_info["dept_name"]) > 30) {
            $dept_info["dept_name"] = substr($dept_info["dept_name"], 0, 28) . "...";
        }
        $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;
}
 function getChildren($id)
 {
     $this->_query->clear();
     $this->_query->addTable('config_list');
     $this->_query->addOrder('config_list_id');
     $this->_query->addWhere('config_id = ' . $id);
     $sql = $this->_query->prepare();
     $this->_query->clear();
     return db_loadHashList($sql, 'config_list_id');
 }
Exemple #24
0
function showcompany($company, $restricted = false)
{
    global $AppUI, $allpdfdata, $log_start_date, $log_end_date, $log_all;
    /* $sql="
            SELECT
                    billingcode_id,
                    billingcode_name,
                    billingcode_value
            FROM billingcode
            WHERE company_id=$company
            ORDER BY billingcode_name ASC
            ";
    
            $company_billingcodes=NULL;
            $ptrc=db_exec($sql);
            $nums=db_num_rows($ptrc);
            echo db_error();
    
            for ($x=0; $x < $nums; $x++) {
                    $row=db_fetch_assoc($ptrc);
                    $company_billingcodes[$row['billingcode_id']]=$row['billingcode_name'];
            }
    */
    $sql = "SELECT project_id, project_name\n\t\tFROM projects\n\t\tWHERE project_company = {$company}";
    $projects = db_loadHashList($sql);
    $sql = "SELECT company_name\n\t\tFROM companies\n\t\tWHERE company_id = {$company}";
    $company_name = db_loadResult($sql);
    $table = '<h2>Company: ' . $company_name . '</h2>
        <table cellspacing="1" cellpadding="4" border="0" class="tbl">';
    $project_row = '
        <tr>
                <th>' . $AppUI->_('Project') . '</th>';
    $pdfth[] = $AppUI->_('Project');
    /*		if (isset($company_billingcodes))
    	                foreach ($company_billingcodes as $code)
    			{
            	                $project_row .= '<th>' . $code . ' ' . $AppUI->_('Hours') . '</th>';
    				$pdfth[] = $code;
    			}
      */
    $project_row .= '<th>' . $AppUI->_('Total') . '</th></tr>';
    $pdfth[] = $AppUI->_('Total');
    $pdfdata[] = $pdfth;
    $hours = 0.0;
    $table .= $project_row;
    foreach ($projects as $project => $name) {
        $pdfproject = array();
        $pdfproject[] = $name;
        $project_hours = 0;
        $project_row = "<tr><td>{$name}</td>";
        $sql = "SELECT task_log_costcode, sum(task_log_hours) as hours\n\t\t\tFROM projects, tasks, task_log\n\t\t\tWHERE project_id = {$project}";
        if ($log_start_date != 0 && !$log_all) {
            $sql .= " AND task_log_date >= {$log_start_date}";
        }
        if ($log_end_date != 0 && !$log_all) {
            $sql .= " AND task_log_date <= {$log_end_date}";
        }
        if ($restricted) {
            $sql .= " AND task_log_creator = '" . $AppUI->user_id . "'";
        }
        $sql .= " AND project_id = task_project\n\t\t\tAND task_id = task_log_task\n\t\t\tGROUP BY project_id";
        //task_log_costcode";
        $task_logs = db_loadHashList($sql);
        /*		if (isset($company_billingcodes))
        		foreach($company_billingcodes as $code => $name)
        		{
        			if (isset($task_logs[$code]))
        			{
        				$value = sprintf( "%.2f", $task_logs[$code] );
        				$project_row .= '<td>' . $value . '</td>';
        				$project_hours += $task_logs[$code];
        				$pdfproject[] = $value;
        			}
        			else
        			{
        				$project_row .= '<td>&nbsp;</td>';
        				$pdfproject[] = 0;
        			}
        		}
        */
        foreach ($task_logs as $task_log) {
            $project_hours += $task_log;
        }
        $project_row .= '<td>' . round($project_hours, 2) . '</td></tr>';
        $pdfproject[] = round($project_hours, 2);
        $hours += $project_hours;
        if ($project_hours > 0) {
            $table .= $project_row;
            $pdfdata[] = $pdfproject;
        }
    }
    if ($hours > 0) {
        $allpdfdata[$company_name] = $pdfdata;
        echo $table;
        echo '<tr><td>Total</td><td>' . round($hours, 2) . '</td></tr></table>';
    }
    return $hours;
}
Exemple #25
0
    if (stristr($AppUI->getPref('TIMEFORMAT'), "%p")) {
        //User time format in 12hr
        $hours[$current_key] = $current > 12 ? $current - 12 : $current;
    } else {
        //User time format in 24hr
        $hours[$current_key] = $current;
    }
}
// Pull tasks dependencies
$deps = false;
if ($deps) {
    $sql = "SELECT task_id, task_name FROM tasks WHERE task_id in ({$deps})";
} else {
    $sql = "\n\t\tSELECT t.task_id, t.task_name\n\t\tFROM tasks t, task_dependencies td\n\t\tWHERE td.dependencies_task_id = {$task_id}\n\t\tAND t.task_id = td.dependencies_req_task_id\n\t";
}
$taskDep = db_loadHashList($sql);
?>
<form name="dependFrm" action="?m=tasks&a=addedit&task_project=<?php 
echo $task_project;
?>
" method="post">
<input name="dosql" type="hidden" value="do_task_aed" />
<input name="task_id" type="hidden" value="<?php 
echo $task_id;
?>
" />
<input name="sub_form" type="hidden" value="1" />
<table width="100%" border="0" cellpadding="4" cellspacing="0" class="std">
			<?php 
if ($can_edit_time_information) {
    ?>
    $actions['m'] = $AppUI->_('Move', UI_OUTPUT_JS);
    $actions['d'] = $AppUI->_('Delete', UI_OUTPUT_JS);
    $actions['f'] = $AppUI->_('Mark as Finished', UI_OUTPUT_JS);
    foreach ($priorities as $k => $v) {
        $actions[$k] = $AppUI->_('set priority to ' . $v, UI_OUTPUT_JS);
    }
}
$deny = $proj->getDeniedRecords($AppUI->user_id);
$q = new DBQuery();
$q->addTable('projects', 'p');
$q->addQuery('p.project_id, p.project_name');
if ($deny) {
    $q->addWhere('p.project_id NOT IN (' . implode(',', $deny) . ')');
}
$q->addOrder('p.project_name');
$projects = db_loadHashList($q->prepare(true), 'project_id');
$p[0] = $AppUI->_('[none]');
foreach ($projects as $proj) {
    $p[$proj[0]] = $proj[1];
}
if ($project_id) {
    $p[$project_id] = $AppUI->_('[same project]');
}
natsort($p);
$projects = $p;
$ts[0] = $AppUI->_('[top task]');
foreach ($tasks as $t) {
    $ts[$t['task_id']] = $t['task_name'];
}
?>
 /**
  *	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);
 }
        $start_data_linkable[$i] = urlencode($start_day->getDate());
        //		$starts[$i] =  $start_day->format($df);
        $sql = "\n\t\t\tSELECT\n\t\t\t\ttask_log_creator,\n\t\t\t\tsum(task_log_hours) as hours\n\t\t\tFROM\n\t\t\t\ttask_log\n\t\t\tWHERE\n\t\t\t\ttask_log_date >= '" . $start_day->format(FMT_DATETIME_MYSQL) . "' \n\t\t\t\tAND task_log_date <= '" . $end_day->format(FMT_DATETIME_MYSQL) . "'\n\t\t\t\tAND task_log_creator in (" . implode(", ", $ids) . ")\n\t\t\tGROUP BY\n\t\t\t\ttask_log_creator\n\t\t\t";
        //print "<pre>$sql</pre>";
        $result = db_loadList($sql);
        foreach ($result as $row) {
            $people[$row['task_log_creator']][$i] = $row['hours'];
        }
        $date = $start_day->format("%Y-%m-%d") . " 12:00:00";
        $start_day->setDate($date, DATE_FORMAT_ISO);
        $start_day->addDays(-7);
    }
}
$sql = "SELECT company_id, company_name FROM companies WHERE " . getPermsWhereClause("companies", "company_id") . " ORDER BY company_name";
//print "<pre>$sql</pre>";
$companies = arrayMerge(array(0 => $AppUI->_('All Entities')), db_loadHashList($sql));
$next_day = new CDate();
$next_day->copy($start_day);
$next_day->addDays($week_count * 7 * 2);
?>
<form name="frmCompanySelect" action="" method="get">
	<input type="hidden" name="m" value="timecard">
	<input type="hidden" name="report_type" value="weekly_by_user">
	<input type="hidden" name="tab" value="<?php 
echo $tab;
?>
">
	<table cellspacing="1" cellpadding="2" border="0" width="100%">
	<tr>
		<td width="95%"><?php 
echo arraySelect($companies, 'company_id', 'size="1" class="text" id="medium" onchange="document.frmCompanySelect.submit()"', $company_id);
Exemple #29
0
    if (!$_REQUEST['project_id']) {
        $selectors[] = "<td align=\"right\" nowrap><label for=\"assigned_to\">" . $AppUI->_('Assigned To') . ":</label></td><td>" . arraySelect(arrayMerge(array('-1' => $AppUI->_('All')), $assigned_to_list), 'assigned_to', 'size="1" id="assigned_to" class="text" onchange="changeList()"', $assigned_to) . "</td>";
    }
}
// check for requestor filter
if ($HELPDESK_CONFIG['search_criteria_requestor']) {
    if (isset($_GET['requestor'])) {
        $AppUI->setState('HelpDeskRequestor', $_GET['requestor']);
    }
    $requestor = $AppUI->getState('HelpDeskRequestor') !== null ? $AppUI->getState('HelpDeskRequestor') : -1;
    if (isset($requestor) && strlen($requestor) > 0 && $requestor != '-1') {
        $tarr[] = "hi.item_requestor='{$requestor}'";
    }
    // retrieve requestor list
    $sql = "SELECT distinct(item_requestor) as requestor, item_requestor\n\t\t      FROM helpdesk_items\n\t\t      WHERE " . getCompanyPerms("item_company_id", NULL, PERM_READ) . "\n\t\t      ORDER BY item_requestor";
    $requestor_list = db_loadHashList($sql);
    if (!$_REQUEST['project_id']) {
        $selectors[] = "<td align=\"right\"><label for=\"requestor\">" . $AppUI->_('Requestor') . ":</label></td><td>" . arraySelect(arrayMerge(array('-1' => $AppUI->_('All')), $requestor_list), 'requestor', 'size="1" id="requestor" class="text" onchange="changeList()"', $requestor) . "</td>";
    }
}
$where = getItemPerms();
if (count($tarr)) {
    $where .= 'AND (' . implode("\n AND ", $tarr) . ') ';
}
$sql = "SELECT hi.*,\n        CONCAT(co.contact_first_name,' ',co.contact_last_name) assigned_fullname,\n        co.contact_email as assigned_email,\n        p.project_id,\n        p.project_name,\n        p.project_color_identifier\n        FROM helpdesk_items hi\n        LEFT JOIN users u2 ON u2.user_id = hi.item_assigned_to\n        LEFT JOIN contacts co ON u2.user_contact = co.contact_id\n        LEFT JOIN projects p ON p.project_id = hi.item_project_id\n        WHERE {$where}\n        ORDER BY ";
// Do custom order by if needed, default at the end
if ($orderby == "project_name") {
    $sql .= "p.project_name";
} elseif ($orderby == "item_assigned_to") {
    $sql .= "assigned_fullname";
} elseif ($orderby == "item_updated") {
Exemple #30
0
/* SYSTEM $Id: addeditpref.php,v 1.43.4.5 2007/09/19 13:45:53 theideaman Exp $ */
if (!defined('DP_BASE_DIR')) {
    die('You should not access this file directly.');
}
##
## add or edit a user preferences
##
$user_id = dPgetParam($_GET, 'user_id', '0');
// Check permissions
if (!$canEdit && $user_id != $AppUI->user_id) {
    $AppUI->redirect("m=public&a=access_denied");
}
// load the preferences
$sql = "\nSELECT pref_name, pref_value\nFROM user_preferences\nWHERE pref_user = {$user_id}\n";
$prefs = db_loadHashList($sql);
// get the user name
if ($user_id) {
    $user = dPgetUsernameFromID($user_id);
} else {
    $user = "******";
}
$titleBlock = new CTitleBlock('Edit User Preferences', 'myevo-weather.png', $m, "{$m}.{$a}");
$perms =& $AppUI->acl();
if ($perms->checkModule('system', 'edit')) {
    $titleBlock->addCrumb("?m=system", "system admin");
    $titleBlock->addCrumb("?m=system&a=systemconfig", "system configuration");
}
$titleBlock->show();
?>
<script language="javascript">