diff --git a/htdocs/soc.php b/htdocs/soc.php index 1668b0eae82..be39e912813 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -27,15 +27,14 @@ require("pre.inc.php"); $langs->load("soc"); - /* * Sécurité accés client */ if ($user->societe_id > 0) { - $_POST["action"] = ''; $_GET["action"] = ''; - $socid = $user->societe_id; + $_POST["action"] = ''; + $_GET["socid"] = $user->societe_id; } if ($_POST["action"] == 'add' or $_POST["action"] == 'update') @@ -60,6 +59,179 @@ if ($_POST["action"] == 'add' or $_POST["action"] == 'update') $soc->client = $_POST["client"]; $soc->fournisseur = $_POST["fournisseur"]; + if ($_POST["action"] == 'update') + { + $soc->update($socid); + } + if ($_POST["action"] == 'add') + { + $socid = $soc->create(); + Header("Location: soc.php?socid=$socid"); + } +} + +/* + * + * + */ +llxHeader(); +$form = new Form($db); + +if ($_GET["action"] == 'create') +{ + if ($user->rights->societe->creer) { + /* + * Fiche societe en mode création + */ + $soc = new Societe($db); + if ($_GET["type"]=='f') { $soc->fournisseur=1; } + if ($_GET["type"]=='c') { $soc->client=1; } + if ($_GET["type"]=='p') { $soc->client=2; } + + print '