<?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'])); ?>,
			passager: <?php echo json_encode(array('id' => $rdata['passager'], 'value' => $rdata['passager'], 'text' => $jdata['passager'])); ?>,
			parcours: <?php echo json_encode(array('id' => $rdata['parcours'], 'value' => $rdata['parcours'], 'text' => $jdata['parcours'])); ?>,
			compagnie: <?php echo json_encode(array('id' => $rdata['compagnie'], 'value' => $rdata['compagnie'], 'text' => $jdata['compagnie'])); ?>,
			provenance: <?php echo json_encode(array('id' => $rdata['provenance'], 'value' => $rdata['provenance'], 'text' => $jdata['provenance'])); ?>,
			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 passager */
		cache.addCheck(function(u, d) {
			if(u != 'ajax_combo.php') return false;
			if(d.t == tn && d.f == 'passager' && d.id == data.passager.id)
				return { results: [ data.passager ], more: false, elapsed: 0.01 };
			return false;
		});

		/* saved value for parcours */
		cache.addCheck(function(u, d) {
			if(u != 'ajax_combo.php') return false;
			if(d.t == tn && d.f == 'parcours' && d.id == data.parcours.id)
				return { results: [ data.parcours ], 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 provenance */
		cache.addCheck(function(u, d) {
			if(u != 'ajax_combo.php') return false;
			if(d.t == tn && d.f == 'provenance' && d.id == data.provenance.id)
				return { results: [ data.provenance ], 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>

