[ 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/comm/action/ -> 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.6 2005/10/01 14:27:47 eldy Exp $
  23   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/action/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.6 $
  31  */
  32  
  33  require_once ("./pre.inc.php");
  34  require_once (DOL_DOCUMENT_ROOT."/contact.class.php");
  35  require_once(DOL_DOCUMENT_ROOT."/cactioncomm.class.php");
  36  require_once (DOL_DOCUMENT_ROOT."/actioncomm.class.php");
  37  if ($conf->webcal->enabled) require_once(DOL_DOCUMENT_ROOT."/lib/webcal.class.php");
  38  
  39  $langs->load("companies");
  40  $langs->load("commercial");
  41  $langs->load("other");
  42  $langs->load("bills");
  43  
  44  if (isset($_GET["error"])) $error=$_GET["error"];
  45  $upload_dir = $conf->actionscomm->dir_output.'/'.$_GET['id'];
  46  
  47  // Sécurité accés client
  48  if ($user->societe_id > 0) 
  49  {
  50    $action = '';
  51    $socidp = $user->societe_id;
  52  }
  53  
  54  
  55  /*
  56   * Action envoie fichier
  57   */
  58  if ( $_POST["sendit"] && $conf->upload )
  59  {
  60      /*
  61       * Creation répertoire si n'existe pas
  62       */
  63      if (! is_dir($upload_dir)) create_exdir($upload_dir);
  64  
  65      if (is_dir($upload_dir))
  66      {
  67          if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']))
  68          {
  69              $mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
  70              //print_r($_FILES);
  71          }
  72          else
  73          {
  74              // Echec transfert (fichier dépassant la limite ?)
  75              $mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
  76              // print_r($_FILES);
  77          }
  78      }
  79  }
  80  
  81  /*
  82   * Efface fichier
  83   */
  84  if ($_GET["action"] == 'delete')
  85  {
  86      $file = $upload_dir . '/' . urldecode($_GET['urlfile']);
  87      dol_delete_file($file);
  88  }
  89  
  90  
  91  /*
  92   * Affiche onglet
  93   */
  94  
  95  llxHeader();
  96  
  97  
  98  if ($_GET["id"] > 0)
  99  {
 100      if ( $error_msg )
 101      { 
 102          echo '<div class="error">'.$error_msg.'</div><br>';
 103      }
 104      
 105      $act = new ActionComm($db);
 106      $act->fetch($_GET["id"]);
 107      $res=$act->societe->fetch($act->societe->id);
 108      $res=$act->author->fetch();     // Le paramètre est le login, hors seul l'id est chargé.
 109      $res=$act->contact->fetch($act->contact->id);
 110  
 111      $h=0;
 112  
 113      $head[$h][0] = DOL_URL_ROOT.'/comm/action/fiche.php?id='.$_GET["id"];
 114      $head[$h][1] = $langs->trans("CardAction");
 115      $hselected=$h;
 116      $h++;
 117  
 118      $head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$_GET["id"];
 119      $head[$h][1] = $langs->trans('Documents');
 120      $hselected=$h;
 121      $h++;
 122  
 123      dolibarr_fiche_head($head, $hselected, $langs->trans("Ref")." ".$act->id);
 124  
 125      // Affichage fiche action en mode visu
 126      print '<table class="border" width="100%"';
 127      print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td colspan="3">'.$act->id.'</td></tr>';
 128      print '<tr><td>'.$langs->trans("Type").'</td><td colspan="3">'.$act->type.'</td></tr>';
 129      print '<tr><td>'.$langs->trans("Title").'</td><td colspan="3">'.$act->label.'</td></tr>';
 130      print '<tr><td>'.$langs->trans("Company").'</td>';
 131      print '<td>'.img_object($langs->trans("ShowCompany"),'company').' '.$act->societe->nom_url.'</td>';
 132  
 133      print '<td>'.$langs->trans("Contact").'</td>';
 134      print '<td>';
 135      if ($act->contact->id) print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$act->contact->id.'">'.img_object($langs->trans("ShowContact"),'contact').' '.$act->contact->fullname.'</a>';
 136      else print $langs->trans("None");
 137      print '</td></tr>';
 138      
 139      // Auteur
 140      print '<tr><td>'.$langs->trans("Author").'</td>';
 141      print '<td colspan="3"><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$act->author->id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$act->author->fullname.'</a></td></tr>';
 142  
 143      // Date
 144      print '<tr><td>'.$langs->trans("Date").'</td><td colspan="3">'.dolibarr_print_date($act->date,'%d %B %Y %H:%M').'</td></tr>';
 145      
 146      // Construit liste des fichiers
 147      clearstatcache();
 148  
 149      $totalsize=0;
 150      $filearray=array();
 151  
 152      if (is_dir($upload_dir))
 153      {
 154          $errorlevel=error_reporting();
 155          error_reporting(0);
 156          $handle=opendir($upload_dir);
 157          error_reporting($errorlevel);
 158          if ($handle)
 159          {
 160              $i=0;
 161              while (($file = readdir($handle))!==false)
 162              {
 163                  if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
 164                  {
 165                      $filearray[$i]=$file;
 166                      $totalsize+=filesize($upload_dir."/".$file);
 167                      $i++;
 168                  }
 169              }
 170              closedir($handle);
 171          }
 172          else
 173          {
 174                  print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
 175          }
 176      }
 177      
 178      print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
 179      print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
 180      print '</table>';
 181  
 182      print '</div>';
 183  
 184  
 185      // Affiche forumlaire upload
 186      if (defined('MAIN_UPLOAD_DOC') && $conf->upload)
 187      {
 188          print_titre($langs->trans('AttachANewFile'));
 189  
 190          print '<form name="userfile" action="document.php?id='.$act->id.'" enctype="multipart/form-data" method="POST">';
 191  
 192          print '<table class="noborder" width="100%">';
 193          print '<tr><td width="50%" valign="top">';
 194  
 195          print '<input type="hidden" name="max_file_size" value="2000000">';
 196          print '<input class="flat" type="file" name="userfile" size="40" maxlength="80">';
 197          print ' &nbsp; ';
 198          print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="sendit">';
 199  
 200          print "</td></tr>";
 201          print "</table>";
 202  
 203          print '</form>';
 204          print '<br>';
 205      }
 206      
 207      $errorlevel=error_reporting();
 208      error_reporting(0);
 209      $handle=opendir($upload_dir);
 210      error_reporting($errorlevel);
 211  
 212      print '<table width="100%" class="noborder">';
 213  
 214      if ($handle)
 215      {
 216          print '<tr class="liste_titre">';
 217          print '<td>'.$langs->trans('Document').'</td>';
 218          print '<td align="right">'.$langs->trans('Size').'</td>';
 219          print '<td align="center">'.$langs->trans('Date').'</td>';
 220          print '<td>&nbsp;</td>';
 221          print '</tr>';
 222          $var=true;
 223          while (($file = readdir($handle))!==false)
 224          {
 225              if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
 226              {
 227                  $var=!$var;
 228                  print '<tr '.$bc[$var].'>';
 229                  print '<td>';
 230                  echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=ationscomm&file='.$act->id.'/'.urlencode($file).'">'.$file.'</a>';
 231                  print "</td>\n";
 232                  print '<td align="right">'.filesize($upload_dir.'/'.$file). ' bytes</td>';
 233                  print '<td align="center">'.strftime('%d %b %Y %H:%M:%S',filemtime($upload_dir.'/'.$file)).'</td>';
 234                  print '<td align="center">';
 235                  print '<a href="'.DOL_URL_ROOT.'/comm/action/document.php?id='.$act->id.'&action=delete&urlfile='.urlencode($file).'">'.img_delete($langs->trans('Delete')).'</a>';
 236                  print "</td></tr>\n";
 237              }
 238          }
 239          closedir($handle);
 240      }
 241      print '</table>';
 242  
 243      print '</div>';
 244  }
 245  else
 246  {
 247      print $langs->trans("UnkownError");
 248  }
 249  
 250  $db->close();
 251  
 252  llxFooter('$Date: 2005/10/01 14:27:47 $ - $Revision: 1.6 $');
 253  ?>


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