From 548266d6071b9898c9740db27107ca5a4ca55f7f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 11 Jun 2012 21:42:19 +0200 Subject: [PATCH] Fix: uniformize code --- htdocs/comm/propal/class/propal.class.php | 8 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/commande/document.php | 4 +- htdocs/core/class/fileupload.class.php | 31 +++++-- .../interface_90_all_Demo.class.php-NORUN | 14 ++- htdocs/fichinter/class/fichinter.class.php | 31 ++++++- htdocs/fichinter/document.php | 53 +++++++---- htdocs/fichinter/fiche.php | 20 ++++- .../class/fournisseur.commande.class.php | 74 +++++++++++---- htdocs/fourn/commande/document.php | 89 ++++++++++--------- htdocs/fourn/commande/fiche.php | 12 ++- 11 files changed, 240 insertions(+), 98 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index aab35e04585..b3fc7d4fde8 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1801,11 +1801,11 @@ class Propal extends CommonObject if (! $error) { // We remove directory - $propalref = dol_sanitizeFileName($this->ref); + $ref = dol_sanitizeFileName($this->ref); if ($conf->propal->dir_output) { - $dir = $conf->propal->dir_output . "/" . $propalref ; - $file = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . ".pdf"; + $dir = $conf->propal->dir_output . "/" . $ref ; + $file = $dir . "/" . $ref . ".pdf"; if (file_exists($file)) { dol_delete_preview($this); @@ -1819,7 +1819,7 @@ class Propal extends CommonObject } if (file_exists($dir)) { - $res=@dol_delete_dir($dir); + $res=@dol_delete_dir_recursive($dir); if (! $res) { $this->error='ErrorFailToDeleteDir'; diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 6da00cbfbd7..6ef9c3aa253 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2294,7 +2294,7 @@ class Commande extends CommonObject } if (file_exists($dir)) { - if (! dol_delete_dir($dir)) + if (! dol_delete_dir_recursive($dir)) { $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); $this->db->rollback(); diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 0002771ee7d..84c2896e0e3 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -119,7 +119,7 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) } // Delete -if ($action == 'confirm_deletefile' && $confirm == 'yes') +else if ($action == 'confirm_deletefile' && $confirm == 'yes') { if ($object->fetch($id)) { @@ -185,7 +185,7 @@ if ($id > 0 || ! empty($ref)) */ if ($action == 'delete') { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); if ($ret == 'html') print '
'; } diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 5b8369a0640..af1a24efb26 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -59,21 +59,36 @@ class FileUpload // For compatibility if ($element == 'propal') { - $pathname = 'comm/propal'; $filename = 'propal'; - } - elseif ($element == 'commande') { - $pathname = $filename = 'commande'; + $pathname = 'comm/propal'; + $dir_output=$conf->$element->dir_output; } elseif ($element == 'facture') { - $pathname = 'compta/facture'; $filename = 'facture'; + $pathname = 'compta/facture'; + $dir_output=$conf->$element->dir_output; } elseif ($element == 'project') { - $element = $pathname = 'projet'; $filename = 'project'; + $element = $pathname = 'projet'; + $dir_output=$conf->$element->dir_output; + } + elseif ($element == 'fichinter') { + $element='ficheinter'; + $dir_output=$conf->$element->dir_output; + } + elseif ($element == 'order_supplier') { + $pathname = 'fourn'; $filename='fournisseur.commande'; + $dir_output=$conf->fournisseur->commande->dir_output; + } else { + $dir_output=$conf->$element->dir_output; } dol_include_once('/'.$pathname.'/class/'.$filename.'.class.php'); $classname = ucfirst($filename); + + if ($element == 'order_supplier') { + $classname = 'CommandeFournisseur'; + } + $object = new $classname($db); $object->fetch($fk_element); @@ -81,7 +96,7 @@ class FileUpload $this->_options = array( 'script_url' => $_SERVER['PHP_SELF'], - 'upload_dir' => $conf->$element->dir_output . '/' . $object->ref . '/', + 'upload_dir' => $dir_output . '/' . $object->ref . '/', 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$object->ref.'/', 'param_name' => 'files', // Set the following option to 'POST', if your server does not support @@ -115,7 +130,7 @@ class FileUpload ), */ 'thumbnail' => array( - 'upload_dir' => $conf->$element->dir_output . '/' . $object->ref . '/thumbs/', + 'upload_dir' => $dir_output . '/' . $object->ref . '/thumbs/', 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$object->ref.'/thumbs/', 'max_width' => 80, 'max_height' => 80 diff --git a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN index 68789b03878..99b52ce3684 100755 --- a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN +++ b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN @@ -396,7 +396,19 @@ class InterfaceDemo } // Interventions - elseif ($action == 'FICHEINTER_VALIDATE') + elseif ($action == 'FICHEINTER_CREATE') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'FICHEINTER_MODIFY') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'FICHEINTER_VALIDATE') + { + dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); + } + elseif ($action == 'FICHEINTER_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 4d43f0cd416..e9de5771635 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -156,6 +156,15 @@ class Fichinter extends CommonObject $result=$this->db->query($sql); if ($result) { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('FICHEINTER_CREATE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + $this->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter"); $this->db->commit(); return $this->id; @@ -193,6 +202,15 @@ class Fichinter extends CommonObject dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); if ($this->db->query($sql)) { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('FICHEINTER_MODIFY',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + $this->db->commit(); return 1; } @@ -629,7 +647,7 @@ class Fichinter extends CommonObject { dol_delete_preview($this); - if (!dol_delete_file($file)) + if (! dol_delete_file($file,0,0,0,$this)) // For triggers { $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); return 0; @@ -637,13 +655,22 @@ class Fichinter extends CommonObject } if (file_exists($dir)) { - if (!dol_delete_dir($dir)) + if (! dol_delete_dir_recursive($dir)) { $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); return 0; } } } + + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('FICHEINTER_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/fichinter/document.php b/htdocs/fichinter/document.php index 018998cf47e..9ac5841bed1 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -41,6 +41,14 @@ $langs->load("interventions"); $id = GETPOST('id','int'); $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); + +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); +} // Security check if ($user->societe_id) $socid=$user->societe_id; @@ -110,6 +118,22 @@ if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC)) } } +// Delete +else if ($action == 'confirm_deletefile' && $confirm == 'yes') +{ + if ($object->id > 0) + { + $langs->load("other"); + $object->fetch_thirdparty(); + + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + dol_delete_file($file,0,0,0,$object); + $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; + } +} + /* * View @@ -124,21 +148,6 @@ if ($object->id) { $object->fetch_thirdparty(); - $soc = new Societe($db); - $soc->fetch($object->societe->id); - - if ( $error_msg ) - { - echo '
'.$error_msg.'

'; - } - - if ($action == 'delete') - { - $file = $upload_dir . '/' . GETPOST('urlfile','alpha'); // 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=fichinter_prepare_head($object, $user); dol_fiche_head($head, 'documents', $langs->trans("InterventionCard"), 0, 'intervention'); @@ -168,7 +177,17 @@ if ($object->id) print ''; print ''; - + + dol_htmloutput_mesg($mesg,$mesgs); + + /* + * Confirmation suppression fichier + */ + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); + if ($ret == 'html') print '
'; + } // Affiche formulaire upload $formfile=new FormFile($db); @@ -176,7 +195,7 @@ if ($object->id) // List of document - //$param='&id='.$object->id; + $param='&id='.$object->id; $formfile->list_of_documents($filearray,$object,'ficheinter',$param); } diff --git a/htdocs/fichinter/fiche.php b/htdocs/fichinter/fiche.php index 576a781ffcb..38a43efbe72 100644 --- a/htdocs/fichinter/fiche.php +++ b/htdocs/fichinter/fiche.php @@ -195,6 +195,23 @@ else if ($action == 'builddoc' && $user->rights->ficheinter->creer) // En get ou } } +// Remove file in doc form +else if ($action == 'remove_file') +{ + if ($object->fetch($id)) + { + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + + $object->fetch_thirdparty(); + + $langs->load("other"); + $upload_dir = $conf->ficheinter->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + dol_delete_file($file,0,0,0,$object); + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('file')).'
'; + } +} + // Set into a project else if ($action == 'classin' && $user->rights->ficheinter->creer) { @@ -205,7 +222,8 @@ else if ($action == 'classin' && $user->rights->ficheinter->creer) else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer) { - $object->fetch($id); + $object->fetch($id); + $object->fetch_thirdparty(); $object->delete($user); Header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter'); diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 3eef7d0116a..587bfb48be5 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -332,6 +332,8 @@ class CommandeFournisseur extends Commande if (! $error) { + $this->oldref=''; + // Rename directory if dir was a temporary ref if (preg_match('/^[\(]?PROV/i', $this->ref)) { @@ -347,6 +349,8 @@ class CommandeFournisseur extends Commande if (@rename($dirsource, $dirdest)) { + $this->oldref = $oldref; + dol_syslog("Rename ok"); // Suppression ancien fichier PDF dans nouveau rep dol_delete_file($dirdest.'/'.$oldref.'.*'); @@ -1226,6 +1230,7 @@ class CommandeFournisseur extends Commande function delete($user='') { global $langs,$conf; + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); $error = 0; @@ -1251,25 +1256,60 @@ class CommandeFournisseur extends Commande { $error++; } - - if ($error == 0) - { - // Appel des triggers - include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); - $interface=new Interfaces($this->db); - $result=$interface->run_triggers('ORDER_SUPPLIER_DELETE',$this,$user,$langs,$conf); - if ($result < 0) { $error++; $this->errors=$interface->errors; } - // Fin appel triggers - - dol_syslog("CommandeFournisseur::delete : Success"); - $this->db->commit(); - return 1; + + if (! $error) + { + // Appel des triggers + include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); + $interface=new Interfaces($this->db); + $result=$interface->run_triggers('ORDER_SUPPLIER_DELETE',$this,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers } - else - { - $this->db->rollback(); - return -1; + + if (! $error) + { + // We remove directory + $ref = dol_sanitizeFileName($this->ref); + if ($conf->fournisseur->commande->dir_output) + { + $dir = $conf->fournisseur->commande->dir_output . "/" . $ref ; + $file = $dir . "/" . $ref . ".pdf"; + if (file_exists($file)) + { + if (! dol_delete_file($file,0,0,0,$this)) // For triggers + { + $this->error='ErrorFailToDeleteFile'; + $error++; + } + } + if (file_exists($dir)) + { + $res=@dol_delete_dir_recursive($dir); + if (! $res) + { + $this->error='ErrorFailToDeleteDir'; + $error++; + } + } + } } + + if (! $error) + { + dol_syslog(get_class($this)."::delete $this->id by $user->id", LOG_DEBUG); + $this->db->commit(); + return 1; + } + else + { + $this->error=$this->db->lasterror(); + dol_syslog(get_class($this)."::delete ".$this->error, LOG_ERR); + $this->db->rollback(); + return -$error; + } } /** diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index 07f0f2e354d..06e01e26e04 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -41,6 +41,11 @@ $langs->load('deliveries'); $langs->load('products'); $langs->load('stocks'); +$id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); + $mesg=''; if (isset($_SESSION['DolMessage'])) { @@ -49,8 +54,6 @@ if (isset($_SESSION['DolMessage'])) } // Security check -$id=empty($_GET['id']) ? 0 : intVal($_GET['id']); -$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'commande_fournisseur', $id,''); @@ -66,14 +69,15 @@ if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; -$commande = new CommandeFournisseur($db); -if ($commande->fetch($_GET['id'],$_GET['ref']) < 0) +$object = new CommandeFournisseur($db); +if ($object->fetch($id,$ref) < 0) { dol_print_error($db); exit; } - +$upload_dir = $conf->fournisseur->dir_output.'/commande/'.dol_sanitizeFileName($object->ref); +$object->fetch_thirdparty(); /* * Actions @@ -82,8 +86,6 @@ if ($commande->fetch($_GET['id'],$_GET['ref']) < 0) // Envoi fichier if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - $upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($commande->ref); - 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']); @@ -119,16 +121,18 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) } } -// Delete -if ($action=='delete') -{ - $langs->load("other"); - $upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($commande->ref); - $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; +else if ($action == 'confirm_deletefile' && $confirm == 'yes') +{ + if ($object->id > 0) + { + $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,0,0,0,$object); + $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; + } } @@ -138,21 +142,14 @@ if ($action=='delete') $form = new Form($db); -$id = $_GET['id']; -$ref= $_GET['ref']; -if ($id > 0 || ! empty($ref)) +if ($object->id > 0) { llxHeader(); - $upload_dir = $conf->fournisseur->dir_output.'/commande/'.dol_sanitizeFileName($commande->ref); - - $soc = new Societe($db); - $soc->fetch($commande->socid); - $author = new User($db); - $author->fetch($commande->user_author_id); + $author->fetch($object->user_author_id); - $head = ordersupplier_prepare_head($commande); + $head = ordersupplier_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans('SupplierOrder'), 0, 'order'); @@ -171,35 +168,35 @@ if ($id > 0 || ! empty($ref)) // Ref print ''.$langs->trans("Ref").''; print ''; - print $form->showrefnav($commande,'ref','',1,'ref','ref'); + print $form->showrefnav($object,'ref','',1,'ref','ref'); print ''; print ''; // Fournisseur print ''.$langs->trans("Supplier").""; - print ''.$soc->getNomUrl(1,'supplier').''; + print ''.$object->thirdparty->getNomUrl(1,'supplier').''; print ''; // Statut print ''; print ''.$langs->trans("Status").''; print ''; - print $commande->getLibStatut(4); + print $object->getLibStatut(4); print ""; // Date - if ($commande->methode_commande_id > 0) + if ($object->methode_commande_id > 0) { print ''.$langs->trans("Date").''; - if ($commande->date_commande) + if ($object->date_commande) { - print dol_print_date($commande->date_commande,"dayhourtext")."\n"; + print dol_print_date($object->date_commande,"dayhourtext")."\n"; } print ""; - if ($commande->methode_commande) + if ($object->methode_commande) { - print ''.$langs->trans("Method").''.$commande->methode_commande.''; + print ''.$langs->trans("Method").''.$object->methode_commande.''; } } @@ -213,25 +210,33 @@ if ($id > 0 || ! empty($ref)) print "\n"; print "\n"; - - if ($mesg) { print $mesg."
"; } - + + dol_htmloutput_mesg($mesg,$mesgs); + + /* + * Confirmation suppression fichier + */ + if ($action == 'delete') + { + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urlencode($_GET["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.'/fourn/commande/document.php?id='.$commande->id,'',0,0,$user->rights->fournisseur->commande->creer,50,$object); + $formfile->form_attach_new_file(DOL_URL_ROOT.'/fourn/commande/document.php?id='.$object->id,'',0,0,$user->rights->fournisseur->commande->creer,50,$object); // List of document - $param='&id='.$commande->id; - $formfile->list_of_documents($filearray,$commande,'commande_fournisseur',$param); + $param='&id='.$object->id; + $formfile->list_of_documents($filearray,$object,'commande_fournisseur',$param); } else { Header('Location: index.php'); } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 8425ae5c0bd..6f3281ecaef 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -356,6 +356,7 @@ else if ($action == 'confirm_deleteproductline' && $confirm == 'yes' && $user->r else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->commande->valider) { $object->fetch($id); + $object->fetch_thirdparty(); $object->date_commande=dol_now(); $result = $object->valid($user); @@ -452,6 +453,7 @@ else if ($action == 'confirm_commande' && $confirm == 'yes' && $user->rights->fo else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->commande->supprimer) { $object->fetch($id); + $object->fetch_thirdparty(); $result=$object->delete($user); if ($result > 0) { @@ -547,7 +549,9 @@ else if ($action == 'builddoc' && $user->rights->fournisseur->commande->creer) / // Build document // Sauvegarde le dernier module choisi pour generer un document - $object->fetch($_REQUEST['id']); + $object->fetch($id); + $object->fetch_thirdparty(); + if ($_REQUEST['model']) { $object->setDocModel($user, $_REQUEST['model']); @@ -579,10 +583,12 @@ else if ($action == 'remove_file' && $user->rights->fournisseur->commande->creer if ($object->fetch($id)) { + $object->fetch_thirdparty(); + $langs->load("other"); - $upload_dir = $conf->fournisseur->commande->dir_output . "/"; + $upload_dir = $conf->fournisseur->commande->dir_output; $file = $upload_dir . '/' . GETPOST('file'); - dol_delete_file($file); + dol_delete_file($file,0,0,0,$object); $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('file')).'
'; } }