suppression d'une societe

This commit is contained in:
hitweb 2003-09-12 00:20:56 +00:00
parent ec0a8ee9e8
commit cf06ee5765
3 changed files with 100 additions and 22 deletions

View File

@ -1,6 +1,10 @@
2003-09-12 Brian Fraval <brian@fraval.org>
* Ajout de la suppression d'une société, avec confirmation.
2003-09-11 Rodolphe Quiédeville <rq@quiedeville.org>
* 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 <rq@quiedeville.org>

View File

@ -1,5 +1,6 @@
<?PHP
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
/* Copyright (C) 2003 Brian Fraval <brian@fraval.org>
* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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 '<table border="1" cellpadding="3" cellspacing="0" width="100%">';
print '<tr><td width="20%">Nom</td><td class="valeur">'.$soc->nom.'</td></tr>';
print '<tr><td valign="top">Adresse</td><td class="valeur">'.nl2br($soc->adresse).'&nbsp;</td></tr>';
print '<tr><td>CP</td><td class="valeur">'.$soc->cp.'&nbsp;'.$soc->ville.'</td></tr>';
print '<tr><td>Tel</td><td class="valeur">'.$soc->tel.'</td></tr>';
print '<tr><td>Fax</td><td class="valeur">'.$soc->fax.'</td></tr>';
print '<tr><td>Web</td><td><a href="http://'.$soc->url.'">http://'.$soc->url.'</a></td></tr>';
if ($action != "del")
{
print_titre("Fiche société");
$soc = new Societe($db);
$soc->id = $socid;
$soc->fetch($socid);
print "
<SCRIPT language=\"JavaScript\">
<!--
function Delete(socid)
{
var where_to= confirm(\"Voulez vous vraiment supprimer cette société ?\");
if (where_to == true)
{
window.location.replace(\"$dolibarr_main_url_root/soc.php?socid=\"+socid+\"&action=del\");
}
}
//-->
</SCRIPT>
";
print '<table border="1" cellpadding="3" cellspacing="0" width="100%">';
print '<tr><td width="20%">Nom</td><td class="valeur">'.$soc->nom.'</td></tr>';
print '<tr><td valign="top">Adresse</td><td class="valeur">'.nl2br($soc->adresse).'&nbsp;</td></tr>';
print '<tr><td>CP</td><td class="valeur">'.$soc->cp.'&nbsp;'.$soc->ville.'</td></tr>';
print '<tr><td>Tel</td><td class="valeur">'.$soc->tel.'</td></tr>';
print '<tr><td>Fax</td><td class="valeur">'.$soc->fax.'</td></tr>';
print '<tr><td>Web</td><td><a href="http://'.$soc->url.'">http://'.$soc->url.'</a></td></tr>';
print '<tr><td>Siren</td><td>'.$soc->siren.'&nbsp;</td></tr>';
if ($soc->client)
{
print '<tr><td>Client</td><td>oui <a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$socid.'">Fiche</a></td></tr>';
@ -181,7 +210,7 @@ elseif ($action == 'edit')
{
print '<tr><td>Client</td><td>non</td></tr>';
}
if ($soc->fournisseur)
{
print '<tr><td>Fournisseur</td><td>oui <a href="'.DOL_URL_ROOT.'/compta/fiche.php?socid='.$socid.'">Fiche</a></td></tr>';
@ -198,12 +227,12 @@ elseif ($action == 'edit')
*/
print '<br><table width="100%" border="1" cellspacing="0" cellpadding="3">';
print '<td width="20%" align="center">[<a href="soc.php?socid='.$socid.'&action=edit">Editer</a>]</td>';
print '<td width="20%" align="center">-</td>';
print '<td width="20%" align="center">[<a href="#" Onclick="javascript:Delete('.$socid.')">Supprimer</a>]</td>';
print '<td width="20%" align="center">-</td>';
print '<td width="20%" align="center">-</td>';
print '<td width="20%" align="center">[<a href="societe/notify/fiche.php?socid='.$socid.'">Notifications</a>]</td>';
@ -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();

View File

@ -1,5 +1,6 @@
<?PHP
/* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
/* Copyright (C) 2003 Brian Fraval <brian@fraval.org>
* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
*
* 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);
}
}
/*
*
*