diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php
index 1cb227795de..af3da6bb410 100644
--- a/htdocs/projet/tasks/document.php
+++ b/htdocs/projet/tasks/document.php
@@ -44,11 +44,11 @@ $ref= GETPOST('ref','alpha');
$withproject=GETPOST('withproject','int');
$project_ref = GETPOST('project_ref','alpha');
-$mesg='';
-if (isset($_SESSION['DolMessage']))
-{
- $mesg=$_SESSION['DolMessage'];
- unset($_SESSION['DolMessage']);
+$mesg='';
+if (isset($_SESSION['DolMessage']))
+{
+ $mesg=$_SESSION['DolMessage'];
+ unset($_SESSION['DolMessage']);
}
// Security check
@@ -79,55 +79,6 @@ $projectstatic = new Project($db);
* Actions
*/
-// Envoi fichier
-if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
-{
- if (dol_mkdir($upload_dir) >= 0)
- {
- $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']),0,0,$_FILES['userfile']['error']);
- if (is_numeric($resupload) && $resupload > 0)
- {
- if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1)
- {
- // Create small thumbs for image (Ratio is near 16/9)
- // Used on logon for example
- $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
- // Create mini thumbs for image (Ratio is near 16/9)
- // Used on menu or for setup page for example
- $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs");
- }
- $mesg = '
'.$langs->trans("FileTransferComplete").'
';
- }
- else
- {
- $langs->load("errors");
- if ($resupload < 0) // Unknown error
- {
- $mesg = ''.$langs->trans("ErrorFileNotUploaded").'
';
- }
- else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
- {
- $mesg = ''.$langs->trans("ErrorFileIsInfectedWithAVirus").'
';
- }
- else // Known error
- {
- $mesg = ''.$langs->trans($resupload).'
';
- }
- }
- }
-}
-
-// Delete
-if ($action=='delete')
-{
- $langs->load("other");
- $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
- dol_delete_file($file);
- $_SESSION['DolMessage'] = ''.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
';
- Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
- exit;
-}
-
// Retreive First Task ID of Project if withprojet is on to allow project prev next to work
if (! empty($project_ref) && ! empty($withproject))
{
@@ -164,6 +115,56 @@ if ($id > 0 || ! empty($ref))
}
}
+// Envoi fichier
+if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
+{
+ if (dol_mkdir($upload_dir) >= 0)
+ {
+ $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_FILES['userfile']['name']),0,0,$_FILES['userfile']['error']);
+ if (is_numeric($resupload) && $resupload > 0)
+ {
+ if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1)
+ {
+ // Create small thumbs for image (Ratio is near 16/9)
+ // Used on logon for example
+ $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs");
+ // Create mini thumbs for image (Ratio is near 16/9)
+ // Used on menu or for setup page for example
+ $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs");
+ }
+ $mesg = ''.$langs->trans("FileTransferComplete").'
';
+ }
+ else
+ {
+ $langs->load("errors");
+ if ($resupload < 0) // Unknown error
+ {
+ $mesg = ''.$langs->trans("ErrorFileNotUploaded").'
';
+ }
+ else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
+ {
+ $mesg = ''.$langs->trans("ErrorFileIsInfectedWithAVirus").'
';
+ }
+ else // Known error
+ {
+ $mesg = ''.$langs->trans($resupload).'
';
+ }
+ }
+ }
+}
+
+// Delete
+if ($action=='delete')
+{
+ $langs->load("other");
+ $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
+ dol_delete_file($file);
+ $_SESSION['DolMessage'] = ''.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
';
+ Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
+ exit;
+}
+
+
/*
* View
*/