| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | |
|---|
| 27 | |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | |
|---|
| 32 | |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | $type = $data['type']; |
|---|
| 46 | $info = $data['info']; |
|---|
| 47 | $recipient = $data['recipient']; |
|---|
| 48 | $letterhead = $data['letterhead']; |
|---|
| 49 | $watermark = ''; |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | $this->ezSetMargins(140, |
|---|
| 53 | 70, |
|---|
| 54 | PHPAGA_PDF_BORDER_LEFT, |
|---|
| 55 | PHPAGA_PDF_BORDER_RIGHT); |
|---|
| 56 | |
|---|
| 57 | if ($letterhead) |
|---|
| 58 | { |
|---|
| 59 | if (!isset($lethead) || !strlen($lethead)) |
|---|
| 60 | include(PHPAGA_BASEPATH.'pdftemplates/letterhead.tpl.php'); |
|---|
| 61 | $this->addObject($lethead,'all'); |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | if ($type == PHPAGA_TYPE_INVOICE) |
|---|
| 65 | { |
|---|
| 66 | $details = $info['bill_details']; |
|---|
| 67 | $header = array(array('label' => sprintf("%s:", utf8_decode(_('Invoice'))), |
|---|
| 68 | 'text' => $info['bill_number']), |
|---|
| 69 | |
|---|
| 70 | array('label' => sprintf("%s:",_('Date')), |
|---|
| 71 | 'text' => date(PHPAGA_DATEFORMAT_PRINT, |
|---|
| 72 | strtotime($info['bill_date'])))); |
|---|
| 73 | |
|---|
| 74 | if (isset($info['bill_date_due']) && strlen($info['bill_date_due'])) |
|---|
| 75 | $header[] = array('label' => sprintf("%s:",utf8_decode(_('Date due'))), |
|---|
| 76 | 'text' => date(PHPAGA_DATEFORMAT_PRINT, |
|---|
| 77 | strtotime($info['bill_date_due']))); |
|---|
| 78 | |
|---|
| 79 | if (isset($info['bill_payterm']) && strlen($info['bill_payterm'])) |
|---|
| 80 | $header[] = array('label' => sprintf("%s:",utf8_decode(_('Term of payment'))), |
|---|
| 81 | 'text' => $info['bill_payterm']); |
|---|
| 82 | |
|---|
| 83 | $watermark = sprintf(_("%s %s / %s"), |
|---|
| 84 | utf8_decode(_('Invoice')), $info['bill_number'], |
|---|
| 85 | date(PHPAGA_DATEFORMAT_PRINT, |
|---|
| 86 | strtotime($info['bill_date']))); |
|---|
| 87 | |
|---|
| 88 | } |
|---|
| 89 | else |
|---|
| 90 | { |
|---|
| 91 | $details = $info['quot_details']; |
|---|
| 92 | $header = array(array('label' => sprintf("%s:",utf8_decode(_('Quotation'))), |
|---|
| 93 | 'text' => $info['quot_number']), |
|---|
| 94 | |
|---|
| 95 | array('label' => sprintf("%s:",utf8_decode(_('Date'))), |
|---|
| 96 | 'text' => date(PHPAGA_DATEFORMAT_PRINT, |
|---|
| 97 | strtotime($info['quot_date'])))); |
|---|
| 98 | |
|---|
| 99 | if (isset($info['quot_payterm']) && strlen($info['quot_payterm'])) |
|---|
| 100 | $header[] = array('label' => sprintf("%s:",utf8_decode(_('Term of payment'))), |
|---|
| 101 | 'text' => $info['quot_payterm']); |
|---|
| 102 | |
|---|
| 103 | $watermark = sprintf(_("%s %s / %s"), |
|---|
| 104 | utf8_decode(_('Quotation')), $info['quot_number'], |
|---|
| 105 | date(PHPAGA_DATEFORMAT_PRINT, |
|---|
| 106 | strtotime($info['quot_date']))); |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | $this->setColor(0.9, 0.9, 0.9, 1); |
|---|
| 110 | |
|---|
| 111 | $this->addText(PHPAGA_PDF_BORDER_LEFT, |
|---|
| 112 | PHPAGA_PDF_POS_Y_RECIPIENT + 20, |
|---|
| 113 | 35, |
|---|
| 114 | $watermark); |
|---|
| 115 | |
|---|
| 116 | $this->setColor(0, 0, 0, 1); |
|---|
| 117 | |
|---|
| 118 | if (isset($recipient['cpn_taxnr']) && strlen($recipient['cpn_taxnr'])) { |
|---|
| 119 | $header[] = array('label' => sprintf("%s:",utf8_decode(_('VAT number'))), |
|---|
| 120 | 'text' => $recipient['cpn_taxnr']); |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | if ($recipient != null) { |
|---|
| 124 | include_once(PHPAGA_BASEPATH.'pdftemplates/recipient.tpl.php'); |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | $this->ezSetY(PHPAGA_PDF_POS_Y_RECIPIENT - 25); |
|---|
| 128 | |
|---|
| 129 | $this->ezTable($header, |
|---|
| 130 | array('label' => '', |
|---|
| 131 | 'text' => ''), |
|---|
| 132 | '', |
|---|
| 133 | array('xPos' => PHPAGA_PDF_BORDER_LEFT + 10, |
|---|
| 134 | 'xOrientation' => 'right', |
|---|
| 135 | 'showHeadings' => 0, |
|---|
| 136 | 'shaded' => 0, |
|---|
| 137 | 'fontSize' => PHPAGA_PDF_FONT_SIZE_SMALL, |
|---|
| 138 | 'maxWidth' => PHPAGA_PDF_DOCWIDTH - |
|---|
| 139 | (2 * PHPAGA_PDF_BORDER_LEFT), |
|---|
| 140 | 'showLines' => 0, |
|---|
| 141 | 'cols' => |
|---|
| 142 | array('label' => |
|---|
| 143 | array('justification' => |
|---|
| 144 | 'right'), |
|---|
| 145 | 'text' => |
|---|
| 146 | array('justification' => |
|---|
| 147 | 'left')), |
|---|
| 148 | 'protectRows' => 5)); |
|---|
| 149 | |
|---|
| 150 | $setnum = $this->ezStartPageNumbers(PHPAGA_PDF_DOCWIDTH - PHPAGA_PDF_BORDER_LEFT, |
|---|
| 151 | PHPAGA_PDF_SEPARATOR_BOTTOM_HEIGHT - PHPAGA_PDF_HEADER_NEXTLINE, |
|---|
| 152 | PHPAGA_PDF_FONT_SIZE_SMALL, |
|---|
| 153 | 'left', |
|---|
| 154 | _('Page').' {PAGENUM} / {TOTALPAGENUM}', |
|---|
| 155 | 1); |
|---|
| 156 | |
|---|
| 157 | $this->ezSetDY(-PHPAGA_PDF_BILL_NEXTLINE * 2); |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | |
|---|
| 161 | if (!isset($info['lineitems'])) { |
|---|
| 162 | $info['lineitems'] = array(); |
|---|
| 163 | |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | $this->ezTable($info['lineitems'], |
|---|
| 167 | array('lit_prodcode' => sprintf("<b>%s</b>", utf8_decode(_('Product code'))), |
|---|
| 168 | 'lit_desc' => sprintf("<b>%s</b>", utf8_decode(_('Description'))), |
|---|
| 169 | 'lit_qty' => sprintf("<b>%s</b>", utf8_decode(_('Qty./Hours'))), |
|---|
| 170 | 'lit_netprice_format' => sprintf("<b>%s</b>", utf8_decode(_('Net price')))), |
|---|
| 171 | '', |
|---|
| 172 | array('xPos' => PHPAGA_PDF_BORDER_LEFT + 5, |
|---|
| 173 | 'xOrientation' => 'right', |
|---|
| 174 | 'showHeadings' => 1, |
|---|
| 175 | 'shaded' => 0, |
|---|
| 176 | 'lineCol' => array(0.5, 0.5, 0.5), |
|---|
| 177 | 'outerLineThickness' => 0.3, |
|---|
| 178 | 'innerLineThickness' => 0.3, |
|---|
| 179 | 'fontSize' => PHPAGA_PDF_FONT_SIZE_SMALL, |
|---|
| 180 | 'width' => (PHPAGA_PDF_DOCWIDTH - |
|---|
| 181 | PHPAGA_PDF_BORDER_LEFT - |
|---|
| 182 | PHPAGA_PDF_BORDER_RIGHT), |
|---|
| 183 | 'maxWidth' => (PHPAGA_PDF_DOCWIDTH - |
|---|
| 184 | PHPAGA_PDF_BORDER_LEFT - |
|---|
| 185 | PHPAGA_PDF_BORDER_RIGHT), |
|---|
| 186 | 'showLines' => 2, |
|---|
| 187 | 'cols' => array('lit_qty' => array('justification' => 'right'), |
|---|
| 188 | 'lit_netprice_format' => array('justification' => 'right')))); |
|---|
| 189 | |
|---|
| 190 | $this->ezSetDY(-PHPAGA_PDF_BILL_NEXTLINE); |
|---|
| 191 | |
|---|
| 192 | |
|---|
| 193 | |
|---|
| 194 | |
|---|
| 195 | if (isset($info['expenses']) && array($info['expenses']) && count($info['expenses'])) { |
|---|
| 196 | |
|---|
| 197 | $expenses = array(); |
|---|
| 198 | |
|---|
| 199 | foreach ($info['expenses'] as $e) |
|---|
| 200 | $expenses[] = array('prj_title' => $e['prj_title'], |
|---|
| 201 | 'exp_date' => date(PHPAGA_DATEFORMAT_PRINT, strtotime($e['exp_date'])), |
|---|
| 202 | 'exp_desc' => $e['exp_desc'], |
|---|
| 203 | 'exp_sum' => phpaga_formatamount($e['exp_sum'])); |
|---|
| 204 | |
|---|
| 205 | $this->ezTable($expenses, |
|---|
| 206 | array('prj_title' => sprintf("<b>%s</b>", utf8_decode(_('Project'))), |
|---|
| 207 | 'exp_date' => sprintf("<b>%s</b>", utf8_decode(_('Date'))), |
|---|
| 208 | 'exp_desc' => sprintf("<b>%s</b>", utf8_decode(_('Description'))), |
|---|
| 209 | 'exp_sum' => sprintf("<b>%s</b>", utf8_decode(_('Amount')))), |
|---|
| 210 | utf8_decode(_('Reimbursable expenses')), |
|---|
| 211 | array('titleFontSize' => PHPAGA_PDF_FONT_SIZE_SMALL, |
|---|
| 212 | 'xPos' => PHPAGA_PDF_BORDER_LEFT + 5, |
|---|
| 213 | 'xOrientation' => 'right', |
|---|
| 214 | 'showHeadings' => 1, |
|---|
| 215 | 'shaded' => 0, |
|---|
| 216 | 'lineCol' => array(0.5, 0.5, 0.5), |
|---|
| 217 | 'outerLineThickness' => 0.3, |
|---|
| 218 | 'innerLineThickness' => 0.3, |
|---|
| 219 | 'fontSize' => PHPAGA_PDF_FONT_SIZE_SMALL, |
|---|
| 220 | 'width' => (PHPAGA_PDF_DOCWIDTH - |
|---|
| 221 | PHPAGA_PDF_BORDER_LEFT - |
|---|
| 222 | PHPAGA_PDF_BORDER_RIGHT), |
|---|
| 223 | 'maxWidth' => (PHPAGA_PDF_DOCWIDTH - |
|---|
| 224 | PHPAGA_PDF_BORDER_LEFT - |
|---|
| 225 | PHPAGA_PDF_BORDER_RIGHT), |
|---|
| 226 | 'showLines' => 2, |
|---|
| 227 | 'cols' => array('exp_sum' => array('justification' => 'right')))); |
|---|
| 228 | |
|---|
| 229 | $this->ezSetDY(-PHPAGA_PDF_BILL_NEXTLINE); |
|---|
| 230 | |
|---|
| 231 | } |
|---|
| 232 | |
|---|
| 233 | |
|---|
| 234 | |
|---|
| 235 | $this->ezTable($details, |
|---|
| 236 | array('text' => '', |
|---|
| 237 | 'amount' => ''), |
|---|
| 238 | '', |
|---|
| 239 | array('xPos' => PHPAGA_PDF_BORDER_LEFT + 5, |
|---|
| 240 | 'xOrientation' => 'right', |
|---|
| 241 | 'showHeadings' => 0, |
|---|
| 242 | 'shaded' => 0, |
|---|
| 243 | 'fontSize' => PHPAGA_PDF_FONT_SIZE_SMALL, |
|---|
| 244 | 'width' => (PHPAGA_PDF_DOCWIDTH - |
|---|
| 245 | PHPAGA_PDF_BORDER_LEFT - |
|---|
| 246 | PHPAGA_PDF_BORDER_RIGHT), |
|---|
| 247 | 'maxWidth' => (PHPAGA_PDF_DOCWIDTH - |
|---|
| 248 | PHPAGA_PDF_BORDER_LEFT - |
|---|
| 249 | PHPAGA_PDF_BORDER_RIGHT), |
|---|
| 250 | 'showLines' => 2, |
|---|
| 251 | 'lineCol' => array(0.5, 0.5, 0.5), |
|---|
| 252 | 'outerLineThickness' => 0.3, |
|---|
| 253 | 'innerLineThickness' => 0.3, |
|---|
| 254 | 'cols' => |
|---|
| 255 | array('amount' => |
|---|
| 256 | array('justification' => |
|---|
| 257 | 'right')), |
|---|
| 258 | 'protectRows' => 10)); |
|---|
| 259 | |
|---|
| 260 | $this->ezStopPageNumbers(1, 1, $setnum); |
|---|
| 261 | |
|---|
| 262 | if (($letterhead) && isset($lethead)) |
|---|
| 263 | { |
|---|
| 264 | $this->stopObject($lethead); |
|---|
| 265 | $this->ezSetMargins(30, 30, PHPAGA_PDF_BORDER_LEFT, PHPAGA_PDF_BORDER_RIGHT); |
|---|
| 266 | |
|---|
| 267 | } |
|---|
| 268 | |
|---|
| 269 | ?> |
|---|