<!doctype html>
<html><head>
<meta charset="UTF-8">
<title>DEVIS</title>

	

	<link rel="stylesheet" href="textegencon.css" media="all" />
	<link href="https://fonts.googleapis.com/css?family=Noto+Sans" rel="stylesheet">
	<script src="/js/jquery-2.1.0.min.js"></script>
	<script src="js/jquery-ui.js"></script>
	<script src="js/jquery.ui.touch-punch.js"></script>
	<script src="/js/moment.js"></script>
	<script src="/js/jquery.redirect.js"></script>
	<script src="js/jquery.ui.touch-punch.js"></script>
	<!-- <script src="/js/swap.js"></script> -->
	
	</head>
<body onLoad="calculload()">


	<div class="gencont">
	
		<div id="logo" onclick="myFunction() "><img src= "logofac1.png" width="794"></div>	
		<div id="logo2" ><img src= "logofac3.png" width="487" height: "146"></div>
		<div id="logo3" ><img src= "logofac2.png" width="307" height: "26"></div>
	
	  <div id="company">
		<h2 class="name">Ypsoroof - Ipsotoit</h2>
        <h2 class="name2">135 rue montavaux, 7080, Frameries </h2>
        <h2 class="name2">065/793325. Entr.:BE0443870515</h2>
		  <h2 class="name2">Banque CPH IBAN:BBE75</h2>
		   <h2 class="name2">Compte: BE92 1262 1506 3723</h2>
      <!--  <div><a href="mailto:info@ypsoroof.com">info@ypsoroof.com</a></div> -->
      </div>
		 	
	
	
		<?php

		$NumeroIndexDevisP=$_POST['dnumdevis'];
		$NumeroIdxClient=$_POST['didxcli'];
	//	print "<br>".$NumeroIndexDevisP;	
	//	print "<br>".$NumeroIdxClient;	

// on se connecte à notre base pour devis

$servername = "localhost:8889";
$username = "root";
$password = "root";
$dbname = "devis";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
	
				//	 $sql = "SELECT * FROM tete";
$sql = "SELECT * FROM tete WHERE idx=".$NumeroIndexDevisP." ";
//$sql = "SELECT * FROM tete WHERE idx=".intval($_POST['idxcli'])." ";
//print "<br>".$sql;	
			// print "<br>".$sql;	
			 
					// $sql = "UPDATE\n". "  `data`\n"." SET\n". " societe = \'testoooyeahhh\'\n". "WHERE\n". " id = 3";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
		
$NUM=$row["num"];
$IDX=$row["idx"];
$DATE=$row["date"];
$OBJETT=$row["objet"];
$IDXCLI=$row["idxcli"];
$MEMO=$row["memo"];
$ETATC=$row["etat"];		
		$NumeroIdxClient=$row["idxcli"];;
$CHANTIER=$row["chantier"];
$TVA=$row["tva"];
$BANQUE=$row["banque"];
$REMARQUE=$row["remarque"];

    } 
    
	
	} else {
   // echo "0 results";
}

//$sql = "INSERT INTO data (societe,nom1,nom2,nom3,nom4,nom5,titre,ac1,ac2,o1,o2,o3,mail,tel,gsm,pub,jour)
//VALUES ('$SOC' , '$NOM1', '$NOM2', '$NOM3', '$NOM4', '$NOM5', '$TITRE', '$AC1', '$AC2', '$O1', '$O2', '$O3', '$MAIL', '$TEL', '$GSM', '$PUB', //'$today')";


$conn->close();
		
		?>
	
		
<?php		
		
				
		// on se connecte aux client ******************************************
		
$SOC=" ";
$NOM1=" ";
$NOM2=" ";
$NOM3=" ";
$NOM4=" ";
$NOM5=" ";
$TITRE=" ";
$PUB=" ";
$AC1=" ";
$AC2=" ";
$O1=" ";
$O2=" ";
$O3=" ";
$MAIL=" ";
$GSM=" ";
$TEL=" ";
$SIDXCLI=" ";

// on se connecte à notre base pour client

$servername = "localhost:8889";
$username = "test";
$password = "test";
$dbname = "Clients";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
					 

$SIDXCLI = htmlentities($_POST['idxcli']);
	// print "dans la boite<br>";

    
	

					 $sql = "SELECT * FROM data";
$sql = "SELECT * FROM data WHERE id=".$NumeroIdxClient." ";
//$sql = "SELECT * FROM data WHERE id=".intval($_POST['idxcli'])." ";
//print "<br>".$sql;		
		
					// $sql = "UPDATE\n". "  `data`\n"." SET\n". " societe = \'testoooyeahhh\'\n". "WHERE\n". " id = 3";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
		
$SOC=$row["societe"];
$NOM1=$row["nom1"];
$NOM2=$row["nom2"];
$NOM3=$row["nom3"];
$NOM4=$row["nom4"];
$NOM5=$row["nom5"];
$TITRE=$row["titre"];
$PUB=$row["pub"];
$AC1=$row["ac1"];
$AC2=$row["ac2"];
$O1=$row["o1"];
$O2=$row["o2"];
$O3=$row["o3"];
$MAIL=$row["mail"];
$GSM=$row["gsm"];
$TEL=$row["tel"];
$SIDXCLI =$row["id"];
        //echo "Soc: " . $row["societe"]. " - Nom: " . $row["nom1"]. " - idx: " . $row["id"]. " " . $row["nom2"]. "<br>";
		//echo "Soc: " . $row["societe"]. " - Nom: " . $row["nom1"]. "  " . $row["nom2"]. "<br>";
    } 
    
	
	} else {
   // echo "0 results";
}

//$sql = "INSERT INTO data (societe,nom1,nom2,nom3,nom4,nom5,titre,ac1,ac2,o1,o2,o3,mail,tel,gsm,pub,jour)
//VALUES ('$SOC' , '$NOM1', '$NOM2', '$NOM3', '$NOM4', '$NOM5', '$TITRE', '$AC1', '$AC2', '$O1', '$O2', '$O3', '$MAIL', '$TEL', '$GSM', '$PUB', //'$today')";


$conn->close();
					 
		
		
		
	?>			
	
	 
        
		  <div id="client">
			
        <!--   <div class="to">CLIENT:</div> -->
            <h2 class="name"><?php echo $SOC ?></h2>
			<div class="address"><?php echo $TITRE.$NOM1 ?></div>
            <div class="address"><?php echo $NOM2 ?></div>
			<div class="address"><?php echo $NOM3 ?></div>
			<div class="address"><?php echo $NOM4?></div>
			<div class="address"><?php echo $NOM5?></div>
	
	
	
	
		
		   </div>
		
		  <?php
				  switch ($ETATC) {
    case 0:
        echo " <div id='etatcom' style='display:none'>  ";
        break;
    case 1:
        echo " <div id='etatcom' style='display:block'>  En commande";
        break;
    case 2:
        echo " <div id='etatcom' style='display:block'>  En facturation";
        break;
	case 3:
        echo " <div id='etatcom' style='display:block'>  Clôturée";
	case 4:
       echo "<div id='etatcom' style='display:block'>  Brouillon";
        break;
}
		?>	  </div>
				  
				  
						 
	<div style="clear:both"></div>
        
			 
			  <div id="invoice"><br>
         Devis N°<?php echo $NUM ?>
				 
          <div id="datestyle" class="date" style="border-bottom: 1px solid black; border-left: 4px  solid #EFD61E; max-width:300px" contenteditable="true" ><?php echo $DATE ?> </div>
		 
		</div>  
	<div style="clear:both"></div>
			
	
		
	<div style="clear:both"></div>

	
	
	
	
	
	
		<table id="table-2"  cellspacing="0" cellpadding="-1" width="794px" border="0" valign="top" style="border-collapse: collapse;" >
		
		 <tbody id="items_table">
			 
		
			 
	


		
	
	<br>
	<p></p>
  
		
	
	
  

	



<script>
		
		//alert("ok");

		//$( "div.rest" ).html('?php echo $REMARQUE ?>') ;	
	
	</script>	

<div class="rest" contenteditable="true">
	
	<?php 
	$final=" ".$TITRE.$NOM1;
	$posclient = strpos($REMARQUE, $final);
										 
	if ($posclient > 0) {
	$REMARQUE=$REMARQUE;								 
	} else { $REMARQUE=str_replace('Le client',' Le client,'.$final,$REMARQUE);	} 
										 
	echo $REMARQUE ?> 
	
	


	
	
	
	
<br>
	
</div>

	

</body>		

</html>
