Fix: uniformize code

This commit is contained in:
Regis Houssin 2012-06-11 21:42:19 +02:00
parent fb15ea20c6
commit 548266d607
11 changed files with 240 additions and 98 deletions

View File

@ -1801,11 +1801,11 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
// We remove directory // We remove directory
$propalref = dol_sanitizeFileName($this->ref); $ref = dol_sanitizeFileName($this->ref);
if ($conf->propal->dir_output) if ($conf->propal->dir_output)
{ {
$dir = $conf->propal->dir_output . "/" . $propalref ; $dir = $conf->propal->dir_output . "/" . $ref ;
$file = $conf->propal->dir_output . "/" . $propalref . "/" . $propalref . ".pdf"; $file = $dir . "/" . $ref . ".pdf";
if (file_exists($file)) if (file_exists($file))
{ {
dol_delete_preview($this); dol_delete_preview($this);
@ -1819,7 +1819,7 @@ class Propal extends CommonObject
} }
if (file_exists($dir)) if (file_exists($dir))
{ {
$res=@dol_delete_dir($dir); $res=@dol_delete_dir_recursive($dir);
if (! $res) if (! $res)
{ {
$this->error='ErrorFailToDeleteDir'; $this->error='ErrorFailToDeleteDir';

View File

@ -2294,7 +2294,7 @@ class Commande extends CommonObject
} }
if (file_exists($dir)) if (file_exists($dir))
{ {
if (! dol_delete_dir($dir)) if (! dol_delete_dir_recursive($dir))
{ {
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
$this->db->rollback(); $this->db->rollback();

View File

@ -119,7 +119,7 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
} }
// Delete // Delete
if ($action == 'confirm_deletefile' && $confirm == 'yes') else if ($action == 'confirm_deletefile' && $confirm == 'yes')
{ {
if ($object->fetch($id)) if ($object->fetch($id))
{ {
@ -185,7 +185,7 @@ if ($id > 0 || ! empty($ref))
*/ */
if ($action == 'delete') 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 '<br>'; if ($ret == 'html') print '<br>';
} }

View File

@ -59,21 +59,36 @@ class FileUpload
// For compatibility // For compatibility
if ($element == 'propal') { if ($element == 'propal') {
$pathname = 'comm/propal'; $filename = 'propal'; $pathname = 'comm/propal';
} $dir_output=$conf->$element->dir_output;
elseif ($element == 'commande') {
$pathname = $filename = 'commande';
} }
elseif ($element == 'facture') { elseif ($element == 'facture') {
$pathname = 'compta/facture'; $filename = 'facture'; $pathname = 'compta/facture';
$dir_output=$conf->$element->dir_output;
} }
elseif ($element == 'project') { 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'); dol_include_once('/'.$pathname.'/class/'.$filename.'.class.php');
$classname = ucfirst($filename); $classname = ucfirst($filename);
if ($element == 'order_supplier') {
$classname = 'CommandeFournisseur';
}
$object = new $classname($db); $object = new $classname($db);
$object->fetch($fk_element); $object->fetch($fk_element);
@ -81,7 +96,7 @@ class FileUpload
$this->_options = array( $this->_options = array(
'script_url' => $_SERVER['PHP_SELF'], '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.'/', 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$object->ref.'/',
'param_name' => 'files', 'param_name' => 'files',
// Set the following option to 'POST', if your server does not support // Set the following option to 'POST', if your server does not support
@ -115,7 +130,7 @@ class FileUpload
), ),
*/ */
'thumbnail' => array( '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/', 'upload_url' => DOL_URL_ROOT.'/document.php?modulepart='.$element.'&attachment=1&file=/'.$object->ref.'/thumbs/',
'max_width' => 80, 'max_width' => 80,
'max_height' => 80 'max_height' => 80

View File

@ -396,7 +396,19 @@ class InterfaceDemo
} }
// Interventions // 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); dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
} }

View File

@ -156,6 +156,15 @@ class Fichinter extends CommonObject
$result=$this->db->query($sql); $result=$this->db->query($sql);
if ($result) 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->id=$this->db->last_insert_id(MAIN_DB_PREFIX."fichinter");
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
@ -193,6 +202,15 @@ class Fichinter extends CommonObject
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
if ($this->db->query($sql)) 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(); $this->db->commit();
return 1; return 1;
} }
@ -629,7 +647,7 @@ class Fichinter extends CommonObject
{ {
dol_delete_preview($this); 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); $this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
return 0; return 0;
@ -637,7 +655,7 @@ class Fichinter extends CommonObject
} }
if (file_exists($dir)) if (file_exists($dir))
{ {
if (!dol_delete_dir($dir)) if (! dol_delete_dir_recursive($dir))
{ {
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
return 0; return 0;
@ -645,6 +663,15 @@ class Fichinter extends CommonObject
} }
} }
// 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(); $this->db->commit();
return 1; return 1;
} }

View File

@ -41,6 +41,14 @@ $langs->load("interventions");
$id = GETPOST('id','int'); $id = GETPOST('id','int');
$ref = GETPOST('ref', 'alpha'); $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action','alpha'); $action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
$mesg='';
if (isset($_SESSION['DolMessage']))
{
$mesg=$_SESSION['DolMessage'];
unset($_SESSION['DolMessage']);
}
// Security check // Security check
if ($user->societe_id) $socid=$user->societe_id; 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'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
}
/* /*
* View * View
@ -124,21 +148,6 @@ if ($object->id)
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$soc = new Societe($db);
$soc->fetch($object->societe->id);
if ( $error_msg )
{
echo '<div class="error">'.$error_msg.'</div><br>';
}
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); $head=fichinter_prepare_head($object, $user);
dol_fiche_head($head, 'documents', $langs->trans("InterventionCard"), 0, 'intervention'); dol_fiche_head($head, 'documents', $langs->trans("InterventionCard"), 0, 'intervention');
@ -169,6 +178,16 @@ if ($object->id)
print '</div>'; print '</div>';
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 '<br>';
}
// Affiche formulaire upload // Affiche formulaire upload
$formfile=new FormFile($db); $formfile=new FormFile($db);
@ -176,7 +195,7 @@ if ($object->id)
// List of document // List of document
//$param='&id='.$object->id; $param='&id='.$object->id;
$formfile->list_of_documents($filearray,$object,'ficheinter',$param); $formfile->list_of_documents($filearray,$object,'ficheinter',$param);
} }

View File

@ -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 = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
}
}
// Set into a project // Set into a project
else if ($action == 'classin' && $user->rights->ficheinter->creer) else if ($action == 'classin' && $user->rights->ficheinter->creer)
{ {
@ -206,6 +223,7 @@ else if ($action == 'classin' && $user->rights->ficheinter->creer)
else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer) else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->ficheinter->supprimer)
{ {
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty();
$object->delete($user); $object->delete($user);
Header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter'); Header('Location: '.DOL_URL_ROOT.'/fichinter/list.php?leftmenu=ficheinter');

View File

@ -332,6 +332,8 @@ class CommandeFournisseur extends Commande
if (! $error) if (! $error)
{ {
$this->oldref='';
// Rename directory if dir was a temporary ref // Rename directory if dir was a temporary ref
if (preg_match('/^[\(]?PROV/i', $this->ref)) if (preg_match('/^[\(]?PROV/i', $this->ref))
{ {
@ -347,6 +349,8 @@ class CommandeFournisseur extends Commande
if (@rename($dirsource, $dirdest)) if (@rename($dirsource, $dirdest))
{ {
$this->oldref = $oldref;
dol_syslog("Rename ok"); dol_syslog("Rename ok");
// Suppression ancien fichier PDF dans nouveau rep // Suppression ancien fichier PDF dans nouveau rep
dol_delete_file($dirdest.'/'.$oldref.'.*'); dol_delete_file($dirdest.'/'.$oldref.'.*');
@ -1226,6 +1230,7 @@ class CommandeFournisseur extends Commande
function delete($user='') function delete($user='')
{ {
global $langs,$conf; global $langs,$conf;
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$error = 0; $error = 0;
@ -1252,24 +1257,59 @@ class CommandeFournisseur extends Commande
$error++; $error++;
} }
if ($error == 0) if (! $error)
{ {
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('ORDER_SUPPLIER_DELETE',$this,$user,$langs,$conf); $result=$interface->run_triggers('ORDER_SUPPLIER_DELETE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) {
// Fin appel triggers $error++; $this->errors=$interface->errors;
}
// Fin appel triggers
}
dol_syslog("CommandeFournisseur::delete : Success"); if (! $error)
$this->db->commit();
return 1;
}
else
{ {
$this->db->rollback(); // We remove directory
return -1; $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;
}
} }
/** /**

View File

@ -41,6 +41,11 @@ $langs->load('deliveries');
$langs->load('products'); $langs->load('products');
$langs->load('stocks'); $langs->load('stocks');
$id = GETPOST('id','int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
$mesg=''; $mesg='';
if (isset($_SESSION['DolMessage'])) if (isset($_SESSION['DolMessage']))
{ {
@ -49,8 +54,6 @@ if (isset($_SESSION['DolMessage']))
} }
// Security check // 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; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'commande_fournisseur', $id,''); $result = restrictedArea($user, 'commande_fournisseur', $id,'');
@ -66,14 +69,15 @@ if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name"; if (! $sortfield) $sortfield="name";
$commande = new CommandeFournisseur($db); $object = new CommandeFournisseur($db);
if ($commande->fetch($_GET['id'],$_GET['ref']) < 0) if ($object->fetch($id,$ref) < 0)
{ {
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
$upload_dir = $conf->fournisseur->dir_output.'/commande/'.dol_sanitizeFileName($object->ref);
$object->fetch_thirdparty();
/* /*
* Actions * Actions
@ -82,8 +86,6 @@ if ($commande->fetch($_GET['id'],$_GET['ref']) < 0)
// Envoi fichier // Envoi fichier
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) 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) 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']); $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 else if ($action == 'confirm_deletefile' && $confirm == 'yes')
if ($action=='delete')
{ {
$langs->load("other"); if ($object->id > 0)
$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). $langs->load("other");
dol_delete_file($file);
$_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>'; $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); dol_delete_file($file,0,0,0,$object);
exit; $_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
exit;
}
} }
@ -138,21 +142,14 @@ if ($action=='delete')
$form = new Form($db); $form = new Form($db);
$id = $_GET['id']; if ($object->id > 0)
$ref= $_GET['ref'];
if ($id > 0 || ! empty($ref))
{ {
llxHeader(); 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 = 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'); dol_fiche_head($head, 'documents', $langs->trans('SupplierOrder'), 0, 'order');
@ -171,35 +168,35 @@ if ($id > 0 || ! empty($ref))
// Ref // Ref
print '<tr><td width="35%">'.$langs->trans("Ref").'</td>'; print '<tr><td width="35%">'.$langs->trans("Ref").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
print $form->showrefnav($commande,'ref','',1,'ref','ref'); print $form->showrefnav($object,'ref','',1,'ref','ref');
print '</td>'; print '</td>';
print '</tr>'; print '</tr>';
// Fournisseur // Fournisseur
print '<tr><td>'.$langs->trans("Supplier")."</td>"; print '<tr><td>'.$langs->trans("Supplier")."</td>";
print '<td colspan="2">'.$soc->getNomUrl(1,'supplier').'</td>'; print '<td colspan="2">'.$object->thirdparty->getNomUrl(1,'supplier').'</td>';
print '</tr>'; print '</tr>';
// Statut // Statut
print '<tr>'; print '<tr>';
print '<td>'.$langs->trans("Status").'</td>'; print '<td>'.$langs->trans("Status").'</td>';
print '<td colspan="2">'; print '<td colspan="2">';
print $commande->getLibStatut(4); print $object->getLibStatut(4);
print "</td></tr>"; print "</td></tr>";
// Date // Date
if ($commande->methode_commande_id > 0) if ($object->methode_commande_id > 0)
{ {
print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">'; print '<tr><td>'.$langs->trans("Date").'</td><td colspan="2">';
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 "</td></tr>"; print "</td></tr>";
if ($commande->methode_commande) if ($object->methode_commande)
{ {
print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$commande->methode_commande.'</td></tr>'; print '<tr><td>'.$langs->trans("Method").'</td><td colspan="2">'.$object->methode_commande.'</td></tr>';
} }
} }
@ -214,24 +211,32 @@ if ($id > 0 || ! empty($ref))
print "</div>\n"; print "</div>\n";
if ($mesg) { print $mesg."<br>"; } 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 '<br>';
}
// Affiche formulaire upload // Affiche formulaire upload
$formfile=new FormFile($db); $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 // List of document
$param='&id='.$commande->id; $param='&id='.$object->id;
$formfile->list_of_documents($filearray,$commande,'commande_fournisseur',$param); $formfile->list_of_documents($filearray,$object,'commande_fournisseur',$param);
} }
else else
{ {
Header('Location: index.php'); Header('Location: index.php');
} }
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -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) else if ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->commande->valider)
{ {
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty();
$object->date_commande=dol_now(); $object->date_commande=dol_now();
$result = $object->valid($user); $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) else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->commande->supprimer)
{ {
$object->fetch($id); $object->fetch($id);
$object->fetch_thirdparty();
$result=$object->delete($user); $result=$object->delete($user);
if ($result > 0) if ($result > 0)
{ {
@ -547,7 +549,9 @@ else if ($action == 'builddoc' && $user->rights->fournisseur->commande->creer) /
// Build document // Build document
// Sauvegarde le dernier module choisi pour generer un document // Sauvegarde le dernier module choisi pour generer un document
$object->fetch($_REQUEST['id']); $object->fetch($id);
$object->fetch_thirdparty();
if ($_REQUEST['model']) if ($_REQUEST['model'])
{ {
$object->setDocModel($user, $_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)) if ($object->fetch($id))
{ {
$object->fetch_thirdparty();
$langs->load("other"); $langs->load("other");
$upload_dir = $conf->fournisseur->commande->dir_output . "/"; $upload_dir = $conf->fournisseur->commande->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
dol_delete_file($file); dol_delete_file($file,0,0,0,$object);
$mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>'; $mesg = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('file')).'</div>';
} }
} }