mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 08:34:42 +01:00
Migrate Reources app from etemplate old to et2
This commit is contained in:
parent
0cc75cb3e6
commit
7de85d97c9
@ -31,10 +31,10 @@ class resources_ui
|
||||
function __construct()
|
||||
{
|
||||
// print_r($GLOBALS['egw_info']); die();
|
||||
$this->tmpl = new etemplate('resources.show');
|
||||
$this->tmpl = new etemplate_new('resources.show');
|
||||
$this->bo = new resources_bo();
|
||||
// $this->calui = CreateObject('resources.ui_calviews');
|
||||
|
||||
//egw_framework::csp_script_src_attrs(array('unsafe-eval', 'unsafe-inline'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -156,32 +156,6 @@ class resources_ui
|
||||
$no_button['back'] = true;
|
||||
$GLOBALS['egw_info']['flags']['app_header'] = lang('resources');
|
||||
|
||||
$GLOBALS['egw_info']['flags']['java_script'] .= "<script LANGUAGE=\"JavaScript\">
|
||||
function js_btn_book_selected(form)
|
||||
{
|
||||
resources = '';
|
||||
|
||||
el = form.getElementsByTagName(\"input\");
|
||||
for (var i = 0; i < el.length; i++)
|
||||
{
|
||||
if(el[i].name.substr(el[i].name.length-12,el[i].name.length) == '[checkbox][]' && el[i].checked)
|
||||
{
|
||||
if(resources.length > 0)
|
||||
{
|
||||
resources += ',';
|
||||
}
|
||||
resources += 'r' + el[i].value;
|
||||
}
|
||||
}
|
||||
if(resources.length == 0)
|
||||
{
|
||||
alert('". lang('No resources selected'). "');
|
||||
return false;
|
||||
}
|
||||
return resources;
|
||||
}
|
||||
</script>";
|
||||
|
||||
egw_framework::validate_file('.','resources','resources');
|
||||
|
||||
if($content['nm']['filter2'] > 0)
|
||||
@ -257,6 +231,7 @@ class resources_ui
|
||||
'group' => ++$group,
|
||||
'allowOnMultiple' => true,
|
||||
'disableClass' => 'no_view_calendar',
|
||||
'onExecute' => 'javaScript:app.resources.view_calendar',
|
||||
),
|
||||
'book' => array(
|
||||
'caption' => 'Book resource',
|
||||
@ -264,14 +239,9 @@ class resources_ui
|
||||
'group' => $group,
|
||||
'allowOnMultiple' => true,
|
||||
'disableClass' => 'no_book',
|
||||
'onExecute' => 'javaScript:app.resources.book',
|
||||
),
|
||||
/*
|
||||
'documents' => resources_merge::document_action(
|
||||
$GLOBALS['egw_info']['user']['preferences']['resources']['document_dir'],
|
||||
++$group, 'Insert in document', 'document_',
|
||||
$GLOBALS['egw_info']['user']['preferences']['resources']['default_document']
|
||||
),
|
||||
*/
|
||||
|
||||
'delete' => array(
|
||||
'caption' => 'Delete',
|
||||
'group' => ++$group,
|
||||
@ -327,35 +297,6 @@ class resources_ui
|
||||
|
||||
switch($action)
|
||||
{
|
||||
case 'view-calendar':
|
||||
$resource_ids = array(0);
|
||||
$url_params = array(
|
||||
'menuaction' => 'calendar.calendar_uiviews.planner',
|
||||
'sortby' => 'user',
|
||||
);
|
||||
foreach($checked as $n => $id)
|
||||
{
|
||||
$resource_ids[] = 'r'.$id;
|
||||
}
|
||||
$url_params['owner'] = implode(',',$resource_ids);
|
||||
$success = count($resource_ids);
|
||||
egw_framework::set_onload('window.location.href = "'.egw::link('/index.php',$url_params,'calendar').'"');
|
||||
$action_msg = lang('view calendar');
|
||||
break;
|
||||
case 'book':
|
||||
$resource_ids = array();
|
||||
$url_params = array(
|
||||
'menuaction' => 'calendar.calendar_uiforms.edit'
|
||||
);
|
||||
foreach($checked as $n => $id)
|
||||
{
|
||||
$resource_ids[] = 'r'.$id;
|
||||
}
|
||||
$url_params['participants'] = implode(',',$resource_ids);
|
||||
$success = count($resource_ids);
|
||||
egw_framework::set_onload("egw_openWindowCentered2('".egw::link('/index.php',$url_params) ."','_blank');");
|
||||
$action_msg = lang('booked');
|
||||
break;
|
||||
case 'restore':
|
||||
$action_msg = lang('restored');
|
||||
foreach($checked as $n=>$id)
|
||||
@ -491,8 +432,10 @@ class resources_ui
|
||||
$acc_count = count($this->bo->get_acc_list($content['res_id']));
|
||||
}
|
||||
$result = $this->bo->save($content);
|
||||
|
||||
if(is_numeric($result))
|
||||
{
|
||||
$msg = lang('Resource %1 saved!',$result);
|
||||
$content['res_id'] = $result;
|
||||
if($acc_count && $content['accessory_of'] != -1)
|
||||
{
|
||||
@ -504,24 +447,22 @@ class resources_ui
|
||||
{
|
||||
$msg = $result;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'delete':
|
||||
unset($content['delete']);
|
||||
$msg = $this->bo->delete($content['res_id']);
|
||||
break;
|
||||
}
|
||||
$js = "var win = opener || egw.window; win.egw_refresh('".str_replace("'","\\'",$msg)."','resources',{$content['res_id']}, '" .
|
||||
($button == 'delete' ? 'delete' : 'edit') . "');";
|
||||
if($button != 'apply' && !$msg)
|
||||
|
||||
egw_framework::refresh_opener($msg, 'resources',$content['res_id'],(button == 'delete' ? 'delete' : 'edit'));
|
||||
|
||||
if($button != 'apply')
|
||||
{
|
||||
$js .= 'window.close();';
|
||||
echo "<html><body><script>$js</script></body></html>\n";
|
||||
egw_framework::window_close();
|
||||
$GLOBALS['egw']->common->egw_exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['egw_info']['flags']['java_script'] .= "<script>$js</script>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$nm_session_data = $GLOBALS['egw']->session->appsession('session_data','resources_index_nm');
|
||||
@ -625,144 +566,6 @@ class resources_ui
|
||||
return $this->tmpl->exec('resources.resources_ui.edit',$content,$sel_options,$read_only,$preserv,2);
|
||||
}
|
||||
|
||||
/**
|
||||
* select resources
|
||||
*
|
||||
* @author Lukas Weiss <wnz.gh05t@users.sourceforge.net>
|
||||
*/
|
||||
function select($content='')
|
||||
{
|
||||
$GLOBALS['phpgw']->js->set_onload("copyOptions('exec[resources][selectbox]');");
|
||||
|
||||
$GLOBALS['egw_info']['flags']['java_script'] .= "<script LANGUAGE=\"JavaScript\">
|
||||
window.focus();
|
||||
|
||||
openerid='resources_selectbox';
|
||||
id='exec[nm][rows][selectbox]';
|
||||
|
||||
function addOption(label,value,button_id,useable)
|
||||
{
|
||||
var quantity = document.getElementById(button_id+'[default_qty]').value;
|
||||
value = value+':'+quantity;
|
||||
if(quantity>useable) {
|
||||
alert('".lang('You chose more resources than available')."');
|
||||
return false;
|
||||
}
|
||||
label = label+'['+quantity+'/'+useable+']';
|
||||
openerSelectBox = opener.document.getElementById(openerid);
|
||||
if (openerSelectBox) {
|
||||
select = '';
|
||||
for(i=0; i < openerSelectBox.length; i++) {
|
||||
with (openerSelectBox.options[i]) {
|
||||
if (selected || openerSelectBox.selectedIndex == i) {
|
||||
select += (value.slice(0,1)==',' ? '' : ',')+value;
|
||||
}
|
||||
}
|
||||
}
|
||||
select += (select ? ',' : '')+value;
|
||||
opener.selectbox_add_option(openerid,label,value,0);
|
||||
}
|
||||
selectBox = document.getElementById(id);
|
||||
if (selectBox) {
|
||||
var resource_value = value.split(':');
|
||||
for (i=0; i < selectBox.length; i++) {
|
||||
var selectvalue = selectBox.options[i].value.split(':');
|
||||
if (selectvalue[0] == resource_value[0]) {
|
||||
selectBox.options[i] = null;
|
||||
selectBox.options[selectBox.length] = new Option(label,value,false,true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i >= selectBox.length) {
|
||||
selectBox.options[selectBox.length] = new Option(label,value,false,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeSelectedOptions()
|
||||
{
|
||||
openerSelectBox = opener.document.getElementById(openerid);
|
||||
if (openerSelectBox == null) window.close();
|
||||
selectBox = document.getElementById(id);
|
||||
for (i=0; i < selectBox.length; i++) {
|
||||
if (selectBox.options[i].selected) {
|
||||
for (j=0; j < openerSelectBox.length; j++) {
|
||||
if (openerSelectBox[j].value == selectBox.options[i].value) {
|
||||
openerSelectBox.removeChild(openerSelectBox[j]);
|
||||
}
|
||||
}
|
||||
selectBox.options[i--] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function copyOptions()
|
||||
{
|
||||
openerSelectBox = opener.document.getElementById(openerid);
|
||||
selectBox = document.getElementById(id);
|
||||
for (i=0; i < openerSelectBox.length; i++) {
|
||||
with (openerSelectBox.options[i]) {
|
||||
if (selected && value.slice(0,1) != ',') {
|
||||
selectBox.options[selectBox.length] = new Option(text,value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function oneLineSubmit()
|
||||
{
|
||||
/*
|
||||
openerSelectBox = opener.document.getElementById(openerid);
|
||||
|
||||
if (openerSelectBox) {
|
||||
if (openerSelectBox.selectedIndex >= 0) {
|
||||
selected = openerSelectBox.options[openerSelectBox.selectedIndex].value;
|
||||
if (selected.slice(0,1) == ',') selected = selected.slice(1);
|
||||
opener.selectbox_add_option(openerid,'multiple*',selected,1);
|
||||
}
|
||||
else {
|
||||
for (i=0; i < openerSelectBox.length; i++) {
|
||||
with (openerSelectBox.options[i]) {
|
||||
if (selected) {
|
||||
opener.selectbox_add_option(openerid,text,value,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
window.close();
|
||||
}</script>";
|
||||
|
||||
if (!is_array($content))
|
||||
{
|
||||
if (!($content['nm'] = egw_cache::getSession('resources','get_rows')))
|
||||
{
|
||||
$content['nm'] = array(
|
||||
'header_left' => 'resources.resource_select.header',
|
||||
'show_bookable' => true,
|
||||
'get_rows' => 'resources.resources_bo.get_rows',
|
||||
'filter_label' => 'Category',
|
||||
'filter_help' => lang('Select a category'),
|
||||
'options-filter'=> array(''=>lang('all categories'))+(array)$this->bo->acl->get_cats(EGW_ACL_READ),
|
||||
'no_filter2' => true,
|
||||
'filter_no_lang'=> true,
|
||||
'no_cat' => true,
|
||||
'rows' => array('js_id' => 1),
|
||||
'csv_fields' => false,
|
||||
'default_cols' => 'name,cat_id,quantity', // I columns to use if there's no user or default pref
|
||||
'store_state' => 'get_rows', // store in session as for location get_rows
|
||||
);
|
||||
$content['nm']['filter'] = $GLOBALS['egw_info']['user']['preferences']['resources']['filter'];
|
||||
}
|
||||
}
|
||||
$sel_options = array();
|
||||
$no_button = array();
|
||||
$this->tmpl->read('resources.resource_select');
|
||||
return $this->tmpl->exec('resources.resources_ui.select',$content,$sel_options,$no_button,$preserv,2);
|
||||
}
|
||||
|
||||
/**
|
||||
* get_calendar_sidebox
|
||||
* get data für calendar sidebox
|
||||
|
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- $Id$ -->
|
||||
<overlay>
|
||||
<template id="resources.resource_select.header" template="" lang="" group="0" version="">
|
||||
<grid>
|
||||
<columns>
|
||||
<column/>
|
||||
<column/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<image label="Select resources" src="navbar"/>
|
||||
<description id="$msg" no_lang="1"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</template>
|
||||
</overlay>
|
@ -1,62 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- $Id$ -->
|
||||
<overlay>
|
||||
<template id="resources.resource_select.row" template="" lang="" group="0" version="1.7.002">
|
||||
<grid width="100%" class="selTable">
|
||||
<columns>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
<column width="3%"/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row class="th">
|
||||
<nextmatch-sortheader label="Name" id="name"/>
|
||||
<nextmatch-sortheader label="Category" id="cat_id"/>
|
||||
<nextmatch-sortheader label="Description" id="short_description"/>
|
||||
<nextmatch-sortheader label="Location" id="location"/>
|
||||
<nextmatch-sortheader label="Storage information" id="storage_info"/>
|
||||
<nextmatch-header label="Quantity" id="quantity"/>
|
||||
<description/>
|
||||
</row>
|
||||
<row class="row">
|
||||
<description id="${row}[name]" no_lang="1"/>
|
||||
<menulist>
|
||||
<menupopup type="select-cat" id="${row}[cat_id]" readonly="true"/>
|
||||
</menulist>
|
||||
<description id="${row}[short_description]"/>
|
||||
<description id="${row}[location]"/>
|
||||
<description id="${row}[storage_info]"/>
|
||||
<hbox cols="3" no_lang="1" rows="1" options="0,0">
|
||||
<textbox type="integer" id="${row}[default_qty]" min="1" size="2"/>
|
||||
<textbox type="integer" label="of" id="${row}[useable]" readonly="true" class="leftPad5"/>
|
||||
</hbox>
|
||||
<button label="select resource" id="${row}" needed="1" onclick="addOption('$row_cont[name]',$row_cont[res_id],this.id,$row_cont[useable]); return false;" image="select"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<vbox align="right" cols="1" rows="3" class="selSelection">
|
||||
<hbox align="center" cols="1" rows="1" class="th">
|
||||
<description value="Selection" class="big"/>
|
||||
<button align="right" label="clear selection" needed="1" onclick="removeSelectedOptions(); return false;" image="delete"/>
|
||||
</hbox>
|
||||
<listbox id="selectbox" no_lang="1" rows="13+" span="0" class="sel"/>
|
||||
<button align="center" label="Close" onclick="oneLineSubmit();window.close();"/>
|
||||
</vbox>
|
||||
</template>
|
||||
<template id="resources.resource_select" template="" lang="" group="0" version="1.7.001">
|
||||
<grid width="100%">
|
||||
<columns>
|
||||
<column/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<nextmatch id="nm" options="resources.resource_select.row"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</template>
|
||||
</overlay>
|
@ -47,14 +47,13 @@
|
||||
<nextmatch-header label="Resource / Accessories"/>
|
||||
<nextmatch-customfields id="customfields"/>
|
||||
<hbox align="right">
|
||||
<nextmatch-header label="Actions" id="legacy_actions"/>
|
||||
<description/>
|
||||
<description needed="1"/>
|
||||
<button align="right" statustext="Check all" label="Check all" id="check_all" needed="1" onclick="toggle_all(this.form,form::name('nm[rows][checkbox][]'),true); return false;" image="check.png"/>
|
||||
</hbox>
|
||||
</row>
|
||||
<row class="nmr $row_cont[class]" valign="top">
|
||||
<button align="center" id="${row}[picture_thumb]" onclick="if('${row_cont[picture_src]}' == 'own_src') {egw.open('/apps/resources/${row_cont[res_id]}/.picture.jpg','file');} return false;" image="$row_cont[picture_thumb]" class="thumb"/>
|
||||
<button align="center" id="${row}[picture_thumb]" onclick="if('${row}[picture_src]}' == 'own_src') {egw.open('/apps/resources/${row_cont[res_id]}/.picture.jpg','file');} return false;" image="${row}[picture_thumb]" class="thumb"/>
|
||||
<vbox>
|
||||
<description id="${row}[name]" no_lang="1"/>
|
||||
<description id="${row}[short_description]" no_lang="1"/>
|
||||
@ -89,28 +88,6 @@
|
||||
</grid>
|
||||
</vbox>
|
||||
<customfields-list id="$row"/>
|
||||
<grid id="${row}">
|
||||
<columns>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<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&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&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&res_id=0&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"/>
|
||||
<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&sortby=user&owner=0,r$cont[res_id]','calendar'); return false;" image="calendar/planner" ro_image="trans16x16"/>
|
||||
<button align="center" statustext="Delete this entry" label="Delete" id="delete[$cont[res_id]]" onclick="return confirm('Delete this entry');" image="delete" ro_image="trans16x16"/>
|
||||
<button align="center" statustext="View accessories for this resource" label="View accessories for this resource" id="view_acc[$cont[res_id]]" image="view_acc" ro_image="trans16x16"/>
|
||||
<checkbox align="right" id="checkbox[]" options="$cont[res_id]"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
@ -130,12 +107,6 @@
|
||||
<row>
|
||||
<nextmatch id="nm" no_lang="1" template="resources.show.rows"/>
|
||||
</row>
|
||||
<row disabled="!@nm[selectcols]=/legacy_actions/">
|
||||
<hbox align="right" span="all">
|
||||
<buttononly statustext="Select action" label="Select action" id="legacy_actions" onclick="if (!egw_globalObjectManager.getObjectById('resources.show.rows').executeActionImplementation(this, 'popup')) alert(egw::lang('You need to select some entries first!')); return false;;"/>
|
||||
<button statustext="Check all" label="Check all" id="check_all" needed="1" onclick="egw_globalObjectManager.getObjectById('resources.show.rows').toggleAllSelected(); return false;" image="arrow_ltr" class="checkAllArrow"/>
|
||||
</hbox>
|
||||
</row>
|
||||
<row>
|
||||
<hbox>
|
||||
<button label="Add" id="add" onclick="window.open(egw::link('/index.php','menuaction=resources.resources_ui.edit'),'','dependent=yes,width=800,height=600,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false; return false;"/>
|
||||
|
Loading…
Reference in New Issue
Block a user