@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * Método que realiza la firma del DTE cedido |
| 71 | - * @param Firma objeto que representa la Firma Electrónca |
|
| 71 | + * @param Firma \sasco\LibreDTE\FirmaElectronica que representa la Firma Electrónca |
|
| 72 | 72 | * @return =true si el DTE pudo ser fimado o =false si no se pudo firmar |
| 73 | 73 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 74 | 74 | * @version 2016-12-10 |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * Método que entrega el XML del DTE cedido |
| 92 | - * @return XML del DTE cedido (puede ser: con o sin firma) |
|
| 92 | + * @return boolean|string del DTE cedido (puede ser: con o sin firma) |
|
| 93 | 93 | * @author Adonias Vasquez (adonias.vasquez[at]epys.cl) |
| 94 | 94 | * @version 2016-08-10 |
| 95 | 95 | */ |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | /** |
| 116 | 116 | * Método que entrega el RUT de a quién se está autorizando el CAF |
| 117 | - * @return Rut del emisor del CAF |
|
| 117 | + * @return false|string del emisor del CAF |
|
| 118 | 118 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 119 | 119 | * @version 2015-10-30 |
| 120 | 120 | */ |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | /** |
| 158 | 158 | * Método que entrega la firma del SII sobre el nodo DA |
| 159 | - * @return Firma en base64 |
|
| 159 | + * @return false|string en base64 |
|
| 160 | 160 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 161 | 161 | * @version 2015-10-30 |
| 162 | 162 | */ |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | /** |
| 172 | 172 | * Método que entrega el IDK (serial number) de la clave pública del SII |
| 173 | 173 | * utilizada para firmar el CAF |
| 174 | - * @return Serial number |
|
| 174 | + * @return \sasco\LibreDTE\IDK|null number |
|
| 175 | 175 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 176 | 176 | * @version 2015-10-30 |
| 177 | 177 | */ |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | /** |
| 187 | 187 | * Método que entrega la clave privada proporcionada por el SII para el CAF |
| 188 | - * @return Clave privada en base64 |
|
| 188 | + * @return false|string privada en base64 |
|
| 189 | 189 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 190 | 190 | * @version 2015-10-30 |
| 191 | 191 | */ |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | /** |
| 201 | 201 | * Método que entrega la clave pública proporcionada por el SII para el CAF |
| 202 | - * @return Clave pública en base64 |
|
| 202 | + * @return false|string pública en base64 |
|
| 203 | 203 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 204 | 204 | * @version 2015-10-30 |
| 205 | 205 | */ |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | ); |
| 96 | 96 | return false; |
| 97 | 97 | } |
| 98 | - return $plain === $plain_firmado; |
|
| 98 | + return $plain===$plain_firmado; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | public function getCertificacion() |
| 235 | 235 | { |
| 236 | 236 | $idk = $this->getIDK(); |
| 237 | - return $idk ? $idk === 100 : null; |
|
| 237 | + return $idk ? $idk===100 : null; |
|
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | /** |
@@ -63,8 +63,9 @@ discard block |
||
| 63 | 63 | // validar firma del SII sobre los folios |
| 64 | 64 | $firma = $this->getFirma(); |
| 65 | 65 | $idk = $this->getIDK(); |
| 66 | - if (!$firma or !$idk) |
|
| 67 | - return false; |
|
| 66 | + if (!$firma or !$idk) { |
|
| 67 | + return false; |
|
| 68 | + } |
|
| 68 | 69 | $pub_key = \sasco\LibreDTE\Sii::cert($idk); |
| 69 | 70 | if (!$pub_key or openssl_verify($this->xml->getFlattened('/AUTORIZACION/CAF/DA'), base64_decode($firma), $pub_key)!==1) { |
| 70 | 71 | \sasco\LibreDTE\Log::write( |
@@ -75,8 +76,9 @@ discard block |
||
| 75 | 76 | } |
| 76 | 77 | // validar clave privada y pública proporcionada por el SII |
| 77 | 78 | $private_key = $this->getPrivateKey(); |
| 78 | - if (!$private_key) |
|
| 79 | - return false; |
|
| 79 | + if (!$private_key) { |
|
| 80 | + return false; |
|
| 81 | + } |
|
| 80 | 82 | $plain = md5(date('U')); |
| 81 | 83 | if (!openssl_private_encrypt($plain, $crypt, $private_key)) { |
| 82 | 84 | \sasco\LibreDTE\Log::write( |
@@ -86,8 +88,9 @@ discard block |
||
| 86 | 88 | return false; |
| 87 | 89 | } |
| 88 | 90 | $public_key = $this->getPublicKey(); |
| 89 | - if (!$public_key) |
|
| 90 | - return false; |
|
| 91 | + if (!$public_key) { |
|
| 92 | + return false; |
|
| 93 | + } |
|
| 91 | 94 | if (!openssl_public_decrypt($crypt, $plain_firmado, $public_key)) { |
| 92 | 95 | \sasco\LibreDTE\Log::write( |
| 93 | 96 | \sasco\LibreDTE\Estado::FOLIOS_ERROR_DESENCRIPTAR, |
@@ -106,8 +109,9 @@ discard block |
||
| 106 | 109 | */ |
| 107 | 110 | public function getCaf() |
| 108 | 111 | { |
| 109 | - if (!$this->xml) |
|
| 110 | - return false; |
|
| 112 | + if (!$this->xml) { |
|
| 113 | + return false; |
|
| 114 | + } |
|
| 111 | 115 | $CAF = $this->xml->getElementsByTagName('CAF')->item(0); |
| 112 | 116 | return $CAF ? $CAF : false; |
| 113 | 117 | } |
@@ -120,8 +124,9 @@ discard block |
||
| 120 | 124 | */ |
| 121 | 125 | public function getEmisor() |
| 122 | 126 | { |
| 123 | - if (!$this->xml) |
|
| 124 | - return false; |
|
| 127 | + if (!$this->xml) { |
|
| 128 | + return false; |
|
| 129 | + } |
|
| 125 | 130 | $RE = $this->xml->getElementsByTagName('RE')->item(0); |
| 126 | 131 | return $RE ? $RE->nodeValue : false; |
| 127 | 132 | } |
@@ -134,8 +139,9 @@ discard block |
||
| 134 | 139 | */ |
| 135 | 140 | public function getDesde() |
| 136 | 141 | { |
| 137 | - if (!$this->xml) |
|
| 138 | - return false; |
|
| 142 | + if (!$this->xml) { |
|
| 143 | + return false; |
|
| 144 | + } |
|
| 139 | 145 | $D = $this->xml->getElementsByTagName('D')->item(0); |
| 140 | 146 | return $D ? (int)$D->nodeValue : false; |
| 141 | 147 | } |
@@ -148,8 +154,9 @@ discard block |
||
| 148 | 154 | */ |
| 149 | 155 | public function getHasta() |
| 150 | 156 | { |
| 151 | - if (!$this->xml) |
|
| 152 | - return false; |
|
| 157 | + if (!$this->xml) { |
|
| 158 | + return false; |
|
| 159 | + } |
|
| 153 | 160 | $H = $this->xml->getElementsByTagName('H')->item(0); |
| 154 | 161 | return $H ? (int)$H->nodeValue : false; |
| 155 | 162 | } |
@@ -162,8 +169,9 @@ discard block |
||
| 162 | 169 | */ |
| 163 | 170 | private function getFirma() |
| 164 | 171 | { |
| 165 | - if (!$this->xml) |
|
| 166 | - return false; |
|
| 172 | + if (!$this->xml) { |
|
| 173 | + return false; |
|
| 174 | + } |
|
| 167 | 175 | $FRMA = $this->xml->getElementsByTagName('FRMA')->item(0); |
| 168 | 176 | return $FRMA ? $FRMA->nodeValue : false; |
| 169 | 177 | } |
@@ -177,8 +185,9 @@ discard block |
||
| 177 | 185 | */ |
| 178 | 186 | private function getIDK() |
| 179 | 187 | { |
| 180 | - if (!$this->xml) |
|
| 181 | - return false; |
|
| 188 | + if (!$this->xml) { |
|
| 189 | + return false; |
|
| 190 | + } |
|
| 182 | 191 | $IDK = $this->xml->getElementsByTagName('IDK')->item(0); |
| 183 | 192 | return $IDK ? (int)$IDK->nodeValue : false; |
| 184 | 193 | } |
@@ -191,8 +200,9 @@ discard block |
||
| 191 | 200 | */ |
| 192 | 201 | public function getPrivateKey() |
| 193 | 202 | { |
| 194 | - if (!$this->xml) |
|
| 195 | - return false; |
|
| 203 | + if (!$this->xml) { |
|
| 204 | + return false; |
|
| 205 | + } |
|
| 196 | 206 | $RSASK = $this->xml->getElementsByTagName('RSASK')->item(0); |
| 197 | 207 | return $RSASK ? $RSASK->nodeValue : false; |
| 198 | 208 | } |
@@ -205,8 +215,9 @@ discard block |
||
| 205 | 215 | */ |
| 206 | 216 | public function getPublicKey() |
| 207 | 217 | { |
| 208 | - if (!$this->xml) |
|
| 209 | - return false; |
|
| 218 | + if (!$this->xml) { |
|
| 219 | + return false; |
|
| 220 | + } |
|
| 210 | 221 | $RSAPUBK = $this->xml->getElementsByTagName('RSAPUBK')->item(0); |
| 211 | 222 | return $RSAPUBK ? $RSAPUBK->nodeValue : false; |
| 212 | 223 | } |
@@ -219,8 +230,9 @@ discard block |
||
| 219 | 230 | */ |
| 220 | 231 | public function getTipo() |
| 221 | 232 | { |
| 222 | - if (!$this->xml) |
|
| 223 | - return false; |
|
| 233 | + if (!$this->xml) { |
|
| 234 | + return false; |
|
| 235 | + } |
|
| 224 | 236 | $TD = $this->xml->getElementsByTagName('TD')->item(0); |
| 225 | 237 | return $TD ? (int)$TD->nodeValue : false; |
| 226 | 238 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | /** |
| 174 | 174 | * Método que asigna la ubicación del logo de la empresa |
| 175 | 175 | * @param logo URI del logo (puede ser local o en una URL) |
| 176 | - * @param posicion Posición respecto a datos del emisor (=0 izq, =1 arriba) |
|
| 176 | + * @param posicion integer respecto a datos del emisor (=0 izq, =1 arriba) |
|
| 177 | 177 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 178 | 178 | * @version 2016-08-04 |
| 179 | 179 | */ |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | * contínuo |
| 329 | 329 | * @param dte Arreglo con los datos del XML (tag Documento) |
| 330 | 330 | * @param timbre String XML con el tag TED del DTE |
| 331 | - * @param width Ancho del papel contínuo en mm |
|
| 331 | + * @param width boolean del papel contínuo en mm |
|
| 332 | 332 | * @author Pablo Reyes (https://github.com/pabloxp) |
| 333 | 333 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 334 | 334 | * @version 2016-12-02 |
@@ -401,10 +401,11 @@ discard block |
||
| 401 | 401 | * - Dirección casa central del emisor |
| 402 | 402 | * - Dirección sucursales |
| 403 | 403 | * @param emisor Arreglo con los datos del emisor (tag Emisor del XML) |
| 404 | - * @param x Posición horizontal de inicio en el PDF |
|
| 405 | - * @param y Posición vertical de inicio en el PDF |
|
| 406 | - * @param w Ancho de la información del emisor |
|
| 407 | - * @param w_img Ancho máximo de la imagen |
|
| 404 | + * @param x integer horizontal de inicio en el PDF |
|
| 405 | + * @param y integer vertical de inicio en el PDF |
|
| 406 | + * @param w integer de la información del emisor |
|
| 407 | + * @param w_img integer máximo de la imagen |
|
| 408 | + * @param integer $font_size |
|
| 408 | 409 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 409 | 410 | * @version 2016-12-02 |
| 410 | 411 | */ |
@@ -474,11 +475,13 @@ discard block |
||
| 474 | 475 | * @param rut RUT del emisor |
| 475 | 476 | * @param tipo Código o glosa del tipo de documento |
| 476 | 477 | * @param sucursal_sii Código o glosa de la sucursal del SII del Emisor |
| 477 | - * @param x Posición horizontal de inicio en el PDF |
|
| 478 | - * @param y Posición vertical de inicio en el PDF |
|
| 479 | - * @param w Ancho de la información del emisor |
|
| 478 | + * @param x integer horizontal de inicio en el PDF |
|
| 479 | + * @param y integer vertical de inicio en el PDF |
|
| 480 | + * @param w integer de la información del emisor |
|
| 481 | + * @param integer $font_size |
|
| 480 | 482 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 481 | 483 | * @version 2016-12-02 |
| 484 | + * @return integer |
|
| 482 | 485 | */ |
| 483 | 486 | private function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
| 484 | 487 | { |
@@ -524,7 +527,7 @@ discard block |
||
| 524 | 527 | * Método que agrega los datos de la emisión del DTE que no son los dato del |
| 525 | 528 | * receptor |
| 526 | 529 | * @param IdDoc Información general del documento |
| 527 | - * @param x Posición horizontal de inicio en el PDF |
|
| 530 | + * @param x integer horizontal de inicio en el PDF |
|
| 528 | 531 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 529 | 532 | * @version 2016-12-15 |
| 530 | 533 | */ |
@@ -608,7 +611,7 @@ discard block |
||
| 608 | 611 | /** |
| 609 | 612 | * Método que agrega los datos del receptor |
| 610 | 613 | * @param receptor Arreglo con los datos del receptor (tag Receptor del XML) |
| 611 | - * @param x Posición horizontal de inicio en el PDF |
|
| 614 | + * @param x integer horizontal de inicio en el PDF |
|
| 612 | 615 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 613 | 616 | * @version 2016-12-15 |
| 614 | 617 | */ |
@@ -681,7 +684,7 @@ discard block |
||
| 681 | 684 | * Método que agrega los datos del traslado |
| 682 | 685 | * @param IndTraslado |
| 683 | 686 | * @param Transporte |
| 684 | - * @param x Posición horizontal de inicio en el PDF |
|
| 687 | + * @param x integer horizontal de inicio en el PDF |
|
| 685 | 688 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 686 | 689 | * @version 2016-08-03 |
| 687 | 690 | */ |
@@ -752,7 +755,7 @@ discard block |
||
| 752 | 755 | /** |
| 753 | 756 | * Método que agrega las referencias del documento |
| 754 | 757 | * @param referencias Arreglo con las referencias del documento (tag Referencia del XML) |
| 755 | - * @param x Posición horizontal de inicio en el PDF |
|
| 758 | + * @param x integer horizontal de inicio en el PDF |
|
| 756 | 759 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 757 | 760 | * @version 2016-08-03 |
| 758 | 761 | */ |
@@ -775,7 +778,7 @@ discard block |
||
| 775 | 778 | /** |
| 776 | 779 | * Método que agrega el detalle del documento |
| 777 | 780 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
| 778 | - * @param x Posición horizontal de inicio en el PDF |
|
| 781 | + * @param x integer horizontal de inicio en el PDF |
|
| 779 | 782 | * @param y Posición vertical de inicio en el PDF |
| 780 | 783 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 781 | 784 | * @version 2016-08-05 |
@@ -842,7 +845,7 @@ discard block |
||
| 842 | 845 | /** |
| 843 | 846 | * Método que agrega el detalle del documento |
| 844 | 847 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
| 845 | - * @param x Posición horizontal de inicio en el PDF |
|
| 848 | + * @param x integer horizontal de inicio en el PDF |
|
| 846 | 849 | * @param y Posición vertical de inicio en el PDF |
| 847 | 850 | * @author Pablo Reyes (https://github.com/pabloxp) |
| 848 | 851 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
@@ -878,7 +881,7 @@ discard block |
||
| 878 | 881 | * Método que agrega el subtotal del DTE |
| 879 | 882 | * @param detalle Arreglo con los detalles del documentos para poder |
| 880 | 883 | * calcular subtotal |
| 881 | - * @param x Posición horizontal de inicio en el PDF |
|
| 884 | + * @param x integer horizontal de inicio en el PDF |
|
| 882 | 885 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 883 | 886 | * @version 2016-08-17 |
| 884 | 887 | */ |
@@ -899,7 +902,7 @@ discard block |
||
| 899 | 902 | /** |
| 900 | 903 | * Método que agrega los descuentos y/o recargos globales del documento |
| 901 | 904 | * @param descuentosRecargos Arreglo con los descuentos y/o recargos del documento (tag DscRcgGlobal del XML) |
| 902 | - * @param x Posición horizontal de inicio en el PDF |
|
| 905 | + * @param x integer horizontal de inicio en el PDF |
|
| 903 | 906 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 904 | 907 | * @version 2016-08-17 |
| 905 | 908 | */ |
@@ -918,7 +921,7 @@ discard block |
||
| 918 | 921 | /** |
| 919 | 922 | * Método que agrega los pagos del documento |
| 920 | 923 | * @param pagos Arreglo con los pagos del documento |
| 921 | - * @param x Posición horizontal de inicio en el PDF |
|
| 924 | + * @param x integer horizontal de inicio en el PDF |
|
| 922 | 925 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 923 | 926 | * @version 2016-07-24 |
| 924 | 927 | */ |
@@ -1024,9 +1027,9 @@ discard block |
||
| 1024 | 1027 | * - Se imprime en el tamaño mínimo: 2x5 cms |
| 1025 | 1028 | * - En el lado de abajo con margen izquierdo mínimo de 2 cms |
| 1026 | 1029 | * @param timbre String con los datos del timbre |
| 1027 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1028 | - * @param y Posición vertical de inicio en el PDF |
|
| 1029 | - * @param w Ancho del timbre |
|
| 1030 | + * @param x integer horizontal de inicio en el PDF |
|
| 1031 | + * @param y integer vertical de inicio en el PDF |
|
| 1032 | + * @param w integer del timbre |
|
| 1030 | 1033 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1031 | 1034 | * @version 2016-12-02 |
| 1032 | 1035 | */ |
@@ -1057,10 +1060,10 @@ discard block |
||
| 1057 | 1060 | |
| 1058 | 1061 | /** |
| 1059 | 1062 | * Método que agrega el acuse de rebido |
| 1060 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1061 | - * @param y Posición vertical de inicio en el PDF |
|
| 1062 | - * @param w Ancho del acuse de recibo |
|
| 1063 | - * @param h Alto del acuse de recibo |
|
| 1063 | + * @param x integer horizontal de inicio en el PDF |
|
| 1064 | + * @param y integer vertical de inicio en el PDF |
|
| 1065 | + * @param w integer del acuse de recibo |
|
| 1066 | + * @param h integer del acuse de recibo |
|
| 1064 | 1067 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1065 | 1068 | * @version 2015-09-08 |
| 1066 | 1069 | */ |
@@ -1087,10 +1090,10 @@ discard block |
||
| 1087 | 1090 | |
| 1088 | 1091 | /** |
| 1089 | 1092 | * Método que agrega el acuse de rebido |
| 1090 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1093 | + * @param x integer horizontal de inicio en el PDF |
|
| 1091 | 1094 | * @param y Posición vertical de inicio en el PDF |
| 1092 | - * @param w Ancho del acuse de recibo |
|
| 1093 | - * @param h Alto del acuse de recibo |
|
| 1095 | + * @param w integer del acuse de recibo |
|
| 1096 | + * @param h integer del acuse de recibo |
|
| 1094 | 1097 | * @author Pablo Reyes (https://github.com/pabloxp) |
| 1095 | 1098 | * @version 2015-11-17 |
| 1096 | 1099 | */ |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | { |
| 168 | 168 | parent::__construct(); |
| 169 | 169 | $this->SetTitle('Documento Tributario Electrónico (DTE) de Chile by LibreDTE'); |
| 170 | - $this->papelContinuo = $papelContinuo === true ? 80 : $papelContinuo; |
|
| 170 | + $this->papelContinuo = $papelContinuo===true ? 80 : $papelContinuo; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /** |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | // determinar alto de la página y agregarla |
| 343 | 343 | $height = 145; |
| 344 | 344 | $n_detalle = count($dte['Detalle']); |
| 345 | - if ($n_detalle>1) $height += $n_detalle*20; |
|
| 345 | + if ($n_detalle>1) $height += $n_detalle * 20; |
|
| 346 | 346 | if ($this->cedible) $height += 50; |
| 347 | 347 | $this->AddPage('P', [$height, $width]); |
| 348 | 348 | // agregar cabecera del documento |
@@ -351,10 +351,10 @@ discard block |
||
| 351 | 351 | $dte['Encabezado']['IdDoc']['TipoDTE'], |
| 352 | 352 | $dte['Encabezado']['IdDoc']['Folio'], |
| 353 | 353 | $dte['Encabezado']['Emisor']['CmnaOrigen'], |
| 354 | - $x_start, $y_start, $width-($x_start*4), 10, |
|
| 355 | - [0,0,0] |
|
| 354 | + $x_start, $y_start, $width-($x_start * 4), 10, |
|
| 355 | + [0, 0, 0] |
|
| 356 | 356 | ); |
| 357 | - $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, 40, 8, 9, [0,0,0]); |
|
| 357 | + $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, 40, 8, 9, [0, 0, 0]); |
|
| 358 | 358 | // datos del documento |
| 359 | 359 | $this->SetY($y); |
| 360 | 360 | $this->Ln(); |
@@ -416,13 +416,13 @@ discard block |
||
| 416 | 416 | $this->logo['uri'], |
| 417 | 417 | $x, |
| 418 | 418 | $y, |
| 419 | - !$this->logo['posicion']?$w_img:null, $this->logo['posicion']?($w_img/2):null, |
|
| 419 | + !$this->logo['posicion'] ? $w_img : null, $this->logo['posicion'] ? ($w_img / 2) : null, |
|
| 420 | 420 | 'PNG', |
| 421 | - (isset($emisor['url'])?$emisor['url']:''), |
|
| 421 | + (isset($emisor['url']) ? $emisor['url'] : ''), |
|
| 422 | 422 | 'T' |
| 423 | 423 | ); |
| 424 | 424 | if ($this->logo['posicion']) { |
| 425 | - $this->SetY($this->y + ($w_img/2)); |
|
| 425 | + $this->SetY($this->y+($w_img / 2)); |
|
| 426 | 426 | $w += 40; |
| 427 | 427 | } else { |
| 428 | 428 | $x = $this->x+3; |
@@ -433,13 +433,13 @@ discard block |
||
| 433 | 433 | } |
| 434 | 434 | // agregar datos del emisor |
| 435 | 435 | $this->setFont('', 'B', $font_size ? $font_size : 14); |
| 436 | - $this->SetTextColorArray($color===null?[32, 92, 144]:$color); |
|
| 436 | + $this->SetTextColorArray($color===null ? [32, 92, 144] : $color); |
|
| 437 | 437 | $this->MultiTexto(!empty($emisor['RznSoc']) ? $emisor['RznSoc'] : $emisor['RznSocEmisor'], $x, $this->y+2, 'L', $w); |
| 438 | 438 | $this->setFont('', 'B', $font_size ? $font_size : 9); |
| 439 | - $this->SetTextColorArray([0,0,0]); |
|
| 439 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 440 | 440 | $this->MultiTexto(!empty($emisor['GiroEmis']) ? $emisor['GiroEmis'] : $emisor['GiroEmisor'], $x, $this->y, 'L', $w); |
| 441 | 441 | $ciudad = !empty($emisor['CiudadOrigen']) ? $emisor['CiudadOrigen'] : \sasco\LibreDTE\Chile::getCiudad($emisor['CmnaOrigen']); |
| 442 | - $this->MultiTexto($emisor['DirOrigen'].', '.$emisor['CmnaOrigen'].($ciudad?(', '.$ciudad):''), $x, $this->y, 'L', $w); |
|
| 442 | + $this->MultiTexto($emisor['DirOrigen'].', '.$emisor['CmnaOrigen'].($ciudad ? (', '.$ciudad) : ''), $x, $this->y, 'L', $w); |
|
| 443 | 443 | if (!empty($emisor['Sucursal'])) { |
| 444 | 444 | $this->MultiTexto('Sucursal: '.$emisor['Sucursal'], $x, $this->y, 'L', $w); |
| 445 | 445 | } |
@@ -483,12 +483,12 @@ discard block |
||
| 483 | 483 | private function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
| 484 | 484 | { |
| 485 | 485 | if ($color===null) { |
| 486 | - $color = $tipo ? ($tipo==52 ? [0,172,140] : [255,0,0]) : [0,0,0]; |
|
| 486 | + $color = $tipo ? ($tipo==52 ? [0, 172, 140] : [255, 0, 0]) : [0, 0, 0]; |
|
| 487 | 487 | } |
| 488 | 488 | $this->SetTextColorArray($color); |
| 489 | 489 | // colocar rut emisor, glosa documento y folio |
| 490 | 490 | list($rut, $dv) = explode('-', $rut); |
| 491 | - $this->setFont ('', 'B', $font_size ? $font_size : 15); |
|
| 491 | + $this->setFont('', 'B', $font_size ? $font_size : 15); |
|
| 492 | 492 | $this->MultiTexto('R.U.T.: '.$this->num($rut).'-'.$dv, $x, $y+4, 'C', $w); |
| 493 | 493 | $this->setFont('', 'B', $font_size ? $font_size : 12); |
| 494 | 494 | $this->MultiTexto($this->getTipo($tipo), $x, null, 'C', $w); |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | if ($tipo) { |
| 502 | 502 | $this->Texto('S.I.I. - '.\sasco\LibreDTE\Sii::getDireccionRegional($sucursal_sii), $x, $this->getY()+4, 'C', $w); |
| 503 | 503 | } |
| 504 | - $this->SetTextColorArray([0,0,0]); |
|
| 504 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 505 | 505 | $this->Ln(); |
| 506 | 506 | return $this->y; |
| 507 | 507 | } |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | $this->Texto('Señor(es)', $x); |
| 629 | 629 | $this->Texto(':', $x+$offset); |
| 630 | 630 | $this->setFont('', '', null); |
| 631 | - $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
| 631 | + $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
| 632 | 632 | } |
| 633 | 633 | if (!empty($receptor['GiroRecep'])) { |
| 634 | 634 | $this->setFont('', 'B', null); |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | $ciudad = !empty($receptor['CiudadRecep']) ? $receptor['CiudadRecep'] : ( |
| 646 | 646 | !empty($receptor['CmnaRecep']) ? \sasco\LibreDTE\Chile::getCiudad($receptor['CmnaRecep']) : '' |
| 647 | 647 | ); |
| 648 | - $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep'])?(', '.$receptor['CmnaRecep']):'').($ciudad?(', '.$ciudad):''), $x+$offset+2); |
|
| 648 | + $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep']) ? (', '.$receptor['CmnaRecep']) : '').($ciudad ? (', '.$ciudad) : ''), $x+$offset+2); |
|
| 649 | 649 | } |
| 650 | 650 | if (!empty($receptor['Extranjero']['Nacionalidad'])) { |
| 651 | 651 | $this->setFont('', 'B', null); |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | { |
| 761 | 761 | if (!isset($referencias[0])) |
| 762 | 762 | $referencias = [$referencias]; |
| 763 | - foreach($referencias as $r) { |
|
| 763 | + foreach ($referencias as $r) { |
|
| 764 | 764 | $texto = $r['NroLinRef'].' - '.$this->getTipo($r['TpoDocRef']).' N° '.$r['FolioRef'].' del '.$r['FchRef']; |
| 765 | 765 | if (isset($r['RazonRef']) and $r['RazonRef']!==false) |
| 766 | 766 | $texto = $texto.': '.$r['RazonRef']; |
@@ -853,9 +853,9 @@ discard block |
||
| 853 | 853 | $this->SetY($this->getY()+1); |
| 854 | 854 | $p1x = $x; |
| 855 | 855 | $p1y = $this->y; |
| 856 | - $p2x = $this->getPageWidth() - 2; |
|
| 857 | - $p2y = $p1y; // Use same y for a straight line |
|
| 858 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
| 856 | + $p2x = $this->getPageWidth()-2; |
|
| 857 | + $p2y = $p1y; // Use same y for a straight line |
|
| 858 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
| 859 | 859 | $this->Line($p1x, $p1y, $p2x, $p2y, $style); |
| 860 | 860 | $this->Texto($this->detalle_cols['NmbItem']['title'], $x+1, $this->y, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
| 861 | 861 | $this->Texto($this->detalle_cols['PrcItem']['title'], $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
@@ -865,9 +865,9 @@ discard block |
||
| 865 | 865 | if (!isset($detalle[0])) |
| 866 | 866 | $detalle = [$detalle]; |
| 867 | 867 | $this->SetY($this->getY()+2); |
| 868 | - foreach($detalle as &$d) { |
|
| 868 | + foreach ($detalle as &$d) { |
|
| 869 | 869 | $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
| 870 | - $this->Texto(number_format($d['PrcItem'],0,',','.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
| 870 | + $this->Texto(number_format($d['PrcItem'], 0, ',', '.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
| 871 | 871 | $this->Texto($this->num($d['QtyItem']), $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']); |
| 872 | 872 | $this->Texto($this->num($d['MontoItem']), $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']); |
| 873 | 873 | } |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | if (!isset($detalle[0])) { |
| 888 | 888 | $detalle = [$detalle]; |
| 889 | 889 | } |
| 890 | - foreach($detalle as &$d) { |
|
| 890 | + foreach ($detalle as &$d) { |
|
| 891 | 891 | if (!empty($d['MontoItem'])) { |
| 892 | 892 | $subtotal += $d['MontoItem']; |
| 893 | 893 | } |
@@ -907,10 +907,10 @@ discard block |
||
| 907 | 907 | { |
| 908 | 908 | if (!isset($descuentosRecargos[0])) |
| 909 | 909 | $descuentosRecargos = [$descuentosRecargos]; |
| 910 | - foreach($descuentosRecargos as $dr) { |
|
| 910 | + foreach ($descuentosRecargos as $dr) { |
|
| 911 | 911 | $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo'; |
| 912 | 912 | $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : '$'.$this->num($dr['ValorDR']).'.-'; |
| 913 | - $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):''), $x); |
|
| 913 | + $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : ''), $x); |
|
| 914 | 914 | $this->Ln(); |
| 915 | 915 | } |
| 916 | 916 | } |
@@ -928,8 +928,8 @@ discard block |
||
| 928 | 928 | $pagos = [$pagos]; |
| 929 | 929 | $this->Texto('Pago(s) programado(s):', $x); |
| 930 | 930 | $this->Ln(); |
| 931 | - foreach($pagos as $p) { |
|
| 932 | - $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos'])?(' ('.$p['GlosaPagos'].')'):''), $x); |
|
| 931 | + foreach ($pagos as $p) { |
|
| 932 | + $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos']) ? (' ('.$p['GlosaPagos'].')') : ''), $x); |
|
| 933 | 933 | $this->Ln(); |
| 934 | 934 | } |
| 935 | 935 | } |
@@ -979,7 +979,7 @@ discard block |
||
| 979 | 979 | if (!isset($ImptoReten[0])) { |
| 980 | 980 | $ImptoReten = [$ImptoReten]; |
| 981 | 981 | } |
| 982 | - foreach($ImptoReten as $i) { |
|
| 982 | + foreach ($ImptoReten as $i) { |
|
| 983 | 983 | $totales['ImptoReten_'.$i['TipoImp']] = $i['MontoImp']; |
| 984 | 984 | $glosas['ImptoReten_'.$i['TipoImp']] = \sasco\LibreDTE\Sii\ImpuestosAdicionales::getGlosa($i['TipoImp']).' ('.$i['TasaImp'].'%) $'; |
| 985 | 985 | } |
@@ -1040,7 +1040,7 @@ discard block |
||
| 1040 | 1040 | 'vpadding' => 0, |
| 1041 | 1041 | 'module_width' => 1, // width of a single module in points |
| 1042 | 1042 | 'module_height' => 1, // height of a single module in points |
| 1043 | - 'fgcolor' => [0,0,0], |
|
| 1043 | + 'fgcolor' => [0, 0, 0], |
|
| 1044 | 1044 | 'bgcolor' => false, // [255,255,255] |
| 1045 | 1045 | 'position' => $this->papelContinuo ? 'C' : 'S', |
| 1046 | 1046 | ]; |
@@ -1066,7 +1066,7 @@ discard block |
||
| 1066 | 1066 | */ |
| 1067 | 1067 | private function agregarAcuseRecibo($x = 93, $y = 190, $w = 50, $h = 40) |
| 1068 | 1068 | { |
| 1069 | - $this->SetTextColorArray([0,0,0]); |
|
| 1069 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 1070 | 1070 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
| 1071 | 1071 | $this->setFont('', 'B', 10); |
| 1072 | 1072 | $this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1096,9 +1096,9 @@ discard block |
||
| 1096 | 1096 | */ |
| 1097 | 1097 | private function agregarAcuseReciboContinuo($x = 3, $y = null, $w = 68, $h = 40) |
| 1098 | 1098 | { |
| 1099 | - $this->SetTextColorArray([0,0,0]); |
|
| 1099 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 1100 | 1100 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
| 1101 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
| 1101 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
| 1102 | 1102 | $this->Line($x, $y+22, $w+3, $y+22, $style); |
| 1103 | 1103 | //$this->setFont('', 'B', 10); |
| 1104 | 1104 | //$this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1126,7 +1126,7 @@ discard block |
||
| 1126 | 1126 | private function agregarLeyendaDestino($tipo, $y = 254, $font_size = 10) |
| 1127 | 1127 | { |
| 1128 | 1128 | $this->setFont('', 'B', $font_size); |
| 1129 | - $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $y, 'R'); |
|
| 1129 | + $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $y, 'R'); |
|
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | 1132 | /** |
@@ -1157,7 +1157,7 @@ discard block |
||
| 1157 | 1157 | $dias = ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado']; |
| 1158 | 1158 | $meses = ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre']; |
| 1159 | 1159 | $unixtime = strtotime($date); |
| 1160 | - $fecha = date(($mostrar_dia?'\D\I\A ':'').'j \d\e \M\E\S \d\e\l Y', $unixtime); |
|
| 1160 | + $fecha = date(($mostrar_dia ? '\D\I\A ' : '').'j \d\e \M\E\S \d\e\l Y', $unixtime); |
|
| 1161 | 1161 | $dia = $dias[date('w', $unixtime)]; |
| 1162 | 1162 | $mes = $meses[date('n', $unixtime)-1]; |
| 1163 | 1163 | return str_replace(array('DIA', 'MES'), array($dia, $mes), $fecha); |
@@ -302,15 +302,17 @@ discard block |
||
| 302 | 302 | !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null, |
| 303 | 303 | !empty($dte['Encabezado']['Transporte']) ? $dte['Encabezado']['Transporte'] : null |
| 304 | 304 | ); |
| 305 | - if (!empty($dte['Referencia'])) |
|
| 306 | - $this->agregarReferencia($dte['Referencia']); |
|
| 305 | + if (!empty($dte['Referencia'])) { |
|
| 306 | + $this->agregarReferencia($dte['Referencia']); |
|
| 307 | + } |
|
| 307 | 308 | $this->agregarDetalle($dte['Detalle']); |
| 308 | 309 | if (!empty($dte['DscRcgGlobal'])) { |
| 309 | 310 | $this->agregarSubTotal($dte['Detalle']); |
| 310 | 311 | $this->agregarDescuentosRecargos($dte['DscRcgGlobal']); |
| 311 | 312 | } |
| 312 | - if (!empty($dte['Encabezado']['IdDoc']['MntPagos'])) |
|
| 313 | - $this->agregarPagos($dte['Encabezado']['IdDoc']['MntPagos']); |
|
| 313 | + if (!empty($dte['Encabezado']['IdDoc']['MntPagos'])) { |
|
| 314 | + $this->agregarPagos($dte['Encabezado']['IdDoc']['MntPagos']); |
|
| 315 | + } |
|
| 314 | 316 | $this->agregarTotales($dte['Encabezado']['Totales']); |
| 315 | 317 | // agregar observaciones |
| 316 | 318 | $this->agregarObservacion($dte['Encabezado']['IdDoc']); |
@@ -342,8 +344,12 @@ discard block |
||
| 342 | 344 | // determinar alto de la página y agregarla |
| 343 | 345 | $height = 145; |
| 344 | 346 | $n_detalle = count($dte['Detalle']); |
| 345 | - if ($n_detalle>1) $height += $n_detalle*20; |
|
| 346 | - if ($this->cedible) $height += 50; |
|
| 347 | + if ($n_detalle>1) { |
|
| 348 | + $height += $n_detalle*20; |
|
| 349 | + } |
|
| 350 | + if ($this->cedible) { |
|
| 351 | + $height += 50; |
|
| 352 | + } |
|
| 347 | 353 | $this->AddPage('P', [$height, $width]); |
| 348 | 354 | // agregar cabecera del documento |
| 349 | 355 | $y = $this->agregarFolio( |
@@ -445,10 +451,12 @@ discard block |
||
| 445 | 451 | } |
| 446 | 452 | $contacto = []; |
| 447 | 453 | if (!empty($emisor['Telefono'])) { |
| 448 | - if (!is_array($emisor['Telefono'])) |
|
| 449 | - $emisor['Telefono'] = [$emisor['Telefono']]; |
|
| 450 | - foreach ($emisor['Telefono'] as $t) |
|
| 451 | - $contacto[] = $t; |
|
| 454 | + if (!is_array($emisor['Telefono'])) { |
|
| 455 | + $emisor['Telefono'] = [$emisor['Telefono']]; |
|
| 456 | + } |
|
| 457 | + foreach ($emisor['Telefono'] as $t) { |
|
| 458 | + $contacto[] = $t; |
|
| 459 | + } |
|
| 452 | 460 | } |
| 453 | 461 | if (!empty($emisor['CorreoEmisor'])) { |
| 454 | 462 | $contacto[] = $emisor['CorreoEmisor']; |
@@ -515,8 +523,9 @@ discard block |
||
| 515 | 523 | */ |
| 516 | 524 | private function getTipo($tipo) |
| 517 | 525 | { |
| 518 | - if (!is_numeric($tipo) and !isset($this->tipos[$tipo])) |
|
| 519 | - return $tipo; |
|
| 526 | + if (!is_numeric($tipo) and !isset($this->tipos[$tipo])) { |
|
| 527 | + return $tipo; |
|
| 528 | + } |
|
| 520 | 529 | return isset($this->tipos[$tipo]) ? strtoupper($this->tipos[$tipo]) : 'Documento '.$tipo; |
| 521 | 530 | } |
| 522 | 531 | |
@@ -655,10 +664,12 @@ discard block |
||
| 655 | 664 | $this->MultiTexto(\sasco\LibreDTE\Sii\Aduana::getNacionalidad($receptor['Extranjero']['Nacionalidad']), $x+$offset+2); |
| 656 | 665 | } |
| 657 | 666 | $contacto = []; |
| 658 | - if (!empty($receptor['Contacto'])) |
|
| 659 | - $contacto[] = $receptor['Contacto']; |
|
| 660 | - if (!empty($receptor['CorreoRecep'])) |
|
| 661 | - $contacto[] = $receptor['CorreoRecep']; |
|
| 667 | + if (!empty($receptor['Contacto'])) { |
|
| 668 | + $contacto[] = $receptor['Contacto']; |
|
| 669 | + } |
|
| 670 | + if (!empty($receptor['CorreoRecep'])) { |
|
| 671 | + $contacto[] = $receptor['CorreoRecep']; |
|
| 672 | + } |
|
| 662 | 673 | if (!empty($contacto)) { |
| 663 | 674 | $this->setFont('', 'B', null); |
| 664 | 675 | $this->Texto('Contacto', $x); |
@@ -701,15 +712,19 @@ discard block |
||
| 701 | 712 | if (!empty($Transporte['DirDest']) and !empty($Transporte['CmnaDest'])) { |
| 702 | 713 | $transporte .= 'a '.$Transporte['DirDest'].', '.$Transporte['CmnaDest']; |
| 703 | 714 | } |
| 704 | - if (!empty($Transporte['RUTTrans'])) |
|
| 705 | - $transporte .= ' por '.$Transporte['RUTTrans']; |
|
| 706 | - if (!empty($Transporte['Patente'])) |
|
| 707 | - $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
| 715 | + if (!empty($Transporte['RUTTrans'])) { |
|
| 716 | + $transporte .= ' por '.$Transporte['RUTTrans']; |
|
| 717 | + } |
|
| 718 | + if (!empty($Transporte['Patente'])) { |
|
| 719 | + $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
| 720 | + } |
|
| 708 | 721 | if (isset($Transporte['Chofer']) and is_array($Transporte['Chofer'])) { |
| 709 | - if (!empty($Transporte['Chofer']['NombreChofer'])) |
|
| 710 | - $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer']; |
|
| 711 | - if (!empty($Transporte['Chofer']['RUTChofer'])) |
|
| 712 | - $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')'; |
|
| 722 | + if (!empty($Transporte['Chofer']['NombreChofer'])) { |
|
| 723 | + $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer']; |
|
| 724 | + } |
|
| 725 | + if (!empty($Transporte['Chofer']['RUTChofer'])) { |
|
| 726 | + $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')'; |
|
| 727 | + } |
|
| 713 | 728 | } |
| 714 | 729 | if ($transporte) { |
| 715 | 730 | $this->setFont('', 'B', null); |
@@ -723,8 +738,9 @@ discard block |
||
| 723 | 738 | if (!empty($Transporte['Aduana']) and is_array($Transporte['Aduana'])) { |
| 724 | 739 | $col = 0; |
| 725 | 740 | foreach ($Transporte['Aduana'] as $tag => $codigo) { |
| 726 | - if ($codigo===false) |
|
| 727 | - continue; |
|
| 741 | + if ($codigo===false) { |
|
| 742 | + continue; |
|
| 743 | + } |
|
| 728 | 744 | $glosa = \sasco\LibreDTE\Sii\Aduana::getGlosa($tag); |
| 729 | 745 | $valor = \sasco\LibreDTE\Sii\Aduana::getValor($tag, $codigo); |
| 730 | 746 | if ($glosa!==false and $valor!==false) { |
@@ -737,15 +753,18 @@ discard block |
||
| 737 | 753 | $this->Texto(':', $x+$offset+$col); |
| 738 | 754 | $this->setFont('', '', null); |
| 739 | 755 | $this->Texto($valor, $x+$offset+2+$col); |
| 740 | - if ($tag=='TipoBultos') |
|
| 741 | - $col = abs($col-110); |
|
| 742 | - if ($col) |
|
| 743 | - $this->Ln(); |
|
| 756 | + if ($tag=='TipoBultos') { |
|
| 757 | + $col = abs($col-110); |
|
| 758 | + } |
|
| 759 | + if ($col) { |
|
| 760 | + $this->Ln(); |
|
| 761 | + } |
|
| 744 | 762 | $col = abs($col-110); |
| 745 | 763 | } |
| 746 | 764 | } |
| 747 | - if ($col) |
|
| 748 | - $this->Ln(); |
|
| 765 | + if ($col) { |
|
| 766 | + $this->Ln(); |
|
| 767 | + } |
|
| 749 | 768 | } |
| 750 | 769 | } |
| 751 | 770 | |
@@ -758,12 +777,14 @@ discard block |
||
| 758 | 777 | */ |
| 759 | 778 | private function agregarReferencia($referencias, $x = 10, $offset = 22) |
| 760 | 779 | { |
| 761 | - if (!isset($referencias[0])) |
|
| 762 | - $referencias = [$referencias]; |
|
| 780 | + if (!isset($referencias[0])) { |
|
| 781 | + $referencias = [$referencias]; |
|
| 782 | + } |
|
| 763 | 783 | foreach($referencias as $r) { |
| 764 | 784 | $texto = $r['NroLinRef'].' - '.$this->getTipo($r['TpoDocRef']).' N° '.$r['FolioRef'].' del '.$r['FchRef']; |
| 765 | - if (isset($r['RazonRef']) and $r['RazonRef']!==false) |
|
| 766 | - $texto = $texto.': '.$r['RazonRef']; |
|
| 785 | + if (isset($r['RazonRef']) and $r['RazonRef']!==false) { |
|
| 786 | + $texto = $texto.': '.$r['RazonRef']; |
|
| 787 | + } |
|
| 767 | 788 | $this->setFont('', 'B', null); |
| 768 | 789 | $this->Texto('Referencia', $x); |
| 769 | 790 | $this->Texto(':', $x+$offset); |
@@ -782,8 +803,9 @@ discard block |
||
| 782 | 803 | */ |
| 783 | 804 | private function agregarDetalle($detalle, $x = 10) |
| 784 | 805 | { |
| 785 | - if (!isset($detalle[0])) |
|
| 786 | - $detalle = [$detalle]; |
|
| 806 | + if (!isset($detalle[0])) { |
|
| 807 | + $detalle = [$detalle]; |
|
| 808 | + } |
|
| 787 | 809 | $this->setFont('', '', $this->detalle_fuente); |
| 788 | 810 | // titulos |
| 789 | 811 | $titulos = []; |
@@ -800,36 +822,42 @@ discard block |
||
| 800 | 822 | $item['NmbItem'] .= !$this->item_detalle_posicion ? '<br/>' : ': '; |
| 801 | 823 | $item['NmbItem'] .= '<span style="font-size:0.7em">'.$item['DscItem'].'</span>'; |
| 802 | 824 | } |
| 803 | - if (!in_array($col, $titulos_keys) or ($dte_exento and $col=='IndExe')) |
|
| 804 | - unset($item[$col]); |
|
| 825 | + if (!in_array($col, $titulos_keys) or ($dte_exento and $col=='IndExe')) { |
|
| 826 | + unset($item[$col]); |
|
| 827 | + } |
|
| 805 | 828 | } |
| 806 | 829 | // ajustes a IndExe |
| 807 | 830 | if (isset($item['IndExe'])) { |
| 808 | - if ($item['IndExe']==1) |
|
| 809 | - $item['IndExe'] = 'EX'; |
|
| 810 | - else if ($item['IndExe']==2) |
|
| 811 | - $item['IndExe'] = 'NF'; |
|
| 831 | + if ($item['IndExe']==1) { |
|
| 832 | + $item['IndExe'] = 'EX'; |
|
| 833 | + } else if ($item['IndExe']==2) { |
|
| 834 | + $item['IndExe'] = 'NF'; |
|
| 835 | + } |
|
| 812 | 836 | } |
| 813 | 837 | // agregar todas las columnas que se podrían imprimir en la tabla |
| 814 | 838 | $item_default = []; |
| 815 | - foreach ($this->detalle_cols as $key => $info) |
|
| 816 | - $item_default[$key] = false; |
|
| 839 | + foreach ($this->detalle_cols as $key => $info) { |
|
| 840 | + $item_default[$key] = false; |
|
| 841 | + } |
|
| 817 | 842 | $item = array_merge($item_default, $item); |
| 818 | 843 | // si hay código de item se extrae su valor |
| 819 | - if ($item['CdgItem']) |
|
| 820 | - $item['CdgItem'] = $item['CdgItem']['VlrCodigo']; |
|
| 844 | + if ($item['CdgItem']) { |
|
| 845 | + $item['CdgItem'] = $item['CdgItem']['VlrCodigo']; |
|
| 846 | + } |
|
| 821 | 847 | // dar formato a números |
| 822 | 848 | foreach (['QtyItem', 'PrcItem', 'DescuentoMonto', 'RecargoMonto', 'MontoItem'] as $col) { |
| 823 | - if ($item[$col]) |
|
| 824 | - $item[$col] = $this->num($item[$col]); |
|
| 849 | + if ($item[$col]) { |
|
| 850 | + $item[$col] = $this->num($item[$col]); |
|
| 851 | + } |
|
| 825 | 852 | } |
| 826 | 853 | } |
| 827 | 854 | // opciones |
| 828 | 855 | $options = ['align'=>[]]; |
| 829 | 856 | $i = 0; |
| 830 | 857 | foreach ($this->detalle_cols as $info) { |
| 831 | - if (isset($info['width'])) |
|
| 832 | - $options['width'][$i] = $info['width']; |
|
| 858 | + if (isset($info['width'])) { |
|
| 859 | + $options['width'][$i] = $info['width']; |
|
| 860 | + } |
|
| 833 | 861 | $options['align'][$i] = $info['align']; |
| 834 | 862 | $i++; |
| 835 | 863 | } |
@@ -862,8 +890,9 @@ discard block |
||
| 862 | 890 | $this->Texto($this->detalle_cols['QtyItem']['title'], $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']); |
| 863 | 891 | $this->Texto($this->detalle_cols['MontoItem']['title'], $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']); |
| 864 | 892 | $this->Line($p1x, $p1y+4, $p2x, $p2y+4, $style); |
| 865 | - if (!isset($detalle[0])) |
|
| 866 | - $detalle = [$detalle]; |
|
| 893 | + if (!isset($detalle[0])) { |
|
| 894 | + $detalle = [$detalle]; |
|
| 895 | + } |
|
| 867 | 896 | $this->SetY($this->getY()+2); |
| 868 | 897 | foreach($detalle as &$d) { |
| 869 | 898 | $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
@@ -905,8 +934,9 @@ discard block |
||
| 905 | 934 | */ |
| 906 | 935 | private function agregarDescuentosRecargos(array $descuentosRecargos, $x = 10) |
| 907 | 936 | { |
| 908 | - if (!isset($descuentosRecargos[0])) |
|
| 909 | - $descuentosRecargos = [$descuentosRecargos]; |
|
| 937 | + if (!isset($descuentosRecargos[0])) { |
|
| 938 | + $descuentosRecargos = [$descuentosRecargos]; |
|
| 939 | + } |
|
| 910 | 940 | foreach($descuentosRecargos as $dr) { |
| 911 | 941 | $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo'; |
| 912 | 942 | $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : '$'.$this->num($dr['ValorDR']).'.-'; |
@@ -924,8 +954,9 @@ discard block |
||
| 924 | 954 | */ |
| 925 | 955 | private function agregarPagos(array $pagos, $x = 10) |
| 926 | 956 | { |
| 927 | - if (!isset($pagos[0])) |
|
| 928 | - $pagos = [$pagos]; |
|
| 957 | + if (!isset($pagos[0])) { |
|
| 958 | + $pagos = [$pagos]; |
|
| 959 | + } |
|
| 929 | 960 | $this->Texto('Pago(s) programado(s):', $x); |
| 930 | 961 | $this->Ln(); |
| 931 | 962 | foreach($pagos as $p) { |
@@ -1139,11 +1170,13 @@ discard block |
||
| 1139 | 1170 | */ |
| 1140 | 1171 | private function num($n) |
| 1141 | 1172 | { |
| 1142 | - if (!is_numeric($n)) |
|
| 1143 | - return $n; |
|
| 1173 | + if (!is_numeric($n)) { |
|
| 1174 | + return $n; |
|
| 1175 | + } |
|
| 1144 | 1176 | $broken_number = explode('.', (string)$n); |
| 1145 | - if (isset($broken_number[1])) |
|
| 1146 | - return number_format($broken_number[0], 0, ',', '.').','.$broken_number[1]; |
|
| 1177 | + if (isset($broken_number[1])) { |
|
| 1178 | + return number_format($broken_number[0], 0, ',', '.').','.$broken_number[1]; |
|
| 1179 | + } |
|
| 1147 | 1180 | return number_format($broken_number[0], 0, ',', '.'); |
| 1148 | 1181 | } |
| 1149 | 1182 | |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | /** |
| 52 | 52 | * Método que genera nodos XML a partir de un arreglo |
| 53 | 53 | * @param array Arreglo con los datos que se usarán para generar XML |
| 54 | - * @param parent DOMElement padre para los elementos, o =null para que sea la raíz |
|
| 55 | - * @return Objeto \sasco\LibreDTE\XML |
|
| 54 | + * @param parent \DOMElement padre para los elementos, o =null para que sea la raíz |
|
| 55 | + * @return XML \sasco\LibreDTE\XML |
|
| 56 | 56 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 57 | 57 | * @version 2016-04-03 |
| 58 | 58 | */ |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | /** |
| 140 | 140 | * Método para realizar consultas XPATH al documento XML |
| 141 | 141 | * @param expression Expresión XPath a ejecutar |
| 142 | - * @return DOMNodeList |
|
| 142 | + * @return \DOMNodeList |
|
| 143 | 143 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 144 | 144 | * @version 2015-08-05 |
| 145 | 145 | */ |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * Método que cuenta los nodos con el mismo nombre hijos deun DOMElement |
| 260 | 260 | * No sirve usar: $dom->getElementsByTagName($tagName)->length ya que esto |
| 261 | 261 | * entrega todos los nodos con el nombre, sean hijos, nietos, etc. |
| 262 | - * @return Cantidad de nodos hijos con el mismo nombre en el DOMElement |
|
| 262 | + * @return integer de nodos hijos con el mismo nombre en el DOMElement |
|
| 263 | 263 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 264 | 264 | * @version 2015-09-07 |
| 265 | 265 | */ |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | |
| 300 | 300 | /** |
| 301 | 301 | * Método que entrega el nombre del archivo del schema del XML |
| 302 | - * @return Nombre del schema o bien =false si no se encontró |
|
| 302 | + * @return string del schema o bien =false si no se encontró |
|
| 303 | 303 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 304 | 304 | * @version 2015-12-14 |
| 305 | 305 | */ |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 57 | 57 | * @version 2016-04-03 |
| 58 | 58 | */ |
| 59 | - public function generate(array $array, \DOMElement &$parent = null) |
|
| 59 | + public function generate(array $array, \DOMElement & $parent = null) |
|
| 60 | 60 | { |
| 61 | 61 | if ($parent===null) |
| 62 | 62 | $parent = &$this; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | */ |
| 183 | 183 | private function utf2iso($string) |
| 184 | 184 | { |
| 185 | - return mb_detect_encoding($string, ['UTF-8', 'ISO-8859-1']) != 'ISO-8859-1' ? utf8_decode($string) : $string; |
|
| 185 | + return mb_detect_encoding($string, ['UTF-8', 'ISO-8859-1'])!='ISO-8859-1' ? utf8_decode($string) : $string; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /** |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | // agregar nodos hijos |
| 224 | 224 | if ($dom->hasChildNodes()) { |
| 225 | - foreach($dom->childNodes as $child) { |
|
| 225 | + foreach ($dom->childNodes as $child) { |
|
| 226 | 226 | if ($child instanceof \DOMText) { |
| 227 | 227 | $textContent = trim($child->textContent); |
| 228 | 228 | if ($textContent!="") { |
@@ -58,13 +58,15 @@ discard block |
||
| 58 | 58 | */ |
| 59 | 59 | public function generate(array $array, \DOMElement &$parent = null) |
| 60 | 60 | { |
| 61 | - if ($parent===null) |
|
| 62 | - $parent = &$this; |
|
| 61 | + if ($parent===null) { |
|
| 62 | + $parent = &$this; |
|
| 63 | + } |
|
| 63 | 64 | foreach ($array as $key => $value) { |
| 64 | 65 | if ($key=='@attributes') { |
| 65 | 66 | foreach ($value as $attr => $val) { |
| 66 | - if ($val!==false) |
|
| 67 | - $parent->setAttribute($attr, $val); |
|
| 67 | + if ($val!==false) { |
|
| 68 | + $parent->setAttribute($attr, $val); |
|
| 69 | + } |
|
| 68 | 70 | } |
| 69 | 71 | } else if ($key=='@value') { |
| 70 | 72 | $parent->nodeValue = $this->sanitize($value); |
@@ -107,8 +109,9 @@ discard block |
||
| 107 | 109 | private function sanitize($txt) |
| 108 | 110 | { |
| 109 | 111 | // si no se paso un texto o bien es un número no se hace nada |
| 110 | - if (!$txt or is_numeric($txt)) |
|
| 111 | - return $txt; |
|
| 112 | + if (!$txt or is_numeric($txt)) { |
|
| 113 | + return $txt; |
|
| 114 | + } |
|
| 112 | 115 | // convertir "predefined entities" de XML |
| 113 | 116 | $txt = str_replace( |
| 114 | 117 | ['&', '&', '<', '<', '>', '>', '"', '"', ''', '''], |
@@ -160,8 +163,9 @@ discard block |
||
| 160 | 163 | { |
| 161 | 164 | if ($xpath) { |
| 162 | 165 | $node = $this->xpath($xpath)->item(0); |
| 163 | - if (!$node) |
|
| 164 | - return false; |
|
| 166 | + if (!$node) { |
|
| 167 | + return false; |
|
| 168 | + } |
|
| 165 | 169 | $xml = $this->utf2iso($node->C14N()); |
| 166 | 170 | } else { |
| 167 | 171 | $xml = $this->C14N(); |
@@ -207,12 +211,15 @@ discard block |
||
| 207 | 211 | public function toArray(\DOMElement $dom = null, array &$array = null, $arregloNodos = false) |
| 208 | 212 | { |
| 209 | 213 | // determinar valores de parámetros |
| 210 | - if (!$dom) |
|
| 211 | - $dom = $this->documentElement; |
|
| 212 | - if (!$dom) |
|
| 213 | - return false; |
|
| 214 | - if ($array===null) |
|
| 215 | - $array = [$dom->tagName => null]; |
|
| 214 | + if (!$dom) { |
|
| 215 | + $dom = $this->documentElement; |
|
| 216 | + } |
|
| 217 | + if (!$dom) { |
|
| 218 | + return false; |
|
| 219 | + } |
|
| 220 | + if ($array===null) { |
|
| 221 | + $array = [$dom->tagName => null]; |
|
| 222 | + } |
|
| 216 | 223 | // agregar atributos del nodo |
| 217 | 224 | if ($dom->hasAttributes()) { |
| 218 | 225 | $array[$dom->tagName]['@attributes'] = []; |
@@ -228,22 +235,24 @@ discard block |
||
| 228 | 235 | if ($textContent!="") { |
| 229 | 236 | if ($dom->childNodes->length==1 and empty($array[$dom->tagName])) { |
| 230 | 237 | $array[$dom->tagName] = $textContent; |
| 231 | - } else |
|
| 232 | - $array[$dom->tagName]['@value'] = $textContent; |
|
| 238 | + } else { |
|
| 239 | + $array[$dom->tagName]['@value'] = $textContent; |
|
| 240 | + } |
|
| 233 | 241 | } |
| 234 | - } |
|
| 235 | - else if ($child instanceof \DOMElement) { |
|
| 242 | + } else if ($child instanceof \DOMElement) { |
|
| 236 | 243 | $nodos_gemelos = $this->countTwins($dom, $child->tagName); |
| 237 | 244 | if ($nodos_gemelos==1) { |
| 238 | - if ($arregloNodos) |
|
| 239 | - $this->toArray($child, $array); |
|
| 240 | - else |
|
| 241 | - $this->toArray($child, $array[$dom->tagName]); |
|
| 245 | + if ($arregloNodos) { |
|
| 246 | + $this->toArray($child, $array); |
|
| 247 | + } else { |
|
| 248 | + $this->toArray($child, $array[$dom->tagName]); |
|
| 249 | + } |
|
| 242 | 250 | } |
| 243 | 251 | // crear arreglo con nodos hijos que tienen el mismo nombre de tag |
| 244 | 252 | else { |
| 245 | - if (!isset($array[$dom->tagName][$child->tagName])) |
|
| 246 | - $array[$dom->tagName][$child->tagName] = []; |
|
| 253 | + if (!isset($array[$dom->tagName][$child->tagName])) { |
|
| 254 | + $array[$dom->tagName][$child->tagName] = []; |
|
| 255 | + } |
|
| 247 | 256 | $siguiente = count($array[$dom->tagName][$child->tagName]); |
| 248 | 257 | $array[$dom->tagName][$child->tagName][$siguiente] = []; |
| 249 | 258 | $this->toArray($child, $array[$dom->tagName][$child->tagName][$siguiente], true); |
@@ -267,8 +276,9 @@ discard block |
||
| 267 | 276 | { |
| 268 | 277 | $twins = 0; |
| 269 | 278 | foreach ($dom->childNodes as $child) { |
| 270 | - if ($child instanceof \DOMElement and $child->tagName==$tagName) |
|
| 271 | - $twins++; |
|
| 279 | + if ($child instanceof \DOMElement and $child->tagName==$tagName) { |
|
| 280 | + $twins++; |
|
| 281 | + } |
|
| 272 | 282 | } |
| 273 | 283 | return $twins; |
| 274 | 284 | } |
@@ -282,8 +292,9 @@ discard block |
||
| 282 | 292 | public function getErrors() |
| 283 | 293 | { |
| 284 | 294 | $errors = []; |
| 285 | - foreach (libxml_get_errors() as $e) |
|
| 286 | - $errors[] = $e->message; |
|
| 295 | + foreach (libxml_get_errors() as $e) { |
|
| 296 | + $errors[] = $e->message; |
|
| 297 | + } |
|
| 287 | 298 | return $errors; |
| 288 | 299 | } |
| 289 | 300 | |
@@ -306,8 +317,9 @@ discard block |
||
| 306 | 317 | public function getSchema() |
| 307 | 318 | { |
| 308 | 319 | $schemaLocation = $this->documentElement->getAttribute('xsi:schemaLocation'); |
| 309 | - if (!$schemaLocation or strpos($schemaLocation, ' ')===false) |
|
| 310 | - return false; |
|
| 320 | + if (!$schemaLocation or strpos($schemaLocation, ' ')===false) { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 311 | 323 | list($uri, $xsd) = explode(' ', $schemaLocation); |
| 312 | 324 | return $xsd; |
| 313 | 325 | } |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | public function caso2() |
| 67 | 67 | { |
| 68 | - for ($i=0; $i<5; $i++) |
|
| 68 | + for ($i = 0; $i<5; $i++) |
|
| 69 | 69 | \sasco\LibreDTE\Log::write('Soy el error '.($i+1)); |
| 70 | 70 | } |
| 71 | 71 | public function caso3() |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | $GeneradorErrores->caso1(); |
| 83 | 83 | |
| 84 | 84 | // obtener el error más reciente y usar como string |
| 85 | -echo \sasco\LibreDTE\Log::read(),"\n\n"; |
|
| 85 | +echo \sasco\LibreDTE\Log::read(), "\n\n"; |
|
| 86 | 86 | |
| 87 | 87 | // mostrar el resto de errores y usar como string |
| 88 | 88 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 89 | - echo $error,"\n"; |
|
| 89 | + echo $error, "\n"; |
|
| 90 | 90 | echo "\n\n\n"; |
| 91 | 91 | |
| 92 | 92 | // ejecutar caso 2 |
@@ -94,27 +94,27 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | // obtener el error más reciente y usar como objeto |
| 96 | 96 | $error = \sasco\LibreDTE\Log::read(); |
| 97 | -echo 'error código: ',$error->code,' y mensaje ',$error->msg,"\n\n"; |
|
| 97 | +echo 'error código: ', $error->code, ' y mensaje ', $error->msg, "\n\n"; |
|
| 98 | 98 | |
| 99 | 99 | // mostrar el resto de errores y usar como objeto |
| 100 | 100 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 101 | - echo 'error código: ',$error->code,' y mensaje ',$error->msg,"\n"; |
|
| 101 | + echo 'error código: ', $error->code, ' y mensaje ', $error->msg, "\n"; |
|
| 102 | 102 | echo "\n\n\n"; |
| 103 | 103 | |
| 104 | 104 | // ejecutar caso 3 y mostrar en español todos los mensajes |
| 105 | 105 | $GeneradorErrores->caso3(); |
| 106 | 106 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 107 | - echo $error,"\n"; |
|
| 107 | + echo $error, "\n"; |
|
| 108 | 108 | echo "\n\n\n"; |
| 109 | 109 | |
| 110 | 110 | // ejecutar caso 3 y mostrar en español todos los mensajes pero como objetos |
| 111 | 111 | $GeneradorErrores->caso3(); |
| 112 | 112 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 113 | - echo 'error código: ',$error->code,' y mensaje ',$error->msg,"\n"; |
|
| 113 | + echo 'error código: ', $error->code, ' y mensaje ', $error->msg, "\n"; |
|
| 114 | 114 | echo "\n\n\n"; |
| 115 | 115 | |
| 116 | 116 | // ejecutar caso 3 y mostrar en inglés todos los mensajes |
| 117 | 117 | \sasco\LibreDTE\I18n::setIdioma('en'); // idioma se debe asignar antes que se registre cualquier mensaje en el Log |
| 118 | 118 | $GeneradorErrores->caso3(); |
| 119 | 119 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 120 | - echo $error,"\n"; |
|
| 120 | + echo $error, "\n"; |
|
@@ -65,8 +65,9 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | public function caso2() |
| 67 | 67 | { |
| 68 | - for ($i=0; $i<5; $i++) |
|
| 69 | - \sasco\LibreDTE\Log::write('Soy el error '.($i+1)); |
|
| 68 | + for ($i=0; $i<5; $i++) { |
|
| 69 | + \sasco\LibreDTE\Log::write('Soy el error '.($i+1)); |
|
| 70 | + } |
|
| 70 | 71 | } |
| 71 | 72 | public function caso3() |
| 72 | 73 | { |
@@ -85,8 +86,9 @@ discard block |
||
| 85 | 86 | echo \sasco\LibreDTE\Log::read(),"\n\n"; |
| 86 | 87 | |
| 87 | 88 | // mostrar el resto de errores y usar como string |
| 88 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 89 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 89 | 90 | echo $error,"\n"; |
| 91 | +} |
|
| 90 | 92 | echo "\n\n\n"; |
| 91 | 93 | |
| 92 | 94 | // ejecutar caso 2 |
@@ -97,24 +99,28 @@ discard block |
||
| 97 | 99 | echo 'error código: ',$error->code,' y mensaje ',$error->msg,"\n\n"; |
| 98 | 100 | |
| 99 | 101 | // mostrar el resto de errores y usar como objeto |
| 100 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 102 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 101 | 103 | echo 'error código: ',$error->code,' y mensaje ',$error->msg,"\n"; |
| 104 | +} |
|
| 102 | 105 | echo "\n\n\n"; |
| 103 | 106 | |
| 104 | 107 | // ejecutar caso 3 y mostrar en español todos los mensajes |
| 105 | 108 | $GeneradorErrores->caso3(); |
| 106 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 109 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 107 | 110 | echo $error,"\n"; |
| 111 | +} |
|
| 108 | 112 | echo "\n\n\n"; |
| 109 | 113 | |
| 110 | 114 | // ejecutar caso 3 y mostrar en español todos los mensajes pero como objetos |
| 111 | 115 | $GeneradorErrores->caso3(); |
| 112 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 116 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 113 | 117 | echo 'error código: ',$error->code,' y mensaje ',$error->msg,"\n"; |
| 118 | +} |
|
| 114 | 119 | echo "\n\n\n"; |
| 115 | 120 | |
| 116 | 121 | // ejecutar caso 3 y mostrar en inglés todos los mensajes |
| 117 | 122 | \sasco\LibreDTE\I18n::setIdioma('en'); // idioma se debe asignar antes que se registre cualquier mensaje en el Log |
| 118 | 123 | $GeneradorErrores->caso3(); |
| 119 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 124 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 120 | 125 | echo $error,"\n"; |
| 126 | +} |
|
@@ -52,15 +52,18 @@ |
||
| 52 | 52 | |
| 53 | 53 | // directorio temporal para guardar los PDF |
| 54 | 54 | $dir = sys_get_temp_dir().'/dte_'.$Caratula['RutEmisor'].'_'.$Caratula['RutReceptor'].'_'.str_replace(['-', ':', 'T'], '', $Caratula['TmstFirmaEnv']); |
| 55 | -if (is_dir($dir)) |
|
| 55 | +if (is_dir($dir)) { |
|
| 56 | 56 | \sasco\LibreDTE\File::rmdir($dir); |
| 57 | -if (!mkdir($dir)) |
|
| 57 | +} |
|
| 58 | +if (!mkdir($dir)) { |
|
| 58 | 59 | die('No fue posible crear directorio temporal para DTEs'); |
| 60 | +} |
|
| 59 | 61 | |
| 60 | 62 | // procesar cada DTEs e ir agregándolo al PDF |
| 61 | 63 | foreach ($Documentos as $DTE) { |
| 62 | - if (!$DTE->getDatos()) |
|
| 63 | - die('No se pudieron obtener los datos del DTE'); |
|
| 64 | + if (!$DTE->getDatos()) { |
|
| 65 | + die('No se pudieron obtener los datos del DTE'); |
|
| 66 | + } |
|
| 64 | 67 | $pdf = new \sasco\LibreDTE\Sii\PDF\Dte(false); // =false hoja carta, =true papel contínuo (false por defecto si no se pasa) |
| 65 | 68 | $pdf->setFooterText(); |
| 66 | 69 | $pdf->setLogo('/home/delaf/www/localhost/dev/pages/sasco/website/webroot/img/logo_mini.png'); // debe ser PNG! |
@@ -38,18 +38,20 @@ |
||
| 38 | 38 | date_default_timezone_set('America/Santiago'); |
| 39 | 39 | |
| 40 | 40 | // incluir autocarga de composer |
| 41 | -if (is_readable(dirname(dirname(__FILE__)).'/vendor/autoload.php')) |
|
| 41 | +if (is_readable(dirname(dirname(__FILE__)).'/vendor/autoload.php')) { |
|
| 42 | 42 | include dirname(dirname(__FILE__)).'/vendor/autoload.php'; |
| 43 | -else |
|
| 43 | +} else { |
|
| 44 | 44 | die('Para probar los ejemplos debes ejecutar primero "composer install" en el directorio '.dirname(dirname(__FILE__))."\n"); |
| 45 | +} |
|
| 45 | 46 | |
| 46 | 47 | // todos los ejemplos se ejecutan con backtrace activado, esto para ayudar al |
| 47 | 48 | // debug de los mismos |
| 48 | 49 | \sasco\LibreDTE\Log::setBacktrace(true); |
| 49 | 50 | |
| 50 | 51 | // incluir configuración específica de los ejemplos |
| 51 | -if (is_readable('config.php')) |
|
| 52 | +if (is_readable('config.php')) { |
|
| 52 | 53 | include 'config.php'; |
| 53 | -else |
|
| 54 | +} else { |
|
| 54 | 55 | die('Debes crear config.php a partir de config-dist.php'."\n"); |
| 56 | +} |
|
| 55 | 57 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($config['firma']); |
| 40 | 40 | if (!$token) { |
| 41 | 41 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 42 | - echo $error,"\n"; |
|
| 42 | + echo $error, "\n"; |
|
| 43 | 43 | exit; |
| 44 | 44 | } |
| 45 | 45 | |
@@ -65,4 +65,4 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | // si hubo errores se muestran |
| 67 | 67 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 68 | - echo $error,"\n"; |
|
| 68 | + echo $error, "\n"; |
|
@@ -38,8 +38,9 @@ discard block |
||
| 38 | 38 | // solicitar token |
| 39 | 39 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($config['firma']); |
| 40 | 40 | if (!$token) { |
| 41 | - foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 42 | - echo $error,"\n"; |
|
| 41 | + foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 42 | + echo $error,"\n"; |
|
| 43 | + } |
|
| 43 | 44 | exit; |
| 44 | 45 | } |
| 45 | 46 | |
@@ -64,5 +65,6 @@ discard block |
||
| 64 | 65 | } |
| 65 | 66 | |
| 66 | 67 | // si hubo errores se muestran |
| 67 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 68 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 68 | 69 | echo $error,"\n"; |
| 70 | +} |
|
@@ -66,4 +66,4 @@ |
||
| 66 | 66 | |
| 67 | 67 | // si hubo errores mostrar |
| 68 | 68 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 69 | - echo $error,"\n"; |
|
| 69 | + echo $error, "\n"; |
|
@@ -65,5 +65,6 @@ |
||
| 65 | 65 | var_dump($track_id); |
| 66 | 66 | |
| 67 | 67 | // si hubo errores mostrar |
| 68 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 68 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 69 | 69 | echo $error,"\n"; |
| 70 | +} |
|