<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Facturation bon de commande</title>
    <link rel="stylesheet" href="stylecli.css" media="all" />
  </head>
  <body >
    
    </header>
    <main>
      <div id="details" class="clearfix">
        <div id="client">
          <div class="to"><h1><br>
          Bon de commande pour facturation<br></h1></div>
          <h2 class="name"></h2>
          <div class="address"></div>
          <div class="email"></div>
        </div>
        <div id="invoice">
          <h1></h1>
          <div class="date"></div>
          <div class="date"></div>
        </div>
      </div>
		
		
      <table border="0" cellspacing="0" cellpadding="0">
        <thead>
          <tr>
            <th class="no">####</th>
            <th class="desc">DESCRIPTION</th>
            <th class="unit"> </th>
          
          </tr>
        </thead>
		  
		  
        <tbody>
			
<?php

// 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 WHERE etat='2'";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    // output data of each row
    while($row = $result->fetch_assoc()) {
        //echo "Soc: " . $row["societe"]. " - Nom: " . $row["nom1"]. " - idx: " . $row["id"]. " " . $row["nom2"]. "<br>";
		//echo "Soc: " . $row["societe"]. " - Nom: " . $row["nom1"]. "  " . $row["nom2"]. "<br>";
		
				$NUM=$row["num"];
$IDX=$row["idx"];
$DATE=$row["date"];
$OBJET=$row["objet"];
$IDXCLI=$row["idxcli"];
$MEMO=$row["memo"];
$NumeroIdxClient=$row["idxcli"];;
$CHANTIER=$row["chantier"];
$TVA=$row["tva"];
$BANQUE=$row["banque"];
$REMARQUE=$row["remarque"];
$ETATC=$row["etat"];
$MONTANTHTVA=$row["montant"];
		// *********************    connection clients *************************
		
								$servername1 = "localhost:8889";
								$username1 = "root";
								$password1 = "root";
								$dbname1 = "Clients";

								// Create connection
								$conn1 = new mysqli($servername1, $username1, $password1, $dbname1);
								// Check connection
								if ($conn1->connect_error) {
								die("Connection failed: " . $conn1->connect_error);
								} 

			
								$sql1 = "SELECT * FROM data WHERE id=".$NumeroIdxClient." ";
								//print "<br>".$sql1;	
		 
								$result1 = $conn1->query($sql1);
		
								if ($result1->num_rows > 0) {
    							// output data of each row
								while($row1 = $result1->fetch_assoc()) {
								//print "echo <br>".$row1['societe']."  ".$row1['nom1'];
									$tempsoc=$row1['societe'];
									$tempnom1=$row1['nom1'];
									    } 
    
	
									} else {
										// echo "0 results";
									}




$conn1->close();
									
									
		
		
		
			    print "<tr>";
            print " <td class='no'>". $NUM."</td>";
            print "<form method='post' action='textefaccrea.php' name='demande'>";
		    print "<td class='desc'><button name='dnumdevis' id='liensubmit' type='submit' value='". $IDX."'>".$tempsoc."  ".$tempnom1." ".$row1['nom1']."<br> ". $OBJET. " <br> ".$DATE."</button>";print "</form>";
		
			 print "<form method='post' action='textefaccrea.php' name='demande'> Montant : ".$MONTANTHTVA."</td>";
            print "<td class='unit'><button name='dnumdevis' id='liensubmit2' type='submit' value='". $IDX."'>Suivant</button></td>";
		
			print "</form>";
        
            print "</tr>";
		
		
        
          
    } 
    
	
	} else {
    echo "0 results";
}




$conn->close();
			
		
	

		?>	
			
     
        </tbody>
        
      </table>
     
      <div id="notices">
        <div><br></div>
        <div class="notice"><br></div>
      </div>
    </main>
    
  </body>
</html>