<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Liste item recherhe</title>
<!--    <link rel="stylesheet" href="stylecli.css" media="all" /> -->
      	<script src="js/jquery-3.3.1.min.js"></script>
     <link rel="stylesheet" href="css/bootstrap.css" media="all" />
      <script src="/js/bootstrap.min.js"></script>
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  </head>
  <body >
    
    </header>
    <main>
    
		
   
			
<?php
			//	print "<br>".$_POST['item'];	
 				
                  
            // *********************    connection clients pour recherche le nom*************************
		
								$servername1n = "localhost:8889";
								$username1n = "root";
								$password1n = "root";
								$dbname1n = "devis";

								// Create connection
								$conn1n = new mysqli($servername1n, $username1n, $password1n, $dbname1n);
								// Check connection
								if ($conn1n->connect_error) {
								die("Connection failed: " . $conn1n->connect_error);
								} 

			
								$sql1 =  "SELECT * FROM corps INNER JOIN tete ON numidxdevis=idx INNER JOIN clients.data ON idxcli=id WHERE etat='1' and des LIKE  '%".$_POST['item']."%'";
								//print "<br>".$sql1;	
		 
								$result1n = $conn1n->query($sql1);
		
								if ($result1n->num_rows > 0) {
    							// output data of each row
								while($row = $result1n->fetch_assoc()) {
								//print "echo <br>".$row1['societe']."  ".$row1['nom1'];
									$tempsoc=$row['societe'];
									$tempnom1=$row['nom1'];
                                    $IDXCLISEARCH=$row['id'];
							
            
            
            


				
$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"];
$DESCRIPTIONLIGNE=$row["des"];
$QTY=$row["qt"];
$UMES=$row["um"];
	
									
	
									
		
		  $directory = "photos/".$tempnom1."/tmb/";
        $files = scandir ($directory);
        $firstFile = $directory . $files[2];// because [0] = "." [1] = ".." 
        $supported_file = array('jpg','png','jpeg');
 
        $ext = strtolower(pathinfo($firstFile, PATHINFO_EXTENSION));
        if (in_array($ext, $supported_file)) {
            
            $firstFile = $directory . $files[2];
            }else{
            $firstFile = $directory . $files[3];}
        
      print"  <div class='container'>";
        print"<div class='card'>";
        print"<div class='card-body'>";
        
              print"<div style='height:150px;width:150px;background-color:#dedddd;float:right;background-image:url(&quot;".$firstFile."&quot;);'>";
        print "<form method='post' action='picviewcar.php' name='demande'>";
        print "<button class='btn btn-dark fa fa-image rounded-0' name='dnumdevis' type='submit' value='". $tempnom1."'></button>";
		print "</form>";
        print"</div>";
        
        print " <div style='float:left;width:80%;'>";
            print"    <h4>Devis : ". $NUM."</h4>";
            print"<h6 class='text-muted mb-2'>".$tempsoc."  ".$tempnom1." ".$row1['nom1']."</h6>";
        print" <p>". $OBJET. " <br> ".$DATE."</p>";
		 print" <p>".$DESCRIPTIONLIGNE. "  ".$QTY." ".$UMES."</p>";
         print "<form method='post' action='texteditcom.php' name='demande'>";
        print "<button class='btn btn-info' name='dnumdevis' id='liensubmit2' type='submit' value='". $IDX."'>Vers commande</button></form>";
        
        print"</div>";
        print"</div>";
        print"<div class='card-footer'></div>";
        print"</div>";
        print"</div>";
        
        
            
		//    print "<tr>";
        //    print " <td class='no'>". $NUM."</td>";
         
		//    print "<form method='post' action='texteditcom.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></td>";print "</form>";
		
		//    print "<form method='post' action='texteditcom.php' name='demande'>";
        //    print "<td class='unit'><button name='dnumdevis' id='liensubmit2' type='submit' value='". $IDX."'>Suivant</button></td>";
		
		//	print "</form>";
        //
          //  print "</tr>";

    } 
    

            
            
            
            
          		    } 




$conn1n->close();
					  
            
		

		?>	
			
     
     
    </main>
  
  </body>
</html>