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 "
'; + + +} +else +{ + if ($id) + { + + $auteur = new Auteur($db); + $result = $auteur->fetch($id); + + if ( $result ) + { + if ($action == 'edit') + { + print '