[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/boutique/livre/ -> fiche.php (source)

   1  <?php
   2  /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: fiche.php,v 1.26 2005/09/17 00:53:50 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/boutique/livre/fiche.php,v $
  21   *
  22   */
  23  
  24  require ("./pre.inc.php");
  25  
  26  if ( $_POST["sendit"] )
  27  {
  28    global $local_file, $error_msg;
  29  
  30    $upload_dir = OSC_CATALOG_DIRECTORY."/images/";
  31    
  32    if (! is_dir($upload_dir))
  33      {
  34        umask(0);
  35        mkdir($upload_dir, 0755);
  36      }
  37      
  38    if (move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']))
  39      {
  40        print "Le fichier est valide, et a &eacute;t&eacute; t&eacute;l&eacute;charg&eacute; avec succ&egrave;s.\n";
  41        //print_r($_FILES);
  42      }
  43    else
  44      {
  45        echo "Le fichier n'a pas été téléchargé";
  46        // print_r($_FILES);
  47      }
  48  
  49    if ($id or $oscid)
  50      {
  51        $livre = new Livre($db);
  52        
  53        if ($id)
  54      {
  55        $result = $livre->fetch($id, 0);
  56        $livre->update_image($_FILES['userfile']['name']);
  57        $livre->updateosc($user);
  58      }
  59      }
  60  }
  61  
  62  
  63  if ($action == 'add')
  64  {
  65    $livre = new Livre($db);
  66  
  67    $livre->titre = $titre;
  68    $livre->ref = $ref;
  69    $livre->price = $price;
  70    $livre->annee = $annee;
  71    $livre->editeurid = $editeurid;
  72    $livre->description = $desc;
  73    $livre->frais_de_port = $_POST["fdp"];
  74  
  75    $id = $livre->create($user);
  76  }
  77  
  78  if ($action == 'addga')
  79  {
  80    $livre = new Livre($db);
  81    $livre->linkga($id, $coauteurid);
  82  }
  83  
  84  if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == "yes")
  85  {
  86    $livre = new Livre($db);
  87    $livre->fetch($id);
  88    $livre->delete();
  89    Header("Location: index.php");
  90  }
  91  
  92  
  93  if ($action == 'linkcat')
  94  {
  95    $livre = new Livre($db);
  96    $livre->fetch($id);
  97    $livre->linkcategorie( $catid);
  98  }
  99  
 100  if ($action == 'delcat')
 101  {
 102    $livre = new Livre($db);
 103    $livre->fetch($id);
 104    $livre->unlinkcategorie($catid);
 105  }
 106  
 107  if ($action == 'delauteur' && $auteurid)
 108  {
 109    $livre = new Livre($db);
 110    $livre->fetch($id);
 111    $livre->auteur_unlink($auteurid);
 112  }
 113  
 114  if ($action == "status")
 115  {
 116    $livre = new Livre($db);
 117    $livre->fetch($id);
 118    if ($livre->update_status($status))
 119      {
 120        
 121      }
 122  }
 123  
 124  if ($action == 'update' && !$cancel)
 125  {
 126    $livre = new Livre($db);
 127  
 128    $livre->titre = $titre;
 129    $livre->ref = $ref;
 130    $livre->price = $price;
 131    $livre->frais_de_port = $_POST["fdp"];
 132    $livre->annee = $annee;
 133    $livre->editeurid = $editeurid;
 134    $livre->description = $desc;
 135  
 136    if ($livre->update($id, $user))
 137      {
 138        $result = $livre->fetch($id);
 139        $livre->updateosc($user);
 140      }
 141    else
 142      {
 143        $action = 'edit';
 144      }
 145  }
 146  
 147  if ($action == 'updateosc')
 148  {
 149    $livre = new Livre($db);
 150    $result = $livre->fetch($id);
 151  
 152    $livre->updateosc($user);
 153  }
 154  
 155  /*
 156   *
 157   *
 158   */
 159  
 160  llxHeader();
 161  
 162  if ($action == 'create')
 163  {
 164  
 165    print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
 166    print "<input type=\"hidden\" name=\"action\" value=\"add\">";
 167  
 168    print '<div class="titre">Nouvel ouvrage</div><br>';
 169        
 170    print '<table border="1" width="100%" cellspacing="0" cellpadding="4">';
 171    print "<tr>";
 172    print '<td>Référence</td><td><input name="ref" size="20" value=""></td></tr>';
 173    print '<td>Titre</td><td><input name="titre" size="40" value=""></td></tr>';
 174    print '<tr><td>'.$langs->trans("Price").'</td><TD><input name="price" size="10" value=""></td></tr>';    
 175  
 176    print '<tr><td>Frais de port</td><td><select name="fdp">';
 177    print '<option value="1" selected="true">oui</option>';
 178    print '<option value="0">non</option></td></tr>';
 179  
 180    $htmls = new Form($db);
 181    $edits = new Editeur($db);
 182            
 183    print "<tr><td>Editeur</td><td>";
 184    $htmls->select_array("editeurid",  $edits->liste_array(), $livre->editeurid);
 185    print "</td></tr>";
 186  
 187    print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
 188    print '<textarea name="desc" rows="8" cols="50">';
 189    print "</textarea></td></tr>";
 190    print '<tr><td>&nbsp;</td><td><input type="submit" value="Créer"></td></tr>';
 191    print '</table>';
 192    print '</form>';
 193        
 194  
 195  }
 196  else
 197  {
 198    if ($id or $oscid)
 199      {
 200        $livre = new Livre($db);
 201  
 202        if ($id)
 203      {
 204        $result = $livre->fetch($id, 0);
 205      }
 206        if ($oscid)
 207      {
 208        $result = $livre->fetch(0, $oscid);
 209        $id = $livre->id;
 210      }
 211  
 212        if ( $result )
 213      { 
 214        $htmls = new Form($db);
 215        $auteurs = $livre->liste_auteur();
 216  
 217  
 218        /*
 219         * Confirmation de la suppression de l'adhérent
 220         *
 221         */
 222        
 223        if ($action == 'delete')
 224          {
 225            $htmls = new Form($db);
 226            $htmls->form_confirm("fiche.php?id=$id","Supprimer un ouvrage","Etes-vous sur de vouloir supprimer cet ouvrage ?","confirm_delete");
 227          }
 228        
 229  
 230        if ($action == 'edit')
 231          {
 232            print '<div class="titre">Edition de la fiche Livre : '.$livre->titre.'</div><br>';
 233            
 234            print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
 235            print "<input type=\"hidden\" name=\"action\" value=\"update\">";
 236            
 237            print '<table class="border" width="100%">';
 238            print "<tr>";
 239            print '<td width="20%">'.$langs->trans("Ref").'</td><td><input name="ref" size="20" value="'.$livre->ref.'"></td>';
 240            print '<td valign="top">'.$langs->trans("Description").'</td></tr>';
 241  
 242            print '<tr><td>'.$langs->trans("Status").'</td><td>'.$livre->status_text;
 243            if ($livre->status == 0)
 244          {
 245            print '<br><a href="fiche.php?id='.$id.'&status=1&action=status">Changer</a>';
 246          }
 247            else
 248          {
 249            print '<br><a href="fiche.php?id='.$id.'&status=0&action=status">Changer</a>';
 250          }
 251            print "</td>\n";
 252            
 253            print '<td valign="top" width="50%" rowspan="7"><textarea name="desc" rows="14" cols="60">';
 254            print $livre->description;
 255            print "</textarea></td></tr>";
 256  
 257            print '<tr><td>Titre</td><td><input name="titre" size="40" value="'.$livre->titre.'"></td></tr>';
 258  
 259            print '<tr><td>Année</td><TD><input name="annee" size="6" maxlenght="4" value="'.$livre->annee.'"></td></tr>';
 260            print '<tr><td>'.$langs->trans("Price").'</td><TD><input name="price" size="10" value="'.price($livre->price).'"></td></tr>';
 261            print '<tr><td>Frais de port</td><td><select name="fdp">';
 262            if ($livre->frais_de_port)
 263          {
 264            print '<option value="1" selected="true">oui</option>';
 265            print '<option value="0">non</option>';
 266          }
 267            else
 268          {
 269            print '<option value="1">oui</option>';
 270            print '<option value="0" selected="true">non</option>';
 271          }
 272            print '</select></td></tr>';
 273  
 274            $htmls = new Form($db);
 275            $edits = new Editeur($db);
 276            
 277            print "<tr><td>Editeur</td><td>";
 278            $htmls->select_array("editeurid",  $edits->liste_array(), $livre->editeurid);
 279            print "</td></tr>";
 280  
 281            print '<tr><td>Auteur(s)</td><td>';
 282  
 283            foreach ($auteurs as $key => $value)
 284          {
 285            print '<a href="fiche.php?id='.$id.'&action=delauteur&auteurid='.$key.'">';
 286            print '<img src="/theme/'.$conf->theme.'/img/editdelete.png" height="16" width="16" alt="Supprimer" border="0"></a>&nbsp;';
 287            print '<a href="../auteur/fiche.php?id='.$key.'">'.$value."<br>\n";
 288          }
 289            print "</td></tr>";
 290  
 291  
 292            print '<tr><td align="center" colspan="3"><input type="submit" value="'.$langs->trans("Save").'">&nbsp;<input type="submit" value="'.$langs->trans("Cancel").'" name="cancel"></td></tr>';
 293            print "</form>";
 294  
 295            print '</form>';
 296            
 297            $auteur = new Auteur($db);
 298            
 299            print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
 300            print "<input type=\"hidden\" name=\"action\" value=\"addga\">";
 301  
 302            print '<tr><td>Auteur(s)</td><td colspan="2">';
 303            $htmls->select_array("coauteurid",  $auteur->liste_array());
 304            print '&nbsp;<input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
 305            print "</form>";
 306  
 307            print "<form action=\"fiche.php?id=$id\" method=\"post\">\n";
 308            print '<input type="hidden" name="action" value="linkcat">';
 309  
 310            $listecat = new Categorie($db);
 311            print '<td valign="top">Catégories</td><td colspan="2">';
 312            $htmls->select_array("catid", $listecat->liste_array());
 313            print '&nbsp;<input type="submit" value="'.$langs->trans("Add").'"></td></tr>';
 314            print "</form>";
 315            print "</td></tr>\n";
 316  
 317            print '<td valign="top">Vignette</td><td colspan="2">';
 318            echo '<FORM NAME="userfile" ACTION="fiche.php?id='.$id.'" ENCTYPE="multipart/form-data" METHOD="POST">';      
 319            print '<input type="hidden" name="max_file_size" value="2000000">';
 320            print '<input type="file"   name="userfile" size="40" maxlength="80"><br>';
 321            print '<input type="submit" value="Upload File!" name="sendit">';
 322            print '<input type="submit" value="'.$langs->trans("Cancel").'" name="cancelit"><BR>';
 323            print '</form>';
 324            print "</td></tr>\n";
 325  
 326            print '</table><hr>';
 327            
 328          }    
 329  
 330        /*
 331         * Affichage
 332         */
 333  
 334        print '<div class="titre">Fiche Livre : '.$livre->titre.'</div><br>';
 335  
 336        print '<table class="border" width="100%">';
 337        print "<tr>";
 338        print '<td width="15%">'.$langs->trans("Ref").'</td><td width="20%">'.$livre->ref.'</td>';
 339        print '<td width="50%" valign="top">'.$langs->trans("Description").'</td>';
 340        print '<td valign="top">Catégories</td></tr>';
 341        print '<tr><td>'.$langs->trans("Status").'</td><td>'.$livre->status_text;
 342        if ($livre->status == 0)
 343          {
 344            print '<br><a href="fiche.php?id='.$id.'&status=1&action=status">Changer</a>';
 345          }
 346        else
 347          {
 348            print '<br><a href="fiche.php?id='.$id.'&status=0&action=status">Changer</a>';
 349          }
 350        print "</td>\n";
 351        print '<td rowspan="7" valign="top">'.nl2br($livre->description);
 352  
 353        $img = OSC_CATALOG_DIRECTORY."images/".$livre->image;
 354  
 355        if(file_exists($img))
 356          {
 357            print '<p><img src="'.OSC_CATALOG_URL.'/images/'.$livre->image.'">';
 358          }
 359        print "</td>";
 360  
 361        print '<td rowspan="7" valign="top">';
 362        $livre->listcategorie();
 363        print "</td></tr>";
 364        
 365        print "<tr><td>Titre</td><td>$livre->titre</td></tr>\n";
 366        print "<tr><td>Annee</td><td>$livre->annee</td></tr>\n";
 367  
 368        print '<tr><td>Editeur</td><TD>';    
 369  
 370        if ($livre->editeurid)
 371          {
 372            $editeur = new Editeur($db);
 373            $editeur->fetch($livre->editeurid);
 374            print $editeur->nom;    
 375          }
 376        print '</td></tr>';
 377        print '<tr><td>Auteur(s)</td><td>';
 378  
 379        foreach ($auteurs as $key => $value)
 380          {          
 381            print '<a href="../auteur/fiche.php?id='.$key.'">';
 382            print $value."</a><br>\n";
 383          }
 384        print "</td></tr>";
 385        print '<tr><td>'.$langs->trans("Price").'</td><TD>'.price($livre->price).'</td></tr>';    
 386        print '<tr><td>Frais de port</td><td>';
 387        if ($livre->frais_de_port)
 388          {
 389            print 'oui</td></tr>';
 390          }
 391        else
 392          {
 393            print 'non</td></tr>';
 394          }
 395        print "</table>";
 396      }
 397        else
 398      {
 399        print "Fetch failed";
 400      }
 401      
 402  
 403      }
 404    else
 405      {
 406        print "Error";
 407      }
 408  }
 409  
 410  /* ************************************************************************** */
 411  /*                                                                            */ 
 412  /* Barre d'action                                                             */ 
 413  /*                                                                            */ 
 414  /* ************************************************************************** */
 415  
 416  print '<div class="tabsAction">';
 417  if ($action != 'create')
 418  {
 419    print '<a class="tabAction" href="fiche.php?action=edit&id='.$id.'">'.$langs->trans("Edit").'</a>';
 420  }
 421  
 422  print '<a class="tabAction" href="fiche.php?action=delete&id='.$id.'">'.$langs->trans("Delete").'</a>';
 423  print '</div>';
 424  
 425  $db->close();
 426  
 427  llxFooter("<em>Derni&egrave;re modification $Date: 2005/09/17 00:53:50 $ r&eacute;vision $Revision: 1.26 $</em>");
 428  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics