<?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 = 'billeteries';

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

		/* 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_out */
		cache.addCheck(function(u, d) {
			if(u != 'ajax_combo.php') return false;
			if(d.t == tn && d.f == 'link_out' && d.id == data.link_out.id)
				return { results: [ data.link_out ], more: false, elapsed: 0.01 };
			return false;
		});

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

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

