return $result;
}
+ // getActiveProjectsWithFiles - returns an array of active projects for a group
+ // with information whether they have attached files (has_files property).
+ // A separate fiunction from getActiveProjects because sql here is more complex.
+ static function getActiveProjectsWithFiles()
+ {
+ global $user;
+ $mdb2 = getConnection();
+
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
+ $sql = "select p.id, p.name, if(Sub1.entity_id is null, 0, 1) as has_files from tt_projects p".
+ " left join (select distinct entity_id from tt_files".
+ " where entity_type = 'project' and group_id = $group_id and org_id = $org_id and status = 1) Sub1".
+ " on (p.id = Sub1.entity_id)".
+ " where p.group_id = $group_id and p.org_id = $org_id and p.status = 1 order by upper(p.name)";
+ $res = $mdb2->query($sql);
+ $result = array();
+ if (!is_a($res, 'PEAR_Error')) {
+ while ($val = $res->fetchRow()) {
+ $result[] = $val;
+ }
+ }
+ return $result;
+ }
+
// getInactiveProjects - returns an array of inactive projects for a group.
static function getInactiveProjects()
{
return $result;
}
+ // getInactiveProjectsWithFiles - returns an array of inactive projects for a group
+ // with information whether they have attached files (has_files property).
+ // A separate fiunction from getInactiveProjects because sql here is more complex.
+ static function getInactiveProjectsWithFiles()
+ {
+ global $user;
+ $mdb2 = getConnection();
+
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
+ $sql = "select p.id, p.name, if(Sub1.entity_id is null, 0, 1) as has_files from tt_projects p".
+ " left join (select distinct entity_id from tt_files".
+ " where entity_type = 'project' and group_id = $group_id and org_id = $org_id and status = 1) Sub1".
+ " on (p.id = Sub1.entity_id)".
+ " where p.group_id = $group_id and p.org_id = $org_id and p.status = 0 order by upper(p.name)";
+ $res = $mdb2->query($sql);
+ $result = array();
+ if (!is_a($res, 'PEAR_Error')) {
+ while ($val = $res->fetchRow()) {
+ $result[] = $val;
+ }
+ }
+ return $result;
+ }
+
// getPredefinedExpenses - obtains predefined expenses for a group.
static function getPredefinedExpenses() {
global $user;
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.64.4914 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.64.4915 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
<td>{$project.name|escape}</td>
<td>{$project.description|escape}</td>
{if $show_files}
+ {if $project.has_files}
<td><a href="project_files.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.files}" src="images/icon_files.png"></a></td>
+ {else}
+ <td><a href="project_files.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.files}" src="images/icon_file.png"></a></td>
+ {/if}
{/if}
<td><a href="project_edit.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.edit}" src="images/icon_edit.png"></a></td>
<td><a href="project_delete.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.delete}" src="images/icon_delete.png"></a></td>
<td>{$project.name|escape}</td>
<td>{$project.description|escape}</td>
{if $show_files}
+ {if $project.has_files}
<td><a href="project_files.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.files}" src="images/icon_files.png"></a></td>
+ {else}
+ <td><a href="project_files.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.files}" src="images/icon_file.png"></a></td>
+ {/if}
{/if}
<td><a href="project_edit.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.edit}" src="images/icon_edit.png"></a></td>
<td><a href="project_delete.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.delete}" src="images/icon_delete.png"></a></td>
}
// End of access checks.
+$showFiles = $user->isPluginEnabled('at');
+
if($user->can('manage_projects')) {
- $active_projects = ttGroupHelper::getActiveProjects();
- $inactive_projects = ttGroupHelper::getInactiveProjects();
+ $active_projects = $showFiles ? ttGroupHelper::getActiveProjectsWithFiles() : ttGroupHelper::getActiveProjects();
+ $inactive_projects = $showFiles ? ttGroupHelper::getInactiveProjectsWithFiles() : ttGroupHelper::getInactiveProjects();
} else
$active_projects = $user->getAssignedProjects();