Works on alternative addresses management

This commit is contained in:
Regis Houssin 2012-03-14 12:14:28 +01:00
parent 5fbd8e4cee
commit 6bf5132edb
5 changed files with 141 additions and 62 deletions

View File

@ -61,7 +61,7 @@ if ($action == 'add' || $action == 'update')
$object->zip = $_POST["zipcode"];
$object->town = $_POST["town"];
$object->pays_id = $_POST["country_id"];
$object->country_id= $_POST["country_id"];
$object->country_id = $_POST["country_id"];
$object->tel = $_POST["tel"];
$object->fax = $_POST["fax"];
$object->note = $_POST["note"];

View File

@ -365,42 +365,6 @@ if ($id > 0)
print '</tr>';
}
// Old way to define delivery address (deprecated).
// Now all addresses types (like delivery addresses, invoices addresses,...) are saved as contacts.
if ($conf->global->PROPALE_ADD_DELIVERY_ADDRESS) // Hidden deprecated feature.
{
print '<tr><td nowrap>';
print '<table width="100%" class="nobordernopadding"><tr><td nowrap>';
print $langs->trans("DeliveriesAddress");
print '<td><td align="right">';
if ($user->rights->societe->creer)
{
print '<a href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'">'.img_edit($langs->trans("Modify")).'</a>';
}
print '</td></tr></table>';
print '</td><td colspan="3">';
// TODO move to DAO class
$sql = "SELECT count(rowid) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."societe_address";
$sql.= " WHERE fk_soc =".$object->id;
$resql = $db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
$objal = $db->fetch_object($resql);
print $objal->nb?($objal->nb):$langs->trans("NoOtherDeliveryAddress");
}
else
{
dol_print_error($db);
}
print '</td>';
print '</tr>';
}
// Module Adherent
if ($conf->adherent->enabled)
{

View File

@ -593,6 +593,104 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
return $i;
}
/**
* Show html area for list of addresses
*
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Database handler
* @param Object $object Third party object
* @param string $backtopage Url to go once address is created
* @return void
*/
function show_addresses($conf,$langs,$db,$object,$backtopage='')
{
global $user;
global $bc;
require_once(DOL_DOCUMENT_ROOT."/societe/class/address.class.php");
$addressstatic = new Address($db);
$num = $addressstatic->fetch_lines($object->id);
$buttoncreate='';
if ($user->rights->societe->creer)
{
$buttoncreate='<a class="addnewrecord" href="'.DOL_URL_ROOT.'/comm/address.php?socid='.$object->id.'&amp;action=create&amp;backtopage='.urlencode($backtopage).'">'.$langs->trans("AddAddress").' '.img_picto($langs->trans("AddAddress"),'filenew').'</a>'."\n";
}
print "\n";
print_fiche_titre($langs->trans("AddressesForCompany"),$buttoncreate,'');
print "\n".'<table class="noborder" width="100%">'."\n";
print '<tr class="liste_titre"><td>'.$langs->trans("Label").'</td>';
print '<td>'.$langs->trans("CompanyName").'</td>';
print '<td>'.$langs->trans("Town").'</td>';
print '<td>'.$langs->trans("Country").'</td>';
print '<td>'.$langs->trans("Tel").'</td>';
print '<td>'.$langs->trans("Fax").'</td>';
//print '<td>'.$langs->trans("EMail").'</td>';
print "<td>&nbsp;</td>";
print "</tr>";
if ($num > 0)
{
$var=true;
foreach ($addressstatic->lines as $address)
{
$var = !$var;
print "<tr ".$bc[$var].">";
print '<td>';
print $address->label;
//print $addressstatic->getNomUrl(1);
print '</td>';
print '<td>'.$address->name.'</td>';
print '<td>'.$address->town.'</td>';
print '<td>'.$address->country.'</td>';
// Lien click to dial
print '<td>';
print dol_print_phone($address->phone,$address->country_code,$address->id,$object->id,'AC_TEL');
print '</td>';
print '<td>';
print dol_print_phone($address->fax,$address->country_code,$address->id,$object->id,'AC_FAX');
print '</td>';
/*
print '<td>';
print dol_print_email($address->email,$address->id,$object->id,'AC_EMAIL');
print '</td>';
*/
if ($user->rights->societe->creer)
{
print '<td align="right">';
print '<a href="'.DOL_URL_ROOT.'/comm/address.php?action=edit&amp;id='.$address->id.'&amp;socid='.$object->id.'&amp;backtopage='.urlencode($backtopage).'">';
print img_edit();
print '</a></td>';
}
print "</tr>\n";
}
}
else
{
//print "<tr ".$bc[$var].">";
//print '<td>'.$langs->trans("NoAddressYetDefined").'</td>';
//print "</tr>\n";
}
print "\n</table>\n";
print "<br>\n";
return $num;
}
/**
* Show html area with actions to do

View File

@ -38,11 +38,16 @@ class Address
var $socid;
var $name;
var $address;
var $cp;
var $ville;
var $pays_id;
var $pays_code;
var $tel;
var $cp; // deprecated
var $zip;
var $ville; // deprecated
var $town;
var $pays_id; // deprecated
var $country_id;
var $pays_code; // deprecated
var $country_code;
var $tel; // deprecated
var $phone;
var $fax;
var $note;
@ -290,7 +295,7 @@ class Address
{
$objp = $this->db->fetch_object($resql);
$line = new AddressLine();
$line = new AddressLine($this->db);
$line->id = $objp->id;
$line->date_creation = $this->db->jdate($objp->dc);
@ -298,36 +303,39 @@ class Address
$line->label = $objp->label;
$line->name = $objp->name;
$line->address = $objp->address;
$line->cp = $objp->zip;
$line->ville = $objp->town;
$line->zip = $objp->zip;
$line->town = $objp->town;
$line->pays_id = $objp->country_id;
$line->pays_code = $objp->country_id?$objp->country_code:'';
$line->pays = $objp->country_id?($langs->trans('Country'.$objp->country_code)!='Country'.$objp->country_code?strtoupper($langs->trans('Country'.$objp->country_code)):$objp->country):'';
$line->country_id = $objp->country_id;
$line->country_code = $objp->country_id?$objp->country_code:'';
$line->country = $objp->country_id?($langs->trans('Country'.$objp->country_code)!='Country'.$objp->country_code?strtoupper($langs->trans('Country'.$objp->country_code)):$objp->country):'';
$line->tel = $objp->tel;
$line->phone = $objp->tel;
$line->fax = $objp->fax;
$line->note = $objp->note;
// deprecated
$line->cp = $line->zip;
$line->ville = $line->town;
$line->pays_id = $line->country_id;
$line->pays_code = $line->country_code;
$line->pays = $line->country;
$line->tel = $line->phone;
$this->lines[$i] = $line;
$i++;
}
$this->db->free($resql);
return 1;
return $num;
}
else
{
dol_syslog('Address::Fetch Erreur: aucune adresse');
return -1;
return 0;
}
}
else
{
dol_syslog('Address::Fetch Erreur: societe inconnue');
return -2;
return -1;
}
}
else
@ -372,21 +380,24 @@ class Address
$this->label = $obj->label;
$this->name = $obj->name;
$this->address = $obj->address;
$this->cp = $obj->zip;
$this->ville = $obj->town;
$this->zip = $obj->zip;
$this->town = $obj->town;
$this->pays_id = $obj->country_id;
$this->pays_code = $obj->country_id?$obj->country_code:'';
$this->pays = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->trans('Country'.$obj->country_code):$obj->country):'';
$this->country_id = $obj->country_id;
$this->country_code = $obj->country_id?$obj->country_code:'';
$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->trans('Country'.$obj->country_code):$obj->country):'';
$this->country_id = $obj->country_id;
$this->country_code = $obj->country_id?$obj->country_code:'';
$this->country = $obj->country_id?($langs->trans('Country'.$obj->country_code)!='Country'.$obj->country_code?$langs->trans('Country'.$obj->country_code):$obj->country):'';
$this->tel = $obj->tel;
$this->phone = $obj->tel;
$this->fax = $obj->fax;
$this->note = $obj->note;
// deprecated
$line->cp = $line->zip;
$line->ville = $line->town;
$line->pays_id = $line->country_id;
$line->pays_code = $line->country_code;
$line->pays = $line->country;
$line->tel = $line->phone;
$result = 1;
}
@ -513,7 +524,7 @@ class AddressLine
*
* @param DoliDB $db Database handler
*/
function AddressLine($db)
function __construct($db)
{
$this->db = $db;
}

View File

@ -1918,6 +1918,12 @@ else
{
$result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
}
// Addresses list
if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT))
{
$result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
}
// Projects list
$result=show_projects($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);