@@ -66,4 +66,4 @@ |
||
| 66 | 66 | |
| 67 | 67 | // si hubo errores mostrar |
| 68 | 68 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 69 | - echo $error,"\n"; |
|
| 69 | + echo $error, "\n"; |
|
@@ -65,5 +65,6 @@ |
||
| 65 | 65 | var_dump($track_id); |
| 66 | 66 | |
| 67 | 67 | // si hubo errores mostrar |
| 68 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 68 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 69 | 69 | echo $error,"\n"; |
| 70 | +} |
|
@@ -66,4 +66,4 @@ |
||
| 66 | 66 | |
| 67 | 67 | // si hubo errores mostrar |
| 68 | 68 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 69 | - echo $error,"\n"; |
|
| 69 | + echo $error, "\n"; |
|
@@ -98,5 +98,6 @@ |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // si hubo errores mostrar |
| 101 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 101 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 102 | 102 | echo $error,"\n"; |
| 103 | +} |
|
@@ -66,4 +66,4 @@ |
||
| 66 | 66 | |
| 67 | 67 | // si hubo errores mostrar |
| 68 | 68 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
| 69 | - echo $error,"\n"; |
|
| 69 | + echo $error, "\n"; |
|
@@ -65,5 +65,6 @@ |
||
| 65 | 65 | var_dump($track_id); |
| 66 | 66 | |
| 67 | 67 | // si hubo errores mostrar |
| 68 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 68 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 69 | 69 | echo $error,"\n"; |
| 70 | +} |
|
@@ -254,7 +254,7 @@ |
||
| 254 | 254 | |
| 255 | 255 | /** |
| 256 | 256 | * Método que indica si el CAF es de certificación o no |
| 257 | - * @return bool =true si los folios son del ambiente de certificación, =null si no se pudo determinar |
|
| 257 | + * @return boolean|null =true si los folios son del ambiente de certificación, =null si no se pudo determinar |
|
| 258 | 258 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 259 | 259 | * @version 2015-10-30 |
| 260 | 260 | */ |
@@ -63,11 +63,11 @@ discard block |
||
| 63 | 63 | // validar firma del SII sobre los folios |
| 64 | 64 | $firma = $this->getFirma(); |
| 65 | 65 | $idk = $this->getIDK(); |
| 66 | - if ($firma === false || $idk === false) { |
|
| 66 | + if ($firma===false || $idk===false) { |
|
| 67 | 67 | return false; |
| 68 | 68 | } |
| 69 | 69 | $pub_key = \sasco\LibreDTE\Sii::cert($idk); |
| 70 | - if ($pub_key === false || openssl_verify($this->xml->getFlattened('/AUTORIZACION/CAF/DA'), base64_decode($firma), $pub_key)!==1) { |
|
| 70 | + if ($pub_key===false || openssl_verify($this->xml->getFlattened('/AUTORIZACION/CAF/DA'), base64_decode($firma), $pub_key)!==1) { |
|
| 71 | 71 | \sasco\LibreDTE\Log::write( |
| 72 | 72 | \sasco\LibreDTE\Estado::FOLIOS_ERROR_FIRMA, |
| 73 | 73 | \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::FOLIOS_ERROR_FIRMA) |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | ); |
| 99 | 99 | return false; |
| 100 | 100 | } |
| 101 | - return $plain === $plain_firmado; |
|
| 101 | + return $plain===$plain_firmado; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | public function getCertificacion() |
| 262 | 262 | { |
| 263 | 263 | $idk = $this->getIDK(); |
| 264 | - return $idk ? $idk === 100 : null; |
|
| 264 | + return $idk ? $idk===100 : null; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | /** |
@@ -277,14 +277,14 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | $fecha_autorizacion = $this->getFechaAutorizacion(); |
| 279 | 279 | $hoy = date('Y-m-d'); |
| 280 | - if ($fecha_autorizacion < '2018-07-01' and $hoy > '2018-12-31') { |
|
| 280 | + if ($fecha_autorizacion<'2018-07-01' and $hoy>'2018-12-31') { |
|
| 281 | 281 | return false; |
| 282 | 282 | } |
| 283 | - $vigencia = $fecha_autorizacion >= '2018-07-01' ? 6 : 18; |
|
| 283 | + $vigencia = $fecha_autorizacion>='2018-07-01' ? 6 : 18; |
|
| 284 | 284 | $d1 = new \DateTime($fecha_autorizacion); |
| 285 | 285 | $d2 = new \DateTime($hoy); |
| 286 | - $meses = $d1->diff($d2)->m + ($d1->diff($d2)->y*12); |
|
| 287 | - return $meses <= $vigencia; |
|
| 286 | + $meses = $d1->diff($d2)->m+($d1->diff($d2)->y * 12); |
|
| 287 | + return $meses<=$vigencia; |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /** |
@@ -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); |
@@ -198,7 +198,7 @@ |
||
| 198 | 198 | /** |
| 199 | 199 | * Método que entrega la glosa del tipo de documento |
| 200 | 200 | * @param tipo Código del tipo de documento |
| 201 | - * @param folio Folio del tipo de documento (usado al ser generados a partir de borradores en formato libredte) |
|
| 201 | + * @param folio integer del tipo de documento (usado al ser generados a partir de borradores en formato libredte) |
|
| 202 | 202 | * @return Glosa del tipo de documento |
| 203 | 203 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
| 204 | 204 | * @version 2019-08-05 |
@@ -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! |
@@ -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); |