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

   1  <?php
   2  /* Copyright (C) 2002-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 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: docsoc.php,v 1.24 2005/11/11 16:37:53 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/docsoc.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/docsoc.php
  25          \brief      Fichier onglet documents liés à la société
  26          \ingroup    societe
  27          \version    $Revision: 1.24 $
  28  */
  29  
  30  require ("./pre.inc.php");
  31  
  32  $langs->load("companies");
  33  
  34  
  35  llxHeader();
  36  
  37  $mesg = "";
  38  $socid=$_GET["socid"];
  39  
  40  
  41  /*
  42   * Creation répertoire si n'existe pas
  43   */
  44  $upload_dir = $conf->societe->dir_output . "/" . $socid ;
  45  if (! is_dir($upload_dir)) create_exdir($upload_dir);
  46  
  47  
  48  /*
  49   * Action envoie fichier
  50   */
  51  if ( $_POST["sendit"] && $conf->upload)
  52  {
  53      if (is_dir($upload_dir))
  54      {
  55          if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name']))
  56          {
  57              $mesg = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
  58              //print_r($_FILES);
  59          }
  60          else
  61          {
  62              // Echec transfert (fichier dépassant la limite ?)
  63              $mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
  64              // print_r($_FILES);
  65          }
  66      }
  67  }
  68  
  69  
  70  /*
  71   * Action suppression fichier
  72   */
  73  if ($_GET["action"]=='delete')
  74  {
  75      $file = $upload_dir . "/" . urldecode($_GET["urlfile"]);
  76      dol_delete_file($file);
  77      $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
  78  }
  79  
  80  
  81  /*
  82   * Affichage liste
  83   */
  84  
  85  if ($socid > 0)
  86  {
  87      $societe = new Societe($db);
  88      if ($societe->fetch($socid))
  89      {
  90          $h = 0;
  91  
  92          $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$societe->id;
  93          $head[$h][1] = $langs->trans("Company");
  94          $h++;
  95  
  96          if ($societe->client==1)
  97          {
  98              $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id;
  99              $head[$h][1] = $langs->trans("Customer");
 100              $h++;
 101          }
 102  
 103          if ($societe->client==2)
 104          {
 105              $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$societe->id;
 106              $head[$h][1] = $langs->trans("Prospect");
 107              $h++;
 108          }
 109          if ($societe->fournisseur)
 110          {
 111              $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$societe->id;
 112              $head[$h][1] = $langs->trans("Supplier");
 113              $h++;
 114          }
 115  
 116          if ($conf->compta->enabled) {
 117              $langs->load("compta");
 118              $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$societe->id;
 119              $head[$h][1] = $langs->trans("Accountancy");
 120              $h++;
 121          }
 122  
 123          $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$societe->id;
 124          $head[$h][1] = $langs->trans("Note");
 125          $h++;
 126  
 127          if ($user->societe_id == 0)
 128          {
 129              $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$societe->id;
 130              $head[$h][1] = $langs->trans("Documents");
 131              $hselected = $h;
 132              $h++;
 133          }
 134  
 135          $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$societe->id;
 136          $head[$h][1] = $langs->trans("Notifications");
 137          $h++;
 138  
 139          $head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$societe->id;
 140          $head[$h][1] = $langs->trans("Info");
 141          $h++;
 142          
 143          dolibarr_fiche_head($head, $hselected, $societe->nom);
 144  
 145          // Construit liste des fichiers
 146          clearstatcache();
 147  
 148          $totalsize=0;
 149          $filearray=array();
 150  
 151          $errorlevel=error_reporting();
 152          error_reporting(0);
 153          $handle=opendir($upload_dir);
 154          error_reporting($errorlevel);
 155          if ($handle)
 156          {
 157              $i=0;
 158              while (($file = readdir($handle))!==false)
 159              {
 160                  if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
 161                  {
 162                      $filearray[$i]=$file;
 163                      $totalsize+=filesize($upload_dir."/".$file);
 164                      $i++;
 165                  }
 166              }
 167              closedir($handle);
 168          }
 169          else
 170          {
 171  //            print '<div class="error">'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'</div>';
 172          }
 173          
 174          print '<table class="border"width="100%">';
 175          print '<tr><td width="30%">'.$langs->trans("Name").'</td><td colspan="3">'.$societe->nom.'</td></tr>';
 176          print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
 177          print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
 178          print '</table>';
 179  
 180          print '</div>';
 181  
 182          if ($mesg) { print "$mesg<br>"; }
 183  
 184          // Affiche forumlaire upload
 185          if (defined('MAIN_UPLOAD_DOC') && $conf->upload)
 186          {
 187              print_titre($langs->trans("AttachANewFile"));
 188              echo '<form name="userfile" action="docsoc.php?socid='.$socid.'" enctype="multipart/form-data" METHOD="POST">';
 189  
 190              print '<table class="noborder" width="100%">';
 191              print '<tr><td width="50%" valign="top">';
 192  
 193              print '<input type="hidden" name="max_file_size" value="2000000">';
 194              print '<input class="flat" type="file" name="userfile" size="40" maxlength="80">';
 195              print ' &nbsp; ';
 196              print '<input type="submit" class="button" value="'.$langs->trans("Add").'" name="sendit">';
 197  
 198              print "</td></tr>";
 199              print "</table>";
 200  
 201              print '</form>';
 202              print '<br>';
 203          }
 204  
 205          // Affiche liste des documents existant
 206          print_titre($langs->trans("AttachedFiles"));
 207  
 208          print '<table width="100%" class="noborder">';
 209          print '<tr class="liste_titre"><td>'.$langs->trans("Document").'</td><td align="right">'.$langs->trans("Size").'</td><td align="center">'.$langs->trans("Date").'</td><td>&nbsp;</td></tr>';
 210  
 211          $var=true;
 212          foreach($filearray as $key => $file)
 213          {
 214              if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
 215              {
 216                  $var=!$var;
 217                  print "<tr $bc[$var]><td>";
 218                  echo '<a href="'.DOL_URL_ROOT.'/document.php?modulepart=societe&type=application/binary&file='.urlencode($socid.'/'.$file).'">'.$file.'</a>';
 219                  print "</td>\n";
 220  
 221                  print '<td align="right">'.filesize($upload_dir."/".$file). ' '.$langs->trans("bytes").'</td>';
 222                  print '<td align="center">'.dolibarr_print_date(filemtime($upload_dir."/".$file),"%d %b %Y %H:%M:%S").'</td>';
 223  
 224                  print '<td align="center">';
 225                  echo '<a href="docsoc.php?socid='.$socid.'&action=delete&urlfile='.urlencode($file).'">'.img_delete().'</a>';
 226                  print "</td></tr>\n";
 227              }
 228          }
 229  
 230          print "</table>";
 231      }
 232      else
 233      {
 234          dolibarr_print_error($db);
 235      }
 236  }
 237  else
 238  {
 239      dolibarr_print_error();
 240  }
 241  
 242  $db->close();
 243  
 244  
 245  llxFooter('$Date: 2005/11/11 16:37:53 $ - $Revision: 1.24 $');
 246  
 247  ?>


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