git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@217 97e9348a-65ac-dc4b-aefc-98561f571b83
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
class ContactAddress extends AppModel {
|
|
|
|
var $name = 'ContactAddress';
|
|
var $validate = array(
|
|
'id' => array('numeric'),
|
|
'postcode' => array('postal')
|
|
);
|
|
|
|
var $hasMany = array(
|
|
'ContactsMethod' => array(
|
|
'foreignKey' => 'method_id',
|
|
'conditions' => "method = 'ADDRESS'",
|
|
)
|
|
);
|
|
|
|
var $hasAndBelongsToMany = array(
|
|
'Contact' => array(
|
|
'className' => 'Contact',
|
|
'joinTable' => 'contacts_methods',
|
|
'foreignKey' => 'method_id',
|
|
'associationForeignKey' => 'contact_id',
|
|
'unique' => true,
|
|
'conditions' => "method = 'ADDRESS'",
|
|
)
|
|
);
|
|
|
|
function addressList() {
|
|
$results = $this->find('all',
|
|
array('contain' => false,
|
|
'fields' => array('id', 'address', 'city', 'state', 'postcode'),
|
|
'order' => array('state', 'city', 'postcode', 'address')));
|
|
|
|
$list = array();
|
|
foreach ($results as $key => $val) {
|
|
$list[$val['ContactAddress']['id']]
|
|
= preg_replace("/\n/", ", ", $val['ContactAddress']['address'])
|
|
. ', ' . $val['ContactAddress']['city']
|
|
. ', ' . $val['ContactAddress']['state']
|
|
. ' ' . $val['ContactAddress']['postcode']
|
|
;
|
|
}
|
|
return $list;
|
|
}
|
|
}
|
|
?>
|