forked from stavarengo/php-sigep
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request stavarengo#114 from dehdocs/php7-fix
Alteração na classe Semacode
- Loading branch information
Showing
8 changed files
with
194 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
/** | ||
* Este script cria e retorna uma instância de {@link \PhpSigep\Model\PreListaDePostagem} | ||
* | ||
* Como existe mais de um exemplo que precisa de uma {@link \PhpSigep\Model\PreListaDePostagem}, esse script foi criado | ||
* para compartilhar o código necessário para a criação da {@link \PhpSigep\Model\PreListaDePostagem}. | ||
*/ | ||
|
||
|
||
// *** DADOS DA ENCOMENDA QUE SERÁ DESPACHADA *** // | ||
$dimensao = new \PhpSigep\Model\Dimensao(); | ||
$dimensao->setAltura(20); | ||
$dimensao->setLargura(20); | ||
$dimensao->setComprimento(20); | ||
$dimensao->setDiametro(0); | ||
$dimensao->setTipo(\PhpSigep\Model\Dimensao::TIPO_PACOTE_CAIXA); | ||
|
||
$destinatario = new \PhpSigep\Model\Destinatario(); | ||
$destinatario->setNome('Google Belo Horizonte'); | ||
$destinatario->setLogradouro('Av. Bias Fortes'); | ||
$destinatario->setNumero('382'); | ||
$destinatario->setComplemento('6º andar'); | ||
|
||
$destino = new \PhpSigep\Model\DestinoNacional(); | ||
$destino->setBairro('Lourdes'); | ||
$destino->setCep('30170-010'); | ||
$destino->setCidade('Belo Horizonte'); | ||
$destino->setUf('MG'); | ||
|
||
// Estamos criando uma etique falsa, mas em um ambiente real voçê deve usar o método | ||
// {@link \PhpSigep\Services\SoapClient\Real::solicitaEtiquetas() } para gerar o número das etiquetas | ||
$etiqueta = new \PhpSigep\Model\Etiqueta(); | ||
$etiqueta->setEtiquetaSemDv('PD73958096BR'); | ||
|
||
$servicoAdicional = new \PhpSigep\Model\ServicoAdicional(); | ||
$servicoAdicional->setCodigoServicoAdicional(\PhpSigep\Model\ServicoAdicional::SERVICE_REGISTRO); | ||
// Se não tiver valor declarado informar 0 (zero) | ||
$servicoAdicional->setValorDeclarado(0); | ||
|
||
$encomenda = new \PhpSigep\Model\ObjetoPostal(); | ||
$encomenda->setServicosAdicionais(array($servicoAdicional)); | ||
$encomenda->setDestinatario($destinatario); | ||
$encomenda->setDestino($destino); | ||
$encomenda->setDimensao($dimensao); | ||
$encomenda->setEtiqueta($etiqueta); | ||
$encomenda->setPeso(0.500);// 500 gramas | ||
$encomenda->setServicoDePostagem(new \PhpSigep\Model\ServicoDePostagem(\PhpSigep\Model\ServicoDePostagem::SERVICE_SEDEX_40096)); | ||
// *** FIM DOS DADOS DA ENCOMENDA QUE SERÁ DESPACHADA *** // | ||
|
||
// *** DADOS DO REMETENTE *** // | ||
$remetente = new \PhpSigep\Model\Remetente(); | ||
$remetente->setNome('Google São Paulo'); | ||
$remetente->setLogradouro('Av. Brigadeiro Faria Lima'); | ||
$remetente->setNumero('3900'); | ||
$remetente->setComplemento('5º andar'); | ||
$remetente->setBairro('Itaim'); | ||
$remetente->setCep('04538-132'); | ||
$remetente->setUf('SP'); | ||
$remetente->setCidade('São Paulo'); | ||
// *** FIM DOS DADOS DO REMETENTE *** // | ||
|
||
|
||
$plp = new \PhpSigep\Model\PreListaDePostagem(); | ||
$plp->setAccessData(new \PhpSigep\Model\AccessDataHomologacao()); | ||
$plp->setEncomendas([$encomenda,$encomenda,$encomenda,$encomenda]); | ||
$plp->setRemetente($remetente); | ||
|
||
return $plp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
require_once __DIR__ . '/bootstrap-exemplos.php'; | ||
|
||
$params = include __DIR__ . '/helper-criar-pre-lista-a4.php'; | ||
|
||
// Logo da empresa remetente | ||
$logoFile = __DIR__ . '/logo-etiqueta-2016.png'; | ||
|
||
//Parametro opcional indica qual layout utilizar para a chancela. Ex.: CartaoDePostagem::TYPE_CHANCELA_CARTA, CartaoDePostagem::TYPE_CHANCELA_CARTA_2016 | ||
$layoutChancela = array(); //array(\PhpSigep\Pdf\CartaoDePostagem2016::TYPE_CHANCELA_SEDEX_2016); | ||
|
||
$pdf = new \PhpSigep\Pdf\CartaoDePostagem2016($params, time(), $logoFile, $layoutChancela); | ||
|
||
$fileName = 'etiquetas.pdf'; | ||
$pdf->render('F',$fileName); | ||
|
||
unset($pdf); | ||
$pdf = new \PhpSigep\PDF\ImprovedFPDF('P', 'mm', 'Letter' ); | ||
$pageCount = $pdf->setSourceFile($fileName); | ||
|
||
$pdf->AddPage(); | ||
$pdf->SetFillColor(0,0,0); | ||
$pdf->SetFont('Arial','B',16); | ||
|
||
for($i=1;$i<=$pageCount;$i++) { | ||
$tplIdx = $pdf->importPage($i, '/MediaBox'); | ||
|
||
$mod = $i % 4; | ||
|
||
switch ($mod) { | ||
case 0: | ||
//A4: 210(x) × 297(y) | ||
//Letter: 216 (x) × 279 (y) | ||
$pdf->useTemplate($tplIdx, 110, 145, 105, 138, true); | ||
|
||
if ($i !== $pageCount) { | ||
$pdf->AddPage(); | ||
$pdf->SetFillColor(0,0,0); | ||
$pdf->SetFont('Arial','B',16); | ||
} | ||
break; | ||
case 1: | ||
$pdf->useTemplate($tplIdx, 10, 10, 105, 138, true); | ||
break; | ||
case 2: | ||
$pdf->useTemplate($tplIdx, 110, 10, 105, 138, true); | ||
break; | ||
case 3: | ||
$pdf->useTemplate($tplIdx, 10, 145, 105, 138, true); | ||
break; | ||
} | ||
|
||
} | ||
|
||
|
||
$pdf->Output(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters