<?php

ini_set('display_errors', 1);
define("ADMIN", true);
require_once("../../common/lib.php");
require_once("../../common/define.php");
define("TITLE_ELEMENT", 'Cheque');
if(!isset($_SESSION['user'])){
    header("Location: /admin/login.php");
    exit();
}
require_once("../includes/fn_module.php"); 

include('ChiffresEnLettres.php'); 
?>

<?php
$id = $_GET["id"];
$name = "";
	if($db !== false){
		$query = "SELECT * FROM `pm_transaction` WHERE id = ".$id;
		$result = @$db->query($query);
        if($result !== false){
			$row = $result->fetch();  
			$montant = $row["montant"]; 
			$mnt = number_format($montant, 3, '.', '');
			$amount = explode(".", $mnt);
			$lettre=new ChiffreEnLettre(); 
			$montant_lettre = $lettre->Conversion($amount[0])." dinars et ". $lettre->Conversion($amount[1])." millimes";
			if($row["fournisseur"]){
				$query_id = "select * from pm_fournisseurs where id =".$row["fournisseur"];
				$result_id = @$db->query($query_id);
				if($result_id !== false){
					$row_id = $result_id->fetch();
					$name = $row_id["name"];
				}				
			}else{
				$query_id = "select * from pm_client where id =".$row["client"];
			}
		}	
	} 
	

?>

<body style="margin:0px;padding:0px;">

<div class="glob">

<!--<div class="barre">//</div>-->
<div class="mnt_chiffre">#<? echo $mnt ; ?>#</div>
<div class="mnt_lettre" style='text-transform: capitalize;'><? echo $montant_lettre; ?></div>
<div class="order"><? echo $name; ?></div>
<div class="lieux">Tunis</div>
<div class="date"><? echo date("d-m-Y", $row["date_echeance"]); ?></div>
</div> <!-- Row end-->

</body>
<script language="javascript">

 window.print();

</script>
<style>
.glob{
    background-image: url(http://billing.unibro.net/ui/theme/softhash/img/cheque.png);
    width: 662px;
    height: 302px;
    position: absolute;
    top: 250px;
	right: 0px;
}	
.barre{
    font-size: 50px;
	left: 20px;
    position: absolute;
    /* border: 1px red solid; */
}
.mnt_chiffre{
    font-size: 14px;
    font-weight: bold;
    position: absolute;
    width: 144px;
    /* border: 1px red solid; */
    top: 19px;
    left: 498px;
    text-align: center;
}
.order{
	font-size: 14px;
    font-weight: bold;
    position: absolute;
    width: 662px;
    /* border: 1px red solid; */
    top: 100px;
    text-align: center;	
}
.mnt_lettre{
	font-size: 14px;
    font-weight: bold;
    position: absolute;
    width: 662px;
    /* border: 1px red solid; */
    top: 83px;
    text-align: center;	
}
.date{
	font-size: 14px;
    font-weight: bold;
    position: absolute;
    width: 144px;
    /* border: 1px red solid; */
    top: 207px;
    left: 230px;
    text-align: center;
}
.lieux{
	font-size: 14px;
    font-weight: bold;
    position: absolute;
    width: 106px;
    /* border: 1px red solid; */
    top: 207px;
    left: 154px;
    text-align: center;
}

@page {
    margin: 0;
	size: landscape;
}
</style>

