Completed
Push — master ( 9675a7...aabd00 )
by Esteban De La Fuente
01:50
created
lib/Sii/Dte/PDF/Dte.php 3 patches
Doc Comments   +31 added lines, -28 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     /**
79 79
      * Método que asigna la ubicación del logo de la empresa
80 80
      * @param logo URI del logo (puede ser local o en una URL)
81
-     * @param posicion Posición respecto a datos del emisor (=0 izq, =1 arriba)
81
+     * @param posicion integer respecto a datos del emisor (=0 izq, =1 arriba)
82 82
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
83 83
      * @version 2016-08-04
84 84
      */
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
      * contínuo
223 223
      * @param dte Arreglo con los datos del XML (tag Documento)
224 224
      * @param timbre String XML con el tag TED del DTE
225
-     * @param width Ancho del papel contínuo en mm
225
+     * @param width boolean del papel contínuo en mm
226 226
      * @author Pablo Reyes (https://github.com/pabloxp)
227 227
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
228 228
      * @version 2017-10-24
@@ -384,10 +384,11 @@  discard block
 block discarded – undo
384 384
      *  - Dirección casa central del emisor
385 385
      *  - Dirección sucursales
386 386
      * @param emisor Arreglo con los datos del emisor (tag Emisor del XML)
387
-     * @param x Posición horizontal de inicio en el PDF
388
-     * @param y Posición vertical de inicio en el PDF
389
-     * @param w Ancho de la información del emisor
390
-     * @param w_img Ancho máximo de la imagen
387
+     * @param x integer horizontal de inicio en el PDF
388
+     * @param y integer vertical de inicio en el PDF
389
+     * @param w integer de la información del emisor
390
+     * @param w_img integer máximo de la imagen
391
+     * @param integer $font_size
391 392
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
392 393
      * @version 2018-06-15
393 394
      */
@@ -461,11 +462,13 @@  discard block
 block discarded – undo
461 462
      * @param rut RUT del emisor
462 463
      * @param tipo Código o glosa del tipo de documento
463 464
      * @param sucursal_sii Código o glosa de la sucursal del SII del Emisor
464
-     * @param x Posición horizontal de inicio en el PDF
465
-     * @param y Posición vertical de inicio en el PDF
466
-     * @param w Ancho de la información del emisor
465
+     * @param x integer horizontal de inicio en el PDF
466
+     * @param y integer vertical de inicio en el PDF
467
+     * @param w integer de la información del emisor
468
+     * @param integer $font_size
467 469
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
468 470
      * @version 2016-12-02
471
+     * @return integer
469 472
      */
470 473
     protected function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null)
471 474
     {
@@ -497,7 +500,7 @@  discard block
 block discarded – undo
497 500
      * Método que agrega los datos de la emisión del DTE que no son los dato del
498 501
      * receptor
499 502
      * @param IdDoc Información general del documento
500
-     * @param x Posición horizontal de inicio en el PDF
503
+     * @param x integer horizontal de inicio en el PDF
501 504
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
502 505
      * @version 2017-06-15
503 506
      */
@@ -585,7 +588,7 @@  discard block
 block discarded – undo
585 588
     /**
586 589
      * Método que agrega los datos del receptor
587 590
      * @param receptor Arreglo con los datos del receptor (tag Receptor del XML)
588
-     * @param x Posición horizontal de inicio en el PDF
591
+     * @param x integer horizontal de inicio en el PDF
589 592
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
590 593
      * @version 2019-02-13
591 594
      */
@@ -672,7 +675,7 @@  discard block
 block discarded – undo
672 675
      * Método que agrega los datos del traslado
673 676
      * @param IndTraslado
674 677
      * @param Transporte
675
-     * @param x Posición horizontal de inicio en el PDF
678
+     * @param x integer horizontal de inicio en el PDF
676 679
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
677 680
      * @version 2016-08-03
678 681
      */
@@ -743,7 +746,7 @@  discard block
 block discarded – undo
743 746
     /**
744 747
      * Método que agrega las referencias del documento
745 748
      * @param referencias Arreglo con las referencias del documento (tag Referencia del XML)
746
-     * @param x Posición horizontal de inicio en el PDF
749
+     * @param x integer horizontal de inicio en el PDF
747 750
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
748 751
      * @version 2017-09-25
749 752
      */
@@ -780,7 +783,7 @@  discard block
 block discarded – undo
780 783
     /**
781 784
      * Método que agrega el detalle del documento
782 785
      * @param detalle Arreglo con el detalle del documento (tag Detalle del XML)
783
-     * @param x Posición horizontal de inicio en el PDF
786
+     * @param x integer horizontal de inicio en el PDF
784 787
      * @param y Posición vertical de inicio en el PDF
785 788
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
786 789
      * @version 2019-07-09
@@ -880,7 +883,7 @@  discard block
 block discarded – undo
880 883
     /**
881 884
      * Método que agrega el detalle del documento
882 885
      * @param detalle Arreglo con el detalle del documento (tag Detalle del XML)
883
-     * @param x Posición horizontal de inicio en el PDF
886
+     * @param x integer horizontal de inicio en el PDF
884 887
      * @param y Posición vertical de inicio en el PDF
885 888
      * @author Pablo Reyes (https://github.com/pabloxp)
886 889
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
@@ -916,7 +919,7 @@  discard block
 block discarded – undo
916 919
      * Método que agrega el subtotal del DTE
917 920
      * @param detalle Arreglo con los detalles del documentos para poder
918 921
      * calcular subtotal
919
-     * @param x Posición horizontal de inicio en el PDF
922
+     * @param x integer horizontal de inicio en el PDF
920 923
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
921 924
      * @version 2016-08-17
922 925
      */
@@ -942,7 +945,7 @@  discard block
 block discarded – undo
942 945
     /**
943 946
      * Método que agrega los descuentos y/o recargos globales del documento
944 947
      * @param descuentosRecargos Arreglo con los descuentos y/o recargos del documento (tag DscRcgGlobal del XML)
945
-     * @param x Posición horizontal de inicio en el PDF
948
+     * @param x integer horizontal de inicio en el PDF
946 949
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
947 950
      * @version 2018-05-29
948 951
      */
@@ -970,7 +973,7 @@  discard block
 block discarded – undo
970 973
     /**
971 974
      * Método que agrega los pagos del documento
972 975
      * @param pagos Arreglo con los pagos del documento
973
-     * @param x Posición horizontal de inicio en el PDF
976
+     * @param x integer horizontal de inicio en el PDF
974 977
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
975 978
      * @version 2016-07-24
976 979
      */
@@ -1128,9 +1131,9 @@  discard block
 block discarded – undo
1128 1131
      *  - Se imprime en el tamaño mínimo: 2x5 cms
1129 1132
      *  - En el lado de abajo con margen izquierdo mínimo de 2 cms
1130 1133
      * @param timbre String con los datos del timbre
1131
-     * @param x Posición horizontal de inicio en el PDF
1132
-     * @param y Posición vertical de inicio en el PDF
1133
-     * @param w Ancho del timbre
1134
+     * @param x integer horizontal de inicio en el PDF
1135
+     * @param y integer vertical de inicio en el PDF
1136
+     * @param w integer del timbre
1134 1137
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
1135 1138
      * @version 2018-04-12
1136 1139
      */
@@ -1168,10 +1171,10 @@  discard block
 block discarded – undo
1168 1171
 
1169 1172
     /**
1170 1173
      * Método que agrega el acuse de rebido
1171
-     * @param x Posición horizontal de inicio en el PDF
1172
-     * @param y Posición vertical de inicio en el PDF
1173
-     * @param w Ancho del acuse de recibo
1174
-     * @param h Alto del acuse de recibo
1174
+     * @param x integer horizontal de inicio en el PDF
1175
+     * @param y integer vertical de inicio en el PDF
1176
+     * @param w integer del acuse de recibo
1177
+     * @param h integer del acuse de recibo
1175 1178
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
1176 1179
      * @version 2018-04-13
1177 1180
      */
@@ -1199,10 +1202,10 @@  discard block
 block discarded – undo
1199 1202
 
1200 1203
     /**
1201 1204
      * Método que agrega el acuse de rebido
1202
-     * @param x Posición horizontal de inicio en el PDF
1205
+     * @param x integer horizontal de inicio en el PDF
1203 1206
      * @param y Posición vertical de inicio en el PDF
1204
-     * @param w Ancho del acuse de recibo
1205
-     * @param h Alto del acuse de recibo
1207
+     * @param w integer del acuse de recibo
1208
+     * @param h integer del acuse de recibo
1206 1209
      * @author Pablo Reyes (https://github.com/pabloxp)
1207 1210
      * @version 2015-11-17
1208 1211
      */
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
     {
73 73
         parent::__construct();
74 74
         $this->SetTitle('Documento Tributario Electrónico (DTE) de Chile by LibreDTE');
75
-        $this->papelContinuo = $papelContinuo === true ? 80 : $papelContinuo;
75
+        $this->papelContinuo = $papelContinuo===true ? 80 : $papelContinuo;
76 76
     }
77 77
 
78 78
     /**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         $this->setY(max($y));
183 183
         $this->Ln();
184 184
         $y = [];
185
-        $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null);
185
+        $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null);
186 186
         $y[] = $this->agregarReceptor($dte['Encabezado']);
187 187
         $this->setY(max($y));
188 188
         $this->agregarTraslado(
@@ -242,15 +242,15 @@  discard block
 block discarded – undo
242 242
             $dte['Encabezado']['IdDoc']['TipoDTE'],
243 243
             $dte['Encabezado']['IdDoc']['Folio'],
244 244
             $dte['Encabezado']['Emisor']['CmnaOrigen'],
245
-            $x_start, $y_start, $width-($x_start*4), 10,
246
-            [0,0,0]
245
+            $x_start, $y_start, $width-($x_start * 4), 10,
246
+            [0, 0, 0]
247 247
         );
248
-        $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, $width-($x_start*45), 8, 9, [0,0,0]);
248
+        $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, $width-($x_start * 45), 8, 9, [0, 0, 0]);
249 249
         // datos del documento
250 250
         $this->SetY($y);
251 251
         $this->Ln();
252 252
         $this->setFont('', '', 8);
253
-        $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null, $x_start, $offset, false);
253
+        $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null, $x_start, $offset, false);
254 254
         $this->agregarReceptor($dte['Encabezado'], $x_start, $offset);
255 255
         $this->agregarTraslado(
256 256
             !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null,
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
         $this->AddPage('P', [$height ? $height : $this->papel_continuo_alto, $width]);
304 304
         $x = 1;
305 305
         $y = 5;
306
-        $this->SetXY($x,$y);
306
+        $this->SetXY($x, $y);
307 307
         // agregar datos del documento
308 308
         $this->setFont('', '', 8);
309 309
         $this->MultiTexto(!empty($dte['Encabezado']['Emisor']['RznSoc']) ? $dte['Encabezado']['Emisor']['RznSoc'] : $dte['Encabezado']['Emisor']['RznSocEmisor'], $x, null, '', $width-2);
@@ -399,13 +399,13 @@  discard block
 block discarded – undo
399 399
                 $this->logo['uri'],
400 400
                 $x,
401 401
                 $y,
402
-                !$this->logo['posicion']?$w_img:null, $this->logo['posicion']?($w_img/2):null,
402
+                !$this->logo['posicion'] ? $w_img : null, $this->logo['posicion'] ? ($w_img / 2) : null,
403 403
                 'PNG',
404
-                (isset($emisor['url'])?$emisor['url']:''),
404
+                (isset($emisor['url']) ? $emisor['url'] : ''),
405 405
                 'T'
406 406
             );
407 407
             if ($this->logo['posicion']) {
408
-                $this->SetY($this->y + ($w_img/2));
408
+                $this->SetY($this->y+($w_img / 2));
409 409
                 $w += 40;
410 410
             } else {
411 411
                 $x = $this->x+3;
@@ -416,14 +416,14 @@  discard block
 block discarded – undo
416 416
         }
417 417
         // agregar datos del emisor
418 418
         $this->setFont('', 'B', $font_size ? $font_size : 14);
419
-        $this->SetTextColorArray($color===null?[32, 92, 144]:$color);
419
+        $this->SetTextColorArray($color===null ? [32, 92, 144] : $color);
420 420
         $this->MultiTexto(!empty($emisor['RznSoc']) ? $emisor['RznSoc'] : $emisor['RznSocEmisor'], $x, $this->y+2, 'L', $w);
421 421
         $this->setFont('', 'B', $font_size ? $font_size : 9);
422
-        $this->SetTextColorArray([0,0,0]);
422
+        $this->SetTextColorArray([0, 0, 0]);
423 423
         $this->MultiTexto(!empty($emisor['GiroEmis']) ? $emisor['GiroEmis'] : $emisor['GiroEmisor'], $x, $this->y, 'L', $w);
424 424
         $comuna = !empty($emisor['CmnaOrigen']) ? $emisor['CmnaOrigen'] : null;
425 425
         $ciudad = !empty($emisor['CiudadOrigen']) ? $emisor['CiudadOrigen'] : \sasco\LibreDTE\Chile::getCiudad($comuna);
426
-        $this->MultiTexto($emisor['DirOrigen'].($comuna?(', '.$comuna):'').($ciudad?(', '.$ciudad):''), $x, $this->y, 'L', $w);
426
+        $this->MultiTexto($emisor['DirOrigen'].($comuna ? (', '.$comuna) : '').($ciudad ? (', '.$ciudad) : ''), $x, $this->y, 'L', $w);
427 427
         if (!empty($emisor['Sucursal'])) {
428 428
             $this->MultiTexto('Sucursal: '.$emisor['Sucursal'], $x, $this->y, 'L', $w);
429 429
         }
@@ -470,12 +470,12 @@  discard block
 block discarded – undo
470 470
     protected function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null)
471 471
     {
472 472
         if ($color===null) {
473
-            $color = $tipo ? ($tipo==52 ? [0,172,140] : [255,0,0]) : [0,0,0];
473
+            $color = $tipo ? ($tipo==52 ? [0, 172, 140] : [255, 0, 0]) : [0, 0, 0];
474 474
         }
475 475
         $this->SetTextColorArray($color);
476 476
         // colocar rut emisor, glosa documento y folio
477 477
         list($rut, $dv) = explode('-', $rut);
478
-        $this->setFont ('', 'B', $font_size ? $font_size : 15);
478
+        $this->setFont('', 'B', $font_size ? $font_size : 15);
479 479
         $this->MultiTexto('R.U.T.: '.$this->num($rut).'-'.$dv, $x, $y+4, 'C', $w);
480 480
         $this->setFont('', 'B', $font_size ? $font_size : 12);
481 481
         $this->MultiTexto($this->getTipo($tipo), $x, null, 'C', $w);
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
         if ($tipo) {
489 489
             $this->Texto('S.I.I. - '.\sasco\LibreDTE\Sii::getDireccionRegional($sucursal_sii), $x, $this->getY()+4, 'C', $w);
490 490
         }
491
-        $this->SetTextColorArray([0,0,0]);
491
+        $this->SetTextColorArray([0, 0, 0]);
492 492
         $this->Ln();
493 493
         return $this->y;
494 494
     }
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
             $this->Texto(in_array($this->dte, [39, 41]) ? 'Nombre' : 'Razón social', $x);
606 606
             $this->Texto(':', $x+$offset);
607 607
             $this->setFont('', '', null);
608
-            $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10?105:0);
608
+            $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0);
609 609
         }
610 610
         if (!empty($receptor['GiroRecep'])) {
611 611
             $this->setFont('', 'B', null);
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
             $ciudad = !empty($receptor['CiudadRecep']) ? $receptor['CiudadRecep'] : (
623 623
                 !empty($receptor['CmnaRecep']) ? \sasco\LibreDTE\Chile::getCiudad($receptor['CmnaRecep']) : ''
624 624
             );
625
-            $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep'])?(', '.$receptor['CmnaRecep']):'').($ciudad?(', '.$ciudad):''), $x+$offset+2);
625
+            $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep']) ? (', '.$receptor['CmnaRecep']) : '').($ciudad ? (', '.$ciudad) : ''), $x+$offset+2);
626 626
         }
627 627
         if (!empty($receptor['Extranjero']['Nacionalidad'])) {
628 628
             $this->setFont('', 'B', null);
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
             $this->Texto('Cód. recep.', $x);
664 664
             $this->Texto(':', $x+$offset);
665 665
             $this->setFont('', '', null);
666
-            $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10?105:0);
666
+            $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0);
667 667
         }
668 668
         return $this->GetY();
669 669
     }
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
     {
752 752
         if (!isset($referencias[0]))
753 753
             $referencias = [$referencias];
754
-        foreach($referencias as $r) {
754
+        foreach ($referencias as $r) {
755 755
             $texto = $r['NroLinRef'].' - ';
756 756
             if (!empty($r['TpoDocRef'])) {
757 757
                 $texto .= $this->getTipo($r['TpoDocRef']).' ';
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
             // quitar columnas
804 804
             foreach ($item as $col => $valor) {
805 805
                 if ($col=='DscItem' and !empty($item['DscItem'])) {
806
-                    $item['NmbItem'] .= !$this->item_detalle_posicion ? ($html?'<br/>':"\n") : ': ';
806
+                    $item['NmbItem'] .= !$this->item_detalle_posicion ? ($html ? '<br/>' : "\n") : ': ';
807 807
                     if ($html) {
808 808
                         $item['NmbItem'] .= '<span style="font-size:0.7em">'.$item['DscItem'].'</span>';
809 809
                     } else {
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
             }
852 852
             $item = array_merge($item_default, $item);
853 853
             // si hay código de item se extrae su valor
854
-            if (!empty($item['CdgItem']['VlrCodigo'])){
854
+            if (!empty($item['CdgItem']['VlrCodigo'])) {
855 855
                 $item['CdgItem'] = $item['CdgItem']['VlrCodigo'];
856 856
             }
857 857
             // dar formato a números
@@ -891,9 +891,9 @@  discard block
 block discarded – undo
891 891
         $this->SetY($this->getY()+1);
892 892
         $p1x = $x;
893 893
         $p1y = $this->y;
894
-        $p2x = $this->getPageWidth() - 2;
895
-        $p2y = $p1y;  // Use same y for a straight line
896
-        $style = array('width' => 0.2,'color' => array(0, 0, 0));
894
+        $p2x = $this->getPageWidth()-2;
895
+        $p2y = $p1y; // Use same y for a straight line
896
+        $style = array('width' => 0.2, 'color' => array(0, 0, 0));
897 897
         $this->Line($p1x, $p1y, $p2x, $p2y, $style);
898 898
         $this->Texto($this->detalle_cols['NmbItem']['title'], $x+1, $this->y, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']);
899 899
         $this->Texto($this->detalle_cols['PrcItem']['title'], $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']);
@@ -903,9 +903,9 @@  discard block
 block discarded – undo
903 903
         if (!isset($detalle[0]))
904 904
             $detalle = [$detalle];
905 905
         $this->SetY($this->getY()+2);
906
-        foreach($detalle as  &$d) {
906
+        foreach ($detalle as  &$d) {
907 907
             $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']);
908
-            $this->Texto(number_format($d['PrcItem'],0,',','.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']);
908
+            $this->Texto(number_format($d['PrcItem'], 0, ',', '.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']);
909 909
             $this->Texto($this->num($d['QtyItem']), $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']);
910 910
             $this->Texto($this->num($d['MontoItem']), $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']);
911 911
         }
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
         if (!isset($detalle[0])) {
926 926
             $detalle = [$detalle];
927 927
         }
928
-        foreach($detalle as  &$d) {
928
+        foreach ($detalle as  &$d) {
929 929
             if (!empty($d['MontoItem'])) {
930 930
                 $subtotal += $d['MontoItem'];
931 931
             }
@@ -951,16 +951,16 @@  discard block
 block discarded – undo
951 951
         if (!isset($descuentosRecargos[0])) {
952 952
             $descuentosRecargos = [$descuentosRecargos];
953 953
         }
954
-        foreach($descuentosRecargos as $dr) {
954
+        foreach ($descuentosRecargos as $dr) {
955 955
             $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo';
956 956
             if (!empty($dr['IndExeDR'])) {
957 957
                 $tipo .= ' EX';
958 958
             }
959 959
             $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : $this->num($dr['ValorDR']);
960 960
             if ($this->papelContinuo) {
961
-                $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):''), $x);
961
+                $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : ''), $x);
962 962
             } else {
963
-                $this->Texto($tipo.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):'').':', 77, null, 'R', 100);
963
+                $this->Texto($tipo.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : '').':', 77, null, 'R', 100);
964 964
                 $this->Texto($valor, 177, null, 'R', 22);
965 965
             }
966 966
             $this->Ln();
@@ -980,8 +980,8 @@  discard block
 block discarded – undo
980 980
             $pagos = [$pagos];
981 981
         $this->Texto('Pago(s) programado(s):', $x);
982 982
         $this->Ln();
983
-        foreach($pagos as $p) {
984
-            $this->Texto('  - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos'])?(' ('.$p['GlosaPagos'].')'):''), $x);
983
+        foreach ($pagos as $p) {
984
+            $this->Texto('  - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos']) ? (' ('.$p['GlosaPagos'].')') : ''), $x);
985 985
             $this->Ln();
986 986
         }
987 987
     }
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
             if (!isset($ImptoReten[0])) {
1033 1033
                 $ImptoReten = [$ImptoReten];
1034 1034
             }
1035
-            foreach($ImptoReten as $i) {
1035
+            foreach ($ImptoReten as $i) {
1036 1036
                 $totales['ImptoReten_'.$i['TipoImp']] = $i['MontoImp'];
1037 1037
                 if (!empty($i['TasaImp'])) {
1038 1038
                     $glosas['ImptoReten_'.$i['TipoImp']] = \sasco\LibreDTE\Sii\ImpuestosAdicionales::getGlosa($i['TipoImp']).' ('.$i['TasaImp'].'%) $';
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
                 'vpadding' => 0,
1146 1146
                 'module_width' => 1, // width of a single module in points
1147 1147
                 'module_height' => 1, // height of a single module in points
1148
-                'fgcolor' => [0,0,0],
1148
+                'fgcolor' => [0, 0, 0],
1149 1149
                 'bgcolor' => false, // [255,255,255]
1150 1150
                 'position' => $this->papelContinuo ? 'C' : 'S',
1151 1151
             ];
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
     protected function agregarAcuseRecibo($x = 83, $y = 190, $w = 60, $h = 40)
1179 1179
     {
1180 1180
         $y = (!$this->papelContinuo and !$this->timbre_pie) ? $this->x_fin_datos : $y;
1181
-        $this->SetTextColorArray([0,0,0]);
1181
+        $this->SetTextColorArray([0, 0, 0]);
1182 1182
         $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]);
1183 1183
         $this->setFont('', 'B', 10);
1184 1184
         $this->Texto('Acuse de recibo', $x, $y+1, 'C', $w);
@@ -1208,9 +1208,9 @@  discard block
 block discarded – undo
1208 1208
      */
1209 1209
     protected function agregarAcuseReciboContinuo($x = 3, $y = null, $w = 68, $h = 40)
1210 1210
     {
1211
-        $this->SetTextColorArray([0,0,0]);
1211
+        $this->SetTextColorArray([0, 0, 0]);
1212 1212
         $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]);
1213
-        $style = array('width' => 0.2,'color' => array(0, 0, 0));
1213
+        $style = array('width' => 0.2, 'color' => array(0, 0, 0));
1214 1214
         $this->Line($x, $y+22, $w+3, $y+22, $style);
1215 1215
         //$this->setFont('', 'B', 10);
1216 1216
         //$this->Texto('Acuse de recibo', $x, $y+1, 'C', $w);
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
         $y = (!$this->papelContinuo and !$this->timbre_pie and $this->x_fin_datos<=$y) ? $this->x_fin_datos : $y;
1241 1241
         $y += 48;
1242 1242
         $this->setFont('', 'B', $font_size);
1243
-        $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $y, 'R');
1243
+        $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $y, 'R');
1244 1244
     }
1245 1245
 
1246 1246
     /**
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
     protected function agregarLeyendaDestinoContinuo($tipo)
1252 1252
     {
1253 1253
         $this->setFont('', 'B', 8);
1254
-        $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $this->y+6, 'R');
1254
+        $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $this->y+6, 'R');
1255 1255
     }
1256 1256
 
1257 1257
 }
Please login to merge, or discard this patch.
Braces   +45 added lines, -30 removed lines patch added patch discarded remove patch
@@ -432,10 +432,12 @@  discard block
 block discarded – undo
432 432
         }
433 433
         $contacto = [];
434 434
         if (!empty($emisor['Telefono'])) {
435
-            if (!is_array($emisor['Telefono']))
436
-                $emisor['Telefono'] = [$emisor['Telefono']];
437
-            foreach ($emisor['Telefono'] as $t)
438
-                $contacto[] = $t;
435
+            if (!is_array($emisor['Telefono'])) {
436
+                            $emisor['Telefono'] = [$emisor['Telefono']];
437
+            }
438
+            foreach ($emisor['Telefono'] as $t) {
439
+                            $contacto[] = $t;
440
+            }
439 441
         }
440 442
         if (!empty($emisor['CorreoEmisor'])) {
441 443
             $contacto[] = $emisor['CorreoEmisor'];
@@ -639,10 +641,12 @@  discard block
 block discarded – undo
639 641
             $this->MultiTexto($receptor['Extranjero']['NumId'], $x+$offset+2);
640 642
         }
641 643
         $contacto = [];
642
-        if (!empty($receptor['Contacto']))
643
-            $contacto[] = $receptor['Contacto'];
644
-        if (!empty($receptor['CorreoRecep']))
645
-            $contacto[] = $receptor['CorreoRecep'];
644
+        if (!empty($receptor['Contacto'])) {
645
+                    $contacto[] = $receptor['Contacto'];
646
+        }
647
+        if (!empty($receptor['CorreoRecep'])) {
648
+                    $contacto[] = $receptor['CorreoRecep'];
649
+        }
646 650
         if (!empty($contacto)) {
647 651
             $this->setFont('', 'B', null);
648 652
             $this->Texto('Contacto', $x);
@@ -692,15 +696,19 @@  discard block
 block discarded – undo
692 696
             if (!empty($Transporte['DirDest']) and !empty($Transporte['CmnaDest'])) {
693 697
                 $transporte .= 'a '.$Transporte['DirDest'].', '.$Transporte['CmnaDest'];
694 698
             }
695
-            if (!empty($Transporte['RUTTrans']))
696
-                $transporte .= ' por '.$Transporte['RUTTrans'];
697
-            if (!empty($Transporte['Patente']))
698
-                $transporte .= ' en vehículo '.$Transporte['Patente'];
699
+            if (!empty($Transporte['RUTTrans'])) {
700
+                            $transporte .= ' por '.$Transporte['RUTTrans'];
701
+            }
702
+            if (!empty($Transporte['Patente'])) {
703
+                            $transporte .= ' en vehículo '.$Transporte['Patente'];
704
+            }
699 705
             if (isset($Transporte['Chofer']) and is_array($Transporte['Chofer'])) {
700
-                if (!empty($Transporte['Chofer']['NombreChofer']))
701
-                    $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer'];
702
-                if (!empty($Transporte['Chofer']['RUTChofer']))
703
-                    $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')';
706
+                if (!empty($Transporte['Chofer']['NombreChofer'])) {
707
+                                    $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer'];
708
+                }
709
+                if (!empty($Transporte['Chofer']['RUTChofer'])) {
710
+                                    $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')';
711
+                }
704 712
             }
705 713
             if ($transporte) {
706 714
                 $this->setFont('', 'B', null);
@@ -714,8 +722,9 @@  discard block
 block discarded – undo
714 722
         if (!empty($Transporte['Aduana']) and is_array($Transporte['Aduana'])) {
715 723
             $col = 0;
716 724
             foreach ($Transporte['Aduana'] as $tag => $codigo) {
717
-                if ($codigo===false)
718
-                    continue;
725
+                if ($codigo===false) {
726
+                                    continue;
727
+                }
719 728
                 $glosa = \sasco\LibreDTE\Sii\Aduana::getGlosa($tag);
720 729
                 $valor = \sasco\LibreDTE\Sii\Aduana::getValor($tag, $codigo);
721 730
                 if ($glosa!==false and $valor!==false) {
@@ -728,15 +737,18 @@  discard block
 block discarded – undo
728 737
                     $this->Texto(':', $x+$offset+$col);
729 738
                     $this->setFont('', '', null);
730 739
                     $this->Texto($valor, $x+$offset+2+$col);
731
-                    if ($tag=='TipoBultos')
732
-                        $col = abs($col-110);
733
-                    if ($col)
734
-                        $this->Ln();
740
+                    if ($tag=='TipoBultos') {
741
+                                            $col = abs($col-110);
742
+                    }
743
+                    if ($col) {
744
+                                            $this->Ln();
745
+                    }
735 746
                     $col = abs($col-110);
736 747
                 }
737 748
             }
738
-            if ($col)
739
-                $this->Ln();
749
+            if ($col) {
750
+                            $this->Ln();
751
+            }
740 752
         }
741 753
     }
742 754
 
@@ -749,8 +761,9 @@  discard block
 block discarded – undo
749 761
      */
750 762
     protected function agregarReferencia($referencias, $x = 10, $offset = 22)
751 763
     {
752
-        if (!isset($referencias[0]))
753
-            $referencias = [$referencias];
764
+        if (!isset($referencias[0])) {
765
+                    $referencias = [$referencias];
766
+        }
754 767
         foreach($referencias as $r) {
755 768
             $texto = $r['NroLinRef'].' - ';
756 769
             if (!empty($r['TpoDocRef'])) {
@@ -900,8 +913,9 @@  discard block
 block discarded – undo
900 913
         $this->Texto($this->detalle_cols['QtyItem']['title'], $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']);
901 914
         $this->Texto($this->detalle_cols['MontoItem']['title'], $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']);
902 915
         $this->Line($p1x, $p1y+4, $p2x, $p2y+4, $style);
903
-        if (!isset($detalle[0]))
904
-            $detalle = [$detalle];
916
+        if (!isset($detalle[0])) {
917
+                    $detalle = [$detalle];
918
+        }
905 919
         $this->SetY($this->getY()+2);
906 920
         foreach($detalle as  &$d) {
907 921
             $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']);
@@ -976,8 +990,9 @@  discard block
 block discarded – undo
976 990
      */
977 991
     protected function agregarPagos(array $pagos, $x = 10)
978 992
     {
979
-        if (!isset($pagos[0]))
980
-            $pagos = [$pagos];
993
+        if (!isset($pagos[0])) {
994
+                    $pagos = [$pagos];
995
+        }
981 996
         $this->Texto('Pago(s) programado(s):', $x);
982 997
         $this->Ln();
983 998
         foreach($pagos as $p) {
Please login to merge, or discard this patch.
lib/XML.php 3 patches
Doc Comments   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
      * Método que genera nodos XML a partir de un arreglo
53 53
      * @param data Arreglo con los datos que se usarán para generar XML
54 54
      * @param namespace Arreglo con el espacio de nombres para el XML que se generará (URI y prefijo)
55
-     * @param parent DOMElement padre para los elementos, o =null para que sea la raíz
56
-     * @return Objeto \sasco\LibreDTE\XML
55
+     * @param parent \DOMElement padre para los elementos, o =null para que sea la raíz
56
+     * @return XML \sasco\LibreDTE\XML
57 57
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
58 58
      * @version 2017-10-22
59 59
      */
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
     /**
154 154
      * Método para realizar consultas XPATH al documento XML
155 155
      * @param expression Expresión XPath a ejecutar
156
-     * @return DOMNodeList
156
+     * @return \DOMNodeList
157 157
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
158 158
      * @version 2015-08-05
159 159
      */
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
      * Método que cuenta los nodos con el mismo nombre hijos de un DOMElement
284 284
      * No sirve usar: $dom->getElementsByTagName($tagName)->length ya que esto
285 285
      * entrega todos los nodos con el nombre, sean hijos, nietos, etc.
286
-     * @return Cantidad de nodos hijos con el mismo nombre en el DOMElement
286
+     * @return integer de nodos hijos con el mismo nombre en el DOMElement
287 287
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
288 288
      * @version 2015-09-07
289 289
      */
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 
325 325
     /**
326 326
      * Método que entrega el nombre del archivo del schema del XML
327
-     * @return Nombre del schema o bien =false si no se encontró
327
+     * @return string del schema o bien =false si no se encontró
328 328
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
329 329
      * @version 2015-12-14
330 330
      */
@@ -366,6 +366,7 @@  discard block
 block discarded – undo
366 366
      * respeta el estándar y las requiere convertidas
367 367
      * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl)
368 368
      * @version 2017-01-20
369
+     * @param string $xml
369 370
      */
370 371
     private function fixEntities($xml)
371 372
     {
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      */
198 198
     private function utf2iso($string)
199 199
     {
200
-        return mb_detect_encoding($string, ['UTF-8', 'ISO-8859-1']) != 'ISO-8859-1' ? utf8_decode($string) : $string;
200
+        return mb_detect_encoding($string, ['UTF-8', 'ISO-8859-1'])!='ISO-8859-1' ? utf8_decode($string) : $string;
201 201
     }
202 202
 
203 203
     /**
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
         }
241 241
         // si existen nodos hijos se agregan
242 242
         if ($dom->hasChildNodes()) {
243
-            foreach($dom->childNodes as $child) {
243
+            foreach ($dom->childNodes as $child) {
244 244
                 if ($child instanceof \DOMText) {
245 245
                     $textContent = trim($child->textContent);
246 246
                     if ($textContent!="") {
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
         $newXML = '';
373 373
         $n_letras = strlen($xml);
374 374
         $convertir = false;
375
-        for ($i=0; $i<$n_letras; ++$i) {
375
+        for ($i = 0; $i<$n_letras; ++$i) {
376 376
             if ($xml[$i]=='>')
377 377
                 $convertir = true;
378 378
             if ($xml[$i]=='<')
Please login to merge, or discard this patch.
Braces   +19 added lines, -14 removed lines patch added patch discarded remove patch
@@ -120,8 +120,9 @@  discard block
 block discarded – undo
120 120
     private function sanitize($txt)
121 121
     {
122 122
         // si no se paso un texto o bien es un número no se hace nada
123
-        if (!$txt or is_numeric($txt))
124
-            return $txt;
123
+        if (!$txt or is_numeric($txt)) {
124
+                    return $txt;
125
+        }
125 126
         // convertir "predefined entities" de XML
126 127
         $txt = str_replace(
127 128
             ['&amp;', '&#38;', '&lt;', '&#60;', '&gt;', '&#62', '&quot;', '&#34;', '&apos;', '&#39;'],
@@ -174,8 +175,9 @@  discard block
 block discarded – undo
174 175
     {
175 176
         if ($xpath) {
176 177
             $node = $this->xpath($xpath)->item(0);
177
-            if (!$node)
178
-                return false;
178
+            if (!$node) {
179
+                            return false;
180
+            }
179 181
             $xml = $this->utf2iso($node->C14N());
180 182
             $xml = $this->fixEntities($xml);
181 183
         } else {
@@ -250,8 +252,7 @@  discard block
 block discarded – undo
250 252
                             $array[$dom->tagName]['@value'] = $textContent;
251 253
                         }
252 254
                     }
253
-                }
254
-                else if ($child instanceof \DOMElement) {
255
+                } else if ($child instanceof \DOMElement) {
255 256
                     $nodos_gemelos = $this->countTwins($dom, $child->tagName);
256 257
                     // agregar nodo hijo directamente, ya que es el único nodo hijo con el mismo nombre de tag
257 258
                     if ($nodos_gemelos==1) {
@@ -307,8 +308,9 @@  discard block
 block discarded – undo
307 308
     public function getErrors()
308 309
     {
309 310
         $errors = [];
310
-        foreach (libxml_get_errors() as $e)
311
-            $errors[] = $e->message;
311
+        foreach (libxml_get_errors() as $e) {
312
+                    $errors[] = $e->message;
313
+        }
312 314
         return $errors;
313 315
     }
314 316
 
@@ -331,8 +333,9 @@  discard block
 block discarded – undo
331 333
     public function getSchema()
332 334
     {
333 335
         $schemaLocation = $this->documentElement->getAttribute('xsi:schemaLocation');
334
-        if (!$schemaLocation or strpos($schemaLocation, ' ')===false)
335
-            return false;
336
+        if (!$schemaLocation or strpos($schemaLocation, ' ')===false) {
337
+                    return false;
338
+        }
336 339
         list($uri, $xsd) = explode(' ', $schemaLocation);
337 340
         return $xsd;
338 341
     }
@@ -373,10 +376,12 @@  discard block
 block discarded – undo
373 376
         $n_letras = strlen($xml);
374 377
         $convertir = false;
375 378
         for ($i=0; $i<$n_letras; ++$i) {
376
-            if ($xml[$i]=='>')
377
-                $convertir = true;
378
-            if ($xml[$i]=='<')
379
-                $convertir = false;
379
+            if ($xml[$i]=='>') {
380
+                            $convertir = true;
381
+            }
382
+            if ($xml[$i]=='<') {
383
+                            $convertir = false;
384
+            }
380 385
             if ($convertir) {
381 386
                 $l = $xml[$i]=='\'' ? '&apos;' : ($xml[$i]=='"' ? '&quot;' : $xml[$i]);
382 387
             } else {
Please login to merge, or discard this patch.