[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11433] property: pdf preview
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11433] property: pdf preview |
Date: |
Tue, 05 Nov 2013 14:08:37 +0000 |
Revision: 11433
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11433
Author: sigurdne
Date: 2013-11-05 14:08:36 +0000 (Tue, 05 Nov 2013)
Log Message:
-----------
property: pdf preview
Modified Paths:
--------------
trunk/property/inc/class.uitts.inc.php
trunk/property/templates/base/tts.xsl
Modified: trunk/property/inc/class.uitts.inc.php
===================================================================
--- trunk/property/inc/class.uitts.inc.php 2013-11-05 11:33:16 UTC (rev
11432)
+++ trunk/property/inc/class.uitts.inc.php 2013-11-05 14:08:36 UTC (rev
11433)
@@ -2774,6 +2774,14 @@
unset($_temp);
$preview_html = phpgw::get_var('preview_html', 'bool');
+ $preview_pdf = phpgw::get_var('preview_pdf', 'bool');
+
+ if($preview_pdf)
+ {
+ $this->_pdf_order($id, $preview_pdf);
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ }
+
if($vendor_email || $preview_html)
{
$subject = lang('workorder').":
{$ticket['order_id']}";
@@ -2886,6 +2894,7 @@
$GLOBALS['phpgw']->common->phpgw_exit();
}
+
if(isset($values['file_attach']) &&
is_array($values['file_attach']))
{
$bofiles =
CreateObject('property.bofiles');
@@ -3312,6 +3321,7 @@
'order_dim1_list'
=> array('options' =>
$this->bocommon->select_category_list(array('type'=> 'order_dim1','selected'
=>$ticket['order_dim1'], 'order' => 'id', 'id_in_name' => 'num' ))),
'branch_list'
=>
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['tts_branch_list'])
&&
$GLOBALS['phpgw_info']['user']['preferences']['property']['tts_branch_list']==1
? array('options' => execMethod('property.boproject.select_branch_list',
$values['branch_id'])) :'',
'preview_html'
=> "javascript:preview_html($id)",
+ 'preview_pdf'
=> "javascript:preview_pdf($id)",
);
@@ -3617,4 +3627,305 @@
return phpgwapi_yui::tabview_generate($tabs, $tab);
}
+
+ private function _pdf_order($id = 0, $preview_pdf = false ,
$show_cost = false)
+ {
+ if(!$this->acl_read)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=>
'property.uilocation.stop', 'perm'=>1, 'acl_location'=> $this->acl_location));
+ }
+
+ $GLOBALS['phpgw_info']['flags']['noheader'] = true;
+ $GLOBALS['phpgw_info']['flags']['nofooter'] = true;
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = false;
+
+ $pdf= CreateObject('phpgwapi.pdf');
+
+ $preview = phpgw::get_var('preview', 'bool');
+
+ if(!$id)
+ {
+ $id = phpgw::get_var('id'); // in case of bigint
+ $show_cost = phpgw::get_var('show_cost',
'bool');
+ }
+
+ if(!$show_cost)
+ {
+ $show_cost = phpgw::get_var('show_cost',
'bool');
+ }
+
+ $ticket = $this->bo->read_single($id, $values);
+
+ if(isset($this->config->config_data['invoice_acl']) &&
$this->config->config_data['invoice_acl'] == 'dimb')
+ {
+ $approve_role =
execMethod('property.boinvoice.check_role', $ticket['ecodimb']);
+
+ $_ok = false;
+ if($approve_role['is_supervisor'])
+ {
+ $_ok = true;
+ }
+ else if( $approve_role['is_budget_responsible']
)
+ {
+ $_ok = true;
+ }
+ else if( $common_data['workorder']['approved'] )
+ {
+ $_ok = true;
+ }
+
+ if(!$_ok)
+ {
+ phpgwapi_cache::message_set(
lang('order is not approved'), 'error' );
+
$GLOBALS['phpgw']->redirect_link('/index.php',array('menuaction'=>
'property.uiwo_hour.view', 'workorder_id'=> $id, 'from' =>
phpgw::get_var('from')));
+ }
+ unset($_ok);
+ }
+
+ //FIXME
+ $content = array();
//$this->_get_order_details($common_data['content'], $show_cost);
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+ $date =
$GLOBALS['phpgw']->common->show_date(time(),$dateformat);
+
+ set_time_limit(1800);
+ $pdf ->ezSetMargins(50,70,50,50);
+ $pdf->selectFont(PHPGW_API_INC .
'/pdf/fonts/Helvetica.afm');
+
+ // put a line top and bottom on all the pages
+ $all = $pdf->openObject();
+ $pdf->saveState();
+
+ if(isset($this->config->config_data['order_logo']) &&
$this->config->config_data['order_logo'])
+ {
+
$pdf->addJpegFromFile($this->config->config_data['order_logo'],
+ 40,
+ 800,
+
isset($this->config->config_data['order_logo_width']) &&
$this->config->config_data['order_logo_width'] ?
$this->config->config_data['order_logo_width'] : 80
+ );
+ }
+ $pdf->setStrokeColor(0,0,0,1);
+ $pdf->line(20,40,578,40);
+ // $pdf->line(20,820,578,820);
+ // $pdf->addText(50,823,6,lang('order'));
+
$pdf->addText(50,28,6,$this->config->config_data['org_name']);
+ $pdf->addText(300,28,6,$date);
+
+
+ $pdf->restoreState();
+ $pdf->closeObject();
+ // note that object can be told to appear on just odd
or even pages by changing 'all' to 'odd'
+ // or 'even'.
+ $pdf->addObject($all,'all');
+
+ // $pdf->ezSetDy(-100);
+
+ $pdf->ezStartPageNumbers(500,28,6,'right','{PAGENUM} '
. lang('of') . ' {TOTALPAGENUM}',1);
+
+ $data = array
+ (
+
array('col1'=>"{$this->config->config_data['org_name']}\n\nOrg.nr:
{$this->config->config_data['org_unit_id']}",'col2'=>lang('Order'),'col3'=>lang('order
id') . "\n\n{$ticket['order_id']}")
+ );
+
+
$pdf->ezTable($data,array('col1'=>'','col2'=>'','col3'=>''),''
+ ,array('showHeadings'=>0,'shaded'=>0,'xPos'=>0
+ ,'xOrientation'=>'right','width'=>500
+ ,'cols'=>array
+ (
+
'col1'=>array('justification'=>'right','width'=>200, 'justification'=>'left'),
+
'col2'=>array('justification'=>'right','width'=>100, 'justification'=>'center'),
+
'col3'=>array('justification'=>'right','width'=>200),
+ )
+
+ ));
+
+ $delivery_address = lang('delivery address'). ':';
+
if(isset($this->config->config_data['delivery_address']) &&
$this->config->config_data['delivery_address'])
+ {
+ $delivery_address .=
"\n{$this->config->config_data['delivery_address']}";
+ }
+ else
+ {
+ $location_code =
$ticket['location_data']['location_code'];
+ $address_element =
execMethod('property.botts.get_address_element', $location_code);
+ foreach($address_element as $entry)
+ {
+ $delivery_address .=
"\n{$entry['text']}: {$entry['value']}";
+ }
+ }
+
+ $invoice_address = lang('invoice address') .
":\n{$this->config->config_data['invoice_address']}";
+
+
$GLOBALS['phpgw']->preferences->set_account_id($common_data['workorder']['user_id'],
true);
+
+
+ $on_behalf_of_assigned =
phpgw::get_var('on_behalf_of_assigned', 'bool');
+ if($on_behalf_of_assigned &&
isset($ticket['assignedto_name']))
+ {
+ $from_name = $ticket['assignedto_name'];
+
$GLOBALS['phpgw']->preferences->set_account_id($ticket['assignedto'], true);
+ $GLOBALS['phpgw_info']['user']['preferences'] =
$GLOBALS['phpgw']->preferences->data;
+ if(!$preview_pdf)
+ {
+ $_behalf_alert = lang('this order is
sent by %1 on behalf of %2',$GLOBALS['phpgw_info']['user']['fullname'],
$from_name);
+ $historylog =
CreateObject('property.historylog','tts');
+
$historylog->add('C',$id,$_behalf_alert);
+ unset($_behalf_alert);
+ }
+ }
+ else
+ {
+ $from_name =
$GLOBALS['phpgw_info']['user']['fullname'];
+ }
+
+ $from = lang('date') . ": {$date}\n";
+ $from .= lang('dimb') .": {$ticket['ecodimb']}\n";
+ $from .= lang('from') . ":\n {$from_name}";
+ $from .= "\n
{$GLOBALS['phpgw']->preferences->data['property']['email']}";
+ $from .= "\n
{$GLOBALS['phpgw']->preferences->data['property']['cellphone']}";
+
+
+
+ if(isset($ticket['vendor_id']) && $ticket['vendor_id'])
+ {
+ $contacts =
CreateObject('property.sogeneric');
+ $contacts->get_location_info('vendor',false);
+
+ $custom =
createObject('property.custom_fields');
+ $vendor_data['attributes'] =
$custom->find('property','.vendor', 0, '', 'ASC', 'attrib_sort', true, true);
+
+ $vendor_data =
$contacts->read_single(array('id' => $ticket['vendor_id']),$vendor_data);
+ if(is_array($vendor_data))
+ {
+ foreach($vendor_data['attributes'] as
$attribute)
+ {
+
if($attribute['name']=='org_name')
+ {
+
$ticket['vendor_name']=$attribute['value'];
+ break;
+ }
+ }
+ }
+ unset($contacts);
+ }
+
+ $data = array
+ (
+ array('col1'=>lang('vendor') .
":\n{$ticket['vendor_name']}",'col2' => $delivery_address),
+ array('col1'=>$from,'col2'=>$invoice_address)
+ );
+
+ $pdf->ezTable($data,array('col1'=>'','col2'=>''),''
+ ,array('showHeadings'=>0,'shaded'=>0,'xPos'=>0
+
,'xOrientation'=>'right','width'=>500,'showLines'=> 2
+ ,'cols'=>array
+ (
+
'col1'=>array('justification'=>'right','width'=>250, 'justification'=>'left'),
+
'col2'=>array('justification'=>'right','width'=>250, 'justification'=>'left'),
+ )
+
+ ));
+
+// $pdf->ezText(lang('title').':',20);
+// $pdf->ezText(lang('order') . "
#{$ticket['order_id']}",14);
+// $pdf->ezSetDy(-20);
+
+ $pdf->ezText(lang('descr').':',20);
+
+ $ressursnr =
$GLOBALS['phpgw_info']['user']['preferences']['property']['ressursnr'];
+
+
$contact_data=$this->bocommon->initiate_ui_contact_lookup(array(
+ 'contact_id' =>
$ticket['contact_id'],
+ 'field' => 'contact',
+ 'type' => 'form'));
+
+
+ if(isset($contact_data['value_contact_name'])
&& $contact_data['value_contact_name'])
+ {
+ $contact_name =
$contact_data['value_contact_name'];
+ }
+ if(isset($contact_data['value_contact_email'])
&& $contact_data['value_contact_email'])
+ {
+ $contact_email = "<a
href='mailto:{$contact_data['value_contact_email']}'>{$contact_data['value_contact_email']}</a>";
+ }
+ if(isset($contact_data['value_contact_tel']) &&
$contact_data['value_contact_tel'])
+ {
+ $contact_phone =
$contact_data['value_contact_tel'];
+ }
+
+ $order_email_template =
$GLOBALS['phpgw_info']['user']['preferences']['property']['order_email_template'];
+
+ $descr = str_replace(array
+ (
+ // '__vendor_name__',
+ // '__organisation__',
+ // '__user_name__',
+ // '__user_phone__',
+ // '__user_email__',
+ '__ressursnr__',
+ // '__location__',
+ '__order_description__',
+ '__contact_name__',
+ '__contact_email__',
+ '__contact_phone__',
+ '__order_id__',
+ '[b]',
+ '[/b]'
+ ),array
+ (
+ //
$vendor_data['value_vendor_name'],
+ // $organisation,
+ // $user_name,
+ // $user_phone,
+ // $user_email,
+ $ressursnr,
+ // $location,
+ $order_description,
+ $contact_name,
+ $contact_email,
+ $contact_phone,
+ $order_id,
+ '<b>',
+ '</b>'
+ ),$order_email_template);
+
+
+ $pdf->ezText($descr,14);
+
+ if($content)
+ {
+ $pdf->ezSetDy(-20);
+ $pdf->ezTable($content,'',lang('details'),
+
array('xPos'=>0,'xOrientation'=>'right','width'=>500,0,'shaded'=>0,'fontSize'
=> 8,'showLines'=> 2,'titleFontSize' => 12,'outerLineThickness'=>2
+ ,'cols'=>array(
+ lang('bill per
unit')=>array('justification'=>'right','width'=>50)
+
,lang('quantity')=>array('justification'=>'right','width'=>50)
+
,lang('cost')=>array('justification'=>'right','width'=>50)
+
,lang('unit')=>array('width'=>40)
+
,lang('descr')=>array('width'=>120))
+ ));
+ }
+
+
if(isset($this->config->config_data['order_footer_header']) &&
$this->config->config_data['order_footer_header'])
+ {
+ if(!$content)
+ {
+ $pdf->ezSetDy(-100);
+ }
+
$pdf->ezText($this->config->config_data['order_footer_header'],12);
+
$pdf->ezText($this->config->config_data['order_footer'],10);
+ }
+
+ $document= $pdf->ezOutput();
+$preview = true;
+ if($preview)
+ {
+ $pdf->print_pdf($document,'order');
+ }
+ else
+ {
+ return $document;
+ }
+ }
+
}
Modified: trunk/property/templates/base/tts.xsl
===================================================================
--- trunk/property/templates/base/tts.xsl 2013-11-05 11:33:16 UTC (rev
11432)
+++ trunk/property/templates/base/tts.xsl 2013-11-05 14:08:36 UTC (rev
11433)
@@ -406,6 +406,16 @@
Window1=window.open(strURL,'Search',"left=50,top=100,width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
}
+
+ function preview_pdf(id)
+ {
+ var on_behalf_of_assigned =
document.getElementById("on_behalf_of_assigned").checked ? 1 : 0;
+
+ var oArgs =
{menuaction:'property.uitts.view',id:id, preview_pdf:true,
on_behalf_of_assigned: on_behalf_of_assigned};
+ var strURL = phpGWLink('index.php', oArgs);
+
Window1=window.open(strURL,'Search',"left=50,top=100,width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");
+ }
+
</script>
<table cellpadding="2" cellspacing="2" width="95%"
align="center">
<xsl:choose>
@@ -819,8 +829,8 @@
</td>
<td>
<xsl:value-of select="value_order_id"/>
-
<xsl:text> </xsl:text>
<input type="hidden" name="values[order_id]"
value="{value_order_id}"/>
+
<xsl:text> | </xsl:text>
<xsl:variable name="lang_preview_html">
<xsl:value-of select="php:function('lang',
'preview html')"/>
</xsl:variable>
@@ -830,6 +840,16 @@
</xsl:attribute>
<xsl:value-of select="$lang_preview_html"/>
</a>
+
<xsl:text> | </xsl:text>
+
<xsl:variable name="lang_preview_pdf">
+
<xsl:value-of select="php:function('lang',
'preview pdf')"/>
+
</xsl:variable>
+
<a href="{preview_pdf}">
+
<xsl:attribute name="title">
+
<xsl:value-of select="$lang_preview_pdf"/>
+
</xsl:attribute>
+
<xsl:value-of select="$lang_preview_pdf"/>
+
</a>
</td>
</tr>
<tr>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11433] property: pdf preview,
Sigurd Nes <=