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

	
	
	$idmodulo = $html->form('idmodule');
	$module_name=get_module_name_by_id($idmodulo);

	
	$iddocumento = $html->form('iddocumento');
	$idriga = $html->form('idriga');
	$n_protocollo = $html->form('n_protocollo');
	$dir = get_var_tipodoc2($iddocumento,"dir");	
	//Info documento
	$q = "SELECT * FROM co_documenti WHERE id='".$iddocumento."'";
	$rs = $dbo->fetchArray($q);
	( $rs[0]['numero_esterno'] != '' ) ? $numero=$rs[0]['numero_esterno'] : $numero=$rs[0]['numero'];
	$idanagrafica = $rs[0]['idanagrafica'];
	$idconto_fattura = $rs[0]['idconto'];
	
	//Info riga inserita
	$q = "SELECT * FROM co_righe_documenti WHERE iddocumento='".$iddocumento."' AND id='".$idriga."'";
	$rsr = $dbo->fetchArray($q);
	$idconto_fattura = $rsr[0]['idconto'];
	
	/*
		Form di modifica riga documento
	*/
	echo "<label>Documento numero ".$numero."</label><br><br>\n";
	echo "<form id=\"link_form\" action=\"".$rootdir."/editor.php?id_module=".$modules_info[$module_name]['id']."&id_record=".$iddocumento."\" method=\"post\">\n";
	
	echo "	<input type='hidden' name='op' value='editnumero_protocollo'>\n";
	echo "	<input type='hidden' name='idriga' value='".$idriga."'>\n";
	echo "	<input type='hidden' name='backto' value='record-edit'>\n";
	echo "	<input type='hidden' name='dir' value='".$dir."'>\n";
	
	
	

			
	echo "<br>";

	echo "<div class='panel panel-primary'>";
		echo "<div class='panel-body'>";
			echo "	<div class='row'>\n";	
			//Qta	
				echo "		<div class='col-md-3'>\n";
				echo "			<div class='form-group'>\n";
				echo "				<label>Nuovo numero protocollo;</label>\n";
				echo "				<div class='input-group'>\n";
				echo "					<input type='text' class='form-control' id='new_numero' maxlength='8' name='new_numero' value=\"".$n_protocollo."\">\n";
				echo "				</div>\n";
				echo "			</div>\n";
				echo "		</div>\n";		
			echo "		</div>\n";	
		echo "		</div>\n";		
	echo "		</div>\n";		
	
	

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

	<script type="text/javascript">
	
		function addriga(){
			if( $('#descrizione').val()!='' && $('#idiva option:selected').val()!='' ){
				$("#link_form").submit();
			}
		}
		
		$(document).ready( function(){
		
			start_superselect();
			start_inputmask();
		
		});
	</script>

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

