<?php
// This script and data application were generated by AppGini 5.76
// Download AppGini for free from https://bigprof.com/appgini/download/

	$currDir = dirname(__FILE__);
	include("$currDir/defaultLang.php");
	include("$currDir/language.php");
	include("$currDir/lib.php");

	handle_maintenance();

	header('Content-type: text/javascript; charset=' . datalist_db_encoding);

	$table_perms = getTablePermissions('items');
	if(!$table_perms[0]){ die('// Access denied!'); }

	$mfk = $_GET['mfk'];
	$id = makeSafe($_GET['id']);
	$rnd1 = intval($_GET['rnd1']); if(!$rnd1) $rnd1 = '';

	if(!$mfk){
		die('// No js code available!');
	}

	switch($mfk){

		case 'numero':
			if(!$id){
				?>
				$j('#la_date<?php echo $rnd1; ?>').html('&nbsp;');
				<?php
				break;
			}
			$res = sql("SELECT `factures`.`idfactures` as 'idfactures', if(`factures`.`date`,date_format(`factures`.`date`,'%d/%m/%Y'),'') as 'date', IF(    CHAR_LENGTH(`clients1`.`nom_prenom`), CONCAT_WS('',   `clients1`.`nom_prenom`), '') as 'client' FROM `factures` LEFT JOIN `clients` as clients1 ON `clients1`.`idclients`=`factures`.`client`  WHERE `factures`.`idfactures`='{$id}' limit 1", $eo);
			$row = db_fetch_assoc($res);
			?>
			$j('#la_date<?php echo $rnd1; ?>').html('<?php echo addslashes(str_replace(array("\r", "\n"), '', nl2br($row['date']))); ?>&nbsp;');
			<?php
			break;

		case 'designation':
			if(!$id){
				?>
				$j('#tarif<?php echo $rnd1; ?>').html('&nbsp;');
				<?php
				break;
			}
			$res = sql("SELECT `menus`.`idmenu` as 'idmenu', `menus`.`photo` as 'photo', `menus`.`menu` as 'menu', REPLACE(FORMAT(`menus`.`prix`, 0), ',', ' ') as 'prix', `menus`.`description` as 'description', `menus`.`note` as 'note' FROM `menus`  WHERE `menus`.`idmenu`='{$id}' limit 1", $eo);
			$row = db_fetch_assoc($res);
			?>
			$j('#tarif<?php echo $rnd1; ?>').html('<?php echo addslashes(str_replace(array("\r", "\n"), '', nl2br($row['prix']))); ?>&nbsp;');
			<?php
			break;


	}

?>