@@ -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); |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | |
238 | 238 | /** |
239 | 239 | * Método que entrega el tipo de DTE |
240 | - * @return Tipo de dte, ej: 33 (factura electrónica) |
|
240 | + * @return string de dte, ej: 33 (factura electrónica) |
|
241 | 241 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
242 | 242 | * @version 2015-09-02 |
243 | 243 | */ |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | /** |
250 | 250 | * Método que entrega el folio del DTE |
251 | - * @return Folio del DTE |
|
251 | + * @return string del DTE |
|
252 | 252 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
253 | 253 | * @version 2015-09-02 |
254 | 254 | */ |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | |
260 | 260 | /** |
261 | 261 | * Método que entrega rut del emisor del DTE |
262 | - * @return RUT del emiro |
|
262 | + * @return string del emiro |
|
263 | 263 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
264 | 264 | * @version 2015-09-07 |
265 | 265 | */ |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | |
276 | 276 | /** |
277 | 277 | * Método que entrega rut del receptor del DTE |
278 | - * @return RUT del emiro |
|
278 | + * @return string del emiro |
|
279 | 279 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
280 | 280 | * @version 2015-09-07 |
281 | 281 | */ |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | |
292 | 292 | /** |
293 | 293 | * Método que entrega fecha de emisión del DTE |
294 | - * @return Fecha de emisión en formato AAAA-MM-DD |
|
294 | + * @return string de emisión en formato AAAA-MM-DD |
|
295 | 295 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
296 | 296 | * @version 2015-09-07 |
297 | 297 | */ |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | |
401 | 401 | /** |
402 | 402 | * Método que realiza el timbrado del DTE |
403 | - * @param Folios Objeto de los Folios con los que se desea timbrar |
|
403 | + * @param Folios Folios de los Folios con los que se desea timbrar |
|
404 | 404 | * @return =true si se pudo timbrar o =false en caso de error |
405 | 405 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
406 | 406 | * @version 2016-09-01 |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | |
487 | 487 | /** |
488 | 488 | * Método que realiza la firma del DTE |
489 | - * @param Firma objeto que representa la Firma Electrónca |
|
489 | + * @param Firma \sasco\LibreDTE\FirmaElectronica que representa la Firma Electrónca |
|
490 | 490 | * @return =true si el DTE pudo ser fimado o =false si no se pudo firmar |
491 | 491 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
492 | 492 | * @version 2017-10-22 |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | |
510 | 510 | /** |
511 | 511 | * Método que entrega el DTE en XML |
512 | - * @return XML con el DTE (podría: con o sin timbre y con o sin firma) |
|
512 | + * @return string con el DTE (podría: con o sin timbre y con o sin firma) |
|
513 | 513 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
514 | 514 | * @version 2015-08-20 |
515 | 515 | */ |
@@ -1767,7 +1767,7 @@ discard block |
||
1767 | 1767 | * - Firma del DTE |
1768 | 1768 | * - RUT del emisor (si se pasó uno para comparar) |
1769 | 1769 | * - RUT del receptor (si se pasó uno para comparar) |
1770 | - * @return Código del estado de la validación |
|
1770 | + * @return integer del estado de la validación |
|
1771 | 1771 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
1772 | 1772 | * @version 2019-07-03 |
1773 | 1773 | */ |
@@ -1880,7 +1880,7 @@ discard block |
||
1880 | 1880 | |
1881 | 1881 | /** |
1882 | 1882 | * Método que obtiene el estado del DTE |
1883 | - * @param Firma objeto que representa la Firma Electrónca |
|
1883 | + * @param Firma \sasco\LibreDTE\FirmaElectronica que representa la Firma Electrónca |
|
1884 | 1884 | * @return Arreglo con el estado del DTE |
1885 | 1885 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
1886 | 1886 | * @version 2015-10-24 |
@@ -1921,7 +1921,7 @@ discard block |
||
1921 | 1921 | |
1922 | 1922 | /** |
1923 | 1923 | * Método que obtiene el estado avanzado del DTE |
1924 | - * @param Firma objeto que representa la Firma Electrónca |
|
1924 | + * @param Firma \sasco\LibreDTE\FirmaElectronica que representa la Firma Electrónca |
|
1925 | 1925 | * @return Arreglo con el estado del DTE |
1926 | 1926 | * @todo Corregir warning y también definir que se retornará (sobre todo en caso de error) |
1927 | 1927 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
@@ -57,10 +57,11 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function __construct($datos, $normalizar = true) |
59 | 59 | { |
60 | - if (is_array($datos)) |
|
61 | - $this->setDatos($datos, $normalizar); |
|
62 | - else if (is_string($datos)) |
|
63 | - $this->loadXML($datos); |
|
60 | + if (is_array($datos)) { |
|
61 | + $this->setDatos($datos, $normalizar); |
|
62 | + } else if (is_string($datos)) { |
|
63 | + $this->loadXML($datos); |
|
64 | + } |
|
64 | 65 | $this->timestamp = date('Y-m-d\TH:i:s'); |
65 | 66 | } |
66 | 67 | |
@@ -121,8 +122,9 @@ discard block |
||
121 | 122 | if ($normalizar) { |
122 | 123 | $this->normalizar($datos); |
123 | 124 | $method = 'normalizar_'.$this->tipo; |
124 | - if (method_exists($this, $method)) |
|
125 | - $this->$method($datos); |
|
125 | + if (method_exists($this, $method)) { |
|
126 | + $this->$method($datos); |
|
127 | + } |
|
126 | 128 | $this->normalizar_final($datos); |
127 | 129 | } |
128 | 130 | $this->tipo_general = $this->getTipoGeneral($this->tipo); |
@@ -199,8 +201,9 @@ discard block |
||
199 | 201 | */ |
200 | 202 | public function getJSON() |
201 | 203 | { |
202 | - if (!$this->getDatos()) |
|
203 | - return false; |
|
204 | + if (!$this->getDatos()) { |
|
205 | + return false; |
|
206 | + } |
|
204 | 207 | return json_encode($this->datos, JSON_PRETTY_PRINT); |
205 | 208 | } |
206 | 209 | |
@@ -225,9 +228,10 @@ discard block |
||
225 | 228 | */ |
226 | 229 | private function getTipoGeneral($dte) |
227 | 230 | { |
228 | - foreach ($this->tipos as $tipo => $codigos) |
|
229 | - if (in_array($dte, $codigos)) |
|
231 | + foreach ($this->tipos as $tipo => $codigos) { |
|
232 | + if (in_array($dte, $codigos)) |
|
230 | 233 | return $tipo; |
234 | + } |
|
231 | 235 | \sasco\LibreDTE\Log::write( |
232 | 236 | \sasco\LibreDTE\Estado::DTE_ERROR_TIPO, |
233 | 237 | \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::DTE_ERROR_TIPO, $dte) |
@@ -266,10 +270,12 @@ discard block |
||
266 | 270 | public function getEmisor() |
267 | 271 | { |
268 | 272 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Emisor/RUTEmisor')->item(0); |
269 | - if ($nodo) |
|
270 | - return $nodo->nodeValue; |
|
271 | - if (!$this->getDatos()) |
|
272 | - return false; |
|
273 | + if ($nodo) { |
|
274 | + return $nodo->nodeValue; |
|
275 | + } |
|
276 | + if (!$this->getDatos()) { |
|
277 | + return false; |
|
278 | + } |
|
273 | 279 | return $this->datos['Encabezado']['Emisor']['RUTEmisor']; |
274 | 280 | } |
275 | 281 | |
@@ -282,10 +288,12 @@ discard block |
||
282 | 288 | public function getReceptor() |
283 | 289 | { |
284 | 290 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Receptor/RUTRecep')->item(0); |
285 | - if ($nodo) |
|
286 | - return $nodo->nodeValue; |
|
287 | - if (!$this->getDatos()) |
|
288 | - return false; |
|
291 | + if ($nodo) { |
|
292 | + return $nodo->nodeValue; |
|
293 | + } |
|
294 | + if (!$this->getDatos()) { |
|
295 | + return false; |
|
296 | + } |
|
289 | 297 | return $this->datos['Encabezado']['Receptor']['RUTRecep']; |
290 | 298 | } |
291 | 299 | |
@@ -298,10 +306,12 @@ discard block |
||
298 | 306 | public function getFechaEmision() |
299 | 307 | { |
300 | 308 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/IdDoc/FchEmis')->item(0); |
301 | - if ($nodo) |
|
302 | - return $nodo->nodeValue; |
|
303 | - if (!$this->getDatos()) |
|
304 | - return false; |
|
309 | + if ($nodo) { |
|
310 | + return $nodo->nodeValue; |
|
311 | + } |
|
312 | + if (!$this->getDatos()) { |
|
313 | + return false; |
|
314 | + } |
|
305 | 315 | return $this->datos['Encabezado']['IdDoc']['FchEmis']; |
306 | 316 | } |
307 | 317 | |
@@ -314,10 +324,12 @@ discard block |
||
314 | 324 | public function getMontoTotal() |
315 | 325 | { |
316 | 326 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Totales/MntTotal')->item(0); |
317 | - if ($nodo) |
|
318 | - return $nodo->nodeValue; |
|
319 | - if (!$this->getDatos()) |
|
320 | - return false; |
|
327 | + if ($nodo) { |
|
328 | + return $nodo->nodeValue; |
|
329 | + } |
|
330 | + if (!$this->getDatos()) { |
|
331 | + return false; |
|
332 | + } |
|
321 | 333 | return $this->datos['Encabezado']['Totales']['MntTotal']; |
322 | 334 | } |
323 | 335 | |
@@ -330,10 +342,12 @@ discard block |
||
330 | 342 | public function getMoneda() |
331 | 343 | { |
332 | 344 | $nodo = $this->xml->xpath('/DTE/'.$this->tipo_general.'/Encabezado/Totales/TpoMoneda')->item(0); |
333 | - if ($nodo) |
|
334 | - return $nodo->nodeValue; |
|
335 | - if (!$this->getDatos()) |
|
336 | - return false; |
|
345 | + if ($nodo) { |
|
346 | + return $nodo->nodeValue; |
|
347 | + } |
|
348 | + if (!$this->getDatos()) { |
|
349 | + return false; |
|
350 | + } |
|
337 | 351 | return $this->datos['Encabezado']['Totales']['TpoMoneda']; |
338 | 352 | } |
339 | 353 | |
@@ -376,8 +390,9 @@ discard block |
||
376 | 390 | return false;*/ |
377 | 391 | $xml = new \sasco\LibreDTE\XML(); |
378 | 392 | $TED = $this->xml->getElementsByTagName('TED')->item(0); |
379 | - if (!$TED) |
|
380 | - return '<TED/>'; |
|
393 | + if (!$TED) { |
|
394 | + return '<TED/>'; |
|
395 | + } |
|
381 | 396 | $xml->loadXML($TED->C14N()); |
382 | 397 | $xml->documentElement->removeAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi'); |
383 | 398 | $xml->documentElement->removeAttributeNS('http://www.sii.cl/SiiDte', ''); |
@@ -574,10 +589,12 @@ discard block |
||
574 | 589 | */ |
575 | 590 | private function calcularNetoIVA($total, $tasa = null) |
576 | 591 | { |
577 | - if ($tasa === 0 or $tasa === false) |
|
578 | - return [0, 0]; |
|
579 | - if ($tasa === null) |
|
580 | - $tasa = \sasco\LibreDTE\Sii::getIVA(); |
|
592 | + if ($tasa === 0 or $tasa === false) { |
|
593 | + return [0, 0]; |
|
594 | + } |
|
595 | + if ($tasa === null) { |
|
596 | + $tasa = \sasco\LibreDTE\Sii::getIVA(); |
|
597 | + } |
|
581 | 598 | // WARNING: el IVA obtenido puede no ser el NETO*(TASA/100) |
582 | 599 | // se calcula el monto neto y luego se obtiene el IVA haciendo la resta |
583 | 600 | // entre el total y el neto, ya que hay casos de borde como: |
@@ -693,8 +710,9 @@ discard block |
||
693 | 710 | } |
694 | 711 | // si existe descuento o recargo global se normalizan |
695 | 712 | if (!empty($datos['DscRcgGlobal'])) { |
696 | - if (!isset($datos['DscRcgGlobal'][0])) |
|
697 | - $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
713 | + if (!isset($datos['DscRcgGlobal'][0])) { |
|
714 | + $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
715 | + } |
|
698 | 716 | $NroLinDR = 1; |
699 | 717 | foreach ($datos['DscRcgGlobal'] as &$dr) { |
700 | 718 | $dr = array_merge([ |
@@ -1357,8 +1375,9 @@ discard block |
||
1357 | 1375 | */ |
1358 | 1376 | private function normalizar_detalle(array &$datos) |
1359 | 1377 | { |
1360 | - if (!isset($datos['Detalle'][0])) |
|
1361 | - $datos['Detalle'] = [$datos['Detalle']]; |
|
1378 | + if (!isset($datos['Detalle'][0])) { |
|
1379 | + $datos['Detalle'] = [$datos['Detalle']]; |
|
1380 | + } |
|
1362 | 1381 | $item = 1; |
1363 | 1382 | foreach ($datos['Detalle'] as &$d) { |
1364 | 1383 | $d = array_merge([ |
@@ -1420,8 +1439,9 @@ discard block |
||
1420 | 1439 | ]; |
1421 | 1440 | } |
1422 | 1441 | if ($d['PrcItem']) { |
1423 | - if (!$d['QtyItem']) |
|
1424 | - $d['QtyItem'] = 1; |
|
1442 | + if (!$d['QtyItem']) { |
|
1443 | + $d['QtyItem'] = 1; |
|
1444 | + } |
|
1425 | 1445 | if (empty($d['MontoItem'])) { |
1426 | 1446 | $d['MontoItem'] = $this->round( |
1427 | 1447 | $d['QtyItem'] * $d['PrcItem'], |
@@ -1487,8 +1507,9 @@ discard block |
||
1487 | 1507 | private function normalizar_aplicar_descuentos_recargos(array &$datos) |
1488 | 1508 | { |
1489 | 1509 | if (!empty($datos['DscRcgGlobal'])) { |
1490 | - if (!isset($datos['DscRcgGlobal'][0])) |
|
1491 | - $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
1510 | + if (!isset($datos['DscRcgGlobal'][0])) { |
|
1511 | + $datos['DscRcgGlobal'] = [$datos['DscRcgGlobal']]; |
|
1512 | + } |
|
1492 | 1513 | foreach ($datos['DscRcgGlobal'] as &$dr) { |
1493 | 1514 | $dr = array_merge([ |
1494 | 1515 | 'NroLinDR' => false, |
@@ -1555,8 +1576,9 @@ discard block |
||
1555 | 1576 | $montos = []; |
1556 | 1577 | foreach ($datos['Detalle'] as &$d) { |
1557 | 1578 | if (!empty($d['CodImpAdic'])) { |
1558 | - if (!isset($montos[$d['CodImpAdic']])) |
|
1559 | - $montos[$d['CodImpAdic']] = 0; |
|
1579 | + if (!isset($montos[$d['CodImpAdic']])) { |
|
1580 | + $montos[$d['CodImpAdic']] = 0; |
|
1581 | + } |
|
1560 | 1582 | $montos[$d['CodImpAdic']] += $d['MontoItem']; |
1561 | 1583 | } |
1562 | 1584 | } |
@@ -1635,10 +1657,12 @@ discard block |
||
1635 | 1657 | } |
1636 | 1658 | if (empty($datos['Encabezado']['Totales']['MntTotal'])) { |
1637 | 1659 | $datos['Encabezado']['Totales']['MntTotal'] = $datos['Encabezado']['Totales']['MntNeto']; |
1638 | - if (!empty($datos['Encabezado']['Totales']['IVA'])) |
|
1639 | - $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['IVA']; |
|
1640 | - if (!empty($datos['Encabezado']['Totales']['MntExe'])) |
|
1641 | - $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['MntExe']; |
|
1660 | + if (!empty($datos['Encabezado']['Totales']['IVA'])) { |
|
1661 | + $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['IVA']; |
|
1662 | + } |
|
1663 | + if (!empty($datos['Encabezado']['Totales']['MntExe'])) { |
|
1664 | + $datos['Encabezado']['Totales']['MntTotal'] += $datos['Encabezado']['Totales']['MntExe']; |
|
1665 | + } |
|
1642 | 1666 | } |
1643 | 1667 | } else { |
1644 | 1668 | if (!$datos['Encabezado']['Totales']['MntTotal'] and !empty($datos['Encabezado']['Totales']['MntExe'])) { |
@@ -1664,8 +1688,10 @@ discard block |
||
1664 | 1688 | } |
1665 | 1689 | // si hay impuesto de crédito a constructoras del 65% se descuenta del total |
1666 | 1690 | if (!empty($datos['Encabezado']['Totales']['CredEC'])) { |
1667 | - if ($datos['Encabezado']['Totales']['CredEC']===true) |
|
1668 | - $datos['Encabezado']['Totales']['CredEC'] = round($datos['Encabezado']['Totales']['IVA'] * 0.65); // TODO: mover a constante o método |
|
1691 | + if ($datos['Encabezado']['Totales']['CredEC']===true) { |
|
1692 | + $datos['Encabezado']['Totales']['CredEC'] = round($datos['Encabezado']['Totales']['IVA'] * 0.65); |
|
1693 | + } |
|
1694 | + // TODO: mover a constante o método |
|
1669 | 1695 | $datos['Encabezado']['Totales']['MntTotal'] -= $datos['Encabezado']['Totales']['CredEC']; |
1670 | 1696 | } |
1671 | 1697 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | ] |
140 | 140 | ]); |
141 | 141 | $parent = $this->xml->getElementsByTagName($this->tipo_general)->item(0); |
142 | - $this->xml->generate($datos + ['TED' => null], null, $parent); |
|
142 | + $this->xml->generate($datos+['TED' => null], null, $parent); |
|
143 | 143 | $this->datos = $datos; |
144 | 144 | if ($normalizar and !$this->verificarDatos()) { |
145 | 145 | return false; |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | $xml->documentElement->removeAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi'); |
383 | 383 | $xml->documentElement->removeAttributeNS('http://www.sii.cl/SiiDte', ''); |
384 | 384 | $TED = $xml->getFlattened('/'); |
385 | - return mb_detect_encoding($TED, ['UTF-8', 'ISO-8859-1']) != 'ISO-8859-1' ? utf8_decode($TED) : $TED; |
|
385 | + return mb_detect_encoding($TED, ['UTF-8', 'ISO-8859-1'])!='ISO-8859-1' ? utf8_decode($TED) : $TED; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | { |
396 | 396 | $datos = $this->getDatos(); |
397 | 397 | $idk = !empty($datos['TED']['DD']['CAF']['DA']['IDK']) ? (int)$datos['TED']['DD']['CAF']['DA']['IDK'] : null; |
398 | - return $idk ? $idk === 100 : null; |
|
398 | + return $idk ? $idk===100 : null; |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | /** |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | { |
530 | 530 | $this->getDatos(); |
531 | 531 | // generar resumen |
532 | - $resumen = [ |
|
532 | + $resumen = [ |
|
533 | 533 | 'TpoDoc' => (int)$this->datos['Encabezado']['IdDoc']['TipoDTE'], |
534 | 534 | 'NroDoc' => (int)$this->datos['Encabezado']['IdDoc']['Folio'], |
535 | 535 | 'TasaImp' => 0, |
@@ -574,17 +574,17 @@ discard block |
||
574 | 574 | */ |
575 | 575 | private function calcularNetoIVA($total, $tasa = null) |
576 | 576 | { |
577 | - if ($tasa === 0 or $tasa === false) |
|
577 | + if ($tasa===0 or $tasa===false) |
|
578 | 578 | return [0, 0]; |
579 | - if ($tasa === null) |
|
579 | + if ($tasa===null) |
|
580 | 580 | $tasa = \sasco\LibreDTE\Sii::getIVA(); |
581 | 581 | // WARNING: el IVA obtenido puede no ser el NETO*(TASA/100) |
582 | 582 | // se calcula el monto neto y luego se obtiene el IVA haciendo la resta |
583 | 583 | // entre el total y el neto, ya que hay casos de borde como: |
584 | 584 | // - BRUTO: 680 => NETO: 571 e IVA: 108 => TOTAL: 679 |
585 | 585 | // - BRUTO: 86710 => NETO: 72866 e IVA: 13845 => TOTAL: 86711 |
586 | - $neto = round($total / (1+($tasa/100))); |
|
587 | - $iva = $total - $neto; |
|
586 | + $neto = round($total / (1+($tasa / 100))); |
|
587 | + $iva = $total-$neto; |
|
588 | 588 | return [$neto, $iva]; |
589 | 589 | } |
590 | 590 | |
@@ -1429,12 +1429,12 @@ discard block |
||
1429 | 1429 | ); |
1430 | 1430 | // aplicar descuento |
1431 | 1431 | if ($d['DescuentoPct']) { |
1432 | - $d['DescuentoMonto'] = round($d['MontoItem'] * (float)$d['DescuentoPct']/100); |
|
1432 | + $d['DescuentoMonto'] = round($d['MontoItem'] * (float)$d['DescuentoPct'] / 100); |
|
1433 | 1433 | } |
1434 | 1434 | $d['MontoItem'] -= $d['DescuentoMonto']; |
1435 | 1435 | // aplicar recargo |
1436 | 1436 | if ($d['RecargoPct']) { |
1437 | - $d['RecargoMonto'] = round($d['MontoItem'] * (float)$d['RecargoPct']/100); |
|
1437 | + $d['RecargoMonto'] = round($d['MontoItem'] * (float)$d['RecargoPct'] / 100); |
|
1438 | 1438 | } |
1439 | 1439 | $d['MontoItem'] += $d['RecargoMonto']; |
1440 | 1440 | // aproximar monto del item |
@@ -1520,7 +1520,7 @@ discard block |
||
1520 | 1520 | } |
1521 | 1521 | $valor = |
1522 | 1522 | $dr['TpoValor']=='%' |
1523 | - ? $this->round(($dr['ValorDR']/100)*$datos['Encabezado']['Totales'][$monto], $datos['Encabezado']['Totales']['TpoMoneda']) |
|
1523 | + ? $this->round(($dr['ValorDR'] / 100) * $datos['Encabezado']['Totales'][$monto], $datos['Encabezado']['Totales']['TpoMoneda']) |
|
1524 | 1524 | : $dr['ValorDR'] |
1525 | 1525 | ; |
1526 | 1526 | // aplicar descuento |
@@ -1593,7 +1593,7 @@ discard block |
||
1593 | 1593 | // si el monto no existe se asigna |
1594 | 1594 | if ($datos['Encabezado']['Totales']['ImptoReten'][$i]['MontoImp']===null) { |
1595 | 1595 | $datos['Encabezado']['Totales']['ImptoReten'][$i]['MontoImp'] = round( |
1596 | - $neto * $datos['Encabezado']['Totales']['ImptoReten'][$i]['TasaImp']/100 |
|
1596 | + $neto * $datos['Encabezado']['Totales']['ImptoReten'][$i]['TasaImp'] / 100 |
|
1597 | 1597 | ); |
1598 | 1598 | } |
1599 | 1599 | } |
@@ -1601,7 +1601,7 @@ discard block |
||
1601 | 1601 | if (isset($datos['Encabezado']['Totales']['ImptoReten']) and is_array($datos['Encabezado']['Totales']['ImptoReten'])) { |
1602 | 1602 | $codigos = array_keys($montos); |
1603 | 1603 | $n_impuestos = count($datos['Encabezado']['Totales']['ImptoReten']); |
1604 | - for ($i=0; $i<$n_impuestos; $i++) { |
|
1604 | + for ($i = 0; $i<$n_impuestos; $i++) { |
|
1605 | 1605 | if (!in_array($datos['Encabezado']['Totales']['ImptoReten'][$i]['TipoImp'], $codigos)) { |
1606 | 1606 | unset($datos['Encabezado']['Totales']['ImptoReten'][$i]); |
1607 | 1607 | } |
@@ -1629,7 +1629,7 @@ discard block |
||
1629 | 1629 | } else { |
1630 | 1630 | if (empty($datos['Encabezado']['Totales']['IVA']) and !empty($datos['Encabezado']['Totales']['TasaIVA'])) { |
1631 | 1631 | $datos['Encabezado']['Totales']['IVA'] = round( |
1632 | - $datos['Encabezado']['Totales']['MntNeto']*($datos['Encabezado']['Totales']['TasaIVA']/100) |
|
1632 | + $datos['Encabezado']['Totales']['MntNeto'] * ($datos['Encabezado']['Totales']['TasaIVA'] / 100) |
|
1633 | 1633 | ); |
1634 | 1634 | } |
1635 | 1635 | } |
@@ -1653,7 +1653,7 @@ discard block |
||
1653 | 1653 | if (ImpuestosAdicionales::getTipo($ImptoReten['TipoImp'])=='R') { |
1654 | 1654 | $datos['Encabezado']['Totales']['MntTotal'] -= $ImptoReten['MontoImp']; |
1655 | 1655 | if ($ImptoReten['MontoImp']!=$datos['Encabezado']['Totales']['IVA']) { |
1656 | - $datos['Encabezado']['Totales']['IVANoRet'] = $datos['Encabezado']['Totales']['IVA'] - $ImptoReten['MontoImp']; |
|
1656 | + $datos['Encabezado']['Totales']['IVANoRet'] = $datos['Encabezado']['Totales']['IVA']-$ImptoReten['MontoImp']; |
|
1657 | 1657 | } |
1658 | 1658 | } |
1659 | 1659 | // si es adicional se suma al total |
@@ -1813,7 +1813,7 @@ discard block |
||
1813 | 1813 | $SignatureValue = trim(str_replace(["\n", ' ', "\t"], '', $Signature->getElementsByTagName('SignatureValue')->item(0)->nodeValue)); |
1814 | 1814 | $X509Certificate = trim(str_replace(["\n", ' ', "\t"], '', $Signature->getElementsByTagName('X509Certificate')->item(0)->nodeValue)); |
1815 | 1815 | $X509Certificate = '-----BEGIN CERTIFICATE-----'."\n".wordwrap($X509Certificate, 64, "\n", true)."\n".'-----END CERTIFICATE----- '; |
1816 | - $valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate) === 1 ? true : false; |
|
1816 | + $valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate)===1 ? true : false; |
|
1817 | 1817 | return $valid; |
1818 | 1818 | //return $valid and $DigestValue===base64_encode(sha1($Documento->C14N(), true)); |
1819 | 1819 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | /** |
44 | 44 | * Método que agrega un DTE al listado que se enviará |
45 | - * @param DTE Objeto del DTE |
|
45 | + * @param DTE Dte del DTE |
|
46 | 46 | * @return =true si se pudo agregar el DTE o =false si no se agregó por exceder el límite de un envío |
47 | 47 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
48 | 48 | * @version 2015-12-11 |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | /** |
396 | 396 | * Método que determina el estado de validación sobre el envío |
397 | 397 | * @param datos Arreglo con datos para hacer las validaciones |
398 | - * @return Código del estado de la validación |
|
398 | + * @return integer del estado de la validación |
|
399 | 399 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
400 | 400 | * @version 2019-07-03 |
401 | 401 | */ |
@@ -135,8 +135,9 @@ discard block |
||
135 | 135 | public function generar() |
136 | 136 | { |
137 | 137 | // si ya se había generado se entrega directamente |
138 | - if ($this->xml_data) |
|
139 | - return $this->xml_data; |
|
138 | + if ($this->xml_data) { |
|
139 | + return $this->xml_data; |
|
140 | + } |
|
140 | 141 | // si no hay DTEs para generar entregar falso |
141 | 142 | if (!isset($this->dtes[0])) { |
142 | 143 | \sasco\LibreDTE\Log::write( |
@@ -185,8 +186,9 @@ discard block |
||
185 | 186 | $SubTotDTE = []; |
186 | 187 | $subtotales = []; |
187 | 188 | foreach ($this->dtes as &$DTE) { |
188 | - if (!isset($subtotales[$DTE->getTipo()])) |
|
189 | - $subtotales[$DTE->getTipo()] = 0; |
|
189 | + if (!isset($subtotales[$DTE->getTipo()])) { |
|
190 | + $subtotales[$DTE->getTipo()] = 0; |
|
191 | + } |
|
190 | 192 | $subtotales[$DTE->getTipo()]++; |
191 | 193 | } |
192 | 194 | foreach ($subtotales as $tipo => $subtotal) { |
@@ -301,8 +303,9 @@ discard block |
||
301 | 303 | { |
302 | 304 | $fecha = '9999-12-31'; |
303 | 305 | foreach ($this->getDocumentos() as $Dte) { |
304 | - if ($Dte->getFechaEmision() < $fecha) |
|
305 | - $fecha = $Dte->getFechaEmision(); |
|
306 | + if ($Dte->getFechaEmision() < $fecha) { |
|
307 | + $fecha = $Dte->getFechaEmision(); |
|
308 | + } |
|
306 | 309 | } |
307 | 310 | return $fecha; |
308 | 311 | } |
@@ -316,8 +319,9 @@ discard block |
||
316 | 319 | { |
317 | 320 | $fecha = '0000-01-01'; |
318 | 321 | foreach ($this->getDocumentos() as $Dte) { |
319 | - if ($Dte->getFechaEmision() > $fecha) |
|
320 | - $fecha = $Dte->getFechaEmision(); |
|
322 | + if ($Dte->getFechaEmision() > $fecha) { |
|
323 | + $fecha = $Dte->getFechaEmision(); |
|
324 | + } |
|
321 | 325 | } |
322 | 326 | return $fecha; |
323 | 327 | } |
@@ -371,8 +375,9 @@ discard block |
||
371 | 375 | $DTEs = $this->xml->getElementsByTagName('DTE'); |
372 | 376 | foreach ($DTEs as $nodo_dte) { |
373 | 377 | $e = $nodo_dte->getElementsByTagName('RUTEmisor')->item(0)->nodeValue; |
374 | - if (is_numeric($emisor)) |
|
375 | - $e = substr($e, 0, -2); |
|
378 | + if (is_numeric($emisor)) { |
|
379 | + $e = substr($e, 0, -2); |
|
380 | + } |
|
376 | 381 | $d = (int)$nodo_dte->getElementsByTagName('TipoDTE')->item(0)->nodeValue; |
377 | 382 | $f = (int)$nodo_dte->getElementsByTagName('Folio')->item(0)->nodeValue; |
378 | 383 | if ($folio == $f and $dte == $d and $emisor == $e) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | { |
33 | 33 | |
34 | 34 | private $dtes = []; ///< Objetos con los DTE que se enviarán |
35 | - private $config = [ // 0: DTE, 1: boleta |
|
35 | + private $config = [// 0: DTE, 1: boleta |
|
36 | 36 | 'SubTotDTE_max' => [20, 2], ///< máxima cantidad de tipos de documentos en el envío |
37 | 37 | 'DTE_max' => [2000, 1000], ///< máxima cantidad de DTE en un envío |
38 | 38 | 'tipos' => ['EnvioDTE', 'EnvioBOLETA'], ///< Tag para el envío, según si son Boletas o no |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | public function agregar(Dte $DTE) |
51 | 51 | { |
52 | 52 | // determinar el tipo del envío (DTE o boleta) |
53 | - if ($this->tipo === null) { |
|
53 | + if ($this->tipo===null) { |
|
54 | 54 | $this->tipo = (int)$DTE->esBoleta(); |
55 | 55 | } |
56 | 56 | // validar que el tipo de documento sea del tipo que se espera |
57 | - else if ((int)$DTE->esBoleta() != $this->tipo) { |
|
57 | + else if ((int)$DTE->esBoleta()!=$this->tipo) { |
|
58 | 58 | return false; |
59 | 59 | } |
60 | 60 | // |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | 'RutEnvia' => $Dte->getEmisor(), |
222 | 222 | 'RutReceptor' => $Dte->getReceptor(), |
223 | 223 | 'FchResol' => date('Y-m-d'), |
224 | - 'NroResol' => ($Dte->getCertificacion()?'0':'').'9999', |
|
224 | + 'NroResol' => ($Dte->getCertificacion() ? '0' : '').'9999', |
|
225 | 225 | ]); |
226 | 226 | if (!parent::loadXML($this->generar())) { |
227 | 227 | return false; |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | { |
302 | 302 | $fecha = '9999-12-31'; |
303 | 303 | foreach ($this->getDocumentos() as $Dte) { |
304 | - if ($Dte->getFechaEmision() < $fecha) |
|
304 | + if ($Dte->getFechaEmision()<$fecha) |
|
305 | 305 | $fecha = $Dte->getFechaEmision(); |
306 | 306 | } |
307 | 307 | return $fecha; |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | { |
317 | 317 | $fecha = '0000-01-01'; |
318 | 318 | foreach ($this->getDocumentos() as $Dte) { |
319 | - if ($Dte->getFechaEmision() > $fecha) |
|
319 | + if ($Dte->getFechaEmision()>$fecha) |
|
320 | 320 | $fecha = $Dte->getFechaEmision(); |
321 | 321 | } |
322 | 322 | return $fecha; |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | $e = substr($e, 0, -2); |
376 | 376 | $d = (int)$nodo_dte->getElementsByTagName('TipoDTE')->item(0)->nodeValue; |
377 | 377 | $f = (int)$nodo_dte->getElementsByTagName('Folio')->item(0)->nodeValue; |
378 | - if ($folio == $f and $dte == $d and $emisor == $e) { |
|
378 | + if ($folio==$f and $dte==$d and $emisor==$e) { |
|
379 | 379 | return new Dte($nodo_dte->C14N(), false); // cargar DTE sin normalizar |
380 | 380 | } |
381 | 381 | } |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | $SignatureValue = trim(str_replace(["\n", ' ', "\t"], '', $Signatures->item($Signatures->length-1)->getElementsByTagName('SignatureValue')->item(0)->nodeValue)); |
434 | 434 | $X509Certificate = trim(str_replace(["\n", ' ', "\t"], '', $Signatures->item($Signatures->length-1)->getElementsByTagName('X509Certificate')->item(0)->nodeValue)); |
435 | 435 | $X509Certificate = '-----BEGIN CERTIFICATE-----'."\n".wordwrap($X509Certificate, 64, "\n", true)."\n".'-----END CERTIFICATE-----'; |
436 | - $valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate) === 1 ? true : false; |
|
436 | + $valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate)===1 ? true : false; |
|
437 | 437 | return $valid and $DigestValue===base64_encode(sha1($SetDTE, true)); |
438 | 438 | } |
439 | 439 |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * Método que asigna la ubicación del logo de la empresa |
80 | 80 | * @param logo URI del logo (puede ser local o en una URL) |
81 | - * @param posicion Posición respecto a datos del emisor (=0 izq, =1 arriba) |
|
81 | + * @param posicion integer respecto a datos del emisor (=0 izq, =1 arriba) |
|
82 | 82 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
83 | 83 | * @version 2016-08-04 |
84 | 84 | */ |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * contínuo |
223 | 223 | * @param dte Arreglo con los datos del XML (tag Documento) |
224 | 224 | * @param timbre String XML con el tag TED del DTE |
225 | - * @param width Ancho del papel contínuo en mm |
|
225 | + * @param width boolean del papel contínuo en mm |
|
226 | 226 | * @author Pablo Reyes (https://github.com/pabloxp) |
227 | 227 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
228 | 228 | * @version 2017-10-24 |
@@ -384,10 +384,11 @@ discard block |
||
384 | 384 | * - Dirección casa central del emisor |
385 | 385 | * - Dirección sucursales |
386 | 386 | * @param emisor Arreglo con los datos del emisor (tag Emisor del XML) |
387 | - * @param x Posición horizontal de inicio en el PDF |
|
388 | - * @param y Posición vertical de inicio en el PDF |
|
389 | - * @param w Ancho de la información del emisor |
|
390 | - * @param w_img Ancho máximo de la imagen |
|
387 | + * @param x integer horizontal de inicio en el PDF |
|
388 | + * @param y integer vertical de inicio en el PDF |
|
389 | + * @param w integer de la información del emisor |
|
390 | + * @param w_img integer máximo de la imagen |
|
391 | + * @param integer $font_size |
|
391 | 392 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
392 | 393 | * @version 2018-06-15 |
393 | 394 | */ |
@@ -461,11 +462,13 @@ discard block |
||
461 | 462 | * @param rut RUT del emisor |
462 | 463 | * @param tipo Código o glosa del tipo de documento |
463 | 464 | * @param sucursal_sii Código o glosa de la sucursal del SII del Emisor |
464 | - * @param x Posición horizontal de inicio en el PDF |
|
465 | - * @param y Posición vertical de inicio en el PDF |
|
466 | - * @param w Ancho de la información del emisor |
|
465 | + * @param x integer horizontal de inicio en el PDF |
|
466 | + * @param y integer vertical de inicio en el PDF |
|
467 | + * @param w integer de la información del emisor |
|
468 | + * @param integer $font_size |
|
467 | 469 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
468 | 470 | * @version 2016-12-02 |
471 | + * @return integer |
|
469 | 472 | */ |
470 | 473 | protected function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
471 | 474 | { |
@@ -497,7 +500,7 @@ discard block |
||
497 | 500 | * Método que agrega los datos de la emisión del DTE que no son los dato del |
498 | 501 | * receptor |
499 | 502 | * @param IdDoc Información general del documento |
500 | - * @param x Posición horizontal de inicio en el PDF |
|
503 | + * @param x integer horizontal de inicio en el PDF |
|
501 | 504 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
502 | 505 | * @version 2017-06-15 |
503 | 506 | */ |
@@ -585,7 +588,7 @@ discard block |
||
585 | 588 | /** |
586 | 589 | * Método que agrega los datos del receptor |
587 | 590 | * @param receptor Arreglo con los datos del receptor (tag Receptor del XML) |
588 | - * @param x Posición horizontal de inicio en el PDF |
|
591 | + * @param x integer horizontal de inicio en el PDF |
|
589 | 592 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
590 | 593 | * @version 2019-02-13 |
591 | 594 | */ |
@@ -672,7 +675,7 @@ discard block |
||
672 | 675 | * Método que agrega los datos del traslado |
673 | 676 | * @param IndTraslado |
674 | 677 | * @param Transporte |
675 | - * @param x Posición horizontal de inicio en el PDF |
|
678 | + * @param x integer horizontal de inicio en el PDF |
|
676 | 679 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
677 | 680 | * @version 2016-08-03 |
678 | 681 | */ |
@@ -743,7 +746,7 @@ discard block |
||
743 | 746 | /** |
744 | 747 | * Método que agrega las referencias del documento |
745 | 748 | * @param referencias Arreglo con las referencias del documento (tag Referencia del XML) |
746 | - * @param x Posición horizontal de inicio en el PDF |
|
749 | + * @param x integer horizontal de inicio en el PDF |
|
747 | 750 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
748 | 751 | * @version 2017-09-25 |
749 | 752 | */ |
@@ -780,7 +783,7 @@ discard block |
||
780 | 783 | /** |
781 | 784 | * Método que agrega el detalle del documento |
782 | 785 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
783 | - * @param x Posición horizontal de inicio en el PDF |
|
786 | + * @param x integer horizontal de inicio en el PDF |
|
784 | 787 | * @param y Posición vertical de inicio en el PDF |
785 | 788 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
786 | 789 | * @version 2019-07-09 |
@@ -880,7 +883,7 @@ discard block |
||
880 | 883 | /** |
881 | 884 | * Método que agrega el detalle del documento |
882 | 885 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
883 | - * @param x Posición horizontal de inicio en el PDF |
|
886 | + * @param x integer horizontal de inicio en el PDF |
|
884 | 887 | * @param y Posición vertical de inicio en el PDF |
885 | 888 | * @author Pablo Reyes (https://github.com/pabloxp) |
886 | 889 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
@@ -916,7 +919,7 @@ discard block |
||
916 | 919 | * Método que agrega el subtotal del DTE |
917 | 920 | * @param detalle Arreglo con los detalles del documentos para poder |
918 | 921 | * calcular subtotal |
919 | - * @param x Posición horizontal de inicio en el PDF |
|
922 | + * @param x integer horizontal de inicio en el PDF |
|
920 | 923 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
921 | 924 | * @version 2016-08-17 |
922 | 925 | */ |
@@ -942,7 +945,7 @@ discard block |
||
942 | 945 | /** |
943 | 946 | * Método que agrega los descuentos y/o recargos globales del documento |
944 | 947 | * @param descuentosRecargos Arreglo con los descuentos y/o recargos del documento (tag DscRcgGlobal del XML) |
945 | - * @param x Posición horizontal de inicio en el PDF |
|
948 | + * @param x integer horizontal de inicio en el PDF |
|
946 | 949 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
947 | 950 | * @version 2018-05-29 |
948 | 951 | */ |
@@ -970,7 +973,7 @@ discard block |
||
970 | 973 | /** |
971 | 974 | * Método que agrega los pagos del documento |
972 | 975 | * @param pagos Arreglo con los pagos del documento |
973 | - * @param x Posición horizontal de inicio en el PDF |
|
976 | + * @param x integer horizontal de inicio en el PDF |
|
974 | 977 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
975 | 978 | * @version 2016-07-24 |
976 | 979 | */ |
@@ -1128,9 +1131,9 @@ discard block |
||
1128 | 1131 | * - Se imprime en el tamaño mínimo: 2x5 cms |
1129 | 1132 | * - En el lado de abajo con margen izquierdo mínimo de 2 cms |
1130 | 1133 | * @param timbre String con los datos del timbre |
1131 | - * @param x Posición horizontal de inicio en el PDF |
|
1132 | - * @param y Posición vertical de inicio en el PDF |
|
1133 | - * @param w Ancho del timbre |
|
1134 | + * @param x integer horizontal de inicio en el PDF |
|
1135 | + * @param y integer vertical de inicio en el PDF |
|
1136 | + * @param w integer del timbre |
|
1134 | 1137 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
1135 | 1138 | * @version 2018-04-12 |
1136 | 1139 | */ |
@@ -1168,10 +1171,10 @@ discard block |
||
1168 | 1171 | |
1169 | 1172 | /** |
1170 | 1173 | * Método que agrega el acuse de rebido |
1171 | - * @param x Posición horizontal de inicio en el PDF |
|
1172 | - * @param y Posición vertical de inicio en el PDF |
|
1173 | - * @param w Ancho del acuse de recibo |
|
1174 | - * @param h Alto del acuse de recibo |
|
1174 | + * @param x integer horizontal de inicio en el PDF |
|
1175 | + * @param y integer vertical de inicio en el PDF |
|
1176 | + * @param w integer del acuse de recibo |
|
1177 | + * @param h integer del acuse de recibo |
|
1175 | 1178 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
1176 | 1179 | * @version 2018-04-13 |
1177 | 1180 | */ |
@@ -1199,10 +1202,10 @@ discard block |
||
1199 | 1202 | |
1200 | 1203 | /** |
1201 | 1204 | * Método que agrega el acuse de rebido |
1202 | - * @param x Posición horizontal de inicio en el PDF |
|
1205 | + * @param x integer horizontal de inicio en el PDF |
|
1203 | 1206 | * @param y Posición vertical de inicio en el PDF |
1204 | - * @param w Ancho del acuse de recibo |
|
1205 | - * @param h Alto del acuse de recibo |
|
1207 | + * @param w integer del acuse de recibo |
|
1208 | + * @param h integer del acuse de recibo |
|
1206 | 1209 | * @author Pablo Reyes (https://github.com/pabloxp) |
1207 | 1210 | * @version 2015-11-17 |
1208 | 1211 | */ |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | { |
73 | 73 | parent::__construct(); |
74 | 74 | $this->SetTitle('Documento Tributario Electrónico (DTE) de Chile by LibreDTE'); |
75 | - $this->papelContinuo = $papelContinuo === true ? 80 : $papelContinuo; |
|
75 | + $this->papelContinuo = $papelContinuo===true ? 80 : $papelContinuo; |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | $this->setY(max($y)); |
183 | 183 | $this->Ln(); |
184 | 184 | $y = []; |
185 | - $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null); |
|
185 | + $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null); |
|
186 | 186 | $y[] = $this->agregarReceptor($dte['Encabezado']); |
187 | 187 | $this->setY(max($y)); |
188 | 188 | $this->agregarTraslado( |
@@ -242,15 +242,15 @@ discard block |
||
242 | 242 | $dte['Encabezado']['IdDoc']['TipoDTE'], |
243 | 243 | $dte['Encabezado']['IdDoc']['Folio'], |
244 | 244 | $dte['Encabezado']['Emisor']['CmnaOrigen'], |
245 | - $x_start, $y_start, $width-($x_start*4), 10, |
|
246 | - [0,0,0] |
|
245 | + $x_start, $y_start, $width-($x_start * 4), 10, |
|
246 | + [0, 0, 0] |
|
247 | 247 | ); |
248 | - $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, $width-($x_start*45), 8, 9, [0,0,0]); |
|
248 | + $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, $width-($x_start * 45), 8, 9, [0, 0, 0]); |
|
249 | 249 | // datos del documento |
250 | 250 | $this->SetY($y); |
251 | 251 | $this->Ln(); |
252 | 252 | $this->setFont('', '', 8); |
253 | - $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null, $x_start, $offset, false); |
|
253 | + $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null, $x_start, $offset, false); |
|
254 | 254 | $this->agregarReceptor($dte['Encabezado'], $x_start, $offset); |
255 | 255 | $this->agregarTraslado( |
256 | 256 | !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null, |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $this->AddPage('P', [$height ? $height : $this->papel_continuo_alto, $width]); |
304 | 304 | $x = 1; |
305 | 305 | $y = 5; |
306 | - $this->SetXY($x,$y); |
|
306 | + $this->SetXY($x, $y); |
|
307 | 307 | // agregar datos del documento |
308 | 308 | $this->setFont('', '', 8); |
309 | 309 | $this->MultiTexto(!empty($dte['Encabezado']['Emisor']['RznSoc']) ? $dte['Encabezado']['Emisor']['RznSoc'] : $dte['Encabezado']['Emisor']['RznSocEmisor'], $x, null, '', $width-2); |
@@ -399,13 +399,13 @@ discard block |
||
399 | 399 | $this->logo['uri'], |
400 | 400 | $x, |
401 | 401 | $y, |
402 | - !$this->logo['posicion']?$w_img:null, $this->logo['posicion']?($w_img/2):null, |
|
402 | + !$this->logo['posicion'] ? $w_img : null, $this->logo['posicion'] ? ($w_img / 2) : null, |
|
403 | 403 | 'PNG', |
404 | - (isset($emisor['url'])?$emisor['url']:''), |
|
404 | + (isset($emisor['url']) ? $emisor['url'] : ''), |
|
405 | 405 | 'T' |
406 | 406 | ); |
407 | 407 | if ($this->logo['posicion']) { |
408 | - $this->SetY($this->y + ($w_img/2)); |
|
408 | + $this->SetY($this->y+($w_img / 2)); |
|
409 | 409 | $w += 40; |
410 | 410 | } else { |
411 | 411 | $x = $this->x+3; |
@@ -416,14 +416,14 @@ discard block |
||
416 | 416 | } |
417 | 417 | // agregar datos del emisor |
418 | 418 | $this->setFont('', 'B', $font_size ? $font_size : 14); |
419 | - $this->SetTextColorArray($color===null?[32, 92, 144]:$color); |
|
419 | + $this->SetTextColorArray($color===null ? [32, 92, 144] : $color); |
|
420 | 420 | $this->MultiTexto(!empty($emisor['RznSoc']) ? $emisor['RznSoc'] : $emisor['RznSocEmisor'], $x, $this->y+2, 'L', $w); |
421 | 421 | $this->setFont('', 'B', $font_size ? $font_size : 9); |
422 | - $this->SetTextColorArray([0,0,0]); |
|
422 | + $this->SetTextColorArray([0, 0, 0]); |
|
423 | 423 | $this->MultiTexto(!empty($emisor['GiroEmis']) ? $emisor['GiroEmis'] : $emisor['GiroEmisor'], $x, $this->y, 'L', $w); |
424 | 424 | $comuna = !empty($emisor['CmnaOrigen']) ? $emisor['CmnaOrigen'] : null; |
425 | 425 | $ciudad = !empty($emisor['CiudadOrigen']) ? $emisor['CiudadOrigen'] : \sasco\LibreDTE\Chile::getCiudad($comuna); |
426 | - $this->MultiTexto($emisor['DirOrigen'].($comuna?(', '.$comuna):'').($ciudad?(', '.$ciudad):''), $x, $this->y, 'L', $w); |
|
426 | + $this->MultiTexto($emisor['DirOrigen'].($comuna ? (', '.$comuna) : '').($ciudad ? (', '.$ciudad) : ''), $x, $this->y, 'L', $w); |
|
427 | 427 | if (!empty($emisor['Sucursal'])) { |
428 | 428 | $this->MultiTexto('Sucursal: '.$emisor['Sucursal'], $x, $this->y, 'L', $w); |
429 | 429 | } |
@@ -470,12 +470,12 @@ discard block |
||
470 | 470 | protected function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
471 | 471 | { |
472 | 472 | if ($color===null) { |
473 | - $color = $tipo ? ($tipo==52 ? [0,172,140] : [255,0,0]) : [0,0,0]; |
|
473 | + $color = $tipo ? ($tipo==52 ? [0, 172, 140] : [255, 0, 0]) : [0, 0, 0]; |
|
474 | 474 | } |
475 | 475 | $this->SetTextColorArray($color); |
476 | 476 | // colocar rut emisor, glosa documento y folio |
477 | 477 | list($rut, $dv) = explode('-', $rut); |
478 | - $this->setFont ('', 'B', $font_size ? $font_size : 15); |
|
478 | + $this->setFont('', 'B', $font_size ? $font_size : 15); |
|
479 | 479 | $this->MultiTexto('R.U.T.: '.$this->num($rut).'-'.$dv, $x, $y+4, 'C', $w); |
480 | 480 | $this->setFont('', 'B', $font_size ? $font_size : 12); |
481 | 481 | $this->MultiTexto($this->getTipo($tipo), $x, null, 'C', $w); |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | if ($tipo) { |
489 | 489 | $this->Texto('S.I.I. - '.\sasco\LibreDTE\Sii::getDireccionRegional($sucursal_sii), $x, $this->getY()+4, 'C', $w); |
490 | 490 | } |
491 | - $this->SetTextColorArray([0,0,0]); |
|
491 | + $this->SetTextColorArray([0, 0, 0]); |
|
492 | 492 | $this->Ln(); |
493 | 493 | return $this->y; |
494 | 494 | } |
@@ -605,7 +605,7 @@ discard block |
||
605 | 605 | $this->Texto(in_array($this->dte, [39, 41]) ? 'Nombre' : 'Razón social', $x); |
606 | 606 | $this->Texto(':', $x+$offset); |
607 | 607 | $this->setFont('', '', null); |
608 | - $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
608 | + $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
609 | 609 | } |
610 | 610 | if (!empty($receptor['GiroRecep'])) { |
611 | 611 | $this->setFont('', 'B', null); |
@@ -622,7 +622,7 @@ discard block |
||
622 | 622 | $ciudad = !empty($receptor['CiudadRecep']) ? $receptor['CiudadRecep'] : ( |
623 | 623 | !empty($receptor['CmnaRecep']) ? \sasco\LibreDTE\Chile::getCiudad($receptor['CmnaRecep']) : '' |
624 | 624 | ); |
625 | - $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep'])?(', '.$receptor['CmnaRecep']):'').($ciudad?(', '.$ciudad):''), $x+$offset+2); |
|
625 | + $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep']) ? (', '.$receptor['CmnaRecep']) : '').($ciudad ? (', '.$ciudad) : ''), $x+$offset+2); |
|
626 | 626 | } |
627 | 627 | if (!empty($receptor['Extranjero']['Nacionalidad'])) { |
628 | 628 | $this->setFont('', 'B', null); |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | $this->Texto('Cód. recep.', $x); |
664 | 664 | $this->Texto(':', $x+$offset); |
665 | 665 | $this->setFont('', '', null); |
666 | - $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
666 | + $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
667 | 667 | } |
668 | 668 | return $this->GetY(); |
669 | 669 | } |
@@ -751,7 +751,7 @@ discard block |
||
751 | 751 | { |
752 | 752 | if (!isset($referencias[0])) |
753 | 753 | $referencias = [$referencias]; |
754 | - foreach($referencias as $r) { |
|
754 | + foreach ($referencias as $r) { |
|
755 | 755 | $texto = $r['NroLinRef'].' - '; |
756 | 756 | if (!empty($r['TpoDocRef'])) { |
757 | 757 | $texto .= $this->getTipo($r['TpoDocRef']).' '; |
@@ -803,7 +803,7 @@ discard block |
||
803 | 803 | // quitar columnas |
804 | 804 | foreach ($item as $col => $valor) { |
805 | 805 | if ($col=='DscItem' and !empty($item['DscItem'])) { |
806 | - $item['NmbItem'] .= !$this->item_detalle_posicion ? ($html?'<br/>':"\n") : ': '; |
|
806 | + $item['NmbItem'] .= !$this->item_detalle_posicion ? ($html ? '<br/>' : "\n") : ': '; |
|
807 | 807 | if ($html) { |
808 | 808 | $item['NmbItem'] .= '<span style="font-size:0.7em">'.$item['DscItem'].'</span>'; |
809 | 809 | } else { |
@@ -851,7 +851,7 @@ discard block |
||
851 | 851 | } |
852 | 852 | $item = array_merge($item_default, $item); |
853 | 853 | // si hay código de item se extrae su valor |
854 | - if (!empty($item['CdgItem']['VlrCodigo'])){ |
|
854 | + if (!empty($item['CdgItem']['VlrCodigo'])) { |
|
855 | 855 | $item['CdgItem'] = $item['CdgItem']['VlrCodigo']; |
856 | 856 | } |
857 | 857 | // dar formato a números |
@@ -891,9 +891,9 @@ discard block |
||
891 | 891 | $this->SetY($this->getY()+1); |
892 | 892 | $p1x = $x; |
893 | 893 | $p1y = $this->y; |
894 | - $p2x = $this->getPageWidth() - 2; |
|
895 | - $p2y = $p1y; // Use same y for a straight line |
|
896 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
894 | + $p2x = $this->getPageWidth()-2; |
|
895 | + $p2y = $p1y; // Use same y for a straight line |
|
896 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
897 | 897 | $this->Line($p1x, $p1y, $p2x, $p2y, $style); |
898 | 898 | $this->Texto($this->detalle_cols['NmbItem']['title'], $x+1, $this->y, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
899 | 899 | $this->Texto($this->detalle_cols['PrcItem']['title'], $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
@@ -903,9 +903,9 @@ discard block |
||
903 | 903 | if (!isset($detalle[0])) |
904 | 904 | $detalle = [$detalle]; |
905 | 905 | $this->SetY($this->getY()+2); |
906 | - foreach($detalle as &$d) { |
|
906 | + foreach ($detalle as &$d) { |
|
907 | 907 | $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
908 | - $this->Texto(number_format($d['PrcItem'],0,',','.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
908 | + $this->Texto(number_format($d['PrcItem'], 0, ',', '.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
909 | 909 | $this->Texto($this->num($d['QtyItem']), $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']); |
910 | 910 | $this->Texto($this->num($d['MontoItem']), $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']); |
911 | 911 | } |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | if (!isset($detalle[0])) { |
926 | 926 | $detalle = [$detalle]; |
927 | 927 | } |
928 | - foreach($detalle as &$d) { |
|
928 | + foreach ($detalle as &$d) { |
|
929 | 929 | if (!empty($d['MontoItem'])) { |
930 | 930 | $subtotal += $d['MontoItem']; |
931 | 931 | } |
@@ -951,16 +951,16 @@ discard block |
||
951 | 951 | if (!isset($descuentosRecargos[0])) { |
952 | 952 | $descuentosRecargos = [$descuentosRecargos]; |
953 | 953 | } |
954 | - foreach($descuentosRecargos as $dr) { |
|
954 | + foreach ($descuentosRecargos as $dr) { |
|
955 | 955 | $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo'; |
956 | 956 | if (!empty($dr['IndExeDR'])) { |
957 | 957 | $tipo .= ' EX'; |
958 | 958 | } |
959 | 959 | $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : $this->num($dr['ValorDR']); |
960 | 960 | if ($this->papelContinuo) { |
961 | - $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):''), $x); |
|
961 | + $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : ''), $x); |
|
962 | 962 | } else { |
963 | - $this->Texto($tipo.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):'').':', 77, null, 'R', 100); |
|
963 | + $this->Texto($tipo.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : '').':', 77, null, 'R', 100); |
|
964 | 964 | $this->Texto($valor, 177, null, 'R', 22); |
965 | 965 | } |
966 | 966 | $this->Ln(); |
@@ -980,8 +980,8 @@ discard block |
||
980 | 980 | $pagos = [$pagos]; |
981 | 981 | $this->Texto('Pago(s) programado(s):', $x); |
982 | 982 | $this->Ln(); |
983 | - foreach($pagos as $p) { |
|
984 | - $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos'])?(' ('.$p['GlosaPagos'].')'):''), $x); |
|
983 | + foreach ($pagos as $p) { |
|
984 | + $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos']) ? (' ('.$p['GlosaPagos'].')') : ''), $x); |
|
985 | 985 | $this->Ln(); |
986 | 986 | } |
987 | 987 | } |
@@ -1032,7 +1032,7 @@ discard block |
||
1032 | 1032 | if (!isset($ImptoReten[0])) { |
1033 | 1033 | $ImptoReten = [$ImptoReten]; |
1034 | 1034 | } |
1035 | - foreach($ImptoReten as $i) { |
|
1035 | + foreach ($ImptoReten as $i) { |
|
1036 | 1036 | $totales['ImptoReten_'.$i['TipoImp']] = $i['MontoImp']; |
1037 | 1037 | if (!empty($i['TasaImp'])) { |
1038 | 1038 | $glosas['ImptoReten_'.$i['TipoImp']] = \sasco\LibreDTE\Sii\ImpuestosAdicionales::getGlosa($i['TipoImp']).' ('.$i['TasaImp'].'%) $'; |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | 'vpadding' => 0, |
1146 | 1146 | 'module_width' => 1, // width of a single module in points |
1147 | 1147 | 'module_height' => 1, // height of a single module in points |
1148 | - 'fgcolor' => [0,0,0], |
|
1148 | + 'fgcolor' => [0, 0, 0], |
|
1149 | 1149 | 'bgcolor' => false, // [255,255,255] |
1150 | 1150 | 'position' => $this->papelContinuo ? 'C' : 'S', |
1151 | 1151 | ]; |
@@ -1178,7 +1178,7 @@ discard block |
||
1178 | 1178 | protected function agregarAcuseRecibo($x = 83, $y = 190, $w = 60, $h = 40) |
1179 | 1179 | { |
1180 | 1180 | $y = (!$this->papelContinuo and !$this->timbre_pie) ? $this->x_fin_datos : $y; |
1181 | - $this->SetTextColorArray([0,0,0]); |
|
1181 | + $this->SetTextColorArray([0, 0, 0]); |
|
1182 | 1182 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
1183 | 1183 | $this->setFont('', 'B', 10); |
1184 | 1184 | $this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1208,9 +1208,9 @@ discard block |
||
1208 | 1208 | */ |
1209 | 1209 | protected function agregarAcuseReciboContinuo($x = 3, $y = null, $w = 68, $h = 40) |
1210 | 1210 | { |
1211 | - $this->SetTextColorArray([0,0,0]); |
|
1211 | + $this->SetTextColorArray([0, 0, 0]); |
|
1212 | 1212 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
1213 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
1213 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
1214 | 1214 | $this->Line($x, $y+22, $w+3, $y+22, $style); |
1215 | 1215 | //$this->setFont('', 'B', 10); |
1216 | 1216 | //$this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1240,7 +1240,7 @@ discard block |
||
1240 | 1240 | $y = (!$this->papelContinuo and !$this->timbre_pie and $this->x_fin_datos<=$y) ? $this->x_fin_datos : $y; |
1241 | 1241 | $y += 48; |
1242 | 1242 | $this->setFont('', 'B', $font_size); |
1243 | - $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $y, 'R'); |
|
1243 | + $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $y, 'R'); |
|
1244 | 1244 | } |
1245 | 1245 | |
1246 | 1246 | /** |
@@ -1251,7 +1251,7 @@ discard block |
||
1251 | 1251 | protected function agregarLeyendaDestinoContinuo($tipo) |
1252 | 1252 | { |
1253 | 1253 | $this->setFont('', 'B', 8); |
1254 | - $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $this->y+6, 'R'); |
|
1254 | + $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $this->y+6, 'R'); |
|
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | } |
@@ -432,10 +432,12 @@ discard block |
||
432 | 432 | } |
433 | 433 | $contacto = []; |
434 | 434 | if (!empty($emisor['Telefono'])) { |
435 | - if (!is_array($emisor['Telefono'])) |
|
436 | - $emisor['Telefono'] = [$emisor['Telefono']]; |
|
437 | - foreach ($emisor['Telefono'] as $t) |
|
438 | - $contacto[] = $t; |
|
435 | + if (!is_array($emisor['Telefono'])) { |
|
436 | + $emisor['Telefono'] = [$emisor['Telefono']]; |
|
437 | + } |
|
438 | + foreach ($emisor['Telefono'] as $t) { |
|
439 | + $contacto[] = $t; |
|
440 | + } |
|
439 | 441 | } |
440 | 442 | if (!empty($emisor['CorreoEmisor'])) { |
441 | 443 | $contacto[] = $emisor['CorreoEmisor']; |
@@ -639,10 +641,12 @@ discard block |
||
639 | 641 | $this->MultiTexto($receptor['Extranjero']['NumId'], $x+$offset+2); |
640 | 642 | } |
641 | 643 | $contacto = []; |
642 | - if (!empty($receptor['Contacto'])) |
|
643 | - $contacto[] = $receptor['Contacto']; |
|
644 | - if (!empty($receptor['CorreoRecep'])) |
|
645 | - $contacto[] = $receptor['CorreoRecep']; |
|
644 | + if (!empty($receptor['Contacto'])) { |
|
645 | + $contacto[] = $receptor['Contacto']; |
|
646 | + } |
|
647 | + if (!empty($receptor['CorreoRecep'])) { |
|
648 | + $contacto[] = $receptor['CorreoRecep']; |
|
649 | + } |
|
646 | 650 | if (!empty($contacto)) { |
647 | 651 | $this->setFont('', 'B', null); |
648 | 652 | $this->Texto('Contacto', $x); |
@@ -692,10 +696,12 @@ discard block |
||
692 | 696 | if (!empty($Transporte['DirDest']) and !empty($Transporte['CmnaDest'])) { |
693 | 697 | $transporte .= 'a '.$Transporte['DirDest'].', '.$Transporte['CmnaDest']; |
694 | 698 | } |
695 | - if (!empty($Transporte['RUTTrans'])) |
|
696 | - $transporte .= ' por '.$Transporte['RUTTrans']; |
|
697 | - if (!empty($Transporte['Patente'])) |
|
698 | - $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
699 | + if (!empty($Transporte['RUTTrans'])) { |
|
700 | + $transporte .= ' por '.$Transporte['RUTTrans']; |
|
701 | + } |
|
702 | + if (!empty($Transporte['Patente'])) { |
|
703 | + $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
704 | + } |
|
699 | 705 | if (isset($Transporte['Chofer']) and is_array($Transporte['Chofer'])) { |
700 | 706 | if (!empty($Transporte['Chofer']['NombreChofer'])) { |
701 | 707 | $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer']; |
@@ -758,8 +764,9 @@ discard block |
||
758 | 764 | */ |
759 | 765 | protected function agregarReferencia($referencias, $x = 10, $offset = 22) |
760 | 766 | { |
761 | - if (!isset($referencias[0])) |
|
762 | - $referencias = [$referencias]; |
|
767 | + if (!isset($referencias[0])) { |
|
768 | + $referencias = [$referencias]; |
|
769 | + } |
|
763 | 770 | foreach($referencias as $r) { |
764 | 771 | $texto = $r['NroLinRef'].' - '; |
765 | 772 | if (!empty($r['TpoDocRef'])) { |
@@ -909,8 +916,9 @@ discard block |
||
909 | 916 | $this->Texto($this->detalle_cols['QtyItem']['title'], $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']); |
910 | 917 | $this->Texto($this->detalle_cols['MontoItem']['title'], $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']); |
911 | 918 | $this->Line($p1x, $p1y+4, $p2x, $p2y+4, $style); |
912 | - if (!isset($detalle[0])) |
|
913 | - $detalle = [$detalle]; |
|
919 | + if (!isset($detalle[0])) { |
|
920 | + $detalle = [$detalle]; |
|
921 | + } |
|
914 | 922 | $this->SetY($this->getY()+2); |
915 | 923 | foreach($detalle as &$d) { |
916 | 924 | $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
@@ -985,8 +993,9 @@ discard block |
||
985 | 993 | */ |
986 | 994 | protected function agregarPagos(array $pagos, $x = 10) |
987 | 995 | { |
988 | - if (!isset($pagos[0])) |
|
989 | - $pagos = [$pagos]; |
|
996 | + if (!isset($pagos[0])) { |
|
997 | + $pagos = [$pagos]; |
|
998 | + } |
|
990 | 999 | $this->Texto('Pago(s) programado(s):', $x); |
991 | 1000 | $this->Ln(); |
992 | 1001 | foreach($pagos as $p) { |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | * Método que genera nodos XML a partir de un arreglo |
53 | 53 | * @param data Arreglo con los datos que se usarán para generar XML |
54 | 54 | * @param namespace Arreglo con el espacio de nombres para el XML que se generará (URI y prefijo) |
55 | - * @param parent DOMElement padre para los elementos, o =null para que sea la raíz |
|
56 | - * @return Objeto \sasco\LibreDTE\XML |
|
55 | + * @param parent \DOMElement padre para los elementos, o =null para que sea la raíz |
|
56 | + * @return XML \sasco\LibreDTE\XML |
|
57 | 57 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
58 | 58 | * @version 2017-10-22 |
59 | 59 | */ |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | /** |
154 | 154 | * Método para realizar consultas XPATH al documento XML |
155 | 155 | * @param expression Expresión XPath a ejecutar |
156 | - * @return DOMNodeList |
|
156 | + * @return \DOMNodeList |
|
157 | 157 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
158 | 158 | * @version 2015-08-05 |
159 | 159 | */ |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * Método que cuenta los nodos con el mismo nombre hijos de un DOMElement |
284 | 284 | * No sirve usar: $dom->getElementsByTagName($tagName)->length ya que esto |
285 | 285 | * entrega todos los nodos con el nombre, sean hijos, nietos, etc. |
286 | - * @return Cantidad de nodos hijos con el mismo nombre en el DOMElement |
|
286 | + * @return integer de nodos hijos con el mismo nombre en el DOMElement |
|
287 | 287 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
288 | 288 | * @version 2015-09-07 |
289 | 289 | */ |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | |
325 | 325 | /** |
326 | 326 | * Método que entrega el nombre del archivo del schema del XML |
327 | - * @return Nombre del schema o bien =false si no se encontró |
|
327 | + * @return string del schema o bien =false si no se encontró |
|
328 | 328 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
329 | 329 | * @version 2015-12-14 |
330 | 330 | */ |
@@ -366,6 +366,7 @@ discard block |
||
366 | 366 | * respeta el estándar y las requiere convertidas |
367 | 367 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
368 | 368 | * @version 2017-01-20 |
369 | + * @param string $xml |
|
369 | 370 | */ |
370 | 371 | private function fixEntities($xml) |
371 | 372 | { |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | private function utf2iso($string) |
199 | 199 | { |
200 | - return mb_detect_encoding($string, ['UTF-8', 'ISO-8859-1']) != 'ISO-8859-1' ? utf8_decode($string) : $string; |
|
200 | + return mb_detect_encoding($string, ['UTF-8', 'ISO-8859-1'])!='ISO-8859-1' ? utf8_decode($string) : $string; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | } |
241 | 241 | // si existen nodos hijos se agregan |
242 | 242 | if ($dom->hasChildNodes()) { |
243 | - foreach($dom->childNodes as $child) { |
|
243 | + foreach ($dom->childNodes as $child) { |
|
244 | 244 | if ($child instanceof \DOMText) { |
245 | 245 | $textContent = trim($child->textContent); |
246 | 246 | if ($textContent!="") { |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | $newXML = ''; |
373 | 373 | $n_letras = strlen($xml); |
374 | 374 | $convertir = false; |
375 | - for ($i=0; $i<$n_letras; ++$i) { |
|
375 | + for ($i = 0; $i<$n_letras; ++$i) { |
|
376 | 376 | if ($xml[$i]=='>') |
377 | 377 | $convertir = true; |
378 | 378 | if ($xml[$i]=='<') |
@@ -120,8 +120,9 @@ discard block |
||
120 | 120 | private function sanitize($txt) |
121 | 121 | { |
122 | 122 | // si no se paso un texto o bien es un número no se hace nada |
123 | - if (!$txt or is_numeric($txt)) |
|
124 | - return $txt; |
|
123 | + if (!$txt or is_numeric($txt)) { |
|
124 | + return $txt; |
|
125 | + } |
|
125 | 126 | // convertir "predefined entities" de XML |
126 | 127 | $txt = str_replace( |
127 | 128 | ['&', '&', '<', '<', '>', '>', '"', '"', ''', '''], |
@@ -174,8 +175,9 @@ discard block |
||
174 | 175 | { |
175 | 176 | if ($xpath) { |
176 | 177 | $node = $this->xpath($xpath)->item(0); |
177 | - if (!$node) |
|
178 | - return false; |
|
178 | + if (!$node) { |
|
179 | + return false; |
|
180 | + } |
|
179 | 181 | $xml = $this->utf2iso($node->C14N()); |
180 | 182 | $xml = $this->fixEntities($xml); |
181 | 183 | } else { |
@@ -250,8 +252,7 @@ discard block |
||
250 | 252 | $array[$dom->tagName]['@value'] = $textContent; |
251 | 253 | } |
252 | 254 | } |
253 | - } |
|
254 | - else if ($child instanceof \DOMElement) { |
|
255 | + } else if ($child instanceof \DOMElement) { |
|
255 | 256 | $nodos_gemelos = $this->countTwins($dom, $child->tagName); |
256 | 257 | // agregar nodo hijo directamente, ya que es el único nodo hijo con el mismo nombre de tag |
257 | 258 | if ($nodos_gemelos==1) { |
@@ -307,8 +308,9 @@ discard block |
||
307 | 308 | public function getErrors() |
308 | 309 | { |
309 | 310 | $errors = []; |
310 | - foreach (libxml_get_errors() as $e) |
|
311 | - $errors[] = $e->message; |
|
311 | + foreach (libxml_get_errors() as $e) { |
|
312 | + $errors[] = $e->message; |
|
313 | + } |
|
312 | 314 | return $errors; |
313 | 315 | } |
314 | 316 | |
@@ -331,8 +333,9 @@ discard block |
||
331 | 333 | public function getSchema() |
332 | 334 | { |
333 | 335 | $schemaLocation = $this->documentElement->getAttribute('xsi:schemaLocation'); |
334 | - if (!$schemaLocation or strpos($schemaLocation, ' ')===false) |
|
335 | - return false; |
|
336 | + if (!$schemaLocation or strpos($schemaLocation, ' ')===false) { |
|
337 | + return false; |
|
338 | + } |
|
336 | 339 | list($uri, $xsd) = explode(' ', $schemaLocation); |
337 | 340 | return $xsd; |
338 | 341 | } |
@@ -373,10 +376,12 @@ discard block |
||
373 | 376 | $n_letras = strlen($xml); |
374 | 377 | $convertir = false; |
375 | 378 | for ($i=0; $i<$n_letras; ++$i) { |
376 | - if ($xml[$i]=='>') |
|
377 | - $convertir = true; |
|
378 | - if ($xml[$i]=='<') |
|
379 | - $convertir = false; |
|
379 | + if ($xml[$i]=='>') { |
|
380 | + $convertir = true; |
|
381 | + } |
|
382 | + if ($xml[$i]=='<') { |
|
383 | + $convertir = false; |
|
384 | + } |
|
380 | 385 | if ($convertir) { |
381 | 386 | $l = $xml[$i]=='\'' ? ''' : ($xml[$i]=='"' ? '"' : $xml[$i]); |
382 | 387 | } else { |
@@ -852,8 +852,7 @@ |
||
852 | 852 | $valor = $codigo['CantBultos'].' '.$valor; |
853 | 853 | if (!empty($codigo['IdContainer'])) { |
854 | 854 | $valor .= ' ('.$codigo['IdContainer'].' / '.$codigo['Sello'].' / '.$codigo['EmisorSello'].')'; |
855 | - } |
|
856 | - else if (!empty($codigo['Marcas'])) { |
|
855 | + } else if (!empty($codigo['Marcas'])) { |
|
857 | 856 | $valor .= ' ('.$codigo['Marcas'].')'; |
858 | 857 | } |
859 | 858 | } else { |