@@ -492,8 +492,8 @@ discard block |
||
| 492 | 492 | |
| 493 | 493 | /** |
| 494 | 494 | * Método para realizar una solicitud al servicio web del SII |
| 495 | - * @param wsdl Nombre del WSDL que se usará |
|
| 496 | - * @param request Nombre de la función que se ejecutará en el servicio web |
|
| 495 | + * @param wsdl string del WSDL que se usará |
|
| 496 | + * @param request string de la función que se ejecutará en el servicio web |
|
| 497 | 497 | * @param args Argumentos que se pasarán al servicio web |
| 498 | 498 | * @param retry Intentos que se realizarán como máximo para obtener respuesta |
| 499 | 499 | * @return Objeto SimpleXMLElement con la espuesta del servicio web consultado |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | * @param usuario RUN del usuario que envía el DTE |
| 589 | 589 | * @param empresa RUT de la empresa emisora del DTE |
| 590 | 590 | * @param dte Documento XML con el DTE que se desea enviar a SII |
| 591 | - * @param token Token de autenticación automática ante el SII |
|
| 591 | + * @param token string de autenticación automática ante el SII |
|
| 592 | 592 | * @param gzip Permite enviar el archivo XML comprimido al servidor |
| 593 | 593 | * @param retry Intentos que se realizarán como máximo para obtener respuesta |
| 594 | 594 | * @return Respuesta XML desde SII o bien null si no se pudo obtener respuesta |
@@ -696,7 +696,7 @@ discard block |
||
| 696 | 696 | * \endcode |
| 697 | 697 | * |
| 698 | 698 | * @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 |
| 699 | - * @return Contenido del certificado |
|
| 699 | + * @return string|false del certificado |
|
| 700 | 700 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 701 | 701 | * @version 2015-09-16 |
| 702 | 702 | */ |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | /** |
| 723 | 723 | * Método que asigna el ambiente que se usará por defecto (si no está |
| 724 | 724 | * asignado con la constante _LibreDTE_CERTIFICACION_) |
| 725 | - * @param ambiente Ambiente a usar: Sii::PRODUCCION o Sii::CERTIFICACION |
|
| 725 | + * @param ambiente integer a usar: Sii::PRODUCCION o Sii::CERTIFICACION |
|
| 726 | 726 | * @warning No se está verificando SSL en ambiente de certificación |
| 727 | 727 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 728 | 728 | * @version 2016-08-28 |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | |
| 758 | 758 | /** |
| 759 | 759 | * Método que entrega la tasa de IVA vigente |
| 760 | - * @return Tasa de IVA vigente |
|
| 760 | + * @return integer de IVA vigente |
|
| 761 | 761 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 762 | 762 | * @version 2015-09-03 |
| 763 | 763 | */ |
@@ -833,7 +833,7 @@ discard block |
||
| 833 | 833 | /** |
| 834 | 834 | * Método que entrega la dirección regional según la comuna que se esté |
| 835 | 835 | * consultando |
| 836 | - * @param comuna de la sucursal del emior o bien código de la sucursal del SII |
|
| 836 | + * @param comuna Sii\Dte\PDF\Código|null la sucursal del emior o bien código de la sucursal del SII |
|
| 837 | 837 | * @return Dirección regional del SII |
| 838 | 838 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 839 | 839 | * @version 2017-11-07 |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | \sasco\LibreDTE\Log::write(Estado::REQUEST_ERROR_SOAP, Estado::get(Estado::REQUEST_ERROR_SOAP, $msg)); |
| 537 | 537 | return false; |
| 538 | 538 | } |
| 539 | - for ($i=0; $i<$retry; $i++) { |
|
| 539 | + for ($i = 0; $i<$retry; $i++) { |
|
| 540 | 540 | try { |
| 541 | 541 | if ($args) { |
| 542 | 542 | $body = call_user_func_array([$soap, $request], $args); |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | $dte = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".$dte; |
| 606 | 606 | } |
| 607 | 607 | do { |
| 608 | - $file = sys_get_temp_dir().'/dte_'.md5(microtime().$token.$dte).'.'.($gzip?'gz':'xml'); |
|
| 608 | + $file = sys_get_temp_dir().'/dte_'.md5(microtime().$token.$dte).'.'.($gzip ? 'gz' : 'xml'); |
|
| 609 | 609 | } while (file_exists($file)); |
| 610 | 610 | if ($gzip) { |
| 611 | 611 | $dte = gzencode($dte); |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
| 655 | 655 | } |
| 656 | 656 | // enviar XML al SII |
| 657 | - for ($i=0; $i<$retry; $i++) { |
|
| 657 | + for ($i = 0; $i<$retry; $i++) { |
|
| 658 | 658 | $response = curl_exec($curl); |
| 659 | 659 | if ($response and $response!='Error 500') { |
| 660 | 660 | break; |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | if ($xml->STATUS!=0) { |
| 684 | 684 | \sasco\LibreDTE\Log::write( |
| 685 | 685 | $xml->STATUS, |
| 686 | - Estado::get($xml->STATUS).(isset($xml->DETAIL)?'. '.implode("\n", (array)$xml->DETAIL->ERROR):'') |
|
| 686 | + Estado::get($xml->STATUS).(isset($xml->DETAIL) ? '. '.implode("\n", (array)$xml->DETAIL->ERROR) : '') |
|
| 687 | 687 | ); |
| 688 | 688 | } |
| 689 | 689 | return $xml; |
@@ -476,8 +476,9 @@ discard block |
||
| 476 | 476 | // entregar WSDL local (modificados para ambiente de certificación) |
| 477 | 477 | if ($ambiente==self::CERTIFICACION) { |
| 478 | 478 | $wsdl = dirname(dirname(__FILE__)).'/wsdl/'.self::$config['servidor'][$ambiente].'/'.$servicio.'.jws'; |
| 479 | - if (is_readable($wsdl)) |
|
| 480 | - return $wsdl; |
|
| 479 | + if (is_readable($wsdl)) { |
|
| 480 | + return $wsdl; |
|
| 481 | + } |
|
| 481 | 482 | } |
| 482 | 483 | // entregar WSDL oficial desde SII |
| 483 | 484 | $location = isset(self::$config['wsdl'][$servicio]) ? self::$config['wsdl'][$servicio] : self::$config['wsdl']['*']; |
@@ -748,10 +749,11 @@ discard block |
||
| 748 | 749 | public static function getAmbiente($ambiente = null) |
| 749 | 750 | { |
| 750 | 751 | if ($ambiente===null) { |
| 751 | - if (defined('_LibreDTE_CERTIFICACION_')) |
|
| 752 | - $ambiente = (int)_LibreDTE_CERTIFICACION_; |
|
| 753 | - else |
|
| 754 | - $ambiente = self::$ambiente; |
|
| 752 | + if (defined('_LibreDTE_CERTIFICACION_')) { |
|
| 753 | + $ambiente = (int)_LibreDTE_CERTIFICACION_; |
|
| 754 | + } else { |
|
| 755 | + $ambiente = self::$ambiente; |
|
| 756 | + } |
|
| 755 | 757 | } |
| 756 | 758 | return $ambiente; |
| 757 | 759 | } |
@@ -236,7 +236,7 @@ |
||
| 236 | 236 | $dias = ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado']; |
| 237 | 237 | $meses = ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre']; |
| 238 | 238 | $unixtime = strtotime($date); |
| 239 | - $fecha = date(($mostrar_dia?'\D\I\A ':'').'j \d\e \M\E\S \d\e\l Y', $unixtime); |
|
| 239 | + $fecha = date(($mostrar_dia ? '\D\I\A ' : '').'j \d\e \M\E\S \d\e\l Y', $unixtime); |
|
| 240 | 240 | $dia = $dias[date('w', $unixtime)]; |
| 241 | 241 | $mes = $meses[date('n', $unixtime)-1]; |
| 242 | 242 | return str_replace(array('DIA', 'MES'), array($dia, $mes), $fecha); |
@@ -138,7 +138,7 @@ |
||
| 138 | 138 | ]; |
| 139 | 139 | // agregar otros impuestos adicionales |
| 140 | 140 | if ($n_OtrosImp>1) { |
| 141 | - for ($i=1; $i<$n_OtrosImp; $i++) { |
|
| 141 | + for ($i = 1; $i<$n_OtrosImp; $i++) { |
|
| 142 | 142 | $detalle[] = [ |
| 143 | 143 | '', |
| 144 | 144 | '', |
@@ -57,8 +57,9 @@ discard block |
||
| 57 | 57 | { |
| 58 | 58 | $this->startPageGroup(); |
| 59 | 59 | $this->AddPage(); |
| 60 | - if (isset($libro['LibroCompraVenta'])) |
|
| 61 | - $libro = $libro['LibroCompraVenta']; |
|
| 60 | + if (isset($libro['LibroCompraVenta'])) { |
|
| 61 | + $libro = $libro['LibroCompraVenta']; |
|
| 62 | + } |
|
| 62 | 63 | // título del libro |
| 63 | 64 | $this->SetFont('helvetica', 'B', 16); |
| 64 | 65 | $this->Texto('Libro de '.ucfirst(strtolower($libro['EnvioLibro']['Caratula']['TipoOperacion'])), null, null, 'C'); |
@@ -109,8 +110,7 @@ discard block |
||
| 109 | 110 | $total_resumen['TotIVARetTotal'] += !empty($total['TotIVARetTotal']) ? $total['TotIVARetTotal'] : 0; |
| 110 | 111 | $total_resumen['TotIVANoRetenido'] += !empty($total['TotIVANoRetenido']) ? $total['TotIVANoRetenido'] : 0; |
| 111 | 112 | $total_resumen['TotMntTotal'] += $total['TotMntTotal']; |
| 112 | - } |
|
| 113 | - else if (in_array($total['TpoDoc'], $this->dte_tipo_operacion['resta'])) { |
|
| 113 | + } else if (in_array($total['TpoDoc'], $this->dte_tipo_operacion['resta'])) { |
|
| 114 | 114 | $total_resumen['TotMntExe'] -= !empty($total['TotMntExe']) ? $total['TotMntExe'] : 0; |
| 115 | 115 | $total_resumen['TotMntNeto'] -= !empty($total['TotMntNeto']) ? $total['TotMntNeto'] : 0; |
| 116 | 116 | $total_resumen['TotMntIVA'] -= !empty($total['TotMntIVA']) ? $total['TotMntIVA'] : 0; |
@@ -171,10 +171,13 @@ discard block |
||
| 171 | 171 | foreach ($libro['EnvioLibro']['Detalle'] as $d) { |
| 172 | 172 | // impuesto adicional |
| 173 | 173 | if (!empty($d['OtrosImp'])) { |
| 174 | - if (!isset($d['OtrosImp'][0])) |
|
| 175 | - $d['OtrosImp'] = [$d['OtrosImp']]; |
|
| 174 | + if (!isset($d['OtrosImp'][0])) { |
|
| 175 | + $d['OtrosImp'] = [$d['OtrosImp']]; |
|
| 176 | + } |
|
| 176 | 177 | $n_OtrosImp = count($d['OtrosImp']); |
| 177 | - } else $n_OtrosImp = 0; |
|
| 178 | + } else { |
|
| 179 | + $n_OtrosImp = 0; |
|
| 180 | + } |
|
| 178 | 181 | // se agrega detalle |
| 179 | 182 | $detalle[] = [ |
| 180 | 183 | $d['TpoDoc'], |
@@ -52,15 +52,18 @@ |
||
| 52 | 52 | |
| 53 | 53 | // directorio temporal para guardar los PDF |
| 54 | 54 | $dir = sys_get_temp_dir().'/dte_'.$Caratula['RutEmisor'].'_'.$Caratula['RutReceptor'].'_'.str_replace(['-', ':', 'T'], '', $Caratula['TmstFirmaEnv']); |
| 55 | -if (is_dir($dir)) |
|
| 55 | +if (is_dir($dir)) { |
|
| 56 | 56 | \sasco\LibreDTE\File::rmdir($dir); |
| 57 | -if (!mkdir($dir)) |
|
| 57 | +} |
|
| 58 | +if (!mkdir($dir)) { |
|
| 58 | 59 | die('No fue posible crear directorio temporal para DTEs'); |
| 60 | +} |
|
| 59 | 61 | |
| 60 | 62 | // procesar cada DTEs e ir agregándolo al PDF |
| 61 | 63 | foreach ($Documentos as $DTE) { |
| 62 | - if (!$DTE->getDatos()) |
|
| 63 | - die('No se pudieron obtener los datos del DTE'); |
|
| 64 | + if (!$DTE->getDatos()) { |
|
| 65 | + die('No se pudieron obtener los datos del DTE'); |
|
| 66 | + } |
|
| 64 | 67 | $pdf = new \sasco\LibreDTE\Sii\Dte\PDF\Dte(false); // =false hoja carta, =true papel contínuo (false por defecto si no se pasa) |
| 65 | 68 | $pdf->setFooterText(); |
| 66 | 69 | $pdf->setLogo('/home/delaf/www/localhost/dev/pages/sasco/website/webroot/img/logo_mini.png'); // debe ser PNG! |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | ] |
| 140 | 140 | ]); |
| 141 | 141 | $parent = $this->xml->getElementsByTagName($this->tipo_general)->item(0); |
| 142 | - $this->xml->generate($datos + ['TED' => null], null, $parent); |
|
| 142 | + $this->xml->generate($datos+['TED' => null], null, $parent); |
|
| 143 | 143 | $this->datos = $datos; |
| 144 | 144 | if ($normalizar and !$this->verificarDatos()) { |
| 145 | 145 | return false; |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | $xml->documentElement->removeAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi'); |
| 383 | 383 | $xml->documentElement->removeAttributeNS('http://www.sii.cl/SiiDte', ''); |
| 384 | 384 | $TED = $xml->getFlattened('/'); |
| 385 | - return mb_detect_encoding($TED, ['UTF-8', 'ISO-8859-1']) != 'ISO-8859-1' ? utf8_decode($TED) : $TED; |
|
| 385 | + return mb_detect_encoding($TED, ['UTF-8', 'ISO-8859-1'])!='ISO-8859-1' ? utf8_decode($TED) : $TED; |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -395,7 +395,7 @@ discard block |
||
| 395 | 395 | { |
| 396 | 396 | $datos = $this->getDatos(); |
| 397 | 397 | $idk = !empty($datos['TED']['DD']['CAF']['DA']['IDK']) ? (int)$datos['TED']['DD']['CAF']['DA']['IDK'] : null; |
| 398 | - return $idk ? $idk === 100 : null; |
|
| 398 | + return $idk ? $idk===100 : null; |
|
| 399 | 399 | } |
| 400 | 400 | |
| 401 | 401 | /** |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | { |
| 530 | 530 | $this->getDatos(); |
| 531 | 531 | // generar resumen |
| 532 | - $resumen = [ |
|
| 532 | + $resumen = [ |
|
| 533 | 533 | 'TpoDoc' => (int)$this->datos['Encabezado']['IdDoc']['TipoDTE'], |
| 534 | 534 | 'NroDoc' => (int)$this->datos['Encabezado']['IdDoc']['Folio'], |
| 535 | 535 | 'TasaImp' => 0, |
@@ -574,17 +574,17 @@ discard block |
||
| 574 | 574 | */ |
| 575 | 575 | private function calcularNetoIVA($total, $tasa = null) |
| 576 | 576 | { |
| 577 | - if ($tasa === 0 or $tasa === false) |
|
| 577 | + if ($tasa===0 or $tasa===false) |
|
| 578 | 578 | return [0, 0]; |
| 579 | - if ($tasa === null) |
|
| 579 | + if ($tasa===null) |
|
| 580 | 580 | $tasa = \sasco\LibreDTE\Sii::getIVA(); |
| 581 | 581 | // WARNING: el IVA obtenido puede no ser el NETO*(TASA/100) |
| 582 | 582 | // se calcula el monto neto y luego se obtiene el IVA haciendo la resta |
| 583 | 583 | // entre el total y el neto, ya que hay casos de borde como: |
| 584 | 584 | // - BRUTO: 680 => NETO: 571 e IVA: 108 => TOTAL: 679 |
| 585 | 585 | // - BRUTO: 86710 => NETO: 72866 e IVA: 13845 => TOTAL: 86711 |
| 586 | - $neto = round($total / (1+($tasa/100))); |
|
| 587 | - $iva = $total - $neto; |
|
| 586 | + $neto = round($total / (1+($tasa / 100))); |
|
| 587 | + $iva = $total-$neto; |
|
| 588 | 588 | return [$neto, $iva]; |
| 589 | 589 | } |
| 590 | 590 | |
@@ -1429,12 +1429,12 @@ discard block |
||
| 1429 | 1429 | ); |
| 1430 | 1430 | // aplicar descuento |
| 1431 | 1431 | if ($d['DescuentoPct']) { |
| 1432 | - $d['DescuentoMonto'] = round($d['MontoItem'] * (float)$d['DescuentoPct']/100); |
|
| 1432 | + $d['DescuentoMonto'] = round($d['MontoItem'] * (float)$d['DescuentoPct'] / 100); |
|
| 1433 | 1433 | } |
| 1434 | 1434 | $d['MontoItem'] -= $d['DescuentoMonto']; |
| 1435 | 1435 | // aplicar recargo |
| 1436 | 1436 | if ($d['RecargoPct']) { |
| 1437 | - $d['RecargoMonto'] = round($d['MontoItem'] * (float)$d['RecargoPct']/100); |
|
| 1437 | + $d['RecargoMonto'] = round($d['MontoItem'] * (float)$d['RecargoPct'] / 100); |
|
| 1438 | 1438 | } |
| 1439 | 1439 | $d['MontoItem'] += $d['RecargoMonto']; |
| 1440 | 1440 | // aproximar monto del item |
@@ -1520,7 +1520,7 @@ discard block |
||
| 1520 | 1520 | } |
| 1521 | 1521 | $valor = |
| 1522 | 1522 | $dr['TpoValor']=='%' |
| 1523 | - ? $this->round(($dr['ValorDR']/100)*$datos['Encabezado']['Totales'][$monto], $datos['Encabezado']['Totales']['TpoMoneda']) |
|
| 1523 | + ? $this->round(($dr['ValorDR'] / 100) * $datos['Encabezado']['Totales'][$monto], $datos['Encabezado']['Totales']['TpoMoneda']) |
|
| 1524 | 1524 | : $dr['ValorDR'] |
| 1525 | 1525 | ; |
| 1526 | 1526 | // aplicar descuento |
@@ -1593,7 +1593,7 @@ discard block |
||
| 1593 | 1593 | // si el monto no existe se asigna |
| 1594 | 1594 | if ($datos['Encabezado']['Totales']['ImptoReten'][$i]['MontoImp']===null) { |
| 1595 | 1595 | $datos['Encabezado']['Totales']['ImptoReten'][$i]['MontoImp'] = round( |
| 1596 | - $neto * $datos['Encabezado']['Totales']['ImptoReten'][$i]['TasaImp']/100 |
|
| 1596 | + $neto * $datos['Encabezado']['Totales']['ImptoReten'][$i]['TasaImp'] / 100 |
|
| 1597 | 1597 | ); |
| 1598 | 1598 | } |
| 1599 | 1599 | } |
@@ -1601,7 +1601,7 @@ discard block |
||
| 1601 | 1601 | if (isset($datos['Encabezado']['Totales']['ImptoReten']) and is_array($datos['Encabezado']['Totales']['ImptoReten'])) { |
| 1602 | 1602 | $codigos = array_keys($montos); |
| 1603 | 1603 | $n_impuestos = count($datos['Encabezado']['Totales']['ImptoReten']); |
| 1604 | - for ($i=0; $i<$n_impuestos; $i++) { |
|
| 1604 | + for ($i = 0; $i<$n_impuestos; $i++) { |
|
| 1605 | 1605 | if (!in_array($datos['Encabezado']['Totales']['ImptoReten'][$i]['TipoImp'], $codigos)) { |
| 1606 | 1606 | unset($datos['Encabezado']['Totales']['ImptoReten'][$i]); |
| 1607 | 1607 | } |
@@ -1629,7 +1629,7 @@ discard block |
||
| 1629 | 1629 | } else { |
| 1630 | 1630 | if (empty($datos['Encabezado']['Totales']['IVA']) and !empty($datos['Encabezado']['Totales']['TasaIVA'])) { |
| 1631 | 1631 | $datos['Encabezado']['Totales']['IVA'] = round( |
| 1632 | - $datos['Encabezado']['Totales']['MntNeto']*($datos['Encabezado']['Totales']['TasaIVA']/100) |
|
| 1632 | + $datos['Encabezado']['Totales']['MntNeto'] * ($datos['Encabezado']['Totales']['TasaIVA'] / 100) |
|
| 1633 | 1633 | ); |
| 1634 | 1634 | } |
| 1635 | 1635 | } |
@@ -1653,7 +1653,7 @@ discard block |
||
| 1653 | 1653 | if (ImpuestosAdicionales::getTipo($ImptoReten['TipoImp'])=='R') { |
| 1654 | 1654 | $datos['Encabezado']['Totales']['MntTotal'] -= $ImptoReten['MontoImp']; |
| 1655 | 1655 | if ($ImptoReten['MontoImp']!=$datos['Encabezado']['Totales']['IVA']) { |
| 1656 | - $datos['Encabezado']['Totales']['IVANoRet'] = $datos['Encabezado']['Totales']['IVA'] - $ImptoReten['MontoImp']; |
|
| 1656 | + $datos['Encabezado']['Totales']['IVANoRet'] = $datos['Encabezado']['Totales']['IVA']-$ImptoReten['MontoImp']; |
|
| 1657 | 1657 | } |
| 1658 | 1658 | } |
| 1659 | 1659 | // si es adicional se suma al total |
@@ -1811,7 +1811,7 @@ discard block |
||
| 1811 | 1811 | $SignatureValue = $Signature->getElementsByTagName('SignatureValue')->item(0)->nodeValue; |
| 1812 | 1812 | $X509Certificate = $Signature->getElementsByTagName('X509Certificate')->item(0)->nodeValue; |
| 1813 | 1813 | $X509Certificate = '-----BEGIN CERTIFICATE-----'."\n".wordwrap(trim($X509Certificate), 64, "\n", true)."\n".'-----END CERTIFICATE----- '; |
| 1814 | - $valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate) === 1 ? true : false; |
|
| 1814 | + $valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate)===1 ? true : false; |
|
| 1815 | 1815 | return $valid; |
| 1816 | 1816 | //return $valid and $DigestValue===base64_encode(sha1($Documento->C14N(), true)); |
| 1817 | 1817 | } |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | /** |
| 239 | 239 | * Método que entrega el tipo de DTE |
| 240 | - * @return Tipo de dte, ej: 33 (factura electrónica) |
|
| 240 | + * @return string de dte, ej: 33 (factura electrónica) |
|
| 241 | 241 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 242 | 242 | * @version 2015-09-02 |
| 243 | 243 | */ |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | |
| 249 | 249 | /** |
| 250 | 250 | * Método que entrega el folio del DTE |
| 251 | - * @return Folio del DTE |
|
| 251 | + * @return string del DTE |
|
| 252 | 252 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 253 | 253 | * @version 2015-09-02 |
| 254 | 254 | */ |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | |
| 260 | 260 | /** |
| 261 | 261 | * Método que entrega rut del emisor del DTE |
| 262 | - * @return RUT del emiro |
|
| 262 | + * @return string del emiro |
|
| 263 | 263 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 264 | 264 | * @version 2015-09-07 |
| 265 | 265 | */ |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | |
| 276 | 276 | /** |
| 277 | 277 | * Método que entrega rut del receptor del DTE |
| 278 | - * @return RUT del emiro |
|
| 278 | + * @return string del emiro |
|
| 279 | 279 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 280 | 280 | * @version 2015-09-07 |
| 281 | 281 | */ |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | |
| 292 | 292 | /** |
| 293 | 293 | * Método que entrega fecha de emisión del DTE |
| 294 | - * @return Fecha de emisión en formato AAAA-MM-DD |
|
| 294 | + * @return string de emisión en formato AAAA-MM-DD |
|
| 295 | 295 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 296 | 296 | * @version 2015-09-07 |
| 297 | 297 | */ |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | |
| 401 | 401 | /** |
| 402 | 402 | * Método que realiza el timbrado del DTE |
| 403 | - * @param Folios Objeto de los Folios con los que se desea timbrar |
|
| 403 | + * @param Folios Folios de los Folios con los que se desea timbrar |
|
| 404 | 404 | * @return =true si se pudo timbrar o =false en caso de error |
| 405 | 405 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 406 | 406 | * @version 2016-09-01 |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | |
| 487 | 487 | /** |
| 488 | 488 | * Método que realiza la firma del DTE |
| 489 | - * @param Firma objeto que representa la Firma Electrónca |
|
| 489 | + * @param Firma \sasco\LibreDTE\FirmaElectronica que representa la Firma Electrónca |
|
| 490 | 490 | * @return =true si el DTE pudo ser fimado o =false si no se pudo firmar |
| 491 | 491 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 492 | 492 | * @version 2017-10-22 |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | |
| 510 | 510 | /** |
| 511 | 511 | * Método que entrega el DTE en XML |
| 512 | - * @return XML con el DTE (podría: con o sin timbre y con o sin firma) |
|
| 512 | + * @return string con el DTE (podría: con o sin timbre y con o sin firma) |
|
| 513 | 513 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 514 | 514 | * @version 2015-08-20 |
| 515 | 515 | */ |
@@ -1767,7 +1767,7 @@ discard block |
||
| 1767 | 1767 | * - Firma del DTE |
| 1768 | 1768 | * - RUT del emisor (si se pasó uno para comparar) |
| 1769 | 1769 | * - RUT del receptor (si se pasó uno para comparar) |
| 1770 | - * @return Código del estado de la validación |
|
| 1770 | + * @return integer del estado de la validación |
|
| 1771 | 1771 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1772 | 1772 | * @version 2019-07-03 |
| 1773 | 1773 | */ |
@@ -1880,7 +1880,7 @@ discard block |
||
| 1880 | 1880 | |
| 1881 | 1881 | /** |
| 1882 | 1882 | * Método que obtiene el estado del DTE |
| 1883 | - * @param Firma objeto que representa la Firma Electrónca |
|
| 1883 | + * @param Firma \sasco\LibreDTE\FirmaElectronica que representa la Firma Electrónca |
|
| 1884 | 1884 | * @return Arreglo con el estado del DTE |
| 1885 | 1885 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1886 | 1886 | * @version 2015-10-24 |
@@ -1921,7 +1921,7 @@ discard block |
||
| 1921 | 1921 | |
| 1922 | 1922 | /** |
| 1923 | 1923 | * Método que obtiene el estado avanzado del DTE |
| 1924 | - * @param Firma objeto que representa la Firma Electrónca |
|
| 1924 | + * @param Firma \sasco\LibreDTE\FirmaElectronica que representa la Firma Electrónca |
|
| 1925 | 1925 | * @return Arreglo con el estado del DTE |
| 1926 | 1926 | * @todo Corregir warning y también definir que se retornará (sobre todo en caso de error) |
| 1927 | 1927 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
@@ -57,10 +57,11 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | public function __construct($datos, $normalizar = true) |
| 59 | 59 | { |
| 60 | - if (is_array($datos)) |
|
| 61 | - $this->setDatos($datos, $normalizar); |
|
| 62 | - else if (is_string($datos)) |
|
| 63 | - $this->loadXML($datos); |
|
| 60 | + if (is_array($datos)) { |
|
| 61 | + $this->setDatos($datos, $normalizar); |
|
| 62 | + } else if (is_string($datos)) { |
|
| 63 | + $this->loadXML($datos); |
|
| 64 | + } |
|
| 64 | 65 | $this->timestamp = date('Y-m-d\TH:i:s'); |
| 65 | 66 | } |
| 66 | 67 | |
@@ -121,8 +122,9 @@ discard block |
||
| 121 | 122 | if ($normalizar) { |
| 122 | 123 | $this->normalizar($datos); |
| 123 | 124 | $method = 'normalizar_'.$this->tipo; |
| 124 | - if (method_exists($this, $method)) |
|
| 125 | - $this->$method($datos); |
|
| 125 | + if (method_exists($this, $method)) { |
|
| 126 | + $this->$method($datos); |
|
| 127 | + } |
|
| 126 | 128 | $this->normalizar_final($datos); |
| 127 | 129 | } |
| 128 | 130 | $this->tipo_general = $this->getTipoGeneral($this->tipo); |
@@ -199,8 +201,9 @@ discard block |
||
| 199 | 201 | */ |
| 200 | 202 | public function getJSON() |
| 201 | 203 | { |
| 202 | - if (!$this->getDatos()) |
|
| 203 | - return false; |
|
| 204 | + if (!$this->getDatos()) { |
|
| 205 | + return false; |
|
| 206 | + } |
|
| 204 | 207 | return json_encode($this->datos, JSON_PRETTY_PRINT); |
| 205 | 208 | } |
| 206 | 209 | |
@@ -225,9 +228,10 @@ discard block |
||
| 225 | 228 | */ |
| 226 | 229 | private function getTipoGeneral($dte) |
| 227 | 230 | { |
| 228 | - foreach ($this->tipos as $tipo => $codigos) |
|
| 229 | - if (in_array($dte, $codigos)) |
|
| 231 | + foreach ($this->tipos as $tipo => $codigos) { |
|
| 232 | + if (in_array($dte, $codigos)) |
|
| 230 | 233 | return $tipo; |
| 234 | + } |
|
| 231 | 235 | \sasco\LibreDTE\Log::write( |
| 232 | 236 | \sasco\LibreDTE\Estado::DTE_ERROR_TIPO, |
| 233 | 237 | \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::DTE_ERROR_TIPO, $dte) |
@@ -266,10 +270,12 @@ discard block |
||
| 266 | 270 | public function getEmisor() |
| 267 | 271 | { |
| 268 | 272 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Emisor/RUTEmisor')->item(0); |
| 269 | - if ($nodo) |
|
| 270 | - return $nodo->nodeValue; |
|
| 271 | - if (!$this->getDatos()) |
|
| 272 | - return false; |
|
| 273 | + if ($nodo) { |
|
| 274 | + return $nodo->nodeValue; |
|
| 275 | + } |
|
| 276 | + if (!$this->getDatos()) { |
|
| 277 | + return false; |
|
| 278 | + } |
|
| 273 | 279 | return $this->datos['Encabezado']['Emisor']['RUTEmisor']; |
| 274 | 280 | } |
| 275 | 281 | |
@@ -282,10 +288,12 @@ discard block |
||
| 282 | 288 | public function getReceptor() |
| 283 | 289 | { |
| 284 | 290 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Receptor/RUTRecep')->item(0); |
| 285 | - if ($nodo) |
|
| 286 | - return $nodo->nodeValue; |
|
| 287 | - if (!$this->getDatos()) |
|
| 288 | - return false; |
|
| 291 | + if ($nodo) { |
|
| 292 | + return $nodo->nodeValue; |
|
| 293 | + } |
|
| 294 | + if (!$this->getDatos()) { |
|
| 295 | + return false; |
|
| 296 | + } |
|
| 289 | 297 | return $this->datos['Encabezado']['Receptor']['RUTRecep']; |
| 290 | 298 | } |
| 291 | 299 | |
@@ -298,10 +306,12 @@ discard block |
||
| 298 | 306 | public function getFechaEmision() |
| 299 | 307 | { |
| 300 | 308 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/IdDoc/FchEmis')->item(0); |
| 301 | - if ($nodo) |
|
| 302 | - return $nodo->nodeValue; |
|
| 303 | - if (!$this->getDatos()) |
|
| 304 | - return false; |
|
| 309 | + if ($nodo) { |
|
| 310 | + return $nodo->nodeValue; |
|
| 311 | + } |
|
| 312 | + if (!$this->getDatos()) { |
|
| 313 | + return false; |
|
| 314 | + } |
|
| 305 | 315 | return $this->datos['Encabezado']['IdDoc']['FchEmis']; |
| 306 | 316 | } |
| 307 | 317 | |
@@ -314,10 +324,12 @@ discard block |
||
| 314 | 324 | public function getMontoTotal() |
| 315 | 325 | { |
| 316 | 326 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Totales/MntTotal')->item(0); |
| 317 | - if ($nodo) |
|
| 318 | - return $nodo->nodeValue; |
|
| 319 | - if (!$this->getDatos()) |
|
| 320 | - return false; |
|
| 327 | + if ($nodo) { |
|
| 328 | + return $nodo->nodeValue; |
|
| 329 | + } |
|
| 330 | + if (!$this->getDatos()) { |
|
| 331 | + return false; |
|
| 332 | + } |
|
| 321 | 333 | return $this->datos['Encabezado']['Totales']['MntTotal']; |
| 322 | 334 | } |
| 323 | 335 | |
@@ -330,10 +342,12 @@ discard block |
||
| 330 | 342 | public function getMoneda() |
| 331 | 343 | { |
| 332 | 344 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Totales/TpoMoneda')->item(0); |
| 333 | - if ($nodo) |
|
| 334 | - return $nodo->nodeValue; |
|
| 335 | - if (!$this->getDatos()) |
|
| 336 | - return false; |
|
| 345 | + if ($nodo) { |
|
| 346 | + return $nodo->nodeValue; |
|
| 347 | + } |
|
| 348 | + if (!$this->getDatos()) { |
|
| 349 | + return false; |
|
| 350 | + } |
|
| 337 | 351 | return $this->datos['Encabezado']['Totales']['TpoMoneda']; |
| 338 | 352 | } |
| 339 | 353 | |
@@ -376,8 +390,9 @@ discard block |
||
| 376 | 390 | return false;*/ |
| 377 | 391 | $xml = new \sasco\LibreDTE\XML(); |
| 378 | 392 | $TED = $this->xml->getElementsByTagName('TED')->item(0); |
| 379 | - if (!$TED) |
|
| 380 | - return '<TED/>'; |
|
| 393 | + if (!$TED) { |
|
| 394 | + return '<TED/>'; |
|
| 395 | + } |
|
| 381 | 396 | $xml->loadXML($TED->C14N()); |
| 382 | 397 | $xml->documentElement->removeAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi'); |
| 383 | 398 | $xml->documentElement->removeAttributeNS('http://www.sii.cl/SiiDte', ''); |
@@ -574,10 +589,12 @@ discard block |
||
| 574 | 589 | */ |
| 575 | 590 | private function calcularNetoIVA($total, $tasa = null) |
| 576 | 591 | { |
| 577 | - if ($tasa === 0 or $tasa === false) |
|
| 578 | - return [0, 0]; |
|
| 579 | - if ($tasa === null) |
|
| 580 | - $tasa = \sasco\LibreDTE\Sii::getIVA(); |
|
| 592 | + if ($tasa === 0 or $tasa === false) { |
|
| 593 | + return [0, 0]; |
|
| 594 | + } |
|
| 595 | + if ($tasa === null) { |
|
| 596 | + $tasa = \sasco\LibreDTE\Sii::getIVA(); |
|
| 597 | + } |
|
| 581 | 598 | // WARNING: el IVA obtenido puede no ser el NETO*(TASA/100) |
| 582 | 599 | // se calcula el monto neto y luego se obtiene el IVA haciendo la resta |
| 583 | 600 | // entre el total y el neto, ya que hay casos de borde como: |
@@ -693,8 +710,9 @@ discard block |
||
| 693 | 710 | } |
| 694 | 711 | // si existe descuento o recargo global se normalizan |
| 695 | 712 | if (!empty($datos['DscRcgGlobal'])) { |
| 696 | - if (!isset($datos['DscRcgGlobal'][0])) |
|
| 697 | - $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
| 713 | + if (!isset($datos['DscRcgGlobal'][0])) { |
|
| 714 | + $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
| 715 | + } |
|
| 698 | 716 | $NroLinDR = 1; |
| 699 | 717 | foreach ($datos['DscRcgGlobal'] as &$dr) { |
| 700 | 718 | $dr = array_merge([ |
@@ -1357,8 +1375,9 @@ discard block |
||
| 1357 | 1375 | */ |
| 1358 | 1376 | private function normalizar_detalle(array &$datos) |
| 1359 | 1377 | { |
| 1360 | - if (!isset($datos['Detalle'][0])) |
|
| 1361 | - $datos['Detalle'] = [$datos['Detalle']]; |
|
| 1378 | + if (!isset($datos['Detalle'][0])) { |
|
| 1379 | + $datos['Detalle'] = [$datos['Detalle']]; |
|
| 1380 | + } |
|
| 1362 | 1381 | $item = 1; |
| 1363 | 1382 | foreach ($datos['Detalle'] as &$d) { |
| 1364 | 1383 | $d = array_merge([ |
@@ -1420,8 +1439,9 @@ discard block |
||
| 1420 | 1439 | ]; |
| 1421 | 1440 | } |
| 1422 | 1441 | if ($d['PrcItem']) { |
| 1423 | - if (!$d['QtyItem']) |
|
| 1424 | - $d['QtyItem'] = 1; |
|
| 1442 | + if (!$d['QtyItem']) { |
|
| 1443 | + $d['QtyItem'] = 1; |
|
| 1444 | + } |
|
| 1425 | 1445 | if (empty($d['MontoItem'])) { |
| 1426 | 1446 | $d['MontoItem'] = $this->round( |
| 1427 | 1447 | $d['QtyItem'] * $d['PrcItem'], |
@@ -1487,8 +1507,9 @@ discard block |
||
| 1487 | 1507 | private function normalizar_aplicar_descuentos_recargos(array &$datos) |
| 1488 | 1508 | { |
| 1489 | 1509 | if (!empty($datos['DscRcgGlobal'])) { |
| 1490 | - if (!isset($datos['DscRcgGlobal'][0])) |
|
| 1491 | - $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
| 1510 | + if (!isset($datos['DscRcgGlobal'][0])) { |
|
| 1511 | + $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
| 1512 | + } |
|
| 1492 | 1513 | foreach ($datos['DscRcgGlobal'] as &$dr) { |
| 1493 | 1514 | $dr = array_merge([ |
| 1494 | 1515 | 'NroLinDR' => false, |
@@ -1555,8 +1576,9 @@ discard block |
||
| 1555 | 1576 | $montos = []; |
| 1556 | 1577 | foreach ($datos['Detalle'] as &$d) { |
| 1557 | 1578 | if (!empty($d['CodImpAdic'])) { |
| 1558 | - if (!isset($montos[$d['CodImpAdic']])) |
|
| 1559 | - $montos[$d['CodImpAdic']] = 0; |
|
| 1579 | + if (!isset($montos[$d['CodImpAdic']])) { |
|
| 1580 | + $montos[$d['CodImpAdic']] = 0; |
|
| 1581 | + } |
|
| 1560 | 1582 | $montos[$d['CodImpAdic']] += $d['MontoItem']; |
| 1561 | 1583 | } |
| 1562 | 1584 | } |
@@ -1635,10 +1657,12 @@ discard block |
||
| 1635 | 1657 | } |
| 1636 | 1658 | if (empty($datos['Encabezado']['Totales']['MntTotal'])) { |
| 1637 | 1659 | $datos['Encabezado']['Totales']['MntTotal'] = $datos['Encabezado']['Totales']['MntNeto']; |
| 1638 | - if (!empty($datos['Encabezado']['Totales']['IVA'])) |
|
| 1639 | - $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['IVA']; |
|
| 1640 | - if (!empty($datos['Encabezado']['Totales']['MntExe'])) |
|
| 1641 | - $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['MntExe']; |
|
| 1660 | + if (!empty($datos['Encabezado']['Totales']['IVA'])) { |
|
| 1661 | + $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['IVA']; |
|
| 1662 | + } |
|
| 1663 | + if (!empty($datos['Encabezado']['Totales']['MntExe'])) { |
|
| 1664 | + $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['MntExe']; |
|
| 1665 | + } |
|
| 1642 | 1666 | } |
| 1643 | 1667 | } else { |
| 1644 | 1668 | if (!$datos['Encabezado']['Totales']['MntTotal'] and !empty($datos['Encabezado']['Totales']['MntExe'])) { |
@@ -1664,8 +1688,10 @@ discard block |
||
| 1664 | 1688 | } |
| 1665 | 1689 | // si hay impuesto de crédito a constructoras del 65% se descuenta del total |
| 1666 | 1690 | if (!empty($datos['Encabezado']['Totales']['CredEC'])) { |
| 1667 | - if ($datos['Encabezado']['Totales']['CredEC']===true) |
|
| 1668 | - $datos['Encabezado']['Totales']['CredEC'] = round($datos['Encabezado']['Totales']['IVA'] * 0.65); // TODO: mover a constante o método |
|
| 1691 | + if ($datos['Encabezado']['Totales']['CredEC']===true) { |
|
| 1692 | + $datos['Encabezado']['Totales']['CredEC'] = round($datos['Encabezado']['Totales']['IVA'] * 0.65); |
|
| 1693 | + } |
|
| 1694 | + // TODO: mover a constante o método |
|
| 1669 | 1695 | $datos['Encabezado']['Totales']['MntTotal'] -= $datos['Encabezado']['Totales']['CredEC']; |
| 1670 | 1696 | } |
| 1671 | 1697 | } |
@@ -1889,12 +1915,14 @@ discard block |
||
| 1889 | 1915 | { |
| 1890 | 1916 | // solicitar token |
| 1891 | 1917 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma); |
| 1892 | - if (!$token) |
|
| 1893 | - return false; |
|
| 1918 | + if (!$token) { |
|
| 1919 | + return false; |
|
| 1920 | + } |
|
| 1894 | 1921 | // consultar estado dte |
| 1895 | 1922 | $run = $Firma->getID(); |
| 1896 | - if ($run===false) |
|
| 1897 | - return false; |
|
| 1923 | + if ($run===false) { |
|
| 1924 | + return false; |
|
| 1925 | + } |
|
| 1898 | 1926 | list($RutConsultante, $DvConsultante) = explode('-', $run); |
| 1899 | 1927 | list($RutCompania, $DvCompania) = explode('-', $this->getEmisor()); |
| 1900 | 1928 | list($RutReceptor, $DvReceptor) = explode('-', $this->getReceptor()); |
@@ -1913,8 +1941,9 @@ discard block |
||
| 1913 | 1941 | 'token' => $token, |
| 1914 | 1942 | ]); |
| 1915 | 1943 | // si el estado se pudo recuperar se muestra |
| 1916 | - if ($xml===false) |
|
| 1917 | - return false; |
|
| 1944 | + if ($xml===false) { |
|
| 1945 | + return false; |
|
| 1946 | + } |
|
| 1918 | 1947 | // entregar estado |
| 1919 | 1948 | return (array)$xml->xpath('/SII:RESPUESTA/SII:RESP_HDR')[0]; |
| 1920 | 1949 | } |
@@ -1931,8 +1960,9 @@ discard block |
||
| 1931 | 1960 | { |
| 1932 | 1961 | // solicitar token |
| 1933 | 1962 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma); |
| 1934 | - if (!$token) |
|
| 1935 | - return false; |
|
| 1963 | + if (!$token) { |
|
| 1964 | + return false; |
|
| 1965 | + } |
|
| 1936 | 1966 | // consultar estado dte |
| 1937 | 1967 | list($RutEmpresa, $DvEmpresa) = explode('-', $this->getEmisor()); |
| 1938 | 1968 | list($RutReceptor, $DvReceptor) = explode('-', $this->getReceptor()); |
@@ -1950,8 +1980,9 @@ discard block |
||
| 1950 | 1980 | 'token' => $token, |
| 1951 | 1981 | ]); |
| 1952 | 1982 | // si el estado se pudo recuperar se muestra |
| 1953 | - if ($xml===false) |
|
| 1954 | - return false; |
|
| 1983 | + if ($xml===false) { |
|
| 1984 | + return false; |
|
| 1985 | + } |
|
| 1955 | 1986 | // entregar estado |
| 1956 | 1987 | return (array)$xml->xpath('/SII:RESPUESTA/SII:RESP_BODY')[0]; |
| 1957 | 1988 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | /** |
| 78 | 78 | * Método que asigna la ubicación del logo de la empresa |
| 79 | 79 | * @param logo URI del logo (puede ser local o en una URL) |
| 80 | - * @param posicion Posición respecto a datos del emisor (=0 izq, =1 arriba) |
|
| 80 | + * @param posicion integer respecto a datos del emisor (=0 izq, =1 arriba) |
|
| 81 | 81 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 82 | 82 | * @version 2016-08-04 |
| 83 | 83 | */ |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | * contínuo |
| 222 | 222 | * @param dte Arreglo con los datos del XML (tag Documento) |
| 223 | 223 | * @param timbre String XML con el tag TED del DTE |
| 224 | - * @param width Ancho del papel contínuo en mm |
|
| 224 | + * @param width boolean del papel contínuo en mm |
|
| 225 | 225 | * @author Pablo Reyes (https://github.com/pabloxp) |
| 226 | 226 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 227 | 227 | * @version 2017-10-24 |
@@ -383,10 +383,11 @@ discard block |
||
| 383 | 383 | * - Dirección casa central del emisor |
| 384 | 384 | * - Dirección sucursales |
| 385 | 385 | * @param emisor Arreglo con los datos del emisor (tag Emisor del XML) |
| 386 | - * @param x Posición horizontal de inicio en el PDF |
|
| 387 | - * @param y Posición vertical de inicio en el PDF |
|
| 388 | - * @param w Ancho de la información del emisor |
|
| 389 | - * @param w_img Ancho máximo de la imagen |
|
| 386 | + * @param x integer horizontal de inicio en el PDF |
|
| 387 | + * @param y integer vertical de inicio en el PDF |
|
| 388 | + * @param w integer de la información del emisor |
|
| 389 | + * @param w_img integer máximo de la imagen |
|
| 390 | + * @param integer $font_size |
|
| 390 | 391 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 391 | 392 | * @version 2018-06-15 |
| 392 | 393 | */ |
@@ -460,11 +461,13 @@ discard block |
||
| 460 | 461 | * @param rut RUT del emisor |
| 461 | 462 | * @param tipo Código o glosa del tipo de documento |
| 462 | 463 | * @param sucursal_sii Código o glosa de la sucursal del SII del Emisor |
| 463 | - * @param x Posición horizontal de inicio en el PDF |
|
| 464 | - * @param y Posición vertical de inicio en el PDF |
|
| 465 | - * @param w Ancho de la información del emisor |
|
| 464 | + * @param x integer horizontal de inicio en el PDF |
|
| 465 | + * @param y integer vertical de inicio en el PDF |
|
| 466 | + * @param w integer de la información del emisor |
|
| 467 | + * @param integer $font_size |
|
| 466 | 468 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 467 | 469 | * @version 2016-12-02 |
| 470 | + * @return integer |
|
| 468 | 471 | */ |
| 469 | 472 | protected function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
| 470 | 473 | { |
@@ -496,7 +499,7 @@ discard block |
||
| 496 | 499 | * Método que agrega los datos de la emisión del DTE que no son los dato del |
| 497 | 500 | * receptor |
| 498 | 501 | * @param IdDoc Información general del documento |
| 499 | - * @param x Posición horizontal de inicio en el PDF |
|
| 502 | + * @param x integer horizontal de inicio en el PDF |
|
| 500 | 503 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 501 | 504 | * @version 2017-06-15 |
| 502 | 505 | */ |
@@ -584,7 +587,7 @@ discard block |
||
| 584 | 587 | /** |
| 585 | 588 | * Método que agrega los datos del receptor |
| 586 | 589 | * @param receptor Arreglo con los datos del receptor (tag Receptor del XML) |
| 587 | - * @param x Posición horizontal de inicio en el PDF |
|
| 590 | + * @param x integer horizontal de inicio en el PDF |
|
| 588 | 591 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 589 | 592 | * @version 2019-02-13 |
| 590 | 593 | */ |
@@ -671,7 +674,7 @@ discard block |
||
| 671 | 674 | * Método que agrega los datos del traslado |
| 672 | 675 | * @param IndTraslado |
| 673 | 676 | * @param Transporte |
| 674 | - * @param x Posición horizontal de inicio en el PDF |
|
| 677 | + * @param x integer horizontal de inicio en el PDF |
|
| 675 | 678 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 676 | 679 | * @version 2016-08-03 |
| 677 | 680 | */ |
@@ -742,7 +745,7 @@ discard block |
||
| 742 | 745 | /** |
| 743 | 746 | * Método que agrega las referencias del documento |
| 744 | 747 | * @param referencias Arreglo con las referencias del documento (tag Referencia del XML) |
| 745 | - * @param x Posición horizontal de inicio en el PDF |
|
| 748 | + * @param x integer horizontal de inicio en el PDF |
|
| 746 | 749 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 747 | 750 | * @version 2017-09-25 |
| 748 | 751 | */ |
@@ -779,7 +782,7 @@ discard block |
||
| 779 | 782 | /** |
| 780 | 783 | * Método que agrega el detalle del documento |
| 781 | 784 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
| 782 | - * @param x Posición horizontal de inicio en el PDF |
|
| 785 | + * @param x integer horizontal de inicio en el PDF |
|
| 783 | 786 | * @param y Posición vertical de inicio en el PDF |
| 784 | 787 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 785 | 788 | * @version 2018-11-04 |
@@ -859,7 +862,7 @@ discard block |
||
| 859 | 862 | /** |
| 860 | 863 | * Método que agrega el detalle del documento |
| 861 | 864 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
| 862 | - * @param x Posición horizontal de inicio en el PDF |
|
| 865 | + * @param x integer horizontal de inicio en el PDF |
|
| 863 | 866 | * @param y Posición vertical de inicio en el PDF |
| 864 | 867 | * @author Pablo Reyes (https://github.com/pabloxp) |
| 865 | 868 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
@@ -895,7 +898,7 @@ discard block |
||
| 895 | 898 | * Método que agrega el subtotal del DTE |
| 896 | 899 | * @param detalle Arreglo con los detalles del documentos para poder |
| 897 | 900 | * calcular subtotal |
| 898 | - * @param x Posición horizontal de inicio en el PDF |
|
| 901 | + * @param x integer horizontal de inicio en el PDF |
|
| 899 | 902 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 900 | 903 | * @version 2016-08-17 |
| 901 | 904 | */ |
@@ -921,7 +924,7 @@ discard block |
||
| 921 | 924 | /** |
| 922 | 925 | * Método que agrega los descuentos y/o recargos globales del documento |
| 923 | 926 | * @param descuentosRecargos Arreglo con los descuentos y/o recargos del documento (tag DscRcgGlobal del XML) |
| 924 | - * @param x Posición horizontal de inicio en el PDF |
|
| 927 | + * @param x integer horizontal de inicio en el PDF |
|
| 925 | 928 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 926 | 929 | * @version 2018-05-29 |
| 927 | 930 | */ |
@@ -949,7 +952,7 @@ discard block |
||
| 949 | 952 | /** |
| 950 | 953 | * Método que agrega los pagos del documento |
| 951 | 954 | * @param pagos Arreglo con los pagos del documento |
| 952 | - * @param x Posición horizontal de inicio en el PDF |
|
| 955 | + * @param x integer horizontal de inicio en el PDF |
|
| 953 | 956 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 954 | 957 | * @version 2016-07-24 |
| 955 | 958 | */ |
@@ -1107,9 +1110,9 @@ discard block |
||
| 1107 | 1110 | * - Se imprime en el tamaño mínimo: 2x5 cms |
| 1108 | 1111 | * - En el lado de abajo con margen izquierdo mínimo de 2 cms |
| 1109 | 1112 | * @param timbre String con los datos del timbre |
| 1110 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1111 | - * @param y Posición vertical de inicio en el PDF |
|
| 1112 | - * @param w Ancho del timbre |
|
| 1113 | + * @param x integer horizontal de inicio en el PDF |
|
| 1114 | + * @param y integer vertical de inicio en el PDF |
|
| 1115 | + * @param w integer del timbre |
|
| 1113 | 1116 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1114 | 1117 | * @version 2018-04-12 |
| 1115 | 1118 | */ |
@@ -1147,10 +1150,10 @@ discard block |
||
| 1147 | 1150 | |
| 1148 | 1151 | /** |
| 1149 | 1152 | * Método que agrega el acuse de rebido |
| 1150 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1151 | - * @param y Posición vertical de inicio en el PDF |
|
| 1152 | - * @param w Ancho del acuse de recibo |
|
| 1153 | - * @param h Alto del acuse de recibo |
|
| 1153 | + * @param x integer horizontal de inicio en el PDF |
|
| 1154 | + * @param y integer vertical de inicio en el PDF |
|
| 1155 | + * @param w integer del acuse de recibo |
|
| 1156 | + * @param h integer del acuse de recibo |
|
| 1154 | 1157 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 1155 | 1158 | * @version 2018-04-13 |
| 1156 | 1159 | */ |
@@ -1178,10 +1181,10 @@ discard block |
||
| 1178 | 1181 | |
| 1179 | 1182 | /** |
| 1180 | 1183 | * Método que agrega el acuse de rebido |
| 1181 | - * @param x Posición horizontal de inicio en el PDF |
|
| 1184 | + * @param x integer horizontal de inicio en el PDF |
|
| 1182 | 1185 | * @param y Posición vertical de inicio en el PDF |
| 1183 | - * @param w Ancho del acuse de recibo |
|
| 1184 | - * @param h Alto del acuse de recibo |
|
| 1186 | + * @param w integer del acuse de recibo |
|
| 1187 | + * @param h integer del acuse de recibo |
|
| 1185 | 1188 | * @author Pablo Reyes (https://github.com/pabloxp) |
| 1186 | 1189 | * @version 2015-11-17 |
| 1187 | 1190 | */ |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | { |
| 72 | 72 | parent::__construct(); |
| 73 | 73 | $this->SetTitle('Documento Tributario Electrónico (DTE) de Chile by LibreDTE'); |
| 74 | - $this->papelContinuo = $papelContinuo === true ? 80 : $papelContinuo; |
|
| 74 | + $this->papelContinuo = $papelContinuo===true ? 80 : $papelContinuo; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | $this->setY(max($y)); |
| 182 | 182 | $this->Ln(); |
| 183 | 183 | $y = []; |
| 184 | - $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null); |
|
| 184 | + $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null); |
|
| 185 | 185 | $y[] = $this->agregarReceptor($dte['Encabezado']); |
| 186 | 186 | $this->setY(max($y)); |
| 187 | 187 | $this->agregarTraslado( |
@@ -241,15 +241,15 @@ discard block |
||
| 241 | 241 | $dte['Encabezado']['IdDoc']['TipoDTE'], |
| 242 | 242 | $dte['Encabezado']['IdDoc']['Folio'], |
| 243 | 243 | $dte['Encabezado']['Emisor']['CmnaOrigen'], |
| 244 | - $x_start, $y_start, $width-($x_start*4), 10, |
|
| 245 | - [0,0,0] |
|
| 244 | + $x_start, $y_start, $width-($x_start * 4), 10, |
|
| 245 | + [0, 0, 0] |
|
| 246 | 246 | ); |
| 247 | - $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, $width-($x_start*45), 8, 9, [0,0,0]); |
|
| 247 | + $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, $width-($x_start * 45), 8, 9, [0, 0, 0]); |
|
| 248 | 248 | // datos del documento |
| 249 | 249 | $this->SetY($y); |
| 250 | 250 | $this->Ln(); |
| 251 | 251 | $this->setFont('', '', 8); |
| 252 | - $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null, $x_start, $offset, false); |
|
| 252 | + $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null, $x_start, $offset, false); |
|
| 253 | 253 | $this->agregarReceptor($dte['Encabezado'], $x_start, $offset); |
| 254 | 254 | $this->agregarTraslado( |
| 255 | 255 | !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null, |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | $this->AddPage('P', [$height ? $height : $this->papel_continuo_alto, $width]); |
| 303 | 303 | $x = 1; |
| 304 | 304 | $y = 5; |
| 305 | - $this->SetXY($x,$y); |
|
| 305 | + $this->SetXY($x, $y); |
|
| 306 | 306 | // agregar datos del documento |
| 307 | 307 | $this->setFont('', '', 8); |
| 308 | 308 | $this->MultiTexto(!empty($dte['Encabezado']['Emisor']['RznSoc']) ? $dte['Encabezado']['Emisor']['RznSoc'] : $dte['Encabezado']['Emisor']['RznSocEmisor'], $x, null, '', $width-2); |
@@ -398,13 +398,13 @@ discard block |
||
| 398 | 398 | $this->logo['uri'], |
| 399 | 399 | $x, |
| 400 | 400 | $y, |
| 401 | - !$this->logo['posicion']?$w_img:null, $this->logo['posicion']?($w_img/2):null, |
|
| 401 | + !$this->logo['posicion'] ? $w_img : null, $this->logo['posicion'] ? ($w_img / 2) : null, |
|
| 402 | 402 | 'PNG', |
| 403 | - (isset($emisor['url'])?$emisor['url']:''), |
|
| 403 | + (isset($emisor['url']) ? $emisor['url'] : ''), |
|
| 404 | 404 | 'T' |
| 405 | 405 | ); |
| 406 | 406 | if ($this->logo['posicion']) { |
| 407 | - $this->SetY($this->y + ($w_img/2)); |
|
| 407 | + $this->SetY($this->y+($w_img / 2)); |
|
| 408 | 408 | $w += 40; |
| 409 | 409 | } else { |
| 410 | 410 | $x = $this->x+3; |
@@ -415,14 +415,14 @@ discard block |
||
| 415 | 415 | } |
| 416 | 416 | // agregar datos del emisor |
| 417 | 417 | $this->setFont('', 'B', $font_size ? $font_size : 14); |
| 418 | - $this->SetTextColorArray($color===null?[32, 92, 144]:$color); |
|
| 418 | + $this->SetTextColorArray($color===null ? [32, 92, 144] : $color); |
|
| 419 | 419 | $this->MultiTexto(!empty($emisor['RznSoc']) ? $emisor['RznSoc'] : $emisor['RznSocEmisor'], $x, $this->y+2, 'L', $w); |
| 420 | 420 | $this->setFont('', 'B', $font_size ? $font_size : 9); |
| 421 | - $this->SetTextColorArray([0,0,0]); |
|
| 421 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 422 | 422 | $this->MultiTexto(!empty($emisor['GiroEmis']) ? $emisor['GiroEmis'] : $emisor['GiroEmisor'], $x, $this->y, 'L', $w); |
| 423 | 423 | $comuna = !empty($emisor['CmnaOrigen']) ? $emisor['CmnaOrigen'] : null; |
| 424 | 424 | $ciudad = !empty($emisor['CiudadOrigen']) ? $emisor['CiudadOrigen'] : \sasco\LibreDTE\Chile::getCiudad($comuna); |
| 425 | - $this->MultiTexto($emisor['DirOrigen'].($comuna?(', '.$comuna):'').($ciudad?(', '.$ciudad):''), $x, $this->y, 'L', $w); |
|
| 425 | + $this->MultiTexto($emisor['DirOrigen'].($comuna ? (', '.$comuna) : '').($ciudad ? (', '.$ciudad) : ''), $x, $this->y, 'L', $w); |
|
| 426 | 426 | if (!empty($emisor['Sucursal'])) { |
| 427 | 427 | $this->MultiTexto('Sucursal: '.$emisor['Sucursal'], $x, $this->y, 'L', $w); |
| 428 | 428 | } |
@@ -469,12 +469,12 @@ discard block |
||
| 469 | 469 | protected function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
| 470 | 470 | { |
| 471 | 471 | if ($color===null) { |
| 472 | - $color = $tipo ? ($tipo==52 ? [0,172,140] : [255,0,0]) : [0,0,0]; |
|
| 472 | + $color = $tipo ? ($tipo==52 ? [0, 172, 140] : [255, 0, 0]) : [0, 0, 0]; |
|
| 473 | 473 | } |
| 474 | 474 | $this->SetTextColorArray($color); |
| 475 | 475 | // colocar rut emisor, glosa documento y folio |
| 476 | 476 | list($rut, $dv) = explode('-', $rut); |
| 477 | - $this->setFont ('', 'B', $font_size ? $font_size : 15); |
|
| 477 | + $this->setFont('', 'B', $font_size ? $font_size : 15); |
|
| 478 | 478 | $this->MultiTexto('R.U.T.: '.$this->num($rut).'-'.$dv, $x, $y+4, 'C', $w); |
| 479 | 479 | $this->setFont('', 'B', $font_size ? $font_size : 12); |
| 480 | 480 | $this->MultiTexto($this->getTipo($tipo), $x, null, 'C', $w); |
@@ -487,7 +487,7 @@ discard block |
||
| 487 | 487 | if ($tipo) { |
| 488 | 488 | $this->Texto('S.I.I. - '.\sasco\LibreDTE\Sii::getDireccionRegional($sucursal_sii), $x, $this->getY()+4, 'C', $w); |
| 489 | 489 | } |
| 490 | - $this->SetTextColorArray([0,0,0]); |
|
| 490 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 491 | 491 | $this->Ln(); |
| 492 | 492 | return $this->y; |
| 493 | 493 | } |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | $this->Texto(in_array($this->dte, [39, 41]) ? 'Nombre' : 'Razón social', $x); |
| 605 | 605 | $this->Texto(':', $x+$offset); |
| 606 | 606 | $this->setFont('', '', null); |
| 607 | - $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
| 607 | + $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
| 608 | 608 | } |
| 609 | 609 | if (!empty($receptor['GiroRecep'])) { |
| 610 | 610 | $this->setFont('', 'B', null); |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | $ciudad = !empty($receptor['CiudadRecep']) ? $receptor['CiudadRecep'] : ( |
| 622 | 622 | !empty($receptor['CmnaRecep']) ? \sasco\LibreDTE\Chile::getCiudad($receptor['CmnaRecep']) : '' |
| 623 | 623 | ); |
| 624 | - $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep'])?(', '.$receptor['CmnaRecep']):'').($ciudad?(', '.$ciudad):''), $x+$offset+2); |
|
| 624 | + $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep']) ? (', '.$receptor['CmnaRecep']) : '').($ciudad ? (', '.$ciudad) : ''), $x+$offset+2); |
|
| 625 | 625 | } |
| 626 | 626 | if (!empty($receptor['Extranjero']['Nacionalidad'])) { |
| 627 | 627 | $this->setFont('', 'B', null); |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | $this->Texto('Cód. recep.', $x); |
| 663 | 663 | $this->Texto(':', $x+$offset); |
| 664 | 664 | $this->setFont('', '', null); |
| 665 | - $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
| 665 | + $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
| 666 | 666 | } |
| 667 | 667 | return $this->GetY(); |
| 668 | 668 | } |
@@ -750,7 +750,7 @@ discard block |
||
| 750 | 750 | { |
| 751 | 751 | if (!isset($referencias[0])) |
| 752 | 752 | $referencias = [$referencias]; |
| 753 | - foreach($referencias as $r) { |
|
| 753 | + foreach ($referencias as $r) { |
|
| 754 | 754 | $texto = $r['NroLinRef'].' - '; |
| 755 | 755 | if (!empty($r['TpoDocRef'])) { |
| 756 | 756 | $texto .= $this->getTipo($r['TpoDocRef']).' '; |
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | // quitar columnas |
| 802 | 802 | foreach ($item as $col => $valor) { |
| 803 | 803 | if ($col=='DscItem' and !empty($item['DscItem'])) { |
| 804 | - $item['NmbItem'] .= !$this->item_detalle_posicion ? ($html?'<br/>':"\n") : ': '; |
|
| 804 | + $item['NmbItem'] .= !$this->item_detalle_posicion ? ($html ? '<br/>' : "\n") : ': '; |
|
| 805 | 805 | if ($html) { |
| 806 | 806 | $item['NmbItem'] .= '<span style="font-size:0.7em">'.$item['DscItem'].'</span>'; |
| 807 | 807 | } else { |
@@ -831,7 +831,7 @@ discard block |
||
| 831 | 831 | $item_default[$key] = false; |
| 832 | 832 | $item = array_merge($item_default, $item); |
| 833 | 833 | // si hay código de item se extrae su valor |
| 834 | - if (!empty($item['CdgItem']['VlrCodigo'])){ |
|
| 834 | + if (!empty($item['CdgItem']['VlrCodigo'])) { |
|
| 835 | 835 | $item['CdgItem'] = $item['CdgItem']['VlrCodigo']; |
| 836 | 836 | } |
| 837 | 837 | // dar formato a números |
@@ -870,9 +870,9 @@ discard block |
||
| 870 | 870 | $this->SetY($this->getY()+1); |
| 871 | 871 | $p1x = $x; |
| 872 | 872 | $p1y = $this->y; |
| 873 | - $p2x = $this->getPageWidth() - 2; |
|
| 874 | - $p2y = $p1y; // Use same y for a straight line |
|
| 875 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
| 873 | + $p2x = $this->getPageWidth()-2; |
|
| 874 | + $p2y = $p1y; // Use same y for a straight line |
|
| 875 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
| 876 | 876 | $this->Line($p1x, $p1y, $p2x, $p2y, $style); |
| 877 | 877 | $this->Texto($this->detalle_cols['NmbItem']['title'], $x+1, $this->y, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
| 878 | 878 | $this->Texto($this->detalle_cols['PrcItem']['title'], $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
@@ -882,9 +882,9 @@ discard block |
||
| 882 | 882 | if (!isset($detalle[0])) |
| 883 | 883 | $detalle = [$detalle]; |
| 884 | 884 | $this->SetY($this->getY()+2); |
| 885 | - foreach($detalle as &$d) { |
|
| 885 | + foreach ($detalle as &$d) { |
|
| 886 | 886 | $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
| 887 | - $this->Texto(number_format($d['PrcItem'],0,',','.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
| 887 | + $this->Texto(number_format($d['PrcItem'], 0, ',', '.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
| 888 | 888 | $this->Texto($this->num($d['QtyItem']), $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']); |
| 889 | 889 | $this->Texto($this->num($d['MontoItem']), $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']); |
| 890 | 890 | } |
@@ -904,7 +904,7 @@ discard block |
||
| 904 | 904 | if (!isset($detalle[0])) { |
| 905 | 905 | $detalle = [$detalle]; |
| 906 | 906 | } |
| 907 | - foreach($detalle as &$d) { |
|
| 907 | + foreach ($detalle as &$d) { |
|
| 908 | 908 | if (!empty($d['MontoItem'])) { |
| 909 | 909 | $subtotal += $d['MontoItem']; |
| 910 | 910 | } |
@@ -930,16 +930,16 @@ discard block |
||
| 930 | 930 | if (!isset($descuentosRecargos[0])) { |
| 931 | 931 | $descuentosRecargos = [$descuentosRecargos]; |
| 932 | 932 | } |
| 933 | - foreach($descuentosRecargos as $dr) { |
|
| 933 | + foreach ($descuentosRecargos as $dr) { |
|
| 934 | 934 | $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo'; |
| 935 | 935 | if (!empty($dr['IndExeDR'])) { |
| 936 | 936 | $tipo .= ' EX'; |
| 937 | 937 | } |
| 938 | 938 | $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : $this->num($dr['ValorDR']); |
| 939 | 939 | if ($this->papelContinuo) { |
| 940 | - $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):''), $x); |
|
| 940 | + $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : ''), $x); |
|
| 941 | 941 | } else { |
| 942 | - $this->Texto($tipo.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):'').':', 77, null, 'R', 100); |
|
| 942 | + $this->Texto($tipo.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : '').':', 77, null, 'R', 100); |
|
| 943 | 943 | $this->Texto($valor, 177, null, 'R', 22); |
| 944 | 944 | } |
| 945 | 945 | $this->Ln(); |
@@ -959,8 +959,8 @@ discard block |
||
| 959 | 959 | $pagos = [$pagos]; |
| 960 | 960 | $this->Texto('Pago(s) programado(s):', $x); |
| 961 | 961 | $this->Ln(); |
| 962 | - foreach($pagos as $p) { |
|
| 963 | - $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos'])?(' ('.$p['GlosaPagos'].')'):''), $x); |
|
| 962 | + foreach ($pagos as $p) { |
|
| 963 | + $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos']) ? (' ('.$p['GlosaPagos'].')') : ''), $x); |
|
| 964 | 964 | $this->Ln(); |
| 965 | 965 | } |
| 966 | 966 | } |
@@ -1011,7 +1011,7 @@ discard block |
||
| 1011 | 1011 | if (!isset($ImptoReten[0])) { |
| 1012 | 1012 | $ImptoReten = [$ImptoReten]; |
| 1013 | 1013 | } |
| 1014 | - foreach($ImptoReten as $i) { |
|
| 1014 | + foreach ($ImptoReten as $i) { |
|
| 1015 | 1015 | $totales['ImptoReten_'.$i['TipoImp']] = $i['MontoImp']; |
| 1016 | 1016 | if (!empty($i['TasaImp'])) { |
| 1017 | 1017 | $glosas['ImptoReten_'.$i['TipoImp']] = \sasco\LibreDTE\Sii\ImpuestosAdicionales::getGlosa($i['TipoImp']).' ('.$i['TasaImp'].'%) $'; |
@@ -1124,7 +1124,7 @@ discard block |
||
| 1124 | 1124 | 'vpadding' => 0, |
| 1125 | 1125 | 'module_width' => 1, // width of a single module in points |
| 1126 | 1126 | 'module_height' => 1, // height of a single module in points |
| 1127 | - 'fgcolor' => [0,0,0], |
|
| 1127 | + 'fgcolor' => [0, 0, 0], |
|
| 1128 | 1128 | 'bgcolor' => false, // [255,255,255] |
| 1129 | 1129 | 'position' => $this->papelContinuo ? 'C' : 'S', |
| 1130 | 1130 | ]; |
@@ -1157,7 +1157,7 @@ discard block |
||
| 1157 | 1157 | protected function agregarAcuseRecibo($x = 83, $y = 190, $w = 60, $h = 40) |
| 1158 | 1158 | { |
| 1159 | 1159 | $y = (!$this->papelContinuo and !$this->timbre_pie) ? $this->x_fin_datos : $y; |
| 1160 | - $this->SetTextColorArray([0,0,0]); |
|
| 1160 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 1161 | 1161 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
| 1162 | 1162 | $this->setFont('', 'B', 10); |
| 1163 | 1163 | $this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1187,9 +1187,9 @@ discard block |
||
| 1187 | 1187 | */ |
| 1188 | 1188 | protected function agregarAcuseReciboContinuo($x = 3, $y = null, $w = 68, $h = 40) |
| 1189 | 1189 | { |
| 1190 | - $this->SetTextColorArray([0,0,0]); |
|
| 1190 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 1191 | 1191 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
| 1192 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
| 1192 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
| 1193 | 1193 | $this->Line($x, $y+22, $w+3, $y+22, $style); |
| 1194 | 1194 | //$this->setFont('', 'B', 10); |
| 1195 | 1195 | //$this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1219,7 +1219,7 @@ discard block |
||
| 1219 | 1219 | $y = (!$this->papelContinuo and !$this->timbre_pie and $this->x_fin_datos<=$y) ? $this->x_fin_datos : $y; |
| 1220 | 1220 | $y += 48; |
| 1221 | 1221 | $this->setFont('', 'B', $font_size); |
| 1222 | - $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $y, 'R'); |
|
| 1222 | + $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $y, 'R'); |
|
| 1223 | 1223 | } |
| 1224 | 1224 | |
| 1225 | 1225 | /** |
@@ -1230,7 +1230,7 @@ discard block |
||
| 1230 | 1230 | protected function agregarLeyendaDestinoContinuo($tipo) |
| 1231 | 1231 | { |
| 1232 | 1232 | $this->setFont('', 'B', 8); |
| 1233 | - $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $this->y+6, 'R'); |
|
| 1233 | + $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $this->y+6, 'R'); |
|
| 1234 | 1234 | } |
| 1235 | 1235 | |
| 1236 | 1236 | } |
@@ -431,10 +431,12 @@ discard block |
||
| 431 | 431 | } |
| 432 | 432 | $contacto = []; |
| 433 | 433 | if (!empty($emisor['Telefono'])) { |
| 434 | - if (!is_array($emisor['Telefono'])) |
|
| 435 | - $emisor['Telefono'] = [$emisor['Telefono']]; |
|
| 436 | - foreach ($emisor['Telefono'] as $t) |
|
| 437 | - $contacto[] = $t; |
|
| 434 | + if (!is_array($emisor['Telefono'])) { |
|
| 435 | + $emisor['Telefono'] = [$emisor['Telefono']]; |
|
| 436 | + } |
|
| 437 | + foreach ($emisor['Telefono'] as $t) { |
|
| 438 | + $contacto[] = $t; |
|
| 439 | + } |
|
| 438 | 440 | } |
| 439 | 441 | if (!empty($emisor['CorreoEmisor'])) { |
| 440 | 442 | $contacto[] = $emisor['CorreoEmisor']; |
@@ -638,10 +640,12 @@ discard block |
||
| 638 | 640 | $this->MultiTexto($receptor['Extranjero']['NumId'], $x+$offset+2); |
| 639 | 641 | } |
| 640 | 642 | $contacto = []; |
| 641 | - if (!empty($receptor['Contacto'])) |
|
| 642 | - $contacto[] = $receptor['Contacto']; |
|
| 643 | - if (!empty($receptor['CorreoRecep'])) |
|
| 644 | - $contacto[] = $receptor['CorreoRecep']; |
|
| 643 | + if (!empty($receptor['Contacto'])) { |
|
| 644 | + $contacto[] = $receptor['Contacto']; |
|
| 645 | + } |
|
| 646 | + if (!empty($receptor['CorreoRecep'])) { |
|
| 647 | + $contacto[] = $receptor['CorreoRecep']; |
|
| 648 | + } |
|
| 645 | 649 | if (!empty($contacto)) { |
| 646 | 650 | $this->setFont('', 'B', null); |
| 647 | 651 | $this->Texto('Contacto', $x); |
@@ -691,15 +695,19 @@ discard block |
||
| 691 | 695 | if (!empty($Transporte['DirDest']) and !empty($Transporte['CmnaDest'])) { |
| 692 | 696 | $transporte .= 'a '.$Transporte['DirDest'].', '.$Transporte['CmnaDest']; |
| 693 | 697 | } |
| 694 | - if (!empty($Transporte['RUTTrans'])) |
|
| 695 | - $transporte .= ' por '.$Transporte['RUTTrans']; |
|
| 696 | - if (!empty($Transporte['Patente'])) |
|
| 697 | - $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
| 698 | + if (!empty($Transporte['RUTTrans'])) { |
|
| 699 | + $transporte .= ' por '.$Transporte['RUTTrans']; |
|
| 700 | + } |
|
| 701 | + if (!empty($Transporte['Patente'])) { |
|
| 702 | + $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
| 703 | + } |
|
| 698 | 704 | if (isset($Transporte['Chofer']) and is_array($Transporte['Chofer'])) { |
| 699 | - if (!empty($Transporte['Chofer']['NombreChofer'])) |
|
| 700 | - $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer']; |
|
| 701 | - if (!empty($Transporte['Chofer']['RUTChofer'])) |
|
| 702 | - $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')'; |
|
| 705 | + if (!empty($Transporte['Chofer']['NombreChofer'])) { |
|
| 706 | + $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer']; |
|
| 707 | + } |
|
| 708 | + if (!empty($Transporte['Chofer']['RUTChofer'])) { |
|
| 709 | + $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')'; |
|
| 710 | + } |
|
| 703 | 711 | } |
| 704 | 712 | if ($transporte) { |
| 705 | 713 | $this->setFont('', 'B', null); |
@@ -713,8 +721,9 @@ discard block |
||
| 713 | 721 | if (!empty($Transporte['Aduana']) and is_array($Transporte['Aduana'])) { |
| 714 | 722 | $col = 0; |
| 715 | 723 | foreach ($Transporte['Aduana'] as $tag => $codigo) { |
| 716 | - if ($codigo===false) |
|
| 717 | - continue; |
|
| 724 | + if ($codigo===false) { |
|
| 725 | + continue; |
|
| 726 | + } |
|
| 718 | 727 | $glosa = \sasco\LibreDTE\Sii\Aduana::getGlosa($tag); |
| 719 | 728 | $valor = \sasco\LibreDTE\Sii\Aduana::getValor($tag, $codigo); |
| 720 | 729 | if ($glosa!==false and $valor!==false) { |
@@ -727,15 +736,18 @@ discard block |
||
| 727 | 736 | $this->Texto(':', $x+$offset+$col); |
| 728 | 737 | $this->setFont('', '', null); |
| 729 | 738 | $this->Texto($valor, $x+$offset+2+$col); |
| 730 | - if ($tag=='TipoBultos') |
|
| 731 | - $col = abs($col-110); |
|
| 732 | - if ($col) |
|
| 733 | - $this->Ln(); |
|
| 739 | + if ($tag=='TipoBultos') { |
|
| 740 | + $col = abs($col-110); |
|
| 741 | + } |
|
| 742 | + if ($col) { |
|
| 743 | + $this->Ln(); |
|
| 744 | + } |
|
| 734 | 745 | $col = abs($col-110); |
| 735 | 746 | } |
| 736 | 747 | } |
| 737 | - if ($col) |
|
| 738 | - $this->Ln(); |
|
| 748 | + if ($col) { |
|
| 749 | + $this->Ln(); |
|
| 750 | + } |
|
| 739 | 751 | } |
| 740 | 752 | } |
| 741 | 753 | |
@@ -748,8 +760,9 @@ discard block |
||
| 748 | 760 | */ |
| 749 | 761 | protected function agregarReferencia($referencias, $x = 10, $offset = 22) |
| 750 | 762 | { |
| 751 | - if (!isset($referencias[0])) |
|
| 752 | - $referencias = [$referencias]; |
|
| 763 | + if (!isset($referencias[0])) { |
|
| 764 | + $referencias = [$referencias]; |
|
| 765 | + } |
|
| 753 | 766 | foreach($referencias as $r) { |
| 754 | 767 | $texto = $r['NroLinRef'].' - '; |
| 755 | 768 | if (!empty($r['TpoDocRef'])) { |
@@ -786,8 +799,9 @@ discard block |
||
| 786 | 799 | */ |
| 787 | 800 | protected function agregarDetalle($detalle, $x = 10, $html = true) |
| 788 | 801 | { |
| 789 | - if (!isset($detalle[0])) |
|
| 790 | - $detalle = [$detalle]; |
|
| 802 | + if (!isset($detalle[0])) { |
|
| 803 | + $detalle = [$detalle]; |
|
| 804 | + } |
|
| 791 | 805 | $this->setFont('', '', $this->detalle_fuente); |
| 792 | 806 | // titulos |
| 793 | 807 | $titulos = []; |
@@ -820,15 +834,17 @@ discard block |
||
| 820 | 834 | } |
| 821 | 835 | // ajustes a IndExe |
| 822 | 836 | if (isset($item['IndExe'])) { |
| 823 | - if ($item['IndExe']==1) |
|
| 824 | - $item['IndExe'] = 'EX'; |
|
| 825 | - else if ($item['IndExe']==2) |
|
| 826 | - $item['IndExe'] = 'NF'; |
|
| 837 | + if ($item['IndExe']==1) { |
|
| 838 | + $item['IndExe'] = 'EX'; |
|
| 839 | + } else if ($item['IndExe']==2) { |
|
| 840 | + $item['IndExe'] = 'NF'; |
|
| 841 | + } |
|
| 827 | 842 | } |
| 828 | 843 | // agregar todas las columnas que se podrían imprimir en la tabla |
| 829 | 844 | $item_default = []; |
| 830 | - foreach ($this->detalle_cols as $key => $info) |
|
| 831 | - $item_default[$key] = false; |
|
| 845 | + foreach ($this->detalle_cols as $key => $info) { |
|
| 846 | + $item_default[$key] = false; |
|
| 847 | + } |
|
| 832 | 848 | $item = array_merge($item_default, $item); |
| 833 | 849 | // si hay código de item se extrae su valor |
| 834 | 850 | if (!empty($item['CdgItem']['VlrCodigo'])){ |
@@ -845,8 +861,9 @@ discard block |
||
| 845 | 861 | $options = ['align'=>[]]; |
| 846 | 862 | $i = 0; |
| 847 | 863 | foreach ($this->detalle_cols as $info) { |
| 848 | - if (isset($info['width'])) |
|
| 849 | - $options['width'][$i] = $info['width']; |
|
| 864 | + if (isset($info['width'])) { |
|
| 865 | + $options['width'][$i] = $info['width']; |
|
| 866 | + } |
|
| 850 | 867 | $options['align'][$i] = $info['align']; |
| 851 | 868 | $i++; |
| 852 | 869 | } |
@@ -879,8 +896,9 @@ discard block |
||
| 879 | 896 | $this->Texto($this->detalle_cols['QtyItem']['title'], $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']); |
| 880 | 897 | $this->Texto($this->detalle_cols['MontoItem']['title'], $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']); |
| 881 | 898 | $this->Line($p1x, $p1y+4, $p2x, $p2y+4, $style); |
| 882 | - if (!isset($detalle[0])) |
|
| 883 | - $detalle = [$detalle]; |
|
| 899 | + if (!isset($detalle[0])) { |
|
| 900 | + $detalle = [$detalle]; |
|
| 901 | + } |
|
| 884 | 902 | $this->SetY($this->getY()+2); |
| 885 | 903 | foreach($detalle as &$d) { |
| 886 | 904 | $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
@@ -955,8 +973,9 @@ discard block |
||
| 955 | 973 | */ |
| 956 | 974 | protected function agregarPagos(array $pagos, $x = 10) |
| 957 | 975 | { |
| 958 | - if (!isset($pagos[0])) |
|
| 959 | - $pagos = [$pagos]; |
|
| 976 | + if (!isset($pagos[0])) { |
|
| 977 | + $pagos = [$pagos]; |
|
| 978 | + } |
|
| 960 | 979 | $this->Texto('Pago(s) programado(s):', $x); |
| 961 | 980 | $this->Ln(); |
| 962 | 981 | foreach($pagos as $p) { |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | namespace sasco\LibreDTE; |
| 25 | 25 | |
| 26 | 26 | // Directorio para imágenes (no se asume nada) |
| 27 | -define ('K_PATH_IMAGES', ''); |
|
| 27 | +define('K_PATH_IMAGES', ''); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * Clase para generar PDFs |
@@ -152,13 +152,13 @@ discard block |
||
| 152 | 152 | { |
| 153 | 153 | $widths = []; |
| 154 | 154 | if (is_int($cells)) { |
| 155 | - $width = floor($total/$cells); |
|
| 156 | - for ($i=0; $i<$cells; ++$i) { |
|
| 155 | + $width = floor($total / $cells); |
|
| 156 | + for ($i = 0; $i<$cells; ++$i) { |
|
| 157 | 157 | $widths[] = $width; |
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | - else if (is_array($cells)){ |
|
| 161 | - $width = floor($total/count($cells)); |
|
| 160 | + else if (is_array($cells)) { |
|
| 161 | + $width = floor($total / count($cells)); |
|
| 162 | 162 | foreach ($cells as $i) { |
| 163 | 163 | $widths[$i] = $width; |
| 164 | 164 | } |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $suma += $val; |
| 209 | 209 | } |
| 210 | 210 | if ($key_0!==null) { |
| 211 | - $options['width'][$key_0] = 190 - $suma; |
|
| 211 | + $options['width'][$key_0] = 190-$suma; |
|
| 212 | 212 | } |
| 213 | 213 | } |
| 214 | 214 | if (isset($options['align'])) |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $a = (isset($options['align']) and is_array($options['align'])) ? $options['align'] : []; |
| 244 | 244 | $buffer = '<table style="border:1px solid #333">'; |
| 245 | 245 | // Definir títulos de columnas |
| 246 | - $thead = isset($options['width']) and is_array($options['width']) and count($options['width']) == count($headers); |
|
| 246 | + $thead = isset($options['width']) and is_array($options['width']) and count($options['width'])==count($headers); |
|
| 247 | 247 | if ($thead) { |
| 248 | 248 | $buffer .= '<thead>'; |
| 249 | 249 | } |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | $options['bordercolor'][2] |
| 308 | 308 | ); |
| 309 | 309 | $this->SetLineWidth($options['borderwidth']); |
| 310 | - $this->SetFont($this->defaultOptions['font']['family'], 'B', $options['fontsize']); |
|
| 310 | + $this->SetFont($this->defaultOptions['font']['family'], 'B', $options['fontsize']); |
|
| 311 | 311 | // corregir indices |
| 312 | 312 | $headers_keys = array_keys($headers); |
| 313 | 313 | if (is_array($options['width'])) { |
@@ -329,13 +329,13 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | // Header |
| 331 | 331 | $x = $this->GetX(); |
| 332 | - foreach($headers as $i => $header) { |
|
| 332 | + foreach ($headers as $i => $header) { |
|
| 333 | 333 | $this->Cell($options['width'][$i], $options['height'], $headers[$i], 1, 0, $options['align'][$i], 1); |
| 334 | 334 | } |
| 335 | 335 | $this->Ln(); |
| 336 | 336 | $y = $this->GetY(); |
| 337 | 337 | // Color and font restoration |
| 338 | - $this->SetFillColor ( |
|
| 338 | + $this->SetFillColor( |
|
| 339 | 339 | $options['bodybackground'][0], |
| 340 | 340 | $options['bodybackground'][1], |
| 341 | 341 | $options['bodybackground'][2] |
@@ -360,7 +360,7 @@ discard block |
||
| 360 | 360 | $this->SetX($x); |
| 361 | 361 | $y_0 = $this->GetY(); |
| 362 | 362 | $y_s = []; |
| 363 | - foreach($headers as $i => $header) { |
|
| 363 | + foreach ($headers as $i => $header) { |
|
| 364 | 364 | $x_0 = $this->GetX(); |
| 365 | 365 | $this->SetXY($x_0, $y_0); |
| 366 | 366 | $aux = explode("\n", $row[$i]); |
@@ -370,28 +370,28 @@ discard block |
||
| 370 | 370 | if ($value2) { |
| 371 | 371 | $this->Ln(); |
| 372 | 372 | $this->SetX($x_0); |
| 373 | - $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']-2); |
|
| 373 | + $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']-2); |
|
| 374 | 374 | $y_2 = $this->MultiCell($options['width'][$i], $options['height'], $value2, $options['tdborder'], $options['align'][$i], false, 0); |
| 375 | - $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']); |
|
| 376 | - $y_s[] = $y_1 + $y_2*0.9; |
|
| 375 | + $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']); |
|
| 376 | + $y_s[] = $y_1+$y_2 * 0.9; |
|
| 377 | 377 | } else { |
| 378 | 378 | $y_s[] = $y_1; |
| 379 | 379 | } |
| 380 | 380 | } |
| 381 | - $this->Ln(max($y_s)*5); |
|
| 381 | + $this->Ln(max($y_s) * 5); |
|
| 382 | 382 | // si se pasó a página siguiente se hace rollback y se crea nueva página con cabecera nuevamente en la tabla |
| 383 | - if($num_pages < $this->getNumPages()) { |
|
| 383 | + if ($num_pages<$this->getNumPages()) { |
|
| 384 | 384 | $this->rollbackTransaction(true); |
| 385 | 385 | $this->AddPage(); |
| 386 | 386 | $this->SetX($x); |
| 387 | - foreach($headers as $i => $header) { |
|
| 387 | + foreach ($headers as $i => $header) { |
|
| 388 | 388 | $this->Cell($options['width'][$i], $options['height'], $headers[$i], 1, 0, $options['align'][$i], 1); |
| 389 | 389 | } |
| 390 | 390 | $this->Ln(); |
| 391 | 391 | $this->SetX($x); |
| 392 | 392 | $y_0 = $this->GetY(); |
| 393 | 393 | $y_s = []; |
| 394 | - foreach($headers as $i => $header) { |
|
| 394 | + foreach ($headers as $i => $header) { |
|
| 395 | 395 | $x_0 = $this->GetX(); |
| 396 | 396 | $this->SetXY($x_0, $y_0); |
| 397 | 397 | $aux = explode("\n", $row[$i]); |
@@ -401,15 +401,15 @@ discard block |
||
| 401 | 401 | if ($value2) { |
| 402 | 402 | $this->Ln(); |
| 403 | 403 | $this->SetX($x_0); |
| 404 | - $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']-2); |
|
| 404 | + $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']-2); |
|
| 405 | 405 | $y_2 = $this->MultiCell($options['width'][$i], $options['height'], $value2, $options['tdborder'], $options['align'][$i], false, 0); |
| 406 | - $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']); |
|
| 407 | - $y_s[] = $y_1 + $y_2*0.9; |
|
| 406 | + $this->SetFont($this->defaultOptions['font']['family'], '', $options['fontsize']); |
|
| 407 | + $y_s[] = $y_1+$y_2 * 0.9; |
|
| 408 | 408 | } else { |
| 409 | 409 | $y_s[] = $y_1; |
| 410 | 410 | } |
| 411 | 411 | } |
| 412 | - $this->Ln(max($y_s)*5); |
|
| 412 | + $this->Ln(max($y_s) * 5); |
|
| 413 | 413 | } else { |
| 414 | 414 | $this->commitTransaction(); |
| 415 | 415 | } |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl) |
| 439 | 439 | * @version 2014-09-20 |
| 440 | 440 | */ |
| 441 | - public function Texto($txt, $x=null, $y=null, $align='', $w=0, $link='', $border=0, $fill=false) |
|
| 441 | + public function Texto($txt, $x = null, $y = null, $align = '', $w = 0, $link = '', $border = 0, $fill = false) |
|
| 442 | 442 | { |
| 443 | 443 | if ($x==null) $x = $this->GetX(); |
| 444 | 444 | if ($y==null) $y = $this->GetY(); |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl) |
| 460 | 460 | * @version 2014-09-20 |
| 461 | 461 | */ |
| 462 | - public function MultiTexto($txt, $x=null, $y=null, $align='', $w=0, $border=0, $fill=false) |
|
| 462 | + public function MultiTexto($txt, $x = null, $y = null, $align = '', $w = 0, $border = 0, $fill = false) |
|
| 463 | 463 | { |
| 464 | 464 | if ($x==null) $x = $this->GetX(); |
| 465 | 465 | if ($y==null) $y = $this->GetY(); |
@@ -102,13 +102,16 @@ discard block |
||
| 102 | 102 | $this->Line(0, $this->getY()-1, 290, $this->getY()-2, $style); |
| 103 | 103 | $this->SetFont('', 'B', 6); |
| 104 | 104 | if (empty($this->papelContinuo)) { |
| 105 | - if (!empty($this->footer['left'])) |
|
| 106 | - $this->Texto($this->footer['left']); |
|
| 107 | - if (!empty($this->footer['right'])) |
|
| 108 | - $this->Texto($this->footer['right'], null, null, 'R'); |
|
| 105 | + if (!empty($this->footer['left'])) { |
|
| 106 | + $this->Texto($this->footer['left']); |
|
| 107 | + } |
|
| 108 | + if (!empty($this->footer['right'])) { |
|
| 109 | + $this->Texto($this->footer['right'], null, null, 'R'); |
|
| 110 | + } |
|
| 109 | 111 | } else { |
| 110 | - if (!empty($this->footer['left'])) |
|
| 111 | - $this->Texto($this->footer['left'], null, null, 'C'); |
|
| 112 | + if (!empty($this->footer['left'])) { |
|
| 113 | + $this->Texto($this->footer['left'], null, null, 'C'); |
|
| 114 | + } |
|
| 112 | 115 | if (!empty($this->footer['right'])) { |
| 113 | 116 | $this->Ln(); |
| 114 | 117 | $this->Texto($this->footer['right'], null, null, 'C'); |
@@ -134,8 +137,9 @@ discard block |
||
| 134 | 137 | ]; |
| 135 | 138 | } |
| 136 | 139 | // si no es arreglo se convierte en uno |
| 137 | - if (!is_array($footer)) |
|
| 138 | - $footer = ['left'=>$footer]; |
|
| 140 | + if (!is_array($footer)) { |
|
| 141 | + $footer = ['left'=>$footer]; |
|
| 142 | + } |
|
| 139 | 143 | // asignar footer |
| 140 | 144 | $this->footer = array_merge(['left'=>'', 'right'=>''], $footer); |
| 141 | 145 | } else { |
@@ -156,8 +160,7 @@ discard block |
||
| 156 | 160 | for ($i=0; $i<$cells; ++$i) { |
| 157 | 161 | $widths[] = $width; |
| 158 | 162 | } |
| 159 | - } |
|
| 160 | - else if (is_array($cells)){ |
|
| 163 | + } else if (is_array($cells)){ |
|
| 161 | 164 | $width = floor($total/count($cells)); |
| 162 | 165 | foreach ($cells as $i) { |
| 163 | 166 | $widths[$i] = $width; |
@@ -178,8 +181,9 @@ discard block |
||
| 178 | 181 | foreach ($data as $row) { |
| 179 | 182 | foreach ($row as $col => $value) { |
| 180 | 183 | if (empty($value)) { |
| 181 | - if (!array_key_exists($col, $cols_empty)) |
|
| 182 | - $cols_empty[$col] = 0; |
|
| 184 | + if (!array_key_exists($col, $cols_empty)) { |
|
| 185 | + $cols_empty[$col] = 0; |
|
| 186 | + } |
|
| 183 | 187 | $cols_empty[$col]++; |
| 184 | 188 | } |
| 185 | 189 | } |
@@ -192,10 +196,12 @@ discard block |
||
| 192 | 196 | foreach ($data as &$row) { |
| 193 | 197 | unset($row[$col]); |
| 194 | 198 | } |
| 195 | - if (isset($options['width'])) |
|
| 196 | - unset($options['width'][$titles_keys[$col]]); |
|
| 197 | - if (isset($options['align'])) |
|
| 198 | - unset($options['align'][$titles_keys[$col]]); |
|
| 199 | + if (isset($options['width'])) { |
|
| 200 | + unset($options['width'][$titles_keys[$col]]); |
|
| 201 | + } |
|
| 202 | + if (isset($options['align'])) { |
|
| 203 | + unset($options['align'][$titles_keys[$col]]); |
|
| 204 | + } |
|
| 199 | 205 | } |
| 200 | 206 | } |
| 201 | 207 | if (isset($options['width'])) { |
@@ -203,16 +209,18 @@ discard block |
||
| 203 | 209 | $key_0 = null; |
| 204 | 210 | $suma = 0; |
| 205 | 211 | foreach ($options['width'] as $key => $val) { |
| 206 | - if ($val===0) |
|
| 207 | - $key_0 = $key; |
|
| 212 | + if ($val===0) { |
|
| 213 | + $key_0 = $key; |
|
| 214 | + } |
|
| 208 | 215 | $suma += $val; |
| 209 | 216 | } |
| 210 | 217 | if ($key_0!==null) { |
| 211 | 218 | $options['width'][$key_0] = 190 - $suma; |
| 212 | 219 | } |
| 213 | 220 | } |
| 214 | - if (isset($options['align'])) |
|
| 215 | - $options['align'] = array_slice($options['align'], 0); |
|
| 221 | + if (isset($options['align'])) { |
|
| 222 | + $options['align'] = array_slice($options['align'], 0); |
|
| 223 | + } |
|
| 216 | 224 | $this->addTable($titles, $data, $options, $html); |
| 217 | 225 | } |
| 218 | 226 | |
@@ -440,8 +448,12 @@ discard block |
||
| 440 | 448 | */ |
| 441 | 449 | public function Texto($txt, $x=null, $y=null, $align='', $w=0, $link='', $border=0, $fill=false) |
| 442 | 450 | { |
| 443 | - if ($x==null) $x = $this->GetX(); |
|
| 444 | - if ($y==null) $y = $this->GetY(); |
|
| 451 | + if ($x==null) { |
|
| 452 | + $x = $this->GetX(); |
|
| 453 | + } |
|
| 454 | + if ($y==null) { |
|
| 455 | + $y = $this->GetY(); |
|
| 456 | + } |
|
| 445 | 457 | $textrendermode = $this->textrendermode; |
| 446 | 458 | $textstrokewidth = $this->textstrokewidth; |
| 447 | 459 | $this->setTextRenderingMode(0, true, false); |
@@ -461,8 +473,12 @@ discard block |
||
| 461 | 473 | */ |
| 462 | 474 | public function MultiTexto($txt, $x=null, $y=null, $align='', $w=0, $border=0, $fill=false) |
| 463 | 475 | { |
| 464 | - if ($x==null) $x = $this->GetX(); |
|
| 465 | - if ($y==null) $y = $this->GetY(); |
|
| 476 | + if ($x==null) { |
|
| 477 | + $x = $this->GetX(); |
|
| 478 | + } |
|
| 479 | + if ($y==null) { |
|
| 480 | + $y = $this->GetY(); |
|
| 481 | + } |
|
| 466 | 482 | $textrendermode = $this->textrendermode; |
| 467 | 483 | $textstrokewidth = $this->textstrokewidth; |
| 468 | 484 | $this->setTextRenderingMode(0, true, false); |