Works on alternative addresses management
This commit is contained in:
parent
5fbd8e4cee
commit
6bf5132edb
@ -365,42 +365,6 @@ if ($id > 0)
|
|||||||
print '</tr>';
|
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
|
// Module Adherent
|
||||||
if ($conf->adherent->enabled)
|
if ($conf->adherent->enabled)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -593,6 +593,104 @@ function show_contacts($conf,$langs,$db,$object,$backtopage='')
|
|||||||
return $i;
|
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.'&action=create&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> </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&id='.$address->id.'&socid='.$object->id.'&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
|
* Show html area with actions to do
|
||||||
|
|||||||
@ -38,11 +38,16 @@ class Address
|
|||||||
var $socid;
|
var $socid;
|
||||||
var $name;
|
var $name;
|
||||||
var $address;
|
var $address;
|
||||||
var $cp;
|
var $cp; // deprecated
|
||||||
var $ville;
|
var $zip;
|
||||||
var $pays_id;
|
var $ville; // deprecated
|
||||||
var $pays_code;
|
var $town;
|
||||||
var $tel;
|
var $pays_id; // deprecated
|
||||||
|
var $country_id;
|
||||||
|
var $pays_code; // deprecated
|
||||||
|
var $country_code;
|
||||||
|
var $tel; // deprecated
|
||||||
|
var $phone;
|
||||||
var $fax;
|
var $fax;
|
||||||
var $note;
|
var $note;
|
||||||
|
|
||||||
@ -290,7 +295,7 @@ class Address
|
|||||||
{
|
{
|
||||||
$objp = $this->db->fetch_object($resql);
|
$objp = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$line = new AddressLine();
|
$line = new AddressLine($this->db);
|
||||||
|
|
||||||
$line->id = $objp->id;
|
$line->id = $objp->id;
|
||||||
$line->date_creation = $this->db->jdate($objp->dc);
|
$line->date_creation = $this->db->jdate($objp->dc);
|
||||||
@ -298,36 +303,39 @@ class Address
|
|||||||
$line->label = $objp->label;
|
$line->label = $objp->label;
|
||||||
$line->name = $objp->name;
|
$line->name = $objp->name;
|
||||||
$line->address = $objp->address;
|
$line->address = $objp->address;
|
||||||
$line->cp = $objp->zip;
|
|
||||||
$line->ville = $objp->town;
|
|
||||||
$line->zip = $objp->zip;
|
$line->zip = $objp->zip;
|
||||||
$line->town = $objp->town;
|
$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_id = $objp->country_id;
|
||||||
$line->country_code = $objp->country_id?$objp->country_code:'';
|
$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->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->fax = $objp->fax;
|
||||||
$line->note = $objp->note;
|
$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;
|
$this->lines[$i] = $line;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
return 1;
|
return $num;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_syslog('Address::Fetch Erreur: aucune adresse');
|
dol_syslog('Address::Fetch Erreur: aucune adresse');
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_syslog('Address::Fetch Erreur: societe inconnue');
|
dol_syslog('Address::Fetch Erreur: societe inconnue');
|
||||||
return -2;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -372,22 +380,25 @@ class Address
|
|||||||
$this->label = $obj->label;
|
$this->label = $obj->label;
|
||||||
$this->name = $obj->name;
|
$this->name = $obj->name;
|
||||||
$this->address = $obj->address;
|
$this->address = $obj->address;
|
||||||
$this->cp = $obj->zip;
|
|
||||||
$this->ville = $obj->town;
|
|
||||||
$this->zip = $obj->zip;
|
$this->zip = $obj->zip;
|
||||||
$this->town = $obj->town;
|
$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_id = $obj->country_id;
|
||||||
$this->country_code = $obj->country_id?$obj->country_code:'';
|
$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 = $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->fax = $obj->fax;
|
||||||
$this->note = $obj->note;
|
$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;
|
$result = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -513,7 +524,7 @@ class AddressLine
|
|||||||
*
|
*
|
||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
*/
|
*/
|
||||||
function AddressLine($db)
|
function __construct($db)
|
||||||
{
|
{
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1919,6 +1919,12 @@ else
|
|||||||
$result=show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
|
$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
|
// Projects list
|
||||||
$result=show_projects($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
|
$result=show_projects($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user