- Add accessory of selectbox to move accessories between resources

- Remove 'back' button, viewing accessories of a resource now uses nm filter entirely
- Remove view, using read-only edit
This commit is contained in:
Nathan Gray 2012-11-14 18:00:02 +00:00
parent a0a6e14154
commit 0f1b273cb1
5 changed files with 190 additions and 151 deletions

View File

@ -68,6 +68,7 @@ class resources_bo
*/
function get_rows($query,&$rows,&$readonlys)
{
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$query);
if ($query['store_state']) // request to store state in session and filter in prefs?
{
egw_cache::setSession('resources',$query['store_state'],$query);
@ -106,7 +107,7 @@ class resources_bo
$extra_cols[] = 'acc_count';
break;
default:
$filter['accessory_of'] = $query['view_accs_of'];
$filter['accessory_of'] = $query['filter2'];
}
if ($query['filter'])
@ -164,7 +165,7 @@ class resources_bo
$readonlys["delete[$resource[res_id]]"] = true;
$resource['class'] .= 'no_delete ';
}
if ((!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_ADD)) || $accessory_of != -1)
if ((!$this->acl->is_permitted($resource['cat_id'],EGW_ACL_ADD)) || $resource['accessory_of'] != -1)
{
$readonlys["new_acc[$resource[res_id]]"] = true;
$resource['class'] .= 'no_new_accessory ';
@ -438,6 +439,10 @@ class resources_bo
if($options['start'] || $options['num_rows']) {
$limit = array($options['start'], $options['num_rows']);
}
if($options['accessory_of'])
{
$filter['accessory_of'] = $options['accessory_of'];
}
$data = $this->so->search($criteria,$only_keys,$order_by='name',$extra_cols='',$wildcard='%',$empty,$op='OR',$limit,$filter);
// maybe we need to check disponibility of the searched resources in the calendar if $pattern ['exec'] contains some extra args
$show_conflict=False;

View File

@ -20,7 +20,6 @@ class resources_ui
var $public_functions = array(
'index' => True,
'edit' => True,
'show' => True,
'select' => True,
'writeLangFile' => True
);
@ -54,14 +53,6 @@ class resources_ui
unset($sessiondata['rows']);
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata);
if (isset($content['back']))
{
unset($sessiondata['view_accs_of']);
unset($sessiondata['no_filter']);
unset($sessiondata['filter2']);
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata);
return $this->index();
}
if (isset($content['btn_delete_selected']))
{
foreach($content['nm']['rows'] as $row)
@ -82,7 +73,7 @@ class resources_ui
}
if(isset($row['view_acc']))
{
$sessiondata['view_accs_of'] = array_search('pressed',$row['view_acc']);
$sessiondata['filter2'] = array_search('pressed',$row['view_acc']);
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata);
return $this->index();
}
@ -143,7 +134,7 @@ class resources_ui
}
if($_GET['view_accs_of'])
{
$content['nm']['view_accs_of'] = (int)$_GET['view_accs_of'];
$content['nm']['filter2'] = (int)$_GET['view_accs_of'];
}
$content['nm']['actions'] = $this->get_actions();
@ -153,7 +144,6 @@ class resources_ui
$no_button['add'] = true;
}
$no_button['back'] = true;
$no_button['add_sub'] = true;
$GLOBALS['egw_info']['flags']['app_header'] = lang('resources');
$GLOBALS['egw_info']['flags']['java_script'] .= "<script LANGUAGE=\"JavaScript\">
@ -184,16 +174,13 @@ class resources_ui
egw_framework::validate_file('.','resources','resources');
if($content['nm']['view_accs_of'])
if($content['nm']['filter2'] > 0)
{
$master = $this->bo->so->read(array('res_id' => $content['nm']['view_accs_of']));
$content['view_accs_of'] = $content['nm']['filter2'] = $content['nm']['view_accs_of'];
$content['nm']['options-filter2'] = array($master['res_id'] => lang('accessories of') . ' ' . $master['name']);
$master = $this->bo->so->read(array('res_id' => $content['nm']['filter2']));
$content['nm']['options-filter2'] = resources_bo::$filter_options + array(
$master['res_id'] => lang('accessories of') . ' ' . $master['name']
);
$content['nm']['get_rows'] = 'resources.resources_bo.get_rows';
$content['nm']['no_filter'] = true;
$no_button['back'] = false;
$no_button['add'] = true;
$no_button['add_sub'] = false;
$GLOBALS['egw_info']['flags']['app_header'] = lang('resources') . ' - ' . lang('accessories of '). ' '. $master['name'] .
($master['short_description'] ? ' [' . $master['short_description'] . ']' : '');
}
@ -221,13 +208,6 @@ class resources_ui
'group' => $group=1,
'disableClass' => 'rowNoEdit',
),
'view' => array(
'caption' => 'View',
'allowOnMultiple' => false,
'url' => 'menuaction=resources.resources_ui.show&res_id=$id',
'popup' => egw_link::get_registry('resources', 'view_popup'),
'group' => $group,
),
'view-acc' => array(
'caption' => 'View accessories',
'icon' => 'view_acc',
@ -239,7 +219,7 @@ class resources_ui
'add' => array(
'caption' => 'Add',
'caption' => 'New resource',
'url' => 'menuaction=resources.resources_ui.edit',
'popup' => egw_link::get_registry('resources', 'add_popup'),
'group' => $group,
@ -266,10 +246,12 @@ class resources_ui
),
'new_accessory' => array(
'caption' => 'New accessory',
'icon' => 'new',
'group' => $group,
'url' => 'menuaction=resources.resources_ui.edit&res_id=0&accessory_of=$id',
'popup' => egw_link::get_registry('resources', 'add_popup'),
'disableClass' => 'no_new_accessory',
'allowOnMultiple' => false
),
/*
'documents' => resources_merge::document_action(
@ -458,90 +440,28 @@ class resources_ui
$catofmaster = $this->bo->so->get_value('cat_id',$content['accessory_of']);
$sel_options['cat_id'] = array($catofmaster => $sel_options['cat_id'][$catofmaster]);
}
$search_options = array('accessory_of' => -1);
$sel_options['accessory_of'] = $this->bo->link_query('',$search_options);
if($res_id) unset($sel_options['accessory_of'][$res_id]);
// $content['general|page|pictures|links'] = 'resources.edit_tabs.page'; //debug
$no_button = array(); // TODO: show delete button only if allowed to delete resource
// Permissions
$read_only = array();
if($res_id && !$this->bo->acl->is_permitted($content['cat_id'],EGW_ACL_EDIT))
{
$read_only['__ALL__'] = true;
}
if(!$this->bo->acl->is_permitted($content['cat_id'],EGW_ACL_DELETE))
{
$read_only['delete'] = true;
}
// Disable accessories tab for accessories
$readonly['tabs']['accessories'] = ($content['accessory_of'] != -1);
$preserv = $content;
$this->tmpl->read('resources.edit');
return $this->tmpl->exec('resources.resources_ui.edit',$content,$sel_options,$no_button,$preserv,2);
}
/**
* showes a single resource
*
* @param int $res_id resource id
* @author Lukas Weiss <wnz.gh05t@users.sourceforge.net>
*/
function show($res_id=0)
{
if (is_array($content = $res_id))
{
if(isset($content['btn_delete']))
{
$content['msg'] = $this->bo->delete($content['res_id']);
if($content['msg'])
{
return $this->show($content);
}
$js = "opener.location.href='".$GLOBALS['egw']->link('/index.php',
array('menuaction' => 'resources.resources_ui.index'))."';";
$js .= 'window.close();';
echo "<html><body><script>$js</script></body></html>\n";
$GLOBALS['egw']->common->egw_exit();
}
if(isset($content['btn_edit']))
{
return $this->edit($content['res_id']);
}
}
if (isset($_GET['res_id'])) $res_id = $_GET['res_id'];
$content = array('res_id' => $res_id);
$content = $this->bo->read($res_id);
$content['gen_src_list'] = strpos($content['picture_src'],'.') !== false ? $content['picture_src'] : false;
$content['picture_src'] = strpos($content['picture_src'],'.') !== false ? 'gen_src' : $content['picture_src'];
$content['link_to'] = array(
'to_id' => $res_id,
'to_app' => 'resources'
);
$content['resource_picture'] = $this->bo->get_picture($content['res_id'],$content['picture_src'],$size=true);
$content['quantity'] = $content['quantity'] ? $content['quantity'] : 1;
$content['useable'] = $content['useable'] ? $content['useable'] : 1;
$content['quantity'] = ($content['useable'] == $content['quantity']) ? $content['quantity'] : $content['quantity'].' ('.lang('useable').' '.$content['useable'].')';
//$sel_options['gen_src_list'] = $this->bo->get_genpicturelist();
$content['cat_name'] = $this->bo->acl->get_cat_name($content['cat_id']);
$content['cat_admin'] = $this->bo->acl->get_cat_admin($content['cat_id']);
/* if($content['accessory_of'] > 0)
{
$catofmaster = $this->bo->so->get_value('cat_id',$content['accessory_of']);
$sel_options['cat_id'] = array($catofmaster => $sel_options['cat_id'][$catofmaster]);
}
*/
$content['description'] = chop($content['long_description']) ? $content['long_description'] : (chop($content['short_description']) ? $content['short_description'] : lang("no description available"));
$content['description'] = $content['description'] ? $content['description'] : lang('no description available');
$content['link_to'] = array(
'to_id' => $res_id,
'to_app' => 'resources'
);
$sel_options = array();
$no_button = array(
'btn_buy' => !$content['buyable'],
'btn_book' => !$content['bookable'],
'btn_calendar' => !$content['bookable'],
'btn_edit' => !$this->bo->acl->is_permitted($content['cat_id'],EGW_ACL_EDIT),
'btn_delete' => !$this->bo->acl->is_permitted($content['cat_id'],EGW_ACL_DELETE)
);
$preserv = $content;
$this->tmpl->read('resources.showdetails');
return $this->tmpl->exec('resources.resources_ui.show',$content,$sel_options,$no_button,$preserv,2);
return $this->tmpl->exec('resources.resources_ui.edit',$content,$sel_options,$read_only,$preserv,2);
}
/**

File diff suppressed because one or more lines are too long

View File

@ -1,60 +1,162 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="resources.edit.general" template="" lang="" group="0" version="">
<grid>
<template id="resources.edit_tabs.general" template="" lang="" group="0" version="">
<grid width="700" height="380">
<columns>
<column/>
<column/>
<column width="10"/>
<column/>
</columns>
<rows>
<row>
<description value="Description (short)"/>
<textbox statustext="Short description of resource" id="short_description" size="50" maxlength="100"/>
<description/>
<description value="Short description of resource"/>
</row>
<row>
<description value="Location"/>
<textbox statustext="Location of resource" id="location" size="50" maxlength="100"/>
<description/>
<description value="Where to find this resource?"/>
</row>
<row>
<description value="Storage information"/>
<textbox statustext="Information about storage" id="storage_info" size="50" maxlength="100"/>
<description/>
<description value="Information about storage"/>
</row>
<row>
<description value="Quantity"/>
<textbox statustext="Quantity of resource" id="quantity" size="5" maxlength="10"/>
<description/>
<description value="Quantity of resource"/>
</row>
<row>
<description value="Useable"/>
<textbox statustext="How many of them are useable?" id="useable" size="5" maxlength="10"/>
<description/>
<description value="How many of the resources are useable?"/>
</row>
<row>
<description value="Bookable"/>
<checkbox statustext="Is resource bookable?" id="bookable"/>
<description/>
<description value="Is this resource bookable?"/>
</row>
<row>
<description disabled="true" value="Buyable"/>
<checkbox disabled="true" statustext="Is resource buyable?" id="buyable"/>
<description/>
<description disabled="true" value="Is this resource buyable?"/>
</row>
<row height="100%">
<description/>
<description/>
<description/>
<description/>
</row>
</rows>
</grid>
</template>
<template id="resources.edit.page" template="" lang="" group="0" version="">
<grid>
<template id="resources.edit_tabs.page" template="" lang="" group="0" version="">
<grid width="100%" height="380">
<columns>
<column/>
</columns>
<rows>
<row valign="top">
<htmlarea statustext="Web-Site for this resource" id="long_description" mode="simple" height="350px" width="700px" toolbar="true"/>
</row>
</rows>
</grid>
</template>
<template id="resources.edit_tabs.pictures" template="" lang="" group="0" version="">
<grid width="700" height="380">
<columns>
<column/>
</columns>
<rows>
<row valign="top">
<hbox>
<vbox>
<image src="resource_picture"/>
<description/>
</vbox>
<groupbox>
<caption label="picture source"/>
<grid>
<columns>
<column/>
<column/>
<column/>
</columns>
<rows>
<row>
<description align="right" value="Use general resources icon"/>
<radio id="picture_src" options="gen_src"/>
<menulist>
<menupopup id="gen_src_list" no_lang="1"/>
</menulist>
</row>
<row>
<description align="right" value="Use the category's icon"/>
<radio id="picture_src" options="cat_src"/>
<description/>
</row>
<row>
<description align="right" value="Use own picture"/>
<radio id="picture_src" options="own_src"/>
<file id="own_file"/>
</row>
</rows>
</grid>
</groupbox>
</hbox>
</row>
<row height="100%">
<description/>
</row>
</rows>
</grid>
</template>
<template id="resources.edit.pictures" template="" lang="" group="0" version="">
<grid>
<template id="resources.edit_tabs.links" template="" lang="" group="0" version="">
<grid width="700" height="380">
<columns>
<column width="100"/>
<column/>
</columns>
<rows>
<row>
<row class="th">
<description value="Create new links" span="all"/>
</row>
<row class="row">
<link-to id="link_to" span="all"/>
</row>
<row class="th">
<description value="Existing links" span="all"/>
</row>
<row class="row_off" valign="top" height="164">
<link-list id="link_to" span="all"/>
</row>
<row height="100%">
<description/>
<description/>
</row>
</rows>
</grid>
</template>
<template id="resources.edit.links" template="" lang="" group="0" version="">
<grid>
<template id="resources.edit_tabs.custom" template="" lang="" group="0" version="">
<grid width="700" height="380">
<columns>
<column/>
</columns>
<rows>
<row>
<description/>
<row valign="top">
<customfields/>
</row>
</rows>
</grid>
</template>
<template id="resources.edit.custom" template="" lang="" group="0" version="">
<grid>
<columns>
<column/>
</columns>
<rows>
<row>
<description/>
</row>
@ -70,20 +172,20 @@
</columns>
<rows>
<row class="row_off">
<tabbox span="all">
<tabbox id="general|page|pictures|links|custom" span="all">
<tabs>
<tab label="General" statustext="General informations about resource"/>
<tab label="Description" statustext="Informations about the location of resource"/>
<tab label="Picture" statustext="Prizeing information for booking or buying"/>
<tab label="Links" statustext="Web-Page of resource"/>
<tab label="Custom" statustext="Pictures or resource"/>
<tab id="general" label="General" statustext="General informations about resource"/>
<tab id="page" label="Description" statustext="Informations about the location of resource"/>
<tab id="pictures" label="Picture" statustext="Prizeing information for booking or buying"/>
<tab id="links" label="Links" statustext="Web-Page of resource"/>
<tab id="custom" label="Custom" statustext="Pictures or resource"/>
</tabs>
<tabpanels>
<template id="resources.edit.general"/>
<template id="resources.edit.page"/>
<template id="resources.edit.pictures"/>
<template id="resources.edit.links"/>
<template id="resources.edit.custom"/>
<template id="resources.edit_tabs.general"/>
<template id="resources.edit_tabs.page"/>
<template id="resources.edit_tabs.pictures"/>
<template id="resources.edit_tabs.links"/>
<template id="resources.edit_tabs.custom"/>
</tabpanels>
</tabbox>
</row>
@ -102,9 +204,9 @@
</columns>
<rows>
<row>
<button label="Save" id="save" statustext="Saves entry and exits"/>
<button statustext="Saves entry and exits" label="Save" id="save"/>
<button label="Cancel" onclick="window.close();"/>
<button label="Delete" align="right" id="delete" onclick="return confirm('Do you really want do delte this resource?');"/>
<button align="right" label="Delete" id="delete" onclick="return confirm('Do you really want do delte this resource?');"/>
</row>
</rows>
</grid>
@ -116,14 +218,14 @@
</columns>
<rows>
<row>
<description no_lang="1" id="msg"/>
<description id="msg" no_lang="1"/>
</row>
<row>
<hbox>
<textbox label="Name" id="name" statustext="Name of resource" needed="1"/>
<textbox statustext="Name of resource" label="Name" id="name" needed="1"/>
<textbox label="Inventory number" id="inventory_number"/>
<menulist>
<menupopup label="Category" no_lang="1" id="cat_id" needed="1" statustext="Which category does this resource belong to?" align="right"/>
<menupopup align="right" statustext="Which category does this resource belong to?" label="Category" id="cat_id" needed="1" no_lang="1"/>
</menulist>
</hbox>
</row>

View File

@ -13,7 +13,7 @@
</rows>
</grid>
</template>
<template id="resources.show.rows" template="" lang="" group="0" version="1.9.001">
<template id="resources.show.rows" template="" lang="" group="0" version="1.9.002">
<grid width="100%">
<columns>
<column/>
@ -86,7 +86,7 @@
<button align="center" statustext="Book this resource" label="Book this resource" id="bookable[$cont[res_id]]" onclick="window.open(egw::link('/index.php','menuaction=calendar.calendar_uiforms.edit&amp;participants=r$cont[res_id]'),'','dependent=yes,width=750,height=400,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;" image="navbar" ro_image="trams16x16" class="image16"/>
<button align="center" statustext="Edit this entry" label="Edit" id="edit[$cont[res_id]]" onclick="window.open(egw::link('/index.php','menuaction=resources.resources_ui.edit&amp;res_id=$cont[res_id]'),'','dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;" image="edit" ro_image="trans16x16"/>
<button align="center" statustext="Create new accessory for this resource" label="Create new accessory for this resource" id="new_acc[$cont[res_id]]" onclick="window.open(egw::link('/index.php','menuaction=resources.resources_ui.edit&amp;res_id=0&amp;accessory_of=$cont[res_id]'),'','dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;" image="new" ro_image="trans16x16"/>
<button align="right" statustext="View this entry" label="View" id="view[$cont[res_id]]" onclick="window.open(egw::link('/index.php','menuaction=resources.resources_ui.show&amp;res_id=$cont[res_id]'),'','dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;" image="view" ro_image="trans16x16"/>
<description/>
</row>
<row>
<button align="center" statustext="Show calendar of resource" label="Show calendar of resource" id="calendar[$cont[res_id]]" onclick="location=egw::link('/index.php','menuaction=calendar.calendar_uiviews.planner&amp;sortby=user&amp;owner=0,r$cont[res_id]'); return false;" image="calendar/planner" ro_image="trans16x16"/>