예제 #1
0
$allowed_companies_ary = $obj->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name');
$allowed_companies = implode(",", array_keys($allowed_companies_ary));
if (!isset($task_id)) {
    $task_id = dPgetParam($_REQUEST, 'task_id', 0);
}
global $xpg_min, $xpg_pagesize;
$xpg_pagesize = 30;
$xpg_min = $xpg_pagesize * ($page - 1);
// This is where we start our record set from
// load the following classes to retrieved denied records
include_once $AppUI->getModuleClass('projects');
include_once $AppUI->getModuleClass('tasks');
$project = new CProject();
$deny1 = $project->getDeniedRecords($AppUI->user_id);
$task = new CTask();
$deny2 = $task->getDeniedRecords($AppUI->user_id);
global $file_types;
$file_types = dPgetSysVal("FileType");
$folder = $folder ? $folder : 0;
// SQL text for count the total recs from the selected option
$q = new DBQuery();
$q->addTable('files');
$q->addQuery('count(files.file_id)');
$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 (count($deny1) > 0) {
    $q->addWhere('file_project NOT IN (' . implode(',', $deny1) . ')');
}
예제 #2
0
function displayFiles($AppUI, $folder_id, $task_id, $project_id, $company_id)
{
    global $m, $a, $tab, $xpg_min, $xpg_pagesize, $showProject, $file_types, $cfObj, $xpg_totalrecs, $xpg_total_pages, $page, $company_id, $allowed_companies, $current_uri, $w2Pconfig, $canEdit, $canRead;
    $df = $AppUI->getPref('SHDATEFORMAT');
    $tf = $AppUI->getPref('TIMEFORMAT');
    // SETUP FOR FILE LIST
    $q = new w2p_Database_Query();
    $q->addQuery('f.*, max(f.file_id) as latest_id, count(f.file_version) as file_versions, round(max(file_version), 2) as file_lastversion');
    $q->addQuery('ff.*');
    $q->addTable('files', 'f');
    $q->addJoin('file_folders', 'ff', 'ff.file_folder_id = file_folder');
    $q->addJoin('projects', 'p', 'p.project_id = file_project');
    $q->addJoin('tasks', 't', 't.task_id = file_task');
    $q->leftJoin('project_departments', 'project_departments', 'p.project_id = project_departments.project_id OR project_departments.project_id IS NULL');
    $q->leftJoin('departments', 'departments', 'departments.dept_id = project_departments.department_id OR dept_id IS NULL');
    //TODO: apply permissions properly
    $project = new CProject();
    $deny1 = $project->getDeniedRecords($AppUI->user_id);
    if (count($deny1) > 0) {
        $q->addWhere('file_project NOT IN (' . implode(',', $deny1) . ')');
    }
    //TODO: apply permissions properly
    $task = new CTask();
    $deny2 = $task->getDeniedRecords($AppUI->user_id);
    if (count($deny2) > 0) {
        $q->addWhere('file_task NOT IN (' . implode(',', $deny2) . ')');
    }
    if ($project_id) {
        $q->addWhere('file_project = ' . (int) $project_id);
    }
    if ($task_id) {
        $q->addWhere('file_task = ' . (int) $task_id);
    }
    if ($company_id) {
        $q->addWhere('project_company = ' . (int) $company_id);
    }
    $q->setLimit($xpg_pagesize, $xpg_min);
    $q->addWhere('file_folder = ' . (int) $folder_id);
    $q->addGroup('file_version_id DESC');
    $qv = new w2p_Database_Query();
    $qv->addTable('files');
    $qv->addQuery('file_id, file_version, file_project, file_name, file_task,
		file_description, u.user_username as file_owner, file_size, file_category,
		task_name, file_version_id,  file_checkout, file_co_reason, file_type,
		file_date, cu.user_username as co_user, project_name,
		project_color_identifier, project_owner, con.contact_first_name,
		con.contact_last_name, co.contact_first_name as co_contact_first_name,
		co.contact_last_name as co_contact_last_name ');
    $qv->addJoin('projects', 'p', 'p.project_id = file_project');
    $qv->addJoin('users', 'u', 'u.user_id = file_owner');
    $qv->addJoin('contacts', 'con', 'con.contact_id = u.user_contact');
    $qv->addJoin('tasks', 't', 't.task_id = file_task');
    $qv->addJoin('file_folders', 'ff', 'ff.file_folder_id = file_folder');
    if ($project_id) {
        $qv->addWhere('file_project = ' . (int) $project_id);
    }
    if ($task_id) {
        $qv->addWhere('file_task = ' . (int) $task_id);
    }
    if ($company_id) {
        $qv->addWhere('project_company = ' . (int) $company_id);
    }
    $qv->leftJoin('users', 'cu', 'cu.user_id = file_checkout');
    $qv->leftJoin('contacts', 'co', 'co.contact_id = cu.user_contact');
    $qv->addWhere('file_folder = ' . (int) $folder_id);
    $files = array();
    $file_versions = array();
    $files = $q->loadList();
    $file_versions = $qv->loadHashList('file_id');
    $q->clear();
    $qv->clear();
    if ($files === array()) {
        return 0;
    }
    $s = '
		<table 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="nowrap" width="5%"></th>
			<th nowrap="nowrap" width="1"></th>
		</tr>';
    $fp = -1;
    $file_date = new w2p_Utilities_Date();
    $id = 0;
    foreach ($files as $row) {
        $latest_file = $file_versions[$row['latest_id']];
        $file_date = new w2p_Utilities_Date($latest_file['file_date']);
        if ($fp != $latest_file['file_project']) {
            if (!$latest_file['file_project']) {
                $latest_file['project_name'] = $AppUI->_('Not attached to a project');
                $latest_file['project_color_identifier'] = 'f4efe3';
            }
            if ($showProject) {
                $style = 'background-color:#' . $latest_file['project_color_identifier'] . ';color:' . bestColor($latest_file['project_color_identifier']);
                $s .= '<tr>';
                $s .= '<td colspan="20" style="border: outset 2px #eeeeee;' . $style . '">';
                if ($latest_file['file_project'] > 0) {
                    $href = './index.php?m=projects&a=view&project_id=' . $latest_file['file_project'];
                } else {
                    $href = './index.php?m=projects';
                }
                $s .= '<a href="' . $href . '">';
                $s .= '<span style="' . $style . '">' . $latest_file['project_name'] . '</span></a>';
                $s .= '</td></tr>';
            }
        }
        $fp = $latest_file['file_project'];
        $s .= '<tr>
				<td nowrap="8%">
                    <form name="frm_remove_file_' . $latest_file['file_id'] . '" action="?m=files" method="post" accept-charset="utf-8">
                        <input type="hidden" name="dosql" value="do_file_aed" />
                        <input type="hidden" name="del" value="1" />
                        <input type="hidden" name="file_id" value="' . $latest_file['file_id'] . '" />
                        <input type="hidden" name="redirect" value="' . $current_uri . '" />
                    </form>
                    <form name="frm_duplicate_file_' . $latest_file['file_id'] . '" action="?m=files" method="post" accept-charset="utf-8">
                        <input type="hidden" name="dosql" value="do_file_aed" />
                        <input type="hidden" name="duplicate" value="1" />
                        <input type="hidden" name="file_id" value="' . $latest_file['file_id'] . '" />
                        <input type="hidden" name="redirect" value="' . $current_uri . '" />
                    </form>
                ';
        $junkFile = new CFile();
        // TODO: This is just to get getIcon included..
        $file_icon = getIcon($row['file_type']);
        $s .= '<a href="./fileviewer.php?file_id=' . $latest_file['file_id'] . '"><img border="0" width="16" heigth="16" src="' . w2PfindImage($file_icon, 'files') . '" alt="" />&nbsp;' . $latest_file['file_name'] . '</a></td>';
        $s .= '<td width="20%">' . w2p_textarea($latest_file['file_description']) . '</td><td width="5%" nowrap="nowrap" align="right">';
        $hidden_table = '';
        $s .= $row['file_lastversion'];
        if ($row['file_versions'] > 1) {
            $s .= ' <a href="javascript: void(0);" onClick="expand(\'versions_' . $latest_file['file_id'] . '\'); ">(' . $row['file_versions'] . ')</a>';
            $hidden_table = '<tr><td colspan="20">
							<table style="display: none" id="versions_' . $latest_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>' . $AppUI->_('Folder') . '</th>
							        <th>' . $AppUI->_('Task Name') . '</th>
							        <th>' . $AppUI->_('Owner') . '</th>
							        <th>' . $AppUI->_('Size') . '</th>
							        <th>' . $AppUI->_('Type') . '</a></th>
							        <th>' . $AppUI->_('Date') . '</th>
							</tr>';
            foreach ($file_versions as $file) {
                if ($file['file_version_id'] == $latest_file['file_version_id']) {
                    $file_icon = getIcon($file['file_type']);
                    $hdate = new w2p_Utilities_Date($file['file_date']);
                    $hidden_table .= '<tr><td nowrap="8%"><a href="./fileviewer.php?file_id=' . $file['file_id'] . '" title="' . $file['file_description'] . '">' . '<img border="0" width="16" heigth="16" src="' . w2PfindImage($file_icon, 'files') . '" alt="" />&nbsp;' . $file['file_name'] . '
					  </a></td>
					  <td width="20%">' . $file['file_description'] . '</td>
					  <td width="5%" nowrap="nowrap" align="right">' . $file['file_version'] . '</td>
					  <td nowrap="nowrap" align="left">' . $file_types[$file['file_category']] . '</td>
					  <td nowrap="nowrap" align="left">' . ($file['file_folder_name'] != '' ? '<a href="' . W2P_BASE_URL . '/index.php?m=files&tab=' . (count($file_types) + 1) . '&folder=' . $file['file_folder_id'] . '">' . w2PshowImage('folder5_small.png', '16', '16', 'folder icon', 'show only this folder', 'files') . $file['file_folder_name'] . '</a>' : 'Root') . '</td>
					  <td nowrap="nowrap" align="left"><a href="./index.php?m=tasks&a=view&task_id=' . $file['file_task'] . '">' . $file['task_name'] . '</a></td>
					  <td nowrap="nowrap">' . $file['contact_first_name'] . ' ' . $file['contact_last_name'] . '</td>
					  <td width="5%" nowrap="nowrap" align="right">' . file_size(intval($file['file_size'])) . '</td>
					  <td nowrap="nowrap">' . $file['file_type'] . '</td>
					  <td width="5%" nowrap="nowrap" align="center">' . $AppUI->formatTZAwareTime($file['file_date'], $df . ' ' . $tf) . '</td>';
                    if ($canEdit && $w2Pconfig['files_show_versions_edit']) {
                        $hidden_table .= '<a href="./index.php?m=files&a=addedit&file_id=' . $file['file_id'] . '">' . w2PshowImage('kedit.png', '16', '16', 'edit file', 'edit file', 'files') . "</a>";
                    }
                    $hidden_table .= '</td><tr>';
                }
            }
            $hidden_table .= '</table>';
        }
        $s .= '</td>
				<td width="10%" nowrap="nowrap" align="left">' . $file_types[$file['file_category']] . '</td>
				<td nowrap="nowrap" align="left"><a href="./index.php?m=tasks&a=view&task_id=' . $latest_file['file_task'] . '">' . $latest_file['task_name'] . '</a></td>
				<td nowrap="nowrap">' . $latest_file['contact_first_name'] . ' ' . $latest_file['contact_last_name'] . '</td>
				<td width="5%" nowrap="nowrap" align="right">' . intval($latest_file['file_size'] / 1024) . ' kb</td>
				<td nowrap="nowrap">' . $latest_file['file_type'] . '</td>
				<td nowrap="nowrap" align="center">' . $AppUI->formatTZAwareTime($latest_file['file_date'], $df . ' ' . $tf) . '</td>
				<td width="10%">' . $latest_file['file_co_reason'] . '</td>
				<td nowrap="nowrap">';
        if (empty($row['file_checkout'])) {
            $s .= '<a href="?m=files&a=co&file_id=' . $latest_file['file_id'] . '">' . w2PshowImage('up.png', '16', '16', 'checkout', 'checkout file', 'files') . '</a>';
        } elseif ($row['file_checkout'] == $AppUI->user_id) {
            $s .= '<a href="?m=files&a=addedit&ci=1&file_id=' . $latest_file['file_id'] . '">' . w2PshowImage('down.png', '16', '16', 'checkin', 'checkin file', 'files') . '</a>';
        } else {
            if ($latest_file['file_checkout'] == 'final') {
                $s .= 'final';
            } else {
                $s .= $latest_file['co_contact_first_name'] . ' ' . $latest_file['co_contact_last_name'] . '<br>(' . $latest_file['co_user'] . ')';
            }
        }
        $s .= '</td><td nowrap="nowrap" width="50">';
        if ($canEdit && (empty($latest_file['file_checkout']) || $latest_file['file_checkout'] == 'final' && ($canEdit || $latest_file['project_owner'] == $AppUI->user_id))) {
            $s .= '<a style="float: left;" href="./index.php?m=files&a=addedit&file_id=' . $latest_file['file_id'] . '">' . w2PshowImage('kedit.png', '16', '16', 'edit file', 'edit file', 'files') . '</a>';
            $s .= '<a style="float: left;" href="javascript: void(0);" onclick="document.frm_duplicate_file_' . $latest_file['file_id'] . '.submit()">' . w2PshowImage('duplicate.png', '16', '16', 'duplicate file', 'duplicate file', 'files') . '</a>';
            $s .= '<a style="float: left;" href="javascript: void(0);" onclick="if (confirm(\'Are you sure you want to delete this file?\')) {document.frm_remove_file_' . $latest_file['file_id'] . '.submit()}">' . w2PshowImage('remove.png', '16', '16', 'delete file', 'delete file', 'files') . '</a>';
        }
        $s .= '</td>';
        $s .= '<td nowrap="nowrap" align="center" width="1">';
        if ($canEdit && (empty($latest_file['file_checkout']) || $latest_file['file_checkout'] == 'final' && ($canEdit || $latest_file['project_owner'] == $AppUI->user_id))) {
            $bulk_op = 'onchange="(this.checked) ? addBulkComponent(' . $latest_file['file_id'] . ') : removeBulkComponent(' . $latest_file['file_id'] . ')"';
            $s .= '<input type="checkbox" ' . $bulk_op . ' name="chk_sel_file_' . $latest_file['file_id'] . '" />';
        }
        $s .= '</td></tr>';
        $s .= $hidden_table;
        $hidden_table = '';
    }
    return $s;
}
예제 #3
0
 public function getFileCountByFolder($notUsed = null, $folder_id, $task_id, $project_id, $company_id, $allowed_companies)
 {
     // SQL text for count the total recs from the selected option
     $q = $this->_getQuery();
     $q->addTable('files');
     $q->addQuery('count(files.file_id)');
     $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 = ' . (int) $folder_id);
     //TODO: apply permissions properly
     $project = new CProject();
     $project->overrideDatabase($this->_query);
     $deny1 = $project->getDeniedRecords($this->_AppUI->user_id);
     if (count($deny1) > 0) {
         $q->addWhere('file_project NOT IN (' . implode(',', $deny1) . ')');
     }
     //TODO: apply permissions properly
     $task = new CTask();
     $task->overrideDatabase($this->_query);
     $deny2 = $task->getDeniedRecords($this->_AppUI->user_id);
     if (count($deny2) > 0) {
         $q->addWhere('file_task NOT IN (' . implode(',', $deny2) . ')');
     }
     if ($project_id) {
         $q->addWhere('file_project = ' . (int) $project_id);
     }
     if ($task_id) {
         $q->addWhere('file_task = ' . (int) $task_id);
     }
     if ($company_id) {
         $q->innerJoin('companies', 'co', 'co.company_id = p.project_company');
         $q->addWhere('company_id = ' . (int) $company_id);
         $q->addWhere('company_id IN (' . $allowed_companies . ')');
     }
     $q->addGroup('file_folder_name');
     $q->addGroup('project_name');
     $q->addGroup('file_name');
     // counts total recs from selection
     return count($q->loadList());
 }
예제 #4
0
function displayFiles($AppUI, $folder_id, $task_id, $project_id, $company_id)
{
    global $m, $tab, $xpg_min, $xpg_pagesize, $showProject, $file_types, $company_id, $current_uri, $canEdit;
    // SETUP FOR FILE LIST
    $q = new w2p_Database_Query();
    $q->addQuery('f.*, max(f.file_id) as latest_id, count(f.file_version) as file_versions, round(max(file_version), 2) as file_lastversion, file_owner, user_id');
    $q->addQuery('ff.*, max(file_version) as file_version, f.file_date as file_datetime');
    $q->addTable('files', 'f');
    $q->addJoin('file_folders', 'ff', 'ff.file_folder_id = file_folder');
    $q->addJoin('projects', 'p', 'p.project_id = file_project');
    $q->addJoin('tasks', 't', 't.task_id = file_task');
    $q->addJoin('users', 'u', 'u.user_id = file_owner');
    $q->leftJoin('project_departments', 'project_departments', 'p.project_id = project_departments.project_id OR project_departments.project_id IS NULL');
    $q->leftJoin('departments', 'departments', 'departments.dept_id = project_departments.department_id OR dept_id IS NULL');
    //TODO: apply permissions properly
    $project = new CProject();
    $deny1 = $project->getDeniedRecords($AppUI->user_id);
    if (count($deny1) > 0) {
        $q->addWhere('file_project NOT IN (' . implode(',', $deny1) . ')');
    }
    //TODO: apply permissions properly
    $task = new CTask();
    $deny2 = $task->getDeniedRecords($AppUI->user_id);
    if (count($deny2) > 0) {
        $q->addWhere('file_task NOT IN (' . implode(',', $deny2) . ')');
    }
    if ($project_id) {
        $q->addWhere('file_project = ' . (int) $project_id);
    }
    if ($task_id) {
        $q->addWhere('file_task = ' . (int) $task_id);
    }
    if ($company_id) {
        $q->addWhere('project_company = ' . (int) $company_id);
    }
    //$tab = ($m == 'files') ? $tab-1 : -1;
    $temp_tab = $m == 'files' ? $tab - 1 : -1;
    if ($temp_tab >= 0 and count($file_types) - 1 > $temp_tab) {
        //if ($tab >= 0) {
        $q->addWhere('file_category = ' . (int) $temp_tab);
    }
    $q->setLimit($xpg_pagesize, $xpg_min);
    if ($folder_id > -1) {
        $q->addWhere('file_folder = ' . (int) $folder_id);
    }
    $q->addGroup('file_version_id DESC');
    $q->addOrder('project_name ASC, file_parent ASC, file_id DESC');
    $qv = new w2p_Database_Query();
    $qv->addTable('files');
    $qv->addQuery('file_id, file_version, file_project, file_name, file_task,
        file_description, file_owner, file_size, file_category,
        task_name, file_version_id, file_date as file_datetime, file_checkout, file_co_reason, file_type,
        file_date, cu.user_username as co_user, project_name,
        project_color_identifier, project_owner, u.user_id,
        con.contact_first_name, con.contact_last_name, con.contact_display_name as contact_name,
        co.contact_first_name as co_contact_first_name, co.contact_last_name as co_contact_last_name,
        co.contact_display_name as co_contact_name ');
    $qv->addJoin('projects', 'p', 'p.project_id = file_project');
    $qv->addJoin('users', 'u', 'u.user_id = file_owner');
    $qv->addJoin('contacts', 'con', 'con.contact_id = u.user_contact');
    $qv->addJoin('tasks', 't', 't.task_id = file_task');
    $qv->addJoin('file_folders', 'ff', 'ff.file_folder_id = file_folder');
    if ($project_id) {
        $qv->addWhere('file_project = ' . (int) $project_id);
    }
    if ($task_id) {
        $qv->addWhere('file_task = ' . (int) $task_id);
    }
    if ($company_id) {
        $qv->addWhere('project_company = ' . (int) $company_id);
    }
    if ($temp_tab >= 0 and count($file_types) - 1 > $temp_tab) {
        //if ($tab >= 0) {
        $qv->addWhere('file_category = ' . (int) $temp_tab);
    }
    $qv->leftJoin('users', 'cu', 'cu.user_id = file_checkout');
    $qv->leftJoin('contacts', 'co', 'co.contact_id = cu.user_contact');
    if ($folder_id > -1) {
        $qv->addWhere('file_folder = ' . (int) $folder_id);
    }
    $files = $q->loadList();
    $file_versions = $qv->loadHashList('file_id');
    $module = new w2p_System_Module();
    $fields = $module->loadSettings('files', 'index_list');
    if (count($fields) > 0) {
        $fieldList = array_keys($fields);
        $fieldNames = array_values($fields);
    } else {
        // TODO: This is only in place to provide an pre-upgrade-safe
        //   state for versions earlier than v3.0
        //   At some point at/after v4.0, this should be deprecated
        $fieldList = array('file_name', 'file_description', 'file_version', 'file_category', 'file_folder', 'file_task', 'file_owner', 'file_datetime');
        $fieldNames = array('File Name', 'Description', 'Version', 'Category', 'Folder', 'Task Name', 'Owner', 'Date');
        $module->storeSettings('files', 'index_list', $fieldList, $fieldNames);
    }
    $s = '<tr>';
    $s .= '<th></th>';
    $s .= '<th>' . $AppUI->_('co') . '</th>';
    foreach ($fieldNames as $index => $name) {
        $s .= '<th>' . $AppUI->_($fieldNames[$index]) . '</th>';
    }
    $s .= '<th></th>';
    $s .= '</tr>';
    $fp = -1;
    $htmlHelper = new w2p_Output_HTMLHelper($AppUI);
    $htmlHelper->df .= ' ' . $AppUI->getPref('TIMEFORMAT');
    $file_types = w2PgetSysVal('FileType');
    $customLookups = array('file_category' => $file_types);
    foreach ($files as $row) {
        $latest_file = $file_versions[$row['latest_id']];
        if ($fp != $latest_file['file_project']) {
            if (!$latest_file['file_project']) {
                $latest_file['project_name'] = $AppUI->_('Not attached to a project');
                $latest_file['project_color_identifier'] = 'f4efe3';
            }
            if ($showProject) {
                $style = 'background-color:#' . $latest_file['project_color_identifier'] . ';color:' . bestColor($latest_file['project_color_identifier']);
                $s .= '<tr>';
                $s .= '<td colspan="20" style="text-align: left; border: outset 2px #eeeeee;' . $style . '">';
                if ($latest_file['file_project'] > 0) {
                    $href = './index.php?m=projects&a=view&project_id=' . $latest_file['file_project'];
                } else {
                    $href = './index.php?m=projects';
                }
                $s .= '<a href="' . $href . '">';
                $s .= '<span style="' . $style . '">' . $latest_file['project_name'] . '</span></a>';
                $s .= '</td></tr>';
            }
        }
        $fp = $latest_file['file_project'];
        $row['file_datetime'] = $latest_file['file_datetime'];
        $row['file_id'] = $latest_file['file_id'];
        $htmlHelper->stageRowData($row);
        $s .= '<tr>';
        $s .= '<td class="data">';
        if ($canEdit && (empty($latest_file['file_checkout']) || $latest_file['file_checkout'] == 'final' && ($canEdit || $latest_file['project_owner'] == $AppUI->user_id))) {
            $s .= '<a href="./index.php?m=files&a=addedit&file_id=' . $latest_file['file_id'] . '">' . w2PshowImage('kedit.png', '16', '16', 'edit file', 'edit file', 'files') . '</a>';
        }
        $s .= '</td>';
        $s .= '<td class="data">';
        if ($canEdit && empty($latest_file['file_checkout'])) {
            $s .= '<a href="?m=files&a=co&file_id=' . $latest_file['file_id'] . '">' . w2PshowImage('up.png', '16', '16', 'checkout', 'checkout file', 'files') . '</a>';
        } else {
            if ($latest_file['file_checkout'] == $AppUI->user_id) {
                $s .= '<a href="?m=files&a=addedit&ci=1&file_id=' . $latest_file['file_id'] . '">' . w2PshowImage('down.png', '16', '16', 'checkin', 'checkin file', 'files') . '</a>';
            } else {
                if ($latest_file['file_checkout'] == 'final') {
                    $s .= 'final';
                } else {
                    $s .= $latest_file['co_contact_name'] . '<br>(' . $latest_file['co_user'] . ')';
                }
            }
        }
        $version_link = '';
        $hidden_table = '';
        if ($row['file_versions'] > 1) {
            $version_link = '&nbsp<a href="javascript: void(0);" onClick="expand(\'versions_' . $latest_file['file_id'] . '\'); ">(' . $row['file_versions'] . ')</a>';
            $hidden_table = '<tr><td colspan="20">
                <table style="display: none" id="versions_' . $latest_file['file_id'] . '" class="tbl list">
                <tr>';
            foreach ($fieldNames as $index => $name) {
                $hidden_table .= '<th nowrap="nowrap">';
                $hidden_table .= $AppUI->_($fieldNames[$index]);
                $hidden_table .= '</th>';
            }
            $hidden_table .= '</tr>';
            $sub_htmlHelper = new w2p_Output_HTMLHelper($AppUI);
            $sub_htmlHelper->df .= ' ' . $AppUI->getPref('TIMEFORMAT');
            foreach ($file_versions as $file) {
                $sub_htmlHelper->stageRowData($file);
                if ($file['file_version_id'] == $latest_file['file_version_id']) {
                    foreach ($fieldList as $index => $column) {
                        $hidden_table .= $sub_htmlHelper->createCell($fieldList[$index], $file[$fieldList[$index]], $customLookups);
                    }
                    if ($canEdit && w2PgetConfig('files_show_versions_edit')) {
                        $hidden_table .= '<a href="./index.php?m=files&a=addedit&file_id=' . $file['file_id'] . '">' . w2PshowImage('kedit.png', '16', '16', 'edit file', 'edit file', 'files') . "</a>";
                    }
                    $hidden_table .= '</td><tr>';
                }
            }
            $hidden_table .= '</table>';
        }
        $s .= '</td>';
        foreach ($fieldList as $index => $column) {
            $cell = $htmlHelper->createCell($fieldList[$index], $row[$fieldList[$index]], $customLookups);
            if ('file_version' == $fieldList[$index]) {
                $cell = str_replace('</td>', $version_link . '</td>', $cell);
            }
            $s .= $cell;
        }
        $s .= '<td>';
        $s .= '<form name="frm_remove_file_' . $latest_file['file_id'] . '" action="?m=files" method="post" accept-charset="utf-8">
            <input type="hidden" name="dosql" value="do_file_aed" />
            <input type="hidden" name="del" value="1" />
            <input type="hidden" name="file_id" value="' . $latest_file['file_id'] . '" />
            <input type="hidden" name="redirect" value="' . $current_uri . '" />
            </form>';
        $s .= '<a href="javascript: void(0);" onclick="if (confirm(\'' . $AppUI->_('Are you sure you want to delete this file?') . '\')) {document.frm_remove_file_' . $latest_file['file_id'] . '.submit()}">' . w2PshowImage('remove.png', '16', '16', 'delete file', 'delete file', 'files') . '</a>';
        $s .= '</td>';
        $s .= '</tr>';
        $s .= $hidden_table;
    }
    if (0 == count($files)) {
        $s .= '<tr><td colspan="' . (count($fieldNames) + 3) . '">' . $AppUI->_('No data available') . '</td></tr>';
    }
    return $s;
}