@@ -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' => [ |
@@ -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-10-22 |
| 340 | 340 | */ |
@@ -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"); |
@@ -174,12 +174,14 @@ |
||
| 174 | 174 | public static function get($codigo, $args = null) |
| 175 | 175 | { |
| 176 | 176 | // si no hay glosa asociada al código se entrega el mismo código |
| 177 | - if (!isset(self::$glosas[(int)$codigo])) |
|
| 178 | - return (int)$codigo; |
|
| 177 | + if (!isset(self::$glosas[(int)$codigo])) { |
|
| 178 | + return (int)$codigo; |
|
| 179 | + } |
|
| 179 | 180 | // si los argumentos no son un arreglo se obtiene arreglo a partir |
| 180 | 181 | // de los argumentos pasados a la función |
| 181 | - if (!is_array($args)) |
|
| 182 | - $args = array_slice(func_get_args(), 1); |
|
| 182 | + if (!is_array($args)) { |
|
| 183 | + $args = array_slice(func_get_args(), 1); |
|
| 184 | + } |
|
| 183 | 185 | // entregar glosa |
| 184 | 186 | return vsprintf(I18n::translate(self::$glosas[(int)$codigo], 'estados'), $args); |
| 185 | 187 | } |