* Copyright (C) 2004 Laurent Destailleur * * 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"); if ( $_POST["sendit"] ) { global $local_file, $error_msg; $upload_dir = OSC_CATALOG_DIRECTORY."/images/"; if (! is_dir($upload_dir)) { umask(0); mkdir($upload_dir, 0755); } if (move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) { print "Le fichier est valide, et a été téléchargé avec succès.\n"; //print_r($_FILES); } else { echo "Le fichier n'a pas été téléchargé"; // print_r($_FILES); } if ($id or $oscid) { $livre = new Livre($db); if ($id) { $result = $livre->fetch($id, 0); $livre->update_image($_FILES['userfile']['name']); $livre->updateosc($user); } } } 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; $livre->frais_de_port = $_POST["fdp"]; $id = $livre->create($user); } if ($action == 'addga') { $livre = new Livre($db); $livre->linkga($id, $coauteurid); } if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes") { $livre = new Livre($db); $livre->fetch($id); $livre->delete(); Header("Location: index.php"); } if ($action == 'linkcat') { $livre = new Livre($db); $livre->fetch($id); $livre->linkcategorie( $catid); } if ($action == 'delcat') { $livre = new Livre($db); $livre->fetch($id); $livre->unlinkcategorie($catid); } if ($action == 'delauteur' && $auteurid) { $livre = new Livre($db); $livre->fetch($id); $livre->auteur_unlink($auteurid); } if ($action == "status") { $livre = new Livre($db); $livre->fetch($id); if ($livre->update_status($status)) { } } if ($action == 'update' && !$cancel) { $livre = new Livre($db); $livre->titre = $titre; $livre->ref = $ref; $livre->price = $price; $livre->frais_de_port = $_POST["fdp"]; $livre->annee = $annee; $livre->editeurid = $editeurid; $livre->description = $desc; if ($livre->update($id, $user)) { $result = $livre->fetch($id); $livre->updateosc($user); } else { $action = 'edit'; } } if ($action == 'updateosc') { $livre = new Livre($db); $result = $livre->fetch($id); $livre->updateosc($user); } /* * * */ llxHeader(); if ($action == 'create') { print "
\n"; print ""; print '
Nouvel ouvrage

'; print ''; print ""; print ''; print ''; print ''; print ''; $htmls = new Form($db); $edits = new Editeur($db); print ""; print '"; print ''; print '
Référence
Titre
'.$langs->trans("Price").'
Frais de port
Editeur"; $htmls->select_array("editeurid", $edits->liste_array(), $livre->editeurid); print "
'.$langs->trans("Description").''; print '
 
'; print '
'; } else { if ($id or $oscid) { $livre = new Livre($db); if ($id) { $result = $livre->fetch($id, 0); } if ($oscid) { $result = $livre->fetch(0, $oscid); $id = $livre->id; } if ( $result ) { $htmls = new Form($db); $auteurs = $livre->liste_auteur(); /* * Confirmation de la suppression de l'adhérent * */ if ($action == 'delete') { $htmls = new Form($db); $htmls->form_confirm("fiche.php?id=$id","Supprimer un ouvrage","Etes-vous sur de vouloir supprimer cet ouvrage ?","confirm_delete"); } if ($action == 'edit') { print '
Edition de la fiche Livre : '.$livre->titre.'

'; print "
\n"; print ""; print ''; print ""; print ''; print ''; print '\n"; print '"; print ''; print ''; print ''; print ''; $htmls = new Form($db); $edits = new Editeur($db); print ""; print '"; print ''; print ""; print ''; $auteur = new Auteur($db); print "\n"; print ""; print ''; print ""; print "\n"; print ''; $listecat = new Categorie($db); print ''; print ""; print "\n"; print '\n"; print '
'.$langs->trans("Ref").''.$langs->trans("Description").'
'.$langs->trans("Status").''.$livre->status_text; if ($livre->status == 0) { print '
Changer'; } else { print '
Changer'; } print "
Titre
Année
'.$langs->trans("Price").'
Frais de port
Editeur"; $htmls->select_array("editeurid", $edits->liste_array(), $livre->editeurid); print "
Auteur(s)'; foreach ($auteurs as $key => $value) { print ''; print 'Supprimer '; print ''.$value."
\n"; } print "
 
Auteur(s)'; $htmls->select_array("coauteurid", $auteur->liste_array()); print ' 
Catégories'; $htmls->select_array("catid", $listecat->liste_array()); print ' 
Vignette'; echo '
'; print ''; print '
'; print ''; print '
'; print '
'; print "

'; } /* * Affichage */ print '
Fiche Livre : '.$livre->titre.'

'; print ''; print ""; print ''; print ''; print ''; print '\n"; print '"; print '"; print "\n"; print "\n"; print ''; print '"; print ''; print ''; } else { print 'non'; } print "
'.$langs->trans("Ref").''.$livre->ref.''.$langs->trans("Description").'Catégories
'.$langs->trans("Status").''.$livre->status_text; if ($livre->status == 0) { print '
Changer'; } else { print '
Changer'; } print "
'.nl2br($livre->description); $img = OSC_CATALOG_DIRECTORY."images/".$livre->image; if(file_exists($img)) { print '

'; } print "

'; $livre->listcategorie(); print "
Titre$livre->titre
Annee$livre->annee
Editeur'; if ($livre->editeurid) { $editeur = new Editeur($db); $editeur->fetch($livre->editeurid); print $editeur->nom; } print '
Auteur(s)'; foreach ($auteurs as $key => $value) { print ''; print $value."
\n"; } print "
'.$langs->trans("Price").''.price($livre->price).'
Frais de port'; if ($livre->frais_de_port) { print 'oui
"; } else { print "Fetch failed"; } } else { print "Error"; } } /* ************************************************************************** */ /* */ /* Barre d'action */ /* */ /* ************************************************************************** */ print '
'; if ($action != 'create') { print ''.$langs->trans("Edit").''; } print ''.$langs->trans("Delete").''; print '
'; $db->close(); llxFooter("Dernière modification $Date$ révision $Revision$"); ?>