2
0
forked from Wavyzz/dolibarr

Fix: problem with external modules and uniformize code

This commit is contained in:
Regis Houssin
2012-06-09 18:37:54 +02:00
parent 85e7e5eddd
commit b51cd362b0
8 changed files with 238 additions and 184 deletions

View File

@@ -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);
$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');
$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 '<table class="border"width="100%">';
$linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder".'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print '</td></tr>';
// Ref client
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>';
print '</tr></table>';
print '</td><td colspan="3">';
print $object->ref_client;
print '</td>';
print '</tr>';
// Customer
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
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 '<br>';
}
// 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
// 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)
{
dol_print_error($db);
$totalsize+=$file['size'];
}
print '<table class="border"width="100%">';
$linkback='<a href="'.DOL_URL_ROOT.'/comm/propal/list.php'."?page=$page&socid=$socid&viewstatut=$viewstatut&sortfield=$sortfield&$sortorder".'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="3">';
print $form->showrefnav($object,'ref',$linkback,1,'ref','ref','');
print '</td></tr>';
// Ref client
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>';
print '</tr></table>';
print '</td><td colspan="3">';
print $object->ref_client;
print '</td>';
print '</tr>';
// Customer
print "<tr><td>".$langs->trans("Company")."</td>";
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
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 '<br>';
}
// 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
{

View File

@@ -799,9 +799,33 @@ class Contrat extends CommonObject
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; }
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)
{
$this->db->commit();
return 1;
}

View File

@@ -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'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
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 '<div class="error">'.$error_msg.'</div><br>';
}
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,11 +164,11 @@ if ($contrat->id)
print '<table class="border" width="100%">';
// Reference
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">'.$contrat->ref.'</td></tr>';
print '<tr><td width="30%">'.$langs->trans('Ref').'</td><td colspan="3">'.$object->ref.'</td></tr>';
// Societe
print '<tr><td>'.$langs->trans("Customer").'</td>';
print '<td colspan="3">'.$soc->getNomUrl(1).'</td></tr>';
print '<td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
@@ -161,15 +176,26 @@ if ($contrat->id)
print '</div>';
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 '<br>';
}
// 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

View File

@@ -428,6 +428,7 @@ 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_thirdparty();
$result=$object->delete($user,$langs,$conf);
if ($result >= 0)
{

View File

@@ -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');

View File

@@ -48,6 +48,7 @@ class Project extends CommonObject
var $note_public;
var $statuts_short;
var $statuts;
var $oldcopy;
/**
* Constructor
@@ -208,6 +209,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;
}
else
@@ -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);

View File

@@ -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'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
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 '<br>';
}
@@ -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 '</td></tr>';
// Label
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$project->title.'</td></tr>';
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->title.'</td></tr>';
// Company
print '<tr><td>'.$langs->trans("Company").'</td><td>';
if (! empty($project->societe->id)) print $project->societe->getNomUrl(1);
if (! empty($object->societe->id)) print $object->societe->getNomUrl(1);
else print '&nbsp;';
print '</td></tr>';
// Visibility
print '<tr><td>'.$langs->trans("Visibility").'</td><td>';
if ($project->public) print $langs->trans('SharedProject');
if ($object->public) print $langs->trans('SharedProject');
else print $langs->trans('PrivateProject');
print '</td></tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$project->getLibStatut(4).'</td></tr>';
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">'.count($filearray).'</td></tr>';
@@ -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

View File

@@ -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='<div class="error">'.$object->error.'</div>';
}
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