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

$query = "SELECT * FROM sd_ordini WHERE ID_Ordine = '$ID_Ordine'";
$result = mysql_db_query("$Database", $query); 
if ($result) { 
while ($r = mysql_fetch_array($result))
$Ragione_Sociale = $r["Ragione_Sociale"];

if (isset($actionflag) && $actionflag=="Delete")
	{
		$result = delRow($orders_table, "ID_Ordine", $ID_Ordine);
		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 ;
$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);
		
		// faccio qualche operazione sulla data
		// converto la data in Unix timestamp
		$ts_Data_Ordine = strtotime ($form['Data_Ordine']);
		
		// ricavo giorno, mese, anno
		$giorno = strftime("%d", $ts_Data_Ordine);
		$mese = strftime("%m", $ts_Data_Ordine);
		$anno = strftime("%Y", $ts_Data_Ordine);
		// print $giorno ."-".$mese."-".$anno  ;
		// print strftime ($form['Data_Ordine']);
		
		}
		
		}
if (!($form['Status'] == "FATTURATO"))
	$message = "$lang0008";


		
} 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="Delete">

<input type="Hidden" name="ID_Ordine" value="<? print $ID_Ordine; ?>">
<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]" disabled value="<?php print $form["Protocollo"] ?>" maxlength="30" size="20" class="FacetInput">&nbsp;</td>

  </tr>
   <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>

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

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

  </tr>
  
  <tr>

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

    <td class="FacetDataTD"><select name="form[ID_Cliente]" disabled  class="FacetSelect">

	

<?php 
// imposto come selzionato il cliente che e' nel database
print "<option value=\"".$form['ID_Cliente']."\" selected>".$form['Ragione_Sociale']."</option>\n";
 ?>
 
 <option value=""></option>
 
 <?php 
// recupero tutti i clienti per la select del form


$result = dynQuery('*', $customers_table);
 


while ($a_row = dbms_fetch_array ($result))

	{

	print "<option value=\"".$a_row['ID_Cliente']."\">".$a_row['Ragione_Sociale']." - ".$a_row['Cognome']."</option>\n";

	}

	?>

	 </select></td>

  </tr>

 <tr>

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

    <td colspan="2" class="FacetDataTD">
	<select name="form[Tipo_Pagamento]" disabled  class="FacetSelect">
		<?php 
		// imposto come selezionato il tipo pagamento che e' nel database
		print "<option value=\"".$form['Tipo_Pagamento']."\" selected>".$form['Tipo_Pagamento']."</option>\n";
		 ?>	
   	</select>

	</td>

  </tr>



 
   <tr>

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

    <td class="FacetDataTD"><input type="text" name="form[Prezzo]" disabled  value="<?php print $form["Prezzo"] ?>" maxlength="20" size="10" class="FacetInput">&nbsp;</td>

  </tr>
<tr>
    <td class="FacetFieldCaptionTD"><? print $lang0015; ?></td>&nbsp;</td>
  <td class="FacetDataTD">
  <SELECT NAME="giorno" disabled >
<?php 
// imposto come selezionato il giorno che e' nel database
print "<option value=\"".$giorno."\" selected>".$giorno."</option>\n";
 ?>	  
 </SELECT>

 <SELECT name="mese" disabled >
 <?php 
// imposto come selezionato il mese che e' nel database
// devo prima pero' recuperare il nome del mese
switch ($mese)
	{
	case "01";
		$nome_mese = "$lang0016";
		break;
	case "02";
		$nome_mese = "$lang0017";
		break;	
	case "03";
		$nome_mese = "$lang0018";
		break;	
	case "04";
		$nome_mese = "$lang0019";
		break;	
	case "05";
		$nome_mese = "$lang0020";
		break;	
	case "06";
		$nome_mese = "$lang0021";
		break;	
	case "07";
		$nome_mese = "$lang0022";
		break;	
	case "08";
		$nome_mese = "$lang0023";
		break;	
	case "09";
		$nome_mese = "$lang0024";
		break;	
	case "10";
		$nome_mese = "$lang0025";
		break;	
	case "11";
		$nome_mese = "$lang0026";
		break;	
	case "12";
		$nome_mese = "$lang0027";
		break;	
	}	
	
print "<option value=\"".$mese."\" selected>".$nome_mese."</option>\n";
 ?>	  
 </SELECT>&nbsp;
   <SELECT name="anno" disabled >
   <?php 
// imposto come selezionato l'anno che e' nel database
print "<option value=\"".$anno."\" selected>".$anno."</option>\n";
 ?>	  
    </SELECT>&nbsp;
 </td>
</tr>

 <td colspan="2" align="right" nowrap class="FacetFooterTD">
<?
if (!($form['Status'] == "FATTURATO"))
	{
     print " <input name=\"Insert\" type=\"submit\" value=\"Delete\" class=\"FacetButton\">";
	}
?>

    </td>

</table>

</form>



</body>

</html>

