<?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");



if (isset ($actionflag))

	{
	// $form['Prezzo'] = formatNumber($form['Prezzo']);
	// exit;
	//controllo sull'esistenza dei campi obbligatori

	
	
	

	//controllo che l'importo sia stato inserito correttamente
	//  if (!is_numeric ($form["Prezzo"]))
	//	$message .= "L'importo deve essere inserito senza virgole e con il punto tra gli euro e i centesimi, es. 1250.95 <br>";
	
	// controllo che la data sia corretta	
	  



	if ($message == "")

		{
		// se tutto ok aggiorno l'ordine ma prima faccio qualche operazione sulle variabili
		// formatto l'importo
		// $form["Prezzo"] = formatEuro($form["Prezzo"]);
		
		
		
		// inserisco il progressivo fattura
		$form['Progressivo_Fattura'] = "";
		
		// recupero i dati del cliente
		$form = array_merge ($form, getRow($customers_table, "ID_Cliente", "Ragione_Sociale", $form['ID_Cliente'], $form['Ragione_Sociale']));
		
					
		$result = orderUpdate($ID_Ordine, $form['Protocollo'], $form['Oggetto']);
		
		if (! $result )

			die (" Errore di inserimento: ".mysql_error());

		else 
			{

			$message .= "$lang0028";	
			include ("config.php");				
mysql_connect("$hhost","$login","$pass") or die ("Problem connecting to DataBase"); 
$query = "SELECT * FROM $connect where oggnom='$oggnom' "; 
$result = mysql_db_query("$dbname", $query); 
if ($result) {
while ($r = mysql_fetch_array($result)) {

$quant = $r["quant"];
}

}

$tot =	$quant + $quantagg - $form['Protocollo'];
$query = "update $connect  set 
quant='$tot' where 
oggnom='$oggnom'";
$result = mysql_db_query("$dbname", $query);



			}
		}

	}

if (! isset($actionflag))

		{

		// recupero i dati dell'ordine dal db
		
		$form = getRow($orders_table, "ID_Ordine", $ID_Ordine);
		
		
		
		}
} else {
echo "Prego effettuare il login <a href=\"contenuti.php\"> Qui<br>
&copy;Bloghosteria.com<br>
</a>";
}
?>

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



<html>

<head>

	<title></title>



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

</head>



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



<form method="post" action="<?php print $PHP_SELF;?>" name="pws_clienti">

<!-- flag di invio del modulo -->

<input type="Hidden" name="actionflag" value="upd_ordine">

<input type="Hidden" name="ID_Ordine" value="<? print $ID_Ordine; ?>">
<input type="Hidden" name="form[Status]" value="<? print $form['Status'] ?>">
<div align="center"><font class="FacetFormHeaderFont"> <? print "$lang0009 $ID_Ordine"; ?></font></div>

<table border="0" cellpadding="3" cellspacing="1" class="FacetFormTABLE" align="center">

  <!-- BEGIN Error -->

  <tr>

    <td colspan="2" class="FacetDataTD">

	<?php

	if (! $message == "")

	{

	print "$message";

	}

	?>

	</td>

  </tr>

  <!-- END Error -->

  
  
  <tr>

    <td class="FacetFieldCaptionTD"><? print "$lang0010"; ?></td>

    <td class="FacetDataTD"><input type="text" name="form[Protocollo]" value="<?php print $form["Protocollo"] ?>" maxlength="6" size="6" class="FacetInput">
    &nbsp;</td>
 <input type="hidden" name="connect" value="<?php print $form["Cat_Ogg"] ?>" maxlength="100" size="30" class="FacetInput">
 <input type="hidden" name="quantagg" value="<?php print $form["Protocollo"] ?>" maxlength="6" size="6" class="FacetInput">
 <input type="hidden" name="oggnom" value="<?php print $form["Oggetto"] ?>" maxlength="100" size="30" class="FacetInput"> 
  </tr>

    <tr>

    <td class="FacetFieldCaptionTD"><? print "$lang0011"; ?></td>

    <td class="FacetDataTD"><input type="hidden" name="form[Oggetto]" value="<?php print $form["Oggetto"] ?>" maxlength="100" size="30" class="FacetInput"><?php print $form["Oggetto"] ?></td>

  </tr>
  
 
  

 <td colspan="2" align="right" nowrap class="FacetFooterTD">

      <!-- BEGIN Button Insert --><input name="Insert" type="submit" value="Update" class="FacetButton">
      <!-- END Button Insert -->



    </td>

</table>

</form>




</body>

</html>

