<?php

	include_once(__DIR__."/../../core.php");

	$module_name = 'Scadenzario';
	
	$idrecord = $html->form('iddocumento');
	$idriga = $html->form('idriga');
	$tipo_mod="TEST";
	

	$q = "SELECT * FROM co_scadenziario_pagamenti WHERE id='".$idriga."'";
	$rsr = $dbo->fetchArray($q);
	
	$q = "SELECT id , nome FROM co_banche WHERE id='".$rsr[0]['idbanca']."'";
	$rs_banca = $dbo->fetchArray($q);
	
	echo "<label>Modifica Acconto ricevuto</label><br><br>\n";
	echo "<form id=\"link_form\" action=\"".$rootdir."/editor.php?id_module=".$modules_info[$module_name]['id']."&id_record=".$idrecord."\" method=\"post\">\n";
	echo "	<input type='hidden' name='op' value='edit_acconto'>\n";
	echo "	<input type='hidden' name='idriga' value='".$idriga."'>\n";
	echo "	<input type='hidden' name='backto' value='record-edit'>\n";
	

	
	//Descrizione
	echo "	<div class='row'>\n";
	echo "		<div class='col-md-12'>\n";
	echo "			<label>Descrizione</label>\n";
	echo "			<textarea name='descrizione' id='descrizione' class='form-control'>".$rsr[0]['note']."</textarea>\n";
	echo "		</div>\n";	
	echo "	</div>\n";

	echo "<br>";
	
	
	echo "<div class='panel panel-primary'>";
		echo "<div class='panel-body'>";
			//data
			echo "		<div class='col-md-3'>\n";	
				echo "		<label>Data </label>\n";	
				echo "		<div class='form-group'>\n";				
				echo "			<input type='text' class='form-control  datepicker text-center '  id='data_acconto' name='data_acconto' required=\"true\" value=\"".date( "d/m/Y", strtotime($rsr[0]['data_emissione']) )."\">\n";											
				echo "		</div>\n";
			echo "	</div>\n";
			
			//Importo
			echo "		<div class='col-md-3'>\n";
				echo "			<div class='form-group'>\n";
				echo "				<label>Ricevuto</label>\n";
				echo "				<div class='input-group'>\n";
				echo "					<input type='text' class='form-control inputmask-decimal' id='subtot' name='subtot' value=\"".number_format($rsr[0]['ricevuto'], get_var("Cifre decimali"), ".", "")."\"><span class='input-group-addon'>&euro;</span>\n";
				echo "				</div>\n";
				echo "			</div>\n";
			echo "		</div>\n";
				
			//Banca
				$query = "SELECT * FROM co_banche";
				$rs = $dbo->fetchArray($query);	
				echo "		<div class='col-md-4'>\n";
				echo "			<label>Banca</label>\n";
					echo "			<select id='idbanca' class='superselect' name=\"idbanca\">\n";														
					echo "	<option value='".$rs_banca[0]['id']."' $attr>".$rs_banca[0]['nome']."</option>\n";
					for( $i=0; $i<sizeof($rs); $i++ ){				
						echo "	<option value='".$rs[$i]['id']."' $attr>".$rs[$i]['nome']."</option>\n";
					}	
					echo "			</select>\n";	
				echo "		</div>\n";

		echo "	</div>\n";
	echo "	</div>\n";
	
	

	?>


	<script type="text/javascript">
		
		$('.datepicker').datepicker();
		$('.timepicker').timepicker()
		
		function addriga(){
			if( $('#descrizione').val()!=''  ){
				$("#link_form").submit();
			}
		}
	</script>
	<script src="<?php echo $rootdir; ?>/lib/init.js"></script>


	<?php
	echo "	<a onclick=\"addriga();\" class=\"btn btn-primary pull-right\"><i class=\"fa fa-plus\"></i> Aggiorna</a>\n";
	echo "</form>\n";

	?>

	<div class="clearfix"></div>
