From eaea52a8627e0f0bf007a3c6206e16c59d2c5740 Mon Sep 17 00:00:00 2001 From: abijah Date: Mon, 15 Jun 2009 21:45:07 +0000 Subject: [PATCH] Added an element for monetary_sources. Not sure if it will get used, but it was easy enough to do. git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@138 97e9348a-65ac-dc4b-aefc-98561f571b83 --- .../monetary_sources_controller.php | 36 +++++++++++++++++-- site/views/elements/monetary_sources.ctp | 22 ++++++++++++ 2 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 site/views/elements/monetary_sources.ctp diff --git a/site/controllers/monetary_sources_controller.php b/site/controllers/monetary_sources_controller.php index aa294d5..ffe5ab3 100644 --- a/site/controllers/monetary_sources_controller.php +++ b/site/controllers/monetary_sources_controller.php @@ -1,9 +1,6 @@ 100, - 'group' => 'Entry.id', - 'order' => array('Entry.stamp' => 'ASC')); var $sidemenu_links = array(); @@ -19,6 +16,39 @@ class MonetarySourcesController extends AppController { } + /************************************************************************** + ************************************************************************** + ************************************************************************** + * action: index / all + * - Generate a listing of MonetarySources + */ + + function index() { $this->all(); } + function all() { $this->jqGridView('All MonetarySources', 'all'); } + + + /************************************************************************** + ************************************************************************** + ************************************************************************** + * virtuals: jqGridData + * - With the application controller handling the jqGridData action, + * these virtual functions ensure that the correct data is passed + * to jqGrid. + */ + + function jqGridDataTables(&$params, &$model) { + return array + ('link' => array('MonetaryType' => array('fields' => array('MonetaryType.id', 'MonetaryType.name')), + ), + ); + } + + function jqGridRecordLinks(&$params, &$model, &$records, $links) { + $links['MonetarySource'] = array('id'); + return parent::jqGridRecordLinks($params, $model, $records, $links); + } + + /************************************************************************** ************************************************************************** ************************************************************************** diff --git a/site/views/elements/monetary_sources.ctp b/site/views/elements/monetary_sources.ctp new file mode 100644 index 0000000..78be880 --- /dev/null +++ b/site/views/elements/monetary_sources.ctp @@ -0,0 +1,22 @@ + 'MonetarySource.id', 'formatter' => 'id'); +$cols['Name'] = array('index' => 'MonetarySource.name', 'formatter' => 'longname'); +$cols['Type'] = array('index' => 'MonetaryType.name', 'formatter' => 'name'); +$cols['Comment'] = array('index' => 'MonetarySource.comment', 'formatter' => 'comment'); + +$jqGrid_options = array('jqGridColumns' => $cols, + 'controller' => 'monetary_sources', + 'caption' => isset($caption) ? $caption : null); + +if (isset($monetary_sources)) { + $jqGrid_options += array('custom_ids' => + array_map(create_function('$data', + 'return $data["id"];'), + $monetary_sources), + 'limit' => 5); +} + +echo $this->element('jqGrid', $jqGrid_options);