* See horde/config/prefs.php for documentation on the structure of this file.
*/
-// Make sure that constants are defined.
-@define('FIMA_BASE', '/usr/share/horde/fima');
-require_once FIMA_BASE . '/lib/Fima.php';
-
$prefGroups['share'] = array(
'column' => _("General Options"),
'label' => _("Active Configuration"),
'desc' => _("Choose your active Ledger and Posting Type."),
- 'members' => array('ledgerselect', 'active_postingtype', 'closedperiodselect')
+ 'members' => array(
+ 'active_ledger', 'active_postingtype', 'closedperiodselect'
+ )
);
$prefGroups['display'] = array(
'column' => _("General Options"),
'label' => _("Interface Options"),
'desc' => _("Change the display and input options."),
- 'members' => array('max_postings', 'startpage', 'sortby', 'altsortby', 'sortdir', 'wildcard_format', 'amount_format', 'expenses_sign', 'delete_opt', 'report_graphsize')
+ 'members' => array(
+ 'max_postings', 'startpage', 'sortby', 'altsortby', 'sortdir',
+ 'wildcard_format', 'amount_format', 'expenses_sign', 'delete_opt',
+ 'report_graphsize'
+ )
);
-// active ledger selection widget
-$_prefs['ledgerselect'] = array('type' => 'special');
-
// active ledger
// Set locked to true if you don't want users to have multiple ledgers.
$_prefs['active_ledger'] = array(
- 'value' => Horde_Auth::getAuth() ? Horde_Auth::getAuth() : 0,
- 'locked' => false,
- 'shared' => true,
- 'type' => 'implicit'
+ 'value' => Horde_Auth::getAuth() ? Horde_Auth::getAuth() : 0
+ 'type' => 'enum',
+ 'shared' => true
);
// store the ledgers to diplay
$_prefs['display_ledgers'] = array(
- 'value' => 'a:0:{}',
- 'locked' => false,
- 'shared' => false,
- 'type' => 'implicit'
+ 'value' => 'a:0:{}'
);
// active posting type
$_prefs['active_postingtype'] = array(
'value' => FIMA_POSTINGTYPE_ACTUAL,
- 'locked' => false,
- 'shared' => false,
'type' => 'enum',
- 'enum' => array(FIMA_POSTINGTYPE_ACTUAL => _("Actual"),
- FIMA_POSTINGTYPE_FORECAST => _("Forecast"),
- FIMA_POSTINGTYPE_BUDGET => _("Budget")),
+ 'enum' => array(
+ FIMA_POSTINGTYPE_ACTUAL => _("Actual"),
+ FIMA_POSTINGTYPE_FORECAST => _("Forecast"),
+ FIMA_POSTINGTYPE_BUDGET => _("Budget")
+ ),
'desc' => _("Your active posting type:")
);
// closed period selection widget
-$_prefs['closedperiodselect'] = array('type' => 'special');
+$_prefs['closedperiodselect'] = array(
+ 'type' => 'special'
+);
// closed period
$_prefs['closed_period'] = array(
- 'value' => 0,
- 'locked' => false,
- 'shared' => false,
- 'type' => 'implicit'
+ 'value' => 0
);
// postings per page
$_prefs['max_postings'] = array(
'value' => 20,
- 'locked' => false,
- 'shared' => false,
'type' => 'number',
'desc' => _("Postings per page in the list view.")
);
// start page
$_prefs['startpage'] = array(
'value' => -1,
- 'locked' => false,
- 'shared' => false,
'type' => 'enum',
- 'enum' => array(1 => _("First Page"),
- -1 => _("Last Page")),
+ 'enum' => array(
+ 1 => _("First Page"),
+ -1 => _("Last Page")
+ ),
'desc' => _("When displaying the postings, which page do you want to start on?")
);
// user preferred sorting column
$_prefs['sortby'] = array(
'value' => FIMA_SORT_DATE,
- 'locked' => false,
- 'shared' => false,
'type' => 'enum',
- 'enum' => array(FIMA_SORT_DATE => _("Date"),
- FIMA_SORT_ASSET => _("Asset Account"),
- FIMA_SORT_ACCOUNT => _("Posting Account"),
- FIMA_SORT_AMOUNT => _("Amount"),
- FIMA_SORT_DESC => _("Description")),
+ 'enum' => array(
+ FIMA_SORT_DATE => _("Date"),
+ FIMA_SORT_ASSET => _("Asset Account"),
+ FIMA_SORT_ACCOUNT => _("Posting Account"),
+ FIMA_SORT_AMOUNT => _("Amount"),
+ FIMA_SORT_DESC => _("Description")
+ ),
'desc' => _("Sort postings by:")
);
// alternate sort column
$_prefs['altsortby'] = array(
'value' => FIMA_SORT_ACCOUNT,
- 'locked' => false,
- 'shared' => false,
'type' => 'enum',
- 'enum' => array(FIMA_SORT_DATE => _("Date"),
- FIMA_SORT_ASSET => _("Asset Account"),
- FIMA_SORT_ACCOUNT => _("Posting Account"),
- FIMA_SORT_AMOUNT => _("Amount"),
- FIMA_SORT_DESC => _("Description")),
+ 'enum' => array(
+ FIMA_SORT_DATE => _("Date"),
+ FIMA_SORT_ASSET => _("Asset Account"),
+ FIMA_SORT_ACCOUNT => _("Posting Account"),
+ FIMA_SORT_AMOUNT => _("Amount"),
+ FIMA_SORT_DESC => _("Description")
+ ),
'desc' => _("Then:")
);
// user preferred sorting direction
$_prefs['sortdir'] = array(
'value' => FIMA_SORT_ASCEND,
- 'locked' => false,
- 'shared' => false,
'type' => 'enum',
- 'enum' => array(FIMA_SORT_ASCEND => _("Ascending"),
- FIMA_SORT_DESCEND => _("Descending")),
+ 'enum' => array(
+ FIMA_SORT_ASCEND => _("Ascending"),
+ FIMA_SORT_DESCEND => _("Descending")
+ ),
'desc' => _("Sort direction:")
);
// format for wildcards
$_prefs['wildcard_format'] = array(
'value' => 'dos',
- 'locked' => false,
- 'shared' => false,
'type' => 'enum',
- 'enum' => array('dos' => _("DOS (* and ?)"),
- 'sql' => _("SQL (% and _)"),
- 'none' => _("none")),
+ 'enum' => array(
+ 'dos' => _("DOS (* and ?)"),
+ 'sql' => _("SQL (% and _)"),
+ 'none' => _("none")
+ ),
'desc' => _("Select the format for wildcards for text search:")
);
// format for amounts
$_prefs['amount_format'] = array(
'value' => '.,',
- 'locked' => false,
- 'shared' => false,
'type' => 'enum',
- 'enum' => array('.,' => _("-12.345.678,90"),
- ',.' => _("-12,345,678.90"),
- ' ,' => _("-12 345 678,90"),
- '\'.' => _("-12'345'678.90")),
+ 'enum' => array(
+ '.,' => _("-12.345.678,90"),
+ ',.' => _("-12,345,678.90"),
+ ' ,' => _("-12 345 678,90"),
+ '\'.' => _("-12'345'678.90")
+ ),
'desc' => _("Select the format for amounts:")
);
// sign for expenses
$_prefs['expenses_sign'] = array(
'value' => 0,
- 'locked' => false,
- 'shared' => false,
'type' => 'checkbox',
'desc' => _("Enter expenses with negative sign?")
);
// preference for delete confirmation dialog.
$_prefs['delete_opt'] = array(
'value' => 1,
- 'locked' => false,
- 'shared' => false,
'type' => 'checkbox',
'desc' => _("Do you want to confirm deleting postings?")
);
// report graph size
$_prefs['report_graphsize'] = array(
'value' => '800x600',
- 'locked' => false,
- 'shared' => false,
'type' => 'enum',
- 'enum' => array('400x300' => _("400 x 300 Pixel"),
- '800x600' => _("800 x 600 Pixel"),
- '1024x768' => _("1024 x 768 Pixel"),
- '1600x1200' => _("1600 x 1200 Pixel")),
+ 'enum' => array(
+ '400x300' => _("400 x 300 Pixel"),
+ '800x600' => _("800 x 600 Pixel"),
+ '1024x768' => _("1024 x 768 Pixel"),
+ '1600x1200' => _("1600 x 1200 Pixel")
+ ),
'desc' => _("Select the canvas size for chart reports:")
);
public $version = '1.0.1';
/**
+ * Code to run on init when viewing prefs for this application.
+ *
+ * @param Horde_Core_Prefs_Ui $ui The UI object.
+ */
+ public function prefsInit($ui)
+ {
+ switch ($ui->group) {
+ case 'share':
+ if (!$GLOBALS['prefs']->isLocked('active_ledger')) {
+ $ui->override['active_ledger'] = Fima::listLedgers();
+ }
+ break;
+ }
+ }
+
+ /**
+ * Generate code used to display a special preference.
+ *
+ * @param Horde_Core_Prefs_Ui $ui The UI object.
+ * @param string $item The preference name.
+ *
+ * @return string The HTML code to display on the options page.
+ */
+ public function prefsSpecial($ui, $item)
+ {
+ switch ($item) {
+ case 'closedperiodselect':
+ return _("Closed by period:") .
+ '<br />' .
+ Fima::buildDateWidget('closedperiod', (int)$GLOBALS['prefs']->getValue('closed_period'), '', _("None"), true) .
+ '</select><br /><br />';
+ }
+
+ return '';
+ }
+
+ /**
* Special preferences handling on update.
*
* @param Horde_Core_Prefs_Ui $ui The UI object.
public function prefsSpecialUpdate($ui, $item)
{
switch ($item) {
- case 'ledgerselect':
- if (isset($ui->vars->active_ledger)) {
- $ledgers = Fima::listLedgers();
- if (is_array($ledgers) &&
- array_key_exists($ui->vars->active_ledger, $ledgers)) {
- $GLOBALS['prefs']->setValue('active_ledger', $ui->vars->active_ledger);
- return true;
- }
- }
- break;
-
case 'closedperiodselect':
$period = $ui->vars->closedperiod;
$period = ((int)$period['year'] > 0 && (int)$period['month'] > 0)