diff --git a/htdocs/soc.php b/htdocs/soc.php
index 672b48625d9..b628f5ba78c 100644
--- a/htdocs/soc.php
+++ b/htdocs/soc.php
@@ -33,60 +33,36 @@ if ($user->societe_id > 0)
$socid = $user->societe_id;
}
-if ($action == 'add')
+if ($HTTP_POST_VARS["action"] == 'add' or $HTTP_POST_VARS["action"] == 'update')
{
$soc = new Societe($db);
- $soc->nom = $nom;
-
- $soc->adresse = $adresse;
- $soc->cp = $cp;
- $soc->ville = $ville;
-
- $soc->tel = $tel;
- $soc->fax = $fax;
- $soc->url = ereg_replace( "http://", "", $url );
- $soc->siren = $siren;
-
- $soc->siret = $HTTP_POST_VARS["siret"];
- $soc->ape = $HTTP_POST_VARS["ape"];
- $soc->capital = $HTTP_POST_VARS["capital"];
- $soc->tva_intra = $HTTP_POST_VARS["tva_intra_code"] . $HTTP_POST_VARS["tva_intra_num"];
+ $soc->nom = $HTTP_POST_VARS["nom"];
+ $soc->adresse = $HTTP_POST_VARS["adresse"];
+ $soc->cp = $HTTP_POST_VARS["cp"];
+ $soc->ville = $HTTP_POST_VARS["ville"];
+ $soc->departement_id = $HTTP_POST_VARS["departement_id"];
+ $soc->tel = $HTTP_POST_VARS["tel"];
+ $soc->fax = $HTTP_POST_VARS["fax"];
+ $soc->url = ereg_replace( "http://", "", $HTTP_POST_VARS["url"] );
+ $soc->siren = $HTTP_POST_VARS["siren"];
+ $soc->siret = $HTTP_POST_VARS["siret"];
+ $soc->ape = $HTTP_POST_VARS["ape"];
+ $soc->capital = $HTTP_POST_VARS["capital"];
+ $soc->tva_intra = $HTTP_POST_VARS["tva_intra_code"] . $HTTP_POST_VARS["tva_intra_num"];
$soc->forme_juridique_id = $HTTP_POST_VARS["forme_juridique_id"];
- $soc->effectif_id = $HTTP_POST_VARS["effectif_id"];
+ $soc->effectif_id = $HTTP_POST_VARS["effectif_id"];
+ $soc->client = $HTTP_POST_VARS["client"];
+ $soc->fournisseur = $HTTP_POST_VARS["fournisseur"];
- $soc->client = $client;
- $soc->fournisseur = $fournisseur;
-
- $socid = $soc->create();
-}
-
-if ($action == 'update')
-{
- $soc = new Societe($db);
-
- $soc->nom = $nom;
-
- $soc->adresse = $adresse;
- $soc->cp = $cp;
- $soc->ville = $ville;
-
- $soc->tel = $tel;
- $soc->fax = $fax;
- $soc->url = ereg_replace( "http://", "", $url );
-
- $soc->siren = $HTTP_POST_VARS["siren"];
- $soc->siret = $HTTP_POST_VARS["siret"];
- $soc->ape = $HTTP_POST_VARS["ape"];
- $soc->capital = $HTTP_POST_VARS["capital"];
- $soc->tva_intra = $HTTP_POST_VARS["tva_intra_code"] . $HTTP_POST_VARS["tva_intra_num"];
-
- $soc->forme_juridique_id = $HTTP_POST_VARS["forme_juridique_id"];
- $soc->effectif_id = $HTTP_POST_VARS["effectif_id"];
- $soc->client = $client;
- $soc->fournisseur = $fournisseur;
-
- $soc->update($socid);
+ if ($HTTP_POST_VARS["action"] == 'update')
+ {
+ $soc->update($socid);
+ }
+ if ($HTTP_POST_VARS["action"] == 'add')
+ {
+ $socid = $soc->create();
+ }
}
/*
@@ -94,6 +70,7 @@ if ($action == 'update')
*
*/
llxHeader();
+$form = new Form($db);
if ($action == 'create')
{
@@ -106,8 +83,12 @@ if ($action == 'create')
print '
';
print '| Nom | |
';
print '| Adresse | |
';
- print '| CP | ';
- print 'Ville |
';
+ print '| CP | ';
+ print 'Ville | ';
+
+ print 'Département | ';
+ print $form->select_departement(0);
+ print ' |
';
print '| Téléphone | | ';
print 'Fax | |
';
@@ -122,12 +103,11 @@ if ($action == 'create')
print 'Capital | '.MAIN_MONNAIE.' | ';
print '| Forme juridique | ';
- $html = new Form($db);
- print $html->select_array("forme_juridique_id",$soc->forme_juridique_array(), $soc->forme_juridique, 0, 1);
+ print $form->select_array("forme_juridique_id",$soc->forme_juridique_array(), $soc->forme_juridique, 0, 1);
print ' |
';
print '| Effectif | ';
- print $html->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id);
+ print $form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id);
print ' |
';
print '| Numéro de TVA Intracommunautaire | ';
@@ -165,14 +145,16 @@ elseif ($action == 'edit')
print '';
print ' |