From 8a00a651b7b1ff3ddf88534178028128ec96a3d1 Mon Sep 17 00:00:00 2001 From: simontosser Date: Tue, 6 Sep 2005 07:11:19 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20possibilit=E9=20d'attacher=20?= =?UTF-8?q?des=20documents=20aux=20actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/comm/action/document.php | 246 ++++++++++++++++++++++++++++++++ htdocs/comm/action/fiche.php | 6 + htdocs/master.inc.php | 2 +- 3 files changed, 253 insertions(+), 1 deletion(-) create mode 100755 htdocs/comm/action/document.php diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php new file mode 100755 index 00000000000..fbe911fc3af --- /dev/null +++ b/htdocs/comm/action/document.php @@ -0,0 +1,246 @@ + + * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005 Regis Houssin + * Copyright (C) 2005 Simon TOSSER + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + * $Source$ + */ +/** + \file htdocs/product/document.php + \ingroup product + \brief Page des documents joints sur les produits + \version $Revision$ +*/ + +require_once("./pre.inc.php"); +require_once("../../contact.class.php"); +require_once("../../cactioncomm.class.php"); +require_once("../../actioncomm.class.php"); +if ($conf->webcal->enabled) { + require_once("../../lib/webcal.class.php"); +} + +$langs->load("companies"); +$langs->load("commercial"); +$langs->load("other"); +$langs->load("bills"); + +// Sécurité accés client +if ($user->societe_id > 0) +{ + $action = ''; + $socidp = $user->societe_id; +} +if (isset($_GET["error"])) $error=$_GET["error"]; + +$upload_dir = $conf->actionscomm->dir_output.'/'.$_GET['id']; + +/* + * Action envoie fichier + */ +if ( $_POST["sendit"] && $conf->upload) +{ + /* + * Creation répertoire si n'existe pas + */ + 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); + } + } +} + + + +llxHeader(); + + +if ($id > 0) +{ + if ( $error_msg ) + { + echo '
'.$error_msg.'

'; + } + + $act = new ActionComm($db); + $act->fetch($_GET["id"]); + $res=$act->societe->fetch($act->societe->id); + $res=$act->author->fetch(); // Le paramètre est le login, hors seul l'id est chargé. + $res=$act->contact->fetch($act->contact->id); + + if ($action=='delete') + { + $file = $upload_dir . '/' . urldecode($_GET['urlfile']); + dol_delete_file($file); + } + + $h=0; + + $head[$h][0] = DOL_URL_ROOT.'/comm/action/fiche.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans("CardAction"); + $hselected=$h; + $h++; + + $head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans('Documents'); + $hselected=$h; + $h++; + + dolibarr_fiche_head($head, $hselected, $langs->trans("Ref")." ".$act->id); + + // Affichage fiche action en mode visu + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("Type").''.$act->type.'
'.$langs->trans("Title").''.$act->label.'
'.$langs->trans("Company").''.img_object($langs->trans("ShowCompany"),'company').' '.$act->societe->nom_url.''.$langs->trans("Contact").''.img_object($langs->trans("ShowContact"),'contact').' '.$act->contact->fullname.'
'.$langs->trans("DateCreation").''.strftime('%d %B %Y %H:%M',$act->date).''.$langs->trans("Author").''.img_object($langs->trans("ShowUser"),'user').' '.$act->author->fullname.'
'; + // Construit liste des fichiers + clearstatcache(); + + $totalsize=0; + $filearray=array(); + + $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).'
'; + } + + print ''; + //print ''; + //print ''; + print ''; + print ''; + print '
'.$langs->trans("Ref").''.$product->ref.'
'.$langs->trans("Label").''.$product->libelle.'
'.$langs->trans("NbOfAttachedFiles").''.sizeof($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print ''; + + + // Affiche forumlaire upload + if (defined('MAIN_UPLOAD_DOC') && $conf->upload) + { + print_titre($langs->trans('AttachANewFile')); + + print '
'; + + print ''; + print '"; + print "
'; + + print ''; + print ''; + print '   '; + print ''; + + print "
"; + + print '
'; + print '
'; + } + + $errorlevel=error_reporting(); + error_reporting(0); + $handle=opendir($upload_dir); + error_reporting($errorlevel); + + print ''; + + if ($handle) + { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $var=true; + while (($file = readdir($handle))!==false) + { + if (!is_dir($dir.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') + { + $var=!$var; + print ''; + print '\n"; + print ''; + print ''; + print '\n"; + } + } + closedir($handle); + } + print '
'.$langs->trans('Document').''.$langs->trans('Size').''.$langs->trans('Date').' 
'; + echo ''.$file.''; + print "'.filesize($upload_dir.'/'.$file). ' bytes'.strftime('%d %b %Y %H:%M:%S',filemtime($upload_dir.'/'.$file)).''; + if ($file == $propref . '.pdf') + { + echo '-'; + } + else + { + echo ''.$langs->trans('Delete').''; + } + print "
'; + + print ''; +} +else +{ + print $langs->trans("UnkownError"); +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index 0653aa4a2c7..8042df5b7ca 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -1,6 +1,7 @@ * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2005 Simon TOSSER * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -465,6 +466,11 @@ if ($_GET["id"]) $hselected=$h; $h++; + $head[$h][0] = DOL_URL_ROOT.'/comm/action/document.php?id='.$_GET["id"]; + $head[$h][1] = $langs->trans('Documents'); + //$hselected=$h; + $h++; + dolibarr_fiche_head($head, $hselected, $langs->trans("Ref")." ".$act->id); diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 9c6b6b79f68..09e5d1ebf85 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -290,7 +290,7 @@ $conf->propal->dir_images=DOL_DATA_ROOT."/propale/images"; if (defined('PROPALE_OUTPUTDIR') && PROPALE_OUTPUTDIR) { $conf->propal->dir_output=PROPALE_OUTPUTDIR; } # Pour passer outre le rep par défaut $conf->domaine->enabled=0; $conf->voyage->enabled=0; - +$conf->actionscomm->dir_output=DOL_DATA_ROOT."/action"; /* * Modification de quelques variable de conf en fonction des Constantes