<?php
include "vars.php";

header("Cache-Control: private, no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); 
header("Pragma: no-cache");
if ($p3pcompact != "") {
	header("P3P: CP=\"$p3pcompact\"");
}

$islogged = "";
$islogged = $HTTP_COOKIE_VARS["eDenter_bo_logged"];
$cookiefirma = $HTTP_COOKIE_VARS["eDenter_bo_sign"];

$validato = 1;

if ($islogged != $HTTP_SERVER_VARS["REMOTE_ADDR"]) {
	$validato = 0;
}

$firma = urlencode(md5($adminuser . $adminpass));

if ($firma != $cookiefirma) {
	$validato = 0;
}

if (!$validato) {
	header("Location: bologin.php");
	die();
}

?>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<base target="_self">
<link rel="stylesheet" href="backoffice.css" type="text/css">

<script language="JavaScript">
<!--
function EditOrd(id) {
	document.view.ordid.value = id;
	document.view.submit();
}
function Esci() {
	document.cookie = "eDenter_bo_logged=.; path=/;";
	document.cookie = "eDenter_bo_sign=.; path=/;";
}
//-->
</script>
</head>

<body topmargin="0" leftmargin="4" marginwidth="4" marginheight="0" class="pagina">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
      <p class="sottotitolo">Benvenuto</p>
    </td>
    <td align="right"> 
      <p class="sottotitolo"><a href="bologin.php" onClick="javascript:Esci();">Esci (logout)</a></p>
    </td>
  </tr>
</table>
<p>Di seguito l'elenco degli ordini di cui non sono stati ancora visualizzati 
  i dettagli: </p>
<p><span class="titolo">Nuovi ordini</span> </p>
<form name="view" metohd="GET" action="boordedit.php">
  <input type="hidden" name="pagina" value="0">
  <input type="hidden" name="ordid">
  <table width="100%" border="0" cellspacing="1" cellpadding="2">
    <tr> 
      <td class="intestazione">Codice</td>
      <td class="intestazione" nowrap>Data</td>
      <td class="intestazione" nowrap>Utente</td>
      <td class="intestazione" nowrap>Nome e cognome</td>
      <td class="intestazione" width="100%" nowrap>Ragione sociale</td>
      <td class="intestazione" nowrap>E-mail</td>
      <td class="intestazione">Listino</td>
      <td class="intestazione">Totale</td>
      <td class="intestazione">Stato</td>
      <td>&nbsp;</td>
    </tr>
    <?php
$sql = "SELECT ordini.* , DATE_FORMAT(data, '%d/%m/%Y %H.%i') AS data2, clienti.user FROM ordini LEFT JOIN clienti ON ordini.cliente = clienti.cust_id WHERE ordini.visto = 0 ORDER BY ordini.ID DESC";
$result = mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
	$ordid = $row["ID"];
	$codice = htmlentities($row["codice"]);
	$data = htmlentities($row["data2"]);
	$clid = $row["cliente"];
	$user = htmlentities($row["user"]);
	$fullname = htmlentities($row["nome"]);
	$corp = htmlentities($row["ragione_sociale"]);
	$email = $row["email"];
	$list = $row["listino"] + 1;
	$status = $row["status"];
	$totale = htmlentities(number_format($row["totale_lordo"],2,",","."));
	if ($rowclass == "row1") {
		$rowclass = "row2";
	} else {
		$rowclass = "row1";
	}
?>
    <tr> 
      <td class="<?=$rowclass?>" align="center"> 
        <?=$codice?>
      </td>
      <td class="<?=$rowclass?>" nowrap> 
        <?=$data?>
      </td>
      <td class="<?=$rowclass?>" nowrap> 
        <a href="bocledit.php?clid=<?=$clid?>" target="_self"><?=$user?></a>
      </td>
      <td class="<?=$rowclass?>" nowrap> 
        <?=$fullname?>
      </td>
      <td class="<?=$rowclass?>"> 
        <?=$corp?>
      </td>
      <td class="<?=$rowclass?>"><a href="mailto:<?=$email?>"> 
        <?=$email?>
        </a></td>
      <td class="<?=$rowclass?>" align="center"> 
        <?=$list?>
      </td>
      <td class="<?=$rowclass?>" align="center">
        <?=$totale?>
      </td>
      <td class="<?=$rowclass?>" align="center">
        <?=$statusexpl[$status]?>
      </td>
      <td class="<?=$rowclass?>"> 
        <input type="button" value="Dettagli" class="pulsante" onClick="EditOrd(<?=$ordid?>);">
      </td>
    </tr>
    <?php
}
?>
  </table>
</form>
<form name="help"><input type="hidden" name="pagina" value="help.htm"></form>
</body>
</html>
