*** empty log message ***

This commit is contained in:
Rodolphe Quiedeville 2003-03-24 18:29:33 +00:00
parent b103adb241
commit d014dca7f2
6 changed files with 347 additions and 100 deletions

View File

@ -52,6 +52,23 @@ if ($action == 'linkcat')
$livre->linkcategorie( $catid);
}
if ($action == 'delcat')
{
$livre = new Livre($db);
$livre->fetch($id);
$livre->unlinkcategorie($catid);
}
if ($action == "status")
{
$livre = new Livre($db);
$livre->fetch($id);
if ($livre->update_status($status))
{
}
}
if ($action == 'update' && !$cancel) {
$livre = new Livre($db);
@ -109,11 +126,19 @@ if ($action == 'create')
}
else
{
if ($id)
if ($id or $oscid)
{
$livre = new Livre($db);
$result = $livre->fetch($id);
if ($id)
{
$result = $livre->fetch($id, 0);
}
if ($oscid)
{
$result = $livre->fetch(0, $oscid);
$id = $livre->id;
}
if ( $result )
{
@ -145,7 +170,7 @@ else
$htmls->select_array("editeurid", $edits->liste_array(), $livre->editeurid);
print "</td></tr>";
print '<tr><td>Co-Auteurs</td><td>';
print '<tr><td>Auteur(s)</td><td>';
foreach ($auteurs as $key => $value)
{
@ -164,7 +189,7 @@ else
print "<form action=\"$PHP_SELF?id=$id\" method=\"post\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"addga\">";
print "<tr><td>Co-Auteur</td><td>";
print "<tr><td>Auteur(s)</td><td>";
$htmls->select_array("coauteurid", $auteur->liste_array());
print '&nbsp;<input type="submit" value="Ajouter"></td></tr>';
print "</form>";
@ -190,7 +215,16 @@ else
print '<td width="15%">Référence</td><td width="20%">'.$livre->ref.'</td>';
print '<td width="50%" valign="top">Description</td>';
print '<td valign="top">Catégories</td></tr>';
print "<tr><td>Statut</td><td>$livre->status_text</td>\n";
print "<tr><td>Statut</td><td>$livre->status_text";
if ($livre->status == 0)
{
print '<br><a href="fiche.php?id='.$id.'&status=1&action=status">Changer</a>';
}
else
{
print '<br><a href="fiche.php?id='.$id.'&status=0&action=status">Changer</a>';
}
print "</td>\n";
print '<td rowspan="6" valign="top">'.nl2br($livre->description)."</td>";
print '<td rowspan="6" valign="top">';
@ -209,7 +243,7 @@ else
print $editeur->nom;
}
print '</td></tr>';
print '<tr><td>Co-Auteurs</td><td>';
print '<tr><td>Auteur(s)</td><td>';
foreach ($auteurs as $key => $value)
{

View File

@ -156,6 +156,27 @@ class Livre {
print $this->db->error();
}
}
/*
*
*
*/
Function unlinkcategorie($categories_id)
{
$sql = "DELETE FROM ".DB_NAME_OSC.".products_to_categories ";
$sql .= " WHERE products_id=".$this->oscid;
$sql .= " AND categories_id=".$categories_id;
if ( $this->db->query($sql) )
{
return 1;
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
@ -183,6 +204,8 @@ class Livre {
*/
Function listcategorie()
{
global $conf;
$listecat = new Categorie($this->db);
$cats = $listecat->liste_array();
@ -220,14 +243,44 @@ class Livre {
}
if ($test)
{
print "<b>$value</b><br>";
print '<a href="/boutique/livre/fiche.php?id='.$this->id.'&action=delcat&catid='.$key.'">';
print '<img src="/theme/'.$conf->theme.'/img/editdelete.png" height="16" width="16" alt="Supprimer" border="0">';
print "</a><b>$value</b><br>";
}
else
{
print '<img src="/theme/'.$conf->theme.'/img/transparent.png" height="16" width="16" alt="Supprimer" border="0">';
print "$value<br>";
}
}
}
/*
*
*
*/
Function update_status($status)
{
$sql = "UPDATE ".DB_NAME_OSC.".products ";
$sql .= " SET products_status = ".$status;
$sql .= " WHERE products_id = " . $this->oscid;
if ( $this->db->query($sql) )
{
$sql = "UPDATE llx_livre ";
$sql .= " SET status = ".$status;
$sql .= " WHERE rowid = " . $this->id;
if ( $this->db->query($sql) )
{
return 1;
}
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
@ -235,69 +288,106 @@ class Livre {
*/
Function updateosc()
{
$desc = trim(addslashes($this->description));
$desc .= "<p>";
$auteurs = array();
$auteurs = $this->liste_auteur();
foreach ($auteurs as $key => $value)
{
$auteursid = $key;
$auteur = new Auteur($this->db);
$result = $auteur->fetch($auteursid);
if ( $result )
{
$liste_auteurs .= '<a href="">'.addslashes($auteur->nom)."</a>, ";
}
}
$desc .= 'Auteur';
if (sizeof($auteurs)>1)
{
$desc .= "s";
}
$desc .= ' : ' . substr($liste_auteurs, 0, strlen($liste_auteurs) - 2);
$desc .= '<br>Année de parution : '.$this->annee;
$editeur = new Editeur($this->db);
$result = $editeur->fetch($this->editeurid);
if (result)
{
$desc .= '<br>Editeur : ' . addslashes($editeur->nom);
}
$sql = "UPDATE ".DB_NAME_OSC.".products_description ";
$sql .= " SET products_name = '".$this->titre."'";
$desc .= '<br>Info supplémentaires';
$ga = array();
$ga = $this->liste_groupart();
if (sizeof($ga) == 1)
{
foreach ($ga as $key => $value)
{
$gaid = $key;
}
$groupart = new Groupart($this->db);
$result = $groupart->fetch($gaid);
if ( $result )
{
$desc = $groupart->nom."<p>";
$desc .= addslashes($this->description);
$desc .= "<p><b>Autres livres</b> : ";
$gas = $groupart->liste_livres();
$i = 0;
$sizegas = sizeof($gas) - 1;
foreach ($gas as $key => $value)
{
if ($key <> $this->id)
{
$otha = new Livre($this->db);
$otha->fetch($key);
$desc .= '<a href="'.OSC_CATALOG_URL.'product_info.php?products_id='.$otha->oscid.'">'.$value."</a>";
$i++;
if ($sizegas > $i)
{
$desc .= ", ";
}
}
}
}
}
$sql .= ", products_description = '$desc'";
$sql .= " WHERE products_id = " . $this->oscid;
if ( $this->db->query($sql) ) {
return 1;
} else {
print $this->db->error() . ' in ' . $sql;
}
if ( $this->db->query($sql) )
{
$sql = "UPDATE ".DB_NAME_OSC.".products ";
$sql .= "SET products_model = '".$this->ref."'";
$sql .= ", products_price = ".$this->price."";
$sql .= " WHERE products_id = " . $this->oscid;
if ( $this->db->query($sql) )
{
return 1;
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
else
{
print $this->db->error() . ' in ' . $sql;
}
}
/*
*
*
*/
Function liste_auteur()
{
$ga = array();
$sql = "SELECT a.rowid, a.nom FROM llx_auteur as a, llx_livre_to_auteur as l";
$sql .= " WHERE a.rowid = l.fk_auteur AND l.fk_livre = ".$this->id;
$sql .= " ORDER BY a.nom";
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
if ($nump)
{
$i = 0;
while ($i < $nump)
{
$obj = $this->db->fetch_object($i);
$ga[$obj->rowid] = $obj->nom;
$i++;
}
}
return $ga;
}
else
{
print $this->db->error();
}
}
/*
*
*
*/
@ -330,9 +420,17 @@ class Livre {
*
*
*/
Function fetch ($id) {
Function fetch ($id, $oscid=0) {
$sql = "SELECT rowid, fk_editeur, ref, prix, annee, oscid, title, description FROM llx_livre WHERE rowid = $id";
$sql = "SELECT rowid, fk_editeur, ref, prix, annee, oscid, title, description FROM llx_livre";
if ($id)
{
$sql .= " WHERE rowid = $id";
}
if ($oscid)
{
$sql .= " WHERE oscid = $oscid";
}
$result = $this->db->query($sql) ;

View File

@ -48,10 +48,6 @@ function llxHeader($head = "", $urlp = "") {
$menu->add_submenu("/boutique/editeur/fiche.php?&action=create","Nouvel éditeur");
$menu->add("/product/osc-reviews.php", "Critiques");
$menu->add_submenu("/product/osc-productsbyreviews.php", "Meilleurs produits");
$menu->add("/product/categorie/", "Catégories");
left_menu($menu->liste);

View File

@ -24,6 +24,7 @@ class Categorie {
var $db ;
var $id ;
var $parent_id ;
var $oscid ;
var $ref;
var $titre;
@ -212,7 +213,7 @@ class Categorie {
*/
Function fetch ($id) {
$sql = "SELECT c.categories_id, cd.categories_name";
$sql = "SELECT c.categories_id, cd.categories_name, c.parent_id";
$sql .= " FROM ".DB_NAME_OSC.".categories as c,".DB_NAME_OSC.".categories_description as cd";
$sql .= " WHERE c.categories_id = cd.categories_id AND cd.language_id = ".OSC_LANGUAGE_ID;
$sql .= " AND c.categories_id = $id";
@ -222,6 +223,7 @@ class Categorie {
$result = $this->db->fetch_array();
$this->id = $result["categories_id"];
$this->parent_id = $result["parent_id"];
$this->name = $result["categories_name"];
$this->titre = $result["title"];
$this->description = $result["description"];

View File

@ -26,42 +26,145 @@ llxHeader();
$db = new Db();
print_barre_liste("Liste des catégories", $page, $PHP_SELF);
$sql = "SELECT c.categories_id, cd.categories_name ";
$sql .= " FROM ".DB_NAME_OSC.".categories as c,".DB_NAME_OSC.".categories_description as cd";
$sql .= " WHERE c.categories_id = cd.categories_id AND cd.language_id = ".OSC_LANGUAGE_ID;
$sql .= " AND c.parent_id = 0";
$sql .= " ORDER BY cd.categories_name ASC ";
if ( $db->query($sql) )
if ($id)
{
$num = $db->num_rows();
$i = 0;
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR class=\"liste_titre\"><td>";
print_liste_field_titre("Titre",$PHP_SELF, "a.title");
print "</td>";
print "<td></td>";
print "</TR>\n";
$var=True;
while ($i < $num)
$title = title_url($id, $db);
print_barre_liste($title, $page, $PHP_SELF);
$sql = "SELECT products_id FROM ".DB_NAME_OSC.".products_to_categories WHERE categories_id = $id";
if ( $db->query($sql) )
{
$objp = $db->fetch_object( $i);
$var=!$var;
printc($objp->categories_id,$db, 0);
$i++;
$numprod = $db->num_rows();
$i = 0;
$wc = "(";
while ($i < $numprod)
{
$objp = $db->fetch_object( $i);
$wc .= $objp->products_id;
if ($i < $numprod -1)
{
$wc .= ",";
}
$i++;
}
$wc .=")";
$db->free();
}
else
{
print $db->error();
}
// print $wc ;
if ($numprod)
{
$sql = "SELECT l.rowid, l.title, l.oscid, l.ref, l.status FROM llx_livre as l";
$sql .= " WHERE l.oscid in $wc";
if ( $db->query($sql) )
{
$num = $db->num_rows();
$i = 0;
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR class=\"liste_titre\"><td>Réf.</td><td>";
print_liste_field_titre("Titre",$PHP_SELF, "l.title");
print "</td>";
print '<td colspan="3">&nbsp;</td>';
print "</TR>\n";
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print '<TD><a href="/boutique/livre/fiche.php?id='.$objp->rowid.'">'.$objp->ref.'</a></TD>';
print '<TD width="70%"><a href="/boutique/livre/fiche.php?id='.$objp->rowid.'">'.$objp->title.'</a></TD>';
if ($objp->status == 1)
{
print '<td align="center">';
print '<img src="/theme/'.$conf->theme.'/img/icon_status_green.png" border="0"></a></td>';
print '<td align="center">';
print '<img src="/theme/'.$conf->theme.'/img/icon_status_red_light.png" border="0"></a></td>';
}
else
{
print '<td align="center">';
print '<img src="/theme/'.$conf->theme.'/img/icon_status_green_light.png" border="0"></a></td>';
print '<td align="center">';
print '<img src="/theme/'.$conf->theme.'/img/icon_status_red.png" border="0"></a></td>';
}
print '<TD align="right">';
print '<a href="'.OSC_CATALOG_URL.'product_info.php?products_id='.$objp->oscid.'">Fiche en ligne</a></TD>';
print "</TR>\n";
$i++;
}
print "</TABLE>";
$db->free();
}
else
{
print $db->error();
}
}
else
{
print "Aucun produits dans cette catégorie";
}
print "</TABLE>";
$db->free();
}
else
{
print $db->error();
}
print_barre_liste("Liste des catégories", $page, $PHP_SELF);
$sql = "SELECT c.categories_id, cd.categories_name ";
$sql .= " FROM ".DB_NAME_OSC.".categories as c,".DB_NAME_OSC.".categories_description as cd";
$sql .= " WHERE c.categories_id = cd.categories_id AND cd.language_id = ".OSC_LANGUAGE_ID;
$sql .= " AND c.parent_id = 0";
$sql .= " ORDER BY cd.categories_name ASC ";
if ( $db->query($sql) )
{
$num = $db->num_rows();
$i = 0;
print "<p><TABLE border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
print "<TR class=\"liste_titre\"><td>";
print_liste_field_titre("Titre",$PHP_SELF, "a.title");
print "</td>";
print "<td></td>";
print "</TR>\n";
$var=True;
while ($i < $num)
{
$objp = $db->fetch_object( $i);
$var=!$var;
printc($objp->categories_id,$db, 0);
$i++;
}
print "</TABLE>";
$db->free();
}
else
{
print $db->error();
}
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
/*
*
*
*/
Function printc($id, $db, $level)
{
@ -75,7 +178,7 @@ Function printc($id, $db, $level)
print "&nbsp;&nbsp;|--";
}
print "<a href=\"fiche.php?id=$objp->rowid\">".$cat->name."</a></TD>\n";
print '<a href="index.php?id='.$cat->id.'">'.$cat->name."</a></TD>\n";
print "</TR>\n";
$childs = array();
@ -87,9 +190,23 @@ Function printc($id, $db, $level)
printc($key,$db, $level+1);
}
}
}
$db->close();
llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</em>");
Function title_url($id, $db)
{
$cat = new Categorie($db);
$cat->fetch($id);
$title = $title . '<a href="index.php?id='.$cat->id.'">'. $cat->name ."</a>";
if (sizeof($cat->parent_id))
{
$title = title_url($cat->parent_id, $db) . " / ".$title;
}
return $title;
}
?>

View File

@ -65,7 +65,7 @@ if ( $db->query($sql) ) {
$objp = $db->fetch_object( $i);
$var=!$var;
print "<TR $bc[$var]>";
print "<TD>$objp->products_model</TD>\n";
print '<TD><a href="/boutique/livre/fiche.php?oscid='.$objp->products_id.'">'.$objp->products_model.'</a></TD>';
print '<TD align="center">'.$objp->rat."</TD>\n";
print '<TD align="center">'.$objp->products_quantity."</TD>\n";
print '<TD align="center">'.$objp->products_status."</TD>\n";