@@ -82,5 +82,6 @@ |
||
82 | 82 | //echo $AEC->enviar(); |
83 | 83 | |
84 | 84 | // si hubo errores mostrar |
85 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
85 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
86 | 86 | echo $error, "\n"; |
87 | +} |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | ], |
421 | 421 | 'Detalle' => [ |
422 | 422 | [ |
423 | - 'QtyItem' => $set_pruebas[6]['Detalle'][0]['QtyItem']*0.4, |
|
423 | + 'QtyItem' => $set_pruebas[6]['Detalle'][0]['QtyItem'] * 0.4, |
|
424 | 424 | ] |
425 | 425 | ], |
426 | 426 | 'Referencia' => [ |
@@ -447,7 +447,7 @@ discard block |
||
447 | 447 | ], |
448 | 448 | 'Detalle' => [ |
449 | 449 | [ |
450 | - 'QtyItem' => $set_pruebas[9]['Detalle'][0]['QtyItem']*0.4, |
|
450 | + 'QtyItem' => $set_pruebas[9]['Detalle'][0]['QtyItem'] * 0.4, |
|
451 | 451 | ] |
452 | 452 | ], |
453 | 453 | 'Referencia' => [ |
@@ -480,4 +480,4 @@ discard block |
||
480 | 480 | |
481 | 481 | // si hubo errores mostrar |
482 | 482 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
483 | - echo $error,"\n"; |
|
483 | + echo $error, "\n"; |
@@ -313,25 +313,30 @@ discard block |
||
313 | 313 | // Objetos de Firma y Folios |
314 | 314 | $Firma = new \sasco\LibreDTE\FirmaElectronica($config['firma']); |
315 | 315 | $Folios = []; |
316 | -foreach ($folios as $tipo => $cantidad) |
|
316 | +foreach ($folios as $tipo => $cantidad) { |
|
317 | 317 | $Folios[$tipo] = new \sasco\LibreDTE\Sii\Folios(file_get_contents('xml/folios/'.$tipo.'.xml')); |
318 | +} |
|
318 | 319 | |
319 | 320 | // generar cada DTE, timbrar, firmar y agregar al sobre de EnvioBOLETA |
320 | 321 | $EnvioDTE = new \sasco\LibreDTE\Sii\EnvioDte(); |
321 | 322 | foreach ($set_pruebas as $documento) { |
322 | 323 | $DTE = new \sasco\LibreDTE\Sii\Dte($documento); |
323 | - if (!$DTE->timbrar($Folios[$DTE->getTipo()])) |
|
324 | - break; |
|
325 | - if (!$DTE->firmar($Firma)) |
|
326 | - break; |
|
324 | + if (!$DTE->timbrar($Folios[$DTE->getTipo()])) { |
|
325 | + break; |
|
326 | + } |
|
327 | + if (!$DTE->firmar($Firma)) { |
|
328 | + break; |
|
329 | + } |
|
327 | 330 | $EnvioDTE->agregar($DTE); |
328 | 331 | } |
329 | 332 | $EnvioDTE->setFirma($Firma); |
330 | 333 | $EnvioDTE->setCaratula($caratula); |
331 | 334 | $EnvioDTE->generar(); |
332 | 335 | if ($EnvioDTE->schemaValidate()) { |
333 | - if (is_writable('xml/EnvioBOLETA.xml')) |
|
334 | - file_put_contents('xml/EnvioBOLETA.xml', $EnvioDTE->generar()); // guardar XML en sistema de archivos |
|
336 | + if (is_writable('xml/EnvioBOLETA.xml')) { |
|
337 | + file_put_contents('xml/EnvioBOLETA.xml', $EnvioDTE->generar()); |
|
338 | + } |
|
339 | + // guardar XML en sistema de archivos |
|
335 | 340 | echo $EnvioDTE->generar(); |
336 | 341 | } |
337 | 342 | |
@@ -463,21 +468,26 @@ discard block |
||
463 | 468 | $EnvioDTE = new \sasco\LibreDTE\Sii\EnvioDte(); |
464 | 469 | foreach ($notas_credito as $documento) { |
465 | 470 | $DTE = new \sasco\LibreDTE\Sii\Dte($documento); |
466 | - if (!$DTE->timbrar($Folios[$DTE->getTipo()])) |
|
467 | - break; |
|
468 | - if (!$DTE->firmar($Firma)) |
|
469 | - break; |
|
471 | + if (!$DTE->timbrar($Folios[$DTE->getTipo()])) { |
|
472 | + break; |
|
473 | + } |
|
474 | + if (!$DTE->firmar($Firma)) { |
|
475 | + break; |
|
476 | + } |
|
470 | 477 | $EnvioDTE->agregar($DTE); |
471 | 478 | } |
472 | 479 | $EnvioDTE->setFirma($Firma); |
473 | 480 | $EnvioDTE->setCaratula($caratula); |
474 | 481 | $EnvioDTE->generar(); |
475 | 482 | if ($EnvioDTE->schemaValidate()) { |
476 | - if (is_writable('xml/EnvioDTE.xml')) |
|
477 | - file_put_contents('xml/EnvioDTE.xml', $EnvioDTE->generar()); // guardar XML en sistema de archivos |
|
483 | + if (is_writable('xml/EnvioDTE.xml')) { |
|
484 | + file_put_contents('xml/EnvioDTE.xml', $EnvioDTE->generar()); |
|
485 | + } |
|
486 | + // guardar XML en sistema de archivos |
|
478 | 487 | echo $EnvioDTE->generar(); |
479 | 488 | } |
480 | 489 | |
481 | 490 | // si hubo errores mostrar |
482 | -foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
491 | +foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
483 | 492 | echo $error,"\n"; |
493 | +} |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($config['firma']); |
44 | 44 | if (!$token) { |
45 | 45 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
46 | - echo $error,"\n"; |
|
46 | + echo $error, "\n"; |
|
47 | 47 | exit; |
48 | 48 | } |
49 | 49 | |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | // si hubo algún error al enviar al servidor mostrar |
54 | 54 | if ($result===false) { |
55 | 55 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
56 | - echo $error,"\n"; |
|
56 | + echo $error, "\n"; |
|
57 | 57 | exit; |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Mostrar resultado del envío |
61 | 61 | if ($result->STATUS!='0') { |
62 | 62 | foreach (\sasco\LibreDTE\Log::readAll() as $error) |
63 | - echo $error,"\n"; |
|
63 | + echo $error, "\n"; |
|
64 | 64 | exit; |
65 | 65 | } |
66 | -echo 'DTE envíado. Track ID '.$result->TRACKID,"\n"; |
|
66 | +echo 'DTE envíado. Track ID '.$result->TRACKID, "\n"; |
@@ -42,8 +42,9 @@ discard block |
||
42 | 42 | // solicitar token |
43 | 43 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($config['firma']); |
44 | 44 | if (!$token) { |
45 | - foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
46 | - echo $error,"\n"; |
|
45 | + foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
46 | + echo $error,"\n"; |
|
47 | + } |
|
47 | 48 | exit; |
48 | 49 | } |
49 | 50 | |
@@ -52,15 +53,17 @@ discard block |
||
52 | 53 | |
53 | 54 | // si hubo algún error al enviar al servidor mostrar |
54 | 55 | if ($result===false) { |
55 | - foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
56 | - echo $error,"\n"; |
|
56 | + foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
57 | + echo $error,"\n"; |
|
58 | + } |
|
57 | 59 | exit; |
58 | 60 | } |
59 | 61 | |
60 | 62 | // Mostrar resultado del envío |
61 | 63 | if ($result->STATUS!='0') { |
62 | - foreach (\sasco\LibreDTE\Log::readAll() as $error) |
|
63 | - echo $error,"\n"; |
|
64 | + foreach (\sasco\LibreDTE\Log::readAll() as $error) { |
|
65 | + echo $error,"\n"; |
|
66 | + } |
|
64 | 67 | exit; |
65 | 68 | } |
66 | 69 | echo 'DTE envíado. Track ID '.$result->TRACKID,"\n"; |
@@ -98,8 +98,9 @@ discard block |
||
98 | 98 | public function generar() |
99 | 99 | { |
100 | 100 | // si ya se había generado se entrega directamente |
101 | - if ($this->xml_data) |
|
102 | - return $this->xml_data; |
|
101 | + if ($this->xml_data) { |
|
102 | + return $this->xml_data; |
|
103 | + } |
|
103 | 104 | // si no hay respuestas para generar entregar falso |
104 | 105 | if (!isset($this->recibos[0])) { |
105 | 106 | \sasco\LibreDTE\Log::write( |
@@ -173,8 +174,9 @@ discard block |
||
173 | 174 | } |
174 | 175 | // crear recibos a partir del arreglo |
175 | 176 | $Recibos = $this->arreglo['EnvioRecibos']['SetRecibos']['Recibo']; |
176 | - if (!isset($Recibos[0])) |
|
177 | - $Recibos = [$Recibos]; |
|
177 | + if (!isset($Recibos[0])) { |
|
178 | + $Recibos = [$Recibos]; |
|
179 | + } |
|
178 | 180 | foreach ($Recibos as $Recibo) { |
179 | 181 | $this->recibos[] = $Recibo; |
180 | 182 | } |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | ], $detalle); |
76 | 76 | // calcular valores que no se hayan entregado |
77 | 77 | if (!$detalle['IVA'] and $detalle['TasaImp'] and $detalle['MntNeto']) { |
78 | - $detalle['IVA'] = round($detalle['MntNeto'] * ($detalle['TasaImp']/100)); |
|
78 | + $detalle['IVA'] = round($detalle['MntNeto'] * ($detalle['TasaImp'] / 100)); |
|
79 | 79 | } |
80 | 80 | // calcular monto total si no se especificó |
81 | 81 | if ($detalle['MntTotal']===false) { |
82 | - $detalle['MntTotal'] = $detalle['MntNeto'] + $detalle['IVA']; |
|
82 | + $detalle['MntTotal'] = $detalle['MntNeto']+$detalle['IVA']; |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $data = \sasco\LibreDTE\CSV::read($archivo); |
97 | 97 | $n_data = count($data); |
98 | 98 | $detalles = []; |
99 | - for ($i=1; $i<$n_data; $i++) { |
|
99 | + for ($i = 1; $i<$n_data; $i++) { |
|
100 | 100 | // detalle genérico |
101 | 101 | $detalle = [ |
102 | 102 | 'Folio' => $data[$i][0], |
@@ -199,17 +199,17 @@ discard block |
||
199 | 199 | // se contabiliza si la guía está anulada |
200 | 200 | if ($d['Anulado']==1 or $d['Anulado']==2) { |
201 | 201 | if ($d['Anulado']==1) { |
202 | - $ResumenPeriodo['TotFolAnulado'] = (int)$ResumenPeriodo['TotFolAnulado'] + 1; |
|
202 | + $ResumenPeriodo['TotFolAnulado'] = (int)$ResumenPeriodo['TotFolAnulado']+1; |
|
203 | 203 | } else { |
204 | - $ResumenPeriodo['TotGuiaAnulada'] = (int)$ResumenPeriodo['TotGuiaAnulada'] + 1; |
|
204 | + $ResumenPeriodo['TotGuiaAnulada'] = (int)$ResumenPeriodo['TotGuiaAnulada']+1; |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | // si no está anulado |
208 | 208 | else { |
209 | 209 | // si es de venta |
210 | 210 | if ($d['TpoOper']==1) { |
211 | - $ResumenPeriodo['TotGuiaVenta'] = (int)$ResumenPeriodo['TotGuiaVenta'] + 1; |
|
212 | - $ResumenPeriodo['TotMntGuiaVta'] = (int)$ResumenPeriodo['TotMntGuiaVta'] + $d['MntTotal']; |
|
211 | + $ResumenPeriodo['TotGuiaVenta'] = (int)$ResumenPeriodo['TotGuiaVenta']+1; |
|
212 | + $ResumenPeriodo['TotMntGuiaVta'] = (int)$ResumenPeriodo['TotMntGuiaVta']+$d['MntTotal']; |
|
213 | 213 | } |
214 | 214 | // si no es de venta |
215 | 215 | else { |
@@ -40,8 +40,9 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function agregar(array $detalle, $normalizar = true) |
42 | 42 | { |
43 | - if ($normalizar) |
|
44 | - $this->normalizarDetalle($detalle); |
|
43 | + if ($normalizar) { |
|
44 | + $this->normalizarDetalle($detalle); |
|
45 | + } |
|
45 | 46 | $this->detalles[] = $detalle; |
46 | 47 | return true; |
47 | 48 | } |
@@ -138,8 +139,9 @@ discard block |
||
138 | 139 | 'TipoEnvio' => 'TOTAL', |
139 | 140 | 'FolioNotificacion' => null, |
140 | 141 | ], $caratula); |
141 | - if ($this->caratula['TipoEnvio']=='ESPECIAL') |
|
142 | - $this->caratula['FolioNotificacion'] = null; |
|
142 | + if ($this->caratula['TipoEnvio']=='ESPECIAL') { |
|
143 | + $this->caratula['FolioNotificacion'] = null; |
|
144 | + } |
|
143 | 145 | $this->id = 'LibreDTE_LIBRO_GUIA_'.str_replace('-', '', $this->caratula['RutEmisorLibro']).'_'.str_replace('-', '', $this->caratula['PeriodoTributario']).'_'.date('U'); |
144 | 146 | } |
145 | 147 | |
@@ -153,8 +155,9 @@ discard block |
||
153 | 155 | public function generar($incluirDetalle = true) |
154 | 156 | { |
155 | 157 | // si ya se había generado se entrega directamente |
156 | - if ($this->xml_data) |
|
157 | - return $this->xml_data; |
|
158 | + if ($this->xml_data) { |
|
159 | + return $this->xml_data; |
|
160 | + } |
|
158 | 161 | // generar XML del envío |
159 | 162 | $xmlEnvio = (new \sasco\LibreDTE\XML())->generate([ |
160 | 163 | 'LibroGuia' => [ |
@@ -73,10 +73,12 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function agregarRespuestaEnvio(array $datos) |
75 | 75 | { |
76 | - if (isset($this->respuesta_documentos[0])) |
|
77 | - return false; |
|
78 | - if (isset($this->respuesta_envios[$this->config['respuesta_envios_max']-1])) |
|
79 | - return false; |
|
76 | + if (isset($this->respuesta_documentos[0])) { |
|
77 | + return false; |
|
78 | + } |
|
79 | + if (isset($this->respuesta_envios[$this->config['respuesta_envios_max']-1])) { |
|
80 | + return false; |
|
81 | + } |
|
80 | 82 | $this->respuesta_envios[] = array_merge([ |
81 | 83 | 'NmbEnvio' => false, |
82 | 84 | 'FchRecep' => date('Y-m-d\TH:i:s'), |
@@ -102,10 +104,12 @@ discard block |
||
102 | 104 | */ |
103 | 105 | public function agregarRespuestaDocumento(array $datos) |
104 | 106 | { |
105 | - if (isset($this->respuesta_envios[0])) |
|
106 | - return false; |
|
107 | - if (isset($this->respuesta_documentos[$this->config['respuesta_documentos_max']-1])) |
|
108 | - return false; |
|
107 | + if (isset($this->respuesta_envios[0])) { |
|
108 | + return false; |
|
109 | + } |
|
110 | + if (isset($this->respuesta_documentos[$this->config['respuesta_documentos_max']-1])) { |
|
111 | + return false; |
|
112 | + } |
|
109 | 113 | $this->respuesta_documentos[] = array_merge([ |
110 | 114 | 'TipoDTE' => false, |
111 | 115 | 'Folio' => false, |
@@ -156,8 +160,9 @@ discard block |
||
156 | 160 | public function generar() |
157 | 161 | { |
158 | 162 | // si ya se había generado se entrega directamente |
159 | - if ($this->xml_data) |
|
160 | - return $this->xml_data; |
|
163 | + if ($this->xml_data) { |
|
164 | + return $this->xml_data; |
|
165 | + } |
|
161 | 166 | // si no hay respuestas para generar entregar falso |
162 | 167 | if (!isset($this->respuesta_envios[0]) and !isset($this->respuesta_documentos[0])) { |
163 | 168 | \sasco\LibreDTE\Log::write( |
@@ -230,8 +235,9 @@ discard block |
||
230 | 235 | */ |
231 | 236 | public function getRecepciones() |
232 | 237 | { |
233 | - if (!$this->esRecepcionEnvio()) |
|
234 | - return false; |
|
238 | + if (!$this->esRecepcionEnvio()) { |
|
239 | + return false; |
|
240 | + } |
|
235 | 241 | // si no hay respustas se deben crear |
236 | 242 | if (!$this->respuesta_envios) { |
237 | 243 | // si no está creado el arrelgo con los datos error |
@@ -242,8 +248,9 @@ discard block |
||
242 | 248 | if (isset($this->arreglo['RespuestaDTE']['Resultado']['RecepcionEnvio']['RecepcionDTE'])) { |
243 | 249 | // crear repuestas a partir del arreglo |
244 | 250 | $Recepciones = $this->arreglo['RespuestaDTE']['Resultado']['RecepcionEnvio']['RecepcionDTE']; |
245 | - if (!isset($Recepciones[0])) |
|
246 | - $Recepciones = [$Recepciones]; |
|
251 | + if (!isset($Recepciones[0])) { |
|
252 | + $Recepciones = [$Recepciones]; |
|
253 | + } |
|
247 | 254 | foreach ($Recepciones as $Recepcion) { |
248 | 255 | $this->respuesta_envios[] = $Recepcion; |
249 | 256 | } |
@@ -260,8 +267,9 @@ discard block |
||
260 | 267 | */ |
261 | 268 | public function getResultados() |
262 | 269 | { |
263 | - if (!$this->esResultadoDTE()) |
|
264 | - return false; |
|
270 | + if (!$this->esResultadoDTE()) { |
|
271 | + return false; |
|
272 | + } |
|
265 | 273 | // si no hay respustas se deben crear |
266 | 274 | if (!$this->respuesta_documentos) { |
267 | 275 | // si no está creado el arrelgo con los datos error |
@@ -270,8 +278,9 @@ discard block |
||
270 | 278 | } |
271 | 279 | // crear repuestas a partir del arreglo |
272 | 280 | $Resultados = $this->arreglo['RespuestaDTE']['Resultado']['ResultadoDTE']; |
273 | - if (!isset($Resultados[0])) |
|
274 | - $Resultados = [$Resultados]; |
|
281 | + if (!isset($Resultados[0])) { |
|
282 | + $Resultados = [$Resultados]; |
|
283 | + } |
|
275 | 284 | foreach ($Resultados as $Resultado) { |
276 | 285 | $this->respuesta_documentos[] = $Resultado; |
277 | 286 | } |
@@ -162,8 +162,9 @@ discard block |
||
162 | 162 | */ |
163 | 163 | public static function getTipo($codigo) |
164 | 164 | { |
165 | - if (isset(self::$impuestos[$codigo])) |
|
166 | - return self::$impuestos[$codigo]['tipo']; |
|
165 | + if (isset(self::$impuestos[$codigo])) { |
|
166 | + return self::$impuestos[$codigo]['tipo']; |
|
167 | + } |
|
167 | 168 | return false; |
168 | 169 | } |
169 | 170 | |
@@ -175,8 +176,9 @@ discard block |
||
175 | 176 | */ |
176 | 177 | public static function getGlosa($codigo) |
177 | 178 | { |
178 | - if (isset(self::$impuestos[$codigo])) |
|
179 | - return self::$impuestos[$codigo]['glosa']; |
|
179 | + if (isset(self::$impuestos[$codigo])) { |
|
180 | + return self::$impuestos[$codigo]['glosa']; |
|
181 | + } |
|
180 | 182 | return 'Impto. cód. '.$codigo; |
181 | 183 | } |
182 | 184 | |
@@ -188,8 +190,9 @@ discard block |
||
188 | 190 | */ |
189 | 191 | public static function getTasa($codigo) |
190 | 192 | { |
191 | - if (isset(self::$impuestos[$codigo]['tasa'])) |
|
192 | - return self::$impuestos[$codigo]['tasa']; |
|
193 | + if (isset(self::$impuestos[$codigo]['tasa'])) { |
|
194 | + return self::$impuestos[$codigo]['tasa']; |
|
195 | + } |
|
193 | 196 | return false; |
194 | 197 | } |
195 | 198 |
@@ -138,7 +138,7 @@ |
||
138 | 138 | ]; |
139 | 139 | // agregar otros impuestos adicionales |
140 | 140 | if ($n_OtrosImp>1) { |
141 | - for ($i=1; $i<$n_OtrosImp; $i++) { |
|
141 | + for ($i = 1; $i<$n_OtrosImp; $i++) { |
|
142 | 142 | $detalle[] = [ |
143 | 143 | '', |
144 | 144 | '', |
@@ -52,8 +52,9 @@ discard block |
||
52 | 52 | { |
53 | 53 | $this->startPageGroup(); |
54 | 54 | $this->AddPage(); |
55 | - if (isset($libro['LibroCompraVenta'])) |
|
56 | - $libro = $libro['LibroCompraVenta']; |
|
55 | + if (isset($libro['LibroCompraVenta'])) { |
|
56 | + $libro = $libro['LibroCompraVenta']; |
|
57 | + } |
|
57 | 58 | // título del libro |
58 | 59 | $this->SetFont('helvetica', 'B', 16); |
59 | 60 | $this->Texto('Libro de '.ucfirst(strtolower($libro['EnvioLibro']['Caratula']['TipoOperacion'])), null, null, 'C'); |
@@ -115,10 +116,13 @@ discard block |
||
115 | 116 | foreach ($libro['EnvioLibro']['Detalle'] as $d) { |
116 | 117 | // impuesto adicional |
117 | 118 | if (!empty($d['OtrosImp'])) { |
118 | - if (!isset($d['OtrosImp'][0])) |
|
119 | - $d['OtrosImp'] = [$d['OtrosImp']]; |
|
119 | + if (!isset($d['OtrosImp'][0])) { |
|
120 | + $d['OtrosImp'] = [$d['OtrosImp']]; |
|
121 | + } |
|
120 | 122 | $n_OtrosImp = count($d['OtrosImp']); |
121 | - } else $n_OtrosImp = 0; |
|
123 | + } else { |
|
124 | + $n_OtrosImp = 0; |
|
125 | + } |
|
122 | 126 | // se agrega detalle |
123 | 127 | $detalle[] = [ |
124 | 128 | $d['TpoDoc'], |
@@ -302,15 +302,17 @@ discard block |
||
302 | 302 | !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null, |
303 | 303 | !empty($dte['Encabezado']['Transporte']) ? $dte['Encabezado']['Transporte'] : null |
304 | 304 | ); |
305 | - if (!empty($dte['Referencia'])) |
|
306 | - $this->agregarReferencia($dte['Referencia']); |
|
305 | + if (!empty($dte['Referencia'])) { |
|
306 | + $this->agregarReferencia($dte['Referencia']); |
|
307 | + } |
|
307 | 308 | $this->agregarDetalle($dte['Detalle']); |
308 | 309 | if (!empty($dte['DscRcgGlobal'])) { |
309 | 310 | $this->agregarSubTotal($dte['Detalle']); |
310 | 311 | $this->agregarDescuentosRecargos($dte['DscRcgGlobal']); |
311 | 312 | } |
312 | - if (!empty($dte['Encabezado']['IdDoc']['MntPagos'])) |
|
313 | - $this->agregarPagos($dte['Encabezado']['IdDoc']['MntPagos']); |
|
313 | + if (!empty($dte['Encabezado']['IdDoc']['MntPagos'])) { |
|
314 | + $this->agregarPagos($dte['Encabezado']['IdDoc']['MntPagos']); |
|
315 | + } |
|
314 | 316 | $this->agregarTotales($dte['Encabezado']['Totales']); |
315 | 317 | // agregar observaciones |
316 | 318 | $this->agregarObservacion($dte['Encabezado']['IdDoc']); |
@@ -342,8 +344,12 @@ discard block |
||
342 | 344 | // determinar alto de la página y agregarla |
343 | 345 | $height = 145; |
344 | 346 | $n_detalle = count($dte['Detalle']); |
345 | - if ($n_detalle>1) $height += $n_detalle*20; |
|
346 | - if ($this->cedible) $height += 50; |
|
347 | + if ($n_detalle>1) { |
|
348 | + $height += $n_detalle*20; |
|
349 | + } |
|
350 | + if ($this->cedible) { |
|
351 | + $height += 50; |
|
352 | + } |
|
347 | 353 | $this->AddPage('P', [$height, $width]); |
348 | 354 | // agregar cabecera del documento |
349 | 355 | $y = $this->agregarFolio( |
@@ -445,10 +451,12 @@ discard block |
||
445 | 451 | } |
446 | 452 | $contacto = []; |
447 | 453 | if (!empty($emisor['Telefono'])) { |
448 | - if (!is_array($emisor['Telefono'])) |
|
449 | - $emisor['Telefono'] = [$emisor['Telefono']]; |
|
450 | - foreach ($emisor['Telefono'] as $t) |
|
451 | - $contacto[] = $t; |
|
454 | + if (!is_array($emisor['Telefono'])) { |
|
455 | + $emisor['Telefono'] = [$emisor['Telefono']]; |
|
456 | + } |
|
457 | + foreach ($emisor['Telefono'] as $t) { |
|
458 | + $contacto[] = $t; |
|
459 | + } |
|
452 | 460 | } |
453 | 461 | if (!empty($emisor['CorreoEmisor'])) { |
454 | 462 | $contacto[] = $emisor['CorreoEmisor']; |
@@ -515,8 +523,9 @@ discard block |
||
515 | 523 | */ |
516 | 524 | private function getTipo($tipo) |
517 | 525 | { |
518 | - if (!is_numeric($tipo) and !isset($this->tipos[$tipo])) |
|
519 | - return $tipo; |
|
526 | + if (!is_numeric($tipo) and !isset($this->tipos[$tipo])) { |
|
527 | + return $tipo; |
|
528 | + } |
|
520 | 529 | return isset($this->tipos[$tipo]) ? strtoupper($this->tipos[$tipo]) : 'Documento '.$tipo; |
521 | 530 | } |
522 | 531 | |
@@ -655,10 +664,12 @@ discard block |
||
655 | 664 | $this->MultiTexto(\sasco\LibreDTE\Sii\Aduana::getNacionalidad($receptor['Extranjero']['Nacionalidad']), $x+$offset+2); |
656 | 665 | } |
657 | 666 | $contacto = []; |
658 | - if (!empty($receptor['Contacto'])) |
|
659 | - $contacto[] = $receptor['Contacto']; |
|
660 | - if (!empty($receptor['CorreoRecep'])) |
|
661 | - $contacto[] = $receptor['CorreoRecep']; |
|
667 | + if (!empty($receptor['Contacto'])) { |
|
668 | + $contacto[] = $receptor['Contacto']; |
|
669 | + } |
|
670 | + if (!empty($receptor['CorreoRecep'])) { |
|
671 | + $contacto[] = $receptor['CorreoRecep']; |
|
672 | + } |
|
662 | 673 | if (!empty($contacto)) { |
663 | 674 | $this->setFont('', 'B', null); |
664 | 675 | $this->Texto('Contacto', $x); |
@@ -701,15 +712,19 @@ discard block |
||
701 | 712 | if (!empty($Transporte['DirDest']) and !empty($Transporte['CmnaDest'])) { |
702 | 713 | $transporte .= 'a '.$Transporte['DirDest'].', '.$Transporte['CmnaDest']; |
703 | 714 | } |
704 | - if (!empty($Transporte['RUTTrans'])) |
|
705 | - $transporte .= ' por '.$Transporte['RUTTrans']; |
|
706 | - if (!empty($Transporte['Patente'])) |
|
707 | - $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
715 | + if (!empty($Transporte['RUTTrans'])) { |
|
716 | + $transporte .= ' por '.$Transporte['RUTTrans']; |
|
717 | + } |
|
718 | + if (!empty($Transporte['Patente'])) { |
|
719 | + $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
720 | + } |
|
708 | 721 | if (isset($Transporte['Chofer']) and is_array($Transporte['Chofer'])) { |
709 | - if (!empty($Transporte['Chofer']['NombreChofer'])) |
|
710 | - $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer']; |
|
711 | - if (!empty($Transporte['Chofer']['RUTChofer'])) |
|
712 | - $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')'; |
|
722 | + if (!empty($Transporte['Chofer']['NombreChofer'])) { |
|
723 | + $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer']; |
|
724 | + } |
|
725 | + if (!empty($Transporte['Chofer']['RUTChofer'])) { |
|
726 | + $transporte .= ' ('.$Transporte['Chofer']['RUTChofer'].')'; |
|
727 | + } |
|
713 | 728 | } |
714 | 729 | if ($transporte) { |
715 | 730 | $this->setFont('', 'B', null); |
@@ -723,8 +738,9 @@ discard block |
||
723 | 738 | if (!empty($Transporte['Aduana']) and is_array($Transporte['Aduana'])) { |
724 | 739 | $col = 0; |
725 | 740 | foreach ($Transporte['Aduana'] as $tag => $codigo) { |
726 | - if ($codigo===false) |
|
727 | - continue; |
|
741 | + if ($codigo===false) { |
|
742 | + continue; |
|
743 | + } |
|
728 | 744 | $glosa = \sasco\LibreDTE\Sii\Aduana::getGlosa($tag); |
729 | 745 | $valor = \sasco\LibreDTE\Sii\Aduana::getValor($tag, $codigo); |
730 | 746 | if ($glosa!==false and $valor!==false) { |
@@ -737,15 +753,18 @@ discard block |
||
737 | 753 | $this->Texto(':', $x+$offset+$col); |
738 | 754 | $this->setFont('', '', null); |
739 | 755 | $this->Texto($valor, $x+$offset+2+$col); |
740 | - if ($tag=='TipoBultos') |
|
741 | - $col = abs($col-110); |
|
742 | - if ($col) |
|
743 | - $this->Ln(); |
|
756 | + if ($tag=='TipoBultos') { |
|
757 | + $col = abs($col-110); |
|
758 | + } |
|
759 | + if ($col) { |
|
760 | + $this->Ln(); |
|
761 | + } |
|
744 | 762 | $col = abs($col-110); |
745 | 763 | } |
746 | 764 | } |
747 | - if ($col) |
|
748 | - $this->Ln(); |
|
765 | + if ($col) { |
|
766 | + $this->Ln(); |
|
767 | + } |
|
749 | 768 | } |
750 | 769 | } |
751 | 770 | |
@@ -758,12 +777,14 @@ discard block |
||
758 | 777 | */ |
759 | 778 | private function agregarReferencia($referencias, $x = 10, $offset = 22) |
760 | 779 | { |
761 | - if (!isset($referencias[0])) |
|
762 | - $referencias = [$referencias]; |
|
780 | + if (!isset($referencias[0])) { |
|
781 | + $referencias = [$referencias]; |
|
782 | + } |
|
763 | 783 | foreach($referencias as $r) { |
764 | 784 | $texto = $r['NroLinRef'].' - '.$this->getTipo($r['TpoDocRef']).' N° '.$r['FolioRef'].' del '.$r['FchRef']; |
765 | - if (isset($r['RazonRef']) and $r['RazonRef']!==false) |
|
766 | - $texto = $texto.': '.$r['RazonRef']; |
|
785 | + if (isset($r['RazonRef']) and $r['RazonRef']!==false) { |
|
786 | + $texto = $texto.': '.$r['RazonRef']; |
|
787 | + } |
|
767 | 788 | $this->setFont('', 'B', null); |
768 | 789 | $this->Texto('Referencia', $x); |
769 | 790 | $this->Texto(':', $x+$offset); |
@@ -782,8 +803,9 @@ discard block |
||
782 | 803 | */ |
783 | 804 | private function agregarDetalle($detalle, $x = 10) |
784 | 805 | { |
785 | - if (!isset($detalle[0])) |
|
786 | - $detalle = [$detalle]; |
|
806 | + if (!isset($detalle[0])) { |
|
807 | + $detalle = [$detalle]; |
|
808 | + } |
|
787 | 809 | $this->setFont('', '', $this->detalle_fuente); |
788 | 810 | // titulos |
789 | 811 | $titulos = []; |
@@ -800,36 +822,42 @@ discard block |
||
800 | 822 | $item['NmbItem'] .= !$this->item_detalle_posicion ? '<br/>' : ': '; |
801 | 823 | $item['NmbItem'] .= '<span style="font-size:0.7em">'.$item['DscItem'].'</span>'; |
802 | 824 | } |
803 | - if (!in_array($col, $titulos_keys) or ($dte_exento and $col=='IndExe')) |
|
804 | - unset($item[$col]); |
|
825 | + if (!in_array($col, $titulos_keys) or ($dte_exento and $col=='IndExe')) { |
|
826 | + unset($item[$col]); |
|
827 | + } |
|
805 | 828 | } |
806 | 829 | // ajustes a IndExe |
807 | 830 | if (isset($item['IndExe'])) { |
808 | - if ($item['IndExe']==1) |
|
809 | - $item['IndExe'] = 'EX'; |
|
810 | - else if ($item['IndExe']==2) |
|
811 | - $item['IndExe'] = 'NF'; |
|
831 | + if ($item['IndExe']==1) { |
|
832 | + $item['IndExe'] = 'EX'; |
|
833 | + } else if ($item['IndExe']==2) { |
|
834 | + $item['IndExe'] = 'NF'; |
|
835 | + } |
|
812 | 836 | } |
813 | 837 | // agregar todas las columnas que se podrían imprimir en la tabla |
814 | 838 | $item_default = []; |
815 | - foreach ($this->detalle_cols as $key => $info) |
|
816 | - $item_default[$key] = false; |
|
839 | + foreach ($this->detalle_cols as $key => $info) { |
|
840 | + $item_default[$key] = false; |
|
841 | + } |
|
817 | 842 | $item = array_merge($item_default, $item); |
818 | 843 | // si hay código de item se extrae su valor |
819 | - if ($item['CdgItem']) |
|
820 | - $item['CdgItem'] = $item['CdgItem']['VlrCodigo']; |
|
844 | + if ($item['CdgItem']) { |
|
845 | + $item['CdgItem'] = $item['CdgItem']['VlrCodigo']; |
|
846 | + } |
|
821 | 847 | // dar formato a números |
822 | 848 | foreach (['QtyItem', 'PrcItem', 'DescuentoMonto', 'RecargoMonto', 'MontoItem'] as $col) { |
823 | - if ($item[$col]) |
|
824 | - $item[$col] = $this->num($item[$col]); |
|
849 | + if ($item[$col]) { |
|
850 | + $item[$col] = $this->num($item[$col]); |
|
851 | + } |
|
825 | 852 | } |
826 | 853 | } |
827 | 854 | // opciones |
828 | 855 | $options = ['align'=>[]]; |
829 | 856 | $i = 0; |
830 | 857 | foreach ($this->detalle_cols as $info) { |
831 | - if (isset($info['width'])) |
|
832 | - $options['width'][$i] = $info['width']; |
|
858 | + if (isset($info['width'])) { |
|
859 | + $options['width'][$i] = $info['width']; |
|
860 | + } |
|
833 | 861 | $options['align'][$i] = $info['align']; |
834 | 862 | $i++; |
835 | 863 | } |
@@ -862,8 +890,9 @@ discard block |
||
862 | 890 | $this->Texto($this->detalle_cols['QtyItem']['title'], $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']); |
863 | 891 | $this->Texto($this->detalle_cols['MontoItem']['title'], $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']); |
864 | 892 | $this->Line($p1x, $p1y+4, $p2x, $p2y+4, $style); |
865 | - if (!isset($detalle[0])) |
|
866 | - $detalle = [$detalle]; |
|
893 | + if (!isset($detalle[0])) { |
|
894 | + $detalle = [$detalle]; |
|
895 | + } |
|
867 | 896 | $this->SetY($this->getY()+2); |
868 | 897 | foreach($detalle as &$d) { |
869 | 898 | $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
@@ -905,8 +934,9 @@ discard block |
||
905 | 934 | */ |
906 | 935 | private function agregarDescuentosRecargos(array $descuentosRecargos, $x = 10) |
907 | 936 | { |
908 | - if (!isset($descuentosRecargos[0])) |
|
909 | - $descuentosRecargos = [$descuentosRecargos]; |
|
937 | + if (!isset($descuentosRecargos[0])) { |
|
938 | + $descuentosRecargos = [$descuentosRecargos]; |
|
939 | + } |
|
910 | 940 | foreach($descuentosRecargos as $dr) { |
911 | 941 | $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo'; |
912 | 942 | $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : '$'.$this->num($dr['ValorDR']).'.-'; |
@@ -924,8 +954,9 @@ discard block |
||
924 | 954 | */ |
925 | 955 | private function agregarPagos(array $pagos, $x = 10) |
926 | 956 | { |
927 | - if (!isset($pagos[0])) |
|
928 | - $pagos = [$pagos]; |
|
957 | + if (!isset($pagos[0])) { |
|
958 | + $pagos = [$pagos]; |
|
959 | + } |
|
929 | 960 | $this->Texto('Pago(s) programado(s):', $x); |
930 | 961 | $this->Ln(); |
931 | 962 | foreach($pagos as $p) { |
@@ -1139,11 +1170,13 @@ discard block |
||
1139 | 1170 | */ |
1140 | 1171 | private function num($n) |
1141 | 1172 | { |
1142 | - if (!is_numeric($n)) |
|
1143 | - return $n; |
|
1173 | + if (!is_numeric($n)) { |
|
1174 | + return $n; |
|
1175 | + } |
|
1144 | 1176 | $broken_number = explode('.', (string)$n); |
1145 | - if (isset($broken_number[1])) |
|
1146 | - return number_format($broken_number[0], 0, ',', '.').','.$broken_number[1]; |
|
1177 | + if (isset($broken_number[1])) { |
|
1178 | + return number_format($broken_number[0], 0, ',', '.').','.$broken_number[1]; |
|
1179 | + } |
|
1147 | 1180 | return number_format($broken_number[0], 0, ',', '.'); |
1148 | 1181 | } |
1149 | 1182 |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | /** |
174 | 174 | * Método que asigna la ubicación del logo de la empresa |
175 | 175 | * @param logo URI del logo (puede ser local o en una URL) |
176 | - * @param posicion Posición respecto a datos del emisor (=0 izq, =1 arriba) |
|
176 | + * @param posicion integer respecto a datos del emisor (=0 izq, =1 arriba) |
|
177 | 177 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
178 | 178 | * @version 2016-08-04 |
179 | 179 | */ |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * contínuo |
329 | 329 | * @param dte Arreglo con los datos del XML (tag Documento) |
330 | 330 | * @param timbre String XML con el tag TED del DTE |
331 | - * @param width Ancho del papel contínuo en mm |
|
331 | + * @param width boolean del papel contínuo en mm |
|
332 | 332 | * @author Pablo Reyes (https://github.com/pabloxp) |
333 | 333 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
334 | 334 | * @version 2017-06-15 |
@@ -401,10 +401,11 @@ discard block |
||
401 | 401 | * - Dirección casa central del emisor |
402 | 402 | * - Dirección sucursales |
403 | 403 | * @param emisor Arreglo con los datos del emisor (tag Emisor del XML) |
404 | - * @param x Posición horizontal de inicio en el PDF |
|
405 | - * @param y Posición vertical de inicio en el PDF |
|
406 | - * @param w Ancho de la información del emisor |
|
407 | - * @param w_img Ancho máximo de la imagen |
|
404 | + * @param x integer horizontal de inicio en el PDF |
|
405 | + * @param y integer vertical de inicio en el PDF |
|
406 | + * @param w integer de la información del emisor |
|
407 | + * @param w_img integer máximo de la imagen |
|
408 | + * @param integer $font_size |
|
408 | 409 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
409 | 410 | * @version 2016-12-02 |
410 | 411 | */ |
@@ -474,11 +475,13 @@ discard block |
||
474 | 475 | * @param rut RUT del emisor |
475 | 476 | * @param tipo Código o glosa del tipo de documento |
476 | 477 | * @param sucursal_sii Código o glosa de la sucursal del SII del Emisor |
477 | - * @param x Posición horizontal de inicio en el PDF |
|
478 | - * @param y Posición vertical de inicio en el PDF |
|
479 | - * @param w Ancho de la información del emisor |
|
478 | + * @param x integer horizontal de inicio en el PDF |
|
479 | + * @param y integer vertical de inicio en el PDF |
|
480 | + * @param w integer de la información del emisor |
|
481 | + * @param integer $font_size |
|
480 | 482 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
481 | 483 | * @version 2016-12-02 |
484 | + * @return integer |
|
482 | 485 | */ |
483 | 486 | private function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
484 | 487 | { |
@@ -524,7 +527,7 @@ discard block |
||
524 | 527 | * Método que agrega los datos de la emisión del DTE que no son los dato del |
525 | 528 | * receptor |
526 | 529 | * @param IdDoc Información general del documento |
527 | - * @param x Posición horizontal de inicio en el PDF |
|
530 | + * @param x integer horizontal de inicio en el PDF |
|
528 | 531 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
529 | 532 | * @version 2017-06-15 |
530 | 533 | */ |
@@ -612,7 +615,7 @@ discard block |
||
612 | 615 | /** |
613 | 616 | * Método que agrega los datos del receptor |
614 | 617 | * @param receptor Arreglo con los datos del receptor (tag Receptor del XML) |
615 | - * @param x Posición horizontal de inicio en el PDF |
|
618 | + * @param x integer horizontal de inicio en el PDF |
|
616 | 619 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
617 | 620 | * @version 2017-06-15 |
618 | 621 | */ |
@@ -692,7 +695,7 @@ discard block |
||
692 | 695 | * Método que agrega los datos del traslado |
693 | 696 | * @param IndTraslado |
694 | 697 | * @param Transporte |
695 | - * @param x Posición horizontal de inicio en el PDF |
|
698 | + * @param x integer horizontal de inicio en el PDF |
|
696 | 699 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
697 | 700 | * @version 2016-08-03 |
698 | 701 | */ |
@@ -763,7 +766,7 @@ discard block |
||
763 | 766 | /** |
764 | 767 | * Método que agrega las referencias del documento |
765 | 768 | * @param referencias Arreglo con las referencias del documento (tag Referencia del XML) |
766 | - * @param x Posición horizontal de inicio en el PDF |
|
769 | + * @param x integer horizontal de inicio en el PDF |
|
767 | 770 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
768 | 771 | * @version 2016-08-03 |
769 | 772 | */ |
@@ -786,7 +789,7 @@ discard block |
||
786 | 789 | /** |
787 | 790 | * Método que agrega el detalle del documento |
788 | 791 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
789 | - * @param x Posición horizontal de inicio en el PDF |
|
792 | + * @param x integer horizontal de inicio en el PDF |
|
790 | 793 | * @param y Posición vertical de inicio en el PDF |
791 | 794 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
792 | 795 | * @version 2016-08-05 |
@@ -853,7 +856,7 @@ discard block |
||
853 | 856 | /** |
854 | 857 | * Método que agrega el detalle del documento |
855 | 858 | * @param detalle Arreglo con el detalle del documento (tag Detalle del XML) |
856 | - * @param x Posición horizontal de inicio en el PDF |
|
859 | + * @param x integer horizontal de inicio en el PDF |
|
857 | 860 | * @param y Posición vertical de inicio en el PDF |
858 | 861 | * @author Pablo Reyes (https://github.com/pabloxp) |
859 | 862 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
@@ -889,7 +892,7 @@ discard block |
||
889 | 892 | * Método que agrega el subtotal del DTE |
890 | 893 | * @param detalle Arreglo con los detalles del documentos para poder |
891 | 894 | * calcular subtotal |
892 | - * @param x Posición horizontal de inicio en el PDF |
|
895 | + * @param x integer horizontal de inicio en el PDF |
|
893 | 896 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
894 | 897 | * @version 2016-08-17 |
895 | 898 | */ |
@@ -910,7 +913,7 @@ discard block |
||
910 | 913 | /** |
911 | 914 | * Método que agrega los descuentos y/o recargos globales del documento |
912 | 915 | * @param descuentosRecargos Arreglo con los descuentos y/o recargos del documento (tag DscRcgGlobal del XML) |
913 | - * @param x Posición horizontal de inicio en el PDF |
|
916 | + * @param x integer horizontal de inicio en el PDF |
|
914 | 917 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
915 | 918 | * @version 2016-08-17 |
916 | 919 | */ |
@@ -929,7 +932,7 @@ discard block |
||
929 | 932 | /** |
930 | 933 | * Método que agrega los pagos del documento |
931 | 934 | * @param pagos Arreglo con los pagos del documento |
932 | - * @param x Posición horizontal de inicio en el PDF |
|
935 | + * @param x integer horizontal de inicio en el PDF |
|
933 | 936 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
934 | 937 | * @version 2016-07-24 |
935 | 938 | */ |
@@ -1039,9 +1042,9 @@ discard block |
||
1039 | 1042 | * - Se imprime en el tamaño mínimo: 2x5 cms |
1040 | 1043 | * - En el lado de abajo con margen izquierdo mínimo de 2 cms |
1041 | 1044 | * @param timbre String con los datos del timbre |
1042 | - * @param x Posición horizontal de inicio en el PDF |
|
1043 | - * @param y Posición vertical de inicio en el PDF |
|
1044 | - * @param w Ancho del timbre |
|
1045 | + * @param x integer horizontal de inicio en el PDF |
|
1046 | + * @param y integer vertical de inicio en el PDF |
|
1047 | + * @param w integer del timbre |
|
1045 | 1048 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
1046 | 1049 | * @version 2016-12-02 |
1047 | 1050 | */ |
@@ -1072,10 +1075,10 @@ discard block |
||
1072 | 1075 | |
1073 | 1076 | /** |
1074 | 1077 | * Método que agrega el acuse de rebido |
1075 | - * @param x Posición horizontal de inicio en el PDF |
|
1076 | - * @param y Posición vertical de inicio en el PDF |
|
1077 | - * @param w Ancho del acuse de recibo |
|
1078 | - * @param h Alto del acuse de recibo |
|
1078 | + * @param x integer horizontal de inicio en el PDF |
|
1079 | + * @param y integer vertical de inicio en el PDF |
|
1080 | + * @param w integer del acuse de recibo |
|
1081 | + * @param h integer del acuse de recibo |
|
1079 | 1082 | * @author Esteban De La Fuente Rubio, DeLaF (esteban[at]sasco.cl) |
1080 | 1083 | * @version 2015-09-08 |
1081 | 1084 | */ |
@@ -1102,10 +1105,10 @@ discard block |
||
1102 | 1105 | |
1103 | 1106 | /** |
1104 | 1107 | * Método que agrega el acuse de rebido |
1105 | - * @param x Posición horizontal de inicio en el PDF |
|
1108 | + * @param x integer horizontal de inicio en el PDF |
|
1106 | 1109 | * @param y Posición vertical de inicio en el PDF |
1107 | - * @param w Ancho del acuse de recibo |
|
1108 | - * @param h Alto del acuse de recibo |
|
1110 | + * @param w integer del acuse de recibo |
|
1111 | + * @param h integer del acuse de recibo |
|
1109 | 1112 | * @author Pablo Reyes (https://github.com/pabloxp) |
1110 | 1113 | * @version 2015-11-17 |
1111 | 1114 | */ |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | { |
168 | 168 | parent::__construct(); |
169 | 169 | $this->SetTitle('Documento Tributario Electrónico (DTE) de Chile by LibreDTE'); |
170 | - $this->papelContinuo = $papelContinuo === true ? 80 : $papelContinuo; |
|
170 | + $this->papelContinuo = $papelContinuo===true ? 80 : $papelContinuo; |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | /** |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $this->setY(max($y)); |
296 | 296 | $this->Ln(); |
297 | 297 | $y = []; |
298 | - $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null); |
|
298 | + $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null); |
|
299 | 299 | $y[] = $this->agregarReceptor($dte['Encabezado']); |
300 | 300 | $this->setY(max($y)); |
301 | 301 | $this->agregarTraslado( |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | // determinar alto de la página y agregarla |
343 | 343 | $height = 145; |
344 | 344 | $n_detalle = count($dte['Detalle']); |
345 | - if ($n_detalle>1) $height += $n_detalle*20; |
|
345 | + if ($n_detalle>1) $height += $n_detalle * 20; |
|
346 | 346 | if ($this->cedible) $height += 50; |
347 | 347 | $this->AddPage('P', [$height, $width]); |
348 | 348 | // agregar cabecera del documento |
@@ -351,15 +351,15 @@ discard block |
||
351 | 351 | $dte['Encabezado']['IdDoc']['TipoDTE'], |
352 | 352 | $dte['Encabezado']['IdDoc']['Folio'], |
353 | 353 | $dte['Encabezado']['Emisor']['CmnaOrigen'], |
354 | - $x_start, $y_start, $width-($x_start*4), 10, |
|
355 | - [0,0,0] |
|
354 | + $x_start, $y_start, $width-($x_start * 4), 10, |
|
355 | + [0, 0, 0] |
|
356 | 356 | ); |
357 | - $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, 40, 8, 9, [0,0,0]); |
|
357 | + $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, 40, 8, 9, [0, 0, 0]); |
|
358 | 358 | // datos del documento |
359 | 359 | $this->SetY($y); |
360 | 360 | $this->Ln(); |
361 | 361 | $this->setFont('', '', 8); |
362 | - $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null, $x_start, $offset, false); |
|
362 | + $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null, $x_start, $offset, false); |
|
363 | 363 | $this->agregarReceptor($dte['Encabezado'], $x_start, $offset); |
364 | 364 | $this->agregarTraslado( |
365 | 365 | !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null, |
@@ -416,13 +416,13 @@ discard block |
||
416 | 416 | $this->logo['uri'], |
417 | 417 | $x, |
418 | 418 | $y, |
419 | - !$this->logo['posicion']?$w_img:null, $this->logo['posicion']?($w_img/2):null, |
|
419 | + !$this->logo['posicion'] ? $w_img : null, $this->logo['posicion'] ? ($w_img / 2) : null, |
|
420 | 420 | 'PNG', |
421 | - (isset($emisor['url'])?$emisor['url']:''), |
|
421 | + (isset($emisor['url']) ? $emisor['url'] : ''), |
|
422 | 422 | 'T' |
423 | 423 | ); |
424 | 424 | if ($this->logo['posicion']) { |
425 | - $this->SetY($this->y + ($w_img/2)); |
|
425 | + $this->SetY($this->y+($w_img / 2)); |
|
426 | 426 | $w += 40; |
427 | 427 | } else { |
428 | 428 | $x = $this->x+3; |
@@ -433,13 +433,13 @@ discard block |
||
433 | 433 | } |
434 | 434 | // agregar datos del emisor |
435 | 435 | $this->setFont('', 'B', $font_size ? $font_size : 14); |
436 | - $this->SetTextColorArray($color===null?[32, 92, 144]:$color); |
|
436 | + $this->SetTextColorArray($color===null ? [32, 92, 144] : $color); |
|
437 | 437 | $this->MultiTexto(!empty($emisor['RznSoc']) ? $emisor['RznSoc'] : $emisor['RznSocEmisor'], $x, $this->y+2, 'L', $w); |
438 | 438 | $this->setFont('', 'B', $font_size ? $font_size : 9); |
439 | - $this->SetTextColorArray([0,0,0]); |
|
439 | + $this->SetTextColorArray([0, 0, 0]); |
|
440 | 440 | $this->MultiTexto(!empty($emisor['GiroEmis']) ? $emisor['GiroEmis'] : $emisor['GiroEmisor'], $x, $this->y, 'L', $w); |
441 | 441 | $ciudad = !empty($emisor['CiudadOrigen']) ? $emisor['CiudadOrigen'] : \sasco\LibreDTE\Chile::getCiudad($emisor['CmnaOrigen']); |
442 | - $this->MultiTexto($emisor['DirOrigen'].', '.$emisor['CmnaOrigen'].($ciudad?(', '.$ciudad):''), $x, $this->y, 'L', $w); |
|
442 | + $this->MultiTexto($emisor['DirOrigen'].', '.$emisor['CmnaOrigen'].($ciudad ? (', '.$ciudad) : ''), $x, $this->y, 'L', $w); |
|
443 | 443 | if (!empty($emisor['Sucursal'])) { |
444 | 444 | $this->MultiTexto('Sucursal: '.$emisor['Sucursal'], $x, $this->y, 'L', $w); |
445 | 445 | } |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | private function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
484 | 484 | { |
485 | 485 | if ($color===null) { |
486 | - $color = $tipo ? ($tipo==52 ? [0,172,140] : [255,0,0]) : [0,0,0]; |
|
486 | + $color = $tipo ? ($tipo==52 ? [0, 172, 140] : [255, 0, 0]) : [0, 0, 0]; |
|
487 | 487 | } |
488 | 488 | $this->SetTextColorArray($color); |
489 | 489 | // colocar rut emisor, glosa documento y folio |
490 | 490 | list($rut, $dv) = explode('-', $rut); |
491 | - $this->setFont ('', 'B', $font_size ? $font_size : 15); |
|
491 | + $this->setFont('', 'B', $font_size ? $font_size : 15); |
|
492 | 492 | $this->MultiTexto('R.U.T.: '.$this->num($rut).'-'.$dv, $x, $y+4, 'C', $w); |
493 | 493 | $this->setFont('', 'B', $font_size ? $font_size : 12); |
494 | 494 | $this->MultiTexto($this->getTipo($tipo), $x, null, 'C', $w); |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | if ($tipo) { |
502 | 502 | $this->Texto('S.I.I. - '.\sasco\LibreDTE\Sii::getDireccionRegional($sucursal_sii), $x, $this->getY()+4, 'C', $w); |
503 | 503 | } |
504 | - $this->SetTextColorArray([0,0,0]); |
|
504 | + $this->SetTextColorArray([0, 0, 0]); |
|
505 | 505 | $this->Ln(); |
506 | 506 | return $this->y; |
507 | 507 | } |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | $this->Texto('Señor(es)', $x); |
633 | 633 | $this->Texto(':', $x+$offset); |
634 | 634 | $this->setFont('', '', null); |
635 | - $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
635 | + $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
636 | 636 | } |
637 | 637 | if (!empty($receptor['GiroRecep'])) { |
638 | 638 | $this->setFont('', 'B', null); |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | $ciudad = !empty($receptor['CiudadRecep']) ? $receptor['CiudadRecep'] : ( |
650 | 650 | !empty($receptor['CmnaRecep']) ? \sasco\LibreDTE\Chile::getCiudad($receptor['CmnaRecep']) : '' |
651 | 651 | ); |
652 | - $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep'])?(', '.$receptor['CmnaRecep']):'').($ciudad?(', '.$ciudad):''), $x+$offset+2); |
|
652 | + $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep']) ? (', '.$receptor['CmnaRecep']) : '').($ciudad ? (', '.$ciudad) : ''), $x+$offset+2); |
|
653 | 653 | } |
654 | 654 | if (!empty($receptor['Extranjero']['Nacionalidad'])) { |
655 | 655 | $this->setFont('', 'B', null); |
@@ -683,7 +683,7 @@ discard block |
||
683 | 683 | $this->Texto('Cód. recep.', $x); |
684 | 684 | $this->Texto(':', $x+$offset); |
685 | 685 | $this->setFont('', '', null); |
686 | - $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
686 | + $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
687 | 687 | } |
688 | 688 | return $this->GetY(); |
689 | 689 | } |
@@ -771,7 +771,7 @@ discard block |
||
771 | 771 | { |
772 | 772 | if (!isset($referencias[0])) |
773 | 773 | $referencias = [$referencias]; |
774 | - foreach($referencias as $r) { |
|
774 | + foreach ($referencias as $r) { |
|
775 | 775 | $texto = $r['NroLinRef'].' - '.$this->getTipo($r['TpoDocRef']).' N° '.$r['FolioRef'].' del '.$r['FchRef']; |
776 | 776 | if (isset($r['RazonRef']) and $r['RazonRef']!==false) |
777 | 777 | $texto = $texto.': '.$r['RazonRef']; |
@@ -864,9 +864,9 @@ discard block |
||
864 | 864 | $this->SetY($this->getY()+1); |
865 | 865 | $p1x = $x; |
866 | 866 | $p1y = $this->y; |
867 | - $p2x = $this->getPageWidth() - 2; |
|
868 | - $p2y = $p1y; // Use same y for a straight line |
|
869 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
867 | + $p2x = $this->getPageWidth()-2; |
|
868 | + $p2y = $p1y; // Use same y for a straight line |
|
869 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
870 | 870 | $this->Line($p1x, $p1y, $p2x, $p2y, $style); |
871 | 871 | $this->Texto($this->detalle_cols['NmbItem']['title'], $x+1, $this->y, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
872 | 872 | $this->Texto($this->detalle_cols['PrcItem']['title'], $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
@@ -876,9 +876,9 @@ discard block |
||
876 | 876 | if (!isset($detalle[0])) |
877 | 877 | $detalle = [$detalle]; |
878 | 878 | $this->SetY($this->getY()+2); |
879 | - foreach($detalle as &$d) { |
|
879 | + foreach ($detalle as &$d) { |
|
880 | 880 | $this->MultiTexto($d['NmbItem'], $x+1, $this->y+4, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
881 | - $this->Texto(number_format($d['PrcItem'],0,',','.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
881 | + $this->Texto(number_format($d['PrcItem'], 0, ',', '.'), $x+15, $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
|
882 | 882 | $this->Texto($this->num($d['QtyItem']), $x+35, $this->y, ucfirst($this->detalle_cols['QtyItem']['align'][0]), $this->detalle_cols['QtyItem']['width']); |
883 | 883 | $this->Texto($this->num($d['MontoItem']), $x+45, $this->y, ucfirst($this->detalle_cols['MontoItem']['align'][0]), $this->detalle_cols['MontoItem']['width']); |
884 | 884 | } |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | if (!isset($detalle[0])) { |
899 | 899 | $detalle = [$detalle]; |
900 | 900 | } |
901 | - foreach($detalle as &$d) { |
|
901 | + foreach ($detalle as &$d) { |
|
902 | 902 | if (!empty($d['MontoItem'])) { |
903 | 903 | $subtotal += $d['MontoItem']; |
904 | 904 | } |
@@ -918,10 +918,10 @@ discard block |
||
918 | 918 | { |
919 | 919 | if (!isset($descuentosRecargos[0])) |
920 | 920 | $descuentosRecargos = [$descuentosRecargos]; |
921 | - foreach($descuentosRecargos as $dr) { |
|
921 | + foreach ($descuentosRecargos as $dr) { |
|
922 | 922 | $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo'; |
923 | 923 | $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : '$'.$this->num($dr['ValorDR']).'.-'; |
924 | - $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):''), $x); |
|
924 | + $this->Texto($tipo.' global: '.$valor.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : ''), $x); |
|
925 | 925 | $this->Ln(); |
926 | 926 | } |
927 | 927 | } |
@@ -939,8 +939,8 @@ discard block |
||
939 | 939 | $pagos = [$pagos]; |
940 | 940 | $this->Texto('Pago(s) programado(s):', $x); |
941 | 941 | $this->Ln(); |
942 | - foreach($pagos as $p) { |
|
943 | - $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos'])?(' ('.$p['GlosaPagos'].')'):''), $x); |
|
942 | + foreach ($pagos as $p) { |
|
943 | + $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos']) ? (' ('.$p['GlosaPagos'].')') : ''), $x); |
|
944 | 944 | $this->Ln(); |
945 | 945 | } |
946 | 946 | } |
@@ -990,7 +990,7 @@ discard block |
||
990 | 990 | if (!isset($ImptoReten[0])) { |
991 | 991 | $ImptoReten = [$ImptoReten]; |
992 | 992 | } |
993 | - foreach($ImptoReten as $i) { |
|
993 | + foreach ($ImptoReten as $i) { |
|
994 | 994 | $totales['ImptoReten_'.$i['TipoImp']] = $i['MontoImp']; |
995 | 995 | if (!empty($i['TasaImp'])) { |
996 | 996 | $glosas['ImptoReten_'.$i['TipoImp']] = \sasco\LibreDTE\Sii\ImpuestosAdicionales::getGlosa($i['TipoImp']).' ('.$i['TasaImp'].'%) $'; |
@@ -1055,7 +1055,7 @@ discard block |
||
1055 | 1055 | 'vpadding' => 0, |
1056 | 1056 | 'module_width' => 1, // width of a single module in points |
1057 | 1057 | 'module_height' => 1, // height of a single module in points |
1058 | - 'fgcolor' => [0,0,0], |
|
1058 | + 'fgcolor' => [0, 0, 0], |
|
1059 | 1059 | 'bgcolor' => false, // [255,255,255] |
1060 | 1060 | 'position' => $this->papelContinuo ? 'C' : 'S', |
1061 | 1061 | ]; |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | */ |
1082 | 1082 | private function agregarAcuseRecibo($x = 93, $y = 190, $w = 50, $h = 40) |
1083 | 1083 | { |
1084 | - $this->SetTextColorArray([0,0,0]); |
|
1084 | + $this->SetTextColorArray([0, 0, 0]); |
|
1085 | 1085 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
1086 | 1086 | $this->setFont('', 'B', 10); |
1087 | 1087 | $this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1111,9 +1111,9 @@ discard block |
||
1111 | 1111 | */ |
1112 | 1112 | private function agregarAcuseReciboContinuo($x = 3, $y = null, $w = 68, $h = 40) |
1113 | 1113 | { |
1114 | - $this->SetTextColorArray([0,0,0]); |
|
1114 | + $this->SetTextColorArray([0, 0, 0]); |
|
1115 | 1115 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
1116 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
1116 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
1117 | 1117 | $this->Line($x, $y+22, $w+3, $y+22, $style); |
1118 | 1118 | //$this->setFont('', 'B', 10); |
1119 | 1119 | //$this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | private function agregarLeyendaDestino($tipo, $y = 254, $font_size = 10) |
1142 | 1142 | { |
1143 | 1143 | $this->setFont('', 'B', $font_size); |
1144 | - $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $y, 'R'); |
|
1144 | + $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $y, 'R'); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | /** |
@@ -1172,7 +1172,7 @@ discard block |
||
1172 | 1172 | $dias = ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado']; |
1173 | 1173 | $meses = ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre']; |
1174 | 1174 | $unixtime = strtotime($date); |
1175 | - $fecha = date(($mostrar_dia?'\D\I\A ':'').'j \d\e \M\E\S \d\e\l Y', $unixtime); |
|
1175 | + $fecha = date(($mostrar_dia ? '\D\I\A ' : '').'j \d\e \M\E\S \d\e\l Y', $unixtime); |
|
1176 | 1176 | $dia = $dias[date('w', $unixtime)]; |
1177 | 1177 | $mes = $meses[date('n', $unixtime)-1]; |
1178 | 1178 | return str_replace(array('DIA', 'MES'), array($dia, $mes), $fecha); |