diff --git a/htdocs/docsoc.php b/htdocs/docsoc.php index ebac5e0e8d0..ea06d58d4e5 100644 --- a/htdocs/docsoc.php +++ b/htdocs/docsoc.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2002-2007 Rodolphe Quiedeville * Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2005-2006 Regis Houssin * @@ -22,10 +22,10 @@ */ /** - \file htdocs/docsoc.php - \brief Fichier onglet documents liés à la société - \ingroup societe - \version $Revision$ + \file htdocs/docsoc.php + \brief Fichier onglet documents liés à la société + \ingroup societe + \version $Revision$ */ require("./pre.inc.php"); @@ -43,48 +43,47 @@ $socid = isset($_GET["socid"])?$_GET["socid"]:''; if ($socid == '') accessforbidden(); if ($user->societe_id > 0) { - $action = ''; - $socid = $user->societe_id; + $action = ''; + $socid = $user->societe_id; } // Protection restriction commercial if (!$user->rights->commercial->client->voir && $socid && !$user->societe_id > 0) { - $sql = "SELECT sc.fk_soc, s.client"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."societe as s"; - $sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_user = ".$user->id." AND s.client = 1"; - - if ( $db->query($sql) ) - { - if ( $db->num_rows() == 0) accessforbidden(); - } + $sql = "SELECT sc.fk_soc, s.client"; + $sql .= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc, ".MAIN_DB_PREFIX."societe as s"; + $sql .= " WHERE sc.fk_soc = ".$socid." AND sc.fk_user = ".$user->id." AND s.client = 1"; + + if ( $db->query($sql) ) + { + if ( $db->num_rows() == 0) accessforbidden(); + } } /* * Actions */ - $upload_dir = $conf->societe->dir_output . "/" . $socid ; - +$courrier_dir = $conf->societe->dir_output . "/courrier/" . get_exdir($socid) ; // Envoie fichier if ( $_POST["sendit"] && $conf->upload != 0) { - if (! is_dir($upload_dir)) create_exdir($upload_dir); - - if (is_dir($upload_dir)) + if (! is_dir($upload_dir)) create_exdir($upload_dir); + + if (is_dir($upload_dir)) { - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) + if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'])) { - $mesg = '
'.$langs->trans("FileTransferComplete").'
'; - //print_r($_FILES); + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + //print_r($_FILES); } - else + else { - // Echec transfert (fichier dépassant la limite ?) - $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; - // print_r($_FILES); + // Echec transfert (fichier dépassant la limite ?) + $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; + // print_r($_FILES); } } } @@ -92,12 +91,11 @@ if ( $_POST["sendit"] && $conf->upload != 0) // Suppression fichier if ($_GET["action"]=='delete') { - $file = $upload_dir . "/" . urldecode($_GET["urlfile"]); - dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $file = $upload_dir . "/" . urldecode($_GET["urlfile"]); + dol_delete_file($file); + $mesg = '
'.$langs->trans("FileWasRemoved").'
'; } - /* * Affichage liste */ @@ -108,68 +106,67 @@ if ($socid > 0) { $societe = new Societe($db); if ($societe->fetch($socid)) - { - /* - * Affichage onglets - */ - $head = societe_prepare_head($societe); + { + /* + * Affichage onglets + */ + $head = societe_prepare_head($societe); + + dolibarr_fiche_head($head, 'document', $societe->nom); - dolibarr_fiche_head($head, 'document', $societe->nom); - - // Construit liste des fichiers clearstatcache(); - + $totalsize=0; $filearray=array(); - + $errorlevel=error_reporting(); - error_reporting(0); - $handle=opendir($upload_dir); - error_reporting($errorlevel); + error_reporting(0); + $handle=opendir($upload_dir); + error_reporting($errorlevel); if ($handle) - { + { $i=0; while (($file = readdir($handle))!==false) - { + { if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { + { $filearray[$i]=$file; $totalsize+=filesize($upload_dir."/".$file); $i++; - } - } + } + } closedir($handle); - } + } else - { -// print '
'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'
'; - } + { + // print '
'.$langs->trans("ErrorCanNotReadDir",$upload_dir).'
'; + } print ''; - - // Ref + + // Ref print ''; - // Prefix - print ''; - - // Nbre fichiers - print ''; - - //Total taille - print ''; - + // Prefix + print ''; + + // Nbre fichiers + print ''; + + //Total taille + print ''; + print '
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans('Prefix').''.$societe->prefix_comm.'
'.$langs->trans("NbOfAttachedFiles").''.sizeof($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'.$langs->trans('Prefix').''.$societe->prefix_comm.'
'.$langs->trans("NbOfAttachedFiles").''.sizeof($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; - + print ''; - + if ($mesg) { print "$mesg
"; } - - // Affiche formulaire upload - $html=new Form($db); - $html->form_attach_new_file('docsoc.php?socid='.$socid,$langs->trans("AddPhoto"),0); - + + // Affiche formulaire upload + $html=new Form($db); + $html->form_attach_new_file('docsoc.php?socid='.$socid,$langs->trans("AddPhoto"),0); + // Affiche liste des documents existant print_titre($langs->trans("AttachedFiles")); @@ -178,33 +175,72 @@ if ($socid > 0) $var=true; foreach($filearray as $key => $file) - { + { if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') - { + { $var=!$var; print ""; echo ''.$file.''; print "\n"; - print ''.filesize($upload_dir."/".$file). ' '.$langs->trans("bytes").''; print ''.dolibarr_print_date(filemtime($upload_dir."/".$file),"%d %b %Y %H:%M:%S").''; - print ''; echo ''.img_delete().''; print "\n"; } } + print "

"; + // Courriers + // Les courriers sont des documents speciaux generes par des scripts + // Voir Rodo + $filearray=array(); + $errorlevel=error_reporting(); + error_reporting(0); + $handle=opendir($courrier_dir); + error_reporting($errorlevel); + if ($handle) + { + $i=0; + while (($file = readdir($handle))!==false) + { + if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + $filearray[$i]=$file; + $i++; + } + } + closedir($handle); + } + print ''; + print ''; + + $var=true; + foreach($filearray as $key => $file) + { + if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + $var=!$var; + print "\n"; + + print ''; + print ''; + print "\n"; + } + } print "
'.$langs->trans("Courriers").''.$langs->trans("Size").''.$langs->trans("Date").'
"; + $loc = "courrier/".get_exdir($socid); + echo ''.$file.''; + print "'.filesize($courrier_dir."/".$file). ' '.$langs->trans("bytes").''.dolibarr_print_date(filemtime($courrier_dir."/".$file),"%d %b %Y %H:%M:%S").'
"; - } + } else - { - dolibarr_print_error($db); - } + { + dolibarr_print_error($db); + } } else { - dolibarr_print_error(); + dolibarr_print_error(); } $db->close();