<?php
if(isset($_REQUEST['cod'])&&($_REQUEST['cod']!="")) {
$id = $_REQUEST['cod'];
include ('conexao.php');

$proc_m=mysqli_query($mysqli,"SELECT * FROM instituicao");
$res2m=mysqli_fetch_array($proc_m);
$autarquia=$res2m['instituicao'];
$nuit=$res2m['nuit'];
$telef=$res2m['telefone'];
$celular=$res2m['celular'];


$data = date('Y-m-d h:m:i');
$d = new DateTime("now", new DateTimeZone("Africa/Maputo"));
$data= $d->format("r");	
$ano = date("Y");
$sqlx = mysqli_query($mysqli,"SELECT * FROM pagtomresgistado WHERE id = $id");
$resultx=mysqli_fetch_array($sqlx);
$idd=$resultx['codgo'];
$mes=$resultx['mes'];

$agente=$resultx['agente'];

$dia=$resultx['dia'];
$municipe=$resultx['municipe'];

$query=	mysqli_query($mysqli,"SELECT * FROM msing WHERE codigo = $municipe");
$ress = mysqli_fetch_array($query);
$nome=$ress['nome'];$codgo=$ress['codigo'];

$image="1";
$content="  \n";
$content.=$autarquia."\n";
$content.=$nuit."\n";
$content.=$telef."/".$celular."\n";
$content.="Municipe: ".$nome."\n";
$content.="Codigo do cliente: ".$codgo."\n";
$content.="RECIBO Nr".$idd."/".$mes."\n";

$proc = mysqli_query($mysqli,"SELECT * FROM pagtomresgistado WHERE municipe = $municipe AND dia=$dia AND mes=$mes AND ano=$ano");
while($ver =mysqli_fetch_array($proc))
{ 
$content.="--------------------------------";
$content.=$data." ";
$content.="Taxa                  ".number_format($ver['taxa'],2)."MT\n";
$content.="Multa                   ".number_format($ver['multa'],2)."MT\n";
$content.="--------------------------------";
$content.="Total Cobrado         ".number_format($ver['pago'],2)."MT  \n";
$content.="--------------------------------";
$content.="Operador: ".$agente."\n\n";
$content.="MUITO OBRIGADO \n";
$content.="Pague sempre!!\n";
$valor=($ver['pago']);

}

//you can print text and image by sending request from your website
$a = array();
//sending image entry			
$obj2->type = 1;//image
$obj2->path = 'https://cacm.co.mz/images/logo.jpg';//complete filepath on your web server; make sure that it is not big size
$obj2->align = 1;//0 if left, 1 if center, 2 if right; set left align for big size images
array_push($a,$obj2);

//sending text entry	
$obj1->type = 0;//text
$obj1->content = $content;//any string	
$obj1->bold = 1;//0 if no, 1 if yes
$obj1->align =0;//0 if left, 1 if center, 2 if right
$obj1->format = 3;//0 if normal, 1 if double Height, 2 if double Height + Width, 3 if double Width
array_push($a,$obj1);

//sending barcode entry			
$obj3->type = 2;//barcode
$obj3->value = '';//valid barcode value
$obj3->width = 400;//valid barcode width
$obj3->height = 100;//valid barcode height
$obj3->align = 1;//0 if left, 1 if center, 2 if right
array_push($a,$obj3);
//sending QR entry			
$obj4->type = 3;//QR code
//$obj4->value = $cont;//valid QR code value
$obj4->size = 30;//valid QR code size in mm
$obj4->align = 2;//0 if left, 1 if center, 2 if right
array_push($a,$obj4);

echo json_encode($a,JSON_FORCE_OBJECT);

} else {$id = "SEM INFORMACAO";}
?>
