Added User Statement information
This commit is contained in:
parent
35543dd4a9
commit
c55a8fe4cc
@ -25,81 +25,77 @@ class lnApp_Sort {
|
|||||||
if (! $data)
|
if (! $data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static $MASORT_CACHE = array();
|
$code = "\$c=0;\n";
|
||||||
|
|
||||||
if (empty($MASORT_CACHE[$sortby])) {
|
foreach (explode(',',$sortby) as $key) {
|
||||||
$code = "\$c=0;\n";
|
$code .= "if (is_object(\$a) || is_object(\$b)) {\n";
|
||||||
|
|
||||||
foreach (explode(',',$sortby) as $key) {
|
$code .= " if (is_array(\$a->$key)) {\n";
|
||||||
$code .= "if (is_object(\$a) || is_object(\$b)) {\n";
|
$code .= " asort(\$a->$key);\n";
|
||||||
|
$code .= " \$aa = array_shift(\$a->$key);\n";
|
||||||
$code .= " if (is_array(\$a->$key)) {\n";
|
$code .= " } else\n";
|
||||||
$code .= " asort(\$a->$key);\n";
|
$code .= " \$aa = \$a->$key;\n";
|
||||||
$code .= " \$aa = array_shift(\$a->$key);\n";
|
|
||||||
$code .= " } else\n";
|
$code .= " if (is_array(\$b->$key)) {\n";
|
||||||
$code .= " \$aa = \$a->$key;\n";
|
$code .= " asort(\$b->$key);\n";
|
||||||
|
$code .= " \$bb = array_shift(\$b->$key);\n";
|
||||||
$code .= " if (is_array(\$b->$key)) {\n";
|
$code .= " } else\n";
|
||||||
$code .= " asort(\$b->$key);\n";
|
$code .= " \$bb = \$b->$key;\n";
|
||||||
$code .= " \$bb = array_shift(\$b->$key);\n";
|
|
||||||
$code .= " } else\n";
|
$code .= " if (\$aa != \$bb)";
|
||||||
$code .= " \$bb = \$b->$key;\n";
|
if ($rev)
|
||||||
|
$code .= " return (\$aa < \$bb ? 1 : -1);\n";
|
||||||
$code .= " if (\$aa != \$bb)";
|
else
|
||||||
if ($rev)
|
$code .= " return (\$aa > \$bb ? 1 : -1);\n";
|
||||||
$code .= " return (\$aa < \$bb ? 1 : -1);\n";
|
|
||||||
else
|
$code .= "} else {\n";
|
||||||
$code .= " return (\$aa > \$bb ? 1 : -1);\n";
|
|
||||||
|
$code .= " \$a = array_change_key_case(\$a);\n";
|
||||||
$code .= "} else {\n";
|
$code .= " \$b = array_change_key_case(\$b);\n";
|
||||||
|
|
||||||
$code .= " \$a = array_change_key_case(\$a);\n";
|
$key = strtolower($key);
|
||||||
$code .= " \$b = array_change_key_case(\$b);\n";
|
|
||||||
|
$code .= " if ((! isset(\$a['$key'])) && isset(\$b['$key'])) return 1;\n";
|
||||||
$key = strtolower($key);
|
$code .= " if (isset(\$a['$key']) && (! isset(\$b['$key']))) return -1;\n";
|
||||||
|
|
||||||
$code .= " if ((! isset(\$a['$key'])) && isset(\$b['$key'])) return 1;\n";
|
$code .= " if ((isset(\$a['$key'])) && (isset(\$b['$key']))) {\n";
|
||||||
$code .= " if (isset(\$a['$key']) && (! isset(\$b['$key']))) return -1;\n";
|
$code .= " if (is_array(\$a['$key'])) {\n";
|
||||||
|
$code .= " asort(\$a['$key']);\n";
|
||||||
$code .= " if ((isset(\$a['$key'])) && (isset(\$b['$key']))) {\n";
|
$code .= " \$aa = array_shift(\$a['$key']);\n";
|
||||||
$code .= " if (is_array(\$a['$key'])) {\n";
|
$code .= " } else\n";
|
||||||
$code .= " asort(\$a['$key']);\n";
|
$code .= " \$aa = \$a['$key'];\n";
|
||||||
$code .= " \$aa = array_shift(\$a['$key']);\n";
|
|
||||||
$code .= " } else\n";
|
$code .= " if (is_array(\$b['$key'])) {\n";
|
||||||
$code .= " \$aa = \$a['$key'];\n";
|
$code .= " asort(\$b['$key']);\n";
|
||||||
|
$code .= " \$bb = array_shift(\$b['$key']);\n";
|
||||||
$code .= " if (is_array(\$b['$key'])) {\n";
|
$code .= " } else\n";
|
||||||
$code .= " asort(\$b['$key']);\n";
|
$code .= " \$bb = \$b['$key'];\n";
|
||||||
$code .= " \$bb = array_shift(\$b['$key']);\n";
|
|
||||||
$code .= " } else\n";
|
$code .= " if (\$aa != \$bb)\n";
|
||||||
$code .= " \$bb = \$b['$key'];\n";
|
$code .= " if (is_numeric(\$aa) && is_numeric(\$bb)) {\n";
|
||||||
|
|
||||||
$code .= " if (\$aa != \$bb)\n";
|
if ($rev)
|
||||||
$code .= " if (is_numeric(\$aa) && is_numeric(\$bb)) {\n";
|
$code .= " return (\$aa < \$bb ? 1 : -1);\n";
|
||||||
|
else
|
||||||
if ($rev)
|
$code .= " return (\$aa > \$bb ? 1 : -1);\n";
|
||||||
$code .= " return (\$aa < \$bb ? 1 : -1);\n";
|
|
||||||
else
|
$code .= " } else {\n";
|
||||||
$code .= " return (\$aa > \$bb ? 1 : -1);\n";
|
|
||||||
|
if ($rev)
|
||||||
$code .= " } else {\n";
|
$code .= " if ( (\$c = strcasecmp(\$bb,\$aa)) != 0 ) return \$c;\n";
|
||||||
|
else
|
||||||
if ($rev)
|
$code .= " if ( (\$c = strcasecmp(\$aa,\$bb)) != 0 ) return \$c;\n";
|
||||||
$code .= " if ( (\$c = strcasecmp(\$bb,\$aa)) != 0 ) return \$c;\n";
|
|
||||||
else
|
$code .= " }\n";
|
||||||
$code .= " if ( (\$c = strcasecmp(\$aa,\$bb)) != 0 ) return \$c;\n";
|
$code .= " }\n";
|
||||||
|
$code .= "}\n";
|
||||||
$code .= " }\n";
|
|
||||||
$code .= " }\n";
|
|
||||||
$code .= "}\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$code .= 'return $c;';
|
|
||||||
|
|
||||||
$MASORT_CACHE[$sortby] = create_function('$a, $b',$code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$code .= 'return $c;';
|
||||||
|
|
||||||
|
$result = create_function('$a, $b',$code);
|
||||||
|
|
||||||
uasort($data,$MASORT_CACHE[$sortby]);
|
uasort($data,$result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
15
modules/statement/classes/controller/statement.php
Normal file
15
modules/statement/classes/controller/statement.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides Statement management
|
||||||
|
*
|
||||||
|
* @package lnApp
|
||||||
|
* @subpackage Page/Statement
|
||||||
|
* @category Controllers
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
class Controller_Statement extends Controller_TemplateDefault {
|
||||||
|
}
|
||||||
|
?>
|
84
modules/statement/classes/controller/user/statement.php
Normal file
84
modules/statement/classes/controller/user/statement.php
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class provides User Statement functions
|
||||||
|
*
|
||||||
|
* @package OSB
|
||||||
|
* @subpackage Statement
|
||||||
|
* @category Controllers/User
|
||||||
|
* @author Deon George
|
||||||
|
* @copyright (c) 2010 Deon George
|
||||||
|
* @license http://dev.leenooks.net/license.html
|
||||||
|
*/
|
||||||
|
class Controller_User_Statement extends Controller_TemplateDefault_User {
|
||||||
|
protected $secure_actions = array(
|
||||||
|
'show'=>TRUE,
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show a payments received
|
||||||
|
*/
|
||||||
|
public function action_show() {
|
||||||
|
$ta = array();
|
||||||
|
|
||||||
|
foreach ($this->ao->payment->find_all() as $o) {
|
||||||
|
$i = count($ta);
|
||||||
|
$ta[$i]['time'] = $o->date_payment;
|
||||||
|
$ta[$i]['payment'] = $o;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->ao->invoice->find_all() as $o) {
|
||||||
|
$i = count($ta);
|
||||||
|
$ta[$i]['time'] = $o->date_orig;
|
||||||
|
$ta[$i]['invoice'] = $o;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sort::MAsort($ta,'time');
|
||||||
|
|
||||||
|
$t = 0;
|
||||||
|
$a = 0;
|
||||||
|
foreach ($ta as $k => $v) {
|
||||||
|
// If 2 metrics have the same time, we need to increment 1 by a small number so that it doesnt affect the next sorting
|
||||||
|
if ($a == $v['time']) {
|
||||||
|
$ta[$k]['time'] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($v['invoice']))
|
||||||
|
$t += $v['invoice']->total_amt;
|
||||||
|
elseif (isset($v['payment']))
|
||||||
|
$t -= $v['payment']->total_amt;
|
||||||
|
|
||||||
|
$ta[$k]['total'] = $t;
|
||||||
|
$a = $v['time'];
|
||||||
|
}
|
||||||
|
|
||||||
|
Sort::MAsort($ta,'time',1);
|
||||||
|
|
||||||
|
$pag = new Pagination(array(
|
||||||
|
'total_items'=>count($ta),
|
||||||
|
));
|
||||||
|
|
||||||
|
$output = (string)$pag;
|
||||||
|
$output .= View::factory('statement/user/show_head');
|
||||||
|
|
||||||
|
$i = 0;
|
||||||
|
foreach ($ta as $k => $v) {
|
||||||
|
if (++$i < $pag->current_first_item())
|
||||||
|
continue;
|
||||||
|
elseif ($i > $pag->current_last_item())
|
||||||
|
break;
|
||||||
|
|
||||||
|
$output .= View::factory('statement/user/show_body')
|
||||||
|
->set('o',$v)
|
||||||
|
->set('trc',$i%2 ? 'odd' : 'even');
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= View::factory('statement/user/show_foot');
|
||||||
|
|
||||||
|
Block::add(array(
|
||||||
|
'title'=>sprintf('%s: %s - %s',_('Transaactions For'),$this->ao->accnum(),$this->ao->name(TRUE)),
|
||||||
|
'body'=>$output,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
14
modules/statement/views/statement/user/show_body.php
Normal file
14
modules/statement/views/statement/user/show_body.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<tr class="<?php echo $trc; ?>">
|
||||||
|
<?php if (isset($o['invoice'])) { ?>
|
||||||
|
<td><?php echo $o['invoice']->display('date_orig'); ?></td>
|
||||||
|
<td>Invoice</td>
|
||||||
|
<td><?php echo HTML::anchor('user/invoice/view/'.$o['invoice']->id,$o['invoice']->id()); ?></td>
|
||||||
|
<td class="right"><?php echo $o['invoice']->display('total_amt'); ?></td>
|
||||||
|
<?php } elseif (isset($o['payment'])) { ?>
|
||||||
|
<td><?php echo $o['payment']->display('date_payment'); ?></td>
|
||||||
|
<td>Payment</td>
|
||||||
|
<td><?php echo $o['payment']->checkout->display('name'); ?></td>
|
||||||
|
<td class="right"><?php echo $o['payment']->display('total_amt'); ?></td>
|
||||||
|
<?php } ?>
|
||||||
|
<td class="right"><?php echo Currency::display($o['total']); ?></td>
|
||||||
|
</tr>
|
1
modules/statement/views/statement/user/show_foot.php
Normal file
1
modules/statement/views/statement/user/show_foot.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
</table>
|
7
modules/statement/views/statement/user/show_head.php
Normal file
7
modules/statement/views/statement/user/show_head.php
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<table class="box-left" border="0" id="list-table">
|
||||||
|
<tr>
|
||||||
|
<td class="head">Date</td>
|
||||||
|
<td class="head" colspan="2">Type</td>
|
||||||
|
<td class="head">Amt</td>
|
||||||
|
<td class="head">Total</td>
|
||||||
|
</tr>
|
Reference in New Issue
Block a user