From 4dbe1334feef2768d575ffc9a32c60d379166f76 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 9 Jun 2006 14:38:19 +0000 Subject: [PATCH] bugfix --- htdocs/commande/commande.class.php | 3 +- htdocs/commande/fiche.php | 1 - .../modules/commande/modules_commande.php | 39 +++++++++++-------- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php index 5ca510ed1c5..7d350f7e8b8 100644 --- a/htdocs/commande/commande.class.php +++ b/htdocs/commande/commande.class.php @@ -41,6 +41,7 @@ class Commande { var $db ; var $id ; + var $ref; var $socidp; var $contactid; var $projet_id; @@ -1926,7 +1927,7 @@ class Commande $file = $conf->commande->dir_output . "/" . $comref . "/" . $comref . ".pdf"; if (file_exists($file)) { - commande_delete_preview($this->db, $this->id); + commande_delete_preview($this->db, $this->id, $this->ref); if (!dol_delete_file($file)) { diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index a87b40af118..17adfc778c9 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -287,7 +287,6 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes') if ($user->rights->commande->supprimer ) { $commande = new Commande($db); - //$commande->id = $_GET['id']; $commande->fetch($_GET['id']); $commande->delete(); Header('Location: index.php'); diff --git a/htdocs/includes/modules/commande/modules_commande.php b/htdocs/includes/modules/commande/modules_commande.php index 8d6a407874c..9f93c777354 100644 --- a/htdocs/includes/modules/commande/modules_commande.php +++ b/htdocs/includes/modules/commande/modules_commande.php @@ -212,25 +212,39 @@ function commande_pdf_create($db, $id, $modele='', $outputlangs='') } -function commande_delete_preview($db, $commandeid) +function commande_delete_preview($db, $commandeid, $commanderef='') { global $langs,$conf; - $com = new Commande($db,"",$commandeid); - $com->fetch($commandeid); - $client = new Societe($db); - $client->fetch($com->soc_id); + if (!$commanderef) + { + $com = new Commande($db,"",$commandeid); + $com->fetch($commandeid); + $commanderef = $com->ref; + } + //$client = new Societe($db); + //$client->fetch($com->soc_id); if ($conf->commande->dir_output) { - $comref = sanitize_string($com->ref); + $comref = sanitize_string($commanderef); $dir = $conf->commande->dir_output . "/" . $comref ; $file = $dir . "/" . $comref . ".pdf.png"; $multiple = $file . "."; - for ($i = 0; $i < 20; $i++) + if ( file_exists( $file ) && is_writable( $file ) ) { - $preview = $multiple.$i; + if ( ! unlink($file) ) + { + $this->error=$langs->trans("ErrorFailedToOpenFile",$file); + return 0; + } + } + else + { + for ($i = 0; $i < 20; $i++) + { + $preview = $multiple.$i; if ( file_exists( $preview ) && is_writable( $preview ) ) { @@ -240,15 +254,8 @@ function commande_delete_preview($db, $commandeid) return 0; } } - else if ( file_exists( $file ) && is_writable( $file ) ) - { - if ( ! unlink($file) ) - { - $this->error=$langs->trans("ErrorFailedToOpenFile",$file); - return 0; - } - } } } + } } ?>