Completed
Pull Request — master (#44)
by
unknown
03:06 queued 43s
created
examples/012-set_pruebas_ventas.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,4 +66,4 @@
 block discarded – undo
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";
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,5 +65,6 @@
 block discarded – undo
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
+}
Please login to merge, or discard this patch.
examples/031-libro_boleta.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,4 +66,4 @@
 block discarded – undo
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";
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,5 +98,6 @@
 block discarded – undo
98 98
 }
99 99
 
100 100
 // si hubo errores mostrar
101
-foreach (\sasco\LibreDTE\Log::readAll() as $error)
101
+foreach (\sasco\LibreDTE\Log::readAll() as $error) {
102 102
     echo $error,"\n";
103
+}
Please login to merge, or discard this patch.
examples/022-libro_ventas_csv.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -66,4 +66,4 @@
 block discarded – undo
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";
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -65,5 +65,6 @@
 block discarded – undo
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
+}
Please login to merge, or discard this patch.
lib/Sii/RegistroCompraVenta.php 2 patches
Doc Comments   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 
56 56
     /**
57 57
      * Constructor, obtiene el token de la sesión y lo guarda
58
-     * @param Firma Objeto con la firma electrónica
58
+     * @param Firma \sasco\LibreDTE\FirmaElectronica con la firma electrónica
59 59
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
60 60
      * @version 2017-08-28
61 61
      */
@@ -97,6 +97,8 @@  discard block
 block discarded – undo
97 97
      * Método que entrega los eventos asociados a un DTE
98 98
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
99 99
      * @version 2017-08-28
100
+     * @param string $dte
101
+     * @param string $folio
100 102
      */
101 103
     public function listarEventosHistDoc($rut, $dv, $dte, $folio)
102 104
     {
@@ -184,10 +186,10 @@  discard block
 block discarded – undo
184 186
 
185 187
     /**
186 188
      * Método para realizar una solicitud al servicio web del SII
187
-     * @param request Nombre de la función que se ejecutará en el servicio web
189
+     * @param request string de la función que se ejecutará en el servicio web
188 190
      * @param args Argumentos que se pasarán al servicio web
189
-     * @param retry Intentos que se realizarán como máximo para obtener respuesta
190
-     * @return Objeto o String con la respuesta (depende servicio web)
191
+     * @param retry integer que se realizarán como máximo para obtener respuesta
192
+     * @return string o String con la respuesta (depende servicio web)
191 193
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
192 194
      * @version 2017-08-28
193 195
      */
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -220,7 +220,7 @@
 block discarded – undo
220 220
             \sasco\LibreDTE\Log::write(\sasco\LibreDTE\Estado::REQUEST_ERROR_SOAP, \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::REQUEST_ERROR_SOAP, $msg));
221 221
             return false;
222 222
         }
223
-        for ($i=0; $i<$retry; $i++) {
223
+        for ($i = 0; $i<$retry; $i++) {
224 224
             try {
225 225
                 $body = call_user_func_array([$soap, $request], $args);
226 226
                 break;
Please login to merge, or discard this patch.
lib/Sii/PDF/Dte.php 3 patches
Doc Comments   +31 added lines, -28 removed lines patch added patch discarded remove patch
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
     /**
176 176
      * Método que asigna la ubicación del logo de la empresa
177 177
      * @param logo URI del logo (puede ser local o en una URL)
178
-     * @param posicion Posición respecto a datos del emisor (=0 izq, =1 arriba)
178
+     * @param posicion integer respecto a datos del emisor (=0 izq, =1 arriba)
179 179
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
180 180
      * @version 2016-08-04
181 181
      */
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
      * contínuo
338 338
      * @param dte Arreglo con los datos del XML (tag Documento)
339 339
      * @param timbre String XML con el tag TED del DTE
340
-     * @param width Ancho del papel contínuo en mm
340
+     * @param width boolean del papel contínuo en mm
341 341
      * @author Pablo Reyes (https://github.com/pabloxp)
342 342
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
343 343
      * @version 2017-09-02
@@ -489,10 +489,11 @@  discard block
 block discarded – undo
489 489
      *  - Dirección casa central del emisor
490 490
      *  - Dirección sucursales
491 491
      * @param emisor Arreglo con los datos del emisor (tag Emisor del XML)
492
-     * @param x Posición horizontal de inicio en el PDF
493
-     * @param y Posición vertical de inicio en el PDF
494
-     * @param w Ancho de la información del emisor
495
-     * @param w_img Ancho máximo de la imagen
492
+     * @param x integer horizontal de inicio en el PDF
493
+     * @param y integer vertical de inicio en el PDF
494
+     * @param w integer de la información del emisor
495
+     * @param w_img integer máximo de la imagen
496
+     * @param integer $font_size
496 497
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
497 498
      * @version 2016-12-02
498 499
      */
@@ -562,11 +563,13 @@  discard block
 block discarded – undo
562 563
      * @param rut RUT del emisor
563 564
      * @param tipo Código o glosa del tipo de documento
564 565
      * @param sucursal_sii Código o glosa de la sucursal del SII del Emisor
565
-     * @param x Posición horizontal de inicio en el PDF
566
-     * @param y Posición vertical de inicio en el PDF
567
-     * @param w Ancho de la información del emisor
566
+     * @param x integer horizontal de inicio en el PDF
567
+     * @param y integer vertical de inicio en el PDF
568
+     * @param w integer de la información del emisor
569
+     * @param integer $font_size
568 570
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
569 571
      * @version 2016-12-02
572
+     * @return integer
570 573
      */
571 574
     private function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null)
572 575
     {
@@ -612,7 +615,7 @@  discard block
 block discarded – undo
612 615
      * Método que agrega los datos de la emisión del DTE que no son los dato del
613 616
      * receptor
614 617
      * @param IdDoc Información general del documento
615
-     * @param x Posición horizontal de inicio en el PDF
618
+     * @param x integer horizontal de inicio en el PDF
616 619
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
617 620
      * @version 2017-06-15
618 621
      */
@@ -700,7 +703,7 @@  discard block
 block discarded – undo
700 703
     /**
701 704
      * Método que agrega los datos del receptor
702 705
      * @param receptor Arreglo con los datos del receptor (tag Receptor del XML)
703
-     * @param x Posición horizontal de inicio en el PDF
706
+     * @param x integer horizontal de inicio en el PDF
704 707
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
705 708
      * @version 2017-06-15
706 709
      */
@@ -787,7 +790,7 @@  discard block
 block discarded – undo
787 790
      * Método que agrega los datos del traslado
788 791
      * @param IndTraslado
789 792
      * @param Transporte
790
-     * @param x Posición horizontal de inicio en el PDF
793
+     * @param x integer horizontal de inicio en el PDF
791 794
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
792 795
      * @version 2016-08-03
793 796
      */
@@ -858,7 +861,7 @@  discard block
 block discarded – undo
858 861
     /**
859 862
      * Método que agrega las referencias del documento
860 863
      * @param referencias Arreglo con las referencias del documento (tag Referencia del XML)
861
-     * @param x Posición horizontal de inicio en el PDF
864
+     * @param x integer horizontal de inicio en el PDF
862 865
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
863 866
      * @version 2017-08-17
864 867
      */
@@ -891,7 +894,7 @@  discard block
 block discarded – undo
891 894
     /**
892 895
      * Método que agrega el detalle del documento
893 896
      * @param detalle Arreglo con el detalle del documento (tag Detalle del XML)
894
-     * @param x Posición horizontal de inicio en el PDF
897
+     * @param x integer horizontal de inicio en el PDF
895 898
      * @param y Posición vertical de inicio en el PDF
896 899
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
897 900
      * @version 2016-08-05
@@ -958,7 +961,7 @@  discard block
 block discarded – undo
958 961
     /**
959 962
      * Método que agrega el detalle del documento
960 963
      * @param detalle Arreglo con el detalle del documento (tag Detalle del XML)
961
-     * @param x Posición horizontal de inicio en el PDF
964
+     * @param x integer horizontal de inicio en el PDF
962 965
      * @param y Posición vertical de inicio en el PDF
963 966
      * @author Pablo Reyes (https://github.com/pabloxp)
964 967
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
@@ -994,7 +997,7 @@  discard block
 block discarded – undo
994 997
      * Método que agrega el subtotal del DTE
995 998
      * @param detalle Arreglo con los detalles del documentos para poder
996 999
      * calcular subtotal
997
-     * @param x Posición horizontal de inicio en el PDF
1000
+     * @param x integer horizontal de inicio en el PDF
998 1001
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
999 1002
      * @version 2016-08-17
1000 1003
      */
@@ -1020,7 +1023,7 @@  discard block
 block discarded – undo
1020 1023
     /**
1021 1024
      * Método que agrega los descuentos y/o recargos globales del documento
1022 1025
      * @param descuentosRecargos Arreglo con los descuentos y/o recargos del documento (tag DscRcgGlobal del XML)
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
      */
@@ -1044,7 +1047,7 @@  discard block
 block discarded – undo
1044 1047
     /**
1045 1048
      * Método que agrega los pagos del documento
1046 1049
      * @param pagos Arreglo con los pagos del documento
1047
-     * @param x Posición horizontal de inicio en el PDF
1050
+     * @param x integer horizontal de inicio en el PDF
1048 1051
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
1049 1052
      * @version 2016-07-24
1050 1053
      */
@@ -1154,9 +1157,9 @@  discard block
 block discarded – undo
1154 1157
      *  - Se imprime en el tamaño mínimo: 2x5 cms
1155 1158
      *  - En el lado de abajo con margen izquierdo mínimo de 2 cms
1156 1159
      * @param timbre String con los datos del timbre
1157
-     * @param x Posición horizontal de inicio en el PDF
1158
-     * @param y Posición vertical de inicio en el PDF
1159
-     * @param w Ancho del timbre
1160
+     * @param x integer horizontal de inicio en el PDF
1161
+     * @param y integer vertical de inicio en el PDF
1162
+     * @param w integer del timbre
1160 1163
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
1161 1164
      * @version 2017-07-13
1162 1165
      */
@@ -1193,10 +1196,10 @@  discard block
 block discarded – undo
1193 1196
 
1194 1197
     /**
1195 1198
      * Método que agrega el acuse de rebido
1196
-     * @param x Posición horizontal de inicio en el PDF
1197
-     * @param y Posición vertical de inicio en el PDF
1198
-     * @param w Ancho del acuse de recibo
1199
-     * @param h Alto del acuse de recibo
1199
+     * @param x integer horizontal de inicio en el PDF
1200
+     * @param y integer vertical de inicio en el PDF
1201
+     * @param w integer del acuse de recibo
1202
+     * @param h integer del acuse de recibo
1200 1203
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
1201 1204
      * @version 2015-09-08
1202 1205
      */
@@ -1223,10 +1226,10 @@  discard block
 block discarded – undo
1223 1226
 
1224 1227
     /**
1225 1228
      * Método que agrega el acuse de rebido
1226
-     * @param x Posición horizontal de inicio en el PDF
1229
+     * @param x integer horizontal de inicio en el PDF
1227 1230
      * @param y Posición vertical de inicio en el PDF
1228
-     * @param w Ancho del acuse de recibo
1229
-     * @param h Alto del acuse de recibo
1231
+     * @param w integer del acuse de recibo
1232
+     * @param h integer del acuse de recibo
1230 1233
      * @author Pablo Reyes (https://github.com/pabloxp)
1231 1234
      * @version 2015-11-17
1232 1235
      */
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     {
170 170
         parent::__construct();
171 171
         $this->SetTitle('Documento Tributario Electrónico (DTE) de Chile by LibreDTE');
172
-        $this->papelContinuo = $papelContinuo === true ? 80 : $papelContinuo;
172
+        $this->papelContinuo = $papelContinuo===true ? 80 : $papelContinuo;
173 173
     }
174 174
 
175 175
     /**
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
         $this->setY(max($y));
305 305
         $this->Ln();
306 306
         $y = [];
307
-        $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null);
307
+        $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null);
308 308
         $y[] = $this->agregarReceptor($dte['Encabezado']);
309 309
         $this->setY(max($y));
310 310
         $this->agregarTraslado(
@@ -357,15 +357,15 @@  discard block
 block discarded – undo
357 357
             $dte['Encabezado']['IdDoc']['TipoDTE'],
358 358
             $dte['Encabezado']['IdDoc']['Folio'],
359 359
             $dte['Encabezado']['Emisor']['CmnaOrigen'],
360
-            $x_start, $y_start, $width-($x_start*4), 10,
361
-            [0,0,0]
360
+            $x_start, $y_start, $width-($x_start * 4), 10,
361
+            [0, 0, 0]
362 362
         );
363
-        $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, 40, 8, 9, [0,0,0]);
363
+        $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, 40, 8, 9, [0, 0, 0]);
364 364
         // datos del documento
365 365
         $this->SetY($y);
366 366
         $this->Ln();
367 367
         $this->setFont('', '', 8);
368
-        $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null, $x_start, $offset, false);
368
+        $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null, $x_start, $offset, false);
369 369
         $this->agregarReceptor($dte['Encabezado'], $x_start, $offset);
370 370
         $this->agregarTraslado(
371 371
             !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null,
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
         $this->AddPage('P', [$height ? $height : $this->papel_continuo_alto, $width]);
419 419
         $x = 1;
420 420
         $y = 5;
421
-        $this->SetXY($x,$y);
421
+        $this->SetXY($x, $y);
422 422
         // agregar datos del documento
423 423
         $this->setFont('', '', 8);
424 424
         $this->MultiTexto(!empty($dte['Encabezado']['Emisor']['RznSoc']) ? $dte['Encabezado']['Emisor']['RznSoc'] : $dte['Encabezado']['Emisor']['RznSocEmisor'], $x, null, '', $width-2);
@@ -504,13 +504,13 @@  discard block
 block discarded – undo
504 504
                 $this->logo['uri'],
505 505
                 $x,
506 506
                 $y,
507
-                !$this->logo['posicion']?$w_img:null, $this->logo['posicion']?($w_img/2):null,
507
+                !$this->logo['posicion'] ? $w_img : null, $this->logo['posicion'] ? ($w_img / 2) : null,
508 508
                 'PNG',
509
-                (isset($emisor['url'])?$emisor['url']:''),
509
+                (isset($emisor['url']) ? $emisor['url'] : ''),
510 510
                 'T'
511 511
             );
512 512
             if ($this->logo['posicion']) {
513
-                $this->SetY($this->y + ($w_img/2));
513
+                $this->SetY($this->y+($w_img / 2));
514 514
                 $w += 40;
515 515
             } else {
516 516
                 $x = $this->x+3;
@@ -521,13 +521,13 @@  discard block
 block discarded – undo
521 521
         }
522 522
         // agregar datos del emisor
523 523
         $this->setFont('', 'B', $font_size ? $font_size : 14);
524
-        $this->SetTextColorArray($color===null?[32, 92, 144]:$color);
524
+        $this->SetTextColorArray($color===null ? [32, 92, 144] : $color);
525 525
         $this->MultiTexto(!empty($emisor['RznSoc']) ? $emisor['RznSoc'] : $emisor['RznSocEmisor'], $x, $this->y+2, 'L', $w);
526 526
         $this->setFont('', 'B', $font_size ? $font_size : 9);
527
-        $this->SetTextColorArray([0,0,0]);
527
+        $this->SetTextColorArray([0, 0, 0]);
528 528
         $this->MultiTexto(!empty($emisor['GiroEmis']) ? $emisor['GiroEmis'] : $emisor['GiroEmisor'], $x, $this->y, 'L', $w);
529 529
         $ciudad = !empty($emisor['CiudadOrigen']) ? $emisor['CiudadOrigen'] : \sasco\LibreDTE\Chile::getCiudad($emisor['CmnaOrigen']);
530
-        $this->MultiTexto($emisor['DirOrigen'].', '.$emisor['CmnaOrigen'].($ciudad?(', '.$ciudad):''), $x, $this->y, 'L', $w);
530
+        $this->MultiTexto($emisor['DirOrigen'].', '.$emisor['CmnaOrigen'].($ciudad ? (', '.$ciudad) : ''), $x, $this->y, 'L', $w);
531 531
         if (!empty($emisor['Sucursal'])) {
532 532
             $this->MultiTexto('Sucursal: '.$emisor['Sucursal'], $x, $this->y, 'L', $w);
533 533
         }
@@ -571,12 +571,12 @@  discard block
 block discarded – undo
571 571
     private function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null)
572 572
     {
573 573
         if ($color===null) {
574
-            $color = $tipo ? ($tipo==52 ? [0,172,140] : [255,0,0]) : [0,0,0];
574
+            $color = $tipo ? ($tipo==52 ? [0, 172, 140] : [255, 0, 0]) : [0, 0, 0];
575 575
         }
576 576
         $this->SetTextColorArray($color);
577 577
         // colocar rut emisor, glosa documento y folio
578 578
         list($rut, $dv) = explode('-', $rut);
579
-        $this->setFont ('', 'B', $font_size ? $font_size : 15);
579
+        $this->setFont('', 'B', $font_size ? $font_size : 15);
580 580
         $this->MultiTexto('R.U.T.: '.$this->num($rut).'-'.$dv, $x, $y+4, 'C', $w);
581 581
         $this->setFont('', 'B', $font_size ? $font_size : 12);
582 582
         $this->MultiTexto($this->getTipo($tipo), $x, null, 'C', $w);
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         if ($tipo) {
590 590
             $this->Texto('S.I.I. - '.\sasco\LibreDTE\Sii::getDireccionRegional($sucursal_sii), $x, $this->getY()+4, 'C', $w);
591 591
         }
592
-        $this->SetTextColorArray([0,0,0]);
592
+        $this->SetTextColorArray([0, 0, 0]);
593 593
         $this->Ln();
594 594
         return $this->y;
595 595
     }
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
             $this->Texto('Señor(es)', $x);
721 721
             $this->Texto(':', $x+$offset);
722 722
             $this->setFont('', '', null);
723
-            $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10?105:0);
723
+            $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0);
724 724
         }
725 725
         if (!empty($receptor['GiroRecep'])) {
726 726
             $this->setFont('', 'B', null);
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
             $ciudad = !empty($receptor['CiudadRecep']) ? $receptor['CiudadRecep'] : (
738 738
                 !empty($receptor['CmnaRecep']) ? \sasco\LibreDTE\Chile::getCiudad($receptor['CmnaRecep']) : ''
739 739
             );
740
-            $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep'])?(', '.$receptor['CmnaRecep']):'').($ciudad?(', '.$ciudad):''), $x+$offset+2);
740
+            $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep']) ? (', '.$receptor['CmnaRecep']) : '').($ciudad ? (', '.$ciudad) : ''), $x+$offset+2);
741 741
         }
742 742
         if (!empty($receptor['Extranjero']['Nacionalidad'])) {
743 743
             $this->setFont('', 'B', null);
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
             $this->Texto('Cód. recep.', $x);
779 779
             $this->Texto(':', $x+$offset);
780 780
             $this->setFont('', '', null);
781
-            $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10?105:0);
781
+            $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0);
782 782
         }
783 783
         return $this->GetY();
784 784
     }
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
     {
867 867
         if (!isset($referencias[0]))
868 868
             $referencias = [$referencias];
869
-        foreach($referencias as $r) {
869
+        foreach ($referencias as $r) {
870 870
             $texto = $r['NroLinRef'].' - ';
871 871
             if (!empty($r['TpoDocRef'])) {
872 872
                 $texto .= $this->getTipo($r['TpoDocRef']).' ';
@@ -969,9 +969,9 @@  discard block
 block discarded – undo
969 969
         $this->SetY($this->getY()+1);
970 970
         $p1x = $x;
971 971
         $p1y = $this->y;
972
-        $p2x = $this->getPageWidth() - 2;
973
-        $p2y = $p1y;  // Use same y for a straight line
974
-        $style = array('width' => 0.2,'color' => array(0, 0, 0));
972
+        $p2x = $this->getPageWidth()-2;
973
+        $p2y = $p1y; // Use same y for a straight line
974
+        $style = array('width' => 0.2, 'color' => array(0, 0, 0));
975 975
         $this->Line($p1x, $p1y, $p2x, $p2y, $style);
976 976
         $this->Texto($this->detalle_cols['NmbItem']['title'], $x+1, $this->y, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']);
977 977
         $this->Texto($this->detalle_cols['PrcItem']['title'], $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']);
@@ -981,9 +981,9 @@  discard block
 block discarded – undo
981 981
         if (!isset($detalle[0]))
982 982
             $detalle = [$detalle];
983 983
         $this->SetY($this->getY()+2);
984
-        foreach($detalle as  &$d) {
984
+        foreach ($detalle as  &$d) {
985 985
             $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']);
986
-            $this->Texto(number_format($d['PrcItem'],0,',','.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']);
986
+            $this->Texto(number_format($d['PrcItem'], 0, ',', '.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']);
987 987
             $this->Texto($this->num($d['QtyItem']), $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']);
988 988
             $this->Texto($this->num($d['MontoItem']), $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']);
989 989
         }
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
         if (!isset($detalle[0])) {
1004 1004
             $detalle = [$detalle];
1005 1005
         }
1006
-        foreach($detalle as  &$d) {
1006
+        foreach ($detalle as  &$d) {
1007 1007
             if (!empty($d['MontoItem'])) {
1008 1008
                 $subtotal += $d['MontoItem'];
1009 1009
             }
@@ -1028,13 +1028,13 @@  discard block
 block discarded – undo
1028 1028
     {
1029 1029
         if (!isset($descuentosRecargos[0]))
1030 1030
             $descuentosRecargos = [$descuentosRecargos];
1031
-        foreach($descuentosRecargos as $dr) {
1031
+        foreach ($descuentosRecargos as $dr) {
1032 1032
             $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo';
1033 1033
             $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : $this->num($dr['ValorDR']);
1034 1034
             if ($this->papelContinuo) {
1035
-                $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):''), $x);
1035
+                $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : ''), $x);
1036 1036
             } else {
1037
-                $this->Texto($tipo.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):'').':', 77, null, 'R', 100);
1037
+                $this->Texto($tipo.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : '').':', 77, null, 'R', 100);
1038 1038
                 $this->Texto($valor, 177, null, 'R', 22);
1039 1039
             }
1040 1040
             $this->Ln();
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
             $pagos = [$pagos];
1055 1055
         $this->Texto('Pago(s) programado(s):', $x);
1056 1056
         $this->Ln();
1057
-        foreach($pagos as $p) {
1058
-            $this->Texto('  - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos'])?(' ('.$p['GlosaPagos'].')'):''), $x);
1057
+        foreach ($pagos as $p) {
1058
+            $this->Texto('  - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos']) ? (' ('.$p['GlosaPagos'].')') : ''), $x);
1059 1059
             $this->Ln();
1060 1060
         }
1061 1061
     }
@@ -1105,7 +1105,7 @@  discard block
 block discarded – undo
1105 1105
             if (!isset($ImptoReten[0])) {
1106 1106
                 $ImptoReten = [$ImptoReten];
1107 1107
             }
1108
-            foreach($ImptoReten as $i) {
1108
+            foreach ($ImptoReten as $i) {
1109 1109
                 $totales['ImptoReten_'.$i['TipoImp']] = $i['MontoImp'];
1110 1110
                 if (!empty($i['TasaImp'])) {
1111 1111
                     $glosas['ImptoReten_'.$i['TipoImp']] = \sasco\LibreDTE\Sii\ImpuestosAdicionales::getGlosa($i['TipoImp']).' ('.$i['TasaImp'].'%) $';
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
                 'vpadding' => 0,
1171 1171
                 'module_width' => 1, // width of a single module in points
1172 1172
                 'module_height' => 1, // height of a single module in points
1173
-                'fgcolor' => [0,0,0],
1173
+                'fgcolor' => [0, 0, 0],
1174 1174
                 'bgcolor' => false, // [255,255,255]
1175 1175
                 'position' => $this->papelContinuo ? 'C' : 'S',
1176 1176
             ];
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
      */
1203 1203
     private function agregarAcuseRecibo($x = 93, $y = 190, $w = 50, $h = 40)
1204 1204
     {
1205
-        $this->SetTextColorArray([0,0,0]);
1205
+        $this->SetTextColorArray([0, 0, 0]);
1206 1206
         $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]);
1207 1207
         $this->setFont('', 'B', 10);
1208 1208
         $this->Texto('Acuse de recibo', $x, $y+1, 'C', $w);
@@ -1232,9 +1232,9 @@  discard block
 block discarded – undo
1232 1232
      */
1233 1233
     private function agregarAcuseReciboContinuo($x = 3, $y = null, $w = 68, $h = 40)
1234 1234
     {
1235
-        $this->SetTextColorArray([0,0,0]);
1235
+        $this->SetTextColorArray([0, 0, 0]);
1236 1236
         $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]);
1237
-        $style = array('width' => 0.2,'color' => array(0, 0, 0));
1237
+        $style = array('width' => 0.2, 'color' => array(0, 0, 0));
1238 1238
         $this->Line($x, $y+22, $w+3, $y+22, $style);
1239 1239
         //$this->setFont('', 'B', 10);
1240 1240
         //$this->Texto('Acuse de recibo', $x, $y+1, 'C', $w);
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
     private function agregarLeyendaDestino($tipo, $y = 254, $font_size = 10)
1263 1263
     {
1264 1264
         $this->setFont('', 'B', $font_size);
1265
-        $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $y, 'R');
1265
+        $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $y, 'R');
1266 1266
     }
1267 1267
 
1268 1268
     /**
@@ -1293,7 +1293,7 @@  discard block
 block discarded – undo
1293 1293
         $dias = ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'];
1294 1294
         $meses = ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'];
1295 1295
         $unixtime = strtotime($date);
1296
-        $fecha = date(($mostrar_dia?'\D\I\A ':'').'j \d\e \M\E\S \d\e\l Y', $unixtime);
1296
+        $fecha = date(($mostrar_dia ? '\D\I\A ' : '').'j \d\e \M\E\S \d\e\l Y', $unixtime);
1297 1297
         $dia = $dias[date('w', $unixtime)];
1298 1298
         $mes = $meses[date('n', $unixtime)-1];
1299 1299
         return str_replace(array('DIA', 'MES'), array($dia, $mes), $fecha);
Please login to merge, or discard this patch.
Braces   +86 added lines, -58 removed lines patch added patch discarded remove patch
@@ -311,15 +311,17 @@  discard block
 block discarded – undo
311 311
             !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null,
312 312
             !empty($dte['Encabezado']['Transporte']) ? $dte['Encabezado']['Transporte'] : null
313 313
         );
314
-        if (!empty($dte['Referencia']))
315
-            $this->agregarReferencia($dte['Referencia']);
314
+        if (!empty($dte['Referencia'])) {
315
+                    $this->agregarReferencia($dte['Referencia']);
316
+        }
316 317
         $this->agregarDetalle($dte['Detalle']);
317 318
         if (!empty($dte['DscRcgGlobal'])) {
318 319
             $this->agregarSubTotal($dte['Detalle']);
319 320
             $this->agregarDescuentosRecargos($dte['DscRcgGlobal']);
320 321
         }
321
-        if (!empty($dte['Encabezado']['IdDoc']['MntPagos']))
322
-            $this->agregarPagos($dte['Encabezado']['IdDoc']['MntPagos']);
322
+        if (!empty($dte['Encabezado']['IdDoc']['MntPagos'])) {
323
+                    $this->agregarPagos($dte['Encabezado']['IdDoc']['MntPagos']);
324
+        }
323 325
         $this->agregarTotales($dte['Encabezado']['Totales']);
324 326
         // agregar observaciones
325 327
         $this->agregarObservacion($dte['Encabezado']['IdDoc']);
@@ -533,10 +535,12 @@  discard block
 block discarded – undo
533 535
         }
534 536
         $contacto = [];
535 537
         if (!empty($emisor['Telefono'])) {
536
-            if (!is_array($emisor['Telefono']))
537
-                $emisor['Telefono'] = [$emisor['Telefono']];
538
-            foreach ($emisor['Telefono'] as $t)
539
-                $contacto[] = $t;
538
+            if (!is_array($emisor['Telefono'])) {
539
+                            $emisor['Telefono'] = [$emisor['Telefono']];
540
+            }
541
+            foreach ($emisor['Telefono'] as $t) {
542
+                            $contacto[] = $t;
543
+            }
540 544
         }
541 545
         if (!empty($emisor['CorreoEmisor'])) {
542 546
             $contacto[] = $emisor['CorreoEmisor'];
@@ -603,8 +607,9 @@  discard block
 block discarded – undo
603 607
      */
604 608
     private function getTipo($tipo)
605 609
     {
606
-        if (!is_numeric($tipo) and !isset($this->tipos[$tipo]))
607
-            return $tipo;
610
+        if (!is_numeric($tipo) and !isset($this->tipos[$tipo])) {
611
+                    return $tipo;
612
+        }
608 613
         return isset($this->tipos[$tipo]) ? strtoupper($this->tipos[$tipo]) : 'Documento '.$tipo;
609 614
     }
610 615
 
@@ -754,10 +759,12 @@  discard block
 block discarded – undo
754 759
             $this->MultiTexto($receptor['Extranjero']['NumId'], $x+$offset+2);
755 760
         }
756 761
         $contacto = [];
757
-        if (!empty($receptor['Contacto']))
758
-            $contacto[] = $receptor['Contacto'];
759
-        if (!empty($receptor['CorreoRecep']))
760
-            $contacto[] = $receptor['CorreoRecep'];
762
+        if (!empty($receptor['Contacto'])) {
763
+                    $contacto[] = $receptor['Contacto'];
764
+        }
765
+        if (!empty($receptor['CorreoRecep'])) {
766
+                    $contacto[] = $receptor['CorreoRecep'];
767
+        }
761 768
         if (!empty($contacto)) {
762 769
             $this->setFont('', 'B', null);
763 770
             $this->Texto('Contacto', $x);
@@ -807,15 +814,19 @@  discard block
 block discarded – undo
807 814
             if (!empty($Transporte['DirDest']) and !empty($Transporte['CmnaDest'])) {
808 815
                 $transporte .= 'a '.$Transporte['DirDest'].', '.$Transporte['CmnaDest'];
809 816
             }
810
-            if (!empty($Transporte['RUTTrans']))
811
-                $transporte .= ' por '.$Transporte['RUTTrans'];
812
-            if (!empty($Transporte['Patente']))
813
-                $transporte .= ' en vehículo '.$Transporte['Patente'];
817
+            if (!empty($Transporte['RUTTrans'])) {
818
+                            $transporte .= ' por '.$Transporte['RUTTrans'];
819
+            }
820
+            if (!empty($Transporte['Patente'])) {
821
+                            $transporte .= ' en vehículo '.$Transporte['Patente'];
822
+            }
814 823
             if (isset($Transporte['Chofer']) and is_array($Transporte['Chofer'])) {
815
-                if (!empty($Transporte['Chofer']['NombreChofer']))
816
-                    $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer'];
817
-                if (!empty($Transporte['Chofer']['RUTChofer']))
818
-                    $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')';
824
+                if (!empty($Transporte['Chofer']['NombreChofer'])) {
825
+                                    $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer'];
826
+                }
827
+                if (!empty($Transporte['Chofer']['RUTChofer'])) {
828
+                                    $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')';
829
+                }
819 830
             }
820 831
             if ($transporte) {
821 832
                 $this->setFont('', 'B', null);
@@ -829,8 +840,9 @@  discard block
 block discarded – undo
829 840
         if (!empty($Transporte['Aduana']) and is_array($Transporte['Aduana'])) {
830 841
             $col = 0;
831 842
             foreach ($Transporte['Aduana'] as $tag => $codigo) {
832
-                if ($codigo===false)
833
-                    continue;
843
+                if ($codigo===false) {
844
+                                    continue;
845
+                }
834 846
                 $glosa = \sasco\LibreDTE\Sii\Aduana::getGlosa($tag);
835 847
                 $valor = \sasco\LibreDTE\Sii\Aduana::getValor($tag, $codigo);
836 848
                 if ($glosa!==false and $valor!==false) {
@@ -843,15 +855,18 @@  discard block
 block discarded – undo
843 855
                     $this->Texto(':', $x+$offset+$col);
844 856
                     $this->setFont('', '', null);
845 857
                     $this->Texto($valor, $x+$offset+2+$col);
846
-                    if ($tag=='TipoBultos')
847
-                        $col = abs($col-110);
848
-                    if ($col)
849
-                        $this->Ln();
858
+                    if ($tag=='TipoBultos') {
859
+                                            $col = abs($col-110);
860
+                    }
861
+                    if ($col) {
862
+                                            $this->Ln();
863
+                    }
850 864
                     $col = abs($col-110);
851 865
                 }
852 866
             }
853
-            if ($col)
854
-                $this->Ln();
867
+            if ($col) {
868
+                            $this->Ln();
869
+            }
855 870
         }
856 871
     }
857 872
 
@@ -864,8 +879,9 @@  discard block
 block discarded – undo
864 879
      */
865 880
     private function agregarReferencia($referencias, $x = 10, $offset = 22)
866 881
     {
867
-        if (!isset($referencias[0]))
868
-            $referencias = [$referencias];
882
+        if (!isset($referencias[0])) {
883
+                    $referencias = [$referencias];
884
+        }
869 885
         foreach($referencias as $r) {
870 886
             $texto = $r['NroLinRef'].' - ';
871 887
             if (!empty($r['TpoDocRef'])) {
@@ -898,8 +914,9 @@  discard block
 block discarded – undo
898 914
      */
899 915
     private function agregarDetalle($detalle, $x = 10)
900 916
     {
901
-        if (!isset($detalle[0]))
902
-            $detalle = [$detalle];
917
+        if (!isset($detalle[0])) {
918
+                    $detalle = [$detalle];
919
+        }
903 920
         $this->setFont('', '', $this->detalle_fuente);
904 921
         // titulos
905 922
         $titulos = [];
@@ -916,36 +933,42 @@  discard block
 block discarded – undo
916 933
                     $item['NmbItem'] .= !$this->item_detalle_posicion ? '<br/>' : ': ';
917 934
                     $item['NmbItem'] .= '<span style="font-size:0.7em">'.$item['DscItem'].'</span>';
918 935
                 }
919
-                if (!in_array($col, $titulos_keys) or ($dte_exento and $col=='IndExe'))
920
-                    unset($item[$col]);
936
+                if (!in_array($col, $titulos_keys) or ($dte_exento and $col=='IndExe')) {
937
+                                    unset($item[$col]);
938
+                }
921 939
             }
922 940
             // ajustes a IndExe
923 941
             if (isset($item['IndExe'])) {
924
-                if ($item['IndExe']==1)
925
-                    $item['IndExe'] = 'EX';
926
-                else if ($item['IndExe']==2)
927
-                    $item['IndExe'] = 'NF';
942
+                if ($item['IndExe']==1) {
943
+                                    $item['IndExe'] = 'EX';
944
+                } else if ($item['IndExe']==2) {
945
+                                    $item['IndExe'] = 'NF';
946
+                }
928 947
             }
929 948
             // agregar todas las columnas que se podrían imprimir en la tabla
930 949
             $item_default = [];
931
-            foreach ($this->detalle_cols as $key => $info)
932
-                $item_default[$key] = false;
950
+            foreach ($this->detalle_cols as $key => $info) {
951
+                            $item_default[$key] = false;
952
+            }
933 953
             $item = array_merge($item_default, $item);
934 954
             // si hay código de item se extrae su valor
935
-            if ($item['CdgItem'])
936
-                $item['CdgItem'] = $item['CdgItem']['VlrCodigo'];
955
+            if ($item['CdgItem']) {
956
+                            $item['CdgItem'] = $item['CdgItem']['VlrCodigo'];
957
+            }
937 958
             // dar formato a números
938 959
             foreach (['QtyItem', 'PrcItem', 'DescuentoMonto', 'RecargoMonto', 'MontoItem'] as $col) {
939
-                if ($item[$col])
940
-                    $item[$col] = $this->num($item[$col]);
960
+                if ($item[$col]) {
961
+                                    $item[$col] = $this->num($item[$col]);
962
+                }
941 963
             }
942 964
         }
943 965
         // opciones
944 966
         $options = ['align'=>[]];
945 967
         $i = 0;
946 968
         foreach ($this->detalle_cols as $info) {
947
-            if (isset($info['width']))
948
-                $options['width'][$i] = $info['width'];
969
+            if (isset($info['width'])) {
970
+                            $options['width'][$i] = $info['width'];
971
+            }
949 972
             $options['align'][$i] = $info['align'];
950 973
             $i++;
951 974
         }
@@ -978,8 +1001,9 @@  discard block
 block discarded – undo
978 1001
         $this->Texto($this->detalle_cols['QtyItem']['title'], $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']);
979 1002
         $this->Texto($this->detalle_cols['MontoItem']['title'], $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']);
980 1003
         $this->Line($p1x, $p1y+4, $p2x, $p2y+4, $style);
981
-        if (!isset($detalle[0]))
982
-            $detalle = [$detalle];
1004
+        if (!isset($detalle[0])) {
1005
+                    $detalle = [$detalle];
1006
+        }
983 1007
         $this->SetY($this->getY()+2);
984 1008
         foreach($detalle as  &$d) {
985 1009
             $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']);
@@ -1026,8 +1050,9 @@  discard block
 block discarded – undo
1026 1050
      */
1027 1051
     private function agregarDescuentosRecargos(array $descuentosRecargos, $x = 10)
1028 1052
     {
1029
-        if (!isset($descuentosRecargos[0]))
1030
-            $descuentosRecargos = [$descuentosRecargos];
1053
+        if (!isset($descuentosRecargos[0])) {
1054
+                    $descuentosRecargos = [$descuentosRecargos];
1055
+        }
1031 1056
         foreach($descuentosRecargos as $dr) {
1032 1057
             $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo';
1033 1058
             $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : $this->num($dr['ValorDR']);
@@ -1050,8 +1075,9 @@  discard block
 block discarded – undo
1050 1075
      */
1051 1076
     private function agregarPagos(array $pagos, $x = 10)
1052 1077
     {
1053
-        if (!isset($pagos[0]))
1054
-            $pagos = [$pagos];
1078
+        if (!isset($pagos[0])) {
1079
+                    $pagos = [$pagos];
1080
+        }
1055 1081
         $this->Texto('Pago(s) programado(s):', $x);
1056 1082
         $this->Ln();
1057 1083
         foreach($pagos as $p) {
@@ -1275,11 +1301,13 @@  discard block
 block discarded – undo
1275 1301
      */
1276 1302
     private function num($n)
1277 1303
     {
1278
-        if (!is_numeric($n))
1279
-            return $n;
1304
+        if (!is_numeric($n)) {
1305
+                    return $n;
1306
+        }
1280 1307
         $broken_number = explode('.', (string)$n);
1281
-        if (isset($broken_number[1]))
1282
-            return number_format($broken_number[0], 0, ',', '.').','.$broken_number[1];
1308
+        if (isset($broken_number[1])) {
1309
+                    return number_format($broken_number[0], 0, ',', '.').','.$broken_number[1];
1310
+        }
1283 1311
         return number_format($broken_number[0], 0, ',', '.');
1284 1312
     }
1285 1313
 
Please login to merge, or discard this patch.
lib/Sii.php 3 patches
Doc Comments   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -153,8 +153,8 @@  discard block
 block discarded – undo
153 153
 
154 154
     /**
155 155
      * Método para realizar una solicitud al servicio web del SII
156
-     * @param wsdl Nombre del WSDL que se usará
157
-     * @param request Nombre de la función que se ejecutará en el servicio web
156
+     * @param wsdl string del WSDL que se usará
157
+     * @param request string de la función que se ejecutará en el servicio web
158 158
      * @param args Argumentos que se pasarán al servicio web
159 159
      * @param retry Intentos que se realizarán como máximo para obtener respuesta
160 160
      * @return Objeto SimpleXMLElement con la espuesta del servicio web consultado
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
      * @param usuario RUN del usuario que envía el DTE
249 249
      * @param empresa RUT de la empresa emisora del DTE
250 250
      * @param dte Documento XML con el DTE que se desea enviar a SII
251
-     * @param token Token de autenticación automática ante el SII
251
+     * @param token string de autenticación automática ante el SII
252 252
      * @param retry Intentos que se realizarán como máximo para obtener respuesta
253 253
      * @return Respuesta XML desde SII o bien null si no se pudo obtener respuesta
254 254
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
      * \endcode
345 345
      *
346 346
      * @param idk IDK de la clave pública del SII. Si no se indica se tratará de determinar con el ambiente que se esté usando
347
-     * @return Contenido del certificado
347
+     * @return string|false del certificado
348 348
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
349 349
      * @version 2015-09-16
350 350
      */
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
     /**
370 370
      * Método que asigna el ambiente que se usará por defecto (si no está
371 371
      * asignado con la constante _LibreDTE_CERTIFICACION_)
372
-     * @param ambiente Ambiente a usar: Sii::PRODUCCION o Sii::CERTIFICACION
372
+     * @param ambiente integer a usar: Sii::PRODUCCION o Sii::CERTIFICACION
373 373
      * @warning No se está verificando SSL en ambiente de certificación
374 374
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
375 375
      * @version 2016-08-28
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 
405 405
     /**
406 406
      * Método que entrega la tasa de IVA vigente
407
-     * @return Tasa de IVA vigente
407
+     * @return integer de IVA vigente
408 408
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
409 409
      * @version 2015-09-03
410 410
      */
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
     /**
482 482
      * Método que entrega un arreglo con todas los documentos tributarios electrónicos
483 483
      * recepcionados en el SII
484
-     * @param Firma digital del certificado
484
+     * @param Firma FirmaElectronica del certificado
485 485
      * @param Ambiente de prueba
486 486
      * @param Rut empresa a consultar
487 487
      * @param Desde fecha a consultar. Formato d-m-Y
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
     /**
580 580
      * Método que entrega la dirección regional según la comuna que se esté
581 581
      * consultando
582
-     * @param comuna de la sucursal del emior o bien código de la sucursal del SII
582
+     * @param comuna Sii\PDF\Código|null la sucursal del emior o bien código de la sucursal del SII
583 583
      * @return Dirección regional del SII
584 584
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
585 585
      * @version 2016-06-03
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
             \sasco\LibreDTE\Log::write(Estado::REQUEST_ERROR_SOAP, Estado::get(Estado::REQUEST_ERROR_SOAP, $msg));
197 197
             return false;
198 198
         }
199
-        for ($i=0; $i<$retry; $i++) {
199
+        for ($i = 0; $i<$retry; $i++) {
200 200
             try {
201 201
                 if ($args) {
202 202
                     $body = call_user_func_array([$soap, $request], $args);
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
             curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
305 305
         }
306 306
         // enviar XML al SII
307
-        for ($i=0; $i<$retry; $i++) {
307
+        for ($i = 0; $i<$retry; $i++) {
308 308
             $response = curl_exec($curl);
309 309
             if ($response and $response!='Error 500')
310 310
                 break;
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
         if ($xml->STATUS!=0) {
331 331
             \sasco\LibreDTE\Log::write(
332 332
                 $xml->STATUS,
333
-                Estado::get($xml->STATUS).(isset($xml->DETAIL)?'. '.implode("\n", (array)$xml->DETAIL->ERROR):'')
333
+                Estado::get($xml->STATUS).(isset($xml->DETAIL) ? '. '.implode("\n", (array)$xml->DETAIL->ERROR) : '')
334 334
             );
335 335
         }
336 336
         return $xml;
@@ -462,12 +462,12 @@  discard block
 block discarded – undo
462 462
         $lines = explode("\n", $response);
463 463
         $n_lines = count($lines);
464 464
         $data = [];
465
-        for ($i=1; $i<$n_lines; $i++) {
465
+        for ($i = 1; $i<$n_lines; $i++) {
466 466
             $row = str_getcsv($lines[$i], ';', '');
467 467
             unset($lines[$i]);
468 468
             if (!isset($row[5]))
469 469
                 continue;
470
-            for ($j=0; $j<6; $j++)
470
+            for ($j = 0; $j<6; $j++)
471 471
                 $row[$j] = trim($row[$j]);
472 472
             $row[1] = utf8_decode($row[1]);
473 473
             $row[4] = strtolower($row[4]);
@@ -517,12 +517,12 @@  discard block
 block discarded – undo
517 517
         $curl = curl_init();
518 518
         $header = [
519 519
             'User-Agent: User-Agent: Mozilla/4.0 (compatible; PROG 1.0; LibreDTE)',
520
-            'Referer: https://' . $servidor . '.sii.cl',
521
-            'Cookie: TOKEN=' . $token . '; RUT_NS='.$rut_ns.'; DV_NS='.$dv_ns,
520
+            'Referer: https://'.$servidor.'.sii.cl',
521
+            'Cookie: TOKEN='.$token.'; RUT_NS='.$rut_ns.'; DV_NS='.$dv_ns,
522 522
             'Accept-Encoding' => 'gzip, deflate, sdch',
523 523
         ];
524
-        $desde = $desde === null ? date('01-m-Y', strtotime('-60 days')) : $desde; // Consulto últimos 2 meses
525
-        $hasta = $hasta === null ? date('d-m-Y') : $hasta; //Hasta fecha actual
524
+        $desde = $desde===null ? date('01-m-Y', strtotime('-60 days')) : $desde; // Consulto últimos 2 meses
525
+        $hasta = $hasta===null ? date('d-m-Y') : $hasta; //Hasta fecha actual
526 526
 
527 527
         $fields = [
528 528
             'DESDE' => urlencode($desde),
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
             'TIPO_CONSULTA' => '' // En blancopara que genere un CSV
532 532
         ];
533 533
 
534
-        $url = 'https://' . $servidor . '.sii.cl/cgi_dte/consultaDTE/wsDTEConsRecCont.sh';
534
+        $url = 'https://'.$servidor.'.sii.cl/cgi_dte/consultaDTE/wsDTEConsRecCont.sh';
535 535
         curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
536 536
         curl_setopt($curl, CURLOPT_URL, $url);
537 537
         curl_setopt($curl, CURLOPT_POST, 1);
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
         // se está en el ambiente de producción y no se verifica SSL se
545 545
         // generará un error de nivel E_USER_NOTICE
546 546
         if (!self::$verificar_ssl) {
547
-            if ($ambiente == self::PRODUCCION) {
547
+            if ($ambiente==self::PRODUCCION) {
548 548
                 $msg = Estado::get(Estado::ENVIO_SSL_SIN_VERIFICAR);
549 549
                 \sasco\LibreDTE\Log::write(Estado::ENVIO_SSL_SIN_VERIFICAR, $msg, LOG_WARNING);
550 550
             }
@@ -562,10 +562,10 @@  discard block
 block discarded – undo
562 562
         $lines = explode("\n", $response);
563 563
         $n_lines = count($lines);
564 564
         $data = [];
565
-        for ($i = 1; $i < $n_lines; $i++) {
565
+        for ($i = 1; $i<$n_lines; $i++) {
566 566
             $row = str_getcsv($lines[$i], ';', '');
567 567
             unset($lines[$i]);
568
-            for ($j = 0; $j < 6; $j++)
568
+            for ($j = 0; $j<6; $j++)
569 569
                 $row[$j] = trim($row[$j]);
570 570
             $row[1] = utf8_decode($row[1]);
571 571
             $row[2] = utf8_decode($row[2]);
Please login to merge, or discard this patch.
Braces   +50 added lines, -34 removed lines patch added patch discarded remove patch
@@ -137,8 +137,9 @@  discard block
 block discarded – undo
137 137
         // entregar WSDL local (modificados para ambiente de certificación)
138 138
         if ($ambiente==self::CERTIFICACION) {
139 139
             $wsdl = dirname(dirname(__FILE__)).'/wsdl/'.self::$config['servidor'][$ambiente].'/'.$servicio.'.jws';
140
-            if (is_readable($wsdl))
141
-                return $wsdl;
140
+            if (is_readable($wsdl)) {
141
+                            return $wsdl;
142
+            }
142 143
         }
143 144
         // entregar WSDL oficial desde SII
144 145
         $location = isset(self::$config['wsdl'][$servicio]) ? self::$config['wsdl'][$servicio] : self::$config['wsdl']['*'];
@@ -167,10 +168,12 @@  discard block
 block discarded – undo
167 168
             $retry = (int)$args;
168 169
             $args = null;
169 170
         }
170
-        if (!$retry)
171
-            $retry = self::$retry;
172
-        if ($args and !is_array($args))
173
-            $args = [$args];
171
+        if (!$retry) {
172
+                    $retry = self::$retry;
173
+        }
174
+        if ($args and !is_array($args)) {
175
+                    $args = [$args];
176
+        }
174 177
         if (!self::$verificar_ssl) {
175 178
             if (self::getAmbiente()==self::PRODUCCION) {
176 179
                 $msg = Estado::get(Estado::ENVIO_SSL_SIN_VERIFICAR);
@@ -278,8 +281,9 @@  discard block
 block discarded – undo
278 281
             ),
279 282
         ];
280 283
         // definir reintentos si no se pasaron
281
-        if (!$retry)
282
-            $retry = self::$retry;
284
+        if (!$retry) {
285
+                    $retry = self::$retry;
286
+        }
283 287
         // crear sesión curl con sus opciones
284 288
         $curl = curl_init();
285 289
         $header = [
@@ -306,16 +310,19 @@  discard block
 block discarded – undo
306 310
         // enviar XML al SII
307 311
         for ($i=0; $i<$retry; $i++) {
308 312
             $response = curl_exec($curl);
309
-            if ($response and $response!='Error 500')
310
-                break;
313
+            if ($response and $response!='Error 500') {
314
+                            break;
315
+            }
311 316
         }
312 317
         unlink($file);
313 318
         // verificar respuesta del envío y entregar error en caso que haya uno
314 319
         if (!$response or $response=='Error 500') {
315
-            if (!$response)
316
-                \sasco\LibreDTE\Log::write(Estado::ENVIO_ERROR_CURL, Estado::get(Estado::ENVIO_ERROR_CURL, curl_error($curl)));
317
-            if ($response=='Error 500')
318
-                \sasco\LibreDTE\Log::write(Estado::ENVIO_ERROR_500, Estado::get(Estado::ENVIO_ERROR_500));
320
+            if (!$response) {
321
+                            \sasco\LibreDTE\Log::write(Estado::ENVIO_ERROR_CURL, Estado::get(Estado::ENVIO_ERROR_CURL, curl_error($curl)));
322
+            }
323
+            if ($response=='Error 500') {
324
+                            \sasco\LibreDTE\Log::write(Estado::ENVIO_ERROR_500, Estado::get(Estado::ENVIO_ERROR_500));
325
+            }
319 326
             return false;
320 327
         }
321 328
         // cerrar sesión curl
@@ -353,8 +360,9 @@  discard block
 block discarded – undo
353 360
         // si se pasó un idk y existe el archivo asociado se entrega
354 361
         if ($idk) {
355 362
             $cert = dirname(dirname(__FILE__)).'/certs/'.$idk.'.cer';
356
-            if (is_readable($cert))
357
-                return file_get_contents($cert);
363
+            if (is_readable($cert)) {
364
+                            return file_get_contents($cert);
365
+            }
358 366
         }
359 367
         // buscar certificado y entregar si existe o =false si no
360 368
         $ambiente = self::getAmbiente();
@@ -394,10 +402,11 @@  discard block
 block discarded – undo
394 402
     public static function getAmbiente($ambiente = null)
395 403
     {
396 404
         if ($ambiente===null) {
397
-            if (defined('_LibreDTE_CERTIFICACION_'))
398
-                $ambiente = (int)_LibreDTE_CERTIFICACION_;
399
-            else
400
-                $ambiente = self::$ambiente;
405
+            if (defined('_LibreDTE_CERTIFICACION_')) {
406
+                            $ambiente = (int)_LibreDTE_CERTIFICACION_;
407
+            } else {
408
+                            $ambiente = self::$ambiente;
409
+            }
401 410
         }
402 411
         return $ambiente;
403 412
     }
@@ -423,8 +432,9 @@  discard block
 block discarded – undo
423 432
     {
424 433
         // solicitar token
425 434
         $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma);
426
-        if (!$token)
427
-            return false;
435
+        if (!$token) {
436
+                    return false;
437
+        }
428 438
         // definir ambiente y servidor
429 439
         $ambiente = self::getAmbiente($ambiente);
430 440
         $servidor = self::$config['servidor'][$ambiente];
@@ -453,8 +463,9 @@  discard block
 block discarded – undo
453 463
         }
454 464
         // realizar consulta curl
455 465
         $response = curl_exec($curl);
456
-        if (!$response)
457
-            return false;
466
+        if (!$response) {
467
+                    return false;
468
+        }
458 469
         // cerrar sesión curl
459 470
         curl_close($curl);
460 471
         // entregar datos del archivo CSV
@@ -465,10 +476,12 @@  discard block
 block discarded – undo
465 476
         for ($i=1; $i<$n_lines; $i++) {
466 477
             $row = str_getcsv($lines[$i], ';', '');
467 478
             unset($lines[$i]);
468
-            if (!isset($row[5]))
469
-                continue;
470
-            for ($j=0; $j<6; $j++)
471
-                $row[$j] = trim($row[$j]);
479
+            if (!isset($row[5])) {
480
+                            continue;
481
+            }
482
+            for ($j=0; $j<6; $j++) {
483
+                            $row[$j] = trim($row[$j]);
484
+            }
472 485
             $row[1] = utf8_decode($row[1]);
473 486
             $row[4] = strtolower($row[4]);
474 487
             $row[5] = strtolower($row[5]);
@@ -503,8 +516,9 @@  discard block
 block discarded – undo
503 516
     {
504 517
         // solicitar token
505 518
         $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma);
506
-        if (!$token)
507
-            return false;
519
+        if (!$token) {
520
+                    return false;
521
+        }
508 522
 
509 523
         // RUT_NS Y DV_NS
510 524
         list($rut_ns, $dv_ns) = explode('-', $rut);
@@ -553,8 +567,9 @@  discard block
 block discarded – undo
553 567
 
554 568
         // realizar consulta curl
555 569
         $response = curl_exec($curl);
556
-        if (!$response)
557
-            return false;
570
+        if (!$response) {
571
+                    return false;
572
+        }
558 573
         // cerrar sesión curl
559 574
         curl_close($curl);
560 575
         // entregar datos del archivo CSV
@@ -565,8 +580,9 @@  discard block
 block discarded – undo
565 580
         for ($i = 1; $i < $n_lines; $i++) {
566 581
             $row = str_getcsv($lines[$i], ';', '');
567 582
             unset($lines[$i]);
568
-            for ($j = 0; $j < 6; $j++)
569
-                $row[$j] = trim($row[$j]);
583
+            for ($j = 0; $j < 6; $j++) {
584
+                            $row[$j] = trim($row[$j]);
585
+            }
570 586
             $row[1] = utf8_decode($row[1]);
571 587
             $row[2] = utf8_decode($row[2]);
572 588
             $row[3] = utf8_decode($row[3]);
Please login to merge, or discard this patch.