<?php
	include_once(__DIR__."/../../core.php");
?>
<form action="" method="post" role="form">
	<input type="hidden" name="backto" value="record-edit">
	<input type="hidden" name="op" value="update">
	<input type="hidden" name="id_record" value="<?php echo $id_record ?>">

	<!-- ricerco dati ulteriori -->
	<?php
		$rootdir1="";

        $q_1 = " SELECT * FROM mg_movimenti inner join mg_articoli ON idarticolo=mg_articoli.id WHERE mg_movimenti.id=\"".$id_record."\" ";
		$rs_art = $dbo->fetchArray( $q_1 );
		$id_ana=$rs_art[0]['idfornitore'];
		$q_2 = " SELECT * FROM an_anagrafiche  WHERE idanagrafica=\"".$id_ana."\" ";
		$rs_ana = $dbo->fetchArray( $q_2 );
		
		$q_3="SELECT * FROM co_documenti inner join co_tipidocumento on idtipodocumento=co_tipidocumento.id where co_documenti.id=\"".$rs_art[0]['iddocumento']."\" ";
		$rs_doc = $dbo->fetchArray( $q_3 );
		
		$q_4="SELECT in_tipiintervento.descrizione as des FROM in_interventi inner join in_tipiintervento on in_interventi.idtipointervento=in_tipiintervento.idtipointervento where in_interventi.idintervento=\"".$rs_art[0]['idintervento']."\" ";
		$rs_in = $dbo->fetchArray( $q_4 );	
		
		$q_5="SELECT * FROM dt_ddt inner join dt_tipiddt on idtipoddt=dt_tipiddt.id where dt_ddt.id=\"".$rs_art[0]['idddt']."\" ";
		$rs_ddt = $dbo->fetchArray( $q_5 );	
    
		$q_6="select * from an_anagrafiche where idanagrafica=\"".$rs_doc[0]['idanagrafica']."\" ";
		$rs_ana_doc = $dbo->fetchArray( $q_6 );	
		
		$q_7="select * from an_anagrafiche where idanagrafica=\"".$rs_ddt[0]['idanagrafica']."\" ";
		$rs_ana_ddt = $dbo->fetchArray( $q_7 );	
		
		$idanagrafica = $rs_ana[0]['idanagrafica'];
		$id_ana = $rs_ana_doc[0]['idanagrafica'];
		
		$id_mod_art=$modules_info['Articoli']['id'];
	?>
	
	
	<div class="panel panel-<?php echo $_SESSION['profilo_pannello'] ?>">
		<div class="clearfix"></div>
		</br>	
		<div class="col-md-4">				
			<div class="pull-left">		
				<a  class="btn btn-app btn-info" target="_blank" href="<?php echo $rootdir ?>/editor.php?id_module=2&id_record=<?php echo $id_ana ?>"><i class="fa fa-user"></i>Anagrafica</a>	
				<a  class="btn btn-app btn-info" target="_blank" href="<?php echo $rootdir ?>/editor.php?id_module=14&id_record=<?php echo $rs_art[0]['iddocumento'] ?>"><i class="fa fa-line-chart"></i>Documento</a>	
				<a  class="btn btn-app btn-info" target="_blank" href="<?php echo $rootdir ?>/editor.php?id_module=<?php echo $id_mod_art ?>&id_record=<?php echo $rs_art[0]['idarticolo'] ?>"><i class="fa fa-truck"></i>Articolo</a>
			</div>
		</div>
		<div class="col-md-4">				
			<div class="pull-right">
			</div>	
		</div>
		
		<div class="col-md-4">
			<div class="pull-right">				
			</div>			
		</div>			
		<div class="clearfix"></div>
		</br>	
	</div>
	
	
	
	<!-- DATI ANAGRAFICI -->
	<div class="panel panel-<?php echo $_SESSION['profilo_pannello'] ?>">
		<div class="panel-heading">
			<h3 class="panel-title">Movimento</h3>
		</div>
	
		<div class="panel-body">
			
			<div class="row">
				<div class="col-md-3">
					{[ "type": "text", "label": "<?php echo _("Codice"); ?>", "name": "codice", "required": 1, "class": "", "value": "<?php echo $rs_art[0]['codice'] ?>", "extra": "" ]}
				</div>
				<div class="col-md-9">
					{[ "type": "text", "label": "<?php echo _("Descrizione"); ?>", "name": "descrizione_articolo", "required": 1, "class": "", "value": "$descrizione_articolo$", "extra": "" ]}
				</div>
				
			</div>
			<div class="row">
				<div class="col-md-4">
					
					{[ "type": "text", "label": "Fornitore", "name": "qta", "required": 1, "class": "", "value": "<?php echo $rs_ana[0]['ragione_sociale'] ?>", "extra": "" ]}
				</div>
				<div class="col-md-4">
					{[ "type": "text", "label": "Movimento", "name": "movimento", "required": 1, "class": "", "value": "$movimento$", "extra": "" ]}
				</div>
				<div class="col-md-2">
						{[ "type": "date", "label": "Data", "maxlength": 10, "name": "data", "required": 1, "class": "text-center datepicker", "value": "$data$", "extra": "" ]}
				</div>
				<div class="col-md-1">
					{[ "type": "text", "label": "Qta", "name": "qta", "required": 1, "class": "", "value": "$qta$", "extra": "" ]}
				</div>
			</div>
			
			
				<?php if( $rs_art[0]['iddocumento'] > '0' ){ ?>
				<div class="row">
						<div class="col-md-1">
							{[ "type": "text", "label": "Documento", "name": "idintervento", "required": 1, "class": "", "value": "$iddocumento$", "extra": "" ]}
						</div>
						<div class="col-md-3">
							{[ "type": "text", "label": "Descrizione", "name": "des", "required": 1, "class": "", "value": "<?php echo $rs_doc[0]['descrizione'] ?>", "extra": "" ]}
						</div>
						<div class="col-md-4">
							{[ "type": "text", "label": "Ragione Sociale", "name": "idintervento", "required": 1, "class": "", "value": "<?php echo $rs_ana_doc[0]['ragione_sociale'] ?>", "extra": "" ]}
						</div>
				<?php } ?>	
				</div>
		</div>
	</div>

</form>






