Ejemplo n.º 1
0
function liste_produits($rubrique, $critere, $order, $alpha)
{
    $produit = new Produit();
    $produitdesc = new Produitdesc();
    if ($alpha == "alpha") {
        $query = "select p.* from {$produit->table} p LEFT JOIN {$produitdesc->table} pd ON pd.produit = p.id and lang=" . ActionsLang::instance()->get_id_langue_courante() . " where p.rubrique=\"{$rubrique}\" order by pd.{$critere} {$order}";
    } else {
        $query = "select * from {$produit->table} where rubrique=\"{$rubrique}\" order by {$critere} {$order}";
    }
    $resul = $produit->query($query);
    $i = 0;
    while ($resul && ($row = $produit->fetch_object($resul))) {
        $produit->charger($row->ref);
        $produitdesc = new Produitdesc();
        $produitdesc->charger($row->id);
        if (!$produitdesc->affichage_back_office_permis()) {
            continue;
        }
        $fond = "ligne_" . ($i++ % 2 ? "claire" : "fonce");
        $image = new Image();
        $query_image = "select * from {$image->table} where produit=\"" . $row->id . "\" order by classement limit 0,1";
        $resul_image = $image->query($query_image);
        $row_image = $image->fetch_object($resul_image);
        ?>

<ul class="<?php 
        echo $fond;
        ?>
">
	<li><div class="vignette"><?php 
        if ($row_image) {
            ?>
 <img src="../fonctions/redimlive.php?nomorig=<?php 
            echo $row_image->fichier;
            ?>
&type=produit&width=51&height=51&exact=1" title="<?php 
            echo $produit->ref;
            ?>
" /><?php 
        }
        ?>
</div></li>
	<li style="width:61px;"><span class="texte_noedit" title="<?php 
        echo $row->ref;
        ?>
"><?php 
        echo substr($row->ref, 0, 9);
        if (strlen($row->ref) > 9) {
            echo " ...";
        }
        ?>
</span></li>
	<li style="width:225px;"><span id="titreprod_<?php 
        echo $row->id;
        ?>
" <?php 
        if ($produitdesc->est_langue_courante()) {
            echo 'class="texte_edit"';
        }
        ?>
><?php 
        echo substr($produitdesc->titre, 0, 35);
        if (strlen($produitdesc->titre) > 35) {
            echo " ...";
        }
        ?>
</span></li>
	<li style="width:39px;"><span id="stock_<?php 
        echo $row->id;
        ?>
" class="texte_edit"><?php 
        echo $row->stock;
        ?>
</span></li>
	<li style="width:30px;"><span id="prix_<?php 
        echo $row->id;
        ?>
" class="texte_edit"><?php 
        echo $row->prix;
        ?>
</span></li>
	<li style="width:68px;"><span id="prix2_<?php 
        echo $row->id;
        ?>
" class="texte_edit"><?php 
        echo $row->prix2;
        ?>
</span></li>
	<li style="width:64px;"><input id="promo_<?php 
        echo $row->id;
        ?>
" type="checkbox" name="promo[]" class="sytle_checkbox" onchange="checkvalues('promo','<?php 
        echo $row->id;
        ?>
')" <?php 
        if ($row->promo) {
            ?>
 checked="checked" <?php 
        }
        ?>
/></li>
	<li style="width:64px;"><input type="checkbox" id="nouveaute_<?php 
        echo $row->id;
        ?>
" name="nouveaute[]" class="sytle_checkbox" onchange="checkvalues('nouveaute','<?php 
        echo $row->id;
        ?>
')" <?php 
        if ($row->nouveaute) {
            ?>
 checked="checked" <?php 
        }
        ?>
/></li>
	<li style="width:53px;"><input type="checkbox" id="prod_ligne_<?php 
        echo $row->id;
        ?>
" name="ligne[]" class="sytle_checkbox" onchange="checkvalues('ligneprod','<?php 
        echo $row->id;
        ?>
')" <?php 
        if ($row->ligne) {
            ?>
 checked="checked" <?php 
        }
        ?>
/></li>
	<li style="width:41px;"><a href="produit_modifier.php?ref=<?php 
        echo $produit->ref;
        ?>
&rubrique=<?php 
        echo $produit->rubrique;
        ?>
"  class="txt_vert_11"><?php 
        echo trad('editer', 'admin');
        ?>
</a></li>

	<li style="width:78px; text-align:center;">
	<div class="bloc_classement">
  <div class="classement">
		<a href="produit_modifier.php?ref=<?php 
        echo $produit->id;
        ?>
&action=modclassement&parent=<?php 
        echo $rubrique;
        ?>
&type=M"><img src="gfx/up.gif" border="0" /></a>
	</div>
	 <div class="classement"><span id="classementprod_<?php 
        echo $produit->id;
        ?>
" class="classement_edit"><?php 
        echo $row->classement;
        ?>
</span></div>
	 <div class="classement">
		<a href="produit_modifier.php?ref=<?php 
        echo $produit->id;
        ?>
&action=modclassement&parent=<?php 
        echo $rubrique;
        ?>
&type=D"><img src="gfx/dn.gif" border="0" /></a>
	</div>
	</div>
	</li>
	<li style="width:37px; text-align:center;"><a href="javascript:supprimer_produit('<?php 
        echo $produit->ref;
        ?>
','<?php 
        echo $rubrique;
        ?>
')"><img src="gfx/supprimer.gif" width="9" height="9" border="0" /></a></li>
</ul>

<?php 
    }
}
 /**
  * 
  * Return an array of product for the current category
  * 
  * @param string $rubrique id of the current category
  * @param string $critere order by clause
  * @param string $order ASC or DESC
  * @param string $alpha if order is alpha pu "alpha"
  * @return Array
  */
 public function getList($rubrique, $critere, $order, $alpha)
 {
     $return = array();
     if ($alpha == "alpha") {
         $query = "select p.id, p.ref, p.rubrique, p.stock, p.prix, p.prix2, p.promo, p.ligne, p.nouveaute, p.classement, p.tva from " . Produit::TABLE . " p LEFT JOIN " . Produitdesc::TABLE . " pd ON pd.produit = p.id and lang=" . ActionsLang::instance()->get_id_langue_courante() . " where p.rubrique=\"{$rubrique}\" order by pd.{$critere} {$order}";
     } else {
         $query = "select id, ref, rubrique, stock, prix, prix2, promo, ligne, nouveaute, classement, tva from " . Produit::TABLE . " where rubrique=\"{$rubrique}\" order by {$critere} {$order}";
     }
     $resul = $this->query($query);
     $i = 0;
     while ($resul && ($row = $this->fetch_object($resul))) {
         $produitdesc = new Produitdesc();
         $produitdesc->charger($row->id);
         if (!$produitdesc->affichage_back_office_permis()) {
             continue;
         }
         $image = new Image();
         $query_image = "select * from " . Image::TABLE . " where produit=\"" . $row->id . "\" order by classement limit 0,1";
         $resul_image = $image->query($query_image);
         $row_image = $image->fetch_object($resul_image, 'image');
         $return[] = array("ref" => $row->ref, "id" => $row->id, "rubrique" => $row->rubrique, "stock" => $row->stock, "variants" => $this->getVariants($row->id), "prix" => $row->prix, "prix2" => $row->prix2, "promo" => $row->promo, "ligne" => $row->ligne, "nouveaute" => $row->nouveaute, "classement" => $row->classement, "tva" => $row->tva, "titre" => $produitdesc->titre, "langue_courante" => $produitdesc->est_langue_courante(), "image" => array("fichier" => $row_image->fichier));
     }
     return $return;
 }