diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 8697d5c8c84..dd760dc1eec 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2006 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005 Regis Houssin * @@ -38,35 +38,64 @@ if (!$user->rights->propale->lire) accessforbidden(); $langs->load('compta'); - -llxHeader(); +$langs->load('other'); $propalid=empty($_GET['propalid']) ? 0 : intVal($_GET['propalid']); $action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; -function do_upload ($upload_dir) + +/* + * Actions + */ + +// Envoi fichier +if ($_POST["sendit"] && $conf->upload) { - global $local_file, $error_msg, $langs; + $propal = new Propal($db); - if (! is_dir($upload_dir)) - { - create_exdir($upload_dir); - } - - if (doliMoveFileUpload($_FILES['userfile']['tmp_name'], $upload_dir . '/' . $_FILES['userfile']['name'])) - { - echo $langs->trans('FileUploaded'); - } - else - { - echo $langs->trans('FileNotUploaded'); - } + if ($propal->fetch($propalid)) + { + $upload_dir = $conf->propal->dir_output . "/" . $propal->ref; + 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'])) + { + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + //print_r($_FILES); + } + else + { + // Echec transfert (fichier dépassant la limite ?) + $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; + // print_r($_FILES); + } + } + } } -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ +// Delete +if ($action=='delete') +{ + $propal = new Propal($db); + + if ($propal->fetch($propalid)) + { + $upload_dir = $conf->propal->dir_output . "/" . $propal->ref; + $file = $upload_dir . '/' . urldecode($_GET['urlfile']); + dol_delete_file($file); + $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + } +} + + +/* + * Affichage + */ + +llxHeader(); if ($propalid > 0) { @@ -77,25 +106,6 @@ if ($propalid > 0) $propref = sanitize_string($propal->ref); $upload_dir = $conf->propal->dir_output.'/'.$propref; - if ( $error_msg ) - { - echo ''.$error_msg.'

'; - } - -/******************************************************************************/ -/* Actions */ -/******************************************************************************/ - if ($action=='delete') - { - $file = $upload_dir . '/' . urldecode($_GET['urlfile']); - dol_delete_file($file); - } - - if ( $_POST['sendit'] ) - { - do_upload ($upload_dir); - } - $h=0; $head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id; @@ -126,33 +136,82 @@ if ($propalid > 0) $hselected=$h; $h++; - dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal').': '.$propal->ref); + dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal')); - print_titre($langs->trans('AssociatedDocuments').' '.$propal->ref_url); + // Construit liste des fichiers + clearstatcache(); - print ''; + $totalsize=0; + $filearray=array(); - print ''; - print ''; - print '
'; - print '   '; - print '
'; - print '
'; + $errorlevel=error_reporting(); + 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).'
'; + } - clearstatcache(); + + print '
'; + print ''; + print ''; + print ''; + print '
'.$langs->trans('Ref').''.$propal->ref_url.'
'.$langs->trans("NbOfAttachedFiles").''.sizeof($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print ''; + + if ($mesg) { print "$mesg
"; } + + // Affiche formulaire upload + if ($conf->global->MAIN_UPLOAD_DOC) + { + print_titre($langs->trans("AttachANewFile")); + + print '
'; + + print ''; + print '"; + print "
'; + + print ''; + print ''; + print '   '; + print ''; + + print "
"; + + print '
'; + print '
'; + } + + + // Affiche liste des documents existant + print_titre($langs->trans("AttachedFiles")); + + print ''; + print ''; if (is_dir($upload_dir)) { - $handle=opendir($upload_dir); if ($handle) { - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; $var=true; while (($file = readdir($handle))!==false) { @@ -187,7 +246,6 @@ if ($propalid > 0) } print '
'.$langs->trans("Document").''.$langs->trans("Size").''.$langs->trans("Date").' 
'.$langs->trans('Document').''.$langs->trans('Size').''.$langs->trans('Date').' 
'; - print ''; } else { diff --git a/htdocs/docsoc.php b/htdocs/docsoc.php index 183eb40fd55..a15edfa1e20 100644 --- a/htdocs/docsoc.php +++ b/htdocs/docsoc.php @@ -30,26 +30,23 @@ require("./pre.inc.php"); $langs->load("companies"); +$langs->load('other'); -llxHeader(); - $mesg = ""; $socid=$_GET["socid"]; /* - * Creation répertoire si n'existe pas - */ -$upload_dir = $conf->societe->dir_output . "/" . $socid ; -if (! is_dir($upload_dir)) create_exdir($upload_dir); - - -/* - * Action envoie fichier + * Actions */ + +// Envoie fichier if ( $_POST["sendit"] && $conf->upload) { + $upload_dir = $conf->societe->dir_output . "/" . $socid ; + 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'])) @@ -66,12 +63,10 @@ if ( $_POST["sendit"] && $conf->upload) } } - -/* - * Action suppression fichier - */ +// Suppression fichier if ($_GET["action"]=='delete') { + $upload_dir = $conf->societe->dir_output . "/" . $socid ; $file = $upload_dir . "/" . urldecode($_GET["urlfile"]); dol_delete_file($file); $mesg = '
'.$langs->trans("FileWasRemoved").'
'; @@ -82,6 +77,8 @@ if ($_GET["action"]=='delete') * Affichage liste */ +llxHeader(); + if ($socid > 0) { $societe = new Societe($db); @@ -181,8 +178,8 @@ if ($socid > 0) if ($mesg) { print "$mesg
"; } - // Affiche forumlaire upload - if (defined('MAIN_UPLOAD_DOC') && $conf->upload) + // Affiche formulaire upload + if ($conf->global->MAIN_UPLOAD_DOC) { print_titre($langs->trans("AttachANewFile")); echo '
'; diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang index b558c2d71f5..72ad2013597 100644 --- a/htdocs/langs/en_US/other.lang +++ b/htdocs/langs/en_US/other.lang @@ -45,6 +45,7 @@ ModifiedBy=Modified by %s ValidatedBy=Validated by %s CanceledBy=Canceled by %s ClosedBy=Closed by %s +FileWasRemoved=File was deleted ##### Webcal ##### LoginWebcal=Login for Webcalendar AddCalendarEntry=Add entry in calendar diff --git a/htdocs/langs/fr_FR/other.lang b/htdocs/langs/fr_FR/other.lang index 4cde87abba9..e83efdaf621 100644 --- a/htdocs/langs/fr_FR/other.lang +++ b/htdocs/langs/fr_FR/other.lang @@ -45,6 +45,7 @@ ModifiedBy=Modifi ValidatedBy=Validé par %s CanceledBy=Annulé par %s ClosedBy=Cloturé par %s +FileWasRemoved=Le fichier a été supprimé ##### Webcal ##### LoginWebcal=Login Webcalendar AddCalendarEntry=Ajouter entrée dans le calendrier