Added query ability to the customer grid. There is a bug with the paging code, but it roughly works.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@109 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-13 21:20:11 +00:00
parent 0278c77610
commit 3be775f9b2
2 changed files with 30 additions and 0 deletions

View File

@@ -98,6 +98,24 @@ class AppController extends Controller {
else
$fields = array($model_id);
if (isset($_search) && $_search === 'true') {
$ops = array('eq' => array('op' => null, 'pre' => '', 'post' => ''),
'ne' => array('op' => '<>', 'pre' => '', 'post' => ''),
'lt' => array('op' => '<', 'pre' => '', 'post' => ''),
'le' => array('op' => '<=', 'pre' => '', 'post' => ''),
'gt' => array('op' => '>', 'pre' => '', 'post' => ''),
'ge' => array('op' => '>=', 'pre' => '', 'post' => ''),
'bw' => array('op' => 'LIKE', 'pre' => '', 'post' => '%'),
'ew' => array('op' => 'LIKE', 'pre' => '%', 'post' => ''),
'cn' => array('op' => 'LIKE', 'pre' => '%', 'post' => '%'),
);
$op = $ops[$searchOper];
$field = $searchField . ($op['op'] ? ' '.$op['op'] : '');
$val = $op['pre'] . $searchString . $op['post'];
$query['conditions'][] = array($field => $val);
}
// Verify a few parameters and determine our starting row
$total = ($records < 0) ? 0 : ceil($records/$rows);
$page = ($page < 1) ? 1 : (($page > $total) ? $total : $page);
@@ -119,6 +137,8 @@ class AppController extends Controller {
echo "<?xml version='1.0' encoding='utf-8'?>\n";
echo "<rows>\n";
/* echo " <req><![CDATA[\n" . print_r($this->params['url'], true) . "\n]]></req>\n"; */
/* echo " <query><![CDATA[\n" . print_r($query, true) . "\n]]></query>\n"; */
echo " <page>$page</page>\n";
echo " <total>$total</total>\n";
echo " <records>$records</records>\n";

View File

@@ -99,6 +99,16 @@ jQuery(document).ready(function(){
<div id="customer-pager" class="scroll" style="text-align:center;"></div>
</div>
<input type="BUTTON" id="bsdata" value="Search" />
<script type="text/javascript"><!--
$("#bsdata").click(function(){
jQuery("#customer-list").searchGrid(
{sopt:['cn','bw','eq','ne','lt','gt','ew']}
);
});
--></script>
<?php
/* <div><a href="#" onClick="$('#debug').html(htmlEncode($('#everything').html())); return false;">Get Table Code</a></div> */
/* <div id="debug"></div> */