diff --git a/htdocs/comm/address.php b/htdocs/comm/address.php
index ce06caced86..b85da09d0ed 100644
--- a/htdocs/comm/address.php
+++ b/htdocs/comm/address.php
@@ -20,7 +20,7 @@
/**
* \file htdocs/comm/address.php
* \ingroup societe
- * \brief Tab address of customer
+ * \brief Tab address of thirdparty
*/
require("../main.inc.php");
@@ -33,6 +33,7 @@ $langs->load("commercial");
$id = GETPOST('id','int');
$action = GETPOST('action','alpha');
+$confirm = GETPOST('confirm','alpha');
$origin = GETPOST('origin','alpha');
$originid = GETPOST('originid','int');
$socid = GETPOST('socid','int');
@@ -42,6 +43,8 @@ if (! $socid && ($action != 'create' && $action != 'add' && $action != 'update')
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'societe', $socid);
+$object = new Address($db);
+
/*
* Actions
@@ -49,28 +52,24 @@ $result = restrictedArea($user, 'societe', $socid);
if ($action == 'add' || $action == 'update')
{
- $address = new Address($db);
-
- $address->socid = $socid;
- $address->label = ($_POST["label"]!=$langs->trans('RequiredField')?$_POST["label"]:'');
- $address->name = ($_POST["name"]!=$langs->trans('RequiredField')?$_POST["name"]:'');
- $address->address = $_POST["address"];
- $address->cp = $_POST["zipcode"];
- $address->ville = $_POST["town"];
- $address->zip = $_POST["zipcode"];
- $address->town = $_POST["town"];
- $address->pays_id = $_POST["country_id"];
- $address->country_id= $_POST["country_id"];
- $address->tel = $_POST["tel"];
- $address->fax = $_POST["fax"];
- $address->note = $_POST["note"];
-
+ $object->socid = $socid;
+ $object->label = ($_POST["label"]!=$langs->trans('RequiredField')?$_POST["label"]:'');
+ $object->name = ($_POST["name"]!=$langs->trans('RequiredField')?$_POST["name"]:'');
+ $object->address = $_POST["address"];
+ $object->cp = $_POST["zipcode"];
+ $object->ville = $_POST["town"];
+ $object->zip = $_POST["zipcode"];
+ $object->town = $_POST["town"];
+ $object->pays_id = $_POST["country_id"];
+ $object->country_id= $_POST["country_id"];
+ $object->tel = $_POST["tel"];
+ $object->fax = $_POST["fax"];
+ $object->note = $_POST["note"];
+
+ // Add new address
if ($action == 'add')
{
- $socid = $socid;
- $origin = $origin;
- $originid = $originid;
- $result = $address->create($socid, $user);
+ $result = $object->create($socid, $user);
if ($result >= 0)
{
@@ -97,17 +96,15 @@ if ($action == 'add' || $action == 'update')
}
else
{
- $mesg = $address->error;
+ $mesg = $object->error;
$action='create';
}
}
-
- if ($action == 'update')
+
+ // Update address
+ else if ($action == 'update')
{
- $socid = $_POST["socid"];
- $origin = $_POST["origin"];
- $originid = $_POST["originid"];
- $result = $address->update($_POST["id"], $socid, $user);
+ $result = $object->update($_POST["id"], $socid, $user);
if ($result >= 0)
{
@@ -135,17 +132,16 @@ if ($action == 'add' || $action == 'update')
else
{
$reload = 0;
- $mesg = $address->error;
+ $mesg = $object->error;
$actino= "edit";
}
}
}
-if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer)
+else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->supprimer)
{
- $address = new Address($db);
- $result = $address->delete($id, $socid);
+ $result = $object->delete($id, $socid);
if ($result == 0)
{
@@ -155,7 +151,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->societe->
else
{
$reload = 0;
- $_GET["action"]='';
+ $action='';
}
}
@@ -181,8 +177,6 @@ if ($action == 'create')
* Creation
*/
- $address = new Address($db);
-
$societe=new Societe($db);
$societe->fetch($socid);
$head = societe_prepare_head($societe);
@@ -191,35 +185,35 @@ if ($action == 'create')
if ($_POST["label"] && $_POST["name"])
{
- $address->socid = $_POST["socid"];
- $address->label = $_POST["label"];
- $address->name = $_POST["name"];
- $address->address = $_POST["address"];
- $address->cp = $_POST["zipcode"];
- $address->ville = $_POST["town"];
- $address->tel = $_POST["tel"];
- $address->fax = $_POST["fax"];
- $address->note = $_POST["note"];
+ $object->socid = $socid;
+ $object->label = $_POST["label"];
+ $object->name = $_POST["name"];
+ $object->address = $_POST["address"];
+ $object->cp = $_POST["zipcode"];
+ $object->ville = $_POST["town"];
+ $object->tel = $_POST["tel"];
+ $object->fax = $_POST["fax"];
+ $object->note = $_POST["note"];
}
// On positionne pays_id, pays_code et libelle du pays choisi
- $address->country_id=$_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
- if ($address->country_id)
+ $object->country_id=$_POST["country_id"]?$_POST["country_id"]:$mysoc->country_id;
+ if ($object->country_id)
{
- $tmparray=getCountry($address->country_id,'all');
- $address->pays_code = $tmparray['code'];
- $address->pays = $tmparray['label'];
- $address->country_code = $tmparray['code'];
- $address->country = $tmparray['label'];
+ $tmparray=getCountry($object->country_id,'all');
+ $object->pays_code = $tmparray['code'];
+ $object->pays = $tmparray['label'];
+ $object->country_code = $tmparray['code'];
+ $object->country = $tmparray['label'];
}
print_titre($langs->trans("AddAddress"));
print "
\n";
- if ($address->error)
+ if ($object->error)
{
print '
| '.$langs->trans('Label').' | |||
| '.$langs->trans('Name').' | |||
| '.$langs->trans('Label').' | |||
| '.$langs->trans('Name').' | |||
| '.$langs->trans('Address').' | |||
| '.$langs->trans('Zip').' | '; - print $formcompany->select_ziptown($address->cp,'zipcode',array('town','selectcountry_id'),6); + print $formcompany->select_ziptown($object->cp,'zipcode',array('town','selectcountry_id'),6); print ' | ||
| '.$langs->trans('Town').' | '; - print $formcompany->select_ziptown($address->ville,'town',array('zipcode','selectcountry_id')); + print $formcompany->select_ziptown($object->ville,'town',array('zipcode','selectcountry_id')); print ' | ||
| '.$langs->trans('Country').' | '; - print $form->select_country($address->country_id,'selectcountry_id'); + print $form->select_country($object->country_id,'selectcountry_id'); print ' | ||
| '.$langs->trans('Phone').' | |||
| '.$langs->trans('Phone').' | |||
| '.$langs->trans('Fax').' | |||
| '.$langs->trans('Fax').' | |||
| '.$langs->trans('Note').' | |||