@@ -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">'; |
| 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 | $buffer .= '<tr>'; |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | $options['bordercolor'][2] |
| 304 | 304 | ); |
| 305 | 305 | $this->SetLineWidth($options['borderwidth']); |
| 306 | - $this->SetFont($this->defaultOptions['font']['family'], 'B', $options['fontsize']); |
|
| 306 | + $this->SetFont($this->defaultOptions['font']['family'], 'B', $options['fontsize']); |
|
| 307 | 307 | // corregir indices |
| 308 | 308 | $headers_keys = array_keys($headers); |
| 309 | 309 | if (is_array($options['width'])) { |
@@ -325,13 +325,13 @@ discard block |
||
| 325 | 325 | } |
| 326 | 326 | // Header |
| 327 | 327 | $x = $this->GetX(); |
| 328 | - foreach($headers as $i => $header) { |
|
| 328 | + foreach ($headers as $i => $header) { |
|
| 329 | 329 | $this->Cell($options['width'][$i], $options['height'], $headers[$i], 1, 0, $options['align'][$i], 1); |
| 330 | 330 | } |
| 331 | 331 | $this->Ln(); |
| 332 | 332 | $y = $this->GetY(); |
| 333 | 333 | // Color and font restoration |
| 334 | - $this->SetFillColor ( |
|
| 334 | + $this->SetFillColor( |
|
| 335 | 335 | $options['bodybackground'][0], |
| 336 | 336 | $options['bodybackground'][1], |
| 337 | 337 | $options['bodybackground'][2] |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | $this->SetX($x); |
| 357 | 357 | $y_0 = $this->GetY(); |
| 358 | 358 | $y_s = []; |
| 359 | - foreach($headers as $i => $header) { |
|
| 359 | + foreach ($headers as $i => $header) { |
|
| 360 | 360 | $x_0 = $this->GetX(); |
| 361 | 361 | $this->SetXY($x_0, $y_0); |
| 362 | 362 | $aux = explode("\n", $row[$i]); |
@@ -366,28 +366,28 @@ discard block |
||
| 366 | 366 | if ($value2) { |
| 367 | 367 | $this->Ln(); |
| 368 | 368 | $this->SetX($x_0); |
| 369 | - $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']-2); |
|
| 369 | + $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']-2); |
|
| 370 | 370 | $y_2 = $this->MultiCell($options['width'][$i], $options['height'], $value2, $options['tdborder'], $options['align'][$i], false, 0); |
| 371 | - $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']); |
|
| 372 | - $y_s[] = $y_1 + $y_2*0.9; |
|
| 371 | + $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']); |
|
| 372 | + $y_s[] = $y_1+$y_2 * 0.9; |
|
| 373 | 373 | } else { |
| 374 | 374 | $y_s[] = $y_1; |
| 375 | 375 | } |
| 376 | 376 | } |
| 377 | - $this->Ln(max($y_s)*5); |
|
| 377 | + $this->Ln(max($y_s) * 5); |
|
| 378 | 378 | // si se pasó a página siguiente se hace rollback y se crea nueva página con cabecera nuevamente en la tabla |
| 379 | - if($num_pages < $this->getNumPages()) { |
|
| 379 | + if ($num_pages<$this->getNumPages()) { |
|
| 380 | 380 | $this->rollbackTransaction(true); |
| 381 | 381 | $this->AddPage(); |
| 382 | 382 | $this->SetX($x); |
| 383 | - foreach($headers as $i => $header) { |
|
| 383 | + foreach ($headers as $i => $header) { |
|
| 384 | 384 | $this->Cell($options['width'][$i], $options['height'], $headers[$i], 1, 0, $options['align'][$i], 1); |
| 385 | 385 | } |
| 386 | 386 | $this->Ln(); |
| 387 | 387 | $this->SetX($x); |
| 388 | 388 | $y_0 = $this->GetY(); |
| 389 | 389 | $y_s = []; |
| 390 | - foreach($headers as $i => $header) { |
|
| 390 | + foreach ($headers as $i => $header) { |
|
| 391 | 391 | $x_0 = $this->GetX(); |
| 392 | 392 | $this->SetXY($x_0, $y_0); |
| 393 | 393 | $aux = explode("\n", $row[$i]); |
@@ -397,15 +397,15 @@ discard block |
||
| 397 | 397 | if ($value2) { |
| 398 | 398 | $this->Ln(); |
| 399 | 399 | $this->SetX($x_0); |
| 400 | - $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']-2); |
|
| 400 | + $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']-2); |
|
| 401 | 401 | $y_2 = $this->MultiCell($options['width'][$i], $options['height'], $value2, $options['tdborder'], $options['align'][$i], false, 0); |
| 402 | - $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']); |
|
| 403 | - $y_s[] = $y_1 + $y_2*0.9; |
|
| 402 | + $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']); |
|
| 403 | + $y_s[] = $y_1+$y_2 * 0.9; |
|
| 404 | 404 | } else { |
| 405 | 405 | $y_s[] = $y_1; |
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | - $this->Ln(max($y_s)*5); |
|
| 408 | + $this->Ln(max($y_s) * 5); |
|
| 409 | 409 | } else { |
| 410 | 410 | $this->commitTransaction(); |
| 411 | 411 | } |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl) |
| 435 | 435 | * @version 2014-09-20 |
| 436 | 436 | */ |
| 437 | - public function Texto($txt, $x=null, $y=null, $align='', $w=0, $link='', $border=0, $fill=false) |
|
| 437 | + public function Texto($txt, $x = null, $y = null, $align = '', $w = 0, $link = '', $border = 0, $fill = false) |
|
| 438 | 438 | { |
| 439 | 439 | if ($x==null) $x = $this->GetX(); |
| 440 | 440 | if ($y==null) $y = $this->GetY(); |
@@ -455,7 +455,7 @@ discard block |
||
| 455 | 455 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl) |
| 456 | 456 | * @version 2014-09-20 |
| 457 | 457 | */ |
| 458 | - public function MultiTexto($txt, $x=null, $y=null, $align='', $w=0, $border=0, $fill=false) |
|
| 458 | + public function MultiTexto($txt, $x = null, $y = null, $align = '', $w = 0, $border = 0, $fill = false) |
|
| 459 | 459 | { |
| 460 | 460 | if ($x==null) $x = $this->GetX(); |
| 461 | 461 | if ($y==null) $y = $this->GetY(); |