Add a print template to print a single calender event

This commit is contained in:
Stefan Becker 2008-12-18 14:47:21 +00:00
parent a40b1c6bfb
commit e7f82e886c
4 changed files with 194 additions and 31 deletions

View File

@ -383,6 +383,7 @@ class calendar_uiforms extends calendar_ui
// fall through // fall through
case 'mail': case 'mail':
case 'save': case 'save':
case 'print':
case 'apply': case 'apply':
if ($event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT,$event)) if ($event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT,$event))
{ {
@ -394,6 +395,18 @@ class calendar_uiforms extends calendar_ui
$msg = lang('Permission denied'); $msg = lang('Permission denied');
break; break;
} }
if ($event['id'] && !$this->bo->check_perms(EGW_ACL_EDIT,$event))
{
if ($button == 'print') // just print without edit-rights is ok
{
$js = $this->custom_print($event,false);
break;
}
$msg = lang('Permission denied');
break;
}
if ($event['start'] > $event['end']) if ($event['start'] > $event['end'])
{ {
$msg = lang('Error: Starttime has to be before the endtime !!!'); $msg = lang('Error: Starttime has to be before the endtime !!!');
@ -479,6 +492,11 @@ class calendar_uiforms extends calendar_ui
'msg' => $msg, 'msg' => $msg,
))).'\';'; ))).'\';';
if ($button == 'print')
{
$js = $this->custom_print($event,!$content['id'])."\n".$js; // first open the new window and then update the view
}
if ($button == 'mail') if ($button == 'mail')
{ {
$js = $this->custom_mail($event,!$content['id'])."\n".$js; // first open the new window and then update the view $js = $this->custom_mail($event,!$content['id'])."\n".$js; // first open the new window and then update the view
@ -660,6 +678,24 @@ class calendar_uiforms extends calendar_ui
return "window.open('".$GLOBALS['egw']->link('/index.php',$vars)."','_blank','width=700,height=700,scrollbars=yes,status=no');"; return "window.open('".$GLOBALS['egw']->link('/index.php',$vars)."','_blank','width=700,height=700,scrollbars=yes,status=no');";
} }
/**
* return javascript to open compose window to print the event
*
* @param array $event
* @param boolean $added
* @return string javascript window.open command
*/
function custom_print($event,$added)
{
$vars = array(
'menuaction' => 'calendar.calendar_uiforms.edit',
'cal_id' => $event['id'],
'print' => true,
);
return "window.open('".$GLOBALS['egw']->link('/index.php',$vars)."','_blank','width=700,height=700,scrollbars=yes,status=no');";
}
/** /**
* Edit a calendar event * Edit a calendar event
* *
@ -675,7 +711,8 @@ class calendar_uiforms extends calendar_ui
*/ */
function edit($event=null,$preserv=null,$msg='',$js = 'window.focus();',$link_to_id='') function edit($event=null,$preserv=null,$msg='',$js = 'window.focus();',$link_to_id='')
{ {
$etpl =& CreateObject('etemplate.etemplate','calendar.edit'); $template = $_REQUEST['print'] ? 'calendar.print' : 'calendar.edit';
$etpl =& CreateObject('etemplate.etemplate',$template);
$sel_options = array( $sel_options = array(
'recur_type' => &$this->bo->recur_types, 'recur_type' => &$this->bo->recur_types,
'status' => $this->bo->verbose_status, 'status' => $this->bo->verbose_status,
@ -683,6 +720,7 @@ class calendar_uiforms extends calendar_ui
'action' => array( 'action' => array(
'copy' => array('label' => 'Copy', 'title' => 'Copy this event'), 'copy' => array('label' => 'Copy', 'title' => 'Copy this event'),
'ical' => array('label' => 'Export', 'title' => 'Download this event as iCal'), 'ical' => array('label' => 'Export', 'title' => 'Download this event as iCal'),
'print' => array('label' => 'Print', 'title' => 'Print this event'),
'mail' => array('label' => 'Mail all participants', 'title' => 'compose a mail to all participants after the event is saved'), 'mail' => array('label' => 'Mail all participants', 'title' => 'compose a mail to all participants after the event is saved'),
), ),
'status_recurrence' => array('' => 'for this event', 'A' => 'for all future events'), 'status_recurrence' => array('' => 'for this event', 'A' => 'for all future events'),

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,36 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="calendar.print.participants" template="" lang="" group="0" version="1.6.001">
<grid width="100%" height="200" overflow="auto" id="participants">
<columns>
<column width="95"/>
<column/>
<column/>
<column disabled="@hide_status_recurrence"/>
<column/>
</columns>
<rows>
<row>
<description span="all"/>
</row>
<row class="th">
<description value="Type"/>
<description value="Participants"/>
<description value="Quantity"/>
<description value="All future"/>
<description value="Status"/>
</row>
<row valign="top">
<description id="${row}[app]"/>
<description rows="1" cols="2" id="${row}[title]" no_lang="1"/>
<int id="${row}[quantity]" options="1,,3" readonly="true"/>
<checkbox id="${row}[status_recurrence]" align="center" readonly="true"/>
<menulist>
<menupopup id="${row}[status]" no_lang="1" onchange="1"/>
</menulist>
</row>
</rows>
</grid>
</template>
</overlay>

View File

@ -0,0 +1,113 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="calendar.print.participants" template="" lang="" group="0" version="1.6.001">
<grid width="100%" height="200" overflow="auto" id="participants">
<columns>
<column width="95"/>
<column/>
<column/>
<column disabled="@hide_status_recurrence"/>
<column/>
</columns>
<rows>
<row>
<description span="all"/>
</row>
<row class="th">
<description value="Type"/>
<description value="Participants"/>
<description value="Quantity"/>
<description value="All future"/>
<description value="Status"/>
</row>
<row valign="top">
<description id="${row}[app]"/>
<description rows="1" cols="2" id="${row}[title]" no_lang="1"/>
<int id="${row}[quantity]" options="1,,3" readonly="true"/>
<checkbox id="${row}[status_recurrence]" align="center" readonly="true"/>
<menulist>
<menupopup id="${row}[status]" no_lang="1" onchange="1"/>
</menulist>
</row>
</rows>
</grid>
</template>
<template id="calendar.print" template="" lang="" group="0" version="1.6.001">
<hbox options="0,0">
<grid width="100%" height="200">
<columns>
<column width="95"/>
<column/>
</columns>
<rows>
<row class="th">
<image src="print" onclick="window.print();"/>
<description class="bold" value="Calendar" options="bold"/>
</row>
<row class="th" height="28">
<description value="Title"/>
<textbox id="title" size="80" maxlength="255" readonly="true" span="all"/>
</row>
<row class="row">
<description width="95" options=",,,start" value="Start"/>
<hbox options="0,0">
<date-time id="start" readonly="true"/>
<checkbox label="whole day" id="whole_day" options=",, ,disable" statustext="Event will occupy the whole day" align="center" readonly="true"/>
</hbox>
</row>
<row class="row">
<description width="0" options=",,,duration" value="Duration"/>
<hbox options="0,0">
<menulist>
<menupopup no_lang="1" onchange="set_style_by_class('table','end_hide','visibility',this.value == '' ? 'visible' : 'hidden'); if (this.value == '') document.getElementById(form::name('end[str]')).value = document.getElementById(form::name('start[str]')).value;" id="duration" options="Use end date" statustext="Duration of the meeting" readonly="true"/>
</menulist>
<date-time id="end" class="end_hide" readonly="true"/>
</hbox>
</row>
<row class="row">
<description options=",,,location" value="Location" width="0"/>
<textbox maxlength="255" id="location" class="inputFullWidth" readonly="true"/>
</row>
<row class="row_off">
<description options=",,,priority" value="Priority" width="0"/>
<menulist>
<menupopup type="select-priority" id="priority" readonly="true"/>
</menulist>
</row>
<row class="row">
<description value="Options" width="0"/>
<checkbox id="non_blocking" options=",, ,disable" statustext="A non blocking event will not conflict with other events" label="non blocking" readonly="true"/>
</row>
<row class="row">
<description/>
<checkbox id="public" options="0,1" label="Private" readonly="true"/>
</row>
<row class="row">
<description value="Categories"/>
<menulist>
<menupopup type="select-cat" id="category" readonly="true"/>
</menulist>
</row>
<row valign="top">
<description value="Description"/>
<textbox multiline="true" id="description" readonly="true" rows="12" cols="90"/>
</row>
<row class="th">
<description value="custom fields" span="all"/>
</row>
<row>
<customfields span="all" readonly="true"/>
</row>
<row>
<template id="calendar.print.participants" span="all"/>
</row>
<row>
<description/>
<description/>
</row>
</rows>
</grid>
</hbox>
</template>
</overlay>