diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php
index 7a968d6552e..7bb8661d0a6 100644
--- a/htdocs/projet/document.php
+++ b/htdocs/projet/document.php
@@ -56,8 +56,8 @@ $pagenext = $page + 1;
$id = $_GET['id'];
$ref= $_GET['ref'];
-$object = new Project($db);
-if (! $object->fetch($_GET['id'],$_GET['ref']) > 0)
+$project = new Project($db);
+if (! $project->fetch($_GET['id'],$_GET['ref']) > 0)
{
dol_print_error($db);
}
@@ -70,7 +70,7 @@ if (! $object->fetch($_GET['id'],$_GET['ref']) > 0)
// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
- $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
+ $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($project->ref);
if (! is_dir($upload_dir)) create_exdir($upload_dir);
if (is_dir($upload_dir))
@@ -99,7 +99,7 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
// Delete
if ($action=='delete')
{
- $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
+ $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($project->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").'
';
@@ -116,18 +116,18 @@ $form = new Form($db);
if ($id > 0 || ! empty($ref))
{
- $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
+ $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref);
$company = new Societe($db);
- $company->fetch($object->socid);
+ $company->fetch($project->socid);
- if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
+ if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
// To verify role of users
- $userAccess = $object->restrictedProjectArea($user);
+ $userAccess = $project->restrictedProjectArea($user);
- $head = project_prepare_head($object);
- dol_fiche_head($head, 'document', $langs->trans("Project"), 0, ($object->public?'projectpub':'project'));
+ $head = project_prepare_head($project);
+ dol_fiche_head($head, 'document', $langs->trans("Project"), 0, ($project->public?'projectpub':'project'));
// Files list constructor
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
@@ -141,26 +141,26 @@ if ($id > 0 || ! empty($ref))
// Ref
print '| '.$langs->trans("Ref").' | ';
- print $form->showrefnav($object,'ref','',1,'ref','ref');
+ print $form->showrefnav($project,'ref','',1,'ref','ref');
print ' |
';
// Label
- print '| '.$langs->trans("Label").' | '.$object->title.' |
';
+ print '| '.$langs->trans("Label").' | '.$project->title.' |
';
// Company
print '| '.$langs->trans("Company").' | ';
- if (! empty($object->societe->id)) print $object->societe->getNomUrl(1);
+ if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
else print ' ';
print ' |
';
// Visibility
print '| '.$langs->trans("Visibility").' | ';
- if ($object->public) print $langs->trans('SharedProject');
+ if ($project->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print ' |
';
// Statut
- print '| '.$langs->trans("Status").' | '.$object->getLibStatut(4).' |
';
+ print '| '.$langs->trans("Status").' | '.$project->getLibStatut(4).' |
';
// Files infos
print '| '.$langs->trans("NbOfAttachedFiles").' | '.sizeof($filearray).' |
';
@@ -174,12 +174,12 @@ if ($id > 0 || ! empty($ref))
// 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);
+ $formfile->form_attach_new_file(DOL_URL_ROOT.'/projet/document.php?id='.$project->id,'',0,0,$user->rights->projet->creer);
// List of document
- $param='&id='.$object->id;
- $formfile->list_of_documents($filearray,$object,'projet',$param);
+ $param='&id='.$project->id;
+ $formfile->list_of_documents($filearray,$project,'projet',$param);
}
else
diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php
index 7326be8dc06..ae35bc06a72 100644
--- a/htdocs/projet/tasks/document.php
+++ b/htdocs/projet/tasks/document.php
@@ -24,6 +24,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/files.lib.php");
@@ -58,8 +59,19 @@ $pagenext = $page + 1;
$id = $_GET['id'];
$ref= $_GET['ref'];
-$object = new Task($db);
-if (! $object->fetch($_GET['id'],$_GET['ref']) > 0)
+
+$task = new Task($db);
+
+if ($task->fetch($id,$ref) > 0)
+{
+ $projectstatic = new Project($db);
+ $projectstatic->fetch($task->fk_project);
+
+ if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid);
+
+ $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($task->ref);
+}
+else
{
dol_print_error($db);
}
@@ -72,7 +84,6 @@ if (! $object->fetch($_GET['id'],$_GET['ref']) > 0)
// 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))
@@ -101,7 +112,6 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
// 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").'
';
@@ -117,19 +127,12 @@ llxHeader('',$langs->trans('Project'),'EN:Customers_Orders|FR:Commandes_Clients|
$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);
+ $userAccess = $projectstatic->restrictedProjectArea($user);
- $head = project_prepare_head($object);
- dol_fiche_head($head, 'document', $langs->trans("Project"), 0, ($object->public?'projectpub':'project'));
+ $head = task_prepare_head($task);
+ dol_fiche_head($head, 'document', $langs->trans("Task"), 0, 'projecttask');
// Files list constructor
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_ASC:SORT_DESC),1);
@@ -142,28 +145,27 @@ if ($id > 0 || ! empty($ref))
print '';
// Ref
- print '| '.$langs->trans("Ref").' | ';
- print $form->showrefnav($object,'ref','',1,'ref','ref');
- print ' |
';
-
+ print '| ';
+ print $langs->trans("Ref");
+ print ' | ';
+ print $form->showrefnav($task,'id','',1,'rowid','ref','','');
+ print ' | ';
+ print '
';
+
// Label
- print '| '.$langs->trans("Label").' | '.$object->title.' |
';
-
- // Company
- print '| '.$langs->trans("Company").' | ';
- if (! empty($object->societe->id)) print $object->societe->getNomUrl(1);
+ print ' |
| '.$langs->trans("Label").' | '.$task->label.' |
';
+
+ // Project
+ print '| '.$langs->trans("Project").' | ';
+ print $projectstatic->getNomUrl(1);
+ print ' |
';
+
+ // Third party
+ print ''.$langs->trans("Company").' | ';
+ if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1);
else print ' ';
print ' | ';
- // Visibility
- print '| '.$langs->trans("Visibility").' | ';
- if ($object->public) print $langs->trans('SharedProject');
- else print $langs->trans('PrivateProject');
- print ' |
';
-
- // Statut
- print '| '.$langs->trans("Status").' | '.$object->getLibStatut(4).' |
';
-
// Files infos
print '| '.$langs->trans("NbOfAttachedFiles").' | '.sizeof($filearray).' |
';
print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
@@ -176,12 +178,12 @@ if ($id > 0 || ! empty($ref))
// 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);
+ $formfile->form_attach_new_file(DOL_URL_ROOT.'/projet/tasks/document.php?id='.$task->id,'',0,0,$user->rights->projet->creer);
// List of document
- $param='&id='.$object->id;
- $formfile->list_of_documents($filearray,$object,'projet',$param);
+ $param='&id='.$task->id;
+ $formfile->list_of_documents($filearray,$task,'projet',$param);
}
else