<?php
include ('conexao.php');

$data = date('Y-m-d h:m:i');
	
$d = new DateTime("now", new DateTimeZone("Africa/Maputo"));
$data= $d->format("r");	
$id = $_GET['cod'];
/*
$sql2 = mysqli_query($mysqli,"SELECT * FROM pagto_por_referencia WHERE municipe = $id");
$result2 = mysqli_fetch_array($sql2);
$forma = $result2['entidade'];
if($forma != ''){
    $form = "M-Pesa";
}else{
    $form = "Dinheiro";
}
*/
$pro = mysqli_query($mysqli,"SELECT * FROM pagtodriversnregisted WHERE id = $id");
$v = mysqli_fetch_array($pro); $matr=$v['veiculo'];$idd=$v['id'];$agente=$v['agente'];
$rr=mysqli_num_rows($pro);
if($rr<1)
$content="NAO PAGO \n";	
else
$l=mysqli_query($mysqli,"SELECT * FROM pagtodriversnregisted WHERE id=$id");
$s=mysqli_fetch_array($l);$q=$s['veiculo'];	

$image="1";
$content="  \n";
$content.="CONSELHO AUTARQUICO DE MOCUBA \n";
$content.="NUIT: 500023031 \n";
$content.="Telefone: 843300063 / 861251318 \n";
$content.="Municipe: ".$q."\n";
//$content.="Pagamento por: ".$form."\n";
$content.="RECIBO Nº".$idd."/".$q."\n";
$proc = mysqli_query($mysqli,"SELECT * FROM pagtodriversnregisted WHERE id = $id");
while($ver = mysqli_fetch_array($proc))
{
$agente=$ver['agente'];

$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\n";
$valor=$ver['pago'];
}

$a = array();
//sending text entry	
$obj1 = new stdClass(); 
$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 = 0;//0 if normal, 1 if double Height, 2 if double Height + Width, 3 if double Width
array_push($a,$obj1);

echo json_encode($a,JSON_FORCE_OBJECT);

?>
