More Home progress:

- Add support for timesheet favorites
This commit is contained in:
Nathan Gray 2014-11-28 18:03:13 +00:00
parent c869407836
commit 978b5f4ffd
3 changed files with 227 additions and 1 deletions

View File

@ -0,0 +1,139 @@
<?php
/*
* Egroupware - Addressbook - A portlet for displaying a list of entries
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package timesheet
* @subpackage home
* @link http://www.egroupware.org
* @author Nathan Gray
* @version $Id$
*/
/**
* The timesheet_list_portlet uses a nextmatch / favorite
* to display a list of entries.
*/
class timesheet_favorite_portlet extends home_favorite_portlet
{
/**
* Construct the portlet
*
*/
public function __construct(Array &$context = array(), &$need_reload = false)
{
$context['appname'] = 'timesheet';
// Let parent handle the basic stuff
parent::__construct($context,$need_reload);
$ui = new timesheet_ui();
$this->context['template'] = 'timesheet.index.rows';
$this->nm_settings += array(
'get_rows' => 'timesheet_favorite_portlet::get_rows',
// Use a different template so it can be accessed from client side
'template' => 'timesheet.index.rows',
// Use a reduced column set for home, user can change if needed
'default_cols' => 'ts_id,ts_start,ts_project_pm_id_linked_ts_title,ts_duration_duration',
'row_id' => 'ts_id',
'row_modified' => 'ts_modified',
);
}
public function exec($id = null, etemplate_new &$etemplate = null)
{
$ui = new timesheet_ui();
$date_filters = array('All');
foreach(array_keys($ui->date_filters) as $name)
{
$date_filters[$name] = $name;
}
$date_filters['custom'] = 'custom';
$this->context['sel_options']['filter'] = $date_filters;
$this->context['sel_options']['filter2'] = array('No details','Details');
$read_grants = $ui->grant_list(EGW_ACL_READ);
$this->context['sel_options'] += array(
'ts_owner' => $read_grants,
'pm_id' => array(lang('No project')),
'cat_id' => array(array('value' => '', 'label' => lang('all')), array('value' => 0, 'label'=>lang('None'))),
'ts_status' => $ui->status_labels+array(lang('No status')),
);
$this->nm_settings['actions'] = $ui->get_actions($this->nm_settings);
parent::exec($id, $etemplate);
}
/**
* Override from timesheet to clear the app header
*
* @param type $query
* @param type $rows
* @param type $readonlys
* @return integer Total rows found
*/
public static function get_rows(&$query, &$rows, &$readonlys)
{
$ui = new timesheet_ui();
$total = $ui->get_rows($query, $rows, $readonlys);
unset($GLOBALS['egw_info']['flags']['app_header']);
return $total;
}
/**
* Here we need to handle any incoming data. Setup is done in the constructor,
* output is handled by parent.
*
* @param type $id
* @param etemplate_new $etemplate
*/
public static function process($content = array())
{
parent::process($content);
$ui = new timesheet_ui();
// This is just copy+pasted from timesheet_ui line 816, but we don't want
// the etemplate exec to fire again.
if (is_array($content) && isset($content['nm']['rows']['document'])) // handle insert in default document button like an action
{
list($id) = @each($content['nm']['rows']['document']);
$content['nm']['action'] = 'document';
$content['nm']['selected'] = array($id);
}
if ($content['nm']['action'])
{
// remove sum-* rows from checked rows
$content['nm']['selected'] = array_filter($content['nm']['selected'], function($id)
{
return $id > 0;
});
if (!count($content['nm']['selected']) && !$content['nm']['select_all'])
{
$msg = lang('You need to select some entries first!');
}
else
{
$success = $failed = $action_msg = null;
if ($ui->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
$success,$failed,$action_msg,'index',$msg))
{
$msg .= lang('%1 timesheets(s) %2',$success,$action_msg);
foreach($values['nm']['selected'] as &$id)
{
$id = 'timesheet::'.$id;
}
// Directly request an update - this will get timesheet tab too
egw_json_response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected']));
}
elseif(empty($msg))
{
$msg .= lang('%1 timesheets(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
}
}
}
}
}

View File

@ -917,7 +917,7 @@ class timesheet_ui extends timesheet_bo
*
* @return array see nextmatch_widget::egw_actions()
*/
private function get_actions(Array $query)
public function get_actions(Array $query)
{
$actions = array(
'open' => array( // does edit if allowed, otherwise view

View File

@ -0,0 +1,87 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<!-- This template is in a seperate file so etemplate can find it for home -->
<overlay>
<template id="timesheet.index.rows" template="" lang="" group="0" version="1.9.001">
<grid width="100%">
<columns>
<column width="50"/>
<column width="135"/>
<column width="70%"/>
<column width="15%"/>
<column width="60"/>
<column width="60" disabled="@no_ts_quantity"/>
<column width="60" disabled="@no_ts_unitprice"/>
<column width="60" disabled="@no_ts_total"/>
<column width="130" disabled="@no_owner_col"/>
<column width="10%" disabled="@no_ts_status"/>
<column width="15%"/>
</columns>
<rows>
<row class="th">
<nextmatch-sortheader label="ID" id="ts_id"/>
<nextmatch-sortheader label="Date" id="ts_start"/>
<grid spacing="0" padding="0">
<columns>
<column/>
</columns>
<rows>
<row disabled="@pm_integration=full">
<nextmatch-filterheader id="ts_project" no_lang="1" options="All projects" search="false"/>
</row>
<row disabled="!@pm_integration=full">
<nextmatch-entryheader id="pm_id" no_lang="1" blur="All projects" only_app="projectmanager"/>
</row>
<row>
<nextmatch-entryheader id="linked"/>
</row>
<row>
<nextmatch-sortheader label="Title" id="ts_title"/>
</row>
</rows>
</grid>
<nextmatch-sortheader label="Category" id="cat_id"/>
<vbox>
<nextmatch-sortheader label="Duration" id="ts_duration"/>
<date-duration id="duration" readonly="true" options=",h,,,1"/>
</vbox>
<vbox>
<nextmatch-sortheader label="Quantity" id="ts_quantity"/>
<textbox type="float" id="quantity" readonly="true" precision="3"/>
</vbox>
<nextmatch-sortheader label="Price" id="ts_unitprice"/>
<vbox>
<nextmatch-sortheader label="Total" id="ts_total"/>
<textbox type="float" id="price" readonly="true" precision="2"/>
</vbox>
<nextmatch-filterheader id="ts_owner" no_lang="1" options="User" class="$cont[ownerClass]"/>
<nextmatch-filterheader id="ts_status" options="Status"/>
<nextmatch-customfields id="customfields"/>
</row>
<row class="$row_cont[cat_id] $row_cont[class]">
<description id="${row}[ts_id]"/>
<date-time id="${row}[ts_start]" readonly="true" options=",8"/>
<vbox>
<link id="${row}[ts_link]" no_lang="1"/>
<description id="${row}[ts_title]" no_lang="1" class="ts_title $row_cont[titleClass]"/>
<description id="${row}[ts_description]" class="ts_description" no_lang="1"/>
</vbox>
<menulist class="noWrap">
<menupopup type="select-cat" id="${row}[cat_id]" readonly="true"/>
</menulist>
<date-duration id="${row}[ts_duration]" readonly="true" options=",h,,,1" align="right"/>
<textbox type="float" id="${row}[ts_quantity]" no_lang="1" readonly="true" precision="3"/>
<description id="${row}[ts_unitprice]" no_lang="1"/>
<textbox type="float" id="${row}[ts_total]" no_lang="1" readonly="true" precision="2"/>
<menulist class="$cont[ownerClass]">
<menupopup type="select-account" id="${row}[ts_owner]" readonly="true"/>
</menulist>
<menulist>
<menupopup id="${row}[ts_status]" readonly="true"/>
</menulist>
<customfields-list id="$row" readonly="true"/>
</row>
</rows>
</grid>
</template>
</overlay>