<?php 
include('pdo_init.php');
$aafficherjs =' <script type="text/javascript"> 
     jQuery(document).ready(function() {
     
stocks = new Array();
cart = {"valeur" : 0, "items" : 0};
 $(document).ready(function() {
    $(".thumbgallerie a").lightBox();

'; 
 	
$sql = 'SELECT * FROM qzine_stocks';
$resultats = $pdo->query($sql);
$resultats->setFetchMode(PDO::FETCH_OBJ);

//print_r($resultats);
// id , article , qte , date_maj, reserved , type , prix

while( $ligne = $resultats->fetch() )
{
$ligne->qte = $ligne->qte - $ligne->reserved;
 $aafficherjs .=
         "
         /*    $('.nom_item[name=". $ligne->id ."]').before('<span class=reste_items title=\'". $ligne->qte ." exemplaires en stock\'>x". $ligne->qte ."</span>');*/
stocks[".$ligne->id."] = {		'id'      : '".$ligne->id."',
								'qte'     : ".$ligne->qte." ,
								'type'    : '".$ligne->type."' ,
								'prix'    : ".$ligne->prix." ,
								'article' : '".$ligne->article."',
								'panier'  : 0
								
				};
 ";
 
}

 /*
 stocks[".$ligne->id."]['qte'] = ".$ligne->qte." ;
 stocks[".$ligne->id."]['panier'] = 0 ;
 */
 
$aafficherjs .=' console.log("stocks" + stocks); });';






$aafficherjs .='

 });
</script>';


echo $aafficherjs;