diff --git a/htdocs/boutique/livre/fiche.php b/htdocs/boutique/livre/fiche.php index 78d7a18be9b..d07f9f91eb7 100644 --- a/htdocs/boutique/livre/fiche.php +++ b/htdocs/boutique/livre/fiche.php @@ -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 ""; - print '
";
+
+ $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 .= ''.addslashes($auteur->nom).", ";
+ }
+ }
+ $desc .= 'Auteur';
+
+ if (sizeof($auteurs)>1)
+ {
+ $desc .= "s";
+ }
+ $desc .= ' : ' . substr($liste_auteurs, 0, strlen($liste_auteurs) - 2);
+
+ $desc .= '
Année de parution : '.$this->annee;
+
+
+ $editeur = new Editeur($this->db);
+ $result = $editeur->fetch($this->editeurid);
+ if (result)
+ {
+ $desc .= '
Editeur : ' . addslashes($editeur->nom);
+ }
+
$sql = "UPDATE ".DB_NAME_OSC.".products_description ";
$sql .= " SET products_name = '".$this->titre."'";
- $desc .= '
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."
"; - - $desc .= addslashes($this->description); - - $desc .= "
Autres livres : "; - - $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 .= ''.$value.""; - $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) ; diff --git a/htdocs/boutique/livre/pre.inc.php b/htdocs/boutique/livre/pre.inc.php index 78e849d8662..56fe32b7ba2 100644 --- a/htdocs/boutique/livre/pre.inc.php +++ b/htdocs/boutique/livre/pre.inc.php @@ -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); diff --git a/htdocs/product/categorie/categorie.class.php b/htdocs/product/categorie/categorie.class.php index b8c5a34a1ab..e56c358c5d8 100644 --- a/htdocs/product/categorie/categorie.class.php +++ b/htdocs/product/categorie/categorie.class.php @@ -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"]; diff --git a/htdocs/product/categorie/index.php b/htdocs/product/categorie/index.php index ccb0d4e0518..baea44f0e85 100644 --- a/htdocs/product/categorie/index.php +++ b/htdocs/product/categorie/index.php @@ -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 "
| "; - print_liste_field_titre("Titre",$PHP_SELF, "a.title"); - print " | "; - print ""; - print " | |||||
| Réf. | "; + print_liste_field_titre("Titre",$PHP_SELF, "l.title"); + print " | "; + print ''; + print " | ||||
| '.$objp->ref.' | '; + print ''.$objp->title.' | '; + + + if ($objp->status == 1) + { + print '';
+ print ' | ';
+ print '';
+ print ' | ';
+ }
+ else
+ {
+ print '';
+ print ' | ';
+ print '';
+ print ' | ';
+ }
+
+ print ''; + print 'Fiche en ligne | '; + print "
| "; + print_liste_field_titre("Titre",$PHP_SELF, "a.title"); + print " | "; + print ""; + print " |