| @@ 309-510 (lines=202) @@ | ||
| 306 | * @param string $papel (Opcional) Estabelece o tamanho do papel (ex. A4) |
|
| 307 | * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML |
|
| 308 | */ |
|
| 309 | public function montaDACTE( |
|
| 310 | $orientacao = '', |
|
| 311 | $papel = 'A4', |
|
| 312 | $logoAlign = 'C', |
|
| 313 | $classPDF = false |
|
| 314 | ) { |
|
| 315 | ||
| 316 | //se a orientação estiver em branco utilizar o padrão estabelecido na NF |
|
| 317 | if ($orientacao == '') { |
|
| 318 | if ($this->tpImp == '1') { |
|
| 319 | $orientacao = 'P'; |
|
| 320 | } else { |
|
| 321 | $orientacao = 'P'; |
|
| 322 | } |
|
| 323 | } |
|
| 324 | $this->orientacao = $orientacao; |
|
| 325 | $this->papel = $papel; |
|
| 326 | $this->logoAlign = $logoAlign; |
|
| 327 | ||
| 328 | //$this->situacao_externa = $situacao_externa; |
|
| 329 | //instancia a classe pdf |
|
| 330 | if ($classPDF !== false) { |
|
| 331 | $this->pdf = $classPDF; |
|
| 332 | } else { |
|
| 333 | $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel); |
|
| 334 | } |
|
| 335 | if ($this->orientacao == 'P') { |
|
| 336 | // margens do PDF |
|
| 337 | $margSup = 2; |
|
| 338 | $margEsq = 2; |
|
| 339 | $margDir = 2; |
|
| 340 | // posição inicial do relatorio |
|
| 341 | $xInic = 1; |
|
| 342 | $yInic = 1; |
|
| 343 | if ($papel == 'A4') { |
|
| 344 | //A4 210x297mm |
|
| 345 | $maxW = 210; |
|
| 346 | $maxH = 297; |
|
| 347 | } |
|
| 348 | } else { |
|
| 349 | // margens do PDF |
|
| 350 | $margSup = 3; |
|
| 351 | $margEsq = 3; |
|
| 352 | $margDir = 3; |
|
| 353 | // posição inicial do relatorio |
|
| 354 | $xInic = 5; |
|
| 355 | $yInic = 5; |
|
| 356 | if ($papel == 'A4') { |
|
| 357 | //A4 210x297mm |
|
| 358 | $maxH = 210; |
|
| 359 | $maxW = 297; |
|
| 360 | $this->wCanhoto = 25; |
|
| 361 | } |
|
| 362 | } |
|
| 363 | //total inicial de paginas |
|
| 364 | $totPag = 1; |
|
| 365 | //largura imprimivel em mm |
|
| 366 | $this->wPrint = $maxW - ($margEsq + $xInic); |
|
| 367 | //comprimento imprimivel em mm |
|
| 368 | $this->hPrint = $maxH - ($margSup + $yInic); |
|
| 369 | // estabelece contagem de paginas |
|
| 370 | $this->pdf->AliasNbPages(); |
|
| 371 | // fixa as margens |
|
| 372 | $this->pdf->SetMargins($margEsq, $margSup, $margDir); |
|
| 373 | $this->pdf->SetDrawColor(0, 0, 0); |
|
| 374 | $this->pdf->SetFillColor(255, 255, 255); |
|
| 375 | // inicia o documento |
|
| 376 | $this->pdf->Open(); |
|
| 377 | // adiciona a primeira página |
|
| 378 | $this->pdf->AddPage($this->orientacao, $this->papel); |
|
| 379 | $this->pdf->SetLineWidth(0.1); |
|
| 380 | $this->pdf->SetTextColor(0, 0, 0); |
|
| 381 | //calculo do numero de páginas ??? |
|
| 382 | $totPag = 1; |
|
| 383 | //montagem da primeira página |
|
| 384 | $pag = 1; |
|
| 385 | $x = $xInic; |
|
| 386 | $y = $yInic; |
|
| 387 | //coloca o cabeçalho |
|
| 388 | //$r = $this->zCabecalho($x, $y, $pag, $totPag); |
|
| 389 | $y += 70; |
|
| 390 | $r = $this->zRemetente($x, $y); |
|
| 391 | $x = $this->wPrint * 0.5 + 2; |
|
| 392 | $r = $this->zDestinatario($x, $y); |
|
| 393 | $y += 19; |
|
| 394 | $x = $xInic; |
|
| 395 | $r = $this->zExpedidor($x, $y); |
|
| 396 | $x = $this->wPrint * 0.5 + 2; |
|
| 397 | $r = $this->zRecebedor($x, $y); |
|
| 398 | $y += 19; |
|
| 399 | $x = $xInic; |
|
| 400 | $r = $this->zTomador($x, $y); |
|
| 401 | if ($this->tpCTe == '0') { |
|
| 402 | //Normal |
|
| 403 | $y += 10; |
|
| 404 | $x = $xInic; |
|
| 405 | $r = $this->zDescricaoCarga($x, $y); |
|
| 406 | $y += 17; |
|
| 407 | $x = $xInic; |
|
| 408 | $r = $this->zCompValorServ($x, $y); |
|
| 409 | $y += 25; |
|
| 410 | $x = $xInic; |
|
| 411 | $r = $this->zImpostos($x, $y); |
|
| 412 | $y += 13; |
|
| 413 | $x = $xInic; |
|
| 414 | $r = $this->zDocOrig($x, $y); |
|
| 415 | if ($this->modal == '1') { |
|
| 416 | if ($this->lota == 1) { |
|
| 417 | //$y += 24.95; |
|
| 418 | $y += 35; |
|
| 419 | } else { |
|
| 420 | $y += 53; |
|
| 421 | } |
|
| 422 | } elseif ($this->modal == '3') { |
|
| 423 | $y += 37.75; |
|
| 424 | } else { |
|
| 425 | $y += 24.95; |
|
| 426 | } |
|
| 427 | $x = $xInic; |
|
| 428 | $r = $this->zObs($x, $y); |
|
| 429 | $y = $y-6; |
|
| 430 | switch ($this->modal) { |
|
| 431 | case '1': |
|
| 432 | $y += 17.9; |
|
| 433 | $x = $xInic; |
|
| 434 | $r = $this->zModalRod($x, $y); |
|
| 435 | break; |
|
| 436 | case '2': |
|
| 437 | $y += 17.9; |
|
| 438 | $x = $xInic; |
|
| 439 | // TODO fmertins 31/10/14: este método não existe... |
|
| 440 | $r = $this->zModalAereo($x, $y); |
|
| 441 | break; |
|
| 442 | case '3': |
|
| 443 | $y += 17.9; |
|
| 444 | $x = $xInic; |
|
| 445 | $r = $this->zModalAquaviario($x, $y); |
|
| 446 | break; |
|
| 447 | case '4': |
|
| 448 | $y += 17.9; |
|
| 449 | $x = $xInic; |
|
| 450 | $r = $this->zModalFerr($x, $y); |
|
| 451 | break; |
|
| 452 | case '5': |
|
| 453 | $y += 17.9; |
|
| 454 | $x = $xInic; |
|
| 455 | // TODO fmertins 31/10/14: este método não existe... |
|
| 456 | $r = $this->zModalDutoviario($x, $y); |
|
| 457 | break; |
|
| 458 | } |
|
| 459 | if ($this->modal == '1') { |
|
| 460 | if ($this->lota == 1) { |
|
| 461 | $y += 37; |
|
| 462 | } else { |
|
| 463 | $y += 8.9; |
|
| 464 | } |
|
| 465 | } elseif ($this->modal == '3') { |
|
| 466 | $y += 24.15; |
|
| 467 | } else { |
|
| 468 | $y += 37; |
|
| 469 | } |
|
| 470 | } else { |
|
| 471 | $r = $this->zCabecalho(1, 1, $pag, $totPag); |
|
| 472 | //Complementado |
|
| 473 | $y += 10; |
|
| 474 | $x = $xInic; |
|
| 475 | $r = $this->zDocCompl($x, $y); |
|
| 476 | $y += 80; |
|
| 477 | $x = $xInic; |
|
| 478 | $r = $this->zCompValorServ($x, $y); |
|
| 479 | $y += 25; |
|
| 480 | $x = $xInic; |
|
| 481 | $r = $this->zImpostos($x, $y); |
|
| 482 | $y += 13; |
|
| 483 | $x = $xInic; |
|
| 484 | $r = $this->zObs($x, $y); |
|
| 485 | $y += 15; |
|
| 486 | } |
|
| 487 | $x = $xInic; |
|
| 488 | $r = $this->zDadosAdic($x, $y, $pag, $totPag); |
|
| 489 | ||
| 490 | //$y += 19; |
|
| 491 | $y += 10; |
|
| 492 | $y = $this->zCanhoto($x, $y); |
|
| 493 | ||
| 494 | //coloca o rodapé da página |
|
| 495 | if ($this->orientacao == 'P') { |
|
| 496 | $this->zRodape(2, $this->hPrint - 2); |
|
| 497 | } else { |
|
| 498 | $this->zRodape($xInic, $this->hPrint + 2.3); |
|
| 499 | } |
|
| 500 | if ($this->flagDocOrigContinuacao == 1) { |
|
| 501 | $this->zdocOrigContinuacao(1, 71); |
|
| 502 | } |
|
| 503 | //retorna o ID na CTe |
|
| 504 | if ($classPDF !== false) { |
|
| 505 | $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf); |
|
| 506 | return $aR; |
|
| 507 | } else { |
|
| 508 | return str_replace('CTe', '', $this->infCte->getAttribute("Id")); |
|
| 509 | } |
|
| 510 | } //fim da função montaDACTE |
|
| 511 | ||
| 512 | /** |
|
| 513 | * printDACTE |
|
| @@ 310-511 (lines=202) @@ | ||
| 307 | * @param string $papel (Opcional) Estabelece o tamanho do papel (ex. A4) |
|
| 308 | * @return string O ID da NFe numero de 44 digitos extraido do arquivo XML |
|
| 309 | */ |
|
| 310 | public function montaDACTE( |
|
| 311 | $orientacao = '', |
|
| 312 | $papel = 'A4', |
|
| 313 | $logoAlign = 'C', |
|
| 314 | $classPDF = false |
|
| 315 | ) { |
|
| 316 | ||
| 317 | //se a orientação estiver em branco utilizar o padrão estabelecido na NF |
|
| 318 | if ($orientacao == '') { |
|
| 319 | if ($this->tpImp == '1') { |
|
| 320 | $orientacao = 'P'; |
|
| 321 | } else { |
|
| 322 | $orientacao = 'P'; |
|
| 323 | } |
|
| 324 | } |
|
| 325 | $this->orientacao = $orientacao; |
|
| 326 | $this->papel = $papel; |
|
| 327 | $this->logoAlign = $logoAlign; |
|
| 328 | ||
| 329 | //$this->situacao_externa = $situacao_externa; |
|
| 330 | //instancia a classe pdf |
|
| 331 | if ($classPDF !== false) { |
|
| 332 | $this->pdf = $classPDF; |
|
| 333 | } else { |
|
| 334 | $this->pdf = new Pdf($this->orientacao, 'mm', $this->papel); |
|
| 335 | } |
|
| 336 | if ($this->orientacao == 'P') { |
|
| 337 | // margens do PDF |
|
| 338 | $margSup = 2; |
|
| 339 | $margEsq = 2; |
|
| 340 | $margDir = 2; |
|
| 341 | // posição inicial do relatorio |
|
| 342 | $xInic = 1; |
|
| 343 | $yInic = 1; |
|
| 344 | if ($papel == 'A4') { |
|
| 345 | //A4 210x297mm |
|
| 346 | $maxW = 210; |
|
| 347 | $maxH = 297; |
|
| 348 | } |
|
| 349 | } else { |
|
| 350 | // margens do PDF |
|
| 351 | $margSup = 3; |
|
| 352 | $margEsq = 3; |
|
| 353 | $margDir = 3; |
|
| 354 | // posição inicial do relatorio |
|
| 355 | $xInic = 5; |
|
| 356 | $yInic = 5; |
|
| 357 | if ($papel == 'A4') { |
|
| 358 | //A4 210x297mm |
|
| 359 | $maxH = 210; |
|
| 360 | $maxW = 297; |
|
| 361 | $this->wCanhoto = 25; |
|
| 362 | } |
|
| 363 | } |
|
| 364 | //total inicial de paginas |
|
| 365 | $totPag = 1; |
|
| 366 | //largura imprimivel em mm |
|
| 367 | $this->wPrint = $maxW - ($margEsq + $xInic); |
|
| 368 | //comprimento imprimivel em mm |
|
| 369 | $this->hPrint = $maxH - ($margSup + $yInic); |
|
| 370 | // estabelece contagem de paginas |
|
| 371 | $this->pdf->AliasNbPages(); |
|
| 372 | // fixa as margens |
|
| 373 | $this->pdf->SetMargins($margEsq, $margSup, $margDir); |
|
| 374 | $this->pdf->SetDrawColor(0, 0, 0); |
|
| 375 | $this->pdf->SetFillColor(255, 255, 255); |
|
| 376 | // inicia o documento |
|
| 377 | $this->pdf->Open(); |
|
| 378 | // adiciona a primeira página |
|
| 379 | $this->pdf->AddPage($this->orientacao, $this->papel); |
|
| 380 | $this->pdf->SetLineWidth(0.1); |
|
| 381 | $this->pdf->SetTextColor(0, 0, 0); |
|
| 382 | //calculo do numero de páginas ??? |
|
| 383 | $totPag = 1; |
|
| 384 | //montagem da primeira página |
|
| 385 | $pag = 1; |
|
| 386 | $x = $xInic; |
|
| 387 | $y = $yInic; |
|
| 388 | //coloca o cabeçalho |
|
| 389 | //$r = $this->zCabecalho($x, $y, $pag, $totPag); |
|
| 390 | $y += 70; |
|
| 391 | $r = $this->zRemetente($x, $y); |
|
| 392 | $x = $this->wPrint * 0.5 + 2; |
|
| 393 | $r = $this->zDestinatario($x, $y); |
|
| 394 | $y += 19; |
|
| 395 | $x = $xInic; |
|
| 396 | $r = $this->zExpedidor($x, $y); |
|
| 397 | $x = $this->wPrint * 0.5 + 2; |
|
| 398 | $r = $this->zRecebedor($x, $y); |
|
| 399 | $y += 19; |
|
| 400 | $x = $xInic; |
|
| 401 | $r = $this->zTomador($x, $y); |
|
| 402 | if ($this->tpCTe == '0') { |
|
| 403 | //Normal |
|
| 404 | $y += 10; |
|
| 405 | $x = $xInic; |
|
| 406 | $r = $this->zDescricaoCarga($x, $y); |
|
| 407 | $y += 17; |
|
| 408 | $x = $xInic; |
|
| 409 | $r = $this->zCompValorServ($x, $y); |
|
| 410 | $y += 25; |
|
| 411 | $x = $xInic; |
|
| 412 | $r = $this->zImpostos($x, $y); |
|
| 413 | $y += 13; |
|
| 414 | $x = $xInic; |
|
| 415 | $r = $this->zDocOrig($x, $y); |
|
| 416 | if ($this->modal == '1') { |
|
| 417 | if ($this->lota == 1) { |
|
| 418 | //$y += 24.95; |
|
| 419 | $y += 35; |
|
| 420 | } else { |
|
| 421 | $y += 53; |
|
| 422 | } |
|
| 423 | } elseif ($this->modal == '3') { |
|
| 424 | $y += 37.75; |
|
| 425 | } else { |
|
| 426 | $y += 24.95; |
|
| 427 | } |
|
| 428 | $x = $xInic; |
|
| 429 | $r = $this->zObs($x, $y); |
|
| 430 | $y = $y-6; |
|
| 431 | switch ($this->modal) { |
|
| 432 | case '1': |
|
| 433 | $y += 25.9; |
|
| 434 | $x = $xInic; |
|
| 435 | $r = $this->zModalRod($x, $y); |
|
| 436 | break; |
|
| 437 | case '2': |
|
| 438 | $y += 17.9; |
|
| 439 | $x = $xInic; |
|
| 440 | // TODO fmertins 31/10/14: este método não existe... |
|
| 441 | $r = $this->zModalAereo($x, $y); |
|
| 442 | break; |
|
| 443 | case '3': |
|
| 444 | $y += 17.9; |
|
| 445 | $x = $xInic; |
|
| 446 | $r = $this->zModalAquaviario($x, $y); |
|
| 447 | break; |
|
| 448 | case '4': |
|
| 449 | $y += 17.9; |
|
| 450 | $x = $xInic; |
|
| 451 | $r = $this->zModalFerr($x, $y); |
|
| 452 | break; |
|
| 453 | case '5': |
|
| 454 | $y += 17.9; |
|
| 455 | $x = $xInic; |
|
| 456 | // TODO fmertins 31/10/14: este método não existe... |
|
| 457 | $r = $this->zModalDutoviario($x, $y); |
|
| 458 | break; |
|
| 459 | } |
|
| 460 | if ($this->modal == '1') { |
|
| 461 | if ($this->lota == 1) { |
|
| 462 | $y += 37; |
|
| 463 | } else { |
|
| 464 | $y += 8.9; |
|
| 465 | } |
|
| 466 | } elseif ($this->modal == '3') { |
|
| 467 | $y += 24.15; |
|
| 468 | } else { |
|
| 469 | $y += 37; |
|
| 470 | } |
|
| 471 | } else { |
|
| 472 | $r = $this->zCabecalho(1, 1, $pag, $totPag); |
|
| 473 | //Complementado |
|
| 474 | $y += 10; |
|
| 475 | $x = $xInic; |
|
| 476 | $r = $this->zDocCompl($x, $y); |
|
| 477 | $y += 80; |
|
| 478 | $x = $xInic; |
|
| 479 | $r = $this->zCompValorServ($x, $y); |
|
| 480 | $y += 25; |
|
| 481 | $x = $xInic; |
|
| 482 | $r = $this->zImpostos($x, $y); |
|
| 483 | $y += 13; |
|
| 484 | $x = $xInic; |
|
| 485 | $r = $this->zObs($x, $y); |
|
| 486 | $y += 15; |
|
| 487 | } |
|
| 488 | $x = $xInic; |
|
| 489 | $r = $this->zDadosAdic($x, $y, $pag, $totPag); |
|
| 490 | ||
| 491 | //$y += 19; |
|
| 492 | $y += 11; |
|
| 493 | $y = $this->zCanhoto($x, $y); |
|
| 494 | ||
| 495 | //coloca o rodapé da página |
|
| 496 | if ($this->orientacao == 'P') { |
|
| 497 | $this->zRodape(2, $this->hPrint - 2); |
|
| 498 | } else { |
|
| 499 | $this->zRodape($xInic, $this->hPrint + 2.3); |
|
| 500 | } |
|
| 501 | if ($this->flagDocOrigContinuacao == 1) { |
|
| 502 | $this->zdocOrigContinuacao(1, 71); |
|
| 503 | } |
|
| 504 | //retorna o ID na CTe |
|
| 505 | if ($classPDF !== false) { |
|
| 506 | $aR = array('id' => str_replace('CTe', '', $this->infCte->getAttribute("Id")), 'classe_PDF' => $this->pdf); |
|
| 507 | return $aR; |
|
| 508 | } else { |
|
| 509 | return str_replace('CTe', '', $this->infCte->getAttribute("Id")); |
|
| 510 | } |
|
| 511 | } //fim da função montaDACTE |
|
| 512 | ||
| 513 | /** |
|
| 514 | * printDACTE |
|