<?php
include("dblib.inc");

include("clublib.inc");

checkAdmin();

$message = "";

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">



<html>

<head>

	<title>Cerca Ordini</title>

	<link rel="stylesheet" type="text/css" href="stylesheet.css">

</head>



<body bgcolor="#FFFFFF" link="#504C43" alink="#000000" vlink="#504C43" text="#000000">

<? 

   include("Header.php"); 


include ("langselect.php");
 	$cliente = getRow($customers_table, "Ragione_Sociale", $form['Ragione_Sociale']);
 echo"<p><a href=\"Admin_faiordine.php?form[ID_Cliente]=$cliente[ID_Cliente]\">Cataloghi Cliente $cliente[Ragione_Sociale]</a> | 
<a href=\"clgestord.php?form[Ragione_Sociale]=$cliente[Ragione_Sociale]\">$lang0005</a>";







?>






  <p align="center"><strong><font color="#000000" class="FacetFormHeaderFont"><? echo "$lang0005"; ?> </font></strong></p>
</div>

<table width="80%"  border="1" cellspacing="0" cellpadding="1">
  <tr>
    <td width="7%"><div align="center"><font color="#999999"><strong><? echo "$lang0009"; ?></strong></font></div></td>
    <td width="22%"><div align="center"><font color="#999999"><strong><? echo "$lang0012"; ?></strong></font></div></td>
    <td width="19%"><div align="center"><font color="#999999"><strong><? echo "$lang0015"; ?></strong></font></div></td>
    <td width="6%"><div align="center"><font color="#999999"><strong>Qt.</strong></font></div></td>
    <td width="8%"><div align="center"><font color="#999999"><strong><? echo "$lang0011"; ?></strong></font></div></td>
    <td width="10%"><div align="center"><font color="#999999"><strong><? echo "$lang0049"; ?></strong></font></div></td>

  </tr>


  <?php
include "init3.php";
     include "databa3.php";
	 
	if (strlen($_POST['keywords'])<1) { 
    echo "<p>ATTENZIONE!!!! Devi inserire almeno 1 caratteri</p>";
	exit();
	} 
    if (!empty($_POST['keywords'])) {
      $searchStr = $_POST['keywords'];
      if (ereg("^[a-zA-Z0-9.-]+$", $searchStr)) {
        $db = connect();
        if ($db) {
          print "<p class=\"whiteTxt\">Risultati per \"$searchStr\"</p><br>";
          $keys = explode(" ", $searchStr);

          for ($x = 0; $x < count($keys); $x++) {
            $querystr = "SELECT * FROM " . $db_table . " WHERE (((Data_Ordine = \"$keys[$x]\" AND ID_Cliente = \"$last_name\" ) OR (Data_Ordine LIKE \"%$keys[$x]%\" AND ID_Cliente = \"$last_name\")))";
            $result = mysql_query($querystr,$db);
            if ($frow = mysql_fetch_array($result)) {
               $found = true;
               do {
			  
               	print "<tr>";
	
	print "<td>".$frow["ID_Ordine"]."</td>";	
    print "<td>".$frow["Ragione_Sociale"]." ".$frow["Cognome"]."&nbsp;</td><td class=\"FacetDataTD\">".formatDate($frow["Data_Ordine"])." &nbsp;</td><td class=\"FacetDataTD\">".$frow["Protocollo"]." &nbsp;</td><td class=\"FacetDataTD\">".$frow["Oggetto"]." &nbsp;</td>";
	print "<td>".$frow["Prezzo"]." &nbsp;</td>";
	
	
 
	print "</tr>";

	
$Totale =$Totale+$frow["Prezzo"]*$frow["Protocollo"];
	
               } while ($frow = mysql_fetch_array($result));
			   
            } 
            
          }
          if (!$found) {
            print("<p class=\"whiteTxt\">Nessun risultato.<br>");
            
          }
          
          
            
        }
        else {
          print("<p class=\"whiteTxt\">Il database non è in funzione.</p>");
        }
      }
      else {
         print("<p class=\"whiteTxt\">Errore ! Hai inserito dei caratteri riservati..</p>");
       }
    }
    else {
       print("<p class=\"whiteTxt\">Deci inserire una parola chiave.</p>");
    }
  
 



  
?>
</table>
<? echo "<p>Tot. Euro $Totale</p>"; ?>
</body>
</html>


