diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php
index 6d3be75c529..53e8cd6475e 100644
--- a/htdocs/comm/propal/document.php
+++ b/htdocs/comm/propal/document.php
@@ -34,10 +34,10 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
$langs->load('compta');
$langs->load('other');
-$action = GETPOST('action');
-$confirm = GETPOST('confirm');
+$action = GETPOST('action','alpha');
+$confirm = GETPOST('confirm','alpha');
$id = GETPOST('id','int');
-$ref = GETPOST('ref');
+$ref = GETPOST('ref','alpha');
$mesg='';
if (isset($_SESSION['DolMessage']))
@@ -66,6 +66,11 @@ if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
$object = new Propal($db);
+$object->fetch($id,$ref);
+if ($object->id > 0)
+{
+ $object->fetch_thirdparty();
+}
/*
* Actions
@@ -74,7 +79,7 @@ $object = new Propal($db);
// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
- if ($object->fetch($id))
+ if ($object->id > 0)
{
$object->fetch_thirdparty();
@@ -119,10 +124,9 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
// Delete
if ($action == 'confirm_deletefile' && $confirm == 'yes')
{
- if ($object->fetch($id))
+ if ($object->id > 0)
{
$langs->load("other");
- $object->fetch_thirdparty();
$upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
@@ -142,83 +146,73 @@ llxHeader();
$form = new Form($db);
-if ($id > 0 || ! empty($ref))
+if ($object->id > 0)
{
- if ($object->fetch($id,$ref))
- {
- $object->fetch_thirdparty();
-
- $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref);
-
- $head = propal_prepare_head($object);
- dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal');
-
-
- // Construit liste des fichiers
- $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
- $totalsize=0;
- foreach($filearray as $key => $file)
- {
- $totalsize+=$file['size'];
- }
-
-
- print '
';
-
- $linkback=''.$langs->trans("BackToList").'';
-
- // Ref
- print '| '.$langs->trans('Ref').' | ';
- print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
- print ' |
';
-
- // Ref client
- print '';
- print '| ';
- print $langs->trans('RefCustomer').' | ';
- print ' | ';
- print ' ';
- print ' | ';
- print $object->ref_client;
- print ' | ';
- print '
';
-
- // Customer
- print "| ".$langs->trans("Company")." | ";
- print ''.$object->thirdparty->getNomUrl(1).' |
';
-
- print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
- print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
-
- print '
';
-
- print '';
-
- dol_htmloutput_mesg($mesg,$mesgs);
-
- /*
- * Confirmation suppression fichier
- */
- if ($action == 'delete')
- {
- $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
- if ($ret == 'html') print '
';
- }
-
- // Affiche formulaire upload
- $formfile=new FormFile($db);
- $formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id,'',0,0,$user->rights->propale->creer,50,$object);
-
-
- // List of document
- $param='&id='.$object->id;
- $formfile->list_of_documents($filearray,$object,'propal',$param);
-
- }
- else
- {
- dol_print_error($db);
- }
+ $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref);
+
+ $head = propal_prepare_head($object);
+ dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal');
+
+
+ // Construit liste des fichiers
+ $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
+ $totalsize=0;
+ foreach($filearray as $key => $file)
+ {
+ $totalsize+=$file['size'];
+ }
+
+
+ print '';
+
+ $linkback=''.$langs->trans("BackToList").'';
+
+ // Ref
+ print '| '.$langs->trans('Ref').' | ';
+ print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
+ print ' |
';
+
+ // Ref client
+ print '';
+ print '| ';
+ print $langs->trans('RefCustomer').' | ';
+ print ' | ';
+ print ' ';
+ print ' | ';
+ print $object->ref_client;
+ print ' | ';
+ print '
';
+
+ // Customer
+ print "| ".$langs->trans("Company")." | ";
+ print ''.$object->thirdparty->getNomUrl(1).' |
';
+
+ print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
+ print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
+
+ print '
';
+
+ print '';
+
+ dol_htmloutput_mesg($mesg,$mesgs);
+
+ /*
+ * Confirmation suppression fichier
+ */
+ if ($action == 'delete')
+ {
+ $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
+ if ($ret == 'html') print '
';
+ }
+
+ // Affiche formulaire upload
+ $formfile=new FormFile($db);
+ $formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/propal/document.php?id='.$object->id,'',0,0,$user->rights->propale->creer,50,$object);
+
+
+ // List of document
+ $param='&id='.$object->id;
+ $formfile->list_of_documents($filearray,$object,'propal',$param);
}
else
{
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 9e38c6eed0d..a5b04a8f785 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -792,16 +792,40 @@ class Contrat extends CommonObject
$error++;
}
}
+
+ if (! $error)
+ {
+ // Appel des triggers
+ include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
+ $interface=new Interfaces($this->db);
+ $result=$interface->run_triggers('CONTRACT_DELETE',$this,$user,$langs,$conf);
+ if ($result < 0) {
+ $error++; $this->errors=$interface->errors;
+ }
+ // Fin appel triggers
+ }
+
+ if (! $error)
+ {
+ // We remove directory
+ $ref = dol_sanitizeFileName($this->ref);
+ if ($conf->contrat->dir_output)
+ {
+ $dir = $conf->contrat->dir_output . "/" . $ref;
+ if (file_exists($dir))
+ {
+ $res=@dol_delete_dir_recursive($dir);
+ if (! $res)
+ {
+ $this->error='ErrorFailToDeleteDir';
+ $error++;
+ }
+ }
+ }
+ }
if (! $error)
{
- // Appel des triggers
- include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
- $interface=new Interfaces($this->db);
- $result=$interface->run_triggers('CONTRACT_DELETE',$this,$user,$langs,$conf);
- if ($result < 0) { $error++; $this->errors=$interface->errors; }
- // Fin appel triggers
-
$this->db->commit();
return 1;
}
diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php
index 5f192106970..a16030a686b 100644
--- a/htdocs/contrat/document.php
+++ b/htdocs/contrat/document.php
@@ -35,8 +35,18 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
$langs->load("other");
$langs->load("products");
-if (!$user->rights->contrat->lire)
- accessforbidden();
+
+$action = GETPOST('action','alpha');
+$confirm = GETPOST('confirm','alpha');
+$id = GETPOST('id','int');
+$ref = GETPOST('ref','alpha');
+
+$mesg='';
+if (isset($_SESSION['DolMessage']))
+{
+ $mesg=$_SESSION['DolMessage'];
+ unset($_SESSION['DolMessage']);
+}
// Security check
if ($user->societe_id > 0)
@@ -45,6 +55,7 @@ if ($user->societe_id > 0)
$action='';
$socid = $user->societe_id;
}
+$result = restrictedArea($user, 'contrat', $id);
// Get parameters
$sortfield = GETPOST("sortfield",'alpha');
@@ -58,10 +69,14 @@ if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name";
-$contrat = new Contrat($db);
-$contrat->fetch($_GET["id"]);
+$object = new Contrat($db);
+$object->fetch($id, $ref);
+if ($object->id > 0)
+{
+ $object->fetch_thirdparty();
+}
-$upload_dir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($contrat->ref);
+$upload_dir = $conf->contrat->dir_output.'/'.dol_sanitizeFileName($object->ref);
$modulepart='contract';
@@ -105,6 +120,21 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
}
}
+// Delete
+if ($action == 'confirm_deletefile' && $confirm == 'yes')
+{
+ if ($object->id)
+ {
+ $langs->load("other");
+
+ $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
+ $ret=dol_delete_file($file,0,0,0,$object);
+ $_SESSION['DolMessage'] = ''.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
';
+ Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
+ exit;
+ }
+}
+
/*
*
@@ -115,24 +145,9 @@ $form = new Form($db);
llxHeader("","",$langs->trans("CardProduct".$product->type));
-if ($contrat->id)
+if ($object->id)
{
- $soc = new Societe($db);
- $soc->fetch($contrat->societe->id);
-
- if ( $error_msg )
- {
- echo ''.$error_msg.'
';
- }
-
- if ($_GET["action"] == 'delete')
- {
- $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
- $result=dol_delete_file($file);
- //if ($result >= 0) $mesg=$langs->trans("FileWasRemoced");
- }
-
- $head=contract_prepare_head($contrat, $user);
+ $head=contract_prepare_head($object, $user);
dol_fiche_head($head, 'documents', $langs->trans("Contract"), 0, 'contract');
@@ -149,27 +164,38 @@ if ($contrat->id)
print '';
// Reference
- print '| '.$langs->trans('Ref').' | '.$contrat->ref.' |
';
+ print '| '.$langs->trans('Ref').' | '.$object->ref.' |
';
// Societe
print '| '.$langs->trans("Customer").' | ';
- print ''.$soc->getNomUrl(1).' |
';
+ print ''.$object->thirdparty->getNomUrl(1).' | ';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
print '| '.$langs->trans("TotalSizeOfAttachedFiles").' | '.$totalsize.' '.$langs->trans("bytes").' |
';
print '
';
print '';
+
+ dol_htmloutput_mesg($mesg,$mesgs);
+
+ /*
+ * Confirmation suppression fichier
+ */
+ if ($action == 'delete')
+ {
+ $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode(GETPOST("urlfile")), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1);
+ if ($ret == 'html') print '
';
+ }
// Affiche formulaire upload
$formfile=new FormFile($db);
- $formfile->form_attach_new_file(DOL_URL_ROOT.'/contrat/document.php?id='.$contrat->id,'',0,0,$user->rights->contrat->creer,50,$object);
+ $formfile->form_attach_new_file(DOL_URL_ROOT.'/contrat/document.php?id='.$object->id,'',0,0,$user->rights->contrat->creer,50,$object);
// List of document
- $param='&id='.$contrat->id;
- $formfile->list_of_documents($filearray,$contrat,'contract',$param);
+ $param='&id='.$object->id;
+ $formfile->list_of_documents($filearray,$object,'contract',$param);
}
else
diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php
index 1d31aa5a53e..cbe73223aa5 100644
--- a/htdocs/contrat/fiche.php
+++ b/htdocs/contrat/fiche.php
@@ -427,7 +427,8 @@ else if ($action == 'confirm_close' && $confirm == 'yes' && $user->rights->contr
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->contrat->supprimer)
{
- $object->fetch($id);
+ $object->fetch($id);
+ $object->fetch_thirdparty();
$result=$object->delete($user,$langs,$conf);
if ($result >= 0)
{
diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php
index ab014ddc144..529d742ea10 100644
--- a/htdocs/core/class/fileupload.class.php
+++ b/htdocs/core/class/fileupload.class.php
@@ -60,12 +60,15 @@ class FileUpload
if ($element == 'propal') {
$pathname = 'comm/propal'; $filename = 'propal';
}
- if ($element == 'commande') {
+ elseif ($element == 'commande') {
$pathname = $filename = 'commande';
}
- if ($element == 'facture') {
+ elseif ($element == 'facture') {
$pathname = 'compta/facture'; $filename = 'facture';
}
+ elseif ($element == 'project') {
+ $element = $pathname = 'projet'; $filename = 'project';
+ }
dol_include_once('/'.$pathname.'/class/'.$filename.'.class.php');
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index 112e0f9b030..f890d09cab7 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -48,6 +48,7 @@ class Project extends CommonObject
var $note_public;
var $statuts_short;
var $statuts;
+ var $oldcopy;
/**
* Constructor
@@ -207,6 +208,25 @@ class Project extends CommonObject
}
// End call triggers
}
+
+ if (! $error && (is_object($this->oldcopy) && $this->oldcopy->ref != $this->ref))
+ {
+ // We remove directory
+ if ($conf->projet->dir_output)
+ {
+ $olddir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->oldcopy->ref);
+ $newdir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($this->ref);
+ if (file_exists($olddir))
+ {
+ $res=@dol_move($olddir, $newdir);
+ if (! $res)
+ {
+ $this->error='ErrorFailToMoveDir';
+ $error++;
+ }
+ }
+ }
+ }
$result = 1;
}
@@ -240,12 +260,15 @@ class Project extends CommonObject
$sql = "SELECT rowid, ref, title, description, public, datec";
$sql.= ", tms, dateo, datee, fk_soc, fk_user_creat, fk_statut, note_private, note_public";
$sql.= " FROM " . MAIN_DB_PREFIX . "projet";
- if ($ref)
+ if (! empty($id))
+ {
+ $sql.= " WHERE rowid=".$id;
+ }
+ else if (! empty($ref))
{
$sql.= " WHERE ref='".$ref."'";
$sql.= " AND entity IN (".getEntity('project').")";
}
- else $sql.= " WHERE rowid=".$id;
dol_syslog(get_class($this)."::fetch sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php
index 105d606f059..c83952c073f 100644
--- a/htdocs/projet/document.php
+++ b/htdocs/projet/document.php
@@ -32,11 +32,12 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php");
$langs->load('projects');
$langs->load('other');
-$action=GETPOST('action');
-$mine = $_REQUEST['mode']=='mine' ? 1 : 0;
+$action = GETPOST('action','alpha');
+$confirm = GETPOST('confirm','alpha');
+$id = GETPOST('id','int');
+$ref = GETPOST('ref','alpha');
+$mine = (GETPOST('mode','alpha') == 'mine' ? 1 : 0);
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
-$id = GETPOST('id','int');
-$ref= GETPOST('ref');
$mesg='';
if (isset($_SESSION['DolMessage']))
@@ -45,19 +46,18 @@ if (isset($_SESSION['DolMessage']))
unset($_SESSION['DolMessage']);
}
-$project = new Project($db);
-if (! $project->fetch($id,$ref) > 0)
-{
- dol_print_error($db);
- exit;
-}
-else $id=$project->id;
-
// Security check
$socid=0;
if ($user->societe_id > 0) $socid=$user->societe_id;
$result=restrictedArea($user,'projet',$id,'');
+$object = new Project($db);
+$object->fetch($id,$ref);
+if ($object->id > 0)
+{
+ $object->fetch_thirdparty();
+}
+
// Get parameters
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
@@ -78,7 +78,7 @@ if (! $sortfield) $sortfield="name";
// Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{
- $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($project->ref);
+ $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
if (dol_mkdir($upload_dir) >= 0)
{
@@ -116,14 +116,14 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
}
// Delete
-if ($action == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->projet->supprimer)
+if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->projet->supprimer)
{
$langs->load("other");
- $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($project->ref);
+ $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref);
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
- dol_delete_file($file);
+ dol_delete_file($file,0,0,0,$object);
$_SESSION['DolMessage'] = ''.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
';
- Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
+ Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
@@ -136,23 +136,20 @@ llxHeader('',$langs->trans('Project'),'EN:Customers_Orders|FR:Commandes_Clients|
$form = new Form($db);
-if ($id > 0 || ! empty($ref))
+if ($object->id > 0)
{
- $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($project->ref);
+ $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($object->ref);
- $company = new Societe($db);
- $company->fetch($project->socid);
-
- if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id);
+ if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
// To verify role of users
- //$userAccess = $project->restrictedProjectArea($user,'read');
- $userWrite = $project->restrictedProjectArea($user,'write');
- //$userDelete = $project->restrictedProjectArea($user,'delete');
+ //$userAccess = $object->restrictedProjectArea($user,'read');
+ $userWrite = $object->restrictedProjectArea($user,'write');
+ //$userDelete = $object->restrictedProjectArea($user,'delete');
//print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete;
- $head = project_prepare_head($project);
- dol_fiche_head($head, 'document', $langs->trans("Project"), 0, ($project->public?'projectpub':'project'));
+ $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_DESC:SORT_ASC),1);
@@ -164,7 +161,7 @@ if ($id > 0 || ! empty($ref))
if ($action == 'delete')
{
- $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$_GET["id"]."&urlfile=".urlencode(GETPOST("urlfile")),$langs->trans("DeleteAFile"),$langs->trans("ConfirmDeleteAFile"),"confirm_delete",'','',1);
+ $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id."&urlfile=".urlencode(GETPOST("urlfile")),$langs->trans("DeleteAFile"),$langs->trans("ConfirmDeleteAFile"),"confirm_delete",'','',1);
if ($ret == 'html') print '
';
}
@@ -175,29 +172,29 @@ if ($id > 0 || ! empty($ref))
// Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
- $projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,0);
- $project->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
+ $projectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0);
+ $object->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")";
}
- print $form->showrefnav($project,'ref','',1,'ref','ref');
+ print $form->showrefnav($object,'ref','',1,'ref','ref');
print '';
// Label
- print '| '.$langs->trans("Label").' | '.$project->title.' |
';
+ print '| '.$langs->trans("Label").' | '.$object->title.' |
';
// Company
print '| '.$langs->trans("Company").' | ';
- if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
+ if (! empty($object->societe->id)) print $object->societe->getNomUrl(1);
else print ' ';
print ' |
';
// Visibility
print '| '.$langs->trans("Visibility").' | ';
- if ($project->public) print $langs->trans('SharedProject');
+ if ($object->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print ' |
';
// Statut
- print '| '.$langs->trans("Status").' | '.$project->getLibStatut(4).' |
';
+ print '| '.$langs->trans("Status").' | '.$object->getLibStatut(4).' |
';
// Files infos
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
@@ -211,12 +208,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='.$project->id,'',0,0,($userWrite>0),50,$object);
+ $formfile->form_attach_new_file(DOL_URL_ROOT.'/projet/document.php?id='.$object->id,'',0,0,($userWrite>0),50,$object);
// List of document
- $param='&id='.$project->id;
- $formfile->list_of_documents($filearray,$project,'projet',$param,0,'',($userWrite>0));
+ $param='&id='.$object->id;
+ $formfile->list_of_documents($filearray,$object,'projet',$param,0,'',($userWrite>0));
}
else
diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php
index d72cf2d8dba..797b4f4507c 100644
--- a/htdocs/projet/fiche.php
+++ b/htdocs/projet/fiche.php
@@ -43,19 +43,18 @@ if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $acti
$mine = GETPOST('mode')=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
-$object = new Project($db);
-if ($ref)
-{
- $object->fetch(0,$ref);
- $id=$object->id;
-}
// Security check
$socid=0;
if ($user->societe_id > 0) $socid=$user->societe_id;
$result = restrictedArea($user, 'projet', $id);
-
+$object = new Project($db);
+$object->fetch($id,$ref);
+if ($object->id > 0)
+{
+ $object->fetch_thirdparty();
+}
/*
@@ -67,7 +66,6 @@ if (GETPOST("cancel") && ! empty($backtopage))
{
if (GETPOST("comefromclone")==1)
{
- $object->fetch($id);
$result=$object->delete($user);
if ($result > 0)
{
@@ -87,7 +85,6 @@ if (GETPOST("cancel") && ! empty($backtopage))
//if cancel and come from clone then delete the cloned project
if (GETPOST("cancel") && (GETPOST("comefromclone")==1))
{
- $object->fetch($id);
$result=$object->delete($user);
if ($result > 0)
{
@@ -187,7 +184,7 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
}
if (! $error)
{
- $object->fetch($id);
+ $object->oldcopy = dol_clone($object);
$old_start_date = $object->date_start;
@@ -201,8 +198,6 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
$result=$object->update($user);
- $id=$object->id; // On retourne sur la fiche projet
-
if (GETPOST("reportdate") && ($object->date_start!=$old_start_date))
{
$result=$object->shiftTaskDate($old_start_date);
@@ -222,7 +217,6 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer)
// Build doc
if ($action == 'builddoc' && $user->rights->projet->creer)
{
- $object->fetch($id);
if (GETPOST('model'))
{
$object->setDocModel($user, GETPOST('model'));
@@ -252,7 +246,7 @@ if ($action == 'remove_file' && $user->rights->projet->creer)
{
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
- if ($object->fetch($id))
+ if ($object->id > 0)
{
$langs->load("other");
$upload_dir = $conf->projet->dir_output . "/";
@@ -265,8 +259,6 @@ if ($action == 'remove_file' && $user->rights->projet->creer)
if ($action == 'confirm_validate' && GETPOST('confirm') == 'yes')
{
- $object->fetch($id);
-
$result = $object->setValid($user);
if ($result <= 0)
{
@@ -276,7 +268,6 @@ if ($action == 'confirm_validate' && GETPOST('confirm') == 'yes')
if ($action == 'confirm_close' && GETPOST('confirm') == 'yes')
{
- $object->fetch($id);
$result = $object->setClose($user);
if ($result <= 0)
{
@@ -286,7 +277,6 @@ if ($action == 'confirm_close' && GETPOST('confirm') == 'yes')
if ($action == 'confirm_reopen' && GETPOST('confirm') == 'yes')
{
- $object->fetch($id);
$result = $object->setValid($user);
if ($result <= 0)
{
@@ -312,20 +302,18 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights-
if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confirm') == 'yes')
{
- $idtoclone=$id;
- $object->fetch($idtoclone);
$clone_contacts=GETPOST('clone_contacts')?1:0;
$clone_tasks=GETPOST('clone_tasks')?1:0;
$clone_files=GETPOST('clone_files')?1:0;
$clone_notes=GETPOST('clone_notes')?1:0;
- $result=$object->createFromClone($idtoclone,$clone_contacts,$clone_tasks,$clone_files,$clone_notes);
+ $result=$object->createFromClone($object->id,$clone_contacts,$clone_tasks,$clone_files,$clone_notes);
if ($result <= 0)
{
$mesg=''.$object->error.'
';
}
else
{
- $id=$result;
+ $object->id=$result;
$action='edit';
$comefromclone=true;
}
@@ -429,8 +417,6 @@ else
dol_htmloutput_mesg($mesg);
- $object->fetch($id,$ref);
-
if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id);
// To verify role of users