<?php
session_start();
if ($first_name>=1){
echo "Prego effettuare il login <a href=\"/contenuti.php\"> Qui<br>
&copy;Bloghosteria.com<br>
</a>";
}
 elseif  ( empty( $first_name ) ) {
?> Prego effettuare il login <a href="/contenuti.php"> Qui<br>
&copy;Bloghosteria.com<br>
</a>
<?php
} elseif ($first_name==$_SESSION['first_name']) { 
include ("langselect.php");  
include ("Config2db.php");
echo "$lang0003, 
". $_SESSION['last_name'] ." <a href=logout.php> Logout</a> 
<style type=\"text/css\">

a:link, a:visited {
	color: #009933; text-decoration: none;
	font-weight: bold;
}

a:hover {
	color: #ff6600;	text-decoration: none;
	font-weight: bold;	
}
</style>
<p><a href=\"sample.php?last_name=$last_name\">$lang0004</a> | 
<a href=\"clgestord.php?Ragione_Sociale=$last_name\">$lang0005</a> |
<a href=mailto:$emailwebm>$lang0006</a> | 
<a href=\"gestpag.php?Ragione_Sociale=$last_name\">$lang0007</a></p>";



include("dblib.inc");

include("clublib.inc");

} else {
echo "Prego effettuare il login <a href=\"contenuti.php\"> Qui<br>
&copy;Bloghosteria.com<br>
</a>";
}

?>






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

<table width="100%"  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>
    <td width="21%"><div align="center"><font color="#999999"><strong>Status</strong></font></div></td>
    <td width="7%"><div align="center"><font color="#999999"><strong><? echo "$lang0050"; ?></strong></font></div></td>
  </tr>


  <?php
include "init3.php";
     include "database.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 Ragione_Sociale = \"$last_name\" ) OR (Data_Ordine LIKE \"%$keys[$x]%\" AND Ragione_Sociale = \"$last_name\")))";
            $result = mysql_query($querystr,$db);
            if ($frow = mysql_fetch_array($result)) {
               $found = true;
               do {
			  
               	print "<tr>";
	if (($frow['Status'] == "$lang0149"))
		print "<td><a href=\"Admin_Upd_Ordine.php?ID_Ordine=".$frow["ID_Ordine"]."\">".$frow["ID_Ordine"]."</a> &nbsp;</td>";
	else 
	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 "<td>".$frow["Status"]." &nbsp;</td>";
	if (!($frow['Status'] == "$lang0149"))
	print "<td class=\"FacetDataTD\">&nbsp;</td>";
	else
	print "<td><a href=\"Admin_Del_Ordine.php?ID_Ordine=".$frow["ID_Ordine"]."\">$lang0050</a></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>"; ?>


