diff --git a/htdocs/soc.php b/htdocs/soc.php
index 7fc931f7d97..1cb72149dea 100644
--- a/htdocs/soc.php
+++ b/htdocs/soc.php
@@ -29,7 +29,7 @@
*/
require("pre.inc.php");
-
+$user->getrights('societe');
$langs->load("companies");
@@ -103,10 +103,35 @@ if ($_POST["action"] == 'add' or $_POST["action"] == 'update')
}
}
+if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->societe->creer)
+{
+ $soc = new Societe($db);
+ $soc->fetch($_GET["socid"]);
+ $result = $soc->delete($_GET["socid"]);
+
+ if ($result == 0)
+ {
+ llxHeader();
+ print "Société $soc->nom supprimée de la base";
+ llxFooter();
+ exit ;
+ }
+ else
+ {
+ $no_reload = 1;
+ $_GET["action"]='';
+ }
+}
+
+/**
+ *
+ *
+ *
+ *
+ */
llxHeader();
-
$form = new Form($db);
if ($_GET["action"] == 'create')
@@ -297,9 +322,12 @@ elseif ($_GET["action"] == 'edit')
}
else
{
- $soc = new Societe($db);
- $soc->id = $_GET["socid"];
- $soc->fetch($_GET["socid"]);
+ if ($no_reload <> 1)
+ {
+ $soc = new Societe($db);
+ $soc->id = $_GET["socid"];
+ $soc->fetch($_GET["socid"]);
+ }
$head[0][0] = 'soc.php?socid='.$soc->id;
$head[0][1] = $langs->trans("Company");
@@ -350,7 +378,25 @@ else
/*
* Fiche société en mode visu
*/
+ $html = new Form($db);
+ /*
+ * Confirmation de la suppression de la facture
+ *
+ */
+ if ($_GET["action"] == 'delete')
+ {
+ $html->form_confirm("soc.php?socid=".$soc->id,"Supprimer la société","Etes-vous sûr de vouloir supprimer cette société et tous ses contacts associés ?","confirm_delete");
+ print "
\n";
+ }
+
+ if ($soc->error_message)
+ {
+ print '
| '.$langs->trans('Name').' | '.$soc->nom.' | '.$langs->trans('Prefix').' | '.$soc->prefix_comm.' |