@@ -53,8 +53,9 @@ |
||
| 53 | 53 | */ |
| 54 | 54 | public static function getCiudad($comuna) |
| 55 | 55 | { |
| 56 | - if (!$comuna) |
|
| 57 | - return false; |
|
| 56 | + if (!$comuna) { |
|
| 57 | + return false; |
|
| 58 | + } |
|
| 58 | 59 | $comuna = mb_strtoupper($comuna, 'UTF-8'); |
| 59 | 60 | return isset(self::$ciudades[$comuna]) ? self::$ciudades[$comuna] : false; |
| 60 | 61 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | public static function mergeRecursiveDistinct(array $array1, array $array2) |
| 43 | 43 | { |
| 44 | 44 | $merged = $array1; |
| 45 | - foreach ( $array2 as $key => &$value ) { |
|
| 45 | + foreach ($array2 as $key => &$value) { |
|
| 46 | 46 | if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { |
| 47 | 47 | $merged [$key] = self::mergeRecursiveDistinct( |
| 48 | 48 | $merged [$key], |
@@ -46,10 +46,10 @@ discard block |
||
| 46 | 46 | */ |
| 47 | 47 | public static function read($archivo, $separador = ';', $delimitadortexto = '"') |
| 48 | 48 | { |
| 49 | - if (($handle = fopen($archivo, 'r')) !== FALSE) { |
|
| 49 | + if (($handle = fopen($archivo, 'r'))!==FALSE) { |
|
| 50 | 50 | $data = array(); |
| 51 | 51 | $i = 0; |
| 52 | - while (($row = fgetcsv($handle, 0, $separador, $delimitadortexto)) !== FALSE) { |
|
| 52 | + while (($row = fgetcsv($handle, 0, $separador, $delimitadortexto))!==FALSE) { |
|
| 53 | 53 | $j = 0; |
| 54 | 54 | foreach ($row as &$col) { |
| 55 | 55 | $data[$i][$j++] = $col; |
@@ -77,11 +77,11 @@ discard block |
||
| 77 | 77 | header('Content-Disposition: attachment; filename='.$archivo.'.csv'); |
| 78 | 78 | header('Pragma: no-cache'); |
| 79 | 79 | header('Expires: 0'); |
| 80 | - foreach($data as &$row) { |
|
| 81 | - foreach($row as &$col) { |
|
| 80 | + foreach ($data as &$row) { |
|
| 81 | + foreach ($row as &$col) { |
|
| 82 | 82 | $col = $delimitadortexto.rtrim(str_replace('<br />', ', ', strip_tags($col, '<br>')), " \t\n\r\0\x0B,").$delimitadortexto; |
| 83 | 83 | } |
| 84 | - echo implode($separador, $row),"\r\n"; |
|
| 84 | + echo implode($separador, $row), "\r\n"; |
|
| 85 | 85 | unset($row); |
| 86 | 86 | } |
| 87 | 87 | unset($data); |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | public static function save(array $data, $archivo, $separador = ';', $delimitadortexto = '"') |
| 101 | 101 | { |
| 102 | 102 | $fd = fopen($archivo, 'w'); |
| 103 | - foreach($data as &$row) { |
|
| 104 | - foreach($row as &$col) { |
|
| 103 | + foreach ($data as &$row) { |
|
| 104 | + foreach ($row as &$col) { |
|
| 105 | 105 | $col = $delimitadortexto.rtrim(str_replace('<br />', ', ', strip_tags($col, '<br>')), " \t\n\r\0\x0B,").$delimitadortexto; |
| 106 | 106 | } |
| 107 | 107 | fwrite($fd, implode($separador, $row)."\r\n"); |
@@ -49,18 +49,18 @@ discard block |
||
| 49 | 49 | public static function rmdir($dir) |
| 50 | 50 | { |
| 51 | 51 | // List the contents of the directory table |
| 52 | - $dir_content = scandir ($dir); |
|
| 52 | + $dir_content = scandir($dir); |
|
| 53 | 53 | // Is it a directory? |
| 54 | 54 | if ($dir_content!==false) { |
| 55 | 55 | // For each directory entry |
| 56 | 56 | foreach ($dir_content as &$entry) { |
| 57 | 57 | // Unix symbolic shortcuts, we go |
| 58 | - if (!in_array ($entry, array ('.','..'))) { |
|
| 58 | + if (!in_array($entry, array('.', '..'))) { |
|
| 59 | 59 | // We find the path from the beginning |
| 60 | - $entry = $dir.DIRECTORY_SEPARATOR. $entry; |
|
| 60 | + $entry = $dir.DIRECTORY_SEPARATOR.$entry; |
|
| 61 | 61 | // This entry is not an issue: it clears |
| 62 | 62 | if (!is_dir($entry)) { |
| 63 | - unlink ($entry); |
|
| 63 | + unlink($entry); |
|
| 64 | 64 | } else { // This entry is a folder, it again on this issue |
| 65 | 65 | self::rmdir($entry); |
| 66 | 66 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | } |
| 70 | 70 | // It has erased all entries in the folder, we can now erase |
| 71 | - rmdir ($dir); |
|
| 71 | + rmdir($dir); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -160,11 +160,11 @@ discard block |
||
| 160 | 160 | // enviar archivo |
| 161 | 161 | if ($options['download']) { |
| 162 | 162 | ob_clean(); |
| 163 | - header ('Content-Disposition: attachment; filename='.$file_compressed); |
|
| 163 | + header('Content-Disposition: attachment; filename='.$file_compressed); |
|
| 164 | 164 | $mimetype = self::mimetype($dir.DIRECTORY_SEPARATOR.$file_compressed); |
| 165 | 165 | if ($mimetype) |
| 166 | - header ('Content-Type: '.$mimetype); |
|
| 167 | - header ('Content-Length: '.filesize($dir.DIRECTORY_SEPARATOR.$file_compressed)); |
|
| 166 | + header('Content-Type: '.$mimetype); |
|
| 167 | + header('Content-Length: '.filesize($dir.DIRECTORY_SEPARATOR.$file_compressed)); |
|
| 168 | 168 | readfile($dir.DIRECTORY_SEPARATOR.$file_compressed); |
| 169 | 169 | unlink($dir.DIRECTORY_SEPARATOR.$file_compressed); |
| 170 | 170 | } |
@@ -80,8 +80,9 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | public static function mimetype($file) |
| 82 | 82 | { |
| 83 | - if (!function_exists('finfo_open')) |
|
| 84 | - return false; |
|
| 83 | + if (!function_exists('finfo_open')) { |
|
| 84 | + return false; |
|
| 85 | + } |
|
| 85 | 86 | $finfo = finfo_open(FILEINFO_MIME_TYPE); |
| 86 | 87 | $mimetype = finfo_file($finfo, $file); |
| 87 | 88 | finfo_close($finfo); |
@@ -121,8 +122,11 @@ discard block |
||
| 121 | 122 | } |
| 122 | 123 | // si es formato gz y es directorio se cambia a tgz |
| 123 | 124 | if (is_dir($file)) { |
| 124 | - if ($options['format']=='gz') $options['format'] = 'tar.gz'; |
|
| 125 | - else if ($options['format']=='bz2') $options['format'] = 'tar.bz2'; |
|
| 125 | + if ($options['format']=='gz') { |
|
| 126 | + $options['format'] = 'tar.gz'; |
|
| 127 | + } else if ($options['format']=='bz2') { |
|
| 128 | + $options['format'] = 'tar.bz2'; |
|
| 129 | + } |
|
| 126 | 130 | } |
| 127 | 131 | // obtener directorio que contiene al archivo/directorio y el nombre de este |
| 128 | 132 | $filepath = $file; |
@@ -162,8 +166,9 @@ discard block |
||
| 162 | 166 | ob_clean(); |
| 163 | 167 | header ('Content-Disposition: attachment; filename='.$file_compressed); |
| 164 | 168 | $mimetype = self::mimetype($dir.DIRECTORY_SEPARATOR.$file_compressed); |
| 165 | - if ($mimetype) |
|
| 166 | - header ('Content-Type: '.$mimetype); |
|
| 169 | + if ($mimetype) { |
|
| 170 | + header ('Content-Type: '.$mimetype); |
|
| 171 | + } |
|
| 167 | 172 | header ('Content-Length: '.filesize($dir.DIRECTORY_SEPARATOR.$file_compressed)); |
| 168 | 173 | readfile($dir.DIRECTORY_SEPARATOR.$file_compressed); |
| 169 | 174 | unlink($dir.DIRECTORY_SEPARATOR.$file_compressed); |
@@ -171,8 +176,11 @@ discard block |
||
| 171 | 176 | // borrar directorio o archivo que se está comprimiendo si así se ha |
| 172 | 177 | // solicitado |
| 173 | 178 | if ($options['delete']) { |
| 174 | - if (is_dir($filepath)) self::rmdir($filepath); |
|
| 175 | - else unlink($filepath); |
|
| 179 | + if (is_dir($filepath)) { |
|
| 180 | + self::rmdir($filepath); |
|
| 181 | + } else { |
|
| 182 | + unlink($filepath); |
|
| 183 | + } |
|
| 176 | 184 | } |
| 177 | 185 | } |
| 178 | 186 | |
@@ -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 | +} |
|
@@ -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 | +} |
|
@@ -83,5 +83,6 @@ |
||
| 83 | 83 | echo $XML2->getFlattened('/nodo1/nodo2')."\n\n"; |
| 84 | 84 | |
| 85 | 85 | // si hubo errores mostrar |
| 86 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 86 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 87 | 87 | echo $error, "\n"; |
| 88 | +} |
|
@@ -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"; |
|
@@ -411,17 +411,20 @@ discard block |
||
| 411 | 411 | // Objetos de Firma, Folios y EnvioDTE |
| 412 | 412 | $Firma = new \sasco\LibreDTE\FirmaElectronica($config['firma']); |
| 413 | 413 | $Folios = []; |
| 414 | -foreach ($folios as $tipo => $cantidad) |
|
| 414 | +foreach ($folios as $tipo => $cantidad) { |
|
| 415 | 415 | $Folios[$tipo] = new \sasco\LibreDTE\Sii\Folios(file_get_contents('xml/folios/'.$tipo.'.xml')); |
| 416 | +} |
|
| 416 | 417 | $EnvioDTE = new \sasco\LibreDTE\Sii\EnvioDte(); |
| 417 | 418 | |
| 418 | 419 | // generar cada DTE, timbrar, firmar y agregar al sobre de EnvioDTE |
| 419 | 420 | foreach ($set_pruebas as $documento) { |
| 420 | 421 | $DTE = new \sasco\LibreDTE\Sii\Dte($documento); |
| 421 | - if (!$DTE->timbrar($Folios[$DTE->getTipo()])) |
|
| 422 | - break; |
|
| 423 | - if (!$DTE->firmar($Firma)) |
|
| 424 | - break; |
|
| 422 | + if (!$DTE->timbrar($Folios[$DTE->getTipo()])) { |
|
| 423 | + break; |
|
| 424 | + } |
|
| 425 | + if (!$DTE->firmar($Firma)) { |
|
| 426 | + break; |
|
| 427 | + } |
|
| 425 | 428 | $EnvioDTE->agregar($DTE); |
| 426 | 429 | } |
| 427 | 430 | |
@@ -433,5 +436,6 @@ discard block |
||
| 433 | 436 | var_dump($track_id); |
| 434 | 437 | |
| 435 | 438 | // si hubo errores mostrar |
| 436 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
| 439 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
| 437 | 440 | echo $error,"\n"; |
| 441 | +} |
|