@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | // buscar el caso y copiar sus columnas que no estén |
263 | 263 | $detalle_r = $documentos[$caso['referencia']['caso']]['Detalle']; |
264 | 264 | $n_detalle_r = count($detalle_r); |
265 | - for ($i=0; $i<$n_detalle_r; $i++) { |
|
265 | + for ($i = 0; $i<$n_detalle_r; $i++) { |
|
266 | 266 | if ($detalle_r[$i]['NmbItem']==$detalle['NmbItem']) { |
267 | 267 | foreach ($detalle_r[$i] as $attr => $val) { |
268 | 268 | if (!isset($detalle[$attr])) |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | $documento['DscRcgGlobal'][] = [ |
326 | 326 | 'TpoMov' => 'R', |
327 | 327 | 'TpoValor' => '$', |
328 | - 'ValorDR' => round((substr($caso['recargo-total-clausula'], 0, -1)/100) * $documento['Encabezado']['Transporte']['Aduana']['TotClauVenta'], 2), |
|
328 | + 'ValorDR' => round((substr($caso['recargo-total-clausula'], 0, -1) / 100) * $documento['Encabezado']['Transporte']['Aduana']['TotClauVenta'], 2), |
|
329 | 329 | ]; |
330 | 330 | } |
331 | 331 | // agregar recargo por flete y/o seguro, se agrega sólo en factura |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | $casos = explode($separador, $archivo); |
467 | 467 | $separador_len = strlen($separador); |
468 | 468 | $n_casos = count($casos); |
469 | - for ($i=1; $i<$n_casos; $i++) { |
|
469 | + for ($i = 1; $i<$n_casos; $i++) { |
|
470 | 470 | $caso = trim($casos[$i]); |
471 | 471 | $caso_anterior = trim($casos[$i-1]); |
472 | 472 | $caso_titulo = substr($caso_anterior, -$separador_len); |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | $titulos = array_slice(array_filter(explode("\t", $lineas[$linea_titulos_detalles])), 0); |
524 | 524 | // extraer detalles |
525 | 525 | $datos['detalle'] = []; |
526 | - $i = $linea_titulos_detalles + 1; |
|
526 | + $i = $linea_titulos_detalles+1; |
|
527 | 527 | while (!empty($lineas[$i])) { |
528 | 528 | $item = array_slice(array_filter(explode("\t", $lineas[$i])), 0); |
529 | 529 | $n_item = count($item); |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | // sólo continuar si hay más líneas, será, por ej, el descuento global |
538 | 538 | if (isset($lineas[$i])) { |
539 | 539 | $n_lineas = count($lineas); |
540 | - for ($i=$i; $i<$n_lineas; $i++) { |
|
540 | + for ($i = $i; $i<$n_lineas; $i++) { |
|
541 | 541 | // si la línea está vacía se omite |
542 | 542 | if (!$lineas[$i]) |
543 | 543 | continue; |
@@ -154,8 +154,9 @@ discard block |
||
154 | 154 | foreach ($casos as $caso) { |
155 | 155 | // determinar tipo documento y folio |
156 | 156 | $TipoDTE = self::$tipos[$caso['documento']]; |
157 | - if (!isset($folios[$TipoDTE])) |
|
158 | - $folios[$TipoDTE] = 1; |
|
157 | + if (!isset($folios[$TipoDTE])) { |
|
158 | + $folios[$TipoDTE] = 1; |
|
159 | + } |
|
159 | 160 | $Folio = $folios[$TipoDTE]; |
160 | 161 | // crear encabezado del documento |
161 | 162 | $documento = [ |
@@ -219,8 +220,9 @@ discard block |
||
219 | 220 | $documento['Encabezado']['Transporte']['Aduana']['TipoBultos']['EmisorSello'] = 'Sellos de Chile'; |
220 | 221 | } |
221 | 222 | } |
222 | - if (empty($documento['Encabezado']['Transporte']['Aduana'])) |
|
223 | - unset($documento['Encabezado']['Transporte']); |
|
223 | + if (empty($documento['Encabezado']['Transporte']['Aduana'])) { |
|
224 | + unset($documento['Encabezado']['Transporte']); |
|
225 | + } |
|
224 | 226 | // agregar moneda a los totales |
225 | 227 | if (!empty($caso['exportacion']['MONEDA DE LA OPERACION'])) { |
226 | 228 | $documento['Encabezado']['Totales']['TpoMoneda'] = $caso['exportacion']['MONEDA DE LA OPERACION']; |
@@ -248,14 +250,17 @@ discard block |
||
248 | 250 | foreach ($item as $col => $val) { |
249 | 251 | $col = self::$item_cols[$col]; |
250 | 252 | // procesar cada valor de acuerdo al nombre de la columna |
251 | - if (in_array($col, ['DescuentoPct', 'RecargoPct'])) |
|
252 | - $detalle[$col] = substr($val, 0, -1); |
|
253 | - else |
|
254 | - $detalle[$col] = utf8_encode($val); // se convierte de ISO-8859-1 a UTF-8 |
|
253 | + if (in_array($col, ['DescuentoPct', 'RecargoPct'])) { |
|
254 | + $detalle[$col] = substr($val, 0, -1); |
|
255 | + } else { |
|
256 | + $detalle[$col] = utf8_encode($val); |
|
257 | + } |
|
258 | + // se convierte de ISO-8859-1 a UTF-8 |
|
255 | 259 | } |
256 | 260 | // si el item es EXENTO se agrega campo que lo indica |
257 | - if (strpos($detalle['NmbItem'], 'EXENTO')) |
|
258 | - $detalle['IndExe'] = 1; |
|
261 | + if (strpos($detalle['NmbItem'], 'EXENTO')) { |
|
262 | + $detalle['IndExe'] = 1; |
|
263 | + } |
|
259 | 264 | // si hay una referencia se completa con los campos del |
260 | 265 | // detalle de la referencia que no estén en este detalle |
261 | 266 | if (!empty($caso['referencia'])) { |
@@ -265,8 +270,9 @@ discard block |
||
265 | 270 | for ($i=0; $i<$n_detalle_r; $i++) { |
266 | 271 | if ($detalle_r[$i]['NmbItem']==$detalle['NmbItem']) { |
267 | 272 | foreach ($detalle_r[$i] as $attr => $val) { |
268 | - if (!isset($detalle[$attr])) |
|
269 | - $detalle[$attr] = $val; |
|
273 | + if (!isset($detalle[$attr])) { |
|
274 | + $detalle[$attr] = $val; |
|
275 | + } |
|
270 | 276 | } |
271 | 277 | } |
272 | 278 | } |
@@ -350,8 +356,9 @@ discard block |
||
350 | 356 | 'ValorDR' => substr($caso['recargo'], 0, -1), |
351 | 357 | ]; |
352 | 358 | } |
353 | - if (empty($documento['DscRcgGlobal'])) |
|
354 | - unset($documento['DscRcgGlobal']); |
|
359 | + if (empty($documento['DscRcgGlobal'])) { |
|
360 | + unset($documento['DscRcgGlobal']); |
|
361 | + } |
|
355 | 362 | // agregar descuento del documento de la referencia |
356 | 363 | else if (!empty($caso['referencia'])) { |
357 | 364 | $referencia = self::getReferencia($caso['referencia']['razon']); |
@@ -383,14 +390,16 @@ discard block |
||
383 | 390 | // agregar totales |
384 | 391 | $documento['Encabezado']['Totales'] = $referencia['Totales']; |
385 | 392 | // agregar tasa de IVA si corresponde |
386 | - if (isset($documento['Encabezado']['Totales']['TasaIVA'])) |
|
387 | - $documento['Encabezado']['Totales']['TasaIVA'] = \sasco\LibreDTE\Sii::getIVA(); |
|
393 | + if (isset($documento['Encabezado']['Totales']['TasaIVA'])) { |
|
394 | + $documento['Encabezado']['Totales']['TasaIVA'] = \sasco\LibreDTE\Sii::getIVA(); |
|
395 | + } |
|
388 | 396 | // si el documento referenciado es factura exenta y hay MntExe |
389 | 397 | if (isset($documento['Encabezado']['Totales']['MntExe'])) { |
390 | - if ($documentos[$caso['referencia']['caso']]['Encabezado']['IdDoc']['TipoDTE']==34) |
|
391 | - $documento['Encabezado']['Totales']['MntExe'] = 0; |
|
392 | - else |
|
393 | - unset($documento['Encabezado']['Totales']['MntExe']); |
|
398 | + if ($documentos[$caso['referencia']['caso']]['Encabezado']['IdDoc']['TipoDTE']==34) { |
|
399 | + $documento['Encabezado']['Totales']['MntExe'] = 0; |
|
400 | + } else { |
|
401 | + unset($documento['Encabezado']['Totales']['MntExe']); |
|
402 | + } |
|
394 | 403 | } |
395 | 404 | // si es documento de exportación se resetean los totales y se copia el tipo de moneda si no existe |
396 | 405 | if (in_array($documento['Encabezado']['IdDoc']['TipoDTE'], [111, 112])) { |
@@ -403,8 +412,9 @@ discard block |
||
403 | 412 | } |
404 | 413 | // agregar referencia de exportación si existe |
405 | 414 | if (!empty($caso['exportacion']['REFERENCIA'])) { |
406 | - if (!is_array($caso['exportacion']['REFERENCIA'])) |
|
407 | - $caso['exportacion']['REFERENCIA'] = [$caso['exportacion']['REFERENCIA']]; |
|
415 | + if (!is_array($caso['exportacion']['REFERENCIA'])) { |
|
416 | + $caso['exportacion']['REFERENCIA'] = [$caso['exportacion']['REFERENCIA']]; |
|
417 | + } |
|
408 | 418 | foreach ($caso['exportacion']['REFERENCIA'] as $ref) { |
409 | 419 | $documento['Referencia'][] = [ |
410 | 420 | 'TpoDocRef' => self::$referencias_exportacion[$ref], |
@@ -424,14 +434,16 @@ discard block |
||
424 | 434 | if (isset($documento['Encabezado']['Totales'])) { |
425 | 435 | $hayValor = false; |
426 | 436 | foreach ($documento['Detalle'] as $d) { |
427 | - if (!empty($d['PrcItem'])) |
|
428 | - $hayValor = true; |
|
437 | + if (!empty($d['PrcItem'])) { |
|
438 | + $hayValor = true; |
|
439 | + } |
|
429 | 440 | } |
430 | 441 | if (!$hayValor) { |
431 | - if (isset($documento['Encabezado']['Totales']['MntExe'])) |
|
432 | - $documento['Encabezado']['Totales'] = ['MntExe'=>0]; |
|
433 | - else |
|
434 | - $documento['Encabezado']['Totales'] = []; |
|
442 | + if (isset($documento['Encabezado']['Totales']['MntExe'])) { |
|
443 | + $documento['Encabezado']['Totales'] = ['MntExe'=>0]; |
|
444 | + } else { |
|
445 | + $documento['Encabezado']['Totales'] = []; |
|
446 | + } |
|
435 | 447 | $documento['Encabezado']['Totales']['MntTotal'] = 0; |
436 | 448 | } |
437 | 449 | } |
@@ -539,8 +551,9 @@ discard block |
||
539 | 551 | $n_lineas = count($lineas); |
540 | 552 | for ($i=$i; $i<$n_lineas; $i++) { |
541 | 553 | // si la línea está vacía se omite |
542 | - if (!$lineas[$i]) |
|
543 | - continue; |
|
554 | + if (!$lineas[$i]) { |
|
555 | + continue; |
|
556 | + } |
|
544 | 557 | // si hay descuento global se guarda |
545 | 558 | if (strpos($lineas[$i], 'DESCUENTO GLOBAL ITEMES AFECTOS')===0) { |
546 | 559 | $aux = explode("\t", $lineas[$i]); |
@@ -576,13 +589,15 @@ discard block |
||
576 | 589 | } |
577 | 590 | // agregar a los datos de aduanas |
578 | 591 | else { |
579 | - if (!isset($datos['exportacion'])) |
|
580 | - $datos['exportacion'] = []; |
|
592 | + if (!isset($datos['exportacion'])) { |
|
593 | + $datos['exportacion'] = []; |
|
594 | + } |
|
581 | 595 | if (!isset($datos['exportacion'][$var])) { |
582 | 596 | $datos['exportacion'][$var] = $val; |
583 | 597 | } else { |
584 | - if (!is_array($datos['exportacion'][$var])) |
|
585 | - $datos['exportacion'][$var] = [$datos['exportacion'][$var]]; |
|
598 | + if (!is_array($datos['exportacion'][$var])) { |
|
599 | + $datos['exportacion'][$var] = [$datos['exportacion'][$var]]; |
|
600 | + } |
|
586 | 601 | $datos['exportacion'][$var][] = $val; |
587 | 602 | } |
588 | 603 | } |
@@ -170,13 +170,13 @@ |
||
170 | 170 | } |
171 | 171 | // determinar neto e iva |
172 | 172 | $tasa = \sasco\LibreDTE\Sii::getIVA(); |
173 | - $neto = round(($d['MntTotal'] - $d['MntExe']) / (1 + $tasa/100)); |
|
173 | + $neto = round(($d['MntTotal']-$d['MntExe']) / (1+$tasa / 100)); |
|
174 | 174 | if ($neto) { |
175 | 175 | $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntNeto'] += $neto; |
176 | 176 | $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TasaIVA'] = $tasa; |
177 | 177 | // WARNING: problema por aproximaciones al calcular el NETO e IVA a partir del BRUTO |
178 | 178 | //$resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntIVA'] = round($resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntNeto'] * ($tasa/100)); |
179 | - $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntIVA'] = $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntTotal'] - $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntExe'] - $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntNeto']; |
|
179 | + $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntIVA'] = $resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntTotal']-$resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntExe']-$resumen[$d['TpoDoc']]['TotalesServicio'][$d['TpoServ']]['TotMntNeto']; |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | // documento anulado |
@@ -91,8 +91,9 @@ |
||
91 | 91 | public function generar() |
92 | 92 | { |
93 | 93 | // si ya se había generado se entrega directamente |
94 | - if ($this->xml_data) |
|
95 | - return $this->xml_data; |
|
94 | + if ($this->xml_data) { |
|
95 | + return $this->xml_data; |
|
96 | + } |
|
96 | 97 | // generar XML del envío |
97 | 98 | $xmlEnvio = (new \sasco\LibreDTE\XML())->generate([ |
98 | 99 | 'LibroBoleta' => [ |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ); |
96 | 96 | return false; |
97 | 97 | } |
98 | - return $plain === $plain_firmado; |
|
98 | + return $plain===$plain_firmado; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | public function getCertificacion() |
235 | 235 | { |
236 | 236 | $idk = $this->getIDK(); |
237 | - return $idk ? $idk === 100 : null; |
|
237 | + return $idk ? $idk===100 : null; |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | /** |
116 | 116 | * Método que entrega el RUT de a quién se está autorizando el CAF |
117 | - * @return Rut del emisor del CAF |
|
117 | + * @return false|string del emisor del CAF |
|
118 | 118 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
119 | 119 | * @version 2015-10-30 |
120 | 120 | */ |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Método que entrega la firma del SII sobre el nodo DA |
159 | - * @return Firma en base64 |
|
159 | + * @return false|string en base64 |
|
160 | 160 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
161 | 161 | * @version 2015-10-30 |
162 | 162 | */ |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | /** |
172 | 172 | * Método que entrega el IDK (serial number) de la clave pública del SII |
173 | 173 | * utilizada para firmar el CAF |
174 | - * @return Serial number |
|
174 | + * @return \sasco\LibreDTE\IDK|null number |
|
175 | 175 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
176 | 176 | * @version 2015-10-30 |
177 | 177 | */ |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | |
186 | 186 | /** |
187 | 187 | * Método que entrega la clave privada proporcionada por el SII para el CAF |
188 | - * @return Clave privada en base64 |
|
188 | + * @return false|string privada en base64 |
|
189 | 189 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
190 | 190 | * @version 2015-10-30 |
191 | 191 | */ |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | /** |
201 | 201 | * Método que entrega la clave pública proporcionada por el SII para el CAF |
202 | - * @return Clave pública en base64 |
|
202 | + * @return false|string pública en base64 |
|
203 | 203 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
204 | 204 | * @version 2015-10-30 |
205 | 205 | */ |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | /** |
229 | 229 | * Método que entrega la fecha de autorización con la que se emitió el CAF |
230 | - * @return Fecha de autorización del CAF |
|
230 | + * @return false|string de autorización del CAF |
|
231 | 231 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
232 | 232 | * @version 2017-07-19 |
233 | 233 | */ |
@@ -63,8 +63,9 @@ discard block |
||
63 | 63 | // validar firma del SII sobre los folios |
64 | 64 | $firma = $this->getFirma(); |
65 | 65 | $idk = $this->getIDK(); |
66 | - if (!$firma or !$idk) |
|
67 | - return false; |
|
66 | + if (!$firma or !$idk) { |
|
67 | + return false; |
|
68 | + } |
|
68 | 69 | $pub_key = \sasco\LibreDTE\Sii::cert($idk); |
69 | 70 | if (!$pub_key or openssl_verify($this->xml->getFlattened('/AUTORIZACION/CAF/DA'), base64_decode($firma), $pub_key)!==1) { |
70 | 71 | \sasco\LibreDTE\Log::write( |
@@ -75,8 +76,9 @@ discard block |
||
75 | 76 | } |
76 | 77 | // validar clave privada y pública proporcionada por el SII |
77 | 78 | $private_key = $this->getPrivateKey(); |
78 | - if (!$private_key) |
|
79 | - return false; |
|
79 | + if (!$private_key) { |
|
80 | + return false; |
|
81 | + } |
|
80 | 82 | $plain = md5(date('U')); |
81 | 83 | if (!openssl_private_encrypt($plain, $crypt, $private_key)) { |
82 | 84 | \sasco\LibreDTE\Log::write( |
@@ -86,8 +88,9 @@ discard block |
||
86 | 88 | return false; |
87 | 89 | } |
88 | 90 | $public_key = $this->getPublicKey(); |
89 | - if (!$public_key) |
|
90 | - return false; |
|
91 | + if (!$public_key) { |
|
92 | + return false; |
|
93 | + } |
|
91 | 94 | if (!openssl_public_decrypt($crypt, $plain_firmado, $public_key)) { |
92 | 95 | \sasco\LibreDTE\Log::write( |
93 | 96 | \sasco\LibreDTE\Estado::FOLIOS_ERROR_DESENCRIPTAR, |
@@ -106,8 +109,9 @@ discard block |
||
106 | 109 | */ |
107 | 110 | public function getCaf() |
108 | 111 | { |
109 | - if (!$this->xml) |
|
110 | - return false; |
|
112 | + if (!$this->xml) { |
|
113 | + return false; |
|
114 | + } |
|
111 | 115 | $CAF = $this->xml->getElementsByTagName('CAF')->item(0); |
112 | 116 | return $CAF ? $CAF : false; |
113 | 117 | } |
@@ -120,8 +124,9 @@ discard block |
||
120 | 124 | */ |
121 | 125 | public function getEmisor() |
122 | 126 | { |
123 | - if (!$this->xml) |
|
124 | - return false; |
|
127 | + if (!$this->xml) { |
|
128 | + return false; |
|
129 | + } |
|
125 | 130 | $RE = $this->xml->getElementsByTagName('RE')->item(0); |
126 | 131 | return $RE ? $RE->nodeValue : false; |
127 | 132 | } |
@@ -134,8 +139,9 @@ discard block |
||
134 | 139 | */ |
135 | 140 | public function getDesde() |
136 | 141 | { |
137 | - if (!$this->xml) |
|
138 | - return false; |
|
142 | + if (!$this->xml) { |
|
143 | + return false; |
|
144 | + } |
|
139 | 145 | $D = $this->xml->getElementsByTagName('D')->item(0); |
140 | 146 | return $D ? (int)$D->nodeValue : false; |
141 | 147 | } |
@@ -148,8 +154,9 @@ discard block |
||
148 | 154 | */ |
149 | 155 | public function getHasta() |
150 | 156 | { |
151 | - if (!$this->xml) |
|
152 | - return false; |
|
157 | + if (!$this->xml) { |
|
158 | + return false; |
|
159 | + } |
|
153 | 160 | $H = $this->xml->getElementsByTagName('H')->item(0); |
154 | 161 | return $H ? (int)$H->nodeValue : false; |
155 | 162 | } |
@@ -162,8 +169,9 @@ discard block |
||
162 | 169 | */ |
163 | 170 | private function getFirma() |
164 | 171 | { |
165 | - if (!$this->xml) |
|
166 | - return false; |
|
172 | + if (!$this->xml) { |
|
173 | + return false; |
|
174 | + } |
|
167 | 175 | $FRMA = $this->xml->getElementsByTagName('FRMA')->item(0); |
168 | 176 | return $FRMA ? $FRMA->nodeValue : false; |
169 | 177 | } |
@@ -177,8 +185,9 @@ discard block |
||
177 | 185 | */ |
178 | 186 | private function getIDK() |
179 | 187 | { |
180 | - if (!$this->xml) |
|
181 | - return false; |
|
188 | + if (!$this->xml) { |
|
189 | + return false; |
|
190 | + } |
|
182 | 191 | $IDK = $this->xml->getElementsByTagName('IDK')->item(0); |
183 | 192 | return $IDK ? (int)$IDK->nodeValue : false; |
184 | 193 | } |
@@ -191,8 +200,9 @@ discard block |
||
191 | 200 | */ |
192 | 201 | public function getPrivateKey() |
193 | 202 | { |
194 | - if (!$this->xml) |
|
195 | - return false; |
|
203 | + if (!$this->xml) { |
|
204 | + return false; |
|
205 | + } |
|
196 | 206 | $RSASK = $this->xml->getElementsByTagName('RSASK')->item(0); |
197 | 207 | return $RSASK ? $RSASK->nodeValue : false; |
198 | 208 | } |
@@ -205,8 +215,9 @@ discard block |
||
205 | 215 | */ |
206 | 216 | public function getPublicKey() |
207 | 217 | { |
208 | - if (!$this->xml) |
|
209 | - return false; |
|
218 | + if (!$this->xml) { |
|
219 | + return false; |
|
220 | + } |
|
210 | 221 | $RSAPUBK = $this->xml->getElementsByTagName('RSAPUBK')->item(0); |
211 | 222 | return $RSAPUBK ? $RSAPUBK->nodeValue : false; |
212 | 223 | } |
@@ -219,8 +230,9 @@ discard block |
||
219 | 230 | */ |
220 | 231 | public function getTipo() |
221 | 232 | { |
222 | - if (!$this->xml) |
|
223 | - return false; |
|
233 | + if (!$this->xml) { |
|
234 | + return false; |
|
235 | + } |
|
224 | 236 | $TD = $this->xml->getElementsByTagName('TD')->item(0); |
225 | 237 | return $TD ? (int)$TD->nodeValue : false; |
226 | 238 | } |
@@ -233,8 +245,9 @@ discard block |
||
233 | 245 | */ |
234 | 246 | public function getFechaAutorizacion() |
235 | 247 | { |
236 | - if (!$this->xml) |
|
237 | - return false; |
|
248 | + if (!$this->xml) { |
|
249 | + return false; |
|
250 | + } |
|
238 | 251 | $FA = $this->xml->getElementsByTagName('FA')->item(0); |
239 | 252 | return $FA ? $FA->nodeValue : false; |
240 | 253 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | { |
126 | 126 | $fecha = '9999-12-31'; |
127 | 127 | foreach ($this->detalles as &$d) { |
128 | - if ($d['FchDoc'] < $fecha) |
|
128 | + if ($d['FchDoc']<$fecha) |
|
129 | 129 | $fecha = $d['FchDoc']; |
130 | 130 | } |
131 | 131 | return $fecha; |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | { |
142 | 142 | $fecha = '0000-01-01'; |
143 | 143 | foreach ($this->detalles as &$d) { |
144 | - if ($d['FchDoc'] > $fecha) |
|
144 | + if ($d['FchDoc']>$fecha) |
|
145 | 145 | $fecha = $d['FchDoc']; |
146 | 146 | } |
147 | 147 | return $fecha; |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | // ajustes post agregar detalles |
200 | 200 | foreach ($Resumen as &$r) { |
201 | 201 | // obtener folios utilizados = emitidos + anulados |
202 | - $r['FoliosUtilizados'] = $r['FoliosEmitidos'] + $r['FoliosAnulados']; |
|
202 | + $r['FoliosUtilizados'] = $r['FoliosEmitidos']+$r['FoliosAnulados']; |
|
203 | 203 | $r['RangoUtilizados'] = $this->getRangos($RangoUtilizados[$r['TipoDocumento']]); |
204 | 204 | } |
205 | 205 | // completar con los resumenes que no se colocaron |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | $aux = []; |
232 | 232 | $inicial = $folios[0]; |
233 | 233 | $i = $inicial; |
234 | - foreach($folios as $f) { |
|
234 | + foreach ($folios as $f) { |
|
235 | 235 | if ($i!=$f) { |
236 | 236 | $inicial = $f; |
237 | 237 | $i = $inicial; |
@@ -90,8 +90,9 @@ discard block |
||
90 | 90 | public function generar() |
91 | 91 | { |
92 | 92 | // si ya se había generado se entrega directamente |
93 | - if ($this->xml_data) |
|
94 | - return $this->xml_data; |
|
93 | + if ($this->xml_data) { |
|
94 | + return $this->xml_data; |
|
95 | + } |
|
95 | 96 | // generar XML del envío |
96 | 97 | $xmlEnvio = (new \sasco\LibreDTE\XML())->generate([ |
97 | 98 | 'ConsumoFolios' => [ |
@@ -125,8 +126,9 @@ discard block |
||
125 | 126 | { |
126 | 127 | $fecha = '9999-12-31'; |
127 | 128 | foreach ($this->detalles as &$d) { |
128 | - if ($d['FchDoc'] < $fecha) |
|
129 | - $fecha = $d['FchDoc']; |
|
129 | + if ($d['FchDoc'] < $fecha) { |
|
130 | + $fecha = $d['FchDoc']; |
|
131 | + } |
|
130 | 132 | } |
131 | 133 | return $fecha; |
132 | 134 | } |
@@ -141,8 +143,9 @@ discard block |
||
141 | 143 | { |
142 | 144 | $fecha = '0000-01-01'; |
143 | 145 | foreach ($this->detalles as &$d) { |
144 | - if ($d['FchDoc'] > $fecha) |
|
145 | - $fecha = $d['FchDoc']; |
|
146 | + if ($d['FchDoc'] > $fecha) { |
|
147 | + $fecha = $d['FchDoc']; |
|
148 | + } |
|
146 | 149 | } |
147 | 150 | return $fecha; |
148 | 151 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | { |
37 | 37 | |
38 | 38 | private static $idioma = 'es'; ///< Idioma por defecto de los mensajes |
39 | - private static $locales = [ ///< Mapeo de idioma a locales |
|
39 | + private static $locales = [///< Mapeo de idioma a locales |
|
40 | 40 | 'es' => 'es_CL.utf8', |
41 | 41 | 'en' => 'en_US.utf8', |
42 | 42 | ]; |
@@ -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 |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | { |
149 | 149 | $widths = []; |
150 | 150 | if (is_int($cells)) { |
151 | - $width = floor($total/$cells); |
|
152 | - for ($i=0; $i<$cells; ++$i) { |
|
151 | + $width = floor($total / $cells); |
|
152 | + for ($i = 0; $i<$cells; ++$i) { |
|
153 | 153 | $widths[] = $width; |
154 | 154 | } |
155 | 155 | } |
156 | - else if (is_array($cells)){ |
|
157 | - $width = floor($total/count($cells)); |
|
156 | + else if (is_array($cells)) { |
|
157 | + $width = floor($total / count($cells)); |
|
158 | 158 | foreach ($cells as $i) { |
159 | 159 | $widths[$i] = $width; |
160 | 160 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | $suma += $val; |
205 | 205 | } |
206 | 206 | if ($key_0!==null) { |
207 | - $options['width'][$key_0] = 190 - $suma; |
|
207 | + $options['width'][$key_0] = 190-$suma; |
|
208 | 208 | } |
209 | 209 | } |
210 | 210 | if (isset($options['align'])) |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $a = (isset($options['align']) and is_array($options['align'])) ? $options['align'] : []; |
240 | 240 | $buffer = '<table style="border:1px solid #333">'; |
241 | 241 | // Definir títulos de columnas |
242 | - $thead = isset($options['width']) and is_array($options['width']) and count($options['width']) == count($headers); |
|
242 | + $thead = isset($options['width']) and is_array($options['width']) and count($options['width'])==count($headers); |
|
243 | 243 | if ($thead) |
244 | 244 | $buffer .= '<thead>'; |
245 | 245 | $buffer .= '<tr>'; |
@@ -293,16 +293,15 @@ discard block |
||
293 | 293 | $options['headercolor'][1], |
294 | 294 | $options['headercolor'][2] |
295 | 295 | ); |
296 | - $this->SetFont($this->defaultOptions['font']['family'], 'B', $options['fontsize']); |
|
296 | + $this->SetFont($this->defaultOptions['font']['family'], 'B', $options['fontsize']); |
|
297 | 297 | // Header |
298 | - $w = is_array($options['width']) ? $options['width'] : |
|
299 | - $this->getTableCellWidth($options['width'], array_keys($headers)); |
|
300 | - foreach($headers as $i => $header) { |
|
301 | - $this->Cell ($w[$i], $options['height'], $headers[$i], 1, 0, $options['align'], 1); |
|
298 | + $w = is_array($options['width']) ? $options['width'] : $this->getTableCellWidth($options['width'], array_keys($headers)); |
|
299 | + foreach ($headers as $i => $header) { |
|
300 | + $this->Cell($w[$i], $options['height'], $headers[$i], 1, 0, $options['align'], 1); |
|
302 | 301 | } |
303 | 302 | $this->Ln(); |
304 | 303 | // Color and font restoration |
305 | - $this->SetFillColor ( |
|
304 | + $this->SetFillColor( |
|
306 | 305 | $options['bodybackground'][0], |
307 | 306 | $options['bodybackground'][1], |
308 | 307 | $options['bodybackground'][2] |
@@ -318,19 +317,19 @@ discard block |
||
318 | 317 | foreach ($data as &$row) { |
319 | 318 | $num_pages = $this->getNumPages(); |
320 | 319 | $this->startTransaction(); |
321 | - foreach($headers as $i => $header) { |
|
322 | - $this->Cell ($w[$i], $options['height'], $row[$i], 'LR', 0, $options['align'], $fill); |
|
320 | + foreach ($headers as $i => $header) { |
|
321 | + $this->Cell($w[$i], $options['height'], $row[$i], 'LR', 0, $options['align'], $fill); |
|
323 | 322 | } |
324 | 323 | $this->Ln(); |
325 | - if($num_pages < $this->getNumPages()) { |
|
324 | + if ($num_pages<$this->getNumPages()) { |
|
326 | 325 | $this->rollbackTransaction(true); |
327 | 326 | $this->AddPage(); |
328 | - foreach($headers as $i => $header) { |
|
329 | - $this->Cell ($w[$i], $options['height'], $headers[$i], 1, 0, $options['align'], 1); |
|
327 | + foreach ($headers as $i => $header) { |
|
328 | + $this->Cell($w[$i], $options['height'], $headers[$i], 1, 0, $options['align'], 1); |
|
330 | 329 | } |
331 | 330 | $this->Ln(); |
332 | - foreach($headers as $i => $header) { |
|
333 | - $this->Cell ($w[$i], $options['height'], $row[$i], 'LR', 0, $options['align'], $fill); |
|
331 | + foreach ($headers as $i => $header) { |
|
332 | + $this->Cell($w[$i], $options['height'], $row[$i], 'LR', 0, $options['align'], $fill); |
|
334 | 333 | } |
335 | 334 | $this->Ln(); |
336 | 335 | } else { |
@@ -350,7 +349,7 @@ discard block |
||
350 | 349 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl) |
351 | 350 | * @version 2014-09-20 |
352 | 351 | */ |
353 | - public function Texto($txt, $x=null, $y=null, $align='', $w=0, $link='', $border=0, $fill=false) |
|
352 | + public function Texto($txt, $x = null, $y = null, $align = '', $w = 0, $link = '', $border = 0, $fill = false) |
|
354 | 353 | { |
355 | 354 | if ($x==null) $x = $this->GetX(); |
356 | 355 | if ($y==null) $y = $this->GetY(); |
@@ -371,7 +370,7 @@ discard block |
||
371 | 370 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]delaf.cl) |
372 | 371 | * @version 2014-09-20 |
373 | 372 | */ |
374 | - public function MultiTexto($txt, $x=null, $y=null, $align='', $w=0, $border=0, $fill=false) |
|
373 | + public function MultiTexto($txt, $x = null, $y = null, $align = '', $w = 0, $border = 0, $fill = false) |
|
375 | 374 | { |
376 | 375 | if ($x==null) $x = $this->GetX(); |
377 | 376 | if ($y==null) $y = $this->GetY(); |
@@ -98,13 +98,16 @@ discard block |
||
98 | 98 | $this->Line(0, $this->getY()-1, 290, $this->getY()-2, $style); |
99 | 99 | $this->SetFont('', 'B', 6); |
100 | 100 | if (empty($this->papelContinuo)) { |
101 | - if (!empty($this->footer['left'])) |
|
102 | - $this->Texto($this->footer['left']); |
|
103 | - if (!empty($this->footer['right'])) |
|
104 | - $this->Texto($this->footer['right'], null, null, 'R'); |
|
101 | + if (!empty($this->footer['left'])) { |
|
102 | + $this->Texto($this->footer['left']); |
|
103 | + } |
|
104 | + if (!empty($this->footer['right'])) { |
|
105 | + $this->Texto($this->footer['right'], null, null, 'R'); |
|
106 | + } |
|
105 | 107 | } else { |
106 | - if (!empty($this->footer['left'])) |
|
107 | - $this->Texto($this->footer['left'], null, null, 'C'); |
|
108 | + if (!empty($this->footer['left'])) { |
|
109 | + $this->Texto($this->footer['left'], null, null, 'C'); |
|
110 | + } |
|
108 | 111 | if (!empty($this->footer['right'])) { |
109 | 112 | $this->Ln(); |
110 | 113 | $this->Texto($this->footer['right'], null, null, 'C'); |
@@ -130,8 +133,9 @@ discard block |
||
130 | 133 | ]; |
131 | 134 | } |
132 | 135 | // si no es arreglo se convierte en uno |
133 | - if (!is_array($footer)) |
|
134 | - $footer = ['left'=>$footer]; |
|
136 | + if (!is_array($footer)) { |
|
137 | + $footer = ['left'=>$footer]; |
|
138 | + } |
|
135 | 139 | // asignar footer |
136 | 140 | $this->footer = array_merge(['left'=>'', 'right'=>''], $footer); |
137 | 141 | } else { |
@@ -152,8 +156,7 @@ discard block |
||
152 | 156 | for ($i=0; $i<$cells; ++$i) { |
153 | 157 | $widths[] = $width; |
154 | 158 | } |
155 | - } |
|
156 | - else if (is_array($cells)){ |
|
159 | + } else if (is_array($cells)){ |
|
157 | 160 | $width = floor($total/count($cells)); |
158 | 161 | foreach ($cells as $i) { |
159 | 162 | $widths[$i] = $width; |
@@ -174,8 +177,9 @@ discard block |
||
174 | 177 | foreach ($data as $row) { |
175 | 178 | foreach ($row as $col => $value) { |
176 | 179 | if (empty($value)) { |
177 | - if (!array_key_exists($col, $cols_empty)) |
|
178 | - $cols_empty[$col] = 0; |
|
180 | + if (!array_key_exists($col, $cols_empty)) { |
|
181 | + $cols_empty[$col] = 0; |
|
182 | + } |
|
179 | 183 | $cols_empty[$col]++; |
180 | 184 | } |
181 | 185 | } |
@@ -188,10 +192,12 @@ discard block |
||
188 | 192 | foreach ($data as &$row) { |
189 | 193 | unset($row[$col]); |
190 | 194 | } |
191 | - if (isset($options['width'])) |
|
192 | - unset($options['width'][$titles_keys[$col]]); |
|
193 | - if (isset($options['align'])) |
|
194 | - unset($options['align'][$titles_keys[$col]]); |
|
195 | + if (isset($options['width'])) { |
|
196 | + unset($options['width'][$titles_keys[$col]]); |
|
197 | + } |
|
198 | + if (isset($options['align'])) { |
|
199 | + unset($options['align'][$titles_keys[$col]]); |
|
200 | + } |
|
195 | 201 | } |
196 | 202 | } |
197 | 203 | if (isset($options['width'])) { |
@@ -199,16 +205,18 @@ discard block |
||
199 | 205 | $key_0 = null; |
200 | 206 | $suma = 0; |
201 | 207 | foreach ($options['width'] as $key => $val) { |
202 | - if ($val===0) |
|
203 | - $key_0 = $key; |
|
208 | + if ($val===0) { |
|
209 | + $key_0 = $key; |
|
210 | + } |
|
204 | 211 | $suma += $val; |
205 | 212 | } |
206 | 213 | if ($key_0!==null) { |
207 | 214 | $options['width'][$key_0] = 190 - $suma; |
208 | 215 | } |
209 | 216 | } |
210 | - if (isset($options['align'])) |
|
211 | - $options['align'] = array_slice($options['align'], 0); |
|
217 | + if (isset($options['align'])) { |
|
218 | + $options['align'] = array_slice($options['align'], 0); |
|
219 | + } |
|
212 | 220 | $this->addTable($titles, $data, $options, $html); |
213 | 221 | } |
214 | 222 | |
@@ -240,8 +248,9 @@ discard block |
||
240 | 248 | $buffer = '<table style="border:1px solid #333">'; |
241 | 249 | // Definir títulos de columnas |
242 | 250 | $thead = isset($options['width']) and is_array($options['width']) and count($options['width']) == count($headers); |
243 | - if ($thead) |
|
244 | - $buffer .= '<thead>'; |
|
251 | + if ($thead) { |
|
252 | + $buffer .= '<thead>'; |
|
253 | + } |
|
245 | 254 | $buffer .= '<tr>'; |
246 | 255 | $i = 0; |
247 | 256 | foreach ($headers as &$col) { |
@@ -251,11 +260,13 @@ discard block |
||
251 | 260 | $i++; |
252 | 261 | } |
253 | 262 | $buffer .= '</tr>'; |
254 | - if ($thead) |
|
255 | - $buffer .= '</thead>'; |
|
263 | + if ($thead) { |
|
264 | + $buffer .= '</thead>'; |
|
265 | + } |
|
256 | 266 | // Definir datos de la tabla |
257 | - if ($thead) |
|
258 | - $buffer .= '<tbody>'; |
|
267 | + if ($thead) { |
|
268 | + $buffer .= '<tbody>'; |
|
269 | + } |
|
259 | 270 | foreach ($data as &$row) { |
260 | 271 | $buffer .= '<tr>'; |
261 | 272 | $i = 0; |
@@ -267,8 +278,9 @@ discard block |
||
267 | 278 | } |
268 | 279 | $buffer .= '</tr>'; |
269 | 280 | } |
270 | - if ($thead) |
|
271 | - $buffer .= '</tbody>'; |
|
281 | + if ($thead) { |
|
282 | + $buffer .= '</tbody>'; |
|
283 | + } |
|
272 | 284 | // Finalizar tabla |
273 | 285 | $buffer .= '</table>'; |
274 | 286 | // generar tabla en HTML |
@@ -336,8 +348,9 @@ discard block |
||
336 | 348 | } else { |
337 | 349 | $this->commitTransaction(); |
338 | 350 | } |
339 | - if ($options['colorchange']) |
|
340 | - $fill = !$fill; |
|
351 | + if ($options['colorchange']) { |
|
352 | + $fill = !$fill; |
|
353 | + } |
|
341 | 354 | } |
342 | 355 | $this->Cell(array_sum($w), 0, '', 'T'); |
343 | 356 | $this->Ln(); |
@@ -352,8 +365,12 @@ discard block |
||
352 | 365 | */ |
353 | 366 | public function Texto($txt, $x=null, $y=null, $align='', $w=0, $link='', $border=0, $fill=false) |
354 | 367 | { |
355 | - if ($x==null) $x = $this->GetX(); |
|
356 | - if ($y==null) $y = $this->GetY(); |
|
368 | + if ($x==null) { |
|
369 | + $x = $this->GetX(); |
|
370 | + } |
|
371 | + if ($y==null) { |
|
372 | + $y = $this->GetY(); |
|
373 | + } |
|
357 | 374 | $textrendermode = $this->textrendermode; |
358 | 375 | $textstrokewidth = $this->textstrokewidth; |
359 | 376 | $this->setTextRenderingMode(0, true, false); |
@@ -373,8 +390,12 @@ discard block |
||
373 | 390 | */ |
374 | 391 | public function MultiTexto($txt, $x=null, $y=null, $align='', $w=0, $border=0, $fill=false) |
375 | 392 | { |
376 | - if ($x==null) $x = $this->GetX(); |
|
377 | - if ($y==null) $y = $this->GetY(); |
|
393 | + if ($x==null) { |
|
394 | + $x = $this->GetX(); |
|
395 | + } |
|
396 | + if ($y==null) { |
|
397 | + $y = $this->GetY(); |
|
398 | + } |
|
378 | 399 | $textrendermode = $this->textrendermode; |
379 | 400 | $textstrokewidth = $this->textstrokewidth; |
380 | 401 | $this->setTextRenderingMode(0, true, false); |
@@ -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], |
@@ -317,10 +317,10 @@ discard block |
||
317 | 317 | */ |
318 | 318 | public function verify($data, $signature, $pub_key = null, $signature_alg = OPENSSL_ALGO_SHA1) |
319 | 319 | { |
320 | - if ($pub_key === null) |
|
320 | + if ($pub_key===null) |
|
321 | 321 | $pub_key = $this->certs['cert']; |
322 | 322 | $pub_key = $this->normalizeCert($pub_key); |
323 | - return openssl_verify($data, base64_decode($signature), $pub_key, $signature_alg) == 1 ? true : false; |
|
323 | + return openssl_verify($data, base64_decode($signature), $pub_key, $signature_alg)==1 ? true : false; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | } else { |
452 | 452 | $digest_calculado = base64_encode(sha1($doc->C14N(), true)); |
453 | 453 | } |
454 | - return $digest_original == $digest_calculado; |
|
454 | + return $digest_original==$digest_calculado; |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | /** |
@@ -164,8 +164,9 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function getName() |
166 | 166 | { |
167 | - if (isset($this->data['subject']['CN'])) |
|
168 | - return $this->data['subject']['CN']; |
|
167 | + if (isset($this->data['subject']['CN'])) { |
|
168 | + return $this->data['subject']['CN']; |
|
169 | + } |
|
169 | 170 | return $this->error('No fue posible obtener el Name (subject.CN) de la firma'); |
170 | 171 | } |
171 | 172 | |
@@ -177,8 +178,9 @@ discard block |
||
177 | 178 | */ |
178 | 179 | public function getEmail() |
179 | 180 | { |
180 | - if (isset($this->data['subject']['emailAddress'])) |
|
181 | - return $this->data['subject']['emailAddress']; |
|
181 | + if (isset($this->data['subject']['emailAddress'])) { |
|
182 | + return $this->data['subject']['emailAddress']; |
|
183 | + } |
|
182 | 184 | return $this->error('No fue posible obtener el Email (subject.emailAddress) de la firma'); |
183 | 185 | } |
184 | 186 | |
@@ -317,8 +319,9 @@ discard block |
||
317 | 319 | */ |
318 | 320 | public function verify($data, $signature, $pub_key = null, $signature_alg = OPENSSL_ALGO_SHA1) |
319 | 321 | { |
320 | - if ($pub_key === null) |
|
321 | - $pub_key = $this->certs['cert']; |
|
322 | + if ($pub_key === null) { |
|
323 | + $pub_key = $this->certs['cert']; |
|
324 | + } |
|
322 | 325 | $pub_key = $this->normalizeCert($pub_key); |
323 | 326 | return openssl_verify($data, base64_decode($signature), $pub_key, $signature_alg) == 1 ? true : false; |
324 | 327 | } |
@@ -409,8 +412,9 @@ discard block |
||
409 | 412 | // calcular SignatureValue |
410 | 413 | $SignedInfo = $doc->saveHTML($Signature->getElementsByTagName('SignedInfo')->item(0)); |
411 | 414 | $firma = $this->sign($SignedInfo); |
412 | - if (!$firma) |
|
413 | - return false; |
|
415 | + if (!$firma) { |
|
416 | + return false; |
|
417 | + } |
|
414 | 418 | $signature = wordwrap($firma, $this->config['wordwrap'], "\n", true); |
415 | 419 | // reemplazar valores en la firma de |
416 | 420 | $Signature->getElementsByTagName('SignatureValue')->item(0)->nodeValue = $signature; |
@@ -442,8 +446,9 @@ discard block |
||
442 | 446 | $signature = $Signature->getElementsByTagName('SignatureValue')->item(0)->nodeValue; |
443 | 447 | $pub_key = $Signature->getElementsByTagName('X509Certificate')->item(0)->nodeValue; |
444 | 448 | // verificar firma |
445 | - if (!$this->verify($signed_info, $signature, $pub_key)) |
|
446 | - return false; |
|
449 | + if (!$this->verify($signed_info, $signature, $pub_key)) { |
|
450 | + return false; |
|
451 | + } |
|
447 | 452 | // verificar digest |
448 | 453 | $digest_original = $Signature->getElementsByTagName('DigestValue')->item(0)->nodeValue; |
449 | 454 | if ($tag) { |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | /** |
101 | 101 | * Método para generar un error usando una excepción de SowerPHP o terminar |
102 | 102 | * el script si no se está usando el framework |
103 | - * @param msg Mensaje del error |
|
103 | + * @param msg string del error |
|
104 | 104 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
105 | 105 | * @version 2017-08-04 |
106 | 106 | */ |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | |
189 | 189 | /** |
190 | 190 | * Método que entrega desde cuando es válida la firma |
191 | - * @return validFrom_time_t |
|
191 | + * @return string |
|
192 | 192 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
193 | 193 | * @version 2015-09-22 |
194 | 194 | */ |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | |
200 | 200 | /** |
201 | 201 | * Método que entrega hasta cuando es válida la firma |
202 | - * @return validTo_time_t |
|
202 | + * @return string |
|
203 | 203 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
204 | 204 | * @version 2015-09-22 |
205 | 205 | */ |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | |
233 | 233 | /** |
234 | 234 | * Método que obtiene el módulo de la clave privada |
235 | - * @return Módulo en base64 |
|
235 | + * @return string en base64 |
|
236 | 236 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
237 | 237 | * @version 2014-12-07 |
238 | 238 | */ |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | |
245 | 245 | /** |
246 | 246 | * Método que obtiene el exponente público de la clave privada |
247 | - * @return Exponente público en base64 |
|
247 | + * @return string público en base64 |
|
248 | 248 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
249 | 249 | * @version 2014-12-06 |
250 | 250 | */ |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | |
295 | 295 | /** |
296 | 296 | * Método para realizar la firma de datos |
297 | - * @param data Datos que se desean firmar |
|
297 | + * @param data string que se desean firmar |
|
298 | 298 | * @param signature_alg Algoritmo que se utilizará para firmar (por defect SHA1) |
299 | - * @return Firma digital de los datos en base64 o =false si no se pudo firmar |
|
299 | + * @return boolean|string digital de los datos en base64 o =false si no se pudo firmar |
|
300 | 300 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
301 | 301 | * @version 2014-12-08 |
302 | 302 | */ |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | |
312 | 312 | /** |
313 | 313 | * Método que verifica la firma digital de datos |
314 | - * @param data Datos que se desean verificar |
|
314 | + * @param data string que se desean verificar |
|
315 | 315 | * @param signature Firma digital de los datos en base64 |
316 | 316 | * @param pub_key Certificado digital, clave pública, de la firma |
317 | 317 | * @param signature_alg Algoritmo que se usó para firmar (por defect SHA1) |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @param xml Datos XML que se desean firmar |
336 | 336 | * @param reference Referencia a la que hace la firma |
337 | - * @return XML firmado o =false si no se pudo fimar |
|
337 | + * @return boolean|string firmado o =false si no se pudo fimar |
|
338 | 338 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
339 | 339 | * @version 2017-07-24 |
340 | 340 | */ |