<?php
	$rdata = array_map('to_utf8', array_map('nl2br', array_map('html_attr_tags_ok', $rdata)));
	$jdata = array_map('to_utf8', array_map('nl2br', array_map('html_attr_tags_ok', $jdata)));
?>
<script>
	$j(function(){
		var tn = 'tarifs';

		/* data for selected record, or defaults if none is selected */
		var data = {
			link_bieleterie: <?php echo json_encode(array('id' => $rdata['link_bieleterie'], 'value' => $rdata['link_bieleterie'], 'text' => $jdata['link_bieleterie'])); ?>,
			compagnie: <?php echo json_encode(array('id' => $rdata['compagnie'], 'value' => $rdata['compagnie'], 'text' => $jdata['compagnie'])); ?>,
			emetteur: <?php echo json_encode(array('id' => $rdata['emetteur'], 'value' => $rdata['emetteur'], 'text' => $jdata['emetteur'])); ?>
		};

		/* initialize or continue using AppGini.cache for the current table */
		AppGini.cache = AppGini.cache || {};
		AppGini.cache[tn] = AppGini.cache[tn] || AppGini.ajaxCache();
		var cache = AppGini.cache[tn];

		/* saved value for link_bieleterie */
		cache.addCheck(function(u, d){
			if(u != 'ajax_combo.php') return false;
			if(d.t == tn && d.f == 'link_bieleterie' && d.id == data.link_bieleterie.id)
				return { results: [ data.link_bieleterie ], more: false, elapsed: 0.01 };
			return false;
		});

		/* saved value for compagnie */
		cache.addCheck(function(u, d){
			if(u != 'ajax_combo.php') return false;
			if(d.t == tn && d.f == 'compagnie' && d.id == data.compagnie.id)
				return { results: [ data.compagnie ], more: false, elapsed: 0.01 };
			return false;
		});

		/* saved value for emetteur */
		cache.addCheck(function(u, d){
			if(u != 'ajax_combo.php') return false;
			if(d.t == tn && d.f == 'emetteur' && d.id == data.emetteur.id)
				return { results: [ data.emetteur ], more: false, elapsed: 0.01 };
			return false;
		});

		cache.start();
	});
</script>

