diff --git a/ChangeLog b/ChangeLog index 44e636c538b..37c320d318e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ +2003-09-12 Brian Fraval + + * Ajout de la suppression d'une société, avec confirmation. + 2003-09-11 Rodolphe Quiédeville - * Correction erreur d'index dans las gestion des documents + * Correction erreur d'index dans la gestion des documents attachés à une société 2003-09-10 Rodolphe Quiédeville diff --git a/htdocs/soc.php b/htdocs/soc.php index 78164229693..2148c413241 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2003 Brian Fraval + * Copyright (C) 2001-2003 Rodolphe Quiedeville * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,6 +36,15 @@ if ($user->societe_id > 0) llxHeader(); + +if ($action == 'del') +{ + print_titre("Suppression de la société"); + + $soc = new Societe($db); + $soc->delete($socid); +} + if ($action == 'add') { $soc = new Societe($db); @@ -156,23 +166,42 @@ elseif ($action == 'edit') } } else { - print_titre("Fiche société"); - $soc = new Societe($db); - $soc->id = $socid; - $soc->fetch($socid); - - print ''; - print ''; - print ''; - print ''; - - print ''; - print ''; - print ''; + if ($action != "del") + { + print_titre("Fiche société"); + + $soc = new Societe($db); + $soc->id = $socid; + $soc->fetch($socid); + + print " + +"; + + print '
Nom'.$soc->nom.'
Adresse'.nl2br($soc->adresse).' 
CP'.$soc->cp.' '.$soc->ville.'
Tel'.$soc->tel.'
Fax'.$soc->fax.'
Webhttp://'.$soc->url.'
'; + print ''; + print ''; + print ''; + + print ''; + print ''; + print ''; + print ''; - + if ($soc->client) { print ''; @@ -181,7 +210,7 @@ elseif ($action == 'edit') { print ''; } - + if ($soc->fournisseur) { print ''; @@ -198,12 +227,12 @@ elseif ($action == 'edit') */ - + print '
Nom'.$soc->nom.'
Adresse'.nl2br($soc->adresse).' 
CP'.$soc->cp.' '.$soc->ville.'
Tel'.$soc->tel.'
Fax'.$soc->fax.'
Webhttp://'.$soc->url.'
Siren'.$soc->siren.' 
Clientoui Fiche
Clientnon
Fournisseuroui Fiche
'; - + print ''; - print ''; + print ''; print ''; print ''; print ''; @@ -215,7 +244,7 @@ elseif ($action == 'edit') clearstatcache(); umask(0); - + $docdir = SOCIETE_OUTPUTDIR . "/$socid"; $url = SOCIETE_OUTPUT_URL . "/$socid"; @@ -238,6 +267,8 @@ elseif ($action == 'edit') } } } + } + } $db->close(); diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index cf076846cee..95e31adc75a 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2003 Brian Fraval + * Copyright (C) 2002-2003 Rodolphe Quiedeville * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -92,6 +93,48 @@ class Societe { print $this->db->error(); } } + + /* + * Suppression d'une societe. + * TODO: il faut ajouter la suppression du répertoire de la societe + */ + Function delete($id) + { + $sql = "DELETE from llx_societe "; + $sql .= " WHERE idp = " . $id .";"; + + if (! $this->db->query($sql)) + { + print $this->db->error(); + } + + // Suppression du répertoire document + $docdir = SOCIETE_OUTPUTDIR . "/$id"; + + // Cette fonction permet de supprimer le répertoire de la societe + // Meme s'il contient des documents. + function deldir($dir){ + $current_dir = opendir($dir); + while($entryname = readdir($current_dir)){ + if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")){ + deldir("${dir}/${entryname}"); + }elseif($entryname != "." and $entryname!=".."){ + unlink("${dir}/${entryname}"); + } + } + closedir($current_dir); + rmdir(${dir}); + } + + + if (file_exists ($docdir)) + { + deldir($docdir); + } + } + + + /* * *
[Editer]-[Supprimer]--[Notifications]