diff --git a/htdocs/boutique/auteur/auteur.class.php b/htdocs/boutique/auteur/auteur.class.php new file mode 100644 index 00000000000..8b9e2ac1498 --- /dev/null +++ b/htdocs/boutique/auteur/auteur.class.php @@ -0,0 +1,154 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + */ + +class Auteur { + var $db ; + + var $id ; + var $nom; + + Function Auteur($DB, $id=0) { + $this->db = $DB; + $this->id = $id ; + } + /* + * + * + * + */ + Function create($user) { + + $sql = "INSERT INTO llx_auteur (fk_user_author) VALUES (".$user->id.")"; + + if ($this->db->query($sql) ) + { + $id = $this->db->last_insert_id(); + + if ( $this->update($id, $user) ) + { + return $id; + } + } + + } + + /* + * + * + */ + Function liste_array () + { + $ga = array(); + + $sql = "SELECT rowid, nom FROM llx_auteur ORDER BY 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(); + } + + } + /* + * + * + * + */ + Function update($id, $user) + { + + $sql = "UPDATE llx_auteur "; + $sql .= " SET nom = '" . trim($this->nom) ."'"; + + $sql .= " WHERE rowid = " . $id; + + if ( $this->db->query($sql) ) { + return 1; + } else { + print $this->db->error() . ' in ' . $sql; + } + } + /* + * + * + * + */ + Function fetch ($id) { + + $sql = "SELECT rowid, nom FROM llx_auteur WHERE rowid = $id"; + + $result = $this->db->query($sql) ; + + if ( $result ) + { + $result = $this->db->fetch_array(); + + $this->id = $result["rowid"]; + $this->nom = stripslashes($result["nom"]); + + $this->db->free(); + } + else + { + print $this->db->error(); + } + + return $result; + } + + + /* + * + * + */ + Function delete($user) { + + $sql = "DELETE FROM ".DB_NAME_OSC.".products WHERE products_id = $idosc "; + + $sql = "DELETE FROM ".DB_NAME_OSC.".products_to_categories WHERE products_id = $idosc"; + + $sql = "DELETE FROM ".DB_NAME_OSC.".products_description WHERE products_id = $idosc"; + + $sql = "DELETE FROM llx_livre WHERE rowid = $id"; + + + } + + +} +?> diff --git a/htdocs/boutique/auteur/fiche.php b/htdocs/boutique/auteur/fiche.php new file mode 100644 index 00000000000..7b938012620 --- /dev/null +++ b/htdocs/boutique/auteur/fiche.php @@ -0,0 +1,153 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + */ + +require("./pre.inc.php"); + +llxHeader(); + +$db = new Db(); + +if ($action == 'add') { + $auteur = new Auteur($db); + + $auteur->nom = $nom; + + $id = $auteur->create($user); +} + +if ($action == 'addga') { + $auteur = new Auteur($db); + + $auteur->linkga($id, $ga); +} + + +if ($action == 'update' && !$cancel) { + $auteur = new Auteur($db); + + $auteur->nom = $nom; + + $auteur->update($id, $user); +} + +/* + * + * + */ +if ($action == 'create') +{ + + print "
\n"; + print ''; + + print '
Nouvel Auteur

'; + + print ''; + print ""; + print ''; + print ''; + print '
Nom
 
'; + print '
'; + + +} +else +{ + if ($id) + { + + $auteur = new Auteur($db); + $result = $auteur->fetch($id); + + if ( $result ) + { + if ($action == 'edit') + { + print '
Edition de la fiche Auteur : '.$auteur->nom.'

'; + + print "
\n"; + print ''; + + print ''; + print ""; + print ''; + + + print ''; + + print ''; + + print '
Nom
 

'; + + } + + print '
Fiche Auteur : '.$auteur->nom.'

'; + + print ''; + print ""; + print ''; + print "
Nom'.$auteur->nom.'
"; + + + + } + else + { + print "Fetch failed"; + } + + + } + else + { + print "Error"; + } +} + +/* ************************************************************************** */ +/* */ +/* Barre d'action */ +/* */ +/* ************************************************************************** */ + +print '
'; +print ''; +print ''; +print ''; + +if ($action == 'create') +{ + print ''; +} +else +{ + print ''; +} +print ''; +print '
----[Editer]-

'; + + + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/boutique/auteur/index.php b/htdocs/boutique/auteur/index.php new file mode 100644 index 00000000000..af92ad0a1a9 --- /dev/null +++ b/htdocs/boutique/auteur/index.php @@ -0,0 +1,75 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + */ + +require("./pre.inc.php"); + +llxHeader(); + +$db = new Db(); +if ($sortfield == "") { + $sortfield="lower(e.nom)"; +} +if ($sortorder == "") { + $sortorder="ASC"; +} + + +if ($page == -1) { $page = 0 ; } +$limit = $conf->liste_limit; +$offset = $limit * $page ; + +print_barre_liste("Liste des Auteurs", $page, $PHP_SELF); + +$sql = "SELECT e.rowid, e.nom FROM llx_auteur as e"; + +$sql .= " ORDER BY $sortfield $sortorder "; +$sql .= $db->plimit( $limit ,$offset); + +if ( $db->query($sql) ) { + $num = $db->num_rows(); + $i = 0; + print "

"; + print ""; + print "\n"; + $var=True; + while ($i < $num) { + $objp = $db->fetch_object( $i); + $var=!$var; + print ""; + print "\n"; + print "\n"; + $i++; + } + print "
"; + print_liste_field_titre("Nom",$PHP_SELF, "e.nom"); + print "
rowid\">$objp->nom
"; + $db->free(); +} +else +{ + print $db->error(); +} + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/boutique/auteur/pre.inc.php b/htdocs/boutique/auteur/pre.inc.php new file mode 100644 index 00000000000..3a0582eb28c --- /dev/null +++ b/htdocs/boutique/auteur/pre.inc.php @@ -0,0 +1,58 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + * + */ +require("../../main.inc.php3"); +require("../livre/livre.class.php"); +require("./auteur.class.php"); + +function llxHeader($head = "", $urlp = "") { + global $user, $conf; + + /* + * + * + */ + top_menu($head); + + $menu = new Menu(); + + $menu->add("/boutique/livre/", "Livres"); + + $menu->add_submenu("/boutique/livre/fiche.php?&action=create","Nouvel ouvrage"); + + $menu->add("/boutique/auteur/", "Auteur"); + + $menu->add_submenu("/boutique/auteur/fiche.php?&action=create","Nouvel auteur"); + + $menu->add("/boutique/editeur/", "Editeurs"); + + $menu->add_submenu("/boutique/editeur/fiche.php?&action=create","Nouvel éditeur"); + + $menu->add("/product/categorie/", "Catégories"); + + left_menu($menu->liste); + /* + * + * + */ + +} +?>