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 'Co-Auteurs'; + print 'Auteur(s)'; foreach ($auteurs as $key => $value) { @@ -164,7 +189,7 @@ else print "
\n"; print ""; - print "Co-Auteur"; + print "Auteur(s)"; $htmls->select_array("coauteurid", $auteur->liste_array()); print ' '; print "
"; @@ -190,7 +215,16 @@ else print 'Référence'.$livre->ref.''; print 'Description'; print 'Catégories'; - print "Statut$livre->status_text\n"; + print "Statut$livre->status_text"; + if ($livre->status == 0) + { + print '
Changer'; + } + else + { + print '
Changer'; + } + print "\n"; print ''.nl2br($livre->description).""; print ''; @@ -209,7 +243,7 @@ else print $editeur->nom; } print ''; - print 'Co-Auteurs'; + print 'Auteur(s)'; foreach ($auteurs as $key => $value) { diff --git a/htdocs/boutique/livre/livre.class.php b/htdocs/boutique/livre/livre.class.php index cd54da8aceb..f48252b2b10 100644 --- a/htdocs/boutique/livre/livre.class.php +++ b/htdocs/boutique/livre/livre.class.php @@ -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 "$value
"; + print ''; + print 'Supprimer'; + print "$value
"; } else { + print 'Supprimer'; print "$value
"; } } } + /* + * + * + */ + 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 .= "

"; + + $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 ""; - print ""; - print "\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 "

"; - print_liste_field_titre("Titre",$PHP_SELF, "a.title"); - print "
"; + print ""; + print ''; + print "\n"; + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print ''; + print ''; + + + if ($objp->status == 1) + { + print ''; + print ''; + } + else + { + print ''; + print ''; + } + + print ''; + print "\n"; + $i++; + } + print "
Réf."; + print_liste_field_titre("Titre",$PHP_SELF, "l.title"); + print " 
'.$objp->ref.''.$objp->title.''; + print ''; + print ''; + print ''; + print ''; + print 'Fiche en ligne
"; + $db->free(); + } + else + { + print $db->error(); + } + } + else + { + print "Aucun produits dans cette catégorie"; } - print ""; - $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 "

"; + print ""; + print ""; + print "\n"; + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object( $i); + $var=!$var; + + printc($objp->categories_id,$db, 0); + + $i++; + } + print "
"; + print_liste_field_titre("Titre",$PHP_SELF, "a.title"); + print "
"; + $db->free(); + } + else + { + print $db->error(); + } +} +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); + + +/* + * + * + */ Function printc($id, $db, $level) { @@ -75,7 +178,7 @@ Function printc($id, $db, $level) print "  |--"; } - print "rowid\">".$cat->name."\n"; + print ''.$cat->name."\n"; print "\n"; $childs = array(); @@ -87,9 +190,23 @@ Function printc($id, $db, $level) printc($key,$db, $level+1); } } - } -$db->close(); -llxFooter("Dernière modification $Date$ révision $Revision$"); +Function title_url($id, $db) +{ + + $cat = new Categorie($db); + $cat->fetch($id); + + $title = $title . ''. $cat->name .""; + + + if (sizeof($cat->parent_id)) + { + $title = title_url($cat->parent_id, $db) . " / ".$title; + } + + return $title; +} + ?> diff --git a/htdocs/product/critiques/bestproduct.php b/htdocs/product/critiques/bestproduct.php index 19792298e79..becb60900b9 100644 --- a/htdocs/product/critiques/bestproduct.php +++ b/htdocs/product/critiques/bestproduct.php @@ -65,7 +65,7 @@ if ( $db->query($sql) ) { $objp = $db->fetch_object( $i); $var=!$var; print ""; - print "$objp->products_model\n"; + print ''.$objp->products_model.''; print ''.$objp->rat."\n"; print ''.$objp->products_quantity."\n"; print ''.$objp->products_status."\n";