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

   1  <?php
   2  /* Copyright (C) 2003-2004 Rodolphe Quiedeville  <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur   <eldy@users.sourceforge.net>
   4   * Copyright (C) 2005      Marc Barilley / Ocebo <marc@ocebo.com>
   5   * Copyright (C) 2005      Regis Houssin         <regis.houssin@cap-networks.com>
   6   * Copyright (C) 2005      Simon TOSSER         <simon@kornog-computing.com>
   7   *
   8   * This program is free software; you can redistribute it and/or modify
   9   * it under the terms of the GNU General Public License as published by
  10   * the Free Software Foundation; either version 2 of the License, or
  11   * (at your option) any later version.
  12   *
  13   * This program is distributed in the hope that it will be useful,
  14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16   * GNU General Public License for more details.
  17   *
  18   * You should have received a copy of the GNU General Public License
  19   * along with this program; if not, write to the Free Software
  20   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21   *
  22   * $Id: document.php,v 1.9 2005/12/03 11:48:44 hregis Exp $
  23   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/product/document.php,v $
  24   */
  25   
  26  /**
  27          \file       htdocs/product/document.php
  28          \ingroup    product
  29          \brief      Page des documents joints sur les produits
  30          \version    $Revision: 1.9 $
  31  */
  32  
  33  require ('./pre.inc.php');
  34  require_once(DOL_DOCUMENT_ROOT."/product.class.php");
  35  
  36  $langs->load("other");
  37  
  38  $user->getrights('produit');
  39  
  40  if (!$user->rights->produit->lire)
  41      accessforbidden();
  42  
  43  $action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
  44  
  45  $product = new Product($db);
  46  if ($_GET['id'] || $_GET["ref"])
  47  {
  48      if ($_GET["ref"]) $result = $product->fetch('',$_GET["ref"]);
  49      if ($_GET["id"]) $result = $product->fetch($_GET["id"]);
  50  
  51      $prodref = sanitize_string($product->ref);
  52      $upload_dir = $conf->produit->dir_output.'/'.$prodref;
  53  }
  54  
  55  
  56  /*
  57   * Action envoie fichier
  58   */
  59  if ($_POST["sendit"] && $conf->upload)
  60  {
  61      /*
  62       * Creation répertoire si n'existe pas
  63       */
  64      if (! is_dir($upload_dir)) create_exdir($upload_dir);
  65  
  66      if (is_dir($upload_dir))
  67      {
  68          if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']))
  69          {
  70              $mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
  71              //print_r($_FILES);
  72          }
  73          else
  74          {
  75              // Echec transfert (fichier dépassant la limite ?)
  76              $mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
  77              // print_r($_FILES);
  78          }
  79      }
  80  }
  81  
  82  
  83  
  84  llxHeader();
  85  
  86  
  87  if ($product->id)
  88  {
  89      if ( $error_msg )
  90      { 
  91          echo '<div class="error">'.$error_msg.'</div><br>';
  92      }
  93  
  94      if ($action=='delete')
  95      {
  96          $file = $upload_dir . '/' . urldecode($_GET['urlfile']);
  97          dol_delete_file($file);
  98      }
  99  
 100      $h=0;
 101  
 102      $head[$h][0] = DOL_URL_ROOT."/product/fiche.php?id=".$product->id;
 103      $head[$h][1] = $langs->trans("Card");
 104      $hselected = $h;
 105      $h++;
 106  
 107      $head[$h][0] = DOL_URL_ROOT."/product/price.php?id=".$product->id;
 108      $head[$h][1] = $langs->trans("Price");
 109      $h++;
 110  
 111      if($product->type == 0)
 112      {
 113          if ($user->rights->barcode->lire)
 114          {
 115              if ($conf->barcode->enabled)
 116              {
 117                  $head[$h][0] = DOL_URL_ROOT."/product/barcode.php?id=".$product->id;
 118                  $head[$h][1] = $langs->trans("BarCode");
 119                  $h++;
 120              }
 121          }
 122      }
 123  
 124      $head[$h][0] = DOL_URL_ROOT."/product/photos.php?id=".$product->id;
 125      $head[$h][1] = $langs->trans("Photos");
 126      $h++;
 127  
 128      if($product->type == 0)
 129      {
 130          if ($conf->stock->enabled)
 131          {
 132              $head[$h][0] = DOL_URL_ROOT."/product/stock/product.php?id=".$product->id;
 133              $head[$h][1] = $langs->trans("Stock");
 134              $h++;
 135          }
 136      }
 137  
 138      if ($conf->fournisseur->enabled)
 139      {
 140          $head[$h][0] = DOL_URL_ROOT."/product/fournisseurs.php?id=".$product->id;
 141          $head[$h][1] = $langs->trans("Suppliers");
 142          $h++;
 143      }
 144  
 145      $head[$h][0] = DOL_URL_ROOT."/product/stats/fiche.php?id=".$product->id;
 146      $head[$h][1] = $langs->trans('Statistics');
 147      $h++;
 148  
 149      //erics: pour créer des produits composés de x 'sous' produits
 150      /*
 151      $head[$h][0] = DOL_URL_ROOT."/product/pack.php?id=".$product->id;
 152      $head[$h][1] = $langs->trans('Packs');
 153      $h++;
 154      */
 155  
 156      $head[$h][0] = DOL_URL_ROOT."/product/stats/facture.php?id=".$product->id;
 157      $head[$h][1] = $langs->trans('Referers');
 158      $h++;
 159  
 160      $head[$h][0] = DOL_URL_ROOT.'/product/document.php?id='.$product->id;
 161      $head[$h][1] = $langs->trans('Documents');
 162      $hselected=$h;
 163      $h++;
 164  
 165      $titre=$langs->trans("CardProduct".$product->type);
 166      dolibarr_fiche_head($head, $hselected, $titre);
 167  
 168      // Construit liste des fichiers
 169      clearstatcache();
 170  
 171      $totalsize=0;
 172      $filearray=array();
 173  
 174      $errorlevel=error_reporting();
 175      error_reporting(0);
 176      $handle=opendir($upload_dir);
 177      error_reporting($errorlevel);
 178      if ($handle)
 179      {
 180          $i=0;
 181          while (($file = readdir($handle))!==false)
 182          {
 183              if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
 184              {
 185                  $filearray[$i]=$file;
 186                  $totalsize+=filesize($upload_dir."/".$file);
 187                  $i++;
 188              }
 189          }
 190          closedir($handle);
 191      }
 192      else
 193      {
 194  //            print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
 195      }
 196      
 197      print '<table class="border" width="100%">';
 198  
 199      // Reference
 200      print '<tr>';
 201      print '<td width="28%">'.$langs->trans("Ref").'</td><td colspan="3">';
 202      $product->load_previous_next_ref();
 203      $previous_ref = $product->ref_previous?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_previous.'">'.img_previous().'</a>':'';
 204      $next_ref     = $product->ref_next?'<a href="'.$_SERVER["PHP_SELF"].'?ref='.$product->ref_next.'">'.img_next().'</a>':'';
 205      if ($previous_ref || $next_ref) print '<table class="nobordernopadding" width="100%"><tr class="nobordernopadding"><td class="nobordernopadding">';
 206      print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$product->id.'">'.$product->ref.'</a>';
 207      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>';
 208      print '</td>';
 209      print '</tr>';
 210  
 211      // Libelle
 212      print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$product->libelle.'</td></tr>';
 213  
 214      print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
 215      print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
 216      print '</table>';
 217  
 218      print '</div>';
 219  
 220  
 221      // Affiche forumlaire upload
 222      if (defined('MAIN_UPLOAD_DOC') && $conf->upload)
 223      {
 224          print_titre($langs->trans('AttachANewFile'));
 225  
 226          print '<form name="userfile" action="document.php?id='.$product->id.'" enctype="multipart/form-data" method="POST">';
 227  
 228          print '<table class="noborder" width="100%">';
 229          print '<tr><td width="50%" valign="top">';
 230  
 231          print '<input type="hidden" name="max_file_size" value="2000000">';
 232          print '<input class="flat" type="file" name="userfile" size="40" maxlength="80">';
 233          print ' &nbsp; ';
 234          print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="sendit">';
 235  
 236          print "</td></tr>";
 237          print "</table>";
 238  
 239          print '</form>';
 240          print '<br>';
 241      }
 242      
 243      $errorlevel=error_reporting();
 244      error_reporting(0);
 245      $handle=opendir($upload_dir);
 246      error_reporting($errorlevel);
 247  
 248      print '<table width="100%" class="noborder">';
 249  
 250      if ($handle)
 251      {
 252          print '<tr class="liste_titre">';
 253          print '<td>'.$langs->trans('Document').'</td>';
 254          print '<td align="right">'.$langs->trans('Size').'</td>';
 255          print '<td align="center">'.$langs->trans('Date').'</td>';
 256          print '<td>&nbsp;</td>';
 257          print '</tr>';
 258          $var=true;
 259          while (($file = readdir($handle))!==false)
 260          {
 261              if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
 262              {
 263                  $var=!$var;
 264                  print '<tr '.$bc[$var].'>';
 265                  print '<td>';
 266                  echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=produit&file='.$prodref.'/'.urlencode($file).'">'.$file.'</a>';
 267                  print "</td>\n";
 268                  print '<td align="right">'.filesize($upload_dir.'/'.$file). ' bytes</td>';
 269                  print '<td align="center">'.strftime('%d %b %Y %H:%M:%S',filemtime($upload_dir.'/'.$file)).'</td>';
 270                  print '<td align="center">';
 271                  if ($file == $propref . '.pdf')
 272                  {
 273                      echo '-';
 274                  }
 275                  else
 276                  {
 277                      echo '<a href="'.DOL_URL_ROOT.'/product/document.php?id='.$product->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>';
 278                  }
 279                  print "</td></tr>\n";
 280              }
 281          }
 282          closedir($handle);
 283      }
 284      print '</table>';
 285  
 286  }
 287  else
 288  {
 289      print $langs->trans("UnkownError");
 290  }
 291  
 292  $db->close();
 293  
 294  llxFooter('$Date: 2005/12/03 11:48:44 $ - $Revision: 1.9 $');
 295  ?>


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