@@ -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,8 +277,8 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | $d1 = new \DateTime($this->getFechaAutorizacion()); |
| 279 | 279 | $d2 = new \DateTime(date('Y-m-d')); |
| 280 | - $meses = $d1->diff($d2)->m + ($d1->diff($d2)->y*12); |
|
| 281 | - return $meses <= 18; |
|
| 280 | + $meses = $d1->diff($d2)->m+($d1->diff($d2)->y * 12); |
|
| 281 | + return $meses<=18; |
|
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | /** |
@@ -466,8 +466,9 @@ discard block |
||
| 466 | 466 | // entregar WSDL local (modificados para ambiente de certificación) |
| 467 | 467 | if ($ambiente==self::CERTIFICACION) { |
| 468 | 468 | $wsdl = dirname(dirname(__FILE__)).'/wsdl/'.self::$config['servidor'][$ambiente].'/'.$servicio.'.jws'; |
| 469 | - if (is_readable($wsdl)) |
|
| 470 | - return $wsdl; |
|
| 469 | + if (is_readable($wsdl)) { |
|
| 470 | + return $wsdl; |
|
| 471 | + } |
|
| 471 | 472 | } |
| 472 | 473 | // entregar WSDL oficial desde SII |
| 473 | 474 | $location = isset(self::$config['wsdl'][$servicio]) ? self::$config['wsdl'][$servicio] : self::$config['wsdl']['*']; |
@@ -496,10 +497,12 @@ discard block |
||
| 496 | 497 | $retry = (int)$args; |
| 497 | 498 | $args = null; |
| 498 | 499 | } |
| 499 | - if (!$retry) |
|
| 500 | - $retry = self::$retry; |
|
| 501 | - if ($args and !is_array($args)) |
|
| 502 | - $args = [$args]; |
|
| 500 | + if (!$retry) { |
|
| 501 | + $retry = self::$retry; |
|
| 502 | + } |
|
| 503 | + if ($args and !is_array($args)) { |
|
| 504 | + $args = [$args]; |
|
| 505 | + } |
|
| 503 | 506 | if (!self::$verificar_ssl) { |
| 504 | 507 | if (self::getAmbiente()==self::PRODUCCION) { |
| 505 | 508 | $msg = Estado::get(Estado::ENVIO_SSL_SIN_VERIFICAR); |
@@ -736,10 +739,11 @@ discard block |
||
| 736 | 739 | public static function getAmbiente($ambiente = null) |
| 737 | 740 | { |
| 738 | 741 | if ($ambiente===null) { |
| 739 | - if (defined('_LibreDTE_CERTIFICACION_')) |
|
| 740 | - $ambiente = (int)_LibreDTE_CERTIFICACION_; |
|
| 741 | - else |
|
| 742 | - $ambiente = self::$ambiente; |
|
| 742 | + if (defined('_LibreDTE_CERTIFICACION_')) { |
|
| 743 | + $ambiente = (int)_LibreDTE_CERTIFICACION_; |
|
| 744 | + } else { |
|
| 745 | + $ambiente = self::$ambiente; |
|
| 746 | + } |
|
| 743 | 747 | } |
| 744 | 748 | return $ambiente; |
| 745 | 749 | } |
@@ -765,8 +769,9 @@ discard block |
||
| 765 | 769 | { |
| 766 | 770 | // solicitar token |
| 767 | 771 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($Firma); |
| 768 | - if (!$token) |
|
| 769 | - return false; |
|
| 772 | + if (!$token) { |
|
| 773 | + return false; |
|
| 774 | + } |
|
| 770 | 775 | // definir ambiente y servidor |
| 771 | 776 | $ambiente = self::getAmbiente($ambiente); |
| 772 | 777 | $servidor = self::$config['servidor'][$ambiente]; |
@@ -795,8 +800,9 @@ discard block |
||
| 795 | 800 | } |
| 796 | 801 | // realizar consulta curl |
| 797 | 802 | $response = curl_exec($curl); |
| 798 | - if (!$response) |
|
| 799 | - return false; |
|
| 803 | + if (!$response) { |
|
| 804 | + return false; |
|
| 805 | + } |
|
| 800 | 806 | // cerrar sesión curl |
| 801 | 807 | curl_close($curl); |
| 802 | 808 | // entregar datos del archivo CSV |
@@ -807,10 +813,12 @@ discard block |
||
| 807 | 813 | for ($i=1; $i<$n_lines; $i++) { |
| 808 | 814 | $row = str_getcsv($lines[$i], ';', ''); |
| 809 | 815 | unset($lines[$i]); |
| 810 | - if (!isset($row[5])) |
|
| 811 | - continue; |
|
| 812 | - for ($j=0; $j<6; $j++) |
|
| 813 | - $row[$j] = trim($row[$j]); |
|
| 816 | + if (!isset($row[5])) { |
|
| 817 | + continue; |
|
| 818 | + } |
|
| 819 | + for ($j=0; $j<6; $j++) { |
|
| 820 | + $row[$j] = trim($row[$j]); |
|
| 821 | + } |
|
| 814 | 822 | $row[1] = utf8_decode($row[1]); |
| 815 | 823 | $row[4] = strtolower($row[4]); |
| 816 | 824 | $row[5] = strtolower($row[5]); |