Fix: on n'efface pas le répertoire lors de la validation d'une commande qui avait
déjà été validé et rééditée
This commit is contained in:
parent
1357aca327
commit
48f1adc9ae
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2006 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2006 Regis Houssin <regis.houssin@cap-networks.com>
|
* Copyright (C) 2005-2007 Regis Houssin <regis.houssin@cap-networks.com>
|
||||||
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -212,47 +212,50 @@ class Commande extends CommonObject
|
|||||||
// on vérifie si la commande est en numérotation provisoire
|
// on vérifie si la commande est en numérotation provisoire
|
||||||
$comref = substr($this->ref, 1, 4);
|
$comref = substr($this->ref, 1, 4);
|
||||||
if ($comref == 'PROV')
|
if ($comref == 'PROV')
|
||||||
{
|
{
|
||||||
$num = $this->getNextNumRef($soc);
|
$num = $this->getNextNumRef($soc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$num = $this->ref;
|
$num = $this->ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='$num', fk_statut = 1, date_valid=now(), fk_user_valid=$user->id";
|
$sql = 'UPDATE '.MAIN_DB_PREFIX."commande SET ref='$num', fk_statut = 1, date_valid=now(), fk_user_valid=$user->id";
|
||||||
$sql .= " WHERE rowid = $this->id AND fk_statut = 0";
|
$sql .= " WHERE rowid = $this->id AND fk_statut = 0";
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
|
{
|
||||||
|
// On efface le répertoire de pdf provisoire
|
||||||
|
if ($comref == 'PROV')
|
||||||
{
|
{
|
||||||
// On efface le répertoire de pdf provisoire
|
|
||||||
$comref = sanitize_string($this->ref);
|
$comref = sanitize_string($this->ref);
|
||||||
if ($conf->commande->dir_output)
|
if ($conf->commande->dir_output)
|
||||||
{
|
{
|
||||||
$dir = $conf->commande->dir_output . "/" . $comref ;
|
$dir = $conf->commande->dir_output . "/" . $comref ;
|
||||||
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
|
$file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf";
|
||||||
if (file_exists($file))
|
if (file_exists($file))
|
||||||
{
|
{
|
||||||
commande_delete_preview($this->db, $this->id, $this->ref);
|
commande_delete_preview($this->db, $this->id, $this->ref);
|
||||||
|
|
||||||
if (!dol_delete_file($file))
|
if (!dol_delete_file($file))
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
|
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (file_exists($dir))
|
||||||
if (file_exists($dir))
|
|
||||||
{
|
|
||||||
if (!dol_delete_dir($dir))
|
|
||||||
{
|
{
|
||||||
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
|
if (!dol_delete_dir($dir))
|
||||||
$this->db->rollback();
|
{
|
||||||
return 0;
|
$this->error=$langs->trans("ErrorCanNotDeleteDir",$dir);
|
||||||
|
$this->db->rollback();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user