git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@217 97e9348a-65ac-dc4b-aefc-98561f571b83
46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|
class ContactPhone extends AppModel {
|
|
|
|
var $validate = array(
|
|
'id' => array('numeric'),
|
|
//'type' => array('inlist'),
|
|
'phone' => array('phone'),
|
|
'ext' => array('numeric')
|
|
);
|
|
|
|
var $hasMany = array(
|
|
'ContactsMethod' => array(
|
|
'foreignKey' => 'method_id',
|
|
'conditions' => "method = 'PHONE'",
|
|
)
|
|
);
|
|
|
|
var $hasAndBelongsToMany = array(
|
|
'Contact' => array(
|
|
'className' => 'Contact',
|
|
'joinTable' => 'contacts_methods',
|
|
'foreignKey' => 'method_id',
|
|
'associationForeignKey' => 'contact_id',
|
|
'unique' => true,
|
|
'conditions' => "method = 'PHONE'",
|
|
)
|
|
);
|
|
|
|
function phoneList() {
|
|
$results = $this->find('all',
|
|
array('contain' => false,
|
|
'fields' => array('id', 'phone', 'ext'),
|
|
'order' => array('phone', 'ext')));
|
|
|
|
App::Import('Helper', 'Format');
|
|
$list = array();
|
|
foreach ($results as $key => $val) {
|
|
$list[$val['ContactPhone']['id']]
|
|
= FormatHelper::phone($val['ContactPhone']['phone'],
|
|
$val['ContactPhone']['ext']);
|
|
}
|
|
return $list;
|
|
}
|
|
|
|
}
|
|
?>
|