<?php
// This script and data application were generated by AppGini 5.71
// 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('achats');
	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 'designation':
			if(!$id){
				?>
				$j('#reference<?php echo $rnd1; ?>').html('&nbsp;');
				<?php
				break;
			}
			$res = sql("SELECT `marchandises`.`idmarchandises` as 'idmarchandises', `marchandises`.`designation` as 'designation', `marchandises`.`reference` as 'reference', IF(    CHAR_LENGTH(`fournisseurs1`.`raison_sociale`), CONCAT_WS('',   `fournisseurs1`.`raison_sociale`), '') as 'fournisseur', IF(    CHAR_LENGTH(`provenances1`.`provenance`), CONCAT_WS('',   `provenances1`.`provenance`), '') as 'provenance', REPLACE(FORMAT(`marchandises`.`achat`, 0), ',', ' ') as 'achat', REPLACE(FORMAT(`marchandises`.`vente`, 0), ',', ' ') as 'vente', REPLACE(FORMAT(`marchandises`.`stock`, 0), ',', ' ') as 'stock', REPLACE(FORMAT(`marchandises`.`stockaa`, 0), ',', ' ') as 'stockaa', REPLACE(FORMAT(`marchandises`.`stockvv`, 0), ',', ' ') as 'stockvv', REPLACE(FORMAT(`marchandises`.`sstock`, 0), ',', ' ') as 'sstock' FROM `marchandises` LEFT JOIN `fournisseurs` as fournisseurs1 ON `fournisseurs1`.`idfournisseurs`=`marchandises`.`fournisseur` LEFT JOIN `provenances` as provenances1 ON `provenances1`.`idprovenances`=`marchandises`.`provenance`  WHERE `marchandises`.`idmarchandises`='{$id}' limit 1", $eo);
			$row = db_fetch_assoc($res);
			?>
			$j('#reference<?php echo $rnd1; ?>').html('<?php echo addslashes(str_replace(array("\r", "\n"), '', nl2br($row['reference']))); ?>&nbsp;');
			<?php
			break;


	}

?>