[ 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/product/ -> photos.php (source)

   1  <?php
   2  /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   * Copyright (C) 2005      Eric Seigne          <eric.seigne@ryxeo.com>
   5   * Copyright (C) 2005      Regis Houssin        <regis.houssin@cap-networks.com>
   6   *
   7   * This program is free software; you can redistribute it and/or modify
   8   * it under the terms of the GNU General Public License as published by
   9   * the Free Software Foundation; either version 2 of the License, or
  10   * (at your option) any later version.
  11   *
  12   * This program is distributed in the hope that it will be useful,
  13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15   * GNU General Public License for more details.
  16   *
  17   * You should have received a copy of the GNU General Public License
  18   * along with this program; if not, write to the Free Software
  19   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20   *
  21   * $Id: photos.php,v 1.20 2005/12/03 03:49:01 eldy Exp $
  22   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/photos.php,v $
  23   */
  24  
  25  /**
  26          \file       htdocs/product/photos.php
  27          \ingroup    product
  28          \brief      Onglet photos de la fiche produit
  29          \version    $Revision: 1.20 $
  30  */
  31  
  32  require ("./pre.inc.php");
  33  require_once (DOL_DOCUMENT_ROOT."/propal.class.php");
  34  require_once (DOL_DOCUMENT_ROOT."/facture.class.php");
  35  require_once(DOL_DOCUMENT_ROOT."/product.class.php");
  36  
  37  $langs->load("products");
  38  $langs->load("bills");
  39  
  40  $user->getrights('produit');
  41  $user->getrights('propale');
  42  $user->getrights('facture');
  43  $mesg = '';
  44  
  45  if (!$user->rights->produit->lire) accessforbidden();
  46  
  47  $types[0] = $langs->trans("Product");
  48  $types[1] = $langs->trans("Service");
  49  
  50  
  51  /*
  52   * Actions
  53   */
  54  
  55  if ($_POST["sendit"] && $conf->global->MAIN_UPLOAD_DOC)
  56  {
  57      if ($_GET["id"])
  58      {
  59          $product = new Product($db);
  60          $result = $product->fetch($_GET["id"]);
  61  
  62          // if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']))
  63  
  64          //      var_dump($_FILES);
  65  
  66          $product->add_photo($conf->produit->dir_output, $_FILES['photofile']);
  67      }
  68  }
  69  
  70  if ($_GET["action"] == 'delete' && $_GET["file"]) 
  71  {
  72      unlink($conf->produit->dir_output."/".$_GET["file"]);
  73  }
  74  
  75  
  76  /*
  77   *
  78   */
  79  
  80  llxHeader("","",$langs->trans("CardProduct0"));
  81  
  82  
  83  if ($_GET["id"] || $_GET["ref"])
  84  {
  85  
  86      $product = new Product($db);
  87      if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
  88      if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
  89  
  90      if ($result)
  91      {
  92          /*
  93           *  En mode visu
  94           */
  95  
  96          $h=0;
  97  
  98          $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
  99          $head[$h][1] = $langs->trans("Card");
 100          $h++;
 101  
 102          $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
 103          $head[$h][1] = $langs->trans("Price");
 104          $h++;
 105  
 106          if($product->type == 0)
 107          {
 108             if ($user->rights->barcode->lire)
 109             {
 110                 if ($conf->barcode->enabled)
 111                 {
 112                     $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id;
 113                     $head[$h][1] = $langs->trans("BarCode");
 114                     $h++;
 115                 }
 116              }
 117          }
 118  
 119  
 120          $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
 121          $head[$h][1] = $langs->trans("Photos");
 122          $hselected = $h;
 123          $h++;
 124  
 125          if($product->type == 0)
 126          {
 127              if ($conf->stock->enabled)
 128              {
 129                  $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
 130                  $head[$h][1] = $langs->trans("Stock");
 131                  $h++;
 132              }
 133          }
 134          
 135          if ($conf->fournisseur->enabled)
 136          {
 137              $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
 138              $head[$h][1] = $langs->trans("Suppliers");
 139              $h++;
 140          }
 141  
 142          $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
 143          $head[$h][1] = $langs->trans('Statistics');
 144          $h++;
 145  
 146          //erics: pour créer des produits composés de x 'sous' produits
 147          /*
 148          $head[$h][0] = DOL_URL_ROOT."/product/pack.php?id=".$product->id;
 149          $head[$h][1] = $langs->trans('Packs');
 150          $h++;
 151          */
 152          
 153          $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
 154          $head[$h][1] = $langs->trans('Referers');
 155          $h++;
 156  
 157          $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id;
 158          $head[$h][1] = $langs->trans('Documents');
 159          $h++;
 160  
 161          $titre=$langs->trans("CardProduct".$product->type);
 162          dolibarr_fiche_head($head, $hselected, $titre);
 163  
 164          print($mesg);
 165  
 166          print '<table class="border" width="100%">';
 167  
 168          // Reference
 169          print '<tr>';
 170          print '<td width="15%">'.$langs->trans("Ref").'</td><td colspan="2">';
 171          $product->load_previous_next_ref();
 172          $previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':'';
 173          $next_ref     = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':'';
 174          if ($previous_ref || $next_ref) print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">';
 175          print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>';
 176          if ($previous_ref || $next_ref) print '</td><td class="nobordernopadding" align="center" width="20">'.$previous_ref.'</td><td class="nobordernopadding" align="center" width="20">'.$next_ref.'</td></tr></table>';
 177          print '</td>';
 178          print '</tr>';
 179  
 180          // Libelle
 181          print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$product->libelle.'</td>';
 182          print '</tr>';
 183  
 184          // Prix
 185          print '<tr><td>'.$langs->trans("SellingPrice").'</td><td colspan="2">'.price($product->price).'</td></tr>';
 186  
 187          // Statut
 188          print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">';
 189          if ($product->envente) print $langs->trans("OnSell");
 190          else print $langs->trans("NotOnSell");
 191          print '</td></tr>';
 192  
 193          print "</table>\n";
 194  
 195          print "</div>\n";
 196  
 197  
 198  
 199          /* ************************************************************************** */
 200          /*                                                                            */
 201          /* Barre d'action                                                             */
 202          /*                                                                            */
 203          /* ************************************************************************** */
 204  
 205          print "\n<div class=\"tabsAction\">\n";
 206  
 207          if ($_GET["action"] != 'ajout_photo' && $user->rights->produit->creer && $conf->upload)
 208          {
 209              print '<a class="tabAction" href="'.DOL_URL_ROOT.'/product/photos.php?action=ajout_photo&amp;id='.$product->id.'">';
 210              print $langs->trans("AddPhoto").'</a>';
 211          }
 212  
 213          print "\n</div>\n";
 214  
 215          /*
 216           * Ajouter une photo
 217           */
 218          if ($_GET["action"] == 'ajout_photo' && $conf->upload && $user->rights->produit->creer)
 219          {
 220              print_titre($langs->trans("AddPhoto"));
 221  
 222              print '<form name="userfile" action="'.DOL_URL_ROOT.'/product/photos.php?id='.$product->id.'" enctype="multipart/form-data" METHOD="POST">';
 223              print '<input type="hidden" name="max_file_size" value="'.$conf->maxfilesize.'">';
 224              print '<input type="hidden" name="id" value="'.$product->id.'">';
 225  
 226              print '<table class="border" width="100%"><tr>';
 227              print '<td>'.$langs->trans("File").' ('.$langs->trans("Size").' <= '.$conf->maxfilesize.')</td>';
 228              print '<td><input type="file" class="flat" name="photofile"></td></tr>';
 229  
 230              print '<tr><td colspan="2" align="center">';
 231              print '<input type="submit" class="button" name="sendit" value="'.$langs->trans("Upload").'"> &nbsp; ';
 232  
 233              print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td></tr>';
 234              print '</table>';
 235              print '</form>';
 236          }
 237  
 238          // Affiche photos
 239          if ($_GET["action"] != 'ajout_photo')
 240          {
 241              $nbphoto=0;
 242              $nbbyrow=5;
 243              
 244              $pdir = get_exdir($product->id) . $product->id ."/photos/";
 245              $dir = $conf->produit->dir_output . '/'. $pdir;
 246  
 247              print '<br><table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
 248              
 249              foreach ($product->liste_photos($dir) as $obj)
 250              {
 251                  $nbphoto++;
 252  
 253  //                if ($nbbyrow && $nbphoto == 1) print '<table width="100%" valign="top" align="center" border="0" cellpadding="2" cellspacing="2">';
 254  
 255                  if ($nbbyrow && ($nbphoto % $nbbyrow == 1)) print '<tr align=center valign=middle border=1>';
 256                  if ($nbbyrow) print '<td width="'.ceil(100/$nbbyrow).'%" class="photo">';
 257                  
 258                  print '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$obj->photo).'" alt="Taille origine" target="_blank">';
 259  
 260                  // Si fichier vignette disponible, on l'utilise, sinon on utilise photo origine
 261                  if ($obj->photo_vignette) $filename=$obj->photo_vignette;
 262                  else $filename=$obj->photo;
 263                  print '<img border="0" height="120" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=product&file='.urlencode($pdir.$filename).'">';
 264  
 265                  print '</a>';
 266                  print '<br>'.$langs->trans("File").': '.dolibarr_trunc($filename,16);
 267                  if ($user->rights->produit->creer)
 268                  {
 269                      print '<br>'.'<a href="'.$_SERVER["PHP_SELF"].'?id='.$_GET["id"].'&amp;action=delete&amp;file='.urlencode($pdir.$filename).'">'.img_delete().'</a>';
 270                  }
 271                  if ($nbbyrow) print '</td>';
 272                  if ($nbbyrow && ($nbphoto % $nbbyrow == 0)) print '</tr>';
 273              }
 274              
 275              // Ferme tableau
 276              while ($nbphoto % $nbbyrow)
 277              {
 278                  print '<td width="'.ceil(100/$nbbyrow).'%">&nbsp;</td>';
 279                  $nbphoto++;
 280              }
 281              
 282              if ($nbphoto < 1)
 283              {
 284                  print '<tr align=center valign=middle border=1><td class="photo">';
 285                  print "<br>".$langs->trans("NoPhotoYet")."<br><br>";
 286                  print '</td></tr></table>';
 287              }
 288  
 289             print '</table>';
 290          }
 291      }
 292  }
 293  else
 294  {
 295      print $langs->trans("ErrorUnknown");
 296  }
 297  
 298  
 299  
 300  $db->close();
 301  
 302  llxFooter('$Date: 2005/12/03 03:49:01 $ - $Revision: 1.20 $');
 303  ?>


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