Added phone and address models as well as outputing them to the view.
git-svn-id: file:///svn-source/pmgr/branches/initial_20090526/site@16 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -25,6 +25,36 @@ class Contact extends AppModel {
|
|||||||
'deleteQuery' => '',
|
'deleteQuery' => '',
|
||||||
'insertQuery' => ''
|
'insertQuery' => ''
|
||||||
),
|
),
|
||||||
|
'ContactAddress' => array(
|
||||||
|
'className' => 'ContactAddress',
|
||||||
|
'joinTable' => 'contacts_methods',
|
||||||
|
'foreignKey' => 'contact_id',
|
||||||
|
'associationForeignKey' => 'method_id',
|
||||||
|
'unique' => true,
|
||||||
|
'conditions' => "ContactsMethod.method = 'POST'",
|
||||||
|
'fields' => '',
|
||||||
|
'order' => '',
|
||||||
|
'limit' => '',
|
||||||
|
'offset' => '',
|
||||||
|
'finderQuery' => '',
|
||||||
|
'deleteQuery' => '',
|
||||||
|
'insertQuery' => ''
|
||||||
|
),
|
||||||
|
'ContactPhone' => array(
|
||||||
|
'className' => 'ContactPhone',
|
||||||
|
'joinTable' => 'contacts_methods',
|
||||||
|
'foreignKey' => 'contact_id',
|
||||||
|
'associationForeignKey' => 'method_id',
|
||||||
|
'unique' => true,
|
||||||
|
'conditions' => "ContactsMethod.method = 'PHONE'",
|
||||||
|
'fields' => '',
|
||||||
|
'order' => '',
|
||||||
|
'limit' => '',
|
||||||
|
'offset' => '',
|
||||||
|
'finderQuery' => '',
|
||||||
|
'deleteQuery' => '',
|
||||||
|
'insertQuery' => ''
|
||||||
|
),
|
||||||
'ContactEmail' => array(
|
'ContactEmail' => array(
|
||||||
'className' => 'ContactEmail',
|
'className' => 'ContactEmail',
|
||||||
'joinTable' => 'contacts_methods',
|
'joinTable' => 'contacts_methods',
|
||||||
@@ -39,7 +69,7 @@ class Contact extends AppModel {
|
|||||||
'finderQuery' => '',
|
'finderQuery' => '',
|
||||||
'deleteQuery' => '',
|
'deleteQuery' => '',
|
||||||
'insertQuery' => ''
|
'insertQuery' => ''
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
28
models/contact_address.php
Normal file
28
models/contact_address.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
class ContactAddress extends AppModel {
|
||||||
|
|
||||||
|
var $name = 'ContactAddress';
|
||||||
|
var $validate = array(
|
||||||
|
'id' => array('numeric'),
|
||||||
|
'postcode' => array('postal')
|
||||||
|
);
|
||||||
|
|
||||||
|
var $hasAndBelongsToMany = array(
|
||||||
|
'Contact' => array(
|
||||||
|
'className' => 'Contact',
|
||||||
|
'joinTable' => 'contacts_methods',
|
||||||
|
'foreignKey' => 'method_id',
|
||||||
|
'associationForeignKey' => 'contact_id',
|
||||||
|
'unique' => true,
|
||||||
|
'conditions' => "ContactsMethod.method = 'POST'",
|
||||||
|
'fields' => '',
|
||||||
|
'order' => '',
|
||||||
|
'limit' => '',
|
||||||
|
'offset' => '',
|
||||||
|
'finderQuery' => '',
|
||||||
|
'deleteQuery' => '',
|
||||||
|
'insertQuery' => ''
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -7,7 +7,6 @@ class ContactEmail extends AppModel {
|
|||||||
'email' => array('email')
|
'email' => array('email')
|
||||||
);
|
);
|
||||||
|
|
||||||
//The Associations below have been created with all possible keys, those that are not needed can be removed
|
|
||||||
var $hasAndBelongsToMany = array(
|
var $hasAndBelongsToMany = array(
|
||||||
'Contact' => array(
|
'Contact' => array(
|
||||||
'className' => 'Contact',
|
'className' => 'Contact',
|
||||||
|
|||||||
31
models/contact_phone.php
Normal file
31
models/contact_phone.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
class ContactPhone extends AppModel {
|
||||||
|
|
||||||
|
var $name = 'ContactPhone';
|
||||||
|
var $validate = array(
|
||||||
|
'id' => array('numeric'),
|
||||||
|
//'type' => array('inlist'),
|
||||||
|
'phone' => array('phone'),
|
||||||
|
'ext' => array('numeric')
|
||||||
|
);
|
||||||
|
|
||||||
|
var $hasAndBelongsToMany = array(
|
||||||
|
'Contact' => array(
|
||||||
|
'className' => 'Contact',
|
||||||
|
'joinTable' => 'contacts_methods',
|
||||||
|
'foreignKey' => 'method_id',
|
||||||
|
'associationForeignKey' => 'contact_id',
|
||||||
|
'unique' => true,
|
||||||
|
'conditions' => "ContactsMethod.method = 'PHONE'",
|
||||||
|
'fields' => '',
|
||||||
|
'order' => '',
|
||||||
|
'limit' => '',
|
||||||
|
'offset' => '',
|
||||||
|
'finderQuery' => '',
|
||||||
|
'deleteQuery' => '',
|
||||||
|
'insertQuery' => ''
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
?>
|
||||||
@@ -5,23 +5,117 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
$date_fmt = 'm/d/Y';
|
||||||
function currency($number) {
|
function currency($number) {
|
||||||
if ($number < 0) {
|
if ($number < 0)
|
||||||
return "($ " . number_format(-1*$number, 2) . ")";
|
return "($ " . number_format(-1*$number, 2) . ")";
|
||||||
} else {
|
else
|
||||||
return "$ " . number_format($number, 2);
|
return "$ " . number_format($number, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function phone($phone) {
|
||||||
|
$phone = preg_replace("/\D/", "", $phone);
|
||||||
|
if(strlen($phone) == 7)
|
||||||
|
return preg_replace("/(\d{3})(\d{4})/", "$1-$2", $phone);
|
||||||
|
elseif(strlen($phone) == 10)
|
||||||
|
return preg_replace("/(\d{3})(\d{3})(\d{4})/", "$1-$2-$3", $phone);
|
||||||
|
else
|
||||||
|
return $phone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Tenant Info
|
||||||
|
*/
|
||||||
$rows = array();
|
$rows = array();
|
||||||
foreach($tenant['Contact'] AS $col => $val) {
|
foreach($tenant['Contact'] AS $col => $val) {
|
||||||
$rows[] = array(array($col, 'width=1%'), $val);
|
$rows[] = array(array($col, 'width=1%'), $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo('<table cellpadding="0" cellspacing="0">' . "\n");
|
echo('<table cellpadding="0" cellspacing="0">' . "\n");
|
||||||
echo(' <CAPTION>Tenant Info</CAPTION>' . "\n");
|
echo(' <CAPTION>Tenant Info</CAPTION>' . "\n");
|
||||||
echo $html->tableCells($rows, null, array('class' => "altrow"));
|
echo $html->tableCells(array(array('Name', $tenant['Contact']['display_name']),
|
||||||
|
array('Company', $tenant['Contact']['company_name']),
|
||||||
|
array('SSN', $tenant['Contact']['id_federal']),
|
||||||
|
array('ID', $tenant['Contact']['id_num']
|
||||||
|
. ($tenant['Contact']['id_state']
|
||||||
|
? " - ".$tenant['Contact']['id_state']
|
||||||
|
: ""))),
|
||||||
|
null, array('class' => "altrow"), false, false);
|
||||||
echo('</table>' . "\n");
|
echo('</table>' . "\n");
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Phones
|
||||||
|
*/
|
||||||
|
$headers = array('Location', 'Preference', 'Type', 'Phone', 'Extension', 'Comment');
|
||||||
|
$rows = array();
|
||||||
|
foreach($tenant['ContactPhone'] AS $phone) {
|
||||||
|
$rows[] = array($phone['ContactsMethod']['type'],
|
||||||
|
$phone['ContactsMethod']['preference'],
|
||||||
|
$phone['type'],
|
||||||
|
phone($phone['phone']),
|
||||||
|
$phone['ext'],
|
||||||
|
$phone['comment']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($rows)) {
|
||||||
|
echo('<table cellpadding="0" cellspacing="0">' . "\n");
|
||||||
|
echo(' <CAPTION>Phone</CAPTION>' . "\n");
|
||||||
|
echo $html->tableHeaders($headers);
|
||||||
|
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
|
||||||
|
echo('</table>' . "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Emails
|
||||||
|
*/
|
||||||
|
$headers = array('Location', 'Preference', 'Email', 'Comment');
|
||||||
|
$rows = array();
|
||||||
|
foreach($tenant['ContactEmail'] AS $email) {
|
||||||
|
$rows[] = array($email['ContactsMethod']['type'],
|
||||||
|
$email['ContactsMethod']['preference'],
|
||||||
|
$email['email'],
|
||||||
|
$email['comment']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($rows)) {
|
||||||
|
echo('<table cellpadding="0" cellspacing="0">' . "\n");
|
||||||
|
echo(' <CAPTION>Email</CAPTION>' . "\n");
|
||||||
|
echo $html->tableHeaders($headers);
|
||||||
|
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
|
||||||
|
echo('</table>' . "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Addresses
|
||||||
|
*/
|
||||||
|
$headers = array('Location', 'Preference', 'Address', 'City', 'State', 'Zip', 'Country', 'Comment');
|
||||||
|
$rows = array();
|
||||||
|
foreach($tenant['ContactAddress'] AS $address) {
|
||||||
|
$rows[] = array($address['ContactsMethod']['type'],
|
||||||
|
$address['ContactsMethod']['preference'],
|
||||||
|
$address['address'],
|
||||||
|
$address['city'],
|
||||||
|
$address['state'],
|
||||||
|
$address['postcode'],
|
||||||
|
$address['country'],
|
||||||
|
$address['comment']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($rows)) {
|
||||||
|
echo('<table cellpadding="0" cellspacing="0">' . "\n");
|
||||||
|
echo(' <CAPTION>Address</CAPTION>' . "\n");
|
||||||
|
echo $html->tableHeaders($headers);
|
||||||
|
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
|
||||||
|
echo('</table>' . "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Ledger History
|
||||||
|
*/
|
||||||
$grand_total = 0;
|
$grand_total = 0;
|
||||||
foreach($tenant['Lease'] AS $lease) {
|
foreach($tenant['Lease'] AS $lease) {
|
||||||
$headers = array('Date', /*'Through',*/ /*'Charge/Receipt'*/'ID', 'Type', 'Comment', 'Amount', 'Total');
|
$headers = array('Date', /*'Through',*/ /*'Charge/Receipt'*/'ID', 'Type', 'Comment', 'Amount', 'Total');
|
||||||
@@ -31,8 +125,8 @@ foreach($tenant['Lease'] AS $lease) {
|
|||||||
foreach($lease['Charge'] AS $charge) {
|
foreach($lease['Charge'] AS $charge) {
|
||||||
$amount = $charge['total'];
|
$amount = $charge['total'];
|
||||||
$running_total += $amount;
|
$running_total += $amount;
|
||||||
$rows[] = array(date_format(date_create($charge['charge_date']), 'm-d-Y') . ' - ' .
|
$rows[] = array(date_format(date_create($charge['charge_date']), $date_fmt) . ' - ' .
|
||||||
date_format(date_create($charge['charge_to_date']), 'm-d-Y'),
|
date_format(date_create($charge['charge_to_date']), $date_fmt),
|
||||||
'#'.$charge['id'],
|
'#'.$charge['id'],
|
||||||
$charge['ChargeType']['name'],
|
$charge['ChargeType']['name'],
|
||||||
$charge['comment'],
|
$charge['comment'],
|
||||||
@@ -42,10 +136,10 @@ foreach($tenant['Lease'] AS $lease) {
|
|||||||
foreach ($charge['Receipt'] AS $receipt) {
|
foreach ($charge['Receipt'] AS $receipt) {
|
||||||
$amount = -1 * $receipt['ChargesReceipt']['amount'];
|
$amount = -1 * $receipt['ChargesReceipt']['amount'];
|
||||||
$running_total += $amount;
|
$running_total += $amount;
|
||||||
$rows[] = array(' -- ' .date_format(date_create($receipt['stamp']), 'm-d-Y'),
|
$rows[] = array(' -- ' .date_format(date_create($receipt['stamp']), $date_fmt),
|
||||||
//null,
|
//null,
|
||||||
'#'.$receipt['id'],
|
'#'.$receipt['id'],
|
||||||
'Receipt',
|
'Payment/Receipt',
|
||||||
$receipt['comment'],
|
$receipt['comment'],
|
||||||
currency($amount),
|
currency($amount),
|
||||||
currency($running_total));
|
currency($running_total));
|
||||||
@@ -56,11 +150,11 @@ foreach($tenant['Lease'] AS $lease) {
|
|||||||
echo('<table cellpadding="0" cellspacing="0">' . "\n");
|
echo('<table cellpadding="0" cellspacing="0">' . "\n");
|
||||||
echo(' <CAPTION>Lease #'.$lease['number'].' (Unit '.$lease['Unit']['name'].')</CAPTION>' . "\n");
|
echo(' <CAPTION>Lease #'.$lease['number'].' (Unit '.$lease['Unit']['name'].')</CAPTION>' . "\n");
|
||||||
echo $html->tableHeaders($headers);
|
echo $html->tableHeaders($headers);
|
||||||
echo $html->tableCells($rows, null, array('class' => "altrow"));
|
echo $html->tableCells($rows, null, array('class' => "altrow"), false, false);
|
||||||
echo('</table>' . "\n");
|
echo('</table>' . "\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<DIV ALIGN=RIGHT><H3>Grand Total: <?php echo currency($grand_total); ?></H3></DIV>
|
<DIV ALIGN=RIGHT><H3>Outstanding Balance: <?php echo currency($grand_total); ?></H3></DIV>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user