- if (count($this->orig) > 0) {
- $this->values = $this->orig;
- return;
- }
- // Build the addresses tree
- $res = XDB::query("SELECT a.adrid AS id, a.adr1, a.adr2, a.adr3,
- a.postcode, a.city, a.cityid, a.region, a.regiontxt,
- a.fax, a.glat, a.glng, a.datemaj, a.pub,
- a.country, gp.pays AS countrytxt, gp.display,
- FIND_IN_SET('res-secondaire', a.statut) AS secondaire,
- FIND_IN_SET('courrier', a.statut) AS mail,
- FIND_IN_SET('temporary', a.statut) AS temporary,
- FIND_IN_SET('active', a.statut) AS current
- FROM adresses AS a
- INNER JOIN geoloc_pays AS gp ON(gp.a2 = a.country)
- WHERE uid = {?} AND NOT FIND_IN_SET('pro', statut)
- ORDER BY adrid",
- S::i('uid'));
- $this->values['addresses'] = $res->fetchAllAssoc();
-
- $res = XDB::iterator("SELECT adrid, tel_type AS type, tel_pub AS pub, tel
- FROM tels
- WHERE uid = {?}
- ORDER BY adrid",
- S::i('uid'));
- $i = 0;
- while ($tel = $res->next()) {
- $adrid = $tel['adrid'];
- unset($tel['adrid']);
- while ($this->values['addresses'][$i]['id'] < $adrid) {
- $i++;
- }
- $address =& $this->values['addresses'][$i];
- if (!isset($address['tel'])) {
- $address['tel'] = array();
- }
- if ($address['id'] == $adrid) {
- $address['tel'][] = $tel;
- }
- }
- foreach ($this->values['addresses'] as $id=>&$address) {
- unset($address['id']);
- }
- parent::fetchData();