@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | namespace sasco\LibreDTE; |
| 25 | 25 | |
| 26 | 26 | // Directorio para imágenes (no se asume nada) |
| 27 | -define ('K_PATH_IMAGES', ''); |
|
| 27 | +define('K_PATH_IMAGES', ''); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Clase para generar PDFs |
@@ -152,13 +152,13 @@ discard block |
||
| 152 | 152 | { |
| 153 | 153 | $widths = []; |
| 154 | 154 | if (is_int($cells)) { |
| 155 | - $width = floor($total/$cells); |
|
| 156 | - for ($i=0; $i<$cells; ++$i) { |
|
| 155 | + $width = floor($total / $cells); |
|
| 156 | + for ($i = 0; $i<$cells; ++$i) { |
|
| 157 | 157 | $widths[] = $width; |
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | - else if (is_array($cells)){ |
|
| 161 | - $width = floor($total/count($cells)); |
|
| 160 | + else if (is_array($cells)) { |
|
| 161 | + $width = floor($total / count($cells)); |
|
| 162 | 162 | foreach ($cells as $i) { |
| 163 | 163 | $widths[$i] = $width; |
| 164 | 164 | } |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $suma += $val; |
| 209 | 209 | } |
| 210 | 210 | if ($key_0!==null) { |
| 211 | - $options['width'][$key_0] = 190 - $suma; |
|
| 211 | + $options['width'][$key_0] = 190-$suma; |
|
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | if (isset($options['align'])) |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $a = (isset($options['align']) and is_array($options['align'])) ? $options['align'] : []; |
| 244 | 244 | $buffer = '<table style="border:1px solid #333;'.$width_table.'">'; |
| 245 | 245 | // Definir títulos de columnas |
| 246 | - $thead = isset($options['width']) and is_array($options['width']) and count($options['width']) == count($headers); |
|
| 246 | + $thead = isset($options['width']) and is_array($options['width']) and count($options['width'])==count($headers); |
|
| 247 | 247 | if ($thead) { |
| 248 | 248 | $buffer .= '<thead>'; |
| 249 | 249 | } |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | $options['bordercolor'][2] |
| 308 | 308 | ); |
| 309 | 309 | $this->SetLineWidth($options['borderwidth']); |
| 310 | - $this->SetFont($this->defaultOptions['font']['family'], 'B', $options['fontsize']); |
|
| 310 | + $this->SetFont($this->defaultOptions['font']['family'], 'B', $options['fontsize']); |
|
| 311 | 311 | // corregir indices |
| 312 | 312 | $headers_keys = array_keys($headers); |
| 313 | 313 | if (is_array($options['width'])) { |
@@ -329,13 +329,13 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | // Header |
| 331 | 331 | $x = $this->GetX(); |
| 332 | - foreach($headers as $i => $header) { |
|
| 332 | + foreach ($headers as $i => $header) { |
|
| 333 | 333 | $this->Cell($options['width'][$i], $options['height'], $headers[$i], 1, 0, $options['align'][$i], 1); |
| 334 | 334 | } |
| 335 | 335 | $this->Ln(); |
| 336 | 336 | $y = $this->GetY(); |
| 337 | 337 | // Color and font restoration |
| 338 | - $this->SetFillColor ( |
|
| 338 | + $this->SetFillColor( |
|
| 339 | 339 | $options['bodybackground'][0], |
| 340 | 340 | $options['bodybackground'][1], |
| 341 | 341 | $options['bodybackground'][2] |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | $this->SetX($x); |
| 361 | 361 | $y_0 = $this->GetY(); |
| 362 | 362 | $y_s = []; |
| 363 | - foreach($headers as $i => $header) { |
|
| 363 | + foreach ($headers as $i => $header) { |
|
| 364 | 364 | $x_0 = $this->GetX(); |
| 365 | 365 | $this->SetXY($x_0, $y_0); |
| 366 | 366 | $aux = explode("\n", $row[$i]); |
@@ -370,28 +370,28 @@ discard block |
||
| 370 | 370 | if ($value2) { |
| 371 | 371 | $this->Ln(); |
| 372 | 372 | $this->SetX($x_0); |
| 373 | - $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']-2); |
|
| 373 | + $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']-2); |
|
| 374 | 374 | $y_2 = $this->MultiCell($options['width'][$i], $options['height'], $value2, $options['tdborder'], $options['align'][$i], false, 0); |
| 375 | - $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']); |
|
| 376 | - $y_s[] = $y_1 + $y_2*0.9; |
|
| 375 | + $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']); |
|
| 376 | + $y_s[] = $y_1+$y_2 * 0.9; |
|
| 377 | 377 | } else { |
| 378 | 378 | $y_s[] = $y_1; |
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | - $this->Ln(max($y_s)*5); |
|
| 381 | + $this->Ln(max($y_s) * 5); |
|
| 382 | 382 | // si se pasó a página siguiente se hace rollback y se crea nueva página con cabecera nuevamente en la tabla |
| 383 | - if($num_pages < $this->getNumPages()) { |
|
| 383 | + if ($num_pages<$this->getNumPages()) { |
|
| 384 | 384 | $this->rollbackTransaction(true); |
| 385 | 385 | $this->AddPage(); |
| 386 | 386 | $this->SetX($x); |
| 387 | - foreach($headers as $i => $header) { |
|
| 387 | + foreach ($headers as $i => $header) { |
|
| 388 | 388 | $this->Cell($options['width'][$i], $options['height'], $headers[$i], 1, 0, $options['align'][$i], 1); |
| 389 | 389 | } |
| 390 | 390 | $this->Ln(); |
| 391 | 391 | $this->SetX($x); |
| 392 | 392 | $y_0 = $this->GetY(); |
| 393 | 393 | $y_s = []; |
| 394 | - foreach($headers as $i => $header) { |
|
| 394 | + foreach ($headers as $i => $header) { |
|
| 395 | 395 | $x_0 = $this->GetX(); |
| 396 | 396 | $this->SetXY($x_0, $y_0); |
| 397 | 397 | $aux = explode("\n", $row[$i]); |
@@ -401,15 +401,15 @@ discard block |
||
| 401 | 401 | if ($value2) { |
| 402 | 402 | $this->Ln(); |
| 403 | 403 | $this->SetX($x_0); |
| 404 | - $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']-2); |
|
| 404 | + $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']-2); |
|
| 405 | 405 | $y_2 = $this->MultiCell($options['width'][$i], $options['height'], $value2, $options['tdborder'], $options['align'][$i], false, 0); |
| 406 | - $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']); |
|
| 407 | - $y_s[] = $y_1 + $y_2*0.9; |
|
| 406 | + $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']); |
|
| 407 | + $y_s[] = $y_1+$y_2 * 0.9; |
|
| 408 | 408 | } else { |
| 409 | 409 | $y_s[] = $y_1; |
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | - $this->Ln(max($y_s)*5); |
|
| 412 | + $this->Ln(max($y_s) * 5); |
|
| 413 | 413 | } else { |
| 414 | 414 | $this->commitTransaction(); |
| 415 | 415 | } |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl) |
| 439 | 439 | * @version 2014-09-20 |
| 440 | 440 | */ |
| 441 | - public function Texto($txt, $x=null, $y=null, $align='', $w=0, $link='', $border=0, $fill=false) |
|
| 441 | + public function Texto($txt, $x = null, $y = null, $align = '', $w = 0, $link = '', $border = 0, $fill = false) |
|
| 442 | 442 | { |
| 443 | 443 | if ($x==null) $x = $this->GetX(); |
| 444 | 444 | if ($y==null) $y = $this->GetY(); |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl) |
| 460 | 460 | * @version 2014-09-20 |
| 461 | 461 | */ |
| 462 | - public function MultiTexto($txt, $x=null, $y=null, $align='', $w=0, $border=0, $fill=false) |
|
| 462 | + public function MultiTexto($txt, $x = null, $y = null, $align = '', $w = 0, $border = 0, $fill = false) |
|
| 463 | 463 | { |
| 464 | 464 | if ($x==null) $x = $this->GetX(); |
| 465 | 465 | if ($y==null) $y = $this->GetY(); |