@@ -168,8 +168,9 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | public function getName() |
| 170 | 170 | { |
| 171 | - if (isset($this->data['subject']['CN'])) |
|
| 172 | - return $this->data['subject']['CN']; |
|
| 171 | + if (isset($this->data['subject']['CN'])) { |
|
| 172 | + return $this->data['subject']['CN']; |
|
| 173 | + } |
|
| 173 | 174 | return $this->error('No fue posible obtener el Name (subject.CN) de la firma'); |
| 174 | 175 | } |
| 175 | 176 | |
@@ -353,8 +354,9 @@ discard block |
||
| 353 | 354 | */ |
| 354 | 355 | public function verify($data, $signature, $pub_key = null, $signature_alg = OPENSSL_ALGO_SHA1) |
| 355 | 356 | { |
| 356 | - if ($pub_key === null) |
|
| 357 | - $pub_key = $this->certs['cert']; |
|
| 357 | + if ($pub_key === null) { |
|
| 358 | + $pub_key = $this->certs['cert']; |
|
| 359 | + } |
|
| 358 | 360 | $pub_key = $this->normalizeCert($pub_key); |
| 359 | 361 | return openssl_verify($data, base64_decode($signature), $pub_key, $signature_alg) == 1 ? true : false; |
| 360 | 362 | } |
@@ -453,8 +455,9 @@ discard block |
||
| 453 | 455 | // calcular SignatureValue |
| 454 | 456 | $SignedInfo = $doc->saveHTML($Signature->getElementsByTagName('SignedInfo')->item(0)); |
| 455 | 457 | $firma = $this->sign($SignedInfo); |
| 456 | - if (!$firma) |
|
| 457 | - return false; |
|
| 458 | + if (!$firma) { |
|
| 459 | + return false; |
|
| 460 | + } |
|
| 458 | 461 | $signature = wordwrap($firma, $this->config['wordwrap'], "\n", true); |
| 459 | 462 | // reemplazar valores en la firma de |
| 460 | 463 | $Signature->getElementsByTagName('SignatureValue')->item(0)->nodeValue = $signature; |
@@ -486,8 +489,9 @@ discard block |
||
| 486 | 489 | $signature = $Signature->getElementsByTagName('SignatureValue')->item(0)->nodeValue; |
| 487 | 490 | $pub_key = $Signature->getElementsByTagName('X509Certificate')->item(0)->nodeValue; |
| 488 | 491 | // verificar firma |
| 489 | - if (!$this->verify($signed_info, $signature, $pub_key)) |
|
| 490 | - return false; |
|
| 492 | + if (!$this->verify($signed_info, $signature, $pub_key)) { |
|
| 493 | + return false; |
|
| 494 | + } |
|
| 491 | 495 | // verificar digest |
| 492 | 496 | $digest_original = $Signature->getElementsByTagName('DigestValue')->item(0)->nodeValue; |
| 493 | 497 | if ($tag) { |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | if (!$when) { |
| 263 | 263 | $when = date('Y-m-d').' 00:00:00'; |
| 264 | 264 | } |
| 265 | - return $this->getTo() > $when; |
|
| 265 | + return $this->getTo()>$when; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -378,10 +378,10 @@ discard block |
||
| 378 | 378 | */ |
| 379 | 379 | public function verify($data, $signature, $pub_key = null, $signature_alg = OPENSSL_ALGO_SHA1) |
| 380 | 380 | { |
| 381 | - if ($pub_key === null) |
|
| 381 | + if ($pub_key===null) |
|
| 382 | 382 | $pub_key = $this->certs['cert']; |
| 383 | 383 | $pub_key = $this->normalizeCert($pub_key); |
| 384 | - return openssl_verify($data, base64_decode($signature), $pub_key, $signature_alg) == 1 ? true : false; |
|
| 384 | + return openssl_verify($data, base64_decode($signature), $pub_key, $signature_alg)==1 ? true : false; |
|
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | /** |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | } else { |
| 521 | 521 | $digest_calculado = base64_encode(sha1($doc->C14N(), true)); |
| 522 | 522 | } |
| 523 | - return $digest_original == $digest_calculado; |
|
| 523 | + return $digest_original==$digest_calculado; |
|
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | /** |
@@ -184,11 +184,11 @@ discard block |
||
| 184 | 184 | { |
| 185 | 185 | // definir datos que se usarán en el envío |
| 186 | 186 | list($rutCompany, $dvCompany) = explode('-', str_replace('.', '', $empresa)); |
| 187 | - if (strpos($dte, '<?xml') === false) { |
|
| 188 | - $dte = '<?xml version="1.0" encoding="ISO-8859-1"?>' . "\n" . $dte; |
|
| 187 | + if (strpos($dte, '<?xml')===false) { |
|
| 188 | + $dte = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".$dte; |
|
| 189 | 189 | } |
| 190 | 190 | do { |
| 191 | - $file = sys_get_temp_dir() . '/aec_' . md5(microtime() . $token . $dte) . '.xml'; |
|
| 191 | + $file = sys_get_temp_dir().'/aec_'.md5(microtime().$token.$dte).'.xml'; |
|
| 192 | 192 | } while (file_exists($file)); |
| 193 | 193 | file_put_contents($file, $dte); |
| 194 | 194 | $data = [ |
@@ -228,17 +228,17 @@ discard block |
||
| 228 | 228 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
| 229 | 229 | } |
| 230 | 230 | // enviar XML al SII |
| 231 | - for ($i = 0; $i < $retry; $i++) { |
|
| 231 | + for ($i = 0; $i<$retry; $i++) { |
|
| 232 | 232 | $response = curl_exec($curl); |
| 233 | - if ($response and $response != 'Error 500') |
|
| 233 | + if ($response and $response!='Error 500') |
|
| 234 | 234 | break; |
| 235 | 235 | } |
| 236 | 236 | unlink($file); |
| 237 | 237 | // verificar respuesta del envío y entregar error en caso que haya uno |
| 238 | - if (!$response or $response == 'Error 500') { |
|
| 238 | + if (!$response or $response=='Error 500') { |
|
| 239 | 239 | if (!$response) |
| 240 | 240 | \sasco\LibreDTE\Log::write(\sasco\LibreDTE\Estado::ENVIO_ERROR_CURL, \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::ENVIO_ERROR_CURL, curl_error($curl))); |
| 241 | - if ($response == 'Error 500') |
|
| 241 | + if ($response=='Error 500') |
|
| 242 | 242 | \sasco\LibreDTE\Log::write(\sasco\LibreDTE\Estado::ENVIO_ERROR_500, \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::ENVIO_ERROR_500)); |
| 243 | 243 | return false; |
| 244 | 244 | } |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | 9 => 'Error Interno', |
| 271 | 271 | 10 => 'Error Interno' |
| 272 | 272 | ]; |
| 273 | - if ($xml->STATUS != 0) { |
|
| 273 | + if ($xml->STATUS!=0) { |
|
| 274 | 274 | \sasco\LibreDTE\Log::write( |
| 275 | 275 | $xml->STATUS, |
| 276 | 276 | $error[(int)$xml->STATUS] |
@@ -87,10 +87,12 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | public function generar() |
| 89 | 89 | { |
| 90 | - if (!isset($this->cedido) or !isset($this->cesiones[0])) |
|
| 91 | - return false; |
|
| 92 | - if (!isset($this->caratula)) |
|
| 93 | - $this->setCaratula(); |
|
| 90 | + if (!isset($this->cedido) or !isset($this->cesiones[0])) { |
|
| 91 | + return false; |
|
| 92 | + } |
|
| 93 | + if (!isset($this->caratula)) { |
|
| 94 | + $this->setCaratula(); |
|
| 95 | + } |
|
| 94 | 96 | // genear XML del envío |
| 95 | 97 | $xmlEnvio = (new \sasco\LibreDTE\XML())->generate([ |
| 96 | 98 | 'AEC' => [ |
@@ -137,8 +139,9 @@ discard block |
||
| 137 | 139 | public function enviar($retry = null, $gzip = false) |
| 138 | 140 | { |
| 139 | 141 | // generar XML que se enviará |
| 140 | - if (!$this->xml_data) |
|
| 141 | - $this->xml_data = $this->generar(); |
|
| 142 | + if (!$this->xml_data) { |
|
| 143 | + $this->xml_data = $this->generar(); |
|
| 144 | + } |
|
| 142 | 145 | if (!$this->xml_data) { |
| 143 | 146 | \sasco\LibreDTE\Log::write( |
| 144 | 147 | \sasco\LibreDTE\Estado::DOCUMENTO_ERROR_GENERAR_XML, |
@@ -150,20 +153,24 @@ discard block |
||
| 150 | 153 | return false; |
| 151 | 154 | } |
| 152 | 155 | // validar schema del documento antes de enviar |
| 153 | - if (!$this->schemaValidate()) |
|
| 154 | - return false; |
|
| 156 | + if (!$this->schemaValidate()) { |
|
| 157 | + return false; |
|
| 158 | + } |
|
| 155 | 159 | // solicitar token |
| 156 | 160 | $token = \sasco\LibreDTE\Sii\Autenticacion::getToken($this->Firma); |
| 157 | - if (!$token) |
|
| 158 | - return false; |
|
| 161 | + if (!$token) { |
|
| 162 | + return false; |
|
| 163 | + } |
|
| 159 | 164 | // enviar AEC |
| 160 | 165 | $email = $this->caratula['MailContacto']; |
| 161 | 166 | $emisor = $this->caratula['RutCedente']; |
| 162 | 167 | $result = $this->enviarRTC($email, $emisor, $this->xml_data, $token, 10); |
| 163 | - if ($result===false) |
|
| 164 | - return false; |
|
| 165 | - if (!is_numeric((string)$result->TRACKID)) |
|
| 166 | - return false; |
|
| 168 | + if ($result===false) { |
|
| 169 | + return false; |
|
| 170 | + } |
|
| 171 | + if (!is_numeric((string)$result->TRACKID)) { |
|
| 172 | + return false; |
|
| 173 | + } |
|
| 167 | 174 | return (int)(string)$result->TRACKID; |
| 168 | 175 | } |
| 169 | 176 | |
@@ -230,16 +237,19 @@ discard block |
||
| 230 | 237 | // enviar XML al SII |
| 231 | 238 | for ($i = 0; $i < $retry; $i++) { |
| 232 | 239 | $response = curl_exec($curl); |
| 233 | - if ($response and $response != 'Error 500') |
|
| 234 | - break; |
|
| 240 | + if ($response and $response != 'Error 500') { |
|
| 241 | + break; |
|
| 242 | + } |
|
| 235 | 243 | } |
| 236 | 244 | unlink($file); |
| 237 | 245 | // verificar respuesta del envío y entregar error en caso que haya uno |
| 238 | 246 | if (!$response or $response == 'Error 500') { |
| 239 | - if (!$response) |
|
| 240 | - \sasco\LibreDTE\Log::write(\sasco\LibreDTE\Estado::ENVIO_ERROR_CURL, \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::ENVIO_ERROR_CURL, curl_error($curl))); |
|
| 241 | - if ($response == 'Error 500') |
|
| 242 | - \sasco\LibreDTE\Log::write(\sasco\LibreDTE\Estado::ENVIO_ERROR_500, \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::ENVIO_ERROR_500)); |
|
| 247 | + if (!$response) { |
|
| 248 | + \sasco\LibreDTE\Log::write(\sasco\LibreDTE\Estado::ENVIO_ERROR_CURL, \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::ENVIO_ERROR_CURL, curl_error($curl))); |
|
| 249 | + } |
|
| 250 | + if ($response == 'Error 500') { |
|
| 251 | + \sasco\LibreDTE\Log::write(\sasco\LibreDTE\Estado::ENVIO_ERROR_500, \sasco\LibreDTE\Estado::get(\sasco\LibreDTE\Estado::ENVIO_ERROR_500)); |
|
| 252 | + } |
|
| 243 | 253 | return false; |
| 244 | 254 | } |
| 245 | 255 | // cerrar sesión curl |
@@ -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); |
@@ -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;'.$width_table.'">'; |
| 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(); |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | \sasco\LibreDTE\Log::write(Estado::REQUEST_ERROR_SOAP, Estado::get(Estado::REQUEST_ERROR_SOAP, $msg)); |
| 537 | 537 | return false; |
| 538 | 538 | } |
| 539 | - for ($i=0; $i<$retry; $i++) { |
|
| 539 | + for ($i = 0; $i<$retry; $i++) { |
|
| 540 | 540 | try { |
| 541 | 541 | if ($args) { |
| 542 | 542 | $body = call_user_func_array([$soap, $request], $args); |
@@ -605,7 +605,7 @@ discard block |
||
| 605 | 605 | $dte = '<?xml version="1.0" encoding="ISO-8859-1"?>'."\n".$dte; |
| 606 | 606 | } |
| 607 | 607 | do { |
| 608 | - $file = sys_get_temp_dir().'/dte_'.md5(microtime().$token.$dte).'.'.($gzip?'gz':'xml'); |
|
| 608 | + $file = sys_get_temp_dir().'/dte_'.md5(microtime().$token.$dte).'.'.($gzip ? 'gz' : 'xml'); |
|
| 609 | 609 | } while (file_exists($file)); |
| 610 | 610 | if ($gzip) { |
| 611 | 611 | $dte = gzencode($dte); |
@@ -654,7 +654,7 @@ discard block |
||
| 654 | 654 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); |
| 655 | 655 | } |
| 656 | 656 | // enviar XML al SII |
| 657 | - for ($i=0; $i<$retry; $i++) { |
|
| 657 | + for ($i = 0; $i<$retry; $i++) { |
|
| 658 | 658 | $response = curl_exec($curl); |
| 659 | 659 | if ($response and $response!='Error 500') { |
| 660 | 660 | break; |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | if ($xml->STATUS!=0) { |
| 684 | 684 | \sasco\LibreDTE\Log::write( |
| 685 | 685 | $xml->STATUS, |
| 686 | - Estado::get($xml->STATUS).(isset($xml->DETAIL)?'. '.implode("\n", (array)$xml->DETAIL->ERROR):'') |
|
| 686 | + Estado::get($xml->STATUS).(isset($xml->DETAIL) ? '. '.implode("\n", (array)$xml->DETAIL->ERROR) : '') |
|
| 687 | 687 | ); |
| 688 | 688 | } |
| 689 | 689 | return $xml; |
@@ -476,8 +476,9 @@ discard block |
||
| 476 | 476 | // entregar WSDL local (modificados para ambiente de certificación) |
| 477 | 477 | if ($ambiente==self::CERTIFICACION) { |
| 478 | 478 | $wsdl = dirname(dirname(__FILE__)).'/wsdl/'.self::$config['servidor'][$ambiente].'/'.$servicio.'.jws'; |
| 479 | - if (is_readable($wsdl)) |
|
| 480 | - return $wsdl; |
|
| 479 | + if (is_readable($wsdl)) { |
|
| 480 | + return $wsdl; |
|
| 481 | + } |
|
| 481 | 482 | } |
| 482 | 483 | // entregar WSDL oficial desde SII |
| 483 | 484 | $location = isset(self::$config['wsdl'][$servicio]) ? self::$config['wsdl'][$servicio] : self::$config['wsdl']['*']; |
@@ -748,10 +749,11 @@ discard block |
||
| 748 | 749 | public static function getAmbiente($ambiente = null) |
| 749 | 750 | { |
| 750 | 751 | if ($ambiente===null) { |
| 751 | - if (defined('_LibreDTE_CERTIFICACION_')) |
|
| 752 | - $ambiente = (int)_LibreDTE_CERTIFICACION_; |
|
| 753 | - else |
|
| 754 | - $ambiente = self::$ambiente; |
|
| 752 | + if (defined('_LibreDTE_CERTIFICACION_')) { |
|
| 753 | + $ambiente = (int)_LibreDTE_CERTIFICACION_; |
|
| 754 | + } else { |
|
| 755 | + $ambiente = self::$ambiente; |
|
| 756 | + } |
|
| 755 | 757 | } |
| 756 | 758 | return $ambiente; |
| 757 | 759 | } |
@@ -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 | // |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | 'RutEnvia' => $Dte->getEmisor(), |
| 240 | 240 | 'RutReceptor' => $Dte->getReceptor(), |
| 241 | 241 | 'FchResol' => date('Y-m-d'), |
| 242 | - 'NroResol' => ($Dte->getCertificacion()?'0':'').'9999', |
|
| 242 | + 'NroResol' => ($Dte->getCertificacion() ? '0' : '').'9999', |
|
| 243 | 243 | ]); |
| 244 | 244 | // cargar nuevo XML con datos completos |
| 245 | 245 | if (!parent::loadXML($this->generar())) { |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | { |
| 321 | 321 | $fecha = '9999-12-31'; |
| 322 | 322 | foreach ($this->getDocumentos() as $Dte) { |
| 323 | - if ($Dte->getFechaEmision() < $fecha) |
|
| 323 | + if ($Dte->getFechaEmision()<$fecha) |
|
| 324 | 324 | $fecha = $Dte->getFechaEmision(); |
| 325 | 325 | } |
| 326 | 326 | return $fecha; |
@@ -335,7 +335,7 @@ discard block |
||
| 335 | 335 | { |
| 336 | 336 | $fecha = '0000-01-01'; |
| 337 | 337 | foreach ($this->getDocumentos() as $Dte) { |
| 338 | - if ($Dte->getFechaEmision() > $fecha) |
|
| 338 | + if ($Dte->getFechaEmision()>$fecha) |
|
| 339 | 339 | $fecha = $Dte->getFechaEmision(); |
| 340 | 340 | } |
| 341 | 341 | return $fecha; |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | $e = substr($e, 0, -2); |
| 395 | 395 | $d = (int)$nodo_dte->getElementsByTagName('TipoDTE')->item(0)->nodeValue; |
| 396 | 396 | $f = (int)$nodo_dte->getElementsByTagName('Folio')->item(0)->nodeValue; |
| 397 | - if ($folio == $f and $dte == $d and $emisor == $e) { |
|
| 397 | + if ($folio==$f and $dte==$d and $emisor==$e) { |
|
| 398 | 398 | return new Dte($nodo_dte->C14N(), false); // cargar DTE sin normalizar |
| 399 | 399 | } |
| 400 | 400 | } |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $SignatureValue = trim(str_replace(["\n", ' ', "\t"], '', $Signatures->item($Signatures->length-1)->getElementsByTagName('SignatureValue')->item(0)->nodeValue)); |
| 453 | 453 | $X509Certificate = trim(str_replace(["\n", ' ', "\t"], '', $Signatures->item($Signatures->length-1)->getElementsByTagName('X509Certificate')->item(0)->nodeValue)); |
| 454 | 454 | $X509Certificate = '-----BEGIN CERTIFICATE-----'."\n".wordwrap($X509Certificate, 64, "\n", true)."\n".'-----END CERTIFICATE-----'; |
| 455 | - $valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate) === 1 ? true : false; |
|
| 455 | + $valid = openssl_verify($SignedInfo->C14N(), base64_decode($SignatureValue), $X509Certificate)===1 ? true : false; |
|
| 456 | 456 | return $valid and $DigestValue===base64_encode(sha1($SetDTE, true)); |
| 457 | 457 | } |
| 458 | 458 | |
@@ -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 { |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | { |
| 127 | 127 | $fecha = '9999-12-31'; |
| 128 | 128 | foreach ($this->detalles as &$d) { |
| 129 | - if ($d['FchDoc'] < $fecha) { |
|
| 129 | + if ($d['FchDoc']<$fecha) { |
|
| 130 | 130 | $fecha = $d['FchDoc']; |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | { |
| 144 | 144 | $fecha = '0000-01-01'; |
| 145 | 145 | foreach ($this->detalles as &$d) { |
| 146 | - if ($d['FchDoc'] > $fecha) { |
|
| 146 | + if ($d['FchDoc']>$fecha) { |
|
| 147 | 147 | $fecha = $d['FchDoc']; |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | // ajustes post agregar detalles |
| 203 | 203 | foreach ($Resumen as &$r) { |
| 204 | 204 | // obtener folios utilizados = emitidos + anulados |
| 205 | - $r['FoliosUtilizados'] = $r['FoliosEmitidos'] + $r['FoliosAnulados']; |
|
| 205 | + $r['FoliosUtilizados'] = $r['FoliosEmitidos']+$r['FoliosAnulados']; |
|
| 206 | 206 | $r['RangoUtilizados'] = $this->getRangos($RangoUtilizados[$r['TipoDocumento']]); |
| 207 | 207 | } |
| 208 | 208 | // completar con los resumenes que no se colocaron |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | $aux = []; |
| 235 | 235 | $inicial = $folios[0]; |
| 236 | 236 | $i = $inicial; |
| 237 | - foreach($folios as $f) { |
|
| 237 | + foreach ($folios as $f) { |
|
| 238 | 238 | if ($i!=$f) { |
| 239 | 239 | $inicial = $f; |
| 240 | 240 | $i = $inicial; |
@@ -770,10 +770,12 @@ discard block |
||
| 770 | 770 | $this->MultiTexto($receptor['Extranjero']['NumId'], $x+$offset+2); |
| 771 | 771 | } |
| 772 | 772 | $contacto = []; |
| 773 | - if (!empty($receptor['Contacto'])) |
|
| 774 | - $contacto[] = $receptor['Contacto']; |
|
| 775 | - if (!empty($receptor['CorreoRecep'])) |
|
| 776 | - $contacto[] = $receptor['CorreoRecep']; |
|
| 773 | + if (!empty($receptor['Contacto'])) { |
|
| 774 | + $contacto[] = $receptor['Contacto']; |
|
| 775 | + } |
|
| 776 | + if (!empty($receptor['CorreoRecep'])) { |
|
| 777 | + $contacto[] = $receptor['CorreoRecep']; |
|
| 778 | + } |
|
| 777 | 779 | if (!empty($contacto)) { |
| 778 | 780 | $this->setFont('', 'B', null); |
| 779 | 781 | $this->Texto('Contacto', $x); |
@@ -823,10 +825,12 @@ discard block |
||
| 823 | 825 | if (!empty($Transporte['DirDest']) and !empty($Transporte['CmnaDest'])) { |
| 824 | 826 | $transporte .= 'a '.$Transporte['DirDest'].', '.$Transporte['CmnaDest']; |
| 825 | 827 | } |
| 826 | - if (!empty($Transporte['RUTTrans'])) |
|
| 827 | - $transporte .= ' por '.$Transporte['RUTTrans']; |
|
| 828 | - if (!empty($Transporte['Patente'])) |
|
| 829 | - $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
| 828 | + if (!empty($Transporte['RUTTrans'])) { |
|
| 829 | + $transporte .= ' por '.$Transporte['RUTTrans']; |
|
| 830 | + } |
|
| 831 | + if (!empty($Transporte['Patente'])) { |
|
| 832 | + $transporte .= ' en vehículo '.$Transporte['Patente']; |
|
| 833 | + } |
|
| 830 | 834 | if (isset($Transporte['Chofer']) and is_array($Transporte['Chofer'])) { |
| 831 | 835 | if (!empty($Transporte['Chofer']['NombreChofer'])) { |
| 832 | 836 | $transporte .= ' con chofer '.$Transporte['Chofer']['NombreChofer']; |
@@ -889,8 +893,9 @@ discard block |
||
| 889 | 893 | */ |
| 890 | 894 | protected function agregarReferencia($referencias, $x = 10, $offset = 22) |
| 891 | 895 | { |
| 892 | - if (!isset($referencias[0])) |
|
| 893 | - $referencias = [$referencias]; |
|
| 896 | + if (!isset($referencias[0])) { |
|
| 897 | + $referencias = [$referencias]; |
|
| 898 | + } |
|
| 894 | 899 | foreach($referencias as $r) { |
| 895 | 900 | $texto = $r['NroLinRef'].' - '; |
| 896 | 901 | if (!empty($r['TpoDocRef'])) { |
@@ -1124,8 +1129,9 @@ discard block |
||
| 1124 | 1129 | */ |
| 1125 | 1130 | protected function agregarPagos(array $pagos, $x = 10) |
| 1126 | 1131 | { |
| 1127 | - if (!isset($pagos[0])) |
|
| 1128 | - $pagos = [$pagos]; |
|
| 1132 | + if (!isset($pagos[0])) { |
|
| 1133 | + $pagos = [$pagos]; |
|
| 1134 | + } |
|
| 1129 | 1135 | $this->Texto('Pago(s) programado(s):', $x); |
| 1130 | 1136 | $this->Ln(); |
| 1131 | 1137 | foreach($pagos as $p) { |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | { |
| 75 | 75 | parent::__construct(); |
| 76 | 76 | $this->SetTitle('Documento Tributario Electrónico (DTE) de Chile by LibreDTE'); |
| 77 | - $this->papelContinuo = $papelContinuo === true ? 80 : $papelContinuo; |
|
| 77 | + $this->papelContinuo = $papelContinuo===true ? 80 : $papelContinuo; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $this->Ln(); |
| 194 | 194 | // datos del documento |
| 195 | 195 | $y = []; |
| 196 | - $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null); |
|
| 196 | + $y[] = $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null); |
|
| 197 | 197 | $y[] = $this->agregarReceptor($dte['Encabezado']); |
| 198 | 198 | $this->setY(max($y)); |
| 199 | 199 | $this->agregarTraslado( |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $this->AddPage('P', [$height ? $height : $this->papel_continuo_alto, $width]); |
| 243 | 243 | $x = 1; |
| 244 | 244 | $y = 5; |
| 245 | - $this->SetXY($x,$y); |
|
| 245 | + $this->SetXY($x, $y); |
|
| 246 | 246 | // agregar datos del documento |
| 247 | 247 | $this->setFont('', '', 8); |
| 248 | 248 | $this->MultiTexto(!empty($dte['Encabezado']['Emisor']['RznSoc']) ? $dte['Encabezado']['Emisor']['RznSoc'] : $dte['Encabezado']['Emisor']['RznSocEmisor'], $x, null, '', $width-2); |
@@ -354,15 +354,15 @@ discard block |
||
| 354 | 354 | $dte['Encabezado']['IdDoc']['TipoDTE'], |
| 355 | 355 | $dte['Encabezado']['IdDoc']['Folio'], |
| 356 | 356 | isset($dte['Encabezado']['Emisor']['CmnaOrigen']) ? $dte['Encabezado']['Emisor']['CmnaOrigen'] : 'Sin comuna', // siempre debería tener comuna |
| 357 | - $x_start, $y_start, $width-($x_start*4), 10, |
|
| 358 | - [0,0,0] |
|
| 357 | + $x_start, $y_start, $width-($x_start * 4), 10, |
|
| 358 | + [0, 0, 0] |
|
| 359 | 359 | ); |
| 360 | - $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, $width-($x_start*45), 8, 9, [0,0,0]); |
|
| 360 | + $y = $this->agregarEmisor($dte['Encabezado']['Emisor'], $x_start, $y+2, $width-($x_start * 45), 8, 9, [0, 0, 0]); |
|
| 361 | 361 | // datos del documento |
| 362 | 362 | $this->SetY($y); |
| 363 | 363 | $this->Ln(); |
| 364 | 364 | $this->setFont('', '', 8); |
| 365 | - $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null, $x_start, $offset, false); |
|
| 365 | + $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null, $x_start, $offset, false); |
|
| 366 | 366 | $this->agregarReceptor($dte['Encabezado'], $x_start, $offset); |
| 367 | 367 | $this->agregarTraslado( |
| 368 | 368 | !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null, |
@@ -433,14 +433,14 @@ discard block |
||
| 433 | 433 | 2, |
| 434 | 434 | 45, |
| 435 | 435 | 9, |
| 436 | - [0,0,0] |
|
| 436 | + [0, 0, 0] |
|
| 437 | 437 | ); |
| 438 | - $y[] = $this->agregarEmisor($dte['Encabezado']['Emisor'], 1, 2, 20, 30, 9, [0,0,0], $y[0]); |
|
| 438 | + $y[] = $this->agregarEmisor($dte['Encabezado']['Emisor'], 1, 2, 20, 30, 9, [0, 0, 0], $y[0]); |
|
| 439 | 439 | $this->SetY(max($y)); |
| 440 | 440 | $this->Ln(); |
| 441 | 441 | // datos del documento |
| 442 | 442 | $this->setFont('', '', 8); |
| 443 | - $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor'])?$dte['Encabezado']['Emisor']['CdgVendedor']:null, $x_start, $offset, false); |
|
| 443 | + $this->agregarDatosEmision($dte['Encabezado']['IdDoc'], !empty($dte['Encabezado']['Emisor']['CdgVendedor']) ? $dte['Encabezado']['Emisor']['CdgVendedor'] : null, $x_start, $offset, false); |
|
| 444 | 444 | $this->agregarReceptor($dte['Encabezado'], $x_start, $offset); |
| 445 | 445 | $this->agregarTraslado( |
| 446 | 446 | !empty($dte['Encabezado']['IdDoc']['IndTraslado']) ? $dte['Encabezado']['IdDoc']['IndTraslado'] : null, |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | if ($this->cedible and !in_array($dte['Encabezado']['IdDoc']['TipoDTE'], $this->sinAcuseRecibo)) { |
| 474 | 474 | $this->agregarAcuseRecibo(63, $y+6, 45, 40, 15); |
| 475 | 475 | $this->setFont('', 'B', 8); |
| 476 | - $this->Texto('CEDIBLE'.($dte['Encabezado']['IdDoc']['TipoDTE']==52?' CON SU FACTURA':''), $x_start, $this->y+1, 'L'); |
|
| 476 | + $this->Texto('CEDIBLE'.($dte['Encabezado']['IdDoc']['TipoDTE']==52 ? ' CON SU FACTURA' : ''), $x_start, $this->y+1, 'L'); |
|
| 477 | 477 | } |
| 478 | 478 | // si el alto no se pasó, entonces es con autocálculo, se elimina esta página y se pasa el alto |
| 479 | 479 | // que se logró determinar para crear la página con el alto correcto |
@@ -504,16 +504,16 @@ discard block |
||
| 504 | 504 | // logo del documento |
| 505 | 505 | if (isset($this->logo)) { |
| 506 | 506 | // logo centrado (papel continuo) |
| 507 | - if (!empty($this->logo['posicion']) and $this->logo['posicion'] == 'C') { |
|
| 507 | + if (!empty($this->logo['posicion']) and $this->logo['posicion']=='C') { |
|
| 508 | 508 | $logo_w = null; |
| 509 | 509 | $logo_y = null; |
| 510 | 510 | $logo_position = 'C'; |
| 511 | 511 | $logo_next_pointer = 'N'; |
| 512 | 512 | } |
| 513 | 513 | // logo a la derecha (posicion=0) o arriba (posicion=1) |
| 514 | - else if (empty($this->logo['posicion']) or $this->logo['posicion'] == 1) { |
|
| 514 | + else if (empty($this->logo['posicion']) or $this->logo['posicion']==1) { |
|
| 515 | 515 | $logo_w = !$this->logo['posicion'] ? $w_img : null; |
| 516 | - $logo_y = $this->logo['posicion'] ? $w_img/2 : null; |
|
| 516 | + $logo_y = $this->logo['posicion'] ? $w_img / 2 : null; |
|
| 517 | 517 | $logo_position = ''; |
| 518 | 518 | $logo_next_pointer = 'T'; |
| 519 | 519 | } |
@@ -532,17 +532,17 @@ discard block |
||
| 532 | 532 | $logo_w, |
| 533 | 533 | $logo_y, |
| 534 | 534 | 'PNG', |
| 535 | - (isset($emisor['url'])?$emisor['url']:''), |
|
| 535 | + (isset($emisor['url']) ? $emisor['url'] : ''), |
|
| 536 | 536 | $logo_next_pointer, |
| 537 | 537 | 2, |
| 538 | 538 | 300, |
| 539 | 539 | $logo_position |
| 540 | 540 | ); |
| 541 | - if (!empty($this->logo['posicion']) and $this->logo['posicion'] == 'C') { |
|
| 541 | + if (!empty($this->logo['posicion']) and $this->logo['posicion']=='C') { |
|
| 542 | 542 | $w += 40; |
| 543 | 543 | } else { |
| 544 | 544 | if ($this->logo['posicion']) { |
| 545 | - $this->SetY($this->y + ($w_img/2)); |
|
| 545 | + $this->SetY($this->y+($w_img / 2)); |
|
| 546 | 546 | $w += 40; |
| 547 | 547 | } else { |
| 548 | 548 | $x = $this->x+3; |
@@ -555,20 +555,20 @@ discard block |
||
| 555 | 555 | // agregar datos del emisor |
| 556 | 556 | if ($agregarDatosEmisor) { |
| 557 | 557 | $this->setFont('', 'B', $font_size ? $font_size : 14); |
| 558 | - $this->SetTextColorArray($color===null?[32, 92, 144]:$color); |
|
| 559 | - $this->MultiTexto(!empty($emisor['RznSoc']) ? $emisor['RznSoc'] : $emisor['RznSocEmisor'], $x, $this->y+2, 'L', ($h_folio and $h_folio < $this->getY()) ? $w_all : $w); |
|
| 558 | + $this->SetTextColorArray($color===null ? [32, 92, 144] : $color); |
|
| 559 | + $this->MultiTexto(!empty($emisor['RznSoc']) ? $emisor['RznSoc'] : $emisor['RznSocEmisor'], $x, $this->y+2, 'L', ($h_folio and $h_folio<$this->getY()) ? $w_all : $w); |
|
| 560 | 560 | $this->setFont('', 'B', $font_size ? $font_size : 9); |
| 561 | - $this->SetTextColorArray([0,0,0]); |
|
| 562 | - $this->MultiTexto(!empty($emisor['GiroEmis']) ? $emisor['GiroEmis'] : $emisor['GiroEmisor'], $x, $this->y, 'L', ($h_folio and $h_folio < $this->getY()) ? $w_all : $w); |
|
| 561 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 562 | + $this->MultiTexto(!empty($emisor['GiroEmis']) ? $emisor['GiroEmis'] : $emisor['GiroEmisor'], $x, $this->y, 'L', ($h_folio and $h_folio<$this->getY()) ? $w_all : $w); |
|
| 563 | 563 | $direccion = !empty($emisor['DirOrigen']) ? $emisor['DirOrigen'] : null; |
| 564 | 564 | $comuna = !empty($emisor['CmnaOrigen']) ? $emisor['CmnaOrigen'] : null; |
| 565 | 565 | $ciudad = !empty($emisor['CiudadOrigen']) ? $emisor['CiudadOrigen'] : \sasco\LibreDTE\Chile::getCiudad($comuna); |
| 566 | - $this->MultiTexto($direccion.($comuna?(', '.$comuna):'').($ciudad?(', '.$ciudad):''), $x, $this->y, 'L', ($h_folio and $h_folio < $this->getY()) ? $w_all : $w); |
|
| 566 | + $this->MultiTexto($direccion.($comuna ? (', '.$comuna) : '').($ciudad ? (', '.$ciudad) : ''), $x, $this->y, 'L', ($h_folio and $h_folio<$this->getY()) ? $w_all : $w); |
|
| 567 | 567 | if (!empty($emisor['Sucursal'])) { |
| 568 | - $this->MultiTexto('Sucursal: '.$emisor['Sucursal'], $x, $this->y, 'L', ($h_folio and $h_folio < $this->getY()) ? $w_all : $w); |
|
| 568 | + $this->MultiTexto('Sucursal: '.$emisor['Sucursal'], $x, $this->y, 'L', ($h_folio and $h_folio<$this->getY()) ? $w_all : $w); |
|
| 569 | 569 | } |
| 570 | 570 | if (!empty($this->casa_matriz)) { |
| 571 | - $this->MultiTexto('Casa matriz: '.$this->casa_matriz, $x, $this->y, 'L', ($h_folio and $h_folio < $this->getY()) ? $w_all : $w); |
|
| 571 | + $this->MultiTexto('Casa matriz: '.$this->casa_matriz, $x, $this->y, 'L', ($h_folio and $h_folio<$this->getY()) ? $w_all : $w); |
|
| 572 | 572 | } |
| 573 | 573 | $contacto = []; |
| 574 | 574 | if (!empty($emisor['Telefono'])) { |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | $contacto[] = $emisor['CorreoEmisor']; |
| 584 | 584 | } |
| 585 | 585 | if ($contacto) { |
| 586 | - $this->MultiTexto(implode(' / ', $contacto), $x, $this->y, 'L', ($h_folio and $h_folio < $this->getY()) ? $w_all : $w); |
|
| 586 | + $this->MultiTexto(implode(' / ', $contacto), $x, $this->y, 'L', ($h_folio and $h_folio<$this->getY()) ? $w_all : $w); |
|
| 587 | 587 | } |
| 588 | 588 | } |
| 589 | 589 | return $this->y; |
@@ -613,12 +613,12 @@ discard block |
||
| 613 | 613 | protected function agregarFolio($rut, $tipo, $folio, $sucursal_sii = null, $x = 130, $y = 15, $w = 70, $font_size = null, array $color = null) |
| 614 | 614 | { |
| 615 | 615 | if ($color===null) { |
| 616 | - $color = $tipo ? ($tipo==52 ? [0,172,140] : [255,0,0]) : [0,0,0]; |
|
| 616 | + $color = $tipo ? ($tipo==52 ? [0, 172, 140] : [255, 0, 0]) : [0, 0, 0]; |
|
| 617 | 617 | } |
| 618 | 618 | $this->SetTextColorArray($color); |
| 619 | 619 | // colocar rut emisor, glosa documento y folio |
| 620 | 620 | list($rut, $dv) = explode('-', $rut); |
| 621 | - $this->setFont ('', 'B', $font_size ? $font_size : 15); |
|
| 621 | + $this->setFont('', 'B', $font_size ? $font_size : 15); |
|
| 622 | 622 | $this->MultiTexto('R.U.T.: '.$this->num($rut).'-'.$dv, $x, $y+4, 'C', $w); |
| 623 | 623 | $this->setFont('', 'B', $font_size ? $font_size : 12); |
| 624 | 624 | $this->MultiTexto($this->getTipo($tipo, $folio), $x, null, 'C', $w); |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | if ($tipo) { |
| 632 | 632 | $this->Texto('S.I.I. - '.\sasco\LibreDTE\Sii::getDireccionRegional($sucursal_sii), $x, $this->getY()+4, 'C', $w); |
| 633 | 633 | } |
| 634 | - $this->SetTextColorArray([0,0,0]); |
|
| 634 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 635 | 635 | $this->Ln(); |
| 636 | 636 | return $this->y; |
| 637 | 637 | } |
@@ -745,10 +745,10 @@ discard block |
||
| 745 | 745 | } |
| 746 | 746 | if (!empty($receptor['RznSocRecep'])) { |
| 747 | 747 | $this->setFont('', 'B', null); |
| 748 | - $this->Texto(in_array($this->dte, [39, 41]) ? 'Nombre' : ($x==10?'Razón social':'Razón soc.'), $x); |
|
| 748 | + $this->Texto(in_array($this->dte, [39, 41]) ? 'Nombre' : ($x==10 ? 'Razón social' : 'Razón soc.'), $x); |
|
| 749 | 749 | $this->Texto(':', $x+$offset); |
| 750 | 750 | $this->setFont('', '', null); |
| 751 | - $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
| 751 | + $this->MultiTexto($receptor['RznSocRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
| 752 | 752 | } |
| 753 | 753 | if (!empty($receptor['GiroRecep'])) { |
| 754 | 754 | $this->setFont('', 'B', null); |
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | $ciudad = !empty($receptor['CiudadRecep']) ? $receptor['CiudadRecep'] : ( |
| 766 | 766 | !empty($receptor['CmnaRecep']) ? \sasco\LibreDTE\Chile::getCiudad($receptor['CmnaRecep']) : '' |
| 767 | 767 | ); |
| 768 | - $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep'])?(', '.$receptor['CmnaRecep']):'').($ciudad?(', '.$ciudad):''), $x+$offset+2); |
|
| 768 | + $this->MultiTexto($receptor['DirRecep'].(!empty($receptor['CmnaRecep']) ? (', '.$receptor['CmnaRecep']) : '').($ciudad ? (', '.$ciudad) : ''), $x+$offset+2); |
|
| 769 | 769 | } |
| 770 | 770 | if (!empty($receptor['Extranjero']['Nacionalidad'])) { |
| 771 | 771 | $this->setFont('', 'B', null); |
@@ -806,7 +806,7 @@ discard block |
||
| 806 | 806 | $this->Texto('Cód. recep.', $x); |
| 807 | 807 | $this->Texto(':', $x+$offset); |
| 808 | 808 | $this->setFont('', '', null); |
| 809 | - $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10?105:0); |
|
| 809 | + $this->MultiTexto($receptor['CdgIntRecep'], $x+$offset+2, null, '', $x==10 ? 105 : 0); |
|
| 810 | 810 | } |
| 811 | 811 | return $this->GetY(); |
| 812 | 812 | } |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | { |
| 904 | 904 | if (!isset($referencias[0])) |
| 905 | 905 | $referencias = [$referencias]; |
| 906 | - foreach($referencias as $r) { |
|
| 906 | + foreach ($referencias as $r) { |
|
| 907 | 907 | $texto = $r['NroLinRef'].' - '; |
| 908 | 908 | if (!empty($r['TpoDocRef'])) { |
| 909 | 909 | $texto .= $this->getTipo($r['TpoDocRef']).' '; |
@@ -964,7 +964,7 @@ discard block |
||
| 964 | 964 | // quitar columnas |
| 965 | 965 | foreach ($item as $col => $valor) { |
| 966 | 966 | if ($col=='DscItem' and !empty($item['DscItem'])) { |
| 967 | - $item['NmbItem'] .= !$this->item_detalle_posicion ? ($html?'<br/>':"\n") : ': '; |
|
| 967 | + $item['NmbItem'] .= !$this->item_detalle_posicion ? ($html ? '<br/>' : "\n") : ': '; |
|
| 968 | 968 | $item['DscItem'] = $html ? str_replace("\n", '<br/>', $item['DscItem']) : str_replace(['<br/>', '<br>'], "\n", $item['DscItem']); |
| 969 | 969 | if ($html) { |
| 970 | 970 | $item['NmbItem'] .= '<span style="font-size:0.7em">'.$item['DscItem'].'</span>'; |
@@ -1067,9 +1067,9 @@ discard block |
||
| 1067 | 1067 | $this->SetY($this->getY()+1); |
| 1068 | 1068 | $p1x = $x; |
| 1069 | 1069 | $p1y = $this->y; |
| 1070 | - $p2x = $this->getPageWidth() - 2; |
|
| 1071 | - $p2y = $p1y; // Use same y for a straight line |
|
| 1072 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
| 1070 | + $p2x = $this->getPageWidth()-2; |
|
| 1071 | + $p2y = $p1y; // Use same y for a straight line |
|
| 1072 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
| 1073 | 1073 | $this->Line($p1x, $p1y, $p2x, $p2y, $style); |
| 1074 | 1074 | $this->Texto($this->detalle_cols['NmbItem']['title'], $x+$offsets[0], $this->y, ucfirst($this->detalle_cols['NmbItem']['align'][0]), $this->detalle_cols['NmbItem']['width']); |
| 1075 | 1075 | $this->Texto($this->detalle_cols['PrcItem']['title'], $x+$offsets[1], $this->y, ucfirst($this->detalle_cols['PrcItem']['align'][0]), $this->detalle_cols['PrcItem']['width']); |
@@ -1081,7 +1081,7 @@ discard block |
||
| 1081 | 1081 | } |
| 1082 | 1082 | // mostrar items |
| 1083 | 1083 | $this->SetY($this->getY()+2); |
| 1084 | - foreach($detalle as &$d) { |
|
| 1084 | + foreach ($detalle as &$d) { |
|
| 1085 | 1085 | // nombre y descripción del item |
| 1086 | 1086 | $item = $d['NmbItem']; |
| 1087 | 1087 | if ($this->papel_continuo_item_detalle and !empty($d['DscItem'])) { |
@@ -1122,7 +1122,7 @@ discard block |
||
| 1122 | 1122 | if (!isset($detalle[0])) { |
| 1123 | 1123 | $detalle = [$detalle]; |
| 1124 | 1124 | } |
| 1125 | - foreach($detalle as &$d) { |
|
| 1125 | + foreach ($detalle as &$d) { |
|
| 1126 | 1126 | if (!empty($d['MontoItem'])) { |
| 1127 | 1127 | $subtotal += $d['MontoItem']; |
| 1128 | 1128 | } |
@@ -1149,18 +1149,18 @@ discard block |
||
| 1149 | 1149 | if (!isset($descuentosRecargos[0])) { |
| 1150 | 1150 | $descuentosRecargos = [$descuentosRecargos]; |
| 1151 | 1151 | } |
| 1152 | - foreach($descuentosRecargos as $dr) { |
|
| 1152 | + foreach ($descuentosRecargos as $dr) { |
|
| 1153 | 1153 | $tipo = $dr['TpoMov']=='D' ? 'Descuento' : 'Recargo'; |
| 1154 | 1154 | if (!empty($dr['IndExeDR'])) { |
| 1155 | 1155 | $tipo .= ' EX'; |
| 1156 | 1156 | } |
| 1157 | 1157 | $valor = $dr['TpoValor']=='%' ? $dr['ValorDR'].'%' : $this->num($dr['ValorDR']); |
| 1158 | 1158 | if ($this->papelContinuo) { |
| 1159 | - $glosa = $tipo.' global'.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):'').':'; |
|
| 1159 | + $glosa = $tipo.' global'.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : '').':'; |
|
| 1160 | 1160 | $this->Texto($glosa, $x, null, 'R', 30); |
| 1161 | 1161 | $this->Texto($valor, $x+$offset, null, 'R', 30); |
| 1162 | 1162 | } else { |
| 1163 | - $this->Texto($tipo.(!empty($dr['GlosaDR'])?(' ('.$dr['GlosaDR'].')'):'').':', 77, null, 'R', 100); |
|
| 1163 | + $this->Texto($tipo.(!empty($dr['GlosaDR']) ? (' ('.$dr['GlosaDR'].')') : '').':', 77, null, 'R', 100); |
|
| 1164 | 1164 | $this->Texto($valor, 177, null, 'R', 22); |
| 1165 | 1165 | } |
| 1166 | 1166 | $this->Ln(); |
@@ -1180,8 +1180,8 @@ discard block |
||
| 1180 | 1180 | $pagos = [$pagos]; |
| 1181 | 1181 | $this->Texto('Pago(s) programado(s):', $x); |
| 1182 | 1182 | $this->Ln(); |
| 1183 | - foreach($pagos as $p) { |
|
| 1184 | - $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos'])?(' ('.$p['GlosaPagos'].')'):''), $x); |
|
| 1183 | + foreach ($pagos as $p) { |
|
| 1184 | + $this->Texto(' - '.$this->date($p['FchPago'], false).': $'.$this->num($p['MntPago']).'.-'.(!empty($p['GlosaPagos']) ? (' ('.$p['GlosaPagos'].')') : ''), $x); |
|
| 1185 | 1185 | $this->Ln(); |
| 1186 | 1186 | } |
| 1187 | 1187 | } |
@@ -1215,7 +1215,7 @@ discard block |
||
| 1215 | 1215 | 'TpoMoneda' => 'Moneda', |
| 1216 | 1216 | 'MntNeto' => 'Neto $', |
| 1217 | 1217 | 'MntExe' => 'Exento $', |
| 1218 | - 'IVA' => 'IVA '.(!empty($totales['TasaIVA'])?(' ('.$totales['TasaIVA'].'%) '):'').'$', |
|
| 1218 | + 'IVA' => 'IVA '.(!empty($totales['TasaIVA']) ? (' ('.$totales['TasaIVA'].'%) ') : '').'$', |
|
| 1219 | 1219 | 'IVANoRet' => 'IVA no retenido $', |
| 1220 | 1220 | 'CredEC' => 'Desc. 65% IVA $', |
| 1221 | 1221 | 'MntTotal' => 'Total $', |
@@ -1232,7 +1232,7 @@ discard block |
||
| 1232 | 1232 | if (!isset($ImptoReten[0])) { |
| 1233 | 1233 | $ImptoReten = [$ImptoReten]; |
| 1234 | 1234 | } |
| 1235 | - foreach($ImptoReten as $i) { |
|
| 1235 | + foreach ($ImptoReten as $i) { |
|
| 1236 | 1236 | $totales['ImptoReten_'.$i['TipoImp']] = $i['MontoImp']; |
| 1237 | 1237 | if (!empty($i['TasaImp'])) { |
| 1238 | 1238 | $glosas['ImptoReten_'.$i['TipoImp']] = \sasco\LibreDTE\Sii\ImpuestosAdicionales::getGlosa($i['TipoImp']).' ('.$i['TasaImp'].'%) $'; |
@@ -1348,9 +1348,9 @@ discard block |
||
| 1348 | 1348 | 'vpadding' => 0, |
| 1349 | 1349 | 'module_width' => 1, // width of a single module in points |
| 1350 | 1350 | 'module_height' => 1, // height of a single module in points |
| 1351 | - 'fgcolor' => [0,0,0], |
|
| 1351 | + 'fgcolor' => [0, 0, 0], |
|
| 1352 | 1352 | 'bgcolor' => false, // [255,255,255] |
| 1353 | - 'position' => $position === null ? ($this->papelContinuo ? 'C' : 'S') : $position, |
|
| 1353 | + 'position' => $position===null ? ($this->papelContinuo ? 'C' : 'S') : $position, |
|
| 1354 | 1354 | ]; |
| 1355 | 1355 | $ecl = version_compare(phpversion(), '7.0.0', '<') ? -1 : $this->ecl; |
| 1356 | 1356 | $this->write2DBarcode($timbre, 'PDF417,,'.$ecl, $x_timbre, $y, $w, 0, $style, 'B'); |
@@ -1381,7 +1381,7 @@ discard block |
||
| 1381 | 1381 | protected function agregarAcuseRecibo($x = 83, $y = 190, $w = 60, $h = 40, $line = 25) |
| 1382 | 1382 | { |
| 1383 | 1383 | $y = (!$this->papelContinuo and !$this->timbre_pie) ? $this->x_fin_datos : $y; |
| 1384 | - $this->SetTextColorArray([0,0,0]); |
|
| 1384 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 1385 | 1385 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
| 1386 | 1386 | $this->setFont('', 'B', 10); |
| 1387 | 1387 | $this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1411,9 +1411,9 @@ discard block |
||
| 1411 | 1411 | */ |
| 1412 | 1412 | protected function agregarAcuseReciboContinuo($x = 3, $y = null, $w = 68, $h = 40) |
| 1413 | 1413 | { |
| 1414 | - $this->SetTextColorArray([0,0,0]); |
|
| 1414 | + $this->SetTextColorArray([0, 0, 0]); |
|
| 1415 | 1415 | $this->Rect($x, $y, $w, $h, 'D', ['all' => ['width' => 0.1, 'color' => [0, 0, 0]]]); |
| 1416 | - $style = array('width' => 0.2,'color' => array(0, 0, 0)); |
|
| 1416 | + $style = array('width' => 0.2, 'color' => array(0, 0, 0)); |
|
| 1417 | 1417 | $this->Line($x, $y+22, $w+3, $y+22, $style); |
| 1418 | 1418 | //$this->setFont('', 'B', 10); |
| 1419 | 1419 | //$this->Texto('Acuse de recibo', $x, $y+1, 'C', $w); |
@@ -1443,7 +1443,7 @@ discard block |
||
| 1443 | 1443 | $y = (!$this->papelContinuo and !$this->timbre_pie and $this->x_fin_datos<=$y) ? $this->x_fin_datos : $y; |
| 1444 | 1444 | $y += 48; |
| 1445 | 1445 | $this->setFont('', 'B', $font_size); |
| 1446 | - $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $y, 'R'); |
|
| 1446 | + $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $y, 'R'); |
|
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | 1449 | /** |
@@ -1454,7 +1454,7 @@ discard block |
||
| 1454 | 1454 | protected function agregarLeyendaDestinoContinuo($tipo) |
| 1455 | 1455 | { |
| 1456 | 1456 | $this->setFont('', 'B', 8); |
| 1457 | - $this->Texto('CEDIBLE'.($tipo==52?' CON SU FACTURA':''), null, $this->y+6, 'R'); |
|
| 1457 | + $this->Texto('CEDIBLE'.($tipo==52 ? ' CON SU FACTURA' : ''), null, $this->y+6, 'R'); |
|
| 1458 | 1458 | } |
| 1459 | 1459 | |
| 1460 | 1460 | } |