[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [6590] property: more on generic code
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [6590] property: more on generic code |
Date: |
Sun, 14 Nov 2010 20:09:44 +0000 |
Revision: 6590
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6590
Author: sigurdne
Date: 2010-11-14 20:09:44 +0000 (Sun, 14 Nov 2010)
Log Message:
-----------
property: more on generic code
Modified Paths:
--------------
trunk/property/inc/class.bocategory.inc.php
trunk/property/inc/class.menu.inc.php
trunk/property/inc/class.socategory.inc.php
trunk/property/inc/class.uicategory.inc.php
trunk/property/js/yahoo/category.index.js
Modified: trunk/property/inc/class.bocategory.inc.php
===================================================================
--- trunk/property/inc/class.bocategory.inc.php 2010-11-14 00:02:01 UTC (rev
6589)
+++ trunk/property/inc/class.bocategory.inc.php 2010-11-14 20:09:44 UTC (rev
6590)
@@ -64,15 +64,8 @@
function __construct($session=false)
{
$this->so =
CreateObject('property.socategory');
- $this->socommon =
CreateObject('property.socommon');
$this->custom = & $this->so->custom;
- if ($session)
- {
- $this->read_sessiondata();
- $this->use_session = true;
- }
-
$start =
phpgw::get_var('start', 'int', 'REQUEST', 0);
$query =
phpgw::get_var('query');
$sort =
phpgw::get_var('sort');
@@ -83,10 +76,16 @@
$type =
phpgw::get_var('type');
$type_id =
phpgw::get_var('type_id', 'int');
+ if ($session)
+ {
+ $this->read_sessiondata($type);
+ $this->use_session = true;
+ }
+
$this->start = $start ? $start : 0;
$this->query = isset($_REQUEST['query']) ?
$query : $this->query;
$this->sort =
isset($_REQUEST['sort']) ? $sort : $this->sort;
- $this->order = isset($_REQUEST['order']) ?
$order : $this->order;
+ $this->order = isset($_REQUEST['order']) &&
$_REQUEST['order'] ? $order : $this->order;
$this->filter = isset($_REQUEST['filter']) ?
$filter : $this->filter;
$this->cat_id = isset($_REQUEST['cat_id']) ?
$cat_id : $this->cat_id;
$this->allrows = isset($allrows) ? $allrows :
false;
@@ -99,13 +98,13 @@
{
if ($this->use_session)
{
-
$GLOBALS['phpgw']->session->appsession('session_data','category',$data);
+
$GLOBALS['phpgw']->session->appsession('session_data',"generic_{$data['type']}",$data);
}
}
- function read_sessiondata()
+ function read_sessiondata($type)
{
- $data =
$GLOBALS['phpgw']->session->appsession('session_data','category');
+ $data =
$GLOBALS['phpgw']->session->appsession('session_data',"generic_{$type}");
// _debug_array($data);
@@ -123,10 +122,22 @@
return $this->so->get_location_info($type,$type_id);
}
- public function read()
+ public function read($filter = array())
{
+
+ if (! $filter )
+ {
+ foreach ( $this->location_info['fields'] as
$field )
+ {
+ if (isset($field['filter']) &&
$field['filter'])
+ {
+ $filter[$field['name']] =
phpgw::get_var($field['name']);
+ }
+ }
+ }
+
$values = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
-
'allrows'=>$this->allrows));
+
'allrows'=>$this->allrows),$filter);
$this->total_records = $this->so->total_records;
$this->uicols = $this->so->uicols;
Modified: trunk/property/inc/class.menu.inc.php
===================================================================
--- trunk/property/inc/class.menu.inc.php 2010-11-14 00:02:01 UTC (rev
6589)
+++ trunk/property/inc/class.menu.inc.php 2010-11-14 20:09:44 UTC (rev
6590)
@@ -268,11 +268,6 @@
'text' => lang('Part of town'),
'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uicategory.index', 'type' => 'part_of_town') )
),
- 'town2' => array
- (
- 'text' => lang('Part of town'),
- 'url' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'property.uip_of_town.index') )
- ),
'location' => array
(
'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uiadmin_location.index') ),
Modified: trunk/property/inc/class.socategory.inc.php
===================================================================
--- trunk/property/inc/class.socategory.inc.php 2010-11-14 00:02:01 UTC (rev
6589)
+++ trunk/property/inc/class.socategory.inc.php 2010-11-14 20:09:44 UTC (rev
6590)
@@ -45,7 +45,7 @@
$this->_join = & $this->_db->join;
}
- function read($data)
+ function read($data, $filter)
{
$start = isset($data['start']) &&
$data['start'] ? $data['start']:0;
$query =
isset($data['query'])?$data['query']:'';
@@ -60,11 +60,13 @@
}
$valid_order = false;
+
if($order)
{
- if($this->location_info['id']['type'] != $order)
+ if($this->location_info['id']['name'] != $order)
{
- foreach
($$this->location_info['fields'] as $field)
+
+ foreach ($this->location_info['fields']
as $field)
{
if($field['name'] == $order)
{
@@ -77,12 +79,30 @@
{
$valid_order = true;
}
+
if(!$valid_order)
{
$order = '';
}
}
+ $_filter_array = array();
+ $get_single = array();
+ foreach ( $this->location_info['fields'] as $field )
+ {
+ if (isset($field['filter']) && $field['filter'])
+ {
+ if(isset($filter[$field['name']]) &&
$filter[$field['name']])
+ {
+ $_filter_array[] =
"{$field['name']} = '{$filter[$field['name']]}'";
+ }
+ }
+ if (isset($field['get_single']) &&
$field['get_single'])
+ {
+ $get_single[$field['name']] =
$field['get_single'];
+ }
+ }
+
$uicols = array();
$uicols['input_type'][] = 'text';
$uicols['name'][] =
$this->location_info['id']['name'];
@@ -134,15 +154,22 @@
$filtermethod = "{$where} user_id =
{$this->account} OR public = 1";
$where = 'AND';
}
+
+ if($_filter_array)
+ {
+ $filtermethod .= " $where " . implode(' AND ',
$_filter_array);
+ $where = 'AND';
+ }
+
$this->uicols = $uicols;
if ($order)
{
- $ordermethod = " ORDER BY $order $sort";
+ $ordermethod = " ORDER BY {$table}.{$order}
{$sort}";
}
else
{
- $ordermethod = " ORDER BY
{$this->location_info['id']['name']} ASC";
+ $ordermethod = " ORDER BY
{$table}.{$this->location_info['id']['name']} ASC";
}
if($query)
@@ -157,7 +184,7 @@
}
$query = $this->_db->db_addslashes($query);
- $querymethod = " {$where }
{$table}.{$this->location_info['id']['name']} = {$id_query}";
+ $querymethod = " {$where }
({$table}.{$this->location_info['id']['name']} = {$id_query}";
foreach($this->location_info['fields'] as
$field)
{
if($field['type'] == 'varchar')
@@ -165,6 +192,7 @@
$querymethod .= " OR
{$table}.{$field['name']} $this->_like '%$query%'";
}
}
+ $querymethod .= ')';
}
$sql = "SELECT * FROM $table $filtermethod
$querymethod";
@@ -183,7 +211,6 @@
$cols_return = $uicols['name'];
$j=0;
-// $n=count($cols_return);
$dataset = array();
while ($this->_db->next_record())
@@ -202,6 +229,32 @@
$values = $this->custom->translate_value($dataset,
$location_id);
+ if($get_single)
+ {
+ foreach($values as $set => &$entry)
+ {
+ foreach ($entry as $field => &$value)
+ {
+ foreach ($get_single as $key =>
$method)
+ {
+ if($field == $key)
+ {
+ switch ($method)
+ {
+ case
'get_user':
+
if($value)
+
{
+
$value = $GLOBALS['phpgw']->accounts->get($value)->__toString();
+
}
+
break;
+ default:
+ //
nothing
+ }
+ }
+ }
+ }
+ }
+ }
return $values;
}
@@ -846,7 +899,8 @@
'descr' =>
lang('descr'),
'type' =>
'varchar',
'nullable'
=> false,
- 'size'
=> 60
+ 'size'
=> 60,
+ 'sortable'
=> true
),
array
(
@@ -854,6 +908,8 @@
'descr'
=> lang('category'),
'type'
=> 'select',
'nullable'
=> false,
+ 'filter'
=> true,
+ 'sortable'
=> true,
'values_def'
=> array
(
'valueset' => false,
@@ -867,13 +923,16 @@
'descr'
=> lang('tax code'),
'type'
=> 'int',
'nullable'
=> true,
- 'size'
=> 4
+ 'size'
=> 4,
+ 'sortable'
=> true
),
array
(
'name'
=> 'responsible',
'descr'
=> lang('responsible'),
'type'
=> 'select',
+ 'filter'
=> true,
+ 'get_single'
=> 'get_user',
'values_def'
=> array
(
'valueset' => false,
@@ -893,7 +952,7 @@
'add_msg'
=> lang('add'),
'name'
=> lang('budget account'),
'acl_location' =>
'.b_account',
- 'menu_selection' =>
'admin::property::responsibility_role',
+ 'menu_selection' =>
'property::invoice::budget_account',
'default'
=> array
(
'user_id'
=> array('add' => '$this->account'),
Modified: trunk/property/inc/class.uicategory.inc.php
===================================================================
--- trunk/property/inc/class.uicategory.inc.php 2010-11-14 00:02:01 UTC (rev
6589)
+++ trunk/property/inc/class.uicategory.inc.php 2010-11-14 20:09:44 UTC (rev
6590)
@@ -57,7 +57,7 @@
{
$GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
$this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
- $this->bo =
CreateObject('property.bocategory');
+ $this->bo =
CreateObject('property.bocategory',true);
$this->bocommon =
CreateObject('property.bocommon');
$this->custom = &
$this->bo->custom;
@@ -78,7 +78,7 @@
$this->allrows =
$this->bo->allrows;
}
- function save_sessiondata()
+ function save_sessiondata($type)
{
$data = array
(
@@ -86,7 +86,8 @@
'query' => $this->query,
'sort' => $this->sort,
'order' => $this->order,
- 'allrows' => $this->allrows
+ 'allrows' => $this->allrows,
+ 'type' => $type
);
$this->bo->save_sessiondata($data);
}
@@ -109,7 +110,7 @@
$type_id = phpgw::get_var('type_id', 'int');
$receipt =
$GLOBALS['phpgw']->session->appsession('session_data',
"general_receipt_{$type}_{$type_id}");
- $this->save_sessiondata();
+ $this->save_sessiondata($type);
$GLOBALS['phpgw_info']['apps']['manual']['section'] =
"general.index.{$type}";
@@ -238,7 +239,7 @@
$values_combo_box[] =
execMethod($field['values_def']['method'],$method_input);
}
- $default_value = array
('id'=>'','name'=>lang('select value'));
+ $default_value = array
('id'=>'','name'=> lang('select') . ' ' . $field['descr']);
array_unshift
($values_combo_box[$i],$default_value);
$i++;
}
Modified: trunk/property/js/yahoo/category.index.js
===================================================================
--- trunk/property/js/yahoo/category.index.js 2010-11-14 00:02:01 UTC (rev
6589)
+++ trunk/property/js/yahoo/category.index.js 2010-11-14 20:09:44 UTC (rev
6590)
@@ -2,7 +2,7 @@
// Declaration of location.index vars
//--------------------------------------------------------
// define buttons
- var selectsButtons = [];
+// var selectsButtons = [];
var oNormalButton_0,oNormalButton_1,oNormalButton_2,oNormalButton_3;
var normalButtons = [
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [6590] property: more on generic code,
Sigurd Nes <=