Files
pmgr/views/elements/customers.ctp

64 lines
1.9 KiB
PHP

<?php /* -*- mode:PHP -*- */
if (isset($heading))
echo $heading;
elseif (!isset($caption))
echo '<h2>'.__('Customers',true).'</h2>';
$headers = array_merge(array('Name'),
isset($customers[0]['ContactsCustomer'])
? array('Relationship')
: array(),
array('Comment'));
$column_class = array();
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
$column_class[$k] = 'comment';
}
if (isset($paginator)) {
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
$headers = array_merge(array($paginator->sort('name')),
isset($customers[0]['ContactsCustomer'])
? array($paginator->sort('Relationship', 'type'))
: array(),
array($paginator->sort('comment')));
}
$rows = array();
foreach ($customers as $customer) {
$contacts_customer = null;
if (isset($customer['ContactsCustomer']))
$contacts_customer = $customer['ContactsCustomer'];
if (isset($customer['Customer']))
$customer = $customer['Customer'];
$rows[] = array_merge(array($html->link($customer['name'],
array('controller' => 'customers',
'action' => 'view',
$customer['id']))),
isset($contacts_customer)
? array($contacts_customer['type'])
: array(),
array($customer['comment']));
}
echo $this->element('table',
array('class' => 'item customer list',
'caption' => isset($caption) ? $caption : null,
'headers' => $headers,
'rows' => $rows,
'column_class' => $column_class));
if (isset($paginator)) {
echo('<div class="paging">' . "\n");
echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));
echo(' | ');
echo $paginator->numbers();
echo(' | ');
echo $paginator->next(__('next', true).' >>', array(), null, array('class'=>'disabled'));
echo('</div>' . "\n");
}