2005-02-03 17:42:20 +01:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
|
|
|
* eGroupWare - resources - Resource Management System *
|
|
|
|
* http://www.egroupware.org *
|
2005-03-02 09:50:39 +01:00
|
|
|
* Written by Lukas Weiss <wnz_gh05t@users.sourceforge.net> and *
|
|
|
|
* Cornelius Weiss <egw@von-und-zu-weiss.de> *
|
2005-02-03 17:42:20 +01:00
|
|
|
* ----------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
2005-02-09 15:41:43 +01:00
|
|
|
/* $Id$ */
|
|
|
|
|
2005-02-03 17:42:20 +01:00
|
|
|
class ui_resources
|
|
|
|
{
|
|
|
|
var $public_functions = array(
|
|
|
|
'index' => True,
|
|
|
|
'edit' => True,
|
2005-03-01 11:20:03 +01:00
|
|
|
'show' => True,
|
2005-06-11 16:58:07 +02:00
|
|
|
'select' => True,
|
2005-03-01 11:20:03 +01:00
|
|
|
'admin' => True,
|
2005-02-03 17:42:20 +01:00
|
|
|
'writeLangFile' => True
|
|
|
|
);
|
|
|
|
|
2005-06-10 22:40:57 +02:00
|
|
|
/**
|
|
|
|
* constructor of class ui_resources
|
|
|
|
*
|
|
|
|
*/
|
2005-02-03 17:42:20 +01:00
|
|
|
function ui_resources()
|
|
|
|
{
|
2005-06-10 22:40:57 +02:00
|
|
|
// print_r($GLOBALS['egw_info']); die();
|
|
|
|
$this->tmpl =& CreateObject('etemplate.etemplate','resources.show');
|
|
|
|
$this->bo =& CreateObject('resources.bo_resources');
|
2005-09-28 01:29:06 +02:00
|
|
|
$this->html =& $GLOBALS['egw']->html;
|
2005-06-18 10:00:03 +02:00
|
|
|
// $this->calui = CreateObject('resources.ui_calviews');
|
2005-02-03 17:42:20 +01:00
|
|
|
|
2005-06-10 22:40:57 +02:00
|
|
|
if(!@is_object($GLOBALS['egw']->js))
|
2005-02-03 17:42:20 +01:00
|
|
|
{
|
2005-06-10 22:40:57 +02:00
|
|
|
$GLOBALS['egw']->js =& CreateObject('phpgwapi.javascript');
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-06-10 22:40:57 +02:00
|
|
|
/**
|
|
|
|
* main resources list.
|
|
|
|
*
|
2005-06-13 11:18:06 +02:00
|
|
|
* Cornelius Weiss <egw@von-und-zu-weiss.de>
|
2005-06-10 22:40:57 +02:00
|
|
|
* @param array $content content from eTemplate callback
|
|
|
|
*
|
|
|
|
* FIXME don't translate cats in nextmach
|
|
|
|
*/
|
2005-02-03 17:42:20 +01:00
|
|
|
function index($content='')
|
|
|
|
{
|
|
|
|
if (is_array($content))
|
2005-06-13 11:18:06 +02:00
|
|
|
{
|
2005-03-02 09:35:10 +01:00
|
|
|
$sessiondata = $content['nm'];
|
2005-10-09 12:13:10 +02:00
|
|
|
unset($sessiondata['rows']);
|
|
|
|
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata);
|
2005-03-02 09:35:10 +01:00
|
|
|
|
2005-06-13 11:18:06 +02:00
|
|
|
if (isset($content['back']))
|
|
|
|
{
|
|
|
|
unset($sessiondata['view_accs_of']);
|
|
|
|
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata);
|
|
|
|
return $this->index();
|
|
|
|
}
|
|
|
|
if (isset($content['btn_delete_selected']))
|
2005-10-09 12:13:10 +02:00
|
|
|
{
|
|
|
|
foreach($content['nm']['rows'] as $row)
|
2005-06-13 11:18:06 +02:00
|
|
|
{
|
2005-10-09 12:13:10 +02:00
|
|
|
if($res_id = $row['checkbox'][0])
|
|
|
|
{
|
|
|
|
$msg .= '<p>'. $this->bo->delete($res_id). '</p><br>';
|
|
|
|
}
|
2005-06-13 11:18:06 +02:00
|
|
|
}
|
|
|
|
return $this->index($msg);
|
|
|
|
}
|
|
|
|
|
2005-10-09 12:13:10 +02:00
|
|
|
foreach($content['nm']['rows'] as $row)
|
2005-02-03 17:42:20 +01:00
|
|
|
{
|
2005-10-09 12:13:10 +02:00
|
|
|
if(isset($row['delete']))
|
|
|
|
{
|
|
|
|
$res_id = array_search('pressed',$row['delete']);
|
|
|
|
return $this->index($this->bo->delete($res_id));
|
|
|
|
}
|
|
|
|
if(isset($row['view_acc']))
|
2005-02-03 17:42:20 +01:00
|
|
|
{
|
2005-10-09 12:13:10 +02:00
|
|
|
$sessiondata['view_accs_of'] = array_search('pressed',$row['view_acc']);
|
|
|
|
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$sessiondata);
|
|
|
|
return $this->index();
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
|
|
|
}
|
2005-03-02 09:35:10 +01:00
|
|
|
}
|
2005-06-13 14:21:18 +02:00
|
|
|
$msg = $content;
|
|
|
|
$content = array();
|
|
|
|
$content['msg'] = $msg;
|
2005-02-03 17:42:20 +01:00
|
|
|
|
2005-06-11 18:00:26 +02:00
|
|
|
$content['nm']['header_left'] = 'resources.resource_select.header';
|
2005-02-03 17:42:20 +01:00
|
|
|
$content['nm']['get_rows'] = 'resources.bo_resources.get_rows';
|
|
|
|
$content['nm']['no_filter'] = False;
|
2005-02-15 17:26:21 +01:00
|
|
|
$content['nm']['filter_label'] = 'Category';
|
2005-02-21 16:56:21 +01:00
|
|
|
$content['nm']['filter_help'] = lang('Select a category'); // is this used???
|
2005-06-11 21:46:50 +02:00
|
|
|
$content['nm']['options-filter']= array(''=>lang('all categories'))+(array)$this->bo->acl->get_cats(EGW_ACL_READ);
|
2005-02-21 16:56:21 +01:00
|
|
|
$content['nm']['no_filter2'] = true;
|
|
|
|
$content['nm']['filter_no_lang'] = true;
|
|
|
|
$content['nm']['no_cat'] = true;
|
2005-06-29 11:30:08 +02:00
|
|
|
$content['nm']['bottom_too'] = true;
|
2005-06-13 14:21:18 +02:00
|
|
|
$content['nm']['order'] = 'name';
|
|
|
|
$content['nm']['sort'] = 'ASC';
|
2005-06-13 17:14:46 +02:00
|
|
|
|
|
|
|
$nm_session_data = $GLOBALS['egw']->session->appsession('session_data','resources_index_nm');
|
|
|
|
if($nm_session_data)
|
|
|
|
{
|
|
|
|
$content['nm'] = $nm_session_data;
|
|
|
|
}
|
2005-02-03 17:42:20 +01:00
|
|
|
|
|
|
|
// check if user is permitted to add resources
|
2005-06-10 22:40:57 +02:00
|
|
|
if(!$this->bo->acl->get_cats(EGW_ACL_ADD))
|
2005-02-03 17:42:20 +01:00
|
|
|
{
|
|
|
|
$no_button['add'] = true;
|
|
|
|
}
|
2005-02-28 16:19:31 +01:00
|
|
|
$no_button['back'] = true;
|
2005-03-02 09:35:10 +01:00
|
|
|
$no_button['add_sub'] = true;
|
2005-06-10 22:40:57 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] = lang('resources');
|
2005-07-01 17:01:07 +02:00
|
|
|
|
|
|
|
$GLOBALS['egw_info']['flags']['java_script'] .= "<script LANGUAGE=\"JavaScript\">
|
|
|
|
function js_btn_book_selected(form)
|
|
|
|
{
|
|
|
|
resources = '';
|
2005-10-18 23:20:33 +02:00
|
|
|
|
|
|
|
el = form.getElementsByTagName(\"input\");
|
|
|
|
for (var i = 0; i < el.length; i++)
|
2005-07-01 17:01:07 +02:00
|
|
|
{
|
2005-10-18 23:20:33 +02:00
|
|
|
if(el[i].name.substr(el[i].name.length-12,el[i].name.length) == '[checkbox][]' && el[i].checked)
|
2005-07-01 17:01:07 +02:00
|
|
|
{
|
|
|
|
if(resources.length > 0)
|
|
|
|
{
|
|
|
|
resources += ',';
|
|
|
|
}
|
2005-10-18 23:20:33 +02:00
|
|
|
resources += 'r' + el[i].value;
|
2005-07-01 17:01:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(resources.length == 0)
|
|
|
|
{
|
|
|
|
alert('". lang('No resources selected'). "');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return resources;
|
|
|
|
}
|
|
|
|
</script>";
|
2005-06-12 16:36:15 +02:00
|
|
|
|
2005-03-02 09:35:10 +01:00
|
|
|
if($content['nm']['view_accs_of'])
|
2005-02-28 16:19:31 +01:00
|
|
|
{
|
2005-06-29 11:30:08 +02:00
|
|
|
$master = $this->bo->so->read(array('res_id' => $content['nm']['view_accs_of']));
|
2005-03-02 09:35:10 +01:00
|
|
|
$content['view_accs_of'] = $content['nm']['view_accs_of'];
|
2005-02-28 16:19:31 +01:00
|
|
|
$content['nm']['get_rows'] = 'resources.bo_resources.get_rows';
|
|
|
|
$content['nm']['no_filter'] = true;
|
|
|
|
$content['nm']['no_filter2'] = true;
|
|
|
|
$no_button['back'] = false;
|
2005-03-02 09:35:10 +01:00
|
|
|
$no_button['add'] = true;
|
|
|
|
$no_button['add_sub'] = false;
|
2005-11-03 23:48:30 +01:00
|
|
|
$GLOBALS['egw_info']['flags']['app_header'] = lang('resources') . ' - ' . lang('accessories of '). ' '. $master['name'] .
|
2005-03-02 09:35:10 +01:00
|
|
|
($master['short_description'] ? ' [' . $master['short_description'] . ']' : '');
|
2005-02-28 16:19:31 +01:00
|
|
|
}
|
2005-03-01 11:20:03 +01:00
|
|
|
$preserv = $content;
|
2005-06-10 22:40:57 +02:00
|
|
|
$GLOBALS['egw']->session->appsession('session_data','resources_index_nm',$content['nm']);
|
2005-03-01 11:58:04 +01:00
|
|
|
$this->tmpl->read('resources.show');
|
2005-10-27 23:53:44 +02:00
|
|
|
return $this->tmpl->exec('resources.ui_resources.index',$content,$sel_options,$no_button,$preserv);
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
|
|
|
|
2005-06-10 22:40:57 +02:00
|
|
|
/**
|
2005-06-13 11:18:06 +02:00
|
|
|
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
|
2005-06-10 22:40:57 +02:00
|
|
|
* invokes add or edit dialog for resources
|
|
|
|
*
|
|
|
|
* @param $content Content from the eTemplate Exec call or id on inital call
|
|
|
|
*/
|
2005-03-02 09:35:10 +01:00
|
|
|
function edit($content=0,$accessory_of = -1)
|
2005-10-09 12:13:10 +02:00
|
|
|
{
|
2005-02-03 17:42:20 +01:00
|
|
|
if (is_array($content))
|
|
|
|
{
|
2005-02-24 19:24:26 +01:00
|
|
|
if(isset($content['save']) || isset($content['delete']))
|
2005-02-03 17:42:20 +01:00
|
|
|
{
|
2005-02-24 19:24:26 +01:00
|
|
|
if(isset($content['save']))
|
2005-02-12 09:25:26 +01:00
|
|
|
{
|
2005-02-24 19:24:26 +01:00
|
|
|
unset($content['save']);
|
2005-06-11 21:54:04 +02:00
|
|
|
// if($content['id'] != 0)
|
|
|
|
// {
|
|
|
|
// // links are already saved by eTemplate
|
|
|
|
// unset($resource['link_to']['to_id']);
|
|
|
|
// }
|
2005-02-24 19:24:26 +01:00
|
|
|
$content['msg'] = $this->bo->save($content);
|
2005-02-12 09:25:26 +01:00
|
|
|
}
|
2005-02-24 19:24:26 +01:00
|
|
|
if(isset($content['delete']))
|
2005-02-03 17:42:20 +01:00
|
|
|
{
|
2005-02-24 19:24:26 +01:00
|
|
|
unset($content['delete']);
|
2005-06-29 11:30:08 +02:00
|
|
|
$content['msg'] = $this->bo->delete($content['res_id']);
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
2005-03-02 09:35:10 +01:00
|
|
|
|
|
|
|
if($content['msg'])
|
|
|
|
{
|
|
|
|
return $this->edit($content);
|
|
|
|
}
|
2005-06-10 22:40:57 +02:00
|
|
|
$js = "opener.location.href='".$GLOBALS['egw']->link('/index.php',
|
2005-03-02 09:35:10 +01:00
|
|
|
array('menuaction' => 'resources.ui_resources.index'))."';";
|
|
|
|
$js .= 'window.close();';
|
|
|
|
echo "<html><body><script>$js</script></body></html>\n";
|
2005-06-10 22:40:57 +02:00
|
|
|
$GLOBALS['egw']->common->egw_exit();
|
2005-02-24 19:24:26 +01:00
|
|
|
}
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
2005-02-09 15:41:43 +01:00
|
|
|
else
|
|
|
|
{
|
2005-06-29 11:30:08 +02:00
|
|
|
$res_id = $content;
|
|
|
|
if (isset($_GET['res_id'])) $res_id = $_GET['res_id'];
|
2005-03-02 09:35:10 +01:00
|
|
|
if (isset($_GET['accessory_of'])) $accessory_of = $_GET['accessory_of'];
|
2005-06-29 11:30:08 +02:00
|
|
|
$content = array('res_id' => $res_id);
|
2005-02-24 19:24:26 +01:00
|
|
|
|
2005-06-29 11:30:08 +02:00
|
|
|
if ($res_id > 0)
|
2005-02-24 19:24:26 +01:00
|
|
|
{
|
2005-06-29 11:30:08 +02:00
|
|
|
$content = $this->bo->read($res_id);
|
2005-02-24 19:24:26 +01:00
|
|
|
$content['gen_src_list'] = strstr($content['picture_src'],'.') ? $content['picture_src'] : false;
|
|
|
|
$content['picture_src'] = strstr($content['picture_src'],'.') ? 'gen_src' : $content['picture_src'];
|
|
|
|
$content['link_to'] = array(
|
2005-06-29 11:30:08 +02:00
|
|
|
'to_id' => $res_id,
|
2005-02-24 19:24:26 +01:00
|
|
|
'to_app' => 'resources'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2005-02-25 12:15:27 +01:00
|
|
|
}
|
2005-02-28 16:19:31 +01:00
|
|
|
// some presetes
|
2005-06-29 11:30:08 +02:00
|
|
|
$content['resource_picture'] = $this->bo->get_picture($content['res_id'],$content['picture_src'],$size=true);
|
2005-02-28 16:19:31 +01:00
|
|
|
$content['quantity'] = $content['quantity'] ? $content['quantity'] : 1;
|
|
|
|
$content['useable'] = $content['useable'] ? $content['useable'] : 1;
|
2005-11-03 23:48:30 +01:00
|
|
|
$content['accessory_of'] = $content['accessory_of'] ? $content['accessory_of'] : $accessory_of;
|
2005-02-28 16:19:31 +01:00
|
|
|
|
2005-03-02 09:35:10 +01:00
|
|
|
$sel_options['gen_src_list'] = $this->bo->get_genpicturelist();
|
2005-06-10 22:40:57 +02:00
|
|
|
$sel_options['cat_id'] = $this->bo->acl->get_cats(EGW_ACL_ADD);
|
2005-11-03 23:48:30 +01:00
|
|
|
$sel_options['cat_id'] = count($sel_options['cat_id']) == 1 ? $sel_options['cat_id'] :
|
|
|
|
$content['cat_id'] ? $sel_options['cat_id'] : array('' => lang('select one')) + $sel_options['cat_id'];
|
2005-03-02 09:35:10 +01:00
|
|
|
if($accessory_of > 0 || $content['accessory_of'] > 0)
|
2005-02-28 16:19:31 +01:00
|
|
|
{
|
2005-03-02 09:35:10 +01:00
|
|
|
$content['accessory_of'] = $content['accessory_of'] ? $content['accessory_of'] : $accessory_of;
|
2005-02-28 16:19:31 +01:00
|
|
|
$catofmaster = $this->bo->so->get_value('cat_id',$content['accessory_of']);
|
|
|
|
$sel_options['cat_id'] = array($catofmaster => $sel_options['cat_id'][$catofmaster]);
|
|
|
|
}
|
|
|
|
|
2005-10-09 12:13:10 +02:00
|
|
|
// $content['general|page|pictures|links'] = 'resources.edit_tabs.page'; //debug
|
2005-02-24 19:24:26 +01:00
|
|
|
$no_button = array(); // TODO: show delete button only if allowed to delete resource
|
|
|
|
$preserv = $content;
|
2005-02-03 17:42:20 +01:00
|
|
|
$this->tmpl->read('resources.edit');
|
2005-10-27 23:53:44 +02:00
|
|
|
return $this->tmpl->exec('resources.ui_resources.edit',$content,$sel_options,$no_button,$preserv,2);
|
2005-02-03 17:42:20 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2005-06-10 22:40:57 +02:00
|
|
|
/**
|
|
|
|
* adminsection of resources
|
|
|
|
*
|
2005-06-13 11:18:06 +02:00
|
|
|
* @author Cornelius Weiss <egw@von-und-zu-weiss.de>
|
2005-06-10 22:40:57 +02:00
|
|
|
*/
|
2005-03-01 11:58:04 +01:00
|
|
|
function admin($content='')
|
|
|
|
{
|
|
|
|
if(is_array($content))
|
|
|
|
{
|
|
|
|
if(isset($content['save']))
|
|
|
|
{
|
|
|
|
$this->bo->conf->read_repository();
|
|
|
|
$this->bo->conf->save_value('dont_use_vfs',$content['dont_use_vfs']);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2005-06-10 22:40:57 +02:00
|
|
|
return $GLOBALS['egw']->redirect_link('/admin/index.php');
|
2005-03-01 11:58:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$content = $this->bo->conf->read_repository();
|
|
|
|
$this->tmpl->read('resources.admin');
|
|
|
|
$this->tmpl->exec('resources.ui_resources.admin',$content,$sel_options,$no_button,$preserv);
|
|
|
|
}
|
|
|
|
|
2005-06-10 22:40:57 +02:00
|
|
|
/**
|
|
|
|
* showes a single resource
|
|
|
|
*
|
2005-06-29 11:30:08 +02:00
|
|
|
* @param int $res_id resource id
|
2005-06-10 22:40:57 +02:00
|
|
|
* @author Lukas Weiss <wnz.gh05t@users.sourceforge.net>
|
|
|
|
*/
|
2005-06-29 11:30:08 +02:00
|
|
|
function show($res_id=0)
|
2005-02-03 17:42:20 +01:00
|
|
|
{
|
2005-10-09 12:13:10 +02:00
|
|
|
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.ui_resources.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']);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2005-06-29 11:30:08 +02:00
|
|
|
if (isset($_GET['res_id'])) $res_id = $_GET['res_id'];
|
2005-03-21 10:52:53 +01:00
|
|
|
|
2005-06-29 11:30:08 +02:00
|
|
|
$content = array('res_id' => $res_id);
|
|
|
|
$content = $this->bo->read($res_id);
|
2005-03-21 10:52:53 +01:00
|
|
|
$content['gen_src_list'] = strstr($content['picture_src'],'.') ? $content['picture_src'] : false;
|
|
|
|
$content['picture_src'] = strstr($content['picture_src'],'.') ? 'gen_src' : $content['picture_src'];
|
|
|
|
$content['link_to'] = array(
|
2005-06-29 11:30:08 +02:00
|
|
|
'to_id' => $res_id,
|
2005-06-13 11:18:06 +02:00
|
|
|
'to_app' => 'resources'
|
|
|
|
);
|
2005-02-03 17:42:20 +01:00
|
|
|
|
2005-06-29 11:30:08 +02:00
|
|
|
$content['resource_picture'] = $this->bo->get_picture($content['res_id'],$content['picture_src'],$size=true);
|
2005-03-21 10:52:53 +01:00
|
|
|
$content['quantity'] = $content['quantity'] ? $content['quantity'] : 1;
|
|
|
|
$content['useable'] = $content['useable'] ? $content['useable'] : 1;
|
|
|
|
|
2005-06-12 12:09:12 +02:00
|
|
|
$content['quantity'] = ($content['useable'] == $content['quantity']) ? $content['quantity'] : $content['quantity'].' ('.lang('useable').' '.$content['useable'].')';
|
2005-03-21 10:52:53 +01:00
|
|
|
|
2005-06-13 11:18:06 +02:00
|
|
|
//$sel_options['gen_src_list'] = $this->bo->get_genpicturelist();
|
2005-06-10 22:40:57 +02:00
|
|
|
|
2005-03-21 10:52:53 +01:00
|
|
|
$content['cat_name'] = $this->bo->acl->get_cat_name($content['cat_id']);
|
|
|
|
$content['cat_admin'] = $this->bo->acl->get_cat_admin($content['cat_id']);
|
|
|
|
|
2005-06-13 11:18:06 +02:00
|
|
|
/* if($content['accessory_of'] > 0)
|
2005-03-21 10:52:53 +01:00
|
|
|
{
|
|
|
|
$catofmaster = $this->bo->so->get_value('cat_id',$content['accessory_of']);
|
|
|
|
$sel_options['cat_id'] = array($catofmaster => $sel_options['cat_id'][$catofmaster]);
|
|
|
|
}
|
2005-06-13 11:18:06 +02:00
|
|
|
*/
|
2005-06-12 12:09:12 +02:00
|
|
|
$content['description'] = chop($content['long_description']) ? $content['long_description'] : (chop($content['short_description']) ? $content['short_description'] : lang("no description available"));
|
2005-03-21 10:52:53 +01:00
|
|
|
$content['description'] = $content['description'] ? $content['description'] : lang('no description available');
|
2005-06-12 12:09:12 +02:00
|
|
|
$content['link_to'] = array(
|
2005-06-29 11:30:08 +02:00
|
|
|
'to_id' => $res_id,
|
2005-06-12 12:09:12 +02:00
|
|
|
'to_app' => 'resources'
|
|
|
|
);
|
2005-03-21 10:52:53 +01:00
|
|
|
$sel_options = array();
|
2005-06-12 12:09:12 +02:00
|
|
|
$no_button = array(
|
2005-10-05 01:02:18 +02:00
|
|
|
'btn_buy' => !$content['buyable'],
|
|
|
|
'btn_book' => !$content['bookable'],
|
2005-10-27 23:53:44 +02:00
|
|
|
'btn_calendar' => !$content['bookable'],
|
2005-10-05 01:02:18 +02:00
|
|
|
'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)
|
2005-06-12 12:09:12 +02:00
|
|
|
);
|
2005-03-21 10:52:53 +01:00
|
|
|
$preserv = $content;
|
|
|
|
$this->tmpl->read('resources.showdetails');
|
2005-10-27 23:53:44 +02:00
|
|
|
return $this->tmpl->exec('resources.ui_resources.show',$content,$sel_options,$no_button,$preserv,2);
|
2005-03-21 10:52:53 +01:00
|
|
|
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
2005-10-09 12:13:10 +02:00
|
|
|
|
2005-06-11 16:58:07 +02:00
|
|
|
/**
|
|
|
|
* select resources
|
|
|
|
*
|
|
|
|
* @author Lukas Weiss <wnz.gh05t@users.sourceforge.net>
|
|
|
|
*/
|
2005-06-11 17:41:12 +02:00
|
|
|
function select($content='')
|
2005-06-11 16:58:07 +02:00
|
|
|
{
|
2005-06-11 21:46:50 +02:00
|
|
|
$GLOBALS['egw_info']['flags']['java_script'] .= "<script LANGUAGE=\"JavaScript\">
|
2005-06-11 17:41:12 +02:00
|
|
|
window.focus();
|
2005-06-11 21:46:50 +02:00
|
|
|
|
2005-06-12 13:15:22 +02:00
|
|
|
openerid='resources_selectbox';
|
2005-06-11 21:46:50 +02:00
|
|
|
id='exec[nm][rows][selectbox]';
|
2005-06-11 17:41:12 +02:00
|
|
|
|
2005-09-06 23:45:37 +02:00
|
|
|
function addOption(label,value,button_id,useable)
|
2005-06-11 17:41:12 +02:00
|
|
|
{
|
2005-09-06 23:45:37 +02:00
|
|
|
quantity = document.getElementById(button_id+'[default_qty]').value;
|
2005-09-13 23:42:46 +02:00
|
|
|
value = value+':'+quantity;
|
2005-09-06 23:45:37 +02:00
|
|
|
if(quantity>useable) {
|
|
|
|
alert('".lang('You chose more resources than available')."');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
label = label+'['+quantity+'/'+useable+']';
|
2005-06-11 21:46:50 +02:00
|
|
|
openerSelectBox = opener.document.getElementById(openerid);
|
|
|
|
if (openerSelectBox) {
|
2005-06-11 17:41:12 +02:00
|
|
|
select = '';
|
|
|
|
for(i=0; i < openerSelectBox.length; i++) {
|
|
|
|
with (openerSelectBox.options[i]) {
|
|
|
|
if (selected || openerSelectBox.selectedIndex == i) {
|
|
|
|
select += (value.slice(0,1)==',' ? '' : ',')+value;
|
|
|
|
}
|
|
|
|
}
|
2005-06-11 16:58:07 +02:00
|
|
|
}
|
2005-06-11 17:41:12 +02:00
|
|
|
select += (select ? ',' : '')+value;
|
2005-09-13 23:42:46 +02:00
|
|
|
opener.selectbox_add_option(openerid,label,value,0);
|
2005-06-11 16:58:07 +02:00
|
|
|
}
|
2005-06-11 21:46:50 +02:00
|
|
|
selectBox = document.getElementById(id);
|
2005-06-11 17:41:12 +02:00
|
|
|
if (selectBox) {
|
2005-09-13 23:42:46 +02:00
|
|
|
var resource_value = value.split(':');
|
2005-06-11 17:41:12 +02:00
|
|
|
for (i=0; i < selectBox.length; i++) {
|
2005-09-13 23:42:46 +02:00
|
|
|
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);
|
2005-06-11 17:41:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i >= selectBox.length) {
|
|
|
|
selectBox.options[selectBox.length] = new Option(label,value,false,true);
|
2005-06-11 16:58:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-06-11 17:41:12 +02:00
|
|
|
|
2005-06-11 21:46:50 +02:00
|
|
|
function removeSelectedOptions()
|
2005-06-11 17:41:12 +02:00
|
|
|
{
|
2005-06-11 21:46:50 +02:00
|
|
|
openerSelectBox = opener.document.getElementById(openerid);
|
2005-06-11 17:41:12 +02:00
|
|
|
if (openerSelectBox == null) window.close();
|
2005-06-11 21:46:50 +02:00
|
|
|
selectBox = document.getElementById(id);
|
2005-06-11 17:41:12 +02:00
|
|
|
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;
|
|
|
|
}
|
2005-06-11 16:58:07 +02:00
|
|
|
}
|
|
|
|
}
|
2005-06-11 17:41:12 +02:00
|
|
|
|
2005-06-11 21:46:50 +02:00
|
|
|
function copyOptions()
|
2005-06-11 17:41:12 +02:00
|
|
|
{
|
2005-06-11 21:46:50 +02:00
|
|
|
openerSelectBox = opener.document.getElementById(openerid);
|
|
|
|
selectBox = document.getElementById(id);
|
2005-06-11 16:58:07 +02:00
|
|
|
for (i=0; i < openerSelectBox.length; i++) {
|
|
|
|
with (openerSelectBox.options[i]) {
|
2005-06-11 17:41:12 +02:00
|
|
|
if (selected && value.slice(0,1) != ',') {
|
|
|
|
selectBox.options[selectBox.length] = new Option(text,value);
|
2005-06-11 16:58:07 +02:00
|
|
|
}
|
|
|
|
}
|
2005-06-11 17:41:12 +02:00
|
|
|
}
|
2005-06-11 16:58:07 +02:00
|
|
|
}
|
2005-06-11 17:41:12 +02:00
|
|
|
|
2005-06-11 21:46:50 +02:00
|
|
|
function oneLineSubmit()
|
2005-06-11 17:41:12 +02:00
|
|
|
{
|
2005-09-13 23:42:46 +02:00
|
|
|
/*
|
2005-06-11 21:46:50 +02:00
|
|
|
openerSelectBox = opener.document.getElementById(openerid);
|
2005-06-11 17:41:12 +02:00
|
|
|
|
|
|
|
if (openerSelectBox) {
|
|
|
|
if (openerSelectBox.selectedIndex >= 0) {
|
|
|
|
selected = openerSelectBox.options[openerSelectBox.selectedIndex].value;
|
|
|
|
if (selected.slice(0,1) == ',') selected = selected.slice(1);
|
2005-06-18 10:00:03 +02:00
|
|
|
opener.selectbox_add_option(openerid,'multiple*',selected,1);
|
2005-06-11 17:41:12 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (i=0; i < openerSelectBox.length; i++) {
|
|
|
|
with (openerSelectBox.options[i]) {
|
|
|
|
if (selected) {
|
2005-06-18 10:00:03 +02:00
|
|
|
opener.selectbox_add_option(openerid,text,value,1);
|
2005-06-11 17:41:12 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-09-13 23:42:46 +02:00
|
|
|
*/
|
2005-06-11 17:41:12 +02:00
|
|
|
window.close();
|
|
|
|
}</script>";
|
2005-06-11 21:46:50 +02:00
|
|
|
|
|
|
|
if (!is_object($GLOBALS['phpgw']->js))
|
|
|
|
{
|
|
|
|
$GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
|
|
|
|
}
|
|
|
|
$GLOBALS['phpgw']->js->set_onload("copyOptions('exec[resources][selectbox]');");
|
2005-06-11 17:41:12 +02:00
|
|
|
|
2005-06-11 19:33:18 +02:00
|
|
|
$content['nm']['header_left'] = 'resources.resource_select.header';
|
2005-06-11 17:41:12 +02:00
|
|
|
$content['nm']['show_bookable'] = true;
|
|
|
|
$content['nm']['get_rows'] = 'resources.bo_resources.get_rows';
|
|
|
|
$content['nm']['no_filter'] = False;
|
|
|
|
$content['nm']['filter_label'] = 'Category';
|
|
|
|
$content['nm']['filter_help'] = lang('Select a category'); // is this used???
|
2005-06-11 21:46:50 +02:00
|
|
|
$content['nm']['options-filter']= array(''=>lang('all categories'))+(array)$this->bo->acl->get_cats(EGW_ACL_READ);
|
2005-06-11 17:41:12 +02:00
|
|
|
$content['nm']['no_filter2'] = true;
|
|
|
|
$content['nm']['filter_no_lang'] = true;
|
|
|
|
$content['nm']['no_cat'] = true;
|
2005-06-11 21:46:50 +02:00
|
|
|
$content['nm']['rows']['js_id'] = 1;
|
|
|
|
|
2005-06-11 16:58:07 +02:00
|
|
|
$sel_options = array();
|
|
|
|
$no_button = array();
|
|
|
|
$this->tmpl->read('resources.resource_select');
|
2005-10-27 23:53:44 +02:00
|
|
|
return $this->tmpl->exec('resources.ui_resources.select',$content,$sel_options,$no_button,$preserv,2);
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
2005-09-28 01:29:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* get_calendar_sidebox
|
|
|
|
* get data für calendar sidebox
|
|
|
|
*
|
|
|
|
* @author Lukas Weiss <wnz_gh05t@users.sourceforge.net>
|
|
|
|
* @return array with: label=>link or array with text
|
|
|
|
*/
|
|
|
|
function get_calendar_sidebox($view_menuaction, $date='')
|
|
|
|
{
|
|
|
|
$selectbox_content = array(lang('Select resources'));
|
|
|
|
$cats = $this->bo->acl->get_cats(EGW_ACL_READ);
|
2005-11-02 11:37:00 +01:00
|
|
|
if (!$cats) return array();
|
2005-09-28 01:29:06 +02:00
|
|
|
|
|
|
|
// this gets the resource-ids of the cats and implodes them to the array-key of the selectbox,
|
|
|
|
// so it is possible to select all resources of a category
|
|
|
|
foreach($cats as $cat_id => $cat_name)
|
|
|
|
{
|
2005-10-27 20:43:08 +02:00
|
|
|
if ($resources = $this->bo->so->search(array('cat_id' => $cat_id, 'bookable' => '1'),'res_id'))
|
2005-09-30 05:51:59 +02:00
|
|
|
{
|
2005-10-27 23:53:44 +02:00
|
|
|
$key = "";
|
2005-09-30 05:51:59 +02:00
|
|
|
foreach($resources as $res)
|
|
|
|
{
|
|
|
|
$key .= ($key == "")?'r'.$res['res_id']:',r'.$res['res_id'];
|
|
|
|
}
|
|
|
|
$selectbox_content[$key] = $cat_name;
|
|
|
|
}
|
2005-09-28 01:29:06 +02:00
|
|
|
}
|
2005-10-05 01:02:18 +02:00
|
|
|
$link_array = array('menuaction' => $view_menuaction);
|
|
|
|
if($date != '') $link_array['date'] = $date;
|
2005-09-28 01:29:06 +02:00
|
|
|
$selectbox = $this->html->select(
|
|
|
|
'owner',
|
2005-10-27 20:43:08 +02:00
|
|
|
$_GET['owner'],
|
2005-09-28 01:29:06 +02:00
|
|
|
$selectbox_content,
|
|
|
|
$no_lang=true,
|
2005-10-05 01:02:18 +02:00
|
|
|
$options='style="width: 165px;" onchange="load_cal(\''.
|
|
|
|
$GLOBALS['egw']->link('/index.php',$link_array).'\',\'uical_select_resource\');" id="uical_select_resource"',
|
2005-09-28 01:29:06 +02:00
|
|
|
$multiple=0
|
|
|
|
);
|
|
|
|
return array(
|
|
|
|
array(
|
|
|
|
'text' => $selectbox,
|
|
|
|
'no_lang' => True,
|
|
|
|
'link' => False
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2005-02-03 17:42:20 +01:00
|
|
|
}
|
2005-06-29 11:30:08 +02:00
|
|
|
|