/**
* Sub-function to collect events within a period
* @param Date the starting date of the period
* @param Date the ending date of the period
* @param array by-ref an array of links to append new items to
* @param int the length to truncate entries by
* @author Andrew Eddie <*****@*****.**>
*/
function getEventLinks($startPeriod, $endPeriod, &$links, $strMaxLen)
{
    global $AppUI, $event_filter;
    $events = CEvent::getEventsForPeriod($startPeriod, $endPeriod, $event_filter);
    // assemble the links for the events
    foreach ($events as $row) {
        $start = new CDate($row['event_start_date']);
        $end = new CDate($row['event_end_date']);
        $date = $start;
        $date->setTime(0, 0, 0);
        $cwd = explode(',', $GLOBALS['dPconfig']['cal_working_days']);
        for ($i = 0, $x = $end->dateDiff($start); $i <= $x; $i++) {
            // the link
            // optionally do not show events on non-working days
            if ($row['event_cwd'] && in_array($date->getDayOfWeek(), $cwd) || !$row['event_cwd']) {
                $link['href'] = '?m=calendar&a=view&event_id=' . $row['event_id'];
                $link['alt'] = $row['event_description'];
                $link['text'] = dPshowImage(dPfindImage('event' . $row['event_type'] . '.png', 'calendar'), 16, 16) . htmlspecialchars($row['event_title']);
                if ($i == 0) {
                    $link['alt'] .= ' [' . $AppUI->_('START') . ']';
                }
                if ($i == $x) {
                    $link['alt'] .= ' [' . $AppUI->_('END') . ']';
                }
                $links[$date->format(FMT_TIMESTAMP_DATE)][] = $link;
            }
            $date = $date->getNextDay();
        }
    }
}
 function fetchResults(&$permissions)
 {
     global $AppUI;
     if (!$permissions->checkModule('files', 'view')) {
         return "<tr>" . "<td>" . $AppUI->_('Empty') . "</td>" . "</tr>";
     }
     $sql = $this->_buildQuery();
     $results = db_loadList($sql);
     $outstring = "<tr><th nowrap='nowrap' STYLE='background: #08245b' >" . $AppUI->_('Files Content') . "</th></tr>\n";
     if ($results) {
         foreach ($results as $records) {
             $outstring .= "<tr>";
             $outstring .= "<td>";
             if ($permissions->checkModuleItem('files', "edit", $records["file_id"])) {
                 $outstring .= "<a href = \"index.php?m=files&a=addedit&file_id=" . $records["file_id"] . "\">" . dPshowImage('./images/icons/stock_edit-16.png', '16', '16') . '</a>';
             }
             $outstring .= '<a href="' . $this->follow_up_link . $records['file_id'] . '">' . $records["file_name"] . ' v.' . $records['file_version'] . "</a> (word {$records['word_placement']})" . ' &nbsp -- &nbsp ' . $records["file_description"];
             $outstring .= "</td>\n";
             $outstring .= "</tr>";
         }
     } else {
         $outstring .= "<tr>" . "<td>" . $AppUI->_('Empty') . "</td>" . "</tr>";
     }
     return $outstring;
 }
Exemple #3
0
function showRow($id = 0, $key = 0, $title = '', $value = '')
{
    global $canEdit, $sysval_id, $CR, $AppUI, $keys;
    $s = '<tr>' . $CR;
    if ($sysval_id == $id && $canEdit) {
        // edit form
        $s .= '<form name="sysValFrm" method="post" action="?m=system&u=syskeys&a=do_sysval_aed">' . $CR;
        $s .= '<input type="hidden" name="del" value="0" />' . $CR;
        $s .= '<input type="hidden" name="sysval_id" value="' . $id . '" />' . $CR;
        $s .= '<td>&nbsp;</td>';
        $s .= '<td valign="top">' . arraySelect($keys, 'sysval_key_id', 'size="1" class="text"', $key) . '</td>';
        $s .= '<td valign="top"><input type="text" name="sysval_title" value="' . dPformSafe($title) . '" class="text" /></td>';
        $s .= '<td valign="top"><textarea name="sysval_value" class="small" rows="5" cols="40">' . $value . '</textarea></td>';
        $s .= '<td><input type="submit" value="' . $AppUI->_($id ? 'edit' : 'add') . '" class="button" /></td>';
        $s .= '<td>&nbsp;</td>';
    } else {
        $s .= '<td width="12" valign="top">';
        if ($canEdit) {
            $s .= '<a href="?m=system&u=syskeys&sysval_id=' . $id . '" title="' . $AppUI->_('edit') . '">' . dPshowImage('./images/icons/stock_edit-16.png', 16, 16, '') . '</a>';
            $s .= '</td>' . $CR;
        }
        $s .= '<td valign="top">' . $keys[$key] . '</td>' . $CR;
        $s .= '<td valign="top">' . dPformSafe($title) . '</td>' . $CR;
        $s .= '<td valign="top" colspan="2">' . nl2br(dPformSafe($value)) . '</td>' . $CR;
        $s .= '<td valign="top" width="16">';
        if ($canEdit) {
            $s .= '<a href="javascript:delIt(' . $id . ', \'' . addslashes(htmlentities($title)) . '\')" title="' . $AppUI->_('delete') . '">' . dPshowImage('./images/icons/stock_delete-16.png', 16, 16, '') . '</a>';
        }
        $s .= '</td>' . $CR;
    }
    $s .= '</tr>' . $CR;
    return $s;
}
Exemple #4
0
function showchilddept_comp(&$a, $level = 0)
{
    global $AppUI;
    $s = '<td><a href="./index.php?m=departments&amp;a=addedit&amp;dept_id=' . $a['dept_id'] . '" title="' . $AppUI->_('edit') . '">' . dPshowImage('./images/icons/stock_edit-16.png', 16, 16, '') . '</td><td>';
    for ($y = 0; $y < $level; $y++) {
        $s .= dPshowImage('./images/' . ($y + 1 == $level ? 'corner-dots.gif' : 'shim.gif'), 16, 12, '');
    }
    $s .= '<a href="./index.php?m=departments&a=view&dept_id=' . $a['dept_id'] . '">' . $a['dept_name'] . '</a>';
    $s .= '</td>';
    $s .= '<td align="center">' . ($a['dept_users'] ? $a['dept_users'] : '') . '</td>';
    echo '<tr>' . $s . '</tr>';
}
Exemple #5
0
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">';
        }
    }
    $s .= '<a href="index.php?m=departments&a=view&dept_id=' . $a['dept_id'] . '">' . $a['dept_name'] . '</a>';
    $s .= '</td>';
    $s .= '<td align="center">' . ($a['dept_users'] ? $a['dept_users'] : '') . '</td>';
    echo '<tr class="second">' . $s . '</tr>';
}
function showchilddept(&$a, $level = 0)
{
    global $AppUI;
    $s = '';
    $s .= '<td>';
    $s .= '<a href="./index.php?m=departments&a=addedit&dept_id=' . $a["dept_id"] . '" title="' . $AppUI->_('edit') . '">';
    $s .= dPshowImage('./images/icons/stock_edit-16.png', 16, 16, '');
    $s .= '</td>';
    $s .= '<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">';
        }
    }
    $s .= '<a href="./index.php?m=departments&a=view&dept_id=' . $a["dept_id"] . '">' . $a["dept_name"] . '</a>';
    $s .= '</td>';
    $s .= '<td align="center">' . ($a["dept_users"] ? $a["dept_users"] : '') . '</td>';
    echo "<tr>{$s}</tr>";
}
Exemple #7
0
/**
* Sub-function to collect events within a period
* @param Date the starting date of the period
* @param Date the ending date of the period
* @param array by-ref an array of links to append new items to
* @param int the length to truncate entries by
* @author Andrew Eddie <*****@*****.**>
*/
function getEventLinks($startPeriod, $endPeriod, &$links, $strMaxLen)
{
    global $event_filter;
    $events = CEvent::getEventsForPeriod($startPeriod, $endPeriod, $event_filter);
    // assemble the links for the events
    foreach ($events as $row) {
        $start = new CDate($row['event_start_date']);
        $end = new CDate($row['event_end_date']);
        $date = $start;
        $cwd = explode(",", $GLOBALS["dPconfig"]['cal_working_days']);
        for ($i = 0; $i <= $start->dateDiff($end); $i++) {
            // the link
            // optionally do not show events on non-working days
            if ($row['event_cwd'] && in_array($date->getDayOfWeek(), $cwd) || !$row['event_cwd']) {
                $url = '?m=calendar&a=view&event_id=' . $row['event_id'];
                $link['href'] = '';
                $link['alt'] = $row['event_description'];
                $link['text'] = '<table cellspacing="0" cellpadding="0" border="0"><tr>' . '<td><a href=' . $url . '>' . dPshowImage(dPfindImage('event' . $row['event_type'] . '.png', 'calendar'), 16, 16, '') . '</a></td>' . '<td><a href="' . $url . '" title="' . $row['event_description'] . '"><span class="event">' . $row['event_title'] . '</span></a>' . '</td></tr></table>';
                $links[$date->format(FMT_TIMESTAMP_DATE)][] = $link;
            }
            $date = $date->getNextDay();
        }
    }
}
Exemple #8
0
        ?>
		<a href="?m=forums&a=addedit&forum_id=<?php 
        echo $row["forum_id"];
        ?>
" title="<?php 
        echo $AppUI->_('edit');
        ?>
">
		<?php 
        echo dPshowImage('./images/icons/stock_edit-16.png', 16, 16, '');
        ?>
		</a>
	<?php 
    }
    if ($row['visit_count'] != $row['message_count']) {
        echo "&nbsp;" . dPshowImage('./images/icons/stock_new_small.png', false, false, "You have unread messages in this forum");
    }
    ?>
	</td>

	<td nowrap="nowrap" align="center">
		<input type="checkbox" name="forum_<?php 
    echo $row['forum_id'];
    ?>
" <?php 
    echo $row['watch_user'] ? 'checked="checked"' : '';
    ?>
 />
	</td>

	<td>
		<td width="10%" nowrap="nowrap" align="center">
			<?php 
                echo $file_types[$file['file_category']];
                ?>
		</td>
		<td width="10%" nowrap="nowrap" align="center">
			<?php 
                if ($file['file_folder_name'] != '') {
                    $file_folder_url = DP_BASE_URL . '/index.php?m=files&amp;tab=' . (count($file_types) + 1) . '&amp;folder=' . $file['file_folder_id'];
                    ?>
			<a href="<?php 
                    echo $file_folder_url;
                    ?>
">
			<?php 
                    echo dPshowImage(DP_BASE_URL . '/modules/files/images/folder5_small.png', '16', '16', 'folder icon', 'show only this folder');
                    ?>
 
			<?php 
                    echo $file['file_folder_name'];
                    ?>
			</a><?php 
                } else {
                    echo $AppUI->_('Root');
                }
                ?>
		</td>
		<td width="5%" align="center">
			<a href="./index.php?m=tasks&amp;a=view&amp;task_id=<?php 
                echo $file['file_task'];
                ?>
Exemple #10
0
 /**
  * CMonthCalendar::_drawWeek()
  *
  * { Description }
  *
  */
 function _drawWeek($dateObj)
 {
     global $AppUI;
     $w = "\t\t" . '<td class="week">';
     if ($this->dayFunc) {
         $w .= '<a href="javascript:' . $this->weekFunc . "(" . $dateObj->getTimestamp() . ",'" . $dateObj->toString() . "')" . '">';
     }
     $w .= dPshowImage(dPfindImage('view.week.gif'), 16, 15, $AppUI->_('Week View'));
     $w .= $this->dayFunc ? '</a>' : '';
     $w .= "</td>\n";
     return $w;
 }
</tr>

<tr>
	<td>&nbsp;</td>
	<td align="left">
		<a href="?m=system&a=viewmods"><?php 
echo $AppUI->_('View Modules');
?>
</a>
	</td>
</tr>

<tr>
	<td>
		<?php 
echo dPshowImage(dPfindImage('main-settings.png', $m), 42, 42, '');
?>
	</td>
	<td align="left" class="subtitle">
		<?php 
echo $AppUI->_('Administration');
?>
	</td>
</tr>

<tr>
	<td>&nbsp;</td>
	<td align="left">
		<a href="?m=system&u=roles"><?php 
echo $AppUI->_('User Roles');
?>
Exemple #12
0
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}\" />&nbsp;{$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}\" />&nbsp;" . $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 />";
}
Exemple #13
0
        if (empty($user_display)) {
            $user_display = $row['user_username'];
        }
        ?>
				<a href="javascript:delMe(<?php 
        echo $row["user_id"];
        ?>
, '<?php 
        echo $user_display;
        ?>
')" title="<?php 
        echo $AppUI->_('delete');
        ?>
">
					<?php 
        echo dPshowImage('./images/icons/stock_delete-16.png', 16, 16, '');
        ?>
				</a>
			</td>
		</tr>
		</table>
<?php 
    }
    ?>
	</td>
	<?php 
    if (dPgetParam($_REQUEST, "tab", 0) == 0) {
        ?>
	<td>
	       <?php 
        $q = new DBQuery();
        $s .= $CR . '<td width="100%">';
        $s .= $CT . '<a href="?m=projects&a=view&project_id=' . $row["project_id"] . '" onmouseover="return overlib( \'' . htmlspecialchars('<div><p>' . str_replace(array("\r\n", "\n", "\r"), '</p><p>', addslashes($row["project_description"])) . '</p></div>', ENT_QUOTES) . '\', CAPTION, \'' . $AppUI->_('Description') . '\', CENTER);" onmouseout="nd();">' . htmlspecialchars($row["project_name"], ENT_QUOTES) . '</a>';
        $s .= $CR . '</td>';
        $s .= $CR . '<td align="center">' . ($start_date ? $start_date->format($df) : '-') . '</td>';
        $s .= $CR . '<td align="center">' . ($row["project_duration"] > 0 ? round($row["project_duration"], 0) . $AppUI->_('h') : '-') . '</td>';
        $s .= $CR . '<td align="center" nowrap="nowrap" style="background-color:' . $priority[$row['project_priority']]['color'] . '">';
        $s .= $CT . ($end_date ? $end_date->format($df) : '-');
        $s .= $CR . '</td>';
        $s .= $CR . '<td align="center">';
        $s .= $actual_end_date ? '<a href="?m=tasks&a=view&task_id=' . $row["critical_task"] . '">' : '';
        $s .= $actual_end_date ? '<span ' . $style . '>' . $actual_end_date->format($df) . '</span>' : '-';
        $s .= $actual_end_date ? '</a>' : '';
        $s .= $CR . '</td>';
        $s .= $CR . '<td align="center">';
        $s .= $row["task_log_problem"] ? '<a href="?m=tasks&a=index&f=all&project_id=' . $row["project_id"] . '">' : '';
        $s .= $row["task_log_problem"] ? dPshowImage('./images/icons/dialog-warning5.png', 16, 16, 'Problem', 'Problem') : '-';
        $s .= $CR . $row["task_log_problem"] ? '</a>' : '';
        $s .= $CR . '</td>';
        $s .= $CR . '<td align="center" nowrap="nowrap">' . htmlspecialchars($row["user_username"], ENT_QUOTES) . '</td>';
        $s .= $CR . '<td align="center" nowrap="nowrap">';
        $s .= $CT . $row["total_tasks"] . ($row["my_tasks"] ? ' (' . $row["my_tasks"] . ')' : '');
        $s .= $CR . '</td>';
        $s .= $CR . '<td align="center" nowrap="nowrap">' . $AppUI->_($pstatus[$row["project_status"]]) . '</td>';
        $s .= $CR . '</tr>';
        echo $s;
    }
}
if ($none) {
    echo $CR . '<tr><td colspan="11">' . $AppUI->_('No projects available') . '</td></tr>';
}
?>
Exemple #15
0
$time_set = CUtils::getStartOfWeek($time_set, $rollover_day);
//Get list of dates for current timesheet
$timestampArray = CUtils::getListDateOfTheWeek($time_set, $working_days);
//Build week header's string
$header = $AppUI->_('Week from') . " ";
$header .= $AppUI->_(date("l", min($timestampArray))) . ' ' . date("d/m/Y", min($timestampArray));
$header .= ' ' . $AppUI->_('to') . ' ';
$header .= $AppUI->_(date("l", max($timestampArray))) . ' ' . date("d/m/Y", max($timestampArray));
?>

<!-- Display week header with appropriate arrows for prev/next  week-->
<table width="100%" class="motitle" cellspacing="0" cellpadding="3" border="0">
	<tr>
	<?php 
$prev = dPshowImage(dPfindImage('prev.gif'), 16, 16, $AppUI->_('Previous week'), 'Previous week');
$next = dPshowImage(dPfindImage('next.gif'), 16, 16, $AppUI->_('Next week'), 'Next week');
?>

		<td align="left"><a
			href="./index.php?m=activity&a=capture&uid=<?php 
echo $user_id;
?>
&wk=<?php 
echo $wk + 1;
?>
"><?php 
echo $prev;
?>
</a>
		</td>
		<th nowrap="nowrap" colspan="6" align="center"><?php 
Exemple #16
0
 /**
 * The drawing function
 * array($attribs, $data, $prefix, $suffix);
 */
 function show()
 {
     global $AppUI;
     $CR = "\n";
     $CT = "\n\t";
     $s = $CR . '<table width="100%" border="0" cellpadding="1" cellspacing="1">';
     $s .= $CR . '<tr>';
     if ($this->icon) {
         $s .= $CR . '<td width="42">';
         $s .= dPshowImage(dPFindImage($this->icon, $this->module));
         $s .= '</td>';
     }
     $s .= $CR . '<td align="left" width="100%" nowrap="nowrap"><h1>' . $AppUI->_($this->title) . '</h1></td>';
     foreach ($this->cells1 as $c) {
         $s .= $c[2] ? $CR . $c[2] : '';
         $s .= $CR . '<td align="right" nowrap="nowrap"' . ($c[0] ? ' ' . $c[0] : '') . '>';
         $s .= $c[1] ? $CT . $c[1] : '&nbsp;';
         $s .= $CR . '</td>';
         $s .= $c[3] ? $CR . $c[3] : '';
     }
     if ($this->showhelp) {
         $s .= '<td nowrap="nowrap" width="20" align="right">';
         //$s .= $CT . contextHelp('<img src="./images/obj/help.gif" width="14" height="16" border="0" alt="'.$AppUI->_('Help').'" />', $this->helpref);
         $s .= "\n\t<a href=\"#" . $this->helpref . "\" onClick=\"javascript:window.open('?m=help&dialog=1&hid=" . $this->helpref . "', 'contexthelp', 'width=400, height=400, left=50, top=50, scrollbars=yes, resizable=yes')\" title=\"" . $AppUI->_('Help') . "\">";
         $s .= "\n\t\t" . dPshowImage('./images/icons/stock_help-16.png', '16', '16', $AppUI->_('Help'));
         $s .= "\n\t</a>";
         $s .= "\n</td>";
     }
     $s .= "\n</tr>";
     $s .= "\n</table>";
     if (count($this->crumbs) || count($this->cells2)) {
         $crumbs = array();
         foreach ($this->crumbs as $k => $v) {
             $t = $v[1] ? '<img src="' . dPfindImage($v[1], $this->module) . '" border="" alt="" />&nbsp;' : '';
             $t .= $AppUI->_($v[0]);
             $crumbs[] = "<a href=\"{$k}\">{$t}</a>";
         }
         $s .= "\n<table border=\"0\" cellpadding=\"4\" cellspacing=\"0\" width=\"100%\">";
         $s .= "\n<tr>";
         $s .= "\n\t<td nowrap=\"nowrap\">";
         $s .= "\n\t\t" . '<strong>' . implode(' : ', $crumbs) . '</strong>';
         $s .= "\n\t</td>";
         foreach ($this->cells2 as $c) {
             $s .= $c[2] ? "\n{$c['2']}" : '';
             $s .= "\n\t<td align=\"right\" nowrap=\"nowrap\"" . ($c[0] ? " {$c['0']}" : '') . '>';
             $s .= $c[1] ? "\n\t{$c['1']}" : '&nbsp;';
             $s .= "\n\t</td>";
             $s .= $c[3] ? "\n\t{$c['3']}" : '';
         }
         $s .= "\n</tr>\n</table>";
     }
     echo "{$s}";
 }
        $perm_type = array();
        if (is_array($permission['aco'])) {
            foreach ($permission['aco'] as $key => $section) {
                foreach ($section as $value) {
                    $perm = $perms->get_object_full($value, $key, 1, 'aco');
                    $perm_type[] = $AppUI->_($perm['name']);
                }
            }
        }
        $buf .= implode("<br />", $perm_type);
        $buf .= "</td>";
        // Allow or deny
        $buf .= "<td>" . $AppUI->_($permission['allow'] ? 'allow' : 'deny') . "</td>";
        $buf .= '<td nowrap>';
        if ($canDelete) {
            $buf .= '<a href="javascript:delIt(' . $acl . ');" title="' . $AppUI->_('delete') . '">' . dPshowImage('./images/icons/stock_delete-16.png', 16, 16, '') . '</a>';
        }
        $buf .= '</td>';
        echo "<tr>{$buf}</tr>";
    }
}
?>
</table>

</td><td width="50%" valign="top">

<?php 
if ($canEdit) {
    ?>

<table cellspacing="1" cellpadding="2" border="0" class="std" width="100%">
Exemple #18
0
    // dylan_cuthbert: auto-transation system in-progress, leave these lines
    $transbrk = "\n[translation]\n";
    $descrip = str_replace("\n", "<br />", $row['task_log_description']);
    $tranpos = strpos($descrip, str_replace("\n", "<br />", $transbrk));
    if ($tranpos === false) {
        $s .= $descrip;
    } else {
        $descrip = substr($descrip, 0, $tranpos);
        $tranpos = strpos($row['task_log_description'], $transbrk);
        $transla = substr($row['task_log_description'], $tranpos + strlen($transbrk));
        $transla = trim(str_replace("'", '"', $transla));
        $s .= $descrip . "<div style='font-weight: bold; text-align: right'><a title='{$transla}' class='hilite'>[" . $AppUI->_("translation") . "]</a></div>";
    }
    // end auto-translation code
    $s .= '</td>';
    $s .= "\n\t<td>";
    if ($canDelete) {
        $s .= "\n\t\t<a href=\"javascript:delIt2({$row['task_log_id']});\" title=\"" . $AppUI->_('delete log') . "\">" . "\n\t\t\t" . dPshowImage('./images/icons/stock_delete-16.png', 16, 16, '') . "\n\t\t</a>";
    }
    $s .= "\n\t</td>";
    $s .= '</tr>';
    $hrs += (double) $row["task_log_hours"];
}
$s .= '<tr bgcolor="white" valign="top">';
$s .= '<td colspan="3" align="right">' . $AppUI->_('Total Hours') . ' =</td>';
$s .= '<td align="right">' . sprintf("%.2f", $hrs) . '</td>';
$s .= '</tr>';
echo $s;
?>
</table>
Exemple #19
0
<tr>
	<th width="100%"><?php 
echo $AppUI->_('Role');
?>
</th>
	<th>&nbsp;</th>
</tr>

<?php 
foreach ($user_roles as $row) {
    $buf = '';
    $style = '';
    $buf .= "<td>" . $row['name'] . "</td>";
    $buf .= '<td nowrap>';
    if ($canEdit) {
        $buf .= "<a href=\"javascript:delIt({$row['id']});\" title=\"" . $AppUI->_('delete') . "\">" . dPshowImage('./images/icons/stock_delete-16.png', 16, 16, '') . "</a>";
    }
    $buf .= '</td>';
    echo "<tr>{$buf}</tr>";
}
?>
</table>

</td><td width="50%" valign="top">

<?php 
if ($canEdit) {
    ?>

<table cellspacing="1" cellpadding="2" border="0" class="std" width="100%">
<form name="frmPerms" method="post" action="?m=admin">
Exemple #20
0
    ?>
+<?php 
    echo dPformSafe(@$obj->company_city, DP_FORM_URI);
    ?>
+<?php 
    echo dPformSafe(@$obj->company_state, DP_FORM_URI);
    ?>
+<?php 
    echo dPformSafe(@$obj->company_zip, DP_FORM_URI);
    ?>
+<?php 
    echo dPformSafe(@$obj->company_country, DP_FORM_URI);
    ?>
" target="_blank">
				<?php 
    echo dPshowImage('./images/googlemaps.gif', 55, 22, 'Find It on Google');
}
?>
				</a></span>
				<?php 
echo htmlspecialchars(@$obj->company_address1) . ($obj->company_address2 ? '<br />' : '') . htmlspecialchars($obj->company_address2) . ($obj->company_city ? '<br />' : '') . htmlspecialchars($obj->company_city) . ($obj->company_state ? ', ' : '') . htmlspecialchars($obj->company_state) . ($obj->company_zip ? ' ' : '') . htmlspecialchars($obj->company_zip);
?>
			</td>
		</tr>
		<tr>
			<td align="right" nowrap="nowrap"><?php 
echo $AppUI->_('URL');
?>
:</td>
			<td class="hilite">
				<a href="http://<?php 
foreach ($events as $row) {
    $start = new CDate($row['event_start_date']);
    $end = new CDate($row['event_end_date']);
    ?>
	<tr>
		<td width="25%" nowrap="nowrap">
			<?php 
    echo $start->format($df . ' ' . $tf);
    ?>
 - <?php 
    echo $end->format($df . ' ' . $tf);
    ?>
		</td>
		<td width="10%" nowrap="nowrap">
			<?php 
    echo dPshowImage(dPfindImage('event' . $row['event_type'] . '.png', 'calendar'), 16, 16, '');
    ?>
			<b><?php 
    echo $AppUI->_($types[$row['event_type']]);
    ?>
</b>
		<td>
			<a href="?m=calendar&a=view&event_id=<?php 
    echo $row['event_id'];
    ?>
" class="event" title="<?php 
    echo $row['event_description'];
    ?>
">
			<?php 
    echo $row['event_title'];
global $AppUI, $project_id, $task_id, $deny, $canRead, $canEdit, $dPconfig, $cfObj, $m, $obj;
require_once $AppUI->getModuleClass('files');
global $allowed_folders_ary, $denied_folders_ary, $limited;
$cfObj = new CFileFolder();
$allowed_folders_ary = $cfObj->getAllowedRecords($AppUI->user_id);
$denied_folders_ary = $cfObj->getDeniedRecords($AppUI->user_id);
$limited = count($allowed_folders_ary) < $cfObj->countFolders() ? true : false;
if (!$limited) {
    $canEdit = true;
} else {
    if ($limited && array_key_exists($folder, $allowed_folders_ary)) {
        $canEdit = true;
    } else {
        $canEdit = false;
    }
}
$showProject = false;
$project_id = $obj->task_project;
if (getPermission('files', 'edit')) {
    echo '<a href="?m=files&amp;a=addedit&amp;project_id=' . $project_id . '&amp;file_task=' . $task_id . '">' . $AppUI->_('Attach a file') . '</a>';
    echo dPshowImage(dPfindImage('stock_attach-16.png', $m), 16, 16, '');
}
$canAccess_folders = getPermission('file_folders', 'access');
if ($canAccess_folders) {
    $folder = (int) dPgetParam($_GET, 'folder', 0);
    require DP_BASE_DIR . '/modules/files/folders_table.php';
} else {
    if (getPermission('files', 'view')) {
        require DP_BASE_DIR . '/modules/files/index_table.php';
    }
}
function showtask(&$a, $level = 0, $is_opened = true, $today_view = false, $hideOpenCloseLink = false, $allowRepeat = false)
{
    global $AppUI, $done, $query_string, $durnTypes, $userAlloc, $showEditCheckbox;
    global $tasks_opened, $tasks_closed, $user_id;
    $tasks_closed = $tasks_closed ? $tasks_closed : array();
    $tasks_opened = $tasks_opened ? $tasks_opened : array();
    $done = $done ? $done : array();
    $now = new CDate();
    $df = $AppUI->getPref('SHDATEFORMAT');
    $df .= ' ' . $AppUI->getPref('TIMEFORMAT');
    $show_all_assignees = dPgetConfig('show_all_task_assignees', false);
    if (!isset($done[$a['task_id']])) {
        $done[$a['task_id']] = 1;
    } else {
        if (!$allowRepeat) {
            //by default, we shouldn't allow repeat displays of the same task
            return;
        }
    }
    $task_obj = new CTask();
    $task_obj->peek($a['task_id']);
    if (!$task_obj->canAccess($user_id ? $user_id : $AppUI->user_id)) {
        //don't show tasks that we can't access
        return;
    }
    if ($is_opened) {
        openClosedTask($a);
    } else {
        closeOpenedTask($a);
    }
    $start_date = intval($a['task_start_date']) ? new CDate($a['task_start_date']) : null;
    $end_date = intval($a['task_end_date']) ? new CDate($a['task_end_date']) : null;
    $last_update = isset($a['last_update']) && intval($a['last_update']) ? new CDate($a['last_update']) : null;
    // prepare coloured highlight of task time information
    $style = '';
    if ($start_date) {
        if ($now->after($start_date) && $a['task_percent_complete'] == 0) {
            $style = 'background-color:#ffeebb';
        } else {
            if ($now->after($start_date) && $a['task_percent_complete'] < 100) {
                $style = 'background-color:#e6eedd';
            }
        }
        if (!empty($end_date) && $now->after($end_date)) {
            $style = 'background-color:#cc6666;color:#ffffff';
        }
        if (!$end_date) {
            /*
             ** end date calc has been moved to calcEndByStartAndDuration()-function
             ** called from array_csort and tasks.php 
             ** perhaps this fallback if-clause could be deleted in the future, 
             ** didn't want to remove it shortly before the 2.0.2
             */
            $end_date = new CDate('0000-00-00 00:00:00');
        }
        if ($a['task_percent_complete'] == 100) {
            $style = 'background-color:#aaddaa; color:#00000';
        }
        $days = $end_date->dateDiff($now);
    }
    $s = "\n<tr>";
    // edit icon
    $s .= "\n\t<td>";
    $canEdit = getPermission('tasks', 'edit', $a['task_id']);
    $canViewLog = getPermission('task_log', 'view', $a['task_id']);
    if ($canEdit) {
        $s .= "\n\t\t" . '<a href="?m=tasks&amp;a=addedit&amp;task_id=' . $a['task_id'] . '">' . "\n\t\t\t" . '<img src="./images/icons/pencil.gif" alt="' . $AppUI->_('Edit Task') . '" border="0" width="12" height="12" />' . "\n\t\t</a>";
    }
    $s .= "\n\t</td>";
    // pinned
    $pin_prefix = $a['task_pinned'] ? '' : 'un';
    $s .= "\n\t<td>\n\t\t" . '<a href="?m=tasks&amp;pin=' . ($a['task_pinned'] ? 0 : 1) . '&task_id=' . $a['task_id'] . '">' . "\n\t\t\t" . '<img src="./images/icons/' . $pin_prefix . 'pin.gif" alt="' . $AppUI->_($pin_prefix . 'pin Task') . '" border="0" width="12" height="12" />' . "\n\t\t</a>\n\t</td>";
    // New Log
    $s .= "\n\t" . '<td align="center">';
    if ($canViewLog && $a['task_dynamic'] != 1) {
        $s .= '<a href="?m=tasks&amp;a=view&amp;task_id=' . $a['task_id'] . '&tab=1">' . $AppUI->_('Log') . '</a>';
    } else {
        $s .= $AppUI->_('-');
    }
    $s .= '</td>';
    // percent complete and priority
    $s .= "\n\t" . '<td align="right">' . intval($a['task_percent_complete']) . '%</td>' . "\n\t" . '<td align="center" nowrap="nowrap">';
    if (@$a['task_log_problem'] > 0) {
        $s .= '<a href="?m=tasks&amp;a=view&amp;task_id=' . $a['task_id'] . '&amp;tab=0&amp;problem=1">' . dPshowImage('./images/icons/dialog-warning5.png', 16, 16, 'Problem', 'Problem!') . '</a>';
    } else {
        if ($a['task_priority'] != 0) {
            $s .= "\n\t\t" . dPshowImage('./images/icons/priority' . ($a['task_priority'] > 0 ? '+' : '-') . abs($a['task_priority']) . '.gif', 13, 16, '', '');
        }
    }
    $s .= (@$a['file_count'] > 0 ? '<img src="./images/clip.png" alt="F" />' : '') . '</td>';
    // dots
    $s .= '<td width="' . ($today_view ? '50%' : '90%') . '">';
    //level
    if ($level == -1) {
        $s .= '...';
    }
    for ($y = 0; $y < $level; $y++) {
        $s .= '<img src="' . ($y + 1 == $level ? './images/corner-dots.gif' : './images/shim.gif') . '" width="16" height="12" border="0" alt="" />';
    }
    // name link
    /*
    $alt = ((mb_strlen($a['task_description']) > 80) 
    		? (mb_substr($a['task_description'], 0, 80) . '...') : $a['task_description']);
    // instead of the statement below
    $alt = str_replace('"', '&quot;', $alt);
    $alt = htmlspecialchars($alt);
    $alt = str_replace("\r", ' ', $alt);
    $alt = str_replace("\n", ' ', $alt);
    */
    $alt = !empty($a['task_description']) ? 'onmouseover="javascript:return overlib(' . "'" . htmlspecialchars('<div><p>' . str_replace(array("\r\n", "\n", "\r"), '</p><p>', addslashes($a['task_description'])), ENT_QUOTES) . '</p></div>' . "', CAPTION, '" . $AppUI->_('Description') . "'" . ', CENTER);" onmouseout="nd();"' : ' ';
    if ($a['task_milestone'] > 0) {
        $s .= '&nbsp;<a href="./index.php?m=tasks&amp;a=view&amp;task_id=' . $a['task_id'] . '" ' . $alt . '>' . '<b>' . $a['task_name'] . '</b></a>' . '<img src="./images/icons/milestone.gif" border="0" alt="Milestone" /></td>';
    } else {
        if ($a['task_dynamic'] == 1 || count($task_obj->getChildren())) {
            if (!($today_view || $hideOpenCloseLink)) {
                $s .= '<a href="index.php' . $query_string . ($is_opened ? '&close_task_id=' . $a['task_id'] . '"><img src="images/icons/collapse.gif" align="center"' : '&open_task_id=' . $a['task_id'] . '"><img src="images/icons/expand.gif"') . ' border="0" alt="" /></a>';
            }
            $s .= '&nbsp;<a href="./index.php?m=tasks&amp;a=view&amp;task_id=' . $a['task_id'] . '" ' . $alt . '>' . ($a['task_dynamic'] == 1 ? '<b><i>' : '') . $a['task_name'] . ($a['task_dynamic'] == 1 ? '</i></b>' : '') . '</a></td>';
        } else {
            $s .= '&nbsp;<a href="./index.php?m=tasks&amp;a=view&amp;task_id=' . $a['task_id'] . '" ' . $alt . '>' . $a['task_name'] . '</a></td>';
        }
    }
    if ($today_view) {
        // Show the project name
        $s .= '<td width="50%"><a href="?m=projects&amp;a=view&amp;project_id=' . $a['task_project'] . '">' . '<span style="padding:2px;background-color:#' . $a['project_color_identifier'] . ';color:' . bestColor($a['project_color_identifier']) . '">' . $a['project_name'] . '</span>' . '</a></td>';
    }
    // task owner
    if (!$today_view) {
        $s .= '<td nowrap="nowrap" align="center">' . '<a href="?m=admin&amp;a=viewuser&amp;user_id=' . $a['user_id'] . '">' . $a['user_username'] . '</a>' . '</td>';
    }
    // $s .= '<td nowrap="nowrap" align="center">' . $a['user_username'] . '</td>';
    if (isset($a['task_assigned_users']) && ($assigned_users = $a['task_assigned_users'])) {
        $a_u_tmp_array = array();
        if ($show_all_assignees) {
            $s .= '<td align="center">';
            foreach ($assigned_users as $val) {
                /*
                $a_u_tmp_array[] = ('<a href="mailto:' . $val['user_email'] . '">' 
                					. $val['user_username'] . '</a>'); 
                */
                $a_u_tmp_array[] = '<a href="?m=admin&amp;a=viewuser&amp;user_id=' . $val['user_id'] . '"' . 'title="' . $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$val['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$val['user_id']]['freeCapacity'] . '%' . '">' . $val['user_username'] . ' (' . $val['perc_assignment'] . '%)</a>';
            }
            $s .= join(', ', $a_u_tmp_array) . '</td>';
        } else {
            $s .= '<td align="center" nowrap="nowrap">' . '<a href="?m=admin&amp;a=viewuser&amp;user_id=' . $assigned_users[0]['user_id'] . '" title="' . $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[0]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[0]['user_id']]['freeCapacity'] . '%">' . $assigned_users[0]['user_username'] . ' (' . $assigned_users[0]['perc_assignment'] . '%)</a>';
            if ($a['assignee_count'] > 1) {
                $s .= ' <a href="javascript: void(0);" onclick="javascript:toggle_users(' . "'users_" . $a['task_id'] . "'" . ');" title="' . join(', ', $a_u_tmp_array) . '">(+' . ($a['assignee_count'] - 1) . ')</a>' . '<span style="display: none" id="users_' . $a['task_id'] . '">';
                $a_u_tmp_array[] = $assigned_users[0]['user_username'];
                for ($i = 1, $xi = count($assigned_users); $i < $xi; $i++) {
                    $a_u_tmp_array[] = $assigned_users[$i]['user_username'];
                    $s .= '<br /><a href="?m=admin&amp;a=viewuser&amp;user_id=' . $assigned_users[$i]['user_id'] . '" title="' . $AppUI->_('Extent of Assignment') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['charge'] . '%; ' . $AppUI->_('Free Capacity') . ':' . $userAlloc[$assigned_users[$i]['user_id']]['freeCapacity'] . '%">' . $assigned_users[$i]['user_username'] . ' (' . $assigned_users[$i]['perc_assignment'] . '%)</a>';
                }
                $s .= '</span>';
            }
            $s .= '</td>';
        }
    } else {
        if (!$today_view) {
            // No users asigned to task
            $s .= '<td align="center">-</td>';
        }
    }
    // duration or milestone
    $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($start_date ? $start_date->format($df) : '-') . '</td>' . '<td align="center" nowrap="nowrap" style="' . $style . '">' . $a['task_duration'] . ' ' . $AppUI->_($durnTypes[$a['task_duration_type']]) . '</td>' . '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($end_date ? $end_date->format($df) : '-') . '</td>';
    if ($today_view) {
        $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . $a['task_due_in'] . '</td>';
    } else {
        if ($AppUI->isActiveModule('history') && getPermission('history', 'view')) {
            $s .= '<td nowrap="nowrap" align="center" style="' . $style . '">' . ($last_update ? $last_update->format($df) : '-') . '</td>';
        }
    }
    // Assignment checkbox
    if ($showEditCheckbox) {
        $s .= "\n\t" . '<td align="center">' . '<input type="checkbox" name="selected_task[' . $a['task_id'] . ']" value="' . $a['task_id'] . '"/></td>';
    }
    $s .= '</tr>';
    echo $s;
}
	<td align="center">
<?php 
        if ($row['task_log_problem']) {
            ?>
		<a href="?m=tasks&amp;a=index&amp;f=all&amp;project_id=<?php 
            echo $row['project_id'];
            ?>
">
		<?php 
            dPshowImage('./images/icons/dialog-warning5.png', 16, 16, 'Problem', 'Problem!');
            ?>
		</a>
<?php 
        } else {
            if ($row['project_priority'] != 0) {
                echo dPshowImage('./images/icons/priority' . ($row['project_priority'] > 0 ? '+' : '-') . abs($row['project_priority']) . '.gif', 13, 16, '', '');
            } else {
                ?>
		&nbsp;
<?php 
            }
        }
        ?>
	</td>
	<td align="center" nowrap="nowrap"><?php 
        echo htmlspecialchars($row['user_username'], ENT_QUOTES);
        ?>
	</td>
	<td align="center" nowrap="nowrap"><?php 
        echo htmlspecialchars($row['total_tasks'] . ($row['my_tasks'] ? ' (' . $row['my_tasks'] . ')' : ''));
        ?>
function displayTask($list, $task, $level, $display_week_hours, $fromPeriod, $toPeriod, $user_id)
{
    global $AppUI, $df, $durnTypes, $log_userfilter_users, $now, $priority, $system_users;
    global $z, $zi, $x, $userAlloc;
    $zi++;
    $users = $task->task_assigned_users;
    $task->userPriority = $task->getUserSpecificTaskPriority($user_id);
    $projects = $task->getProject();
    $tmp = '<tr>';
    $tmp .= '<td align="center" nowrap="nowrap">';
    $tmp .= '<input type="checkbox" name="selected_task[' . $task->task_id . ']" value="' . $task->task_id . '" />';
    $tmp .= '</td>';
    $tmp .= '<td align="center" nowrap="nowrap">';
    if ($task->userPriority) {
        $tmp .= '<img src="./images/icons/priority';
        $tmp .= $task->userPriority < 0 ? '-' . -$task->userPriority : '+' . $task->userPriority;
        $tmp .= '.gif" width="13" height="16" alt="" />';
    }
    $tmp .= '</td>';
    $tmp .= '<td nowrap="nowrap">';
    for ($i = 0; $i < $level; $i++) {
        $tmp .= '&nbsp;&nbsp;&nbsp;';
    }
    if ($task->task_milestone == true) {
        $tmp .= '<strong>';
    }
    if ($level >= 1) {
        $tmp .= dPshowImage(dPfindImage('corner-dots.gif', 'tasks'), 16, 12, 'Subtask') . "&nbsp;";
    }
    $tmp .= '<a href="?m=tasks&amp;a=view&amp;task_id=' . $task->task_id . '">' . $task->task_name . '</a>';
    if ($task->task_milestone == true) {
        $tmp .= '</strong>';
    }
    if ($task->task_priority) {
        $tmp .= '&nbsp;(<img src="./images/icons/priority';
        $tmp .= $task->task_priority < 0 ? '-' . -$task->task_priority : '+' . $task->task_priority;
        $tmp .= '.gif" width="13" height="16" alt="" />)';
    }
    $tmp .= '</td>';
    $tmp .= '<td align="center">';
    $tmp .= '<a href="?m=projects&amp;a=view&amp;project_id=' . $task->task_project . '" style="background-color:#' . @$projects['project_color_identifier'] . '; color:' . bestColor(@$projects['project_color_identifier']) . '">' . $projects['project_short_name'] . '</a>';
    $tmp .= '</td>';
    $tmp .= '<td align="center" nowrap="nowrap">';
    $tmp .= $task->task_duration . '&nbsp;' . $AppUI->_($durnTypes[$task->task_duration_type]);
    $tmp .= '</td>';
    $tmp .= '<td align="center" nowrap="nowrap">';
    $dt = new CDate($task->task_start_date);
    $tmp .= $dt->format($df);
    $tmp .= '&nbsp;&nbsp;&nbsp;</td>';
    $tmp .= '<td align="center" nowrap="nowrap">';
    $ed = new CDate($task->task_end_date);
    $dt = $now->dateDiff($ed);
    $sgn = $now->compare($ed, $now);
    $tmp .= $dt * $sgn;
    $tmp .= '</td>';
    if ($display_week_hours) {
        $tmp .= displayWeeks($list, $task, $level, $fromPeriod, $toPeriod);
    }
    $tmp .= '<td>';
    $sep = $us = '';
    foreach ($users as $row) {
        if ($row['user_id']) {
            $us .= $sep . '<a href="?m=admin&amp;a=viewuser&amp;user_id=' . $row[0] . '">' . $row['contact_first_name'] . ' ' . $row['contact_last_name'] . '&nbsp;(' . $row['perc_assignment'] . '%)</a>';
            $sep = ', ';
        }
    }
    $tmp .= $us;
    $tmp .= '</td>';
    // create the list of possible assignees
    if ($zi == 1) {
        //	selectbox may not have a size smaller than 2, use 5 here as minimum
        $zz = $z < 5 ? 5 : $z * 1.5;
        $zz = sizeof($users) >= 7 ? $zz * 2 : $zz;
        $zm1 = $z - 2;
        $zm1 = $zm1 <= 0 ? 1 : $zm1;
        $assUser = $userAlloc[$user_id]['userFC'];
        // need to handle orphaned tasks different from tasks with existing assignees
        $zm1 += $user_id == 0 ? 1 : 0;
        $tmp .= '<td valign="top" align="center" nowrap="nowrap" rowspan="' . $zm1 . '">';
        $tmp .= '<select name="add_users" style="width:200px" size="' . ($zz - 1) . '" class="text" multiple="multiple" ondblclick="javascript:chAssignment(' . $user_id . ', 0, false)">';
        foreach ($userAlloc as $v => $u) {
            $tmp .= "\n\t" . '<option value="' . $u['user_id'] . '">' . dPformSafe($u['userFC']) . '</option>';
        }
        $tmp .= '</select>';
        /*
        $tmp .= arraySelect($user_list, 'add_users', 'class="text" style="width: 200px" size="' 
                            . ($zz - 1) . '" multiple="multiple"', NULL);
        */
        $tmp .= '</td>';
    }
    $tmp .= "</tr>\n";
    return $tmp;
}
Exemple #26
0
foreach (array_filter($projects, pfilter) as $row) {
    $none = false;
    $today = new CDate();
    $start_date = intval(@$row['project_start_date']) ? new CDate($row['project_start_date']) : null;
    $end_date = intval(@$row['project_end_date']) ? new CDate($row['project_end_date']) : null;
    $actual_end_date = intval(@$row['project_actual_end_date']) ? new CDate($row['project_actual_end_date']) : null;
    $style = $actual_end_date > $end_date && !empty($end_date) ? 'style="color:red; font-weight:bold"' : '';
    $row['total_tasks'] = $row['total_tasks'] ? $row['total_tasks'] : '0';
    $s = $first ? '<tr class="first">' : '<tr class="second">';
    $first = !$first;
    $s .= '<td align="center" valign="top">';
    $s .= '<div style="background-color: #' . $row['project_color_identifier'] . '; border: 1px solid #CCC; width: 40px; height: 36px; text-align: center; font-size: 9px; -moz-border-radius: 4px; padding-top: 4px;">' . sprintf("%.0f%%", $row['project_percent_complete']);
    $s .= '<div style="margin: auto; padding-top: 2px">';
    if ($row['task_log_problem']) {
        $s .= '<a href="?m=tasks&a=index&f=all&project_id=' . $row['project_id'] . '">';
        $s .= dPshowImage('./images/problem.gif', 12, 12, 'Problem', 'Problem!');
        $s .= '</a>';
    } else {
        $s .= '<img src="images/' . ($style === '' ? $start_date > $today ? 'low.png' : 'normal.png' : 'red.png') . '"' . ' title="' . ($style == '' ? $start_date > $today ? 'Future' : 'Good' : 'Bad') . '"/>';
    }
    $s .= '</div>';
    $s .= '</div>';
    $s .= '</td>';
    $s .= '<td class="clickable" onclick="viewProject(' . $row['project_id'] . ')" style="padding-left: 8px">';
    $s .= '<img style="float: left; padding-right: 6px" src="images/' . $ppx[$row['project_type']] . '"
			title="Type: ' . ucfirst(str_replace('.gif', '', $ppx[$row['project_type']])) . '"/>' . '<div style="float: right; font-size: 10px; text-align: right; padding-right: 4px; width: 128px">' . '<div style="float: right; width: 64px"><img src="images/' . $ppi[$row['project_priority']] . '" title="' . $ppt[$row['project_priority']] . '"/></div>';
    if ($psfilter == P_ALL) {
        $s .= '<div style="float: right; width: 54px; color: #888; text-align: right">' . $pstatus[$row['project_status']] . '</div>';
    }
    $s .= '<div style="float: right; font-size: 10px; color: #444; padding-top: 10px; width: 100%">' . '<img src="images/sum.gif"/> task: ' . $row['total_tasks'] . '</div>' . '</div>';
    $s .= '<b>' . htmlspecialchars($row['project_name'], ENT_QUOTES) . '</b><br/>';
Exemple #27
0
/**
* Sub-function to collect tasks within a period
*
* @param Date the starting date of the period
* @param Date the ending date of the period
* @param array by-ref an array of links to append new items to
* @param int the length to truncate entries by
* @param int the company id to filter by
* @author Andrew Eddie <*****@*****.**>
*/
function getTaskLinks($startPeriod, $endPeriod, &$links, $strMaxLen, $company_id = 0)
{
    global $a, $AppUI, $dPconfig;
    $tasks = CTask::getTasksForPeriod($startPeriod, $endPeriod, $company_id, $AppUI->user_id, true);
    $durnTypes = dPgetSysVal('TaskDurationType');
    $link = array();
    $sid = 3600 * 24;
    // assemble the links for the tasks
    foreach ($tasks as $row) {
        // the link
        $link['href'] = "?m=tasks&a=view&task_id=" . $row['task_id'];
        $link['alt'] = $row['project_name'] . ":\n" . $row['task_name'];
        // the link text
        if (strlen($row['task_name']) > $strMaxLen) {
            $row['task_name'] = substr($row['task_name'], 0, $strMaxLen) . '...';
        }
        $link['text'] = '<span style="color:' . bestColor($row['color']) . ';background-color:#' . $row['color'] . '">' . $row['task_name'] . '</span>';
        // determine which day(s) to display the task
        $start = new CDate($row['task_start_date']);
        $end = $row['task_end_date'] ? new CDate($row['task_end_date']) : null;
        $durn = $row['task_duration'];
        $durnType = $row['task_duration_type'];
        if (($start->after($startPeriod) || $start->equals($startPeriod)) && ($start->before($endPeriod) || $start->equals($endPeriod))) {
            $temp = $link;
            $temp['alt'] = "START [" . $row['task_duration'] . ' ' . $AppUI->_($durnTypes[$row['task_duration_type']]) . "]\n" . $link['alt'];
            if ($a != 'day_view') {
                $temp['text'] = dPshowImage(dPfindImage('block-start-16.png')) . $temp['text'];
            }
            $links[$start->format(FMT_TIMESTAMP_DATE)][] = $temp;
        }
        if ($end && $end->after($startPeriod) && $end->before($endPeriod) && $start->before($end)) {
            $temp = $link;
            $temp['alt'] = "FINISH\n" . $link['alt'];
            if ($a != 'day_view') {
                $temp['text'] .= dPshowImage(dPfindImage('block-end-16.png'));
            }
            $links[$end->format(FMT_TIMESTAMP_DATE)][] = $temp;
        }
        // convert duration to days
        if ($durnType < 24.0) {
            if ($durn > $dPconfig['daily_working_hours']) {
                $durn /= $dPconfig['daily_working_hours'];
            } else {
                $durn = 0.0;
            }
        } else {
            $durn *= $durnType / 24.0;
        }
        // fill in between start and finish based on duration
        // notes:
        // start date is not in a future month, must be this or past month
        // start date is counted as one days work
        // business days are not taken into account
        $target = $start;
        $target->addSeconds($durn * $sid);
        if (Date::compare($target, $startPeriod) < 0) {
            continue;
        }
        if (Date::compare($start, $startPeriod) > 0) {
            $temp = $start;
            $temp->addSeconds($sid);
        } else {
            $temp = $startPeriod;
        }
        // Optimised for speed, AJD.
        while (Date::compare($endPeriod, $temp) > 0 && Date::compare($target, $temp) > 0 && ($end == null || $temp->before($end))) {
            $links[$temp->format(FMT_TIMESTAMP_DATE)][] = $link;
            $temp->addSeconds($sid);
        }
    }
}
    $descrip = str_replace("\n", '<br />', htmlspecialchars($row['task_log_description']));
    $tranpos = mb_strpos($descrip, str_replace("\n", '<br />', $transbrk));
    if ($tranpos === false) {
        $s .= $descrip;
    } else {
        $descrip = mb_substr($descrip, 0, $tranpos);
        $tranpos = mb_strpos(htmlspecialchars($row['task_log_description']), $transbrk);
        $transla = mb_substr(htmlspecialchars($row['task_log_description']), $tranpos + mb_strlen($transbrk));
        $transla = trim(str_replace("'", '"', $transla));
        $s .= $descrip . '<div style="font-weight: bold; text-align: right"><a title="' . $transla . '" class="hilite">["' . $AppUI->_('translation') . '"]</a></div>';
    }
    // end auto-translation code
    $s .= '</td>';
    $s .= "\n\t<td>";
    if ($canDelete) {
        $s .= "\n\t\t" . '<a href="javascript:delIt2(' . $row['task_log_id'] . ');" title="' . $AppUI->_('delete log') . '">' . "\n\t\t\t" . dPshowImage('./images/icons/stock_delete-16.png', 16, 16, '') . "\n\t\t</a>";
    }
    $s .= "\n\t</td>";
    $s .= '</tr>';
    $hrs += (double) $row['task_log_hours'];
}
$s .= '<tr bgcolor="white" valign="top">';
$s .= '<td colspan="6" align="right">' . $AppUI->_('Total Hours') . ' =</td>';
$s .= '<td align="right">' . sprintf("%.2f", $hrs) . '</td>';
$s .= '<td align="right" colspan="3"><form action="?m=tasks&a=view&tab=1&task_id=' . $task_id . '" method="post">';
if (getPermission('tasks', 'edit', $task_id)) {
    $s .= '<input type="submit" class="button" value="' . $AppUI->_('new log') . '"></form></td>';
}
$s .= '</tr>';
echo $s;
?>
Exemple #29
0
</tr>
<?php 
$s = '';
foreach ($rows as $row) {
    $canEdit = hditemEditable($row);
    /* We need to check if the user who requested the item is still in the
       system. Just because we have a requestor id does not mean we'll be
       able to retrieve a full name */
    $s .= $CR . '<form method="post">';
    $s .= $CR . '<tr>';
    $s .= $CR . '<td align="right" nowrap>';
    if ($canEdit) {
        $s .= $CR . '<a href="?m=helpdesk&a=addedit&item_id=' . $row["item_id"] . '">' . dPshowImage("./images/icons/pencil.gif", 12, 12, "edit") . '</a>&nbsp;';
    }
    $s .= $CR . '</td>';
    $s .= $CR . '<td nowrap="nowrap"><a href="./index.php?m=helpdesk&a=view&item_id=' . $row["item_id"] . '">' . '<strong>' . $row["item_id"] . '</strong></a> ' . dPshowImage(dPfindImage('ct' . $row["item_calltype"] . '.png', 'helpdesk'), 15, 17, '') . '</td>';
    $date = new CDate($row['item_created']);
    $s .= $CR . "<td nowrap>" . $date->format($format) . "</td>";
    $s .= $CR . "<td nowrap align=\"center\">";
    if ($row["item_requestor_email"]) {
        $s .= $CR . "<a href=\"mailto:" . $row["item_requestor_email"] . "\">" . $row['item_requestor'] . "</a>";
    } else {
        $s .= $CR . $row['item_requestor'];
    }
    $s .= $CR . "</td>";
    $s .= $CR . '<td width="99%"><a href="?m=helpdesk&a=view&item_id=' . $row["item_id"] . '">' . $row["item_title"] . '</a></td>';
    $s .= $CR . "<td nowrap align=\"center\">";
    if ($row["assigned_email"]) {
        $s .= $CR . "<a href=\"mailto:" . $row["assigned_email"] . "\">" . $row['assigned_fullname'] . "</a>";
    } else {
        $s .= $CR . $row['assigned_fullname'];
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 />";
}