<?

include("dblib.inc");

include("clublib.inc");

checkAdmin();

$message = "";

if (isset ($actionflag) && ($actionflag == "Delete"))

	{
	
	$result = delRow($mov_table, "ID_Movimento", $ID_Movimento);
		header("Location: Admin_Movimenti.php");
		exit;	
	}

if (! isset($actionflag))

		{
		// inizializzo l'array associativo del modulo

		// recupero i dati dell'ordine dal db
		
		$form = getRow($mov_table, "ID_Movimento", $ID_Movimento);
		
		if (!($form['Entrate'] == 0))
			{
			$Entrata = "SI";
			$form['Importo'] = $form['Entrate'];
			}
		else
			{
			$Entrata = "NO";
			$form['Importo'] = $form['Uscite'];
			}
		
		// converto la data in Unix timestamp
		$ts_Data_Valuta = strtotime ($form['Data_Valuta']);
		
		// ricavo giorno, mese, anno
		$giorno = strftime("%d", $ts_Data_Valuta);
		$mese = strftime("%m", $ts_Data_Valuta);
		$anno = strftime("%Y", $ts_Data_Valuta);
		$message = "Sei sicuro di voler rimuovere il movimento?";
		}

?>

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



<html>

<head>

	<title>Cancella Movimento</title>



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

</head>



<body class="BODY">

<? 

include("Header.php"); 

?>

<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_Movimento" value="<? print $ID_Movimento ?>">
<div align="center"><font class="FacetFormHeaderFont">Cancella Movimento</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">Data Valuta &nbsp;</td>

    <td class="FacetDataTD" >
		 <? 
		 // inserisco il select box per il campo data
		   $select_data = new selectDate("giorno", "mese", "anno");
		   $select_data -> daySelected($giorno); 
		   $select_data -> monthSelected($mese); 
		   $select_data -> yearSelected($anno); 	  
		   $select_data -> output();
		 ?>
	</td>

  </tr>
 <tr>

 	<td class="FacetFieldCaptionTD">Tipo Pagamento * &nbsp;</td>

    <td class="FacetDataTD">
		 <? 
		 // inserisco il select box per il campo tipo pagamento
		   $select_pagamento = new selectPagamento();
		   $select_pagamento -> addSelectName("form[Tipo_Pagamento]");
		   $select_pagamento -> addSelected($form["Tipo_Pagamento"]);
		   $select_pagamento -> output();
		 ?>
	</td>
  </tr>	
	
 <tr>    
	  <td class="FacetFieldCaptionTD">Banca / Cassa *</td>&nbsp;</td>
	  <td class="FacetDataTD">
			<?
			$selectBank = new selectBank("form[ID_Banca]");
			$selectBank -> addSelected($form['ID_Banca']);
			$selectBank -> output();
			?>
	  </td>
 </tr>

  
 <tr> 
	<td  class="FacetFieldCaptionTD">Entrata * &nbsp;</td>
	<td class="FacetDataTD"><input type="Radio" name="Entrata" value="SI" 
	<?
	$checked = "";
	if ($Entrata == "SI")
		{
		$checked = "checked";
		print "checked";
		}
	?>
	
	></td>
 </tr>
 
 <tr>  	
	<td  class="FacetFieldCaptionTD">Uscita * &nbsp;</td>
 
 	<td class="FacetDataTD"><input type="Radio" name="Entrata" value="NO" 
	<?
	$checked = "";
	if ($Entrata == "NO")
		{
		$checked = "checked";
		print "checked";
		}
	?>

	></td>
 </tr>   
 	
 <tr>

    <td class="FacetFieldCaptionTD">Descrizione &nbsp;<br>(Doc. di riferimento,<br> Codice Assegno, CRO del Bonifico etc.)</td>

	<td class="FacetDataTD"><textarea name="form[Descrizione]" cols="40" rows="5" class="FacetInput"><? print $form['Descrizione'] ?></textarea></td>

  </tr>
  
 <tr>

    <td class="FacetFieldCaptionTD">Cliente &nbsp;</td>

    <td class="FacetDataTD"> 
		<? 
		 // inserisco il select box per i clienti
		   $cliente = new selectCliente("form[ID_Cliente]");
		   $cliente -> addSelected($form['ID_Cliente']); 
		   $cliente-> output();
		 ?>

	</td>

  </tr>

 <tr>

    <td class="FacetFieldCaptionTD">Fornitore &nbsp;</td>

    <td class="FacetDataTD"> 
	<? 
	 // inserisco il select box per i clienti
	   $fornitore = new selectFornitore("form[ID_Fornitore]");
	   $fornitore -> addSelected($form['ID_Fornitore']); 
	   $fornitore -> output();
	 ?>

	</td>

  </tr>


 <tr>

    <td class="FacetFieldCaptionTD">Importo * &nbsp;</td>

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

  </tr>

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

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



    </td>

</table>

</form>



</body>

</html>

