Added jqGrid 3.4.4 and started the work to upgrade our table to use it. The work is by no means done, but it is at leasting working to some degree. I have some customer changes in mind and want to switch gears, so I'm checking in.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@103 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-13 03:51:29 +00:00
parent e32a5e5d4c
commit 2f91dd456a
291 changed files with 11977 additions and 52 deletions

View File

@@ -1,63 +1,175 @@
<?php /* -*- mode:PHP -*- */
if (isset($heading))
echo $heading;
elseif (!isset($caption))
echo '<h2>'.__('Customers',true).'</h2>';
//$imgpath = 'jqGrid/basic/images';
$imgpath = '/pmgr/site/css/jqGrid/basic/images';
$html->css('jqGrid/basic/grid', null, null, false);
$html->css('jqGrid/jqModal', null, null, false);
$javascript->link('jqGrid/jquery.jqGrid.js', false);
$javascript->link('jqGrid/js/jqModal', false);
$javascript->link('jqGrid/js/jqDnR', false);
$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';
/* //echo $html->css('jquery/start/ui.all') . "\n"; */
/* echo $javascript->link('jquery/jquery') . "\n"; */
/* //echo $javascript->link('jquery/jquery-ui') . "\n"; */
/* //echo $javascript->link('jquery.form') . "\n"; */
/* echo $javascript->link('pmgr') . "\n"; */
/* echo $html->css('jqGrid/basic/grid') . "\n"; */
/* //echo $html->css('jqGrid/jqModal') . "\n"; */
/* echo $javascript->link('jqGrid/jquery.jqGrid.js') . "\n"; */
/* //echo $javascript->link('jqGrid/js/jqModal') . "\n"; */
/* //echo $javascript->link('jqGrid/js/jqDnR') . "\n"; */
$cols = array();
$cols['ID'] = array('index' => 'Customer.id', 'width' => '50', 'align' => 'center');
/* $cols['Last Name'] = array('index' => 'Customer.last_name', 'width' => '200', 'align' => 'left'); */
/* $cols['First Name'] = array('index' => 'Customer.first_name', 'width' => '200', 'align' => 'left'); */
$cols['Name'] = array('index' => 'Customer.name', 'width' => '200', 'align' => 'left');
$cols['Unit'] = array('index' => 'Customer.units', 'width' => '200', 'align' => 'left', 'sortable' => false);
$colModels = array();
foreach ($cols AS $col) {
$col['name'] = $col['index'];
$colModels[] =
'{ ' . implode(", ",
array_map(create_function
('$k, $v',
'return "$k:".($v===false?"false":"\'$v\'");'),
array_keys($col),
array_values($col))) .
'}';
}
if (isset($paginator)) {
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records (%start% - %end%) of %count% total', true)));
// URL to fetch data from.
// To prevent having to keep the controller and the view
// in sync on which fields need to be queried by the
// controller in order to be accessible to the view,
// we'll just pass the desired fields to the controller
// as part of the data fetch.
$url = $html->url(array('controller' => 'customers',
'action' => 'data',
'debug' => 0,
implode(";",
array_map(create_function
('$col',
'return $col["index"];'),
$cols)),
));
$headers = array_merge(array($paginator->sort('name')),
isset($customers[0]['ContactsCustomer'])
? array($paginator->sort('Relationship', 'type'))
: array(),
array($paginator->sort('comment')));
/* array_merge(array('Name'), */
/* isset($customers[0]['ContactsCustomer']) */
/* ? array('Relationship') */
/* : array(), */
/* array('Comment')); */
/* $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'])); */
?>
<script type="text/javascript"><!--
jQuery(document).ready(function(){
// return;
jQuery("#customer-list").jqGrid({
url: '<?php echo $url; ?>',
datatype: 'xml',
mtype: 'GET',
colNames:[ '<?php echo implode("', '", array_keys($cols)); ?>' ],
colModel :[ <?php echo "\n " . implode(",\n ", $colModels); ?> ],
pager: jQuery('#customer-pager'),
rowNum:10,
rowList:[10,20,30],
sortname: 'Customer.id',
sortorder: "ASC",
viewrecords: true,
imgpath: '<?php echo $imgpath; ?>',
caption: 'My first grid'
});
});
function getText() {
$("#debug").html(htmlEncode($("#customer-list").html()));
}
$rows = array();
foreach ($customers as $customer) {
$contacts_customer = null;
if (isset($customer['ContactsCustomer']))
$contacts_customer = $customer['ContactsCustomer'];
--></script>
if (isset($customer['Customer']))
$customer = $customer['Customer'];
<table id="customer-list" class="scroll"></table>
<div id="customer-pager" class="scroll" style="text-align:center;"></div>
<div><a href="#" onClick="getText(); return false;">Get Table Code</a>
</div>
<div id="debug"></div>
$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']));
}
<?php
echo $this->element('table',
array('class' => 'item customer list',
'caption' => isset($caption) ? $caption : null,
'headers' => $headers,
'rows' => $rows,
'column_class' => $column_class));
/* if (isset($heading)) */
/* echo $heading; */
/* elseif (!isset($caption)) */
/* echo '<h2>'.__('Customers',true).'</h2>'; */
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");
}
/* $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"); */
/* } */