Completed
Push — master ( 62ce4c...4dae1d )
by Esteban De La Fuente
02:14
created
lib/Sii/PDF/Dte.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     {
182 182
         parent::__construct();
183 183
         $this->SetTitle('Documento Tributario Electrónico (DTE) de Chile by LibreDTE');
184
-        $this->papelContinuo = $papelContinuo === true ? 80 : $papelContinuo;
184
+        $this->papelContinuo = $papelContinuo===true ? 80 : $papelContinuo;
185 185
     }
186 186
 
187 187
     /**
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
         $this->setY(max($y));
327 327
         $this->Ln();
328 328
         $y = [];
329
-        $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null);
329
+        $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null);
330 330
         $y[] = $this->agregarReceptor($dte['Encabezado']);
331 331
         $this->setY(max($y));
332 332
         $this->agregarTraslado(
@@ -386,15 +386,15 @@  discard block
 block discarded – undo
386 386
             $dte['Encabezado']['IdDoc']['TipoDTE'],
387 387
             $dte['Encabezado']['IdDoc']['Folio'],
388 388
             $dte['Encabezado']['Emisor']['CmnaOrigen'],
389
-            $x_start, $y_start, $width-($x_start*4), 10,
390
-            [0,0,0]
389
+            $x_start, $y_start, $width-($x_start * 4), 10,
390
+            [0, 0, 0]
391 391
         );
392
-        $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, $width-($x_start*4), 8, 9, [0,0,0]);
392
+        $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, $width-($x_start * 4), 8, 9, [0, 0, 0]);
393 393
         // datos del documento
394 394
         $this->SetY($y);
395 395
         $this->Ln();
396 396
         $this->setFont('', '', 8);
397
-        $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null, $x_start, $offset, false);
397
+        $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null, $x_start, $offset, false);
398 398
         $this->agregarReceptor($dte['Encabezado'], $x_start, $offset);
399 399
         $this->agregarTraslado(
400 400
             !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null,
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
         $this->AddPage('P', [$height ? $height : $this->papel_continuo_alto, $width]);
448 448
         $x = 1;
449 449
         $y = 5;
450
-        $this->SetXY($x,$y);
450
+        $this->SetXY($x, $y);
451 451
         // agregar datos del documento
452 452
         $this->setFont('', '', 8);
453 453
         $this->MultiTexto(!empty($dte['Encabezado']['Emisor']['RznSoc']) ? $dte['Encabezado']['Emisor']['RznSoc'] : $dte['Encabezado']['Emisor']['RznSocEmisor'], $x, null, '', $width-2);
@@ -537,13 +537,13 @@  discard block
 block discarded – undo
537 537
                 $this->logo['uri'],
538 538
                 $x,
539 539
                 $y,
540
-                !$this->logo['posicion']?$w_img:null, $this->logo['posicion']?($w_img/2):null,
540
+                !$this->logo['posicion'] ? $w_img : null, $this->logo['posicion'] ? ($w_img / 2) : null,
541 541
                 'PNG',
542
-                (isset($emisor['url'])?$emisor['url']:''),
542
+                (isset($emisor['url']) ? $emisor['url'] : ''),
543 543
                 'T'
544 544
             );
545 545
             if ($this->logo['posicion']) {
546
-                $this->SetY($this->y + ($w_img/2));
546
+                $this->SetY($this->y+($w_img / 2));
547 547
                 $w += 40;
548 548
             } else {
549 549
                 $x = $this->x+3;
@@ -554,14 +554,14 @@  discard block
 block discarded – undo
554 554
         }
555 555
         // agregar datos del emisor
556 556
         $this->setFont('', 'B', $font_size ? $font_size : 14);
557
-        $this->SetTextColorArray($color===null?[32, 92, 144]:$color);
557
+        $this->SetTextColorArray($color===null ? [32, 92, 144] : $color);
558 558
         $this->MultiTexto(!empty($emisor['RznSoc']) ? $emisor['RznSoc'] : $emisor['RznSocEmisor'], $x, $this->y+2, 'L', $w);
559 559
         $this->setFont('', 'B', $font_size ? $font_size : 9);
560
-        $this->SetTextColorArray([0,0,0]);
560
+        $this->SetTextColorArray([0, 0, 0]);
561 561
         $this->MultiTexto(!empty($emisor['GiroEmis']) ? $emisor['GiroEmis'] : $emisor['GiroEmisor'], $x, $this->y, 'L', $w);
562 562
         $comuna = !empty($emisor['CmnaOrigen']) ? $emisor['CmnaOrigen'] : null;
563 563
         $ciudad = !empty($emisor['CiudadOrigen']) ? $emisor['CiudadOrigen'] : \sasco\LibreDTE\Chile::getCiudad($comuna);
564
-        $this->MultiTexto($emisor['DirOrigen'].($comuna?(', '.$comuna):'').($ciudad?(', '.$ciudad):''), $x, $this->y, 'L', $w);
564
+        $this->MultiTexto($emisor['DirOrigen'].($comuna ? (', '.$comuna) : '').($ciudad ? (', '.$ciudad) : ''), $x, $this->y, 'L', $w);
565 565
         if (!empty($emisor['Sucursal'])) {
566 566
             $this->MultiTexto('Sucursal: '.$emisor['Sucursal'], $x, $this->y, 'L', $w);
567 567
         }
@@ -605,12 +605,12 @@  discard block
 block discarded – undo
605 605
     protected function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null)
606 606
     {
607 607
         if ($color===null) {
608
-            $color = $tipo ? ($tipo==52 ? [0,172,140] : [255,0,0]) : [0,0,0];
608
+            $color = $tipo ? ($tipo==52 ? [0, 172, 140] : [255, 0, 0]) : [0, 0, 0];
609 609
         }
610 610
         $this->SetTextColorArray($color);
611 611
         // colocar rut emisor, glosa documento y folio
612 612
         list($rut, $dv) = explode('-', $rut);
613
-        $this->setFont ('', 'B', $font_size ? $font_size : 15);
613
+        $this->setFont('', 'B', $font_size ? $font_size : 15);
614 614
         $this->MultiTexto('R.U.T.: '.$this->num($rut).'-'.$dv, $x, $y+4, 'C', $w);
615 615
         $this->setFont('', 'B', $font_size ? $font_size : 12);
616 616
         $this->MultiTexto($this->getTipo($tipo), $x, null, 'C', $w);
@@ -623,7 +623,7 @@  discard block
 block discarded – undo
623 623
         if ($tipo) {
624 624
             $this->Texto('S.I.I. - '.\sasco\LibreDTE\Sii::getDireccionRegional($sucursal_sii), $x, $this->getY()+4, 'C', $w);
625 625
         }
626
-        $this->SetTextColorArray([0,0,0]);
626
+        $this->SetTextColorArray([0, 0, 0]);
627 627
         $this->Ln();
628 628
         return $this->y;
629 629
     }
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
             $this->Texto('Señor(es)', $x);
756 756
             $this->Texto(':', $x+$offset);
757 757
             $this->setFont('', '', null);
758
-            $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10?105:0);
758
+            $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0);
759 759
         }
760 760
         if (!empty($receptor['GiroRecep'])) {
761 761
             $this->setFont('', 'B', null);
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
             $ciudad = !empty($receptor['CiudadRecep']) ? $receptor['CiudadRecep'] : (
773 773
                 !empty($receptor['CmnaRecep']) ? \sasco\LibreDTE\Chile::getCiudad($receptor['CmnaRecep']) : ''
774 774
             );
775
-            $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep'])?(', '.$receptor['CmnaRecep']):'').($ciudad?(', '.$ciudad):''), $x+$offset+2);
775
+            $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep']) ? (', '.$receptor['CmnaRecep']) : '').($ciudad ? (', '.$ciudad) : ''), $x+$offset+2);
776 776
         }
777 777
         if (!empty($receptor['Extranjero']['Nacionalidad'])) {
778 778
             $this->setFont('', 'B', null);
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
             $this->Texto('Cód. recep.', $x);
814 814
             $this->Texto(':', $x+$offset);
815 815
             $this->setFont('', '', null);
816
-            $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10?105:0);
816
+            $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0);
817 817
         }
818 818
         return $this->GetY();
819 819
     }
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
     {
902 902
         if (!isset($referencias[0]))
903 903
             $referencias = [$referencias];
904
-        foreach($referencias as $r) {
904
+        foreach ($referencias as $r) {
905 905
             $texto = $r['NroLinRef'].' - ';
906 906
             if (!empty($r['TpoDocRef'])) {
907 907
                 $texto .= $this->getTipo($r['TpoDocRef']).' ';
@@ -1008,9 +1008,9 @@  discard block
 block discarded – undo
1008 1008
         $this->SetY($this->getY()+1);
1009 1009
         $p1x = $x;
1010 1010
         $p1y = $this->y;
1011
-        $p2x = $this->getPageWidth() - 2;
1012
-        $p2y = $p1y;  // Use same y for a straight line
1013
-        $style = array('width' => 0.2,'color' => array(0, 0, 0));
1011
+        $p2x = $this->getPageWidth()-2;
1012
+        $p2y = $p1y; // Use same y for a straight line
1013
+        $style = array('width' => 0.2, 'color' => array(0, 0, 0));
1014 1014
         $this->Line($p1x, $p1y, $p2x, $p2y, $style);
1015 1015
         $this->Texto($this->detalle_cols['NmbItem']['title'], $x+1, $this->y, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']);
1016 1016
         $this->Texto($this->detalle_cols['PrcItem']['title'], $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']);
@@ -1020,9 +1020,9 @@  discard block
 block discarded – undo
1020 1020
         if (!isset($detalle[0]))
1021 1021
             $detalle = [$detalle];
1022 1022
         $this->SetY($this->getY()+2);
1023
-        foreach($detalle as  &$d) {
1023
+        foreach ($detalle as  &$d) {
1024 1024
             $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']);
1025
-            $this->Texto(number_format($d['PrcItem'],0,',','.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']);
1025
+            $this->Texto(number_format($d['PrcItem'], 0, ',', '.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']);
1026 1026
             $this->Texto($this->num($d['QtyItem']), $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']);
1027 1027
             $this->Texto($this->num($d['MontoItem']), $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']);
1028 1028
         }
@@ -1042,7 +1042,7 @@  discard block
 block discarded – undo
1042 1042
         if (!isset($detalle[0])) {
1043 1043
             $detalle = [$detalle];
1044 1044
         }
1045
-        foreach($detalle as  &$d) {
1045
+        foreach ($detalle as  &$d) {
1046 1046
             if (!empty($d['MontoItem'])) {
1047 1047
                 $subtotal += $d['MontoItem'];
1048 1048
             }
@@ -1067,13 +1067,13 @@  discard block
 block discarded – undo
1067 1067
     {
1068 1068
         if (!isset($descuentosRecargos[0]))
1069 1069
             $descuentosRecargos = [$descuentosRecargos];
1070
-        foreach($descuentosRecargos as $dr) {
1070
+        foreach ($descuentosRecargos as $dr) {
1071 1071
             $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo';
1072 1072
             $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : $this->num($dr['ValorDR']);
1073 1073
             if ($this->papelContinuo) {
1074
-                $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):''), $x);
1074
+                $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : ''), $x);
1075 1075
             } else {
1076
-                $this->Texto($tipo.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):'').':', 77, null, 'R', 100);
1076
+                $this->Texto($tipo.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : '').':', 77, null, 'R', 100);
1077 1077
                 $this->Texto($valor, 177, null, 'R', 22);
1078 1078
             }
1079 1079
             $this->Ln();
@@ -1093,8 +1093,8 @@  discard block
 block discarded – undo
1093 1093
             $pagos = [$pagos];
1094 1094
         $this->Texto('Pago(s) programado(s):', $x);
1095 1095
         $this->Ln();
1096
-        foreach($pagos as $p) {
1097
-            $this->Texto('  - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos'])?(' ('.$p['GlosaPagos'].')'):''), $x);
1096
+        foreach ($pagos as $p) {
1097
+            $this->Texto('  - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos']) ? (' ('.$p['GlosaPagos'].')') : ''), $x);
1098 1098
             $this->Ln();
1099 1099
         }
1100 1100
     }
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
             if (!isset($ImptoReten[0])) {
1146 1146
                 $ImptoReten = [$ImptoReten];
1147 1147
             }
1148
-            foreach($ImptoReten as $i) {
1148
+            foreach ($ImptoReten as $i) {
1149 1149
                 $totales['ImptoReten_'.$i['TipoImp']] = $i['MontoImp'];
1150 1150
                 if (!empty($i['TasaImp'])) {
1151 1151
                     $glosas['ImptoReten_'.$i['TipoImp']] = \sasco\LibreDTE\Sii\ImpuestosAdicionales::getGlosa($i['TipoImp']).' ('.$i['TasaImp'].'%) $';
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
                 'vpadding' => 0,
1250 1250
                 'module_width' => 1, // width of a single module in points
1251 1251
                 'module_height' => 1, // height of a single module in points
1252
-                'fgcolor' => [0,0,0],
1252
+                'fgcolor' => [0, 0, 0],
1253 1253
                 'bgcolor' => false, // [255,255,255]
1254 1254
                 'position' => $this->papelContinuo ? 'C' : 'S',
1255 1255
             ];
@@ -1282,7 +1282,7 @@  discard block
 block discarded – undo
1282 1282
     protected function agregarAcuseRecibo($x = 83, $y = 190, $w = 60, $h = 40)
1283 1283
     {
1284 1284
         $y = (!$this->papelContinuo and !$this->timbre_pie) ? $this->x_fin_datos : $y;
1285
-        $this->SetTextColorArray([0,0,0]);
1285
+        $this->SetTextColorArray([0, 0, 0]);
1286 1286
         $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]);
1287 1287
         $this->setFont('', 'B', 10);
1288 1288
         $this->Texto('Acuse de recibo', $x, $y+1, 'C', $w);
@@ -1312,9 +1312,9 @@  discard block
 block discarded – undo
1312 1312
      */
1313 1313
     protected function agregarAcuseReciboContinuo($x = 3, $y = null, $w = 68, $h = 40)
1314 1314
     {
1315
-        $this->SetTextColorArray([0,0,0]);
1315
+        $this->SetTextColorArray([0, 0, 0]);
1316 1316
         $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]);
1317
-        $style = array('width' => 0.2,'color' => array(0, 0, 0));
1317
+        $style = array('width' => 0.2, 'color' => array(0, 0, 0));
1318 1318
         $this->Line($x, $y+22, $w+3, $y+22, $style);
1319 1319
         //$this->setFont('', 'B', 10);
1320 1320
         //$this->Texto('Acuse de recibo', $x, $y+1, 'C', $w);
@@ -1344,7 +1344,7 @@  discard block
 block discarded – undo
1344 1344
         $y = (!$this->papelContinuo and !$this->timbre_pie) ? $this->x_fin_datos : $y;
1345 1345
         $y += 64;
1346 1346
         $this->setFont('', 'B', $font_size);
1347
-        $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $y, 'R');
1347
+        $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $y, 'R');
1348 1348
     }
1349 1349
 
1350 1350
     /**
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
     protected function agregarLeyendaDestinoContinuo($tipo)
1356 1356
     {
1357 1357
         $this->setFont('', 'B', 8);
1358
-        $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $this->y+6, 'R');
1358
+        $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $this->y+6, 'R');
1359 1359
     }
1360 1360
 
1361 1361
     /**
@@ -1386,7 +1386,7 @@  discard block
 block discarded – undo
1386 1386
         $dias = ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'];
1387 1387
         $meses = ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'];
1388 1388
         $unixtime = strtotime($date);
1389
-        $fecha = date(($mostrar_dia?'\D\I\A ':'').'j \d\e \M\E\S \d\e\l Y', $unixtime);
1389
+        $fecha = date(($mostrar_dia ? '\D\I\A ' : '').'j \d\e \M\E\S \d\e\l Y', $unixtime);
1390 1390
         $dia = $dias[date('w', $unixtime)];
1391 1391
         $mes = $meses[date('n', $unixtime)-1];
1392 1392
         return str_replace(array('DIA', 'MES'), array($dia, $mes), $fecha);
Please login to merge, or discard this patch.