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

	$name="Tipi di canone";

	$contratti_attivi=cerca_contratti_attivi($records[0]['id']);
	$q = "SELECT * FROM `co_contratti_tipi_righe_qta` WHERE idtipocontratto='".$id_record."' ORDER BY ordine";
	$rs = $dbo->fetchArray( $q );
	$tot = sizeof($rs);

	if( $tot>0 ){
		for( $i=0; $i<$tot; $i++ ){
			 if( $rs[$i]['idarticolo'] != 0 ){
				echo "<tr><td>\n";
				echo "<a href='".$rootdir."/editor.php?id_module=".$modules_info['Articoli']['id']."&id_record=".$rs[$i]['idarticolo']."' target=\"_blank\">".nl2br( $rs[$i]['codice_articolo']."".$rs[$i]['descrizione'] )."</a>\n";
	
				//Qta
				echo "<td class='text-center'>\n";
				echo number_format( $rs[$i]['qta'], get_var("Cifre decimali"), ",", "." )."\n";
				echo "</td>\n";
				echo "</td>\n";
				if( $contratti_attivi == "0"  ){
					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[$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[$i]['id']."'>\n";
						echo "		<input type='hidden' name='op' value='unlink_articolo_qt'>\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/contratti_tipo/edit_riga_qt.php?iddocumento=".$id_record."&idriga=".$rs[$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 questa riga dalle impostazioni?') ){ $('#delete-form-".$rs[$i]['id']."').submit(); }\"><i class='fa fa-trash-o'></i></a>\n";
						echo "		</div>\n";
						echo "	</form><form>\n";
					echo "</td>\n";
				}
				echo "</td></tr>\n";
			}
			else{	
			}
		}

	}

?>
