diff --git a/htdocs/boutique/livre/fiche.php b/htdocs/boutique/livre/fiche.php new file mode 100644 index 00000000000..3b4fcf0bc11 --- /dev/null +++ b/htdocs/boutique/livre/fiche.php @@ -0,0 +1,252 @@ + + * + * 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') { + $livre = new Livre($db); + + $livre->titre = $titre; + $livre->ref = $ref; + $livre->price = $price; + $livre->annee = $annee; + $livre->editeurid = $editeurid; + $livre->description = $desc; + + $id = $livre->create($user); +} + +if ($action == 'addga') { + $livre = new Livre($db); + + $livre->linkga($id, $coauteurid); +} + + +if ($action == 'update' && !$cancel) { + $livre = new Livre($db); + + $livre->titre = $titre; + $livre->ref = $ref; + $livre->price = $price; + $livre->annee = $annee; + $livre->editeurid = $editeurid; + $livre->description = $desc; + + $livre->update($id, $user); +} + +if ($action == 'updateosc') { + $livre = new Livre($db); + $result = $livre->fetch($id); + + $livre->updateosc($user); +} + +/* + * + * + */ +if ($action == 'create') +{ + + print "
\n"; + print ""; + + print '
Nouvel ouvrage

'; + + print ''; + print ""; + print ''; + print ''; + print ''; + print ""; + print ''; + print '
Référence
Titre
Prix
Description"; + print '
 
'; + print '
'; + + +} +else +{ + if ($id) + { + + $livre = new Livre($db); + $result = $livre->fetch($id); + + if ( $result ) + { + $htmls = new Form($db); + $auteurs = $livre->liste_auteur(); + + if ($action == 'edit') + { + print '
Edition de la fiche Livre : '.$livre->titre.'

'; + + print "
\n"; + print ""; + + print ''; + print ""; + print ''; + print ""; + + print ''; + print '"; + + print ''; + print ''; + $htmls = new Form($db); + $edits = new Editeur($db); + + print ""; + + print '"; + /* + $c = new Categorie($db); + print ""; + */ + + print ''; + print ""; + + print ''; + + $auteur = new Auteur($db); + + print "\n"; + print ""; + + print "'; + print ""; + + + print '
RéférenceDescription
Titre
Année
Prix
Editeur"; + $htmls->select_array("editeurid", $edits->liste_array(), $livre->editeurid); + print "
Co-Auteurs'; + + foreach ($auteurs as $key => $value) + { + print ''.$value."
\n"; + } + print "
Editeur"; + $htmls->select_array("editeurid", $c->liste_array()); + print "
 
Co-Auteur"; + $htmls->select_array("coauteurid", $auteur->liste_array()); + print ' 

'; + + } + + print '
Fiche Livre : '.$livre->titre.'

'; + + print ''; + print ""; + print ''; + print ''; + + print "\n"; + print '"; + print "\n"; + print "\n"; + + print ''; + print '"; + print ''; + + $listecat = new Categorie($db); + + + print '\n"; + + print "
Référence'.$livre->ref.'Description
Statut$livre->status_text'.nl2br($livre->description)."
Titre$livre->titre
Annee$livre->annee
Editeur'; + + if ($livre->editeurid) + { + $editeur = new Editeur($db); + $editeur->fetch($livre->editeurid); + print $editeur->nom; + } + print '
Co-Auteurs'; + + foreach ($auteurs as $key => $value) + { + print ''.$value."
\n"; + } + print "
Prix'.price($livre->price).'
Artiste/Groupe'; + + $htmls->select_array("catd", $listecat->liste_array()); + + print "
"; + + + + } + else + { + print "Fetch failed"; + } + + + } + else + { + print "Error"; + } +} + +/* ************************************************************************** */ +/* */ +/* Barre d'action */ +/* */ +/* ************************************************************************** */ + +print '
'; +print ''; + +print ''; + +print ''; + +if ($action == 'create') +{ + print ''; +} +else +{ + print ''; +} +print ''; +print '
-[Update Osc]--[Editer]-

'; + +$db->close(); + +llxFooter("Dernière modification $Date$ révision $Revision$"); +?> diff --git a/htdocs/boutique/livre/livre.class.php b/htdocs/boutique/livre/livre.class.php new file mode 100644 index 00000000000..7b172cfea6a --- /dev/null +++ b/htdocs/boutique/livre/livre.class.php @@ -0,0 +1,338 @@ + + * + * 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 Livre { + var $db ; + + var $id ; + var $oscid ; + var $ref; + var $price; + var $annee; + var $editeurid; + var $titre; + var $description; + var $price ; + var $status ; + + Function Livre($DB, $id=0) { + $this->db = $DB; + $this->id = $id ; + } + /* + * + * + * + */ + Function create($user) { + + if (strlen($this->annee)) + { + $this->annee = 0; + } + + $sql = "insert into ".DB_NAME_OSC.".products (products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_date_added) "; + $sql .= "values ('', '', 'Array', '', null, '', '0', '0', '8', now())"; + + if ($this->db->query($sql) ) + { + $idosc = $this->db->last_insert_id(); + + $sql = "insert into ".DB_NAME_OSC.".products_to_categories (products_id, categories_id) values ($idosc, 0)"; + + if ($this->db->query($sql) ) + { + + $sql = "insert into ".DB_NAME_OSC.".products_description (products_name, products_description, products_url, products_id, language_id) values ('".trim($this->titre)."', '".trim($this->description)."', '', $idosc, '1')"; + + if ($this->db->query($sql) ) + { + + $sql = "INSERT INTO llx_livre (oscid, fk_user_author) VALUES ($idosc, ".$user->id.")"; + + if ($this->db->query($sql) ) + { + $id = $this->db->last_insert_id(); + + if ( $this->update($id, $user) ) + { + return $id; + } + } + else + { + print $this->db->error() . ' in ' . $sql; + } + + } + else + { + print $this->db->error() . ' in ' . $sql; + } + + } + else + { + print $this->db->error() . ' in ' . $sql; + } + + } + else + { + print $this->db->error() . ' in ' . $sql; + } + + } + + /* + * + * + * + */ + Function linkga($id, $gaid) + { + + $sql = "INSERT INTO llx_livre_to_auteur (fk_livre, fk_auteur) values ($id, $gaid)"; + + if ( $this->db->query($sql) ) + { + return 1; + } + 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(); + } + } + /* + * + * + * + */ + Function updateosc() + { + + $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; + } + } + /* + * + * + * + */ + Function update($id, $user) + { + + if (strlen($this->annee)==0) + { + $this->annee = 0; + } + + $sql = "UPDATE llx_livre "; + $sql .= " SET title = '" . trim($this->titre) ."'"; + $sql .= ", ref = '" . trim(strtoupper($this->ref)) ."'"; + $sql .= ", prix = " . $this->price .""; + $sql .= ", annee = " . $this->annee ; + $sql .= ", fk_editeur = " . $this->editeurid ; + $sql .= ", description = '" . trim($this->description) ."'"; + + $sql .= " WHERE rowid = " . $id; + + if ( $this->db->query($sql) ) { + return 1; + } else { + print $this->db->error() . ' in ' . $sql; + } + } + /* + * + * + * + */ + Function fetch ($id) { + + $sql = "SELECT rowid, fk_editeur, ref, prix, annee, oscid, title, description FROM llx_livre WHERE rowid = $id"; + + $result = $this->db->query($sql) ; + + if ( $result ) + { + $result = $this->db->fetch_array(); + + $this->id = $result["rowid"]; + $this->ref = $result["ref"]; + $this->price = $result["prix"]; + $this->annee = $result["annee"]; + $this->editeurid = $result["fk_editeur"]; + $this->titre = stripslashes($result["title"]); + $this->description = stripslashes($result["description"]); + $this->oscid = $result["oscid"]; + + $this->db->free(); + + + $sql = "SELECT products_quantity, products_model, products_image, products_price, products_date_available, products_weight, products_status, products_tax_class_id, manufacturers_id, products_date_added"; + $sql .= " FROM ".DB_NAME_OSC.".products WHERE products_id = " . $this->oscid; + + $result = $this->db->query($sql) ; + + if ( $result ) + { + $result = $this->db->fetch_array(); + + $this->status = $result["products_status"]; + + if ($this->status) + { + $this->status_text = "En vente"; + } + else + { + $this->status_text = "Cet article n'est pas en vente"; + } + + $this->db->free(); + } + else + { + print $this->db->error(); + } + } + 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/theme/yellow/img/icon_status_green.png b/htdocs/theme/yellow/img/icon_status_green.png new file mode 100644 index 00000000000..099051eaae1 Binary files /dev/null and b/htdocs/theme/yellow/img/icon_status_green.png differ diff --git a/htdocs/theme/yellow/img/icon_status_green_light.png b/htdocs/theme/yellow/img/icon_status_green_light.png new file mode 100644 index 00000000000..2df56ba79a6 Binary files /dev/null and b/htdocs/theme/yellow/img/icon_status_green_light.png differ diff --git a/htdocs/theme/yellow/img/icon_status_red.png b/htdocs/theme/yellow/img/icon_status_red.png new file mode 100644 index 00000000000..3aea419e213 Binary files /dev/null and b/htdocs/theme/yellow/img/icon_status_red.png differ diff --git a/htdocs/theme/yellow/img/icon_status_red_light.png b/htdocs/theme/yellow/img/icon_status_red_light.png new file mode 100644 index 00000000000..638c74c5dd5 Binary files /dev/null and b/htdocs/theme/yellow/img/icon_status_red_light.png differ diff --git a/htdocs/theme/yellow/img/tick.png b/htdocs/theme/yellow/img/tick.png new file mode 100644 index 00000000000..331e64d0495 Binary files /dev/null and b/htdocs/theme/yellow/img/tick.png differ