@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | /** |
| 177 | 177 | * Método que asigna la ubicación del logo de la empresa |
| 178 | 178 | * @param logo URI del logo (puede ser local o en una URL) |
| 179 | - * @param posicion Posición respecto a datos del emisor (=0 izq, =1 arriba) |
|
| 179 | + * @param posicion integer respecto a datos del emisor (=0 izq, =1 arriba) |
|
| 180 | 180 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 181 | 181 | * @version 2016-08-04 |
| 182 | 182 | */ |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | * contínuo |
| 356 | 356 | * @param dte Arreglo con los datos del XML (tag Documento) |
| 357 | 357 | * @param timbre String XML con el tag TED del DTE |
| 358 | - * @param width Ancho del papel contínuo en mm |
|
| 358 | + * @param width boolean del papel contínuo en mm |
|
| 359 | 359 | * @author Pablo Reyes (https://github.com/pabloxp) |
| 360 | 360 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 361 | 361 | * @version 2017-10-05 |
@@ -511,10 +511,11 @@ discard block |
||
| 511 | 511 | * - Dirección casa central del emisor |
| 512 | 512 | * - Dirección sucursales |
| 513 | 513 | * @param emisor Arreglo con los datos del emisor (tag Emisor del XML) |
| 514 | - * @param x Posición horizontal de inicio en el PDF |
|
| 515 | - * @param y Posición vertical de inicio en el PDF |
|
| 516 | - * @param w Ancho de la información del emisor |
|
| 517 | - * @param w_img Ancho máximo de la imagen |
|
| 514 | + * @param x integer horizontal de inicio en el PDF |
|
| 515 | + * @param y integer vertical de inicio en el PDF |
|
| 516 | + * @param w integer de la información del emisor |
|
| 517 | + * @param w_img integer máximo de la imagen |
|
| 518 | + * @param integer $font_size |
|
| 518 | 519 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 519 | 520 | * @version 2016-12-02 |
| 520 | 521 | */ |
@@ -584,11 +585,13 @@ discard block |
||
| 584 | 585 | * @param rut RUT del emisor |
| 585 | 586 | * @param tipo Código o glosa del tipo de documento |
| 586 | 587 | * @param sucursal_sii Código o glosa de la sucursal del SII del Emisor |
| 587 | - * @param x Posición horizontal de inicio en el PDF |
|
| 588 | - * @param y Posición vertical de inicio en el PDF |
|
| 589 | - * @param w Ancho de la información del emisor |
|
| 588 | + * @param x integer horizontal de inicio en el PDF |
|
| 589 | + * @param y integer vertical de inicio en el PDF |
|
| 590 | + * @param w integer de la información del emisor |
|
| 591 | + * @param integer $font_size |
|
| 590 | 592 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 591 | 593 | * @version 2016-12-02 |
| 594 | + * @return integer |
|
| 592 | 595 | */ |
| 593 | 596 | private function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
| 594 | 597 | { |
@@ -634,7 +637,7 @@ discard block |
||
| 634 | 637 | * Método que agrega los datos de la emisión del DTE que no son los dato del |
| 635 | 638 | * receptor |
| 636 | 639 | * @param IdDoc Información general del documento |
| 637 | - * @param x Posición horizontal de inicio en el PDF |
|
| 640 | + * @param x integer horizontal de inicio en el PDF |
|
| 638 | 641 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 639 | 642 | * @version 2017-06-15 |
| 640 | 643 | */ |
@@ -722,7 +725,7 @@ discard block |
||
| 722 | 725 | /** |
| 723 | 726 | * Método que agrega los datos del receptor |
| 724 | 727 | * @param receptor Arreglo con los datos del receptor (tag Receptor del XML) |
| 725 | - * @param x Posición horizontal de inicio en el PDF |
|
| 728 | + * @param x integer horizontal de inicio en el PDF |
|
| 726 | 729 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 727 | 730 | * @version 2017-06-15 |
| 728 | 731 | */ |
@@ -809,7 +812,7 @@ discard block |
||
| 809 | 812 | * Método que agrega los datos del traslado |
| 810 | 813 | * @param IndTraslado |
| 811 | 814 | * @param Transporte |
| 812 | - * @param x Posición horizontal de inicio en el PDF |
|
| 815 | + * @param x integer horizontal de inicio en el PDF |
|
| 813 | 816 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 814 | 817 | * @version 2016-08-03 |
| 815 | 818 | */ |
@@ -880,7 +883,7 @@ discard block |
||
| 880 | 883 | /** |
| 881 | 884 | * Método que agrega las referencias del documento |
| 882 | 885 | * @param referencias Arreglo con las referencias del documento (tag Referencia del XML) |
| 883 | - * @param x Posición horizontal de inicio en el PDF |
|
| 886 | + * @param x integer horizontal de inicio en el PDF |
|
| 884 | 887 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 885 | 888 | * @version 2017-09-25 |
| 886 | 889 | */ |
@@ -917,7 +920,7 @@ discard block |
||
| 917 | 920 | /** |
| 918 | 921 | * Método que agrega el detalle del documento |
| 919 | 922 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
| 920 | - * @param x Posición horizontal de inicio en el PDF |
|
| 923 | + * @param x integer horizontal de inicio en el PDF |
|
| 921 | 924 | * @param y Posición vertical de inicio en el PDF |
| 922 | 925 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 923 | 926 | * @version 2016-08-05 |
@@ -984,7 +987,7 @@ discard block |
||
| 984 | 987 | /** |
| 985 | 988 | * Método que agrega el detalle del documento |
| 986 | 989 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
| 987 | - * @param x Posición horizontal de inicio en el PDF |
|
| 990 | + * @param x integer horizontal de inicio en el PDF |
|
| 988 | 991 | * @param y Posición vertical de inicio en el PDF |
| 989 | 992 | * @author Pablo Reyes (https://github.com/pabloxp) |
| 990 | 993 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
@@ -1020,7 +1023,7 @@ discard block |
||
| 1020 | 1023 | * Método que agrega el subtotal del DTE |
| 1021 | 1024 | * @param detalle Arreglo con los detalles del documentos para poder |
| 1022 | 1025 | * calcular subtotal |
| 1023 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1026 | + * @param x integer horizontal de inicio en el PDF |
|
| 1024 | 1027 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1025 | 1028 | * @version 2016-08-17 |
| 1026 | 1029 | */ |
@@ -1046,7 +1049,7 @@ discard block |
||
| 1046 | 1049 | /** |
| 1047 | 1050 | * Método que agrega los descuentos y/o recargos globales del documento |
| 1048 | 1051 | * @param descuentosRecargos Arreglo con los descuentos y/o recargos del documento (tag DscRcgGlobal del XML) |
| 1049 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1052 | + * @param x integer horizontal de inicio en el PDF |
|
| 1050 | 1053 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1051 | 1054 | * @version 2016-08-17 |
| 1052 | 1055 | */ |
@@ -1070,7 +1073,7 @@ discard block |
||
| 1070 | 1073 | /** |
| 1071 | 1074 | * Método que agrega los pagos del documento |
| 1072 | 1075 | * @param pagos Arreglo con los pagos del documento |
| 1073 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1076 | + * @param x integer horizontal de inicio en el PDF |
|
| 1074 | 1077 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1075 | 1078 | * @version 2016-07-24 |
| 1076 | 1079 | */ |
@@ -1207,9 +1210,9 @@ discard block |
||
| 1207 | 1210 | * - Se imprime en el tamaño mínimo: 2x5 cms |
| 1208 | 1211 | * - En el lado de abajo con margen izquierdo mínimo de 2 cms |
| 1209 | 1212 | * @param timbre String con los datos del timbre |
| 1210 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1211 | - * @param y Posición vertical de inicio en el PDF |
|
| 1212 | - * @param w Ancho del timbre |
|
| 1213 | + * @param x integer horizontal de inicio en el PDF |
|
| 1214 | + * @param y integer vertical de inicio en el PDF |
|
| 1215 | + * @param w integer del timbre |
|
| 1213 | 1216 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1214 | 1217 | * @version 2017-10-05 |
| 1215 | 1218 | */ |
@@ -1247,10 +1250,10 @@ discard block |
||
| 1247 | 1250 | |
| 1248 | 1251 | /** |
| 1249 | 1252 | * Método que agrega el acuse de rebido |
| 1250 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1251 | - * @param y Posición vertical de inicio en el PDF |
|
| 1252 | - * @param w Ancho del acuse de recibo |
|
| 1253 | - * @param h Alto del acuse de recibo |
|
| 1253 | + * @param x integer horizontal de inicio en el PDF |
|
| 1254 | + * @param y integer vertical de inicio en el PDF |
|
| 1255 | + * @param w integer del acuse de recibo |
|
| 1256 | + * @param h integer del acuse de recibo |
|
| 1254 | 1257 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1255 | 1258 | * @version 2017-10-05 |
| 1256 | 1259 | */ |
@@ -1278,10 +1281,10 @@ discard block |
||
| 1278 | 1281 | |
| 1279 | 1282 | /** |
| 1280 | 1283 | * Método que agrega el acuse de rebido |
| 1281 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1284 | + * @param x integer horizontal de inicio en el PDF |
|
| 1282 | 1285 | * @param y Posición vertical de inicio en el PDF |
| 1283 | - * @param w Ancho del acuse de recibo |
|
| 1284 | - * @param h Alto del acuse de recibo |
|
| 1286 | + * @param w integer del acuse de recibo |
|
| 1287 | + * @param h integer del acuse de recibo |
|
| 1285 | 1288 | * @author Pablo Reyes (https://github.com/pabloxp) |
| 1286 | 1289 | * @version 2015-11-17 |
| 1287 | 1290 | */ |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | { |
| 171 | 171 | parent::__construct(); |
| 172 | 172 | $this->SetTitle('Documento Tributario Electrónico (DTE) de Chile by LibreDTE'); |
| 173 | - $this->papelContinuo = $papelContinuo === true ? 80 : $papelContinuo; |
|
| 173 | + $this->papelContinuo = $papelContinuo===true ? 80 : $papelContinuo; |
|
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | /** |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | $this->setY(max($y)); |
| 316 | 316 | $this->Ln(); |
| 317 | 317 | $y = []; |
| 318 | - $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null); |
|
| 318 | + $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null); |
|
| 319 | 319 | $y[] = $this->agregarReceptor($dte['Encabezado']); |
| 320 | 320 | $this->setY(max($y)); |
| 321 | 321 | $this->agregarTraslado( |
@@ -375,15 +375,15 @@ discard block |
||
| 375 | 375 | $dte['Encabezado']['IdDoc']['TipoDTE'], |
| 376 | 376 | $dte['Encabezado']['IdDoc']['Folio'], |
| 377 | 377 | $dte['Encabezado']['Emisor']['CmnaOrigen'], |
| 378 | - $x_start, $y_start, $width-($x_start*4), 10, |
|
| 379 | - [0,0,0] |
|
| 378 | + $x_start, $y_start, $width-($x_start * 4), 10, |
|
| 379 | + [0, 0, 0] |
|
| 380 | 380 | ); |
| 381 | - $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, 40, 8, 9, [0,0,0]); |
|
| 381 | + $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, 40, 8, 9, [0, 0, 0]); |
|
| 382 | 382 | // datos del documento |
| 383 | 383 | $this->SetY($y); |
| 384 | 384 | $this->Ln(); |
| 385 | 385 | $this->setFont('', '', 8); |
| 386 | - $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null, $x_start, $offset, false); |
|
| 386 | + $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null, $x_start, $offset, false); |
|
| 387 | 387 | $this->agregarReceptor($dte['Encabezado'], $x_start, $offset); |
| 388 | 388 | $this->agregarTraslado( |
| 389 | 389 | !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null, |
@@ -436,7 +436,7 @@ discard block |
||
| 436 | 436 | $this->AddPage('P', [$height ? $height : $this->papel_continuo_alto, $width]); |
| 437 | 437 | $x = 1; |
| 438 | 438 | $y = 5; |
| 439 | - $this->SetXY($x,$y); |
|
| 439 | + $this->SetXY($x, $y); |
|
| 440 | 440 | // agregar datos del documento |
| 441 | 441 | $this->setFont('', '', 8); |
| 442 | 442 | $this->MultiTexto(!empty($dte['Encabezado']['Emisor']['RznSoc']) ? $dte['Encabezado']['Emisor']['RznSoc'] : $dte['Encabezado']['Emisor']['RznSocEmisor'], $x, null, '', $width-2); |
@@ -526,13 +526,13 @@ discard block |
||
| 526 | 526 | $this->logo['uri'], |
| 527 | 527 | $x, |
| 528 | 528 | $y, |
| 529 | - !$this->logo['posicion']?$w_img:null, $this->logo['posicion']?($w_img/2):null, |
|
| 529 | + !$this->logo['posicion'] ? $w_img : null, $this->logo['posicion'] ? ($w_img / 2) : null, |
|
| 530 | 530 | 'PNG', |
| 531 | - (isset($emisor['url'])?$emisor['url']:''), |
|
| 531 | + (isset($emisor['url']) ? $emisor['url'] : ''), |
|
| 532 | 532 | 'T' |
| 533 | 533 | ); |
| 534 | 534 | if ($this->logo['posicion']) { |
| 535 | - $this->SetY($this->y + ($w_img/2)); |
|
| 535 | + $this->SetY($this->y+($w_img / 2)); |
|
| 536 | 536 | $w += 40; |
| 537 | 537 | } else { |
| 538 | 538 | $x = $this->x+3; |
@@ -543,13 +543,13 @@ discard block |
||
| 543 | 543 | } |
| 544 | 544 | // agregar datos del emisor |
| 545 | 545 | $this->setFont('', 'B', $font_size ? $font_size : 14); |
| 546 | - $this->SetTextColorArray($color===null?[32, 92, 144]:$color); |
|
| 546 | + $this->SetTextColorArray($color===null ? [32, 92, 144] : $color); |
|
| 547 | 547 | $this->MultiTexto(!empty($emisor['RznSoc']) ? $emisor['RznSoc'] : $emisor['RznSocEmisor'], $x, $this->y+2, 'L', $w); |
| 548 | 548 | $this->setFont('', 'B', $font_size ? $font_size : 9); |
| 549 | - $this->SetTextColorArray([0,0,0]); |
|
| 549 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 550 | 550 | $this->MultiTexto(!empty($emisor['GiroEmis']) ? $emisor['GiroEmis'] : $emisor['GiroEmisor'], $x, $this->y, 'L', $w); |
| 551 | 551 | $ciudad = !empty($emisor['CiudadOrigen']) ? $emisor['CiudadOrigen'] : \sasco\LibreDTE\Chile::getCiudad($emisor['CmnaOrigen']); |
| 552 | - $this->MultiTexto($emisor['DirOrigen'].', '.$emisor['CmnaOrigen'].($ciudad?(', '.$ciudad):''), $x, $this->y, 'L', $w); |
|
| 552 | + $this->MultiTexto($emisor['DirOrigen'].', '.$emisor['CmnaOrigen'].($ciudad ? (', '.$ciudad) : ''), $x, $this->y, 'L', $w); |
|
| 553 | 553 | if (!empty($emisor['Sucursal'])) { |
| 554 | 554 | $this->MultiTexto('Sucursal: '.$emisor['Sucursal'], $x, $this->y, 'L', $w); |
| 555 | 555 | } |
@@ -593,12 +593,12 @@ discard block |
||
| 593 | 593 | private function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
| 594 | 594 | { |
| 595 | 595 | if ($color===null) { |
| 596 | - $color = $tipo ? ($tipo==52 ? [0,172,140] : [255,0,0]) : [0,0,0]; |
|
| 596 | + $color = $tipo ? ($tipo==52 ? [0, 172, 140] : [255, 0, 0]) : [0, 0, 0]; |
|
| 597 | 597 | } |
| 598 | 598 | $this->SetTextColorArray($color); |
| 599 | 599 | // colocar rut emisor, glosa documento y folio |
| 600 | 600 | list($rut, $dv) = explode('-', $rut); |
| 601 | - $this->setFont ('', 'B', $font_size ? $font_size : 15); |
|
| 601 | + $this->setFont('', 'B', $font_size ? $font_size : 15); |
|
| 602 | 602 | $this->MultiTexto('R.U.T.: '.$this->num($rut).'-'.$dv, $x, $y+4, 'C', $w); |
| 603 | 603 | $this->setFont('', 'B', $font_size ? $font_size : 12); |
| 604 | 604 | $this->MultiTexto($this->getTipo($tipo), $x, null, 'C', $w); |
@@ -611,7 +611,7 @@ discard block |
||
| 611 | 611 | if ($tipo) { |
| 612 | 612 | $this->Texto('S.I.I. - '.\sasco\LibreDTE\Sii::getDireccionRegional($sucursal_sii), $x, $this->getY()+4, 'C', $w); |
| 613 | 613 | } |
| 614 | - $this->SetTextColorArray([0,0,0]); |
|
| 614 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 615 | 615 | $this->Ln(); |
| 616 | 616 | return $this->y; |
| 617 | 617 | } |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | $this->Texto('Señor(es)', $x); |
| 743 | 743 | $this->Texto(':', $x+$offset); |
| 744 | 744 | $this->setFont('', '', null); |
| 745 | - $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
| 745 | + $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
| 746 | 746 | } |
| 747 | 747 | if (!empty($receptor['GiroRecep'])) { |
| 748 | 748 | $this->setFont('', 'B', null); |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | $ciudad = !empty($receptor['CiudadRecep']) ? $receptor['CiudadRecep'] : ( |
| 760 | 760 | !empty($receptor['CmnaRecep']) ? \sasco\LibreDTE\Chile::getCiudad($receptor['CmnaRecep']) : '' |
| 761 | 761 | ); |
| 762 | - $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep'])?(', '.$receptor['CmnaRecep']):'').($ciudad?(', '.$ciudad):''), $x+$offset+2); |
|
| 762 | + $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep']) ? (', '.$receptor['CmnaRecep']) : '').($ciudad ? (', '.$ciudad) : ''), $x+$offset+2); |
|
| 763 | 763 | } |
| 764 | 764 | if (!empty($receptor['Extranjero']['Nacionalidad'])) { |
| 765 | 765 | $this->setFont('', 'B', null); |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | $this->Texto('Cód. recep.', $x); |
| 801 | 801 | $this->Texto(':', $x+$offset); |
| 802 | 802 | $this->setFont('', '', null); |
| 803 | - $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
| 803 | + $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
| 804 | 804 | } |
| 805 | 805 | return $this->GetY(); |
| 806 | 806 | } |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | { |
| 889 | 889 | if (!isset($referencias[0])) |
| 890 | 890 | $referencias = [$referencias]; |
| 891 | - foreach($referencias as $r) { |
|
| 891 | + foreach ($referencias as $r) { |
|
| 892 | 892 | $texto = $r['NroLinRef'].' - '; |
| 893 | 893 | if (!empty($r['TpoDocRef'])) { |
| 894 | 894 | $texto .= $this->getTipo($r['TpoDocRef']).' '; |
@@ -995,9 +995,9 @@ discard block |
||
| 995 | 995 | $this->SetY($this->getY()+1); |
| 996 | 996 | $p1x = $x; |
| 997 | 997 | $p1y = $this->y; |
| 998 | - $p2x = $this->getPageWidth() - 2; |
|
| 999 | - $p2y = $p1y; // Use same y for a straight line |
|
| 1000 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
| 998 | + $p2x = $this->getPageWidth()-2; |
|
| 999 | + $p2y = $p1y; // Use same y for a straight line |
|
| 1000 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
| 1001 | 1001 | $this->Line($p1x, $p1y, $p2x, $p2y, $style); |
| 1002 | 1002 | $this->Texto($this->detalle_cols['NmbItem']['title'], $x+1, $this->y, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
| 1003 | 1003 | $this->Texto($this->detalle_cols['PrcItem']['title'], $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
@@ -1007,9 +1007,9 @@ discard block |
||
| 1007 | 1007 | if (!isset($detalle[0])) |
| 1008 | 1008 | $detalle = [$detalle]; |
| 1009 | 1009 | $this->SetY($this->getY()+2); |
| 1010 | - foreach($detalle as &$d) { |
|
| 1010 | + foreach ($detalle as &$d) { |
|
| 1011 | 1011 | $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
| 1012 | - $this->Texto(number_format($d['PrcItem'],0,',','.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
| 1012 | + $this->Texto(number_format($d['PrcItem'], 0, ',', '.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
| 1013 | 1013 | $this->Texto($this->num($d['QtyItem']), $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']); |
| 1014 | 1014 | $this->Texto($this->num($d['MontoItem']), $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']); |
| 1015 | 1015 | } |
@@ -1029,7 +1029,7 @@ discard block |
||
| 1029 | 1029 | if (!isset($detalle[0])) { |
| 1030 | 1030 | $detalle = [$detalle]; |
| 1031 | 1031 | } |
| 1032 | - foreach($detalle as &$d) { |
|
| 1032 | + foreach ($detalle as &$d) { |
|
| 1033 | 1033 | if (!empty($d['MontoItem'])) { |
| 1034 | 1034 | $subtotal += $d['MontoItem']; |
| 1035 | 1035 | } |
@@ -1054,13 +1054,13 @@ discard block |
||
| 1054 | 1054 | { |
| 1055 | 1055 | if (!isset($descuentosRecargos[0])) |
| 1056 | 1056 | $descuentosRecargos = [$descuentosRecargos]; |
| 1057 | - foreach($descuentosRecargos as $dr) { |
|
| 1057 | + foreach ($descuentosRecargos as $dr) { |
|
| 1058 | 1058 | $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo'; |
| 1059 | 1059 | $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : $this->num($dr['ValorDR']); |
| 1060 | 1060 | if ($this->papelContinuo) { |
| 1061 | - $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):''), $x); |
|
| 1061 | + $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : ''), $x); |
|
| 1062 | 1062 | } else { |
| 1063 | - $this->Texto($tipo.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):'').':', 77, null, 'R', 100); |
|
| 1063 | + $this->Texto($tipo.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : '').':', 77, null, 'R', 100); |
|
| 1064 | 1064 | $this->Texto($valor, 177, null, 'R', 22); |
| 1065 | 1065 | } |
| 1066 | 1066 | $this->Ln(); |
@@ -1080,8 +1080,8 @@ discard block |
||
| 1080 | 1080 | $pagos = [$pagos]; |
| 1081 | 1081 | $this->Texto('Pago(s) programado(s):', $x); |
| 1082 | 1082 | $this->Ln(); |
| 1083 | - foreach($pagos as $p) { |
|
| 1084 | - $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos'])?(' ('.$p['GlosaPagos'].')'):''), $x); |
|
| 1083 | + foreach ($pagos as $p) { |
|
| 1084 | + $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos']) ? (' ('.$p['GlosaPagos'].')') : ''), $x); |
|
| 1085 | 1085 | $this->Ln(); |
| 1086 | 1086 | } |
| 1087 | 1087 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | if (!isset($ImptoReten[0])) { |
| 1133 | 1133 | $ImptoReten = [$ImptoReten]; |
| 1134 | 1134 | } |
| 1135 | - foreach($ImptoReten as $i) { |
|
| 1135 | + foreach ($ImptoReten as $i) { |
|
| 1136 | 1136 | $totales['ImptoReten_'.$i['TipoImp']] = $i['MontoImp']; |
| 1137 | 1137 | if (!empty($i['TasaImp'])) { |
| 1138 | 1138 | $glosas['ImptoReten_'.$i['TipoImp']] = \sasco\LibreDTE\Sii\ImpuestosAdicionales::getGlosa($i['TipoImp']).' ('.$i['TasaImp'].'%) $'; |
@@ -1224,7 +1224,7 @@ discard block |
||
| 1224 | 1224 | 'vpadding' => 0, |
| 1225 | 1225 | 'module_width' => 1, // width of a single module in points |
| 1226 | 1226 | 'module_height' => 1, // height of a single module in points |
| 1227 | - 'fgcolor' => [0,0,0], |
|
| 1227 | + 'fgcolor' => [0, 0, 0], |
|
| 1228 | 1228 | 'bgcolor' => false, // [255,255,255] |
| 1229 | 1229 | 'position' => $this->papelContinuo ? 'C' : 'S', |
| 1230 | 1230 | ]; |
@@ -1257,7 +1257,7 @@ discard block |
||
| 1257 | 1257 | private function agregarAcuseRecibo($x = 93, $y = 190, $w = 50, $h = 40) |
| 1258 | 1258 | { |
| 1259 | 1259 | $y = (!$this->papelContinuo and !$this->timbre_pie) ? $this->x_fin_datos : $y; |
| 1260 | - $this->SetTextColorArray([0,0,0]); |
|
| 1260 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 1261 | 1261 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
| 1262 | 1262 | $this->setFont('', 'B', 10); |
| 1263 | 1263 | $this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1287,9 +1287,9 @@ discard block |
||
| 1287 | 1287 | */ |
| 1288 | 1288 | private function agregarAcuseReciboContinuo($x = 3, $y = null, $w = 68, $h = 40) |
| 1289 | 1289 | { |
| 1290 | - $this->SetTextColorArray([0,0,0]); |
|
| 1290 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 1291 | 1291 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
| 1292 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
| 1292 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
| 1293 | 1293 | $this->Line($x, $y+22, $w+3, $y+22, $style); |
| 1294 | 1294 | //$this->setFont('', 'B', 10); |
| 1295 | 1295 | //$this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1319,7 +1319,7 @@ discard block |
||
| 1319 | 1319 | $y = (!$this->papelContinuo and !$this->timbre_pie) ? $this->x_fin_datos : $y; |
| 1320 | 1320 | $y += 64; |
| 1321 | 1321 | $this->setFont('', 'B', $font_size); |
| 1322 | - $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $y, 'R'); |
|
| 1322 | + $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $y, 'R'); |
|
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | 1325 | /** |
@@ -1330,7 +1330,7 @@ discard block |
||
| 1330 | 1330 | private function agregarLeyendaDestinoContinuo($tipo) |
| 1331 | 1331 | { |
| 1332 | 1332 | $this->setFont('', 'B', 8); |
| 1333 | - $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $this->y+6, 'R'); |
|
| 1333 | + $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $this->y+6, 'R'); |
|
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 | /** |
@@ -1361,7 +1361,7 @@ discard block |
||
| 1361 | 1361 | $dias = ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado']; |
| 1362 | 1362 | $meses = ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre']; |
| 1363 | 1363 | $unixtime = strtotime($date); |
| 1364 | - $fecha = date(($mostrar_dia?'\D\I\A ':'').'j \d\e \M\E\S \d\e\l Y', $unixtime); |
|
| 1364 | + $fecha = date(($mostrar_dia ? '\D\I\A ' : '').'j \d\e \M\E\S \d\e\l Y', $unixtime); |
|
| 1365 | 1365 | $dia = $dias[date('w', $unixtime)]; |
| 1366 | 1366 | $mes = $meses[date('n', $unixtime)-1]; |
| 1367 | 1367 | return str_replace(array('DIA', 'MES'), array($dia, $mes), $fecha); |
@@ -555,10 +555,12 @@ discard block |
||
| 555 | 555 | } |
| 556 | 556 | $contacto = []; |
| 557 | 557 | if (!empty($emisor['Telefono'])) { |
| 558 | - if (!is_array($emisor['Telefono'])) |
|
| 559 | - $emisor['Telefono'] = [$emisor['Telefono']]; |
|
| 560 | - foreach ($emisor['Telefono'] as $t) |
|
| 561 | - $contacto[] = $t; |
|
| 558 | + if (!is_array($emisor['Telefono'])) { |
|
| 559 | + $emisor['Telefono'] = [$emisor['Telefono']]; |
|
| 560 | + } |
|
| 561 | + foreach ($emisor['Telefono'] as $t) { |
|
| 562 | + $contacto[] = $t; |
|
| 563 | + } |
|
| 562 | 564 | } |
| 563 | 565 | if (!empty($emisor['CorreoEmisor'])) { |
| 564 | 566 | $contacto[] = $emisor['CorreoEmisor']; |
@@ -625,8 +627,9 @@ discard block |
||
| 625 | 627 | */ |
| 626 | 628 | private function getTipo($tipo) |
| 627 | 629 | { |
| 628 | - if (!is_numeric($tipo) and !isset($this->tipos[$tipo])) |
|
| 629 | - return $tipo; |
|
| 630 | + if (!is_numeric($tipo) and !isset($this->tipos[$tipo])) { |
|
| 631 | + return $tipo; |
|
| 632 | + } |
|
| 630 | 633 | return isset($this->tipos[$tipo]) ? strtoupper($this->tipos[$tipo]) : 'Documento '.$tipo; |
| 631 | 634 | } |
| 632 | 635 | |
@@ -776,10 +779,12 @@ discard block |
||
| 776 | 779 | $this->MultiTexto($receptor['Extranjero']['NumId'], $x+$offset+2); |
| 777 | 780 | } |
| 778 | 781 | $contacto = []; |
| 779 | - if (!empty($receptor['Contacto'])) |
|
| 780 | - $contacto[] = $receptor['Contacto']; |
|
| 781 | - if (!empty($receptor['CorreoRecep'])) |
|
| 782 | - $contacto[] = $receptor['CorreoRecep']; |
|
| 782 | + if (!empty($receptor['Contacto'])) { |
|
| 783 | + $contacto[] = $receptor['Contacto']; |
|
| 784 | + } |
|
| 785 | + if (!empty($receptor['CorreoRecep'])) { |
|
| 786 | + $contacto[] = $receptor['CorreoRecep']; |
|
| 787 | + } |
|
| 783 | 788 | if (!empty($contacto)) { |
| 784 | 789 | $this->setFont('', 'B', null); |
| 785 | 790 | $this->Texto('Contacto', $x); |
@@ -829,15 +834,19 @@ discard block |
||
| 829 | 834 | if (!empty($Transporte['DirDest']) and !empty($Transporte['CmnaDest'])) { |
| 830 | 835 | $transporte .= 'a '.$Transporte['DirDest'].', '.$Transporte['CmnaDest']; |
| 831 | 836 | } |
| 832 | - if (!empty($Transporte['RUTTrans'])) |
|
| 833 | - $transporte .= ' por '.$Transporte['RUTTrans']; |
|
| 834 | - if (!empty($Transporte['Patente'])) |
|
| 835 | - $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
| 837 | + if (!empty($Transporte['RUTTrans'])) { |
|
| 838 | + $transporte .= ' por '.$Transporte['RUTTrans']; |
|
| 839 | + } |
|
| 840 | + if (!empty($Transporte['Patente'])) { |
|
| 841 | + $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
| 842 | + } |
|
| 836 | 843 | if (isset($Transporte['Chofer']) and is_array($Transporte['Chofer'])) { |
| 837 | - if (!empty($Transporte['Chofer']['NombreChofer'])) |
|
| 838 | - $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer']; |
|
| 839 | - if (!empty($Transporte['Chofer']['RUTChofer'])) |
|
| 840 | - $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')'; |
|
| 844 | + if (!empty($Transporte['Chofer']['NombreChofer'])) { |
|
| 845 | + $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer']; |
|
| 846 | + } |
|
| 847 | + if (!empty($Transporte['Chofer']['RUTChofer'])) { |
|
| 848 | + $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')'; |
|
| 849 | + } |
|
| 841 | 850 | } |
| 842 | 851 | if ($transporte) { |
| 843 | 852 | $this->setFont('', 'B', null); |
@@ -851,8 +860,9 @@ discard block |
||
| 851 | 860 | if (!empty($Transporte['Aduana']) and is_array($Transporte['Aduana'])) { |
| 852 | 861 | $col = 0; |
| 853 | 862 | foreach ($Transporte['Aduana'] as $tag => $codigo) { |
| 854 | - if ($codigo===false) |
|
| 855 | - continue; |
|
| 863 | + if ($codigo===false) { |
|
| 864 | + continue; |
|
| 865 | + } |
|
| 856 | 866 | $glosa = \sasco\LibreDTE\Sii\Aduana::getGlosa($tag); |
| 857 | 867 | $valor = \sasco\LibreDTE\Sii\Aduana::getValor($tag, $codigo); |
| 858 | 868 | if ($glosa!==false and $valor!==false) { |
@@ -865,15 +875,18 @@ discard block |
||
| 865 | 875 | $this->Texto(':', $x+$offset+$col); |
| 866 | 876 | $this->setFont('', '', null); |
| 867 | 877 | $this->Texto($valor, $x+$offset+2+$col); |
| 868 | - if ($tag=='TipoBultos') |
|
| 869 | - $col = abs($col-110); |
|
| 870 | - if ($col) |
|
| 871 | - $this->Ln(); |
|
| 878 | + if ($tag=='TipoBultos') { |
|
| 879 | + $col = abs($col-110); |
|
| 880 | + } |
|
| 881 | + if ($col) { |
|
| 882 | + $this->Ln(); |
|
| 883 | + } |
|
| 872 | 884 | $col = abs($col-110); |
| 873 | 885 | } |
| 874 | 886 | } |
| 875 | - if ($col) |
|
| 876 | - $this->Ln(); |
|
| 887 | + if ($col) { |
|
| 888 | + $this->Ln(); |
|
| 889 | + } |
|
| 877 | 890 | } |
| 878 | 891 | } |
| 879 | 892 | |
@@ -886,8 +899,9 @@ discard block |
||
| 886 | 899 | */ |
| 887 | 900 | private function agregarReferencia($referencias, $x = 10, $offset = 22) |
| 888 | 901 | { |
| 889 | - if (!isset($referencias[0])) |
|
| 890 | - $referencias = [$referencias]; |
|
| 902 | + if (!isset($referencias[0])) { |
|
| 903 | + $referencias = [$referencias]; |
|
| 904 | + } |
|
| 891 | 905 | foreach($referencias as $r) { |
| 892 | 906 | $texto = $r['NroLinRef'].' - '; |
| 893 | 907 | if (!empty($r['TpoDocRef'])) { |
@@ -924,8 +938,9 @@ discard block |
||
| 924 | 938 | */ |
| 925 | 939 | private function agregarDetalle($detalle, $x = 10) |
| 926 | 940 | { |
| 927 | - if (!isset($detalle[0])) |
|
| 928 | - $detalle = [$detalle]; |
|
| 941 | + if (!isset($detalle[0])) { |
|
| 942 | + $detalle = [$detalle]; |
|
| 943 | + } |
|
| 929 | 944 | $this->setFont('', '', $this->detalle_fuente); |
| 930 | 945 | // titulos |
| 931 | 946 | $titulos = []; |
@@ -942,36 +957,42 @@ discard block |
||
| 942 | 957 | $item['NmbItem'] .= !$this->item_detalle_posicion ? '<br/>' : ': '; |
| 943 | 958 | $item['NmbItem'] .= '<span style="font-size:0.7em">'.$item['DscItem'].'</span>'; |
| 944 | 959 | } |
| 945 | - if (!in_array($col, $titulos_keys) or ($dte_exento and $col=='IndExe')) |
|
| 946 | - unset($item[$col]); |
|
| 960 | + if (!in_array($col, $titulos_keys) or ($dte_exento and $col=='IndExe')) { |
|
| 961 | + unset($item[$col]); |
|
| 962 | + } |
|
| 947 | 963 | } |
| 948 | 964 | // ajustes a IndExe |
| 949 | 965 | if (isset($item['IndExe'])) { |
| 950 | - if ($item['IndExe']==1) |
|
| 951 | - $item['IndExe'] = 'EX'; |
|
| 952 | - else if ($item['IndExe']==2) |
|
| 953 | - $item['IndExe'] = 'NF'; |
|
| 966 | + if ($item['IndExe']==1) { |
|
| 967 | + $item['IndExe'] = 'EX'; |
|
| 968 | + } else if ($item['IndExe']==2) { |
|
| 969 | + $item['IndExe'] = 'NF'; |
|
| 970 | + } |
|
| 954 | 971 | } |
| 955 | 972 | // agregar todas las columnas que se podrían imprimir en la tabla |
| 956 | 973 | $item_default = []; |
| 957 | - foreach ($this->detalle_cols as $key => $info) |
|
| 958 | - $item_default[$key] = false; |
|
| 974 | + foreach ($this->detalle_cols as $key => $info) { |
|
| 975 | + $item_default[$key] = false; |
|
| 976 | + } |
|
| 959 | 977 | $item = array_merge($item_default, $item); |
| 960 | 978 | // si hay código de item se extrae su valor |
| 961 | - if ($item['CdgItem']) |
|
| 962 | - $item['CdgItem'] = $item['CdgItem']['VlrCodigo']; |
|
| 979 | + if ($item['CdgItem']) { |
|
| 980 | + $item['CdgItem'] = $item['CdgItem']['VlrCodigo']; |
|
| 981 | + } |
|
| 963 | 982 | // dar formato a números |
| 964 | 983 | foreach (['QtyItem', 'PrcItem', 'DescuentoMonto', 'RecargoMonto', 'MontoItem'] as $col) { |
| 965 | - if ($item[$col]) |
|
| 966 | - $item[$col] = $this->num($item[$col]); |
|
| 984 | + if ($item[$col]) { |
|
| 985 | + $item[$col] = $this->num($item[$col]); |
|
| 986 | + } |
|
| 967 | 987 | } |
| 968 | 988 | } |
| 969 | 989 | // opciones |
| 970 | 990 | $options = ['align'=>[]]; |
| 971 | 991 | $i = 0; |
| 972 | 992 | foreach ($this->detalle_cols as $info) { |
| 973 | - if (isset($info['width'])) |
|
| 974 | - $options['width'][$i] = $info['width']; |
|
| 993 | + if (isset($info['width'])) { |
|
| 994 | + $options['width'][$i] = $info['width']; |
|
| 995 | + } |
|
| 975 | 996 | $options['align'][$i] = $info['align']; |
| 976 | 997 | $i++; |
| 977 | 998 | } |
@@ -1004,8 +1025,9 @@ discard block |
||
| 1004 | 1025 | $this->Texto($this->detalle_cols['QtyItem']['title'], $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']); |
| 1005 | 1026 | $this->Texto($this->detalle_cols['MontoItem']['title'], $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']); |
| 1006 | 1027 | $this->Line($p1x, $p1y+4, $p2x, $p2y+4, $style); |
| 1007 | - if (!isset($detalle[0])) |
|
| 1008 | - $detalle = [$detalle]; |
|
| 1028 | + if (!isset($detalle[0])) { |
|
| 1029 | + $detalle = [$detalle]; |
|
| 1030 | + } |
|
| 1009 | 1031 | $this->SetY($this->getY()+2); |
| 1010 | 1032 | foreach($detalle as &$d) { |
| 1011 | 1033 | $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
@@ -1052,8 +1074,9 @@ discard block |
||
| 1052 | 1074 | */ |
| 1053 | 1075 | private function agregarDescuentosRecargos(array $descuentosRecargos, $x = 10) |
| 1054 | 1076 | { |
| 1055 | - if (!isset($descuentosRecargos[0])) |
|
| 1056 | - $descuentosRecargos = [$descuentosRecargos]; |
|
| 1077 | + if (!isset($descuentosRecargos[0])) { |
|
| 1078 | + $descuentosRecargos = [$descuentosRecargos]; |
|
| 1079 | + } |
|
| 1057 | 1080 | foreach($descuentosRecargos as $dr) { |
| 1058 | 1081 | $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo'; |
| 1059 | 1082 | $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : $this->num($dr['ValorDR']); |
@@ -1076,8 +1099,9 @@ discard block |
||
| 1076 | 1099 | */ |
| 1077 | 1100 | private function agregarPagos(array $pagos, $x = 10) |
| 1078 | 1101 | { |
| 1079 | - if (!isset($pagos[0])) |
|
| 1080 | - $pagos = [$pagos]; |
|
| 1102 | + if (!isset($pagos[0])) { |
|
| 1103 | + $pagos = [$pagos]; |
|
| 1104 | + } |
|
| 1081 | 1105 | $this->Texto('Pago(s) programado(s):', $x); |
| 1082 | 1106 | $this->Ln(); |
| 1083 | 1107 | foreach($pagos as $p) { |
@@ -1343,11 +1367,13 @@ discard block |
||
| 1343 | 1367 | */ |
| 1344 | 1368 | private function num($n) |
| 1345 | 1369 | { |
| 1346 | - if (!is_numeric($n)) |
|
| 1347 | - return $n; |
|
| 1370 | + if (!is_numeric($n)) { |
|
| 1371 | + return $n; |
|
| 1372 | + } |
|
| 1348 | 1373 | $broken_number = explode('.', (string)$n); |
| 1349 | - if (isset($broken_number[1])) |
|
| 1350 | - return number_format($broken_number[0], 0, ',', '.').','.$broken_number[1]; |
|
| 1374 | + if (isset($broken_number[1])) { |
|
| 1375 | + return number_format($broken_number[0], 0, ',', '.').','.$broken_number[1]; |
|
| 1376 | + } |
|
| 1351 | 1377 | return number_format($broken_number[0], 0, ',', '.'); |
| 1352 | 1378 | } |
| 1353 | 1379 | |
@@ -57,10 +57,11 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function __construct($datos, $normalizar = true) |
| 59 | 59 | { |
| 60 | - if (is_array($datos)) |
|
| 61 | - $this->setDatos($datos, $normalizar); |
|
| 62 | - else if (is_string($datos)) |
|
| 63 | - $this->loadXML($datos); |
|
| 60 | + if (is_array($datos)) { |
|
| 61 | + $this->setDatos($datos, $normalizar); |
|
| 62 | + } else if (is_string($datos)) { |
|
| 63 | + $this->loadXML($datos); |
|
| 64 | + } |
|
| 64 | 65 | $this->timestamp = date('Y-m-d\TH:i:s'); |
| 65 | 66 | } |
| 66 | 67 | |
@@ -121,8 +122,9 @@ discard block |
||
| 121 | 122 | if ($normalizar) { |
| 122 | 123 | $this->normalizar($datos); |
| 123 | 124 | $method = 'normalizar_'.$this->tipo; |
| 124 | - if (method_exists($this, $method)) |
|
| 125 | - $this->$method($datos); |
|
| 125 | + if (method_exists($this, $method)) { |
|
| 126 | + $this->$method($datos); |
|
| 127 | + } |
|
| 126 | 128 | $this->normalizar_final($datos); |
| 127 | 129 | } |
| 128 | 130 | $this->tipo_general = $this->getTipoGeneral($this->tipo); |
@@ -199,8 +201,9 @@ discard block |
||
| 199 | 201 | */ |
| 200 | 202 | public function getJSON() |
| 201 | 203 | { |
| 202 | - if (!$this->getDatos()) |
|
| 203 | - return false; |
|
| 204 | + if (!$this->getDatos()) { |
|
| 205 | + return false; |
|
| 206 | + } |
|
| 204 | 207 | return json_encode($this->datos, JSON_PRETTY_PRINT); |
| 205 | 208 | } |
| 206 | 209 | |
@@ -225,9 +228,10 @@ discard block |
||
| 225 | 228 | */ |
| 226 | 229 | private function getTipoGeneral($dte) |
| 227 | 230 | { |
| 228 | - foreach ($this->tipos as $tipo => $codigos) |
|
| 229 | - if (in_array($dte, $codigos)) |
|
| 231 | + foreach ($this->tipos as $tipo => $codigos) { |
|
| 232 | + if (in_array($dte, $codigos)) |
|
| 230 | 233 | return $tipo; |
| 234 | + } |
|
| 231 | 235 | \sasco\LibreDTE\Log::write( |
| 232 | 236 | \sasco\LibreDTE\Estado::DTE_ERROR_TIPO, |
| 233 | 237 | \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::DTE_ERROR_TIPO, $dte) |
@@ -266,10 +270,12 @@ discard block |
||
| 266 | 270 | public function getEmisor() |
| 267 | 271 | { |
| 268 | 272 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Emisor/RUTEmisor')->item(0); |
| 269 | - if ($nodo) |
|
| 270 | - return $nodo->nodeValue; |
|
| 271 | - if (!$this->getDatos()) |
|
| 272 | - return false; |
|
| 273 | + if ($nodo) { |
|
| 274 | + return $nodo->nodeValue; |
|
| 275 | + } |
|
| 276 | + if (!$this->getDatos()) { |
|
| 277 | + return false; |
|
| 278 | + } |
|
| 273 | 279 | return $this->datos['Encabezado']['Emisor']['RUTEmisor']; |
| 274 | 280 | } |
| 275 | 281 | |
@@ -282,10 +288,12 @@ discard block |
||
| 282 | 288 | public function getReceptor() |
| 283 | 289 | { |
| 284 | 290 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Receptor/RUTRecep')->item(0); |
| 285 | - if ($nodo) |
|
| 286 | - return $nodo->nodeValue; |
|
| 287 | - if (!$this->getDatos()) |
|
| 288 | - return false; |
|
| 291 | + if ($nodo) { |
|
| 292 | + return $nodo->nodeValue; |
|
| 293 | + } |
|
| 294 | + if (!$this->getDatos()) { |
|
| 295 | + return false; |
|
| 296 | + } |
|
| 289 | 297 | return $this->datos['Encabezado']['Receptor']['RUTRecep']; |
| 290 | 298 | } |
| 291 | 299 | |
@@ -298,10 +306,12 @@ discard block |
||
| 298 | 306 | public function getFechaEmision() |
| 299 | 307 | { |
| 300 | 308 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/IdDoc/FchEmis')->item(0); |
| 301 | - if ($nodo) |
|
| 302 | - return $nodo->nodeValue; |
|
| 303 | - if (!$this->getDatos()) |
|
| 304 | - return false; |
|
| 309 | + if ($nodo) { |
|
| 310 | + return $nodo->nodeValue; |
|
| 311 | + } |
|
| 312 | + if (!$this->getDatos()) { |
|
| 313 | + return false; |
|
| 314 | + } |
|
| 305 | 315 | return $this->datos['Encabezado']['IdDoc']['FchEmis']; |
| 306 | 316 | } |
| 307 | 317 | |
@@ -314,10 +324,12 @@ discard block |
||
| 314 | 324 | public function getMontoTotal() |
| 315 | 325 | { |
| 316 | 326 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Totales/MntTotal')->item(0); |
| 317 | - if ($nodo) |
|
| 318 | - return $nodo->nodeValue; |
|
| 319 | - if (!$this->getDatos()) |
|
| 320 | - return false; |
|
| 327 | + if ($nodo) { |
|
| 328 | + return $nodo->nodeValue; |
|
| 329 | + } |
|
| 330 | + if (!$this->getDatos()) { |
|
| 331 | + return false; |
|
| 332 | + } |
|
| 321 | 333 | return $this->datos['Encabezado']['Totales']['MntTotal']; |
| 322 | 334 | } |
| 323 | 335 | |
@@ -330,10 +342,12 @@ discard block |
||
| 330 | 342 | public function getMoneda() |
| 331 | 343 | { |
| 332 | 344 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Totales/TpoMoneda')->item(0); |
| 333 | - if ($nodo) |
|
| 334 | - return $nodo->nodeValue; |
|
| 335 | - if (!$this->getDatos()) |
|
| 336 | - return false; |
|
| 345 | + if ($nodo) { |
|
| 346 | + return $nodo->nodeValue; |
|
| 347 | + } |
|
| 348 | + if (!$this->getDatos()) { |
|
| 349 | + return false; |
|
| 350 | + } |
|
| 337 | 351 | return $this->datos['Encabezado']['Totales']['TpoMoneda']; |
| 338 | 352 | } |
| 339 | 353 | |
@@ -355,8 +369,9 @@ discard block |
||
| 355 | 369 | return false;*/ |
| 356 | 370 | $xml = new \sasco\LibreDTE\XML(); |
| 357 | 371 | $TED = $this->xml->getElementsByTagName('TED')->item(0); |
| 358 | - if (!$TED) |
|
| 359 | - return '<TED/>'; |
|
| 372 | + if (!$TED) { |
|
| 373 | + return '<TED/>'; |
|
| 374 | + } |
|
| 360 | 375 | $xml->loadXML($TED->C14N()); |
| 361 | 376 | $xml->documentElement->removeAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi'); |
| 362 | 377 | $xml->documentElement->removeAttributeNS('http://www.sii.cl/SiiDte', ''); |
@@ -553,10 +568,12 @@ discard block |
||
| 553 | 568 | */ |
| 554 | 569 | private function calcularNetoIVA($total, $tasa = null) |
| 555 | 570 | { |
| 556 | - if ($tasa === 0 or $tasa === false) |
|
| 557 | - return [0, 0]; |
|
| 558 | - if ($tasa === null) |
|
| 559 | - $tasa = \sasco\LibreDTE\Sii::getIVA(); |
|
| 571 | + if ($tasa === 0 or $tasa === false) { |
|
| 572 | + return [0, 0]; |
|
| 573 | + } |
|
| 574 | + if ($tasa === null) { |
|
| 575 | + $tasa = \sasco\LibreDTE\Sii::getIVA(); |
|
| 576 | + } |
|
| 560 | 577 | // WARNING: el IVA obtenido puede no ser el NETO*(TASA/100) |
| 561 | 578 | // se calcula el monto neto y luego se obtiene el IVA haciendo la resta |
| 562 | 579 | // entre el total y el neto, ya que hay casos de borde como: |
@@ -665,8 +682,9 @@ discard block |
||
| 665 | 682 | } |
| 666 | 683 | // si existe descuento o recargo global se normalizan |
| 667 | 684 | if (!empty($datos['DscRcgGlobal'])) { |
| 668 | - if (!isset($datos['DscRcgGlobal'][0])) |
|
| 669 | - $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
| 685 | + if (!isset($datos['DscRcgGlobal'][0])) { |
|
| 686 | + $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
| 687 | + } |
|
| 670 | 688 | $NroLinDR = 1; |
| 671 | 689 | foreach ($datos['DscRcgGlobal'] as &$dr) { |
| 672 | 690 | $dr = array_merge([ |
@@ -1310,8 +1328,9 @@ discard block |
||
| 1310 | 1328 | */ |
| 1311 | 1329 | private function normalizar_detalle(array &$datos) |
| 1312 | 1330 | { |
| 1313 | - if (!isset($datos['Detalle'][0])) |
|
| 1314 | - $datos['Detalle'] = [$datos['Detalle']]; |
|
| 1331 | + if (!isset($datos['Detalle'][0])) { |
|
| 1332 | + $datos['Detalle'] = [$datos['Detalle']]; |
|
| 1333 | + } |
|
| 1315 | 1334 | $item = 1; |
| 1316 | 1335 | foreach ($datos['Detalle'] as &$d) { |
| 1317 | 1336 | $d = array_merge([ |
@@ -1373,8 +1392,9 @@ discard block |
||
| 1373 | 1392 | ]; |
| 1374 | 1393 | } |
| 1375 | 1394 | if ($d['PrcItem']) { |
| 1376 | - if (!$d['QtyItem']) |
|
| 1377 | - $d['QtyItem'] = 1; |
|
| 1395 | + if (!$d['QtyItem']) { |
|
| 1396 | + $d['QtyItem'] = 1; |
|
| 1397 | + } |
|
| 1378 | 1398 | if (empty($d['MontoItem'])) { |
| 1379 | 1399 | $d['MontoItem'] = $this->round( |
| 1380 | 1400 | $d['QtyItem'] * $d['PrcItem'], |
@@ -1440,8 +1460,9 @@ discard block |
||
| 1440 | 1460 | private function normalizar_aplicar_descuentos_recargos(array &$datos) |
| 1441 | 1461 | { |
| 1442 | 1462 | if (!empty($datos['DscRcgGlobal'])) { |
| 1443 | - if (!isset($datos['DscRcgGlobal'][0])) |
|
| 1444 | - $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
| 1463 | + if (!isset($datos['DscRcgGlobal'][0])) { |
|
| 1464 | + $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
| 1465 | + } |
|
| 1445 | 1466 | foreach ($datos['DscRcgGlobal'] as &$dr) { |
| 1446 | 1467 | $dr = array_merge([ |
| 1447 | 1468 | 'NroLinDR' => false, |
@@ -1508,8 +1529,9 @@ discard block |
||
| 1508 | 1529 | $montos = []; |
| 1509 | 1530 | foreach ($datos['Detalle'] as &$d) { |
| 1510 | 1531 | if (!empty($d['CodImpAdic'])) { |
| 1511 | - if (!isset($montos[$d['CodImpAdic']])) |
|
| 1512 | - $montos[$d['CodImpAdic']] = 0; |
|
| 1532 | + if (!isset($montos[$d['CodImpAdic']])) { |
|
| 1533 | + $montos[$d['CodImpAdic']] = 0; |
|
| 1534 | + } |
|
| 1513 | 1535 | $montos[$d['CodImpAdic']] += $d['MontoItem']; |
| 1514 | 1536 | } |
| 1515 | 1537 | } |
@@ -1588,10 +1610,12 @@ discard block |
||
| 1588 | 1610 | } |
| 1589 | 1611 | if (empty($datos['Encabezado']['Totales']['MntTotal'])) { |
| 1590 | 1612 | $datos['Encabezado']['Totales']['MntTotal'] = $datos['Encabezado']['Totales']['MntNeto']; |
| 1591 | - if (!empty($datos['Encabezado']['Totales']['IVA'])) |
|
| 1592 | - $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['IVA']; |
|
| 1593 | - if (!empty($datos['Encabezado']['Totales']['MntExe'])) |
|
| 1594 | - $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['MntExe']; |
|
| 1613 | + if (!empty($datos['Encabezado']['Totales']['IVA'])) { |
|
| 1614 | + $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['IVA']; |
|
| 1615 | + } |
|
| 1616 | + if (!empty($datos['Encabezado']['Totales']['MntExe'])) { |
|
| 1617 | + $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['MntExe']; |
|
| 1618 | + } |
|
| 1595 | 1619 | } |
| 1596 | 1620 | } else { |
| 1597 | 1621 | if (!$datos['Encabezado']['Totales']['MntTotal'] and !empty($datos['Encabezado']['Totales']['MntExe'])) { |
@@ -1617,8 +1641,10 @@ discard block |
||
| 1617 | 1641 | } |
| 1618 | 1642 | // si hay impuesto de crédito a constructoras del 65% se descuenta del total |
| 1619 | 1643 | if (!empty($datos['Encabezado']['Totales']['CredEC'])) { |
| 1620 | - if ($datos['Encabezado']['Totales']['CredEC']===true) |
|
| 1621 | - $datos['Encabezado']['Totales']['CredEC'] = round($datos['Encabezado']['Totales']['IVA'] * 0.65); // TODO: mover a constante o método |
|
| 1644 | + if ($datos['Encabezado']['Totales']['CredEC']===true) { |
|
| 1645 | + $datos['Encabezado']['Totales']['CredEC'] = round($datos['Encabezado']['Totales']['IVA'] * 0.65); |
|
| 1646 | + } |
|
| 1647 | + // TODO: mover a constante o método |
|
| 1622 | 1648 | $datos['Encabezado']['Totales']['MntTotal'] -= $datos['Encabezado']['Totales']['CredEC']; |
| 1623 | 1649 | } |
| 1624 | 1650 | } |
@@ -1724,10 +1750,12 @@ discard block |
||
| 1724 | 1750 | /*if (!$this->checkFirma()) |
| 1725 | 1751 | return 1;*/ |
| 1726 | 1752 | if (is_array($datos)) { |
| 1727 | - if (isset($datos['RUTEmisor']) and $this->getEmisor()!=$datos['RUTEmisor']) |
|
| 1728 | - return 2; |
|
| 1729 | - if (isset($datos['RUTRecep']) and $this->getReceptor()!=$datos['RUTRecep']) |
|
| 1730 | - return 3; |
|
| 1753 | + if (isset($datos['RUTEmisor']) and $this->getEmisor()!=$datos['RUTEmisor']) { |
|
| 1754 | + return 2; |
|
| 1755 | + } |
|
| 1756 | + if (isset($datos['RUTRecep']) and $this->getReceptor()!=$datos['RUTRecep']) { |
|
| 1757 | + return 3; |
|
| 1758 | + } |
|
| 1731 | 1759 | } |
| 1732 | 1760 | return 0; |
| 1733 | 1761 | } |
@@ -1741,8 +1769,9 @@ discard block |
||
| 1741 | 1769 | */ |
| 1742 | 1770 | public function checkFirma() |
| 1743 | 1771 | { |
| 1744 | - if (!$this->xml) |
|
| 1745 | - return null; |
|
| 1772 | + if (!$this->xml) { |
|
| 1773 | + return null; |
|
| 1774 | + } |
|
| 1746 | 1775 | // obtener firma |
| 1747 | 1776 | $Signature = $this->xml->documentElement->getElementsByTagName('Signature')->item(0); |
| 1748 | 1777 | // preparar documento a validar |
@@ -1834,12 +1863,14 @@ discard block |
||
| 1834 | 1863 | { |
| 1835 | 1864 | // solicitar token |
| 1836 | 1865 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma); |
| 1837 | - if (!$token) |
|
| 1838 | - return false; |
|
| 1866 | + if (!$token) { |
|
| 1867 | + return false; |
|
| 1868 | + } |
|
| 1839 | 1869 | // consultar estado dte |
| 1840 | 1870 | $run = $Firma->getID(); |
| 1841 | - if ($run===false) |
|
| 1842 | - return false; |
|
| 1871 | + if ($run===false) { |
|
| 1872 | + return false; |
|
| 1873 | + } |
|
| 1843 | 1874 | list($RutConsultante, $DvConsultante) = explode('-', $run); |
| 1844 | 1875 | list($RutCompania, $DvCompania) = explode('-', $this->getEmisor()); |
| 1845 | 1876 | list($RutReceptor, $DvReceptor) = explode('-', $this->getReceptor()); |
@@ -1858,8 +1889,9 @@ discard block |
||
| 1858 | 1889 | 'token' => $token, |
| 1859 | 1890 | ]); |
| 1860 | 1891 | // si el estado se pudo recuperar se muestra |
| 1861 | - if ($xml===false) |
|
| 1862 | - return false; |
|
| 1892 | + if ($xml===false) { |
|
| 1893 | + return false; |
|
| 1894 | + } |
|
| 1863 | 1895 | // entregar estado |
| 1864 | 1896 | return (array)$xml->xpath('/SII:RESPUESTA/SII:RESP_HDR')[0]; |
| 1865 | 1897 | } |
@@ -1876,8 +1908,9 @@ discard block |
||
| 1876 | 1908 | { |
| 1877 | 1909 | // solicitar token |
| 1878 | 1910 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma); |
| 1879 | - if (!$token) |
|
| 1880 | - return false; |
|
| 1911 | + if (!$token) { |
|
| 1912 | + return false; |
|
| 1913 | + } |
|
| 1881 | 1914 | // consultar estado dte |
| 1882 | 1915 | list($RutEmpresa, $DvEmpresa) = explode('-', $this->getEmisor()); |
| 1883 | 1916 | list($RutReceptor, $DvReceptor) = explode('-', $this->getReceptor()); |
@@ -1895,8 +1928,9 @@ discard block |
||
| 1895 | 1928 | 'token' => $token, |
| 1896 | 1929 | ]); |
| 1897 | 1930 | // si el estado se pudo recuperar se muestra |
| 1898 | - if ($xml===false) |
|
| 1899 | - return false; |
|
| 1931 | + if ($xml===false) { |
|
| 1932 | + return false; |
|
| 1933 | + } |
|
| 1900 | 1934 | // entregar estado |
| 1901 | 1935 | return (array)$xml->xpath('/SII:RESPUESTA/SII:RESP_BODY')[0]; |
| 1902 | 1936 | } |