<commit_before><?php
    //classes loading begin
    function classLoad ($myClass) {
        if(file_exists('../model/'.$myClass.'.php')){
            include('../model/'.$myClass.'.php');
        }
        elseif(file_exists('../controller/'.$myClass.'.php')){
            include('../controller/'.$myClass.'.php');
        }
    }
    spl_autoload_register("classLoad"); 
    include('../config.php');  
    //classes loading end
    session_start();
    if( isset($_SESSION['userMerlaTrav']) ){
        //classes managers	
        $idProjet = 0;
    	$projetManager = new ProjetManager($pdo);
		$clientManager = new ClientManager($pdo);
		$contratManager = new ContratManager($pdo);
		$operationManager = new OperationManager($pdo);
        $contratCasLibreManager = new ContratCasLibreManager($pdo);
        $reglementPrevuManager = new ReglementPrevuManager($pdo);
		if(isset($_GET['codeContrat']) and (bool)$contratManager->getCodeContrat($_GET['codeContrat']) ){
			$codeContrat = $_GET['codeContrat'];
			$contrat = $contratManager->getContratByCode($codeContrat);
			$projet = $projetManager->getProjetById($contrat->idProjet());
			$client = $clientManager->getClientById($contrat->idClient());
			$sommeOperations = $operationManager->sommeOperations($contrat->id());
			$biens = "";
            $typeBien = "";
			$niveau = "";
			if($contrat->typeBien()=="appartement"){
				$appartementManager = new AppartementManager($pdo);
				$biens = $appartementManager->getAppartementById($contrat->idBien());
                $typeBien = "Appartement";
				$niveau = $biens->niveau();
			}
			else if($contrat->typeBien()=="localCommercial"){
				$locauxManager = new LocauxManager($pdo);
				$biens = $locauxManager->getLocauxById($contrat->idBien());
                $typeBien = "Local Commercial";
			}
			$operations = "";
			//test the locaux object number: if exists get operations else do nothing
			$operationsNumber = $operationManager->getOpertaionsNumberByIdContrat($contrat->id());
			if($operationsNumber != 0){
				$operations = $operationManager->getOperationsByIdContrat($contrat->id());	
			}
            //ContratCasLibre Elements
            $contratCasLibreNumber = 
            $contratCasLibreManager->getContratCasLibreNumberByCodeContrat($codeContrat);
            $contratCasLibreElements = "";
            $contratCasLibreTitle = "";
            if ( $contratCasLibreNumber > 0 ) {
                $contratCasLibreTitle = "Informations Supplémentaires";
                $contratCasLibreElements = 
                $contratCasLibreManager->getContratCasLibresByCodeContrat($codeContrat);
            }
            //ReglementPrevu Elements
            $reglementPrevuNumber = 
            $reglementPrevuManager->getReglementNumberByCodeContrat($codeContrat);
            $reglementPrevuElements = "";
            $reglementPrevuTitle = "";
            if ( $reglementPrevuNumber > 0 ) {
                $reglementPrevuTitle = "Dates des réglements prévus";
                $reglementPrevuElements =     
                $reglementPrevuManager->getReglementPrevuByCodeContrat($codeContrat);
            }
		}
		
ob_start();
?>
<style type="text/css">
	p, h2, h4{
        text-align: center;
        font-family : Arial;
        font-weight: 100;
        margin-bottom: 0px;
    }
    h4{
        font-weight : bold;
    }
    h1{
        text-align: center;
        font-family : Arial;
        font-weight: bold;
        font-size : 18px;
        margin-bottom: 0px;
    }
    h2{
        font-size: 20px;
    }
	table {
	    border-collapse: collapse;
	    width:auto;
	    border: 1px solid black;
	}
	td, th{
		padding : 5px;
	}
	
	th{
		background-color: grey;
	}
	table, a{
		text-decoration: none;
	}
</style>
<page backtop="10mm" backbottom="20mm" backleft="10mm" backright="10mm">
    <!--img src="../assets/img/logo_company.png" style="width: 110px" /-->
    <h1>Résumé du Contrat Client - Projet : <?= $projet->nom() ?></h1>
    <p>Imprimé le <?= date('d/m/Y') ?> | <?= date('h:i') ?> </p>
    <hr>
    <div>
		<table style="width: 100%">
			<tr>
				<td><h4>Informations du client</h4></td>
				<td></td>
				<td><h4>Informations du contrat</h4></td>
				<td></td>
			</tr>
			<tr>
				<td><strong>Client</strong></td>
				<td><strong><?= $client->nom() ?></strong></td>
				<td><strong>Type</strong></td> 
				<td><strong><?= $typeBien ?></strong></td>
			</tr>
			<tr>
				<td><strong>CIN</strong></td>
				<td><strong><?= $client->cin() ?></strong></td>
				<td><strong>Nom du Bien</strong></td>
				<td><strong><?= $biens->nom() ?></strong></td>
			</tr>
			<tr>
				<td><strong>Téléphone 1</strong></td>
                <td><strong><?= $client->telephone1() ?></strong></td>
				<td><strong>Superficie</strong></td>
				<td><strong><?= $biens->superficie() ?>&nbsp;m<sup>2</sup></strong></td>
			</tr>
			<tr>
				<td><strong>Téléphone 2</strong></td>
                <td><strong><?= $client->telephone2() ?></strong></td>
				<td><strong>Etage</strong></td>
				<td><strong><?= $niveau ?></strong></td>
			</tr>
			<tr>
				<td><strong>Email</strong></td>
                <td><strong><?= $client->email() ?></strong></td>
				<td><strong>Prix de Vente</strong></td>
				<td><strong><?= number_format($contrat->prixVente(), 2, ',', ' ') ?>&nbsp;DH</strong></td>
			</tr>
			<tr>
				<td><strong>Adresse</strong></td>
                <td><strong><?= $client->adresse() ?></strong></td>
				<?php
				if($contrat->avance()!=0 or $contrat->avance()!='NULL' ){
				?>
				<td><strong>Avance</strong></td>
				<td><strong><?= number_format($contrat->avance(), 2, ',', ' ') ?>&nbsp;DH</strong></td>
				<?php
				}
				?>
			</tr>
			<tr>
				<td></td>
				<td></td>
				<td><strong>Réglements</strong></td>
				<td><strong><?= number_format($sommeOperations, 2, ',', ' ') ?>&nbsp;DH</strong></td>
			</tr>
			<tr>
				<td></td>
                <td></td>
				<td><strong>Echeance</strong></td>
				<td><strong><?= number_format($contrat->echeance(), 2, ',', ' ') ?>&nbsp;DH</strong></td>
			</tr>
		</table>
	</div>
	<br>
	<!-- DATES REGLEMENTS PREVU BEGIN -->
    <?php 
    if ( $reglementPrevuNumber > 0 ) { 
    ?>
    <div>
        <h4><?= $reglementPrevuTitle; ?></h4>
        <br>
        <table>
            <tr>
                <th style="width: 33%">Date Prévu de réglement</th>
                <th style="width: 33%">Echéance</th>
                <th style="width: 33%">Status du réglement</th>
            </tr>
            <?php
            $totalEcheance = 0;
            foreach ( $reglementPrevuElements as $element ) {
                $status = "";    
                $totalEcheance += $contrat->echeance();
                if($element->status()==0){
                    //comparing dates
                    $now = date('Y-m-d');<commit_msg>Fix Contrat Situation Print Controller - Date : 03/03/2016<commit_after><?php
    //classes loading begin
    function classLoad ($myClass) {
        if(file_exists('../model/'.$myClass.'.php')){
            include('../model/'.$myClass.'.php');
        }
        elseif(file_exists('../controller/'.$myClass.'.php')){
            include('../controller/'.$myClass.'.php');
        }
    }
    spl_autoload_register("classLoad"); 
    include('../config.php');  
    //classes loading end
    session_start();
    if( isset($_SESSION['userMerlaTrav']) ){
        //classes managers	
        $idProjet = 0;
    	$projetManager = new ProjetManager($pdo);
		$clientManager = new ClientManager($pdo);
		$contratManager = new ContratManager($pdo);
		$operationManager = new OperationManager($pdo);
        $contratCasLibreManager = new ContratCasLibreManager($pdo);
        $reglementPrevuManager = new ReglementPrevuManager($pdo);
		if(isset($_GET['codeContrat']) and (bool)$contratManager->getCodeContrat($_GET['codeContrat']) ){
			$codeContrat = $_GET['codeContrat'];
			$contrat = $contratManager->getContratByCode($codeContrat);
			$projet = $projetManager->getProjetById($contrat->idProjet());
			$client = $clientManager->getClientById($contrat->idClient());
			$sommeOperations = $operationManager->sommeOperations($contrat->id());
			$biens = "";
            $typeBien = "";
			$niveau = "";
			if($contrat->typeBien()=="appartement"){
				$appartementManager = new AppartementManager($pdo);
				$biens = $appartementManager->getAppartementById($contrat->idBien());
                $typeBien = "Appartement";
				$niveau = $biens->niveau();
			}
			else if($contrat->typeBien()=="localCommercial"){
				$locauxManager = new LocauxManager($pdo);
				$biens = $locauxManager->getLocauxById($contrat->idBien());
                $typeBien = "Local Commercial";
			}
			$operations = "";
			//test the locaux object number: if exists get operations else do nothing
			$operationsNumber = $operationManager->getOpertaionsNumberByIdContrat($contrat->id());
			if($operationsNumber != 0){
				$operations = $operationManager->getOperationsByIdContrat($contrat->id());	
			}
            //ContratCasLibre Elements
            $contratCasLibreNumber = 
            $contratCasLibreManager->getContratCasLibreNumberByCodeContrat($codeContrat);
            $contratCasLibreElements = "";
            $contratCasLibreTitle = "";
            if ( $contratCasLibreNumber > 0 ) {
                $contratCasLibreTitle = "Informations Supplémentaires";
                $contratCasLibreElements = 
                $contratCasLibreManager->getContratCasLibresByCodeContrat($codeContrat);
            }
            //ReglementPrevu Elements
            $reglementPrevuNumber = 
            $reglementPrevuManager->getReglementNumberByCodeContrat($codeContrat);
            $reglementPrevuElements = "";
            $reglementPrevuTitle = "";
            if ( $reglementPrevuNumber > 0 ) {
                $reglementPrevuTitle = "Dates des réglements prévus";
                $reglementPrevuElements =     
                $reglementPrevuManager->getReglementPrevuByCodeContrat($codeContrat);
            }
		}
		
ob_start();
?>
<style type="text/css">
	p, h2, h4{
        text-align: center;
        font-family : Arial;
        font-weight: 100;
        margin-bottom: 0px;
    }
    h4{
        font-weight : bold;
    }
    h1{
        text-align: center;
        font-family : Arial;
        font-weight: bold;
        font-size : 18px;
        margin-bottom: 0px;
    }
    h2{
        font-size: 20px;
    }
	table {
	    border-collapse: collapse;
	    width:auto;
	    border: 1px solid black;
	}
	td, th{
		padding : 5px;
	}
	
	th{
		background-color: grey;
	}
	table, a{
		text-decoration: none;
	}
</style>
<page backtop="10mm" backbottom="20mm" backleft="10mm" backright="10mm">
    <!--img src="../assets/img/logo_company.png" style="width: 110px" /-->
    <h1>Résumé du Contrat Client - Projet : <?= $projet->nom() ?></h1>
    <p>Imprimé le <?= date('d/m/Y') ?> | <?= date('h:i') ?> </p>
    <hr>
    <div>
        <table style="width: 100%">
            <tr>
                <td style="width:50%"><h4>Informations du client</h4></td>
                <!--td style="width:25%"></td-->
                <td style="width:50%"><h4>Informations du contrat</h4></td>
                <!--td style="width:25%"></td-->
            </tr>
        </table>
		<table style="width: 100%">
			<!--tr>
				<td style="width:25%"><h4>Informations du client</h4></td>
				<td style="width:25%"></td>
				<td style="width:25%"><h4>Informations du contrat</h4></td>
				<td style="width:25%"></td>
			</tr-->
			<tr>
				<td style="width:25%"><strong>Client</strong></td>
				<td style="width:25%"><strong><?= $client->nom() ?></strong></td>
				<td style="width:25%"><strong>Type</strong></td> 
				<td style="width:25%"><strong><?= $typeBien ?></strong></td>
			</tr>
			<tr>
				<td style="width:25%"><strong>CIN</strong></td>
				<td style="width:25%"><strong><?= $client->cin() ?></strong></td>
				<td style="width:25%"><strong>Nom du Bien</strong></td>
				<td style="width:25%"><strong><?= $biens->nom() ?></strong></td>
			</tr>
			<tr>
				<td style="width:25%"><strong>Téléphone 1</strong></td>
                <td style="width:25%"><strong><?= $client->telephone1() ?></strong></td>
				<td style="width:25%"><strong>Superficie</strong></td>
				<td style="width:25%"><strong><?= $biens->superficie() ?>&nbsp;m<sup>2</sup></strong></td>
			</tr>
			<tr>
				<td style="width:25%"><strong>Téléphone 2</strong></td>
                <td style="width:25%"><strong><?= $client->telephone2() ?></strong></td>
				<td style="width:25%"><strong>Etage</strong></td>
				<td style="width:25%"><strong><?= $niveau ?></strong></td>
			</tr>
			<tr>
				<td style="width:25%"><strong>Email</strong></td>
                <td style="width:25%"><strong><?= $client->email() ?></strong></td>
				<td style="width:25%"><strong>Prix de Vente</strong></td>
				<td style="width:25%"><strong><?= number_format($contrat->prixVente(), 2, ',', ' ') ?>&nbsp;DH</strong></td>
			</tr>
			<tr>
				<td style="width:25%"><strong>Adresse</strong></td>
                <td style="width:25%"><strong><?= $client->adresse() ?></strong></td>
				<?php
				if($contrat->avance()!=0 or $contrat->avance()!='NULL' ){
				?>
				<td style="width:25%"><strong>Avance</strong></td>
				<td style="width:25%"><strong><?= number_format($contrat->avance(), 2, ',', ' ') ?>&nbsp;DH</strong></td>
				<?php
				}
				?>
			</tr>
			<tr>
				<td style="width:25%"></td>
				<td style="width:25%"></td>
				<td style="width:25%"><strong>Réglements</strong></td>
				<td style="width:25%"><strong><?= number_format($sommeOperations, 2, ',', ' ') ?>&nbsp;DH</strong></td>
			</tr>
			<tr>
				<td style="width:25%"></td>
                <td style="width:25%"></td>
				<td style="width:25%"><strong>Echeance</strong></td>
				<td style="width:25%"><strong><?= number_format($contrat->echeance(), 2, ',', ' ') ?>&nbsp;DH</strong></td>
			</tr>
		</table>
	</div>
	<br>
	<!-- DATES REGLEMENTS PREVU BEGIN -->
    <?php 
    if ( $reglementPrevuNumber > 0 ) { 
    ?>
    <div>
        <h4><?= $reglementPrevuTitle; ?></h4>
        <br>
        <table>
            <tr>
                <th style="width: 33%">Date Prévu de réglement</th>
                <th style="width: 33%">Echéance</th>
                <th style="width: 33%">Status du réglement</th>
            </tr>
            <?php
            $totalEcheance = 0;
            foreach ( $reglementPrevuElements as $element ) {
                $status = "";    
                $totalEcheance += $contrat->echeance();
                if($element->status()==0){
                    //comparing dates
                    $now = date('Y-m-d');
{'fraction_non_alphanumeric': 0.1993850358729074, 'fraction_numerical': 0.014827468397676803, 'mean_word_length': 2.6553446553446554, 'pattern_counts': {'":': 0, '<': 425, '<?xml version=': 0, '>': 507, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4435987', 'n_tokens_mistral': 5586, 'n_tokens_neox': 4947, 'n_words': 763}