From 48f1adc9ae42ece8f642071fac1f9077da235d1b Mon Sep 17 00:00:00 2001 From: Regis Houssin <regis@dolibarr.fr> Date: Mon, 15 Jan 2007 13:36:02 +0000 Subject: [PATCH] =?UTF-8?q?Fix:=20on=20n'efface=20pas=20le=20r=E9pertoire?= =?UTF-8?q?=20lors=20de=20la=20validation=20d'une=20commande=20qui=20avait?= =?UTF-8?q?=20=20d=E9j=E0=20=E9t=E9=20valid=E9=20et=20r=E9=E9dit=E9e?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htdocs/commande/commande.class.php | 55 ++++++++++++++++-------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index b500cbe8344..3fc76adfd55 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -1,7 +1,7 @@ <?php /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org> * 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> * * 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 $comref = substr($this->ref, 1, 4); if ($comref == 'PROV') - { + { $num = $this->getNextNumRef($soc); - } + } else - { + { $num = $this->ref; - } + } $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"; $resql=$this->db->query($sql); 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); if ($conf->commande->dir_output) - { - $dir = $conf->commande->dir_output . "/" . $comref ; - $file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf"; - if (file_exists($file)) - { - commande_delete_preview($this->db, $this->id, $this->ref); - - if (!dol_delete_file($file)) + { + $dir = $conf->commande->dir_output . "/" . $comref ; + $file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf"; + if (file_exists($file)) { - $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); - $this->db->rollback(); - return 0; + commande_delete_preview($this->db, $this->id, $this->ref); + + if (!dol_delete_file($file)) + { + $this->error=$langs->trans("ErrorCanNotDeleteFile",$file); + $this->db->rollback(); + return 0; + } } - } - if (file_exists($dir)) - { - if (!dol_delete_dir($dir)) + if (file_exists($dir)) { - $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); - $this->db->rollback(); - return 0; + if (!dol_delete_dir($dir)) + { + $this->error=$langs->trans("ErrorCanNotDeleteDir",$dir); + $this->db->rollback(); + return 0; + } } - } - } + } + } // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/interfaces.class.php"); -- GitLab