<?php
	if( $docroot == '' ){
		die( _("Accesso negato!") );
	}
	
	$name="Scadenzario";
	//Mostro le righe 
	$totale = 0.00;
	$totale_imponibile = 0.00;
	

	$q_art = "SELECT * FROM `co_scadenziario_pagamenti` WHERE iddocumento='".$records[0]['iddocumento']."'";
	$rs_art = $dbo->fetchArray( $q_art );
	$tot_art = sizeof($rs_art);
	$imponibile_art = 0.0;
	$iva_art = 0.0;

	if( $tot_art>0 ){
		for( $i=0; $i<$tot_art; $i++ ){
			echo "<tr><td align='left'>\n";
			echo date( "d/m/Y", strtotime($rs_art[$i]['data_emissione']) )."\n";
			
			echo "</td>\n";
			echo "<td class='text-left'>\n";
			echo number_format( $rs_art[$i]['ricevuto'], get_var("Cifre decimali"), ",", "." )." &euro;\n";
			echo "</td>\n";


			//Banca
			echo "<td class='text-left'>\n";
			echo $rs_art[$i]['banca']."\n";
			echo "</td>\n";


			//Note
			echo "<td class='text-left'>\n";
			echo $rs_art[$i]['note']."\n";
			echo "</td>\n";

			//Possibilità di rimuovere una riga 
			echo "<td class='text-center'>\n";
			echo "	</form><form action='".$rootdir."/editor.php?id_module=".$modules_info[$name]['id']."&id_record=".$id_record."' method='post' id='delete-form-".$rs_art[$i]['id']."' role='form'>\n";
			echo "		<input type='hidden' name='backto' value='record-edit'>\n";
			echo "		<input type='hidden' name='id_record' value='".$id_record."'>\n";
			echo "		<input type='hidden' name='idriga' value='".$rs_art[$i]['id']."'>\n";				
			echo "		<input type='hidden' name='op' value='unlink_acconto'>\n";	
			echo "		<div class='input-group-btn'>\n";
				echo "			<a class='btn btn-xs btn-warning' title='Modifica questa riga...' onclick=\"launch_modal( 'Modifica riga', '".$rootdir."/modules/scadenzario/edit_riga.php?iddocumento=".$id_record."&idriga=".$rs_art[$i]['id']."&dir=".$dir."', 1 );\"><i class='fa fa-edit'></i></a>\n";														
				echo "			<a class='btn btn-xs btn-danger' title='Rimuovi questa riga...' onclick=\"if( confirm('Rimuovere questo pagamento ricevuto?') ){ $('#delete-form-".$rs_art[$i]['id']."').submit(); }\"><i class='fa fa-trash-o'></i></a>\n";
			echo "		</div>\n";
			echo "	</form><form>\n";
			echo "</td>\n";
					
			echo "</tr>\n";
			
			$imponibile_art += $rs_art[$i]['ricevuto'];
			
		}
		$imponibile += $imponibile_art;
		
		$totale += $imponibile_art;
	}
	
	

	echo "<tr><td colspan='1' class='text-left'>\n";
	echo "	<b>Ricevuti:</b>\n";
	echo "</td>\n";

	echo "<td align='left'>\n";
	echo "	".number_format( $imponibile, get_var("Cifre decimali"), ",", "." )." &euro;\n";  
	echo "</td><td></td></tr>\n";
	


?>
