Skip to content
Snippets Groups Projects
Commit ff47f379 authored by Regis Houssin's avatar Regis Houssin
Browse files

Add document tabs in project and task cards

parent a5ea5f26
No related branches found
No related tags found
No related merge requests found
......@@ -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 = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
......@@ -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 '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object,'ref','',1,'ref','ref');
print $form->showrefnav($project,'ref','',1,'ref','ref');
print '</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
// Company
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if (! empty($object->societe->id)) print $object->societe->getNomUrl(1);
if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
else print '&nbsp;';
print '</td></tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($object->public) print $langs->trans('SharedProject');
if ($project->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
// Files infos
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
......@@ -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
......
......@@ -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 = '<div class="ok">'.$langs->trans("FileWasRemoved").'</div>';
......@@ -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 '<table class="border" width="100%">';
// Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object,'ref','',1,'ref','ref');
print '</td></tr>';
print '<tr><td width="30%">';
print $langs->trans("Ref");
print '</td><td colspan="3">';
print $form->showrefnav($task,'id','',1,'rowid','ref','','');
print '</td>';
print '</tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
// Company
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if (! empty($object->societe->id)) print $object->societe->getNomUrl(1);
else print '&nbsp;';
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="3">'.$task->label.'</td></tr>';
// Project
print '<tr><td>'.$langs->trans("Project").'</td><td colspan="3">';
print $projectstatic->getNomUrl(1);
print '</td></tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($object->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
// Third party
print '<td>'.$langs->trans("Company").'</td><td colspan="3">';
if ($projectstatic->societe->id) print $projectstatic->societe->getNomUrl(1);
else print '&nbsp;';
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
// Files infos
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.sizeof($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment