Ticket #50: letterhead.tpl.php

File letterhead.tpl.php, 4.8 kB (added by nagual69, 14 months ago)

Tweaked

Line 
1<?php
2/**
3 * phpaga
4 *
5 * PDF template: show the letterhead
6 *
7 * This file contains the necessary routines to manage expenses.
8 *
9 * @author Florian Lanthaler <florian@phpaga.net>
10 * @version $Id: letterhead.tpl.php 887 2007-11-05 13:34:10Z florian $
11 *
12 * Copyright (c) 2003, Florian Lanthaler <florian@phpaga.net>
13 *
14 * All rights reserved.
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions are
18 * met:
19 *
20 *    * Redistributions of source code must retain the above copyright
21 *      notice, this list of conditions and the following disclaimer.
22 *
23 *    * Redistributions in binary form must reproduce the above copyright
24 *      notice, this list of conditions and the following disclaimer in
25 *      the documentation and/or other materials provided with the
26 *      distribution.
27 *
28 *    * Neither the name of Florian Lanthaler nor the names of his
29 *      contributors may be used to endorse or promote products derived
30 *      from this software without specific prior written permission.
31 *
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
33 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
34 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
35 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
36 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
37 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
38 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
39 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
41 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
42 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 */
44
45$logo_filename = $data["logo_filename"];
46
47$loc = "";
48
49$header = array ();
50$header[] = PHPAGA_LETTERHEAD_OWNER_PERSONALTAXNR;
51$header[] = PHPAGA_LETTERHEAD_COMPANY_TAXNR;
52$header[] = "";
53$header[] = PHPAGA_LETTERHEAD_COMPANY_PHONE;
54$header[] = "";
55
56$loc = array_reverse(explode("\n", PHPAGA_LETTERHEAD_COMPANY_FULLLOCATION));
57
58foreach($loc as $line)
59{
60    $header[] = $line;
61}
62
63$header[] = PHPAGA_LETTERHEAD_COMPANY_STREET;
64
65$lethead = $this->openObject();
66$this->saveState();
67
68$this->setStrokeColor(0,0,0, 1);
69$this->setLineStyle(0.5);
70$this->setColor(0,0,0, 1);
71
72$logo_center = (PHPAGA_PDF_DOCWIDTH / 2) - (PHPAGA_PDF_LOGOWIDTH / 2);
73
74/* show company logo if available */
75
76if (isset($logo_filename) && strlen($logo_filename)
77    && is_file($logo_filename) && is_readable($logo_filename))
78{
79    $this->addJpegFromFile($logo_filename,
80                           $logo_center,
81                           PHPAGA_PDF_POS_Y_LOGO,
82                           PHPAGA_PDF_LOGOWIDTH);
83}
84
85
86
87/* show company name */
88
89// $this->ezSetY(PHPAGA_PDF_POS_Y_HEADER_NAME);
90$this->ezSetY(PHPAGA_PDF_POS_Y_HEADER_NAME);
91$this->ezText(PHPAGA_LETTERHEAD_COMPANY_NAME,
92              PHPAGA_PDF_FONT_SIZE_HEADER,
93              array('aleft' => PHPAGA_PDF_BORDER_LEFT));
94
95/* email address */
96
97$this->ezSetY(PHPAGA_PDF_POS_Y_HEADER_EMAIL);
98$this->ezText(PHPAGA_LETTERHEAD_COMPANY_EMAIL,
99              PHPAGA_PDF_FONT_SIZE_NORMAL,
100              array('aleft' => PHPAGA_PDF_BORDER_LEFT));
101
102
103/* show the rest */
104
105$y = PHPAGA_PDF_POS_Y_HEADER_RLINE5;
106
107foreach ($header as $h)
108{
109    if (!strlen($h)) {
110        /* just hop a little bit upward */
111        $y = ($y + PHPAGA_PDF_HEADER_NEXTLINE / 1.5);
112    } else {
113        $this->ezSetY($y);
114        $this->ezText(utf8_decode($h), PHPAGA_PDF_FONT_SIZE_SMALL,
115                      array('aleft' => PHPAGA_PDF_START_RIGHT -
116                            $this->getTextWidth(PHPAGA_PDF_FONT_SIZE_SMALL, $h)));
117
118        $y += PHPAGA_PDF_HEADER_NEXTLINE;
119    }
120}
121
122/* draw top and bottom separator */
123
124$this->setStrokeColor(0.5,0.5,0.5, 1);
125$this->setLineStyle(0.5);
126
127$this->line(PHPAGA_PDF_BORDER_LEFT,
128            PHPAGA_PDF_SEPARATOR_TOP_HEIGHT,
129            PHPAGA_PDF_DOCWIDTH - PHPAGA_PDF_BORDER_RIGHT,
130            PHPAGA_PDF_SEPARATOR_TOP_HEIGHT);
131
132$this->line(PHPAGA_PDF_BORDER_LEFT,
133            PHPAGA_PDF_SEPARATOR_BOTTOM_HEIGHT,
134            PHPAGA_PDF_DOCWIDTH - PHPAGA_PDF_BORDER_RIGHT,
135            PHPAGA_PDF_SEPARATOR_BOTTOM_HEIGHT);
136
137/* draw the footer */
138$this->setColor(0.2,0.2,0.2, 1);
139/*
140$this->ezSetY(PHPAGA_PDF_SEPARATOR_BOTTOM_HEIGHT);
141
142$this->ezText(PHPAGA_LETTERHEAD_FOOTER,
143              PHPAGA_PDF_FONT_SIZE_SMALL,
144              array('justification'=>'centre'));
145*/
146
147
148$this->addText(PHPAGA_PDF_BORDER_LEFT,
149               PHPAGA_PDF_SEPARATOR_BOTTOM_HEIGHT - PHPAGA_PDF_HEADER_NEXTLINE,
150               PHPAGA_PDF_FONT_SIZE_SMALL,
151               PHPAGA_LETTERHEAD_FOOTER);
152
153$this->setColor(0,0,0, 1);
154$this->setStrokeColor(0,0,0, 1);
155
156$this->restoreState();
157$this->closeObject();
158
159?>