diff --git a/htdocs/conf/conf.php.example b/htdocs/conf/conf.php.example index c72a5ab2166..39b508934ec 100644 --- a/htdocs/conf/conf.php.example +++ b/htdocs/conf/conf.php.example @@ -34,8 +34,8 @@ $dolibarr_main_document_root=""; # This parameter contains absolute file system directory of Dolibarr # directory used to store uploaded and generated physical files. # Examples: -# $dolibarr_main_document_root="/var/www/dolibarr/documents"; -# $dolibarr_main_document_root="E:/My web sites/dolibarr/documents"; +# $dolibarr_main_data_root="/var/www/dolibarr/documents"; +# $dolibarr_main_data_root="E:/My web sites/dolibarr/documents"; # $dolibarr_main_data_root=""; diff --git a/htdocs/includes/modules/modProjet.class.php b/htdocs/includes/modules/modProjet.class.php index d00fb5afa05..0a0b5e39a36 100644 --- a/htdocs/includes/modules/modProjet.class.php +++ b/htdocs/includes/modules/modProjet.class.php @@ -64,7 +64,7 @@ class modProjet extends DolibarrModules $this->picto='project'; // Data directories to create when module is enabled - $this->dirs = array("/project/temp"); + $this->dirs = array("/projet/temp"); // Dependancies $this->depends = array(); diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php index c4b0959b5f6..a43ba567d84 100644 --- a/htdocs/lib/project.lib.php +++ b/htdocs/lib/project.lib.php @@ -57,6 +57,15 @@ function project_prepare_head($object) $head[$h][2] = 'element'; $h++; } + + $head[$h][0] = DOL_URL_ROOT.'/projet/document.php?id='.$object->id; + /*$filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); + include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); + $listoffiles=dol_dir_list($filesdir,'files',1); + $head[$h][1] = (sizeof($listoffiles)?$langs->trans('DocumentsNb',sizeof($listoffiles)):$langs->trans('Documents'));*/ + $head[$h][1] = $langs->trans('Documents'); + $head[$h][2] = 'document'; + $h++; $head[$h][0] = DOL_URL_ROOT.'/projet/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); @@ -110,6 +119,15 @@ function task_prepare_head($object) $head[$h][1] = $langs->trans("TimeSpent"); $head[$h][2] = 'time'; $h++; + + $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/document.php?id='.$object->id; + /*$filesdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); + include_once(DOL_DOCUMENT_ROOT.'/lib/files.lib.php'); + $listoffiles=dol_dir_list($filesdir,'files',1); + $head[$h][1] = (sizeof($listoffiles)?$langs->trans('DocumentsNb',sizeof($listoffiles)):$langs->trans('Documents'));*/ + $head[$h][1] = $langs->trans('Documents'); + $head[$h][2] = 'document'; + $h++; $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/note.php?id='.$object->id; $head[$h][1] = $langs->trans('Notes'); diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php new file mode 100644 index 00000000000..7a968d6552e --- /dev/null +++ b/htdocs/projet/document.php @@ -0,0 +1,193 @@ + + * + * 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. + */ + +/** + * \file htdocs/projet/document.php + * \ingroup project + * \brief Page de gestion des documents attachees a un projet + * \version $Id$ + */ + +require('../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/projet/project.class.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/project.lib.php'); +require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); + +$langs->load('projects'); +$langs->load('other'); + +$id=empty($_GET['id']) ? 0 : intVal($_GET['id']); +$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; + +// Security check +$socid=0; +$id = isset($_GET["id"])?$_GET["id"]:''; +if ($user->societe_id) $socid=$user->societe_id; +$result=restrictedArea($user,'projet',$id,''); + +// Get parameters +$page=$_GET["page"]; +$sortorder=$_GET["sortorder"]; +$sortfield=$_GET["sortfield"]; + +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; +if ($page == -1) { $page = 0 ; } +$offset = $conf->liste_limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + + +$id = $_GET['id']; +$ref= $_GET['ref']; +$object = new Project($db); +if (! $object->fetch($_GET['id'],$_GET['ref']) > 0) +{ + dol_print_error($db); +} + + +/* + * Actions + */ + +// Envoi fichier +if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) +{ + $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); + if (! is_dir($upload_dir)) create_exdir($upload_dir); + + if (is_dir($upload_dir)) + { + $result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0); + if ($result > 0) + { + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + //print_r($_FILES); + } + else if ($result == -99) + { + // Files infected by a virus + $langs->load("errors"); + $mesg = '
'.$langs->trans("ErrorFileIsInfectedWithAVirus").'
'; + } + else if ($result < 0) + { + // Echec transfert (fichier depassant la limite ?) + $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; + // print_r($_FILES); + } + } +} + +// Delete +if ($action=='delete') +{ + $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); + $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + dol_delete_file($file); + $mesg = '
'.$langs->trans("FileWasRemoved").'
'; +} + + +/* + * View + */ + +llxHeader('',$langs->trans('Project'),'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'); + +$form = new Form($db); + +if ($id > 0 || ! empty($ref)) +{ + $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref); + + $company = new Societe($db); + $company->fetch($object->socid); + + if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id); + + // To verify role of users + $userAccess = $object->restrictedProjectArea($user); + + $head = project_prepare_head($object); + dol_fiche_head($head, 'document', $langs->trans("Project"), 0, ($object->public?'projectpub':'project')); + + // Files list constructor + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + print ''; + + // Ref + print ''; + + // Label + print ''; + + // Company + print ''; + + // Visibility + print ''; + + // Statut + print ''; + + // Files infos + print ''; + print ''; + + print "
'.$langs->trans("Ref").''; + print $form->showrefnav($object,'ref','',1,'ref','ref'); + print '
'.$langs->trans("Label").''.$object->title.'
'.$langs->trans("Company").''; + if (! empty($object->societe->id)) print $object->societe->getNomUrl(1); + else print ' '; + print '
'.$langs->trans("Visibility").''; + if ($object->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("NbOfAttachedFiles").''.sizeof($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
\n"; + print "\n"; + + if ($mesg) { print $mesg."
"; } + + + // Affiche formulaire upload + $formfile=new FormFile($db); + $formfile->form_attach_new_file(DOL_URL_ROOT.'/projet/document.php?id='.$object->id,'',0,0,$user->rights->projet->creer); + + + // List of document + $param='&id='.$object->id; + $formfile->list_of_documents($filearray,$object,'projet',$param); + +} +else +{ + Header('Location: index.php'); +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php new file mode 100644 index 00000000000..7326be8dc06 --- /dev/null +++ b/htdocs/projet/tasks/document.php @@ -0,0 +1,195 @@ + + * + * 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. + */ + +/** + * \file htdocs/projet/tasks/document.php + * \ingroup project + * \brief Page de gestion des documents attachees a une tache d'un projet + * \version $Id$ + */ + +require('../../main.inc.php'); +require_once(DOL_DOCUMENT_ROOT."/projet/tasks/task.class.php"); +require_once(DOL_DOCUMENT_ROOT.'/lib/project.lib.php'); +require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/html.formfile.class.php"); + +if (!$user->rights->projet->lire) accessforbidden(); + +$langs->load('projects'); +$langs->load('other'); + +$id=empty($_GET['id']) ? 0 : intVal($_GET['id']); +$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; + +// Security check +$socid=0; +$id = isset($_GET["id"])?$_GET["id"]:''; +if ($user->societe_id) $socid=$user->societe_id; +//$result=restrictedArea($user,'projet',$id,''); + +// Get parameters +$page=$_GET["page"]; +$sortorder=$_GET["sortorder"]; +$sortfield=$_GET["sortfield"]; + +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; +if ($page == -1) { $page = 0 ; } +$offset = $conf->liste_limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + + +$id = $_GET['id']; +$ref= $_GET['ref']; +$object = new Task($db); +if (! $object->fetch($_GET['id'],$_GET['ref']) > 0) +{ + dol_print_error($db); +} + + +/* + * Actions + */ + +// Envoi fichier +if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) +{ + $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); + if (! is_dir($upload_dir)) create_exdir($upload_dir); + + if (is_dir($upload_dir)) + { + $result = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0); + if ($result > 0) + { + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + //print_r($_FILES); + } + else if ($result == -99) + { + // Files infected by a virus + $langs->load("errors"); + $mesg = '
'.$langs->trans("ErrorFileIsInfectedWithAVirus").'
'; + } + else if ($result < 0) + { + // Echec transfert (fichier depassant la limite ?) + $mesg = '
'.$langs->trans("ErrorFileNotUploaded").'
'; + // print_r($_FILES); + } + } +} + +// Delete +if ($action=='delete') +{ + $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); + $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + dol_delete_file($file); + $mesg = '
'.$langs->trans("FileWasRemoved").'
'; +} + + +/* + * View + */ + +llxHeader('',$langs->trans('Project'),'EN:Customers_Orders|FR:Commandes_Clients|ES:Pedidos de clientes'); + +$form = new Form($db); + +if ($id > 0 || ! empty($ref)) +{ + $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref); + + $company = new Societe($db); + $company->fetch($object->socid); + + if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id); + + // To verify role of users + $userAccess = $object->restrictedProjectArea($user); + + $head = project_prepare_head($object); + dol_fiche_head($head, 'document', $langs->trans("Project"), 0, ($object->public?'projectpub':'project')); + + // Files list constructor + $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + print ''; + + // Ref + print ''; + + // Label + print ''; + + // Company + print ''; + + // Visibility + print ''; + + // Statut + print ''; + + // Files infos + print ''; + print ''; + + print "
'.$langs->trans("Ref").''; + print $form->showrefnav($object,'ref','',1,'ref','ref'); + print '
'.$langs->trans("Label").''.$object->title.'
'.$langs->trans("Company").''; + if (! empty($object->societe->id)) print $object->societe->getNomUrl(1); + else print ' '; + print '
'.$langs->trans("Visibility").''; + if ($object->public) print $langs->trans('SharedProject'); + else print $langs->trans('PrivateProject'); + print '
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("NbOfAttachedFiles").''.sizeof($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
\n"; + print "\n"; + + if ($mesg) { print $mesg."
"; } + + + // Affiche formulaire upload + $formfile=new FormFile($db); + $formfile->form_attach_new_file(DOL_URL_ROOT.'/projet/document.php?id='.$object->id,'',0,0,$user->rights->projet->creer); + + + // List of document + $param='&id='.$object->id; + $formfile->list_of_documents($filearray,$object,'projet',$param); + +} +else +{ + Header('Location: index.php'); +} + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/projet/tasks/fiche.php b/htdocs/projet/tasks/fiche.php index 8b106d0499e..fda90ccca9e 100644 --- a/htdocs/projet/tasks/fiche.php +++ b/htdocs/projet/tasks/fiche.php @@ -29,6 +29,7 @@ require ("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/projet/project.class.php"); require_once(DOL_DOCUMENT_ROOT."/projet/tasks/task.class.php"); require_once(DOL_DOCUMENT_ROOT."/lib/project.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/date.lib.php"); require_once(DOL_DOCUMENT_ROOT."/html.formother.class.php"); $projectid='';