diff --git a/htdocs/boutique/livre/fiche.php b/htdocs/boutique/livre/fiche.php
index 3b4fcf0bc11..78d7a18be9b 100644
--- a/htdocs/boutique/livre/fiche.php
+++ b/htdocs/boutique/livre/fiche.php
@@ -39,12 +39,19 @@ if ($action == 'add') {
$id = $livre->create($user);
}
-if ($action == 'addga') {
+if ($action == 'addga')
+{
$livre = new Livre($db);
-
$livre->linkga($id, $coauteurid);
}
+if ($action == 'linkcat')
+{
+ $livre = new Livre($db);
+ $livre->fetch($id);
+ $livre->linkcategorie( $catid);
+}
+
if ($action == 'update' && !$cancel) {
$livre = new Livre($db);
@@ -83,6 +90,14 @@ if ($action == 'create')
print '
Référence | | ';
print 'Titre | | ';
print '| Prix | |
';
+
+ $htmls = new Form($db);
+ $edits = new Editeur($db);
+
+ print "| Editeur | ";
+ $htmls->select_array("editeurid", $edits->liste_array(), $livre->editeurid);
+ print " |
";
+
print "| Description | ";
print ' |
";
@@ -116,7 +131,6 @@ else
print "";
print '| Référence | | ';
print "Description |
";
-
print 'Titre | | ';
print ' | ";
- /*
- $c = new Categorie($db);
- print "| Editeur | ";
- $htmls->select_array("editeurid", $c->liste_array());
- print " |
";
- */
+
print '| |
';
print "";
@@ -160,6 +169,15 @@ else
print ' ';
print "";
+ print "";
+ print "\n";
print '
';
@@ -169,11 +187,16 @@ else
print '';
print "";
- print '| Référence | '.$livre->ref.' | ';
- print 'Description |
';
-
+ print 'Référence | '.$livre->ref.' | ';
+ print 'Description | ';
+ print 'Catégories | ';
print "| Statut | $livre->status_text | \n";
print ''.nl2br($livre->description)." | ";
+
+ print '';
+ $livre->listcategorie();
+ print " |
";
+
print "| Titre | $livre->titre |
\n";
print "| Annee | $livre->annee |
\n";
@@ -195,15 +218,6 @@ else
print "";
print '| Prix | '.price($livre->price).' |
';
- $listecat = new Categorie($db);
-
-
- print 'Artiste/Groupe | ';
-
- $htmls->select_array("catd", $listecat->liste_array());
-
- print " | \n";
-
print "
";
diff --git a/htdocs/boutique/livre/livre.class.php b/htdocs/boutique/livre/livre.class.php
index 7b172cfea6a..cd54da8aceb 100644
--- a/htdocs/boutique/livre/livre.class.php
+++ b/htdocs/boutique/livre/livre.class.php
@@ -156,6 +156,78 @@ class Livre {
print $this->db->error();
}
}
+ /*
+ *
+ *
+ */
+ Function linkcategorie($categories_id)
+ {
+
+ $sql = "INSERT INTO ".DB_NAME_OSC.".products_to_categories ";
+
+ $sql .= " (products_id, categories_id)";
+ $sql .= " VALUES (".$this->oscid.",".$categories_id.")";
+
+ if ( $this->db->query($sql) )
+ {
+ return 1;
+ }
+ else
+ {
+ print $this->db->error() . ' in ' . $sql;
+ }
+ }
+ /*
+ *
+ *
+ */
+ Function listcategorie()
+ {
+ $listecat = new Categorie($this->db);
+ $cats = $listecat->liste_array();
+
+ $pcat = array();
+
+ $sql = "SELECT products_id, categories_id";
+ $sql .= " FROM ".DB_NAME_OSC.".products_to_categories ";
+ $sql .= " WHERE products_id = " . $this->oscid;
+
+ if ($this->db->query($sql) )
+ {
+ $nump = $this->db->num_rows();
+
+ if ($nump)
+ {
+ $i = 0;
+ while ($i < $nump)
+ {
+ $obj = $this->db->fetch_object($i);
+ $pcat[$i] = $obj->categories_id;
+ $i++;
+ }
+ }
+ }
+
+ foreach ($cats as $key => $value)
+ {
+ $test = 0;
+ for ($i = 0 ; $i < $nump ; $i++)
+ {
+ if ($pcat[$i] == $key)
+ {
+ $test = 1;
+ }
+ }
+ if ($test)
+ {
+ print "$value
";
+ }
+ else
+ {
+ print "$value
";
+ }
+ }
+ }
/*
*
*
diff --git a/htdocs/product/categorie/categorie.class.php b/htdocs/product/categorie/categorie.class.php
index 2daaf0559ab..b8c5a34a1ab 100644
--- a/htdocs/product/categorie/categorie.class.php
+++ b/htdocs/product/categorie/categorie.class.php
@@ -86,7 +86,7 @@ class Categorie {
$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 .= " AND c.parent_id = 0 ORDER BY cd.categories_name";
if ( $this->db->query($sql) )
{
@@ -96,9 +96,12 @@ class Categorie {
while ($i < $num)
{
$objp = $this->db->fetch_object( $i);
+
+ $cl[$objp->categories_id] = $objp->categories_name;
+
$var=!$var;
$pc = array();
- $pc = $this->printc($objp->categories_id, 0);
+ $pc = $this->printc($objp->categories_id, 1);
foreach($pc as $key => $value)
{
$cl[$key] = $value;
@@ -109,36 +112,39 @@ class Categorie {
return $cl;
}
/*
+ *
*/
Function printc($id, $level)
{
$cr = array();
$cat = new Categorie($this->db);
$cat->fetch($id);
-
+
for ($i = 0 ; $i < $level ; $i++)
{
- $string = " |--";
+ $prefix .= " ";
}
- $string .= $cat->name;
-
-
+ $cr[$cat->id] = $cat->name;
$childs = array();
$childs = $cat->liste_childs_array();
-
+
if (sizeof($childs))
{
foreach($childs as $key => $value)
{
- $cr[$key] = $value;
- $this->printc($key, $level+1);
+ $pc = array();
+ $pc = $this->printc($key,$level+1);
+ foreach($pc as $key => $value)
+ {
+ $cr[$key] = $prefix . $value;
+ }
}
}
-
return $cr;
}
+
/*
*
*
@@ -151,7 +157,7 @@ class Categorie {
$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 = " . $this->id;
-
+ $sql .= " ORDER BY cd.categories_name";
if ($this->db->query($sql) )
{
$nump = $this->db->num_rows();
diff --git a/htdocs/product/categorie/index.php b/htdocs/product/categorie/index.php
index fa9726739c8..ccb0d4e0518 100644
--- a/htdocs/product/categorie/index.php
+++ b/htdocs/product/categorie/index.php
@@ -25,16 +25,6 @@ require("./pre.inc.php");
llxHeader();
$db = new Db();
-if ($sortfield == "") {
- $sortfield="lower(cd.categories_name)";
-}
-if ($sortorder == "") {
- $sortorder="ASC";
-}
-
-if ($page == -1) { $page = 0 ; }
-$limit = $conf->liste_limit;
-$offset = $limit * $page ;
print_barre_liste("Liste des catégories", $page, $PHP_SELF);
@@ -42,8 +32,7 @@ $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 $sortfield $sortorder ";
-$sql .= $db->plimit( $limit ,$offset);
+$sql .= " ORDER BY cd.categories_name ASC ";
if ( $db->query($sql) )
{