[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [6685] Merge of dev-bim branch, revisions 4247 - 4564
From: |
Petur Bjorn Thorsteinsson |
Subject: |
[Fmsystem-commits] [6685] Merge of dev-bim branch, revisions 4247 - 4564 |
Date: |
Mon, 20 Dec 2010 14:44:14 +0000 |
Revision: 6685
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=6685
Author: peturbjorn
Date: 2010-12-20 14:44:13 +0000 (Mon, 20 Dec 2010)
Log Message:
-----------
Merge of dev-bim branch, revisions 4247 - 4564
Modified Paths:
--------------
branches/dev-bim2/property/inc/class.menu.inc.php
branches/dev-bim2/property/setup/setup.inc.php
branches/dev-bim2/property/setup/tables_current.inc.php
branches/dev-bim2/property/setup/tables_update.inc.php
Added Paths:
-----------
branches/dev-bim2/property/inc/class.boattribute.inc.php
branches/dev-bim2/property/inc/class.boattribute_owner.inc.php
branches/dev-bim2/property/inc/class.bogroup.inc.php
branches/dev-bim2/property/inc/class.boitem.inc.php
branches/dev-bim2/property/inc/class.soitem.inc.php
branches/dev-bim2/property/inc/class.soitem_group.inc.php
branches/dev-bim2/property/inc/class.uiitem.inc.php
branches/dev-bim2/property/js/yahoo/item.index.js
Added: branches/dev-bim2/property/inc/class.boattribute.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.boattribute.inc.php
(rev 0)
+++ branches/dev-bim2/property/inc/class.boattribute.inc.php 2010-12-20
14:44:13 UTC (rev 6685)
@@ -0,0 +1,125 @@
+<?php
+ /**
+ * FIXME: Description
+ *
+ * @author Espen
+ */
+ class property_boattribute
+ {
+ private $id, $name, $display_name, $value, $data_type, $unit, $desc;
+
+
+ /**
+ * Constructor. Takes an optional array of values where the keys should
+ * be identical to the name of the variable it is trying to set. Setter
+ * methods reflect these names.
+ *
+ * @param array $values
+ */
+ public function __construct($properties = null)
+ {
+ if($this->valid_properties($properties))
+ {
+ $this->set_id($properties['id']); // May be null
+ $this->set_name($properties['name']);
+ $this->set_display_name($properties['display_name']);
+ $this->set_value($properties['value']);
+ $this->set_data_type($properties['data_type']);
+ $this->set_unit($properties['unit']);
+ $this->set_desc($properties['desc']);
+ }
+ }
+
+ /**
+ * Simple value array validation.
+ *
+ * @param array $properties
+ * @return boolean
+ */
+ private function valid_properties(array $properties) {
+ if(!is_array($properties) || empty($properties['name']) ||
empty($properties['display_name']) || empty($properties['value']) ||
empty($properties['data_type']) || empty($properties['unit']))
+ {
+ return false;
+ }
+ return true;
+ }
+
+
+
+ public function get_id()
+ {
+ return $this->id;
+ }
+
+ public function set_id($id)
+ {
+ $this->id = $id;
+ }
+
+ public function get_name()
+ {
+ return $this->name;
+ }
+
+ public function set_name($name)
+ {
+ $this->name = $name;
+ }
+
+ public function get_display_name()
+ {
+ return $this->display_name;
+ }
+
+ public function set_display_name($display_name)
+ {
+ $this->display_name = $display_name;
+ }
+
+ public function get_value()
+ {
+ return $this->value;
+ }
+
+ public function set_value($value)
+ {
+ $this->value = $value;
+ }
+
+ public function get_data_type()
+ {
+ return $this->data_type;
+ }
+
+ public function set_data_type($data_type)
+ {
+ $this->data_type = $data_type;
+ }
+
+ public function get_desc()
+ {
+ return $this->desc;
+ }
+
+ public function set_desc($desc)
+ {
+ $this->desc = $desc;
+ }
+
+ public function get_unit()
+ {
+ return $this->unit;
+ }
+
+ public function set_unit($unit)
+ {
+ $this->unit = $unit;
+ }
+
+
+
+ public function __toString()
+ {
+ return $this->display_name + ": " + $this->value + " " +
$this->unit;
+ }
+ }
Added: branches/dev-bim2/property/inc/class.boattribute_owner.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.boattribute_owner.inc.php
(rev 0)
+++ branches/dev-bim2/property/inc/class.boattribute_owner.inc.php
2010-12-20 14:44:13 UTC (rev 6685)
@@ -0,0 +1,66 @@
+<?php
+ /**
+ * Description of classboattrobjectinc
+ *
+ * @author Espen
+ * @abstract
+ */
+ abstract class property_boattribute_owner
+ {
+ protected $attributes;
+
+ /**
+ * Set the value-object of a given attribute.
+ * If used on a group the attribute will be added if not already
existing
+ * and (default) value will be set.
+ *
+ * If used on an item it will override the value set by the group.
+ * Attributes not already set on the group, however, cannot be set on
+ * an item and will return false.
+ *
+ * @abstract
+ * @param string $attr_def
+ * @param property_boattribute $attr
+ * @return bool FALSE if failed, TRUE otherwise.
+ */
+ public abstract function set_attribute($attr_def, property_boattribute
$attr);
+
+
+ /**
+ * Get the value of a given attribute.
+ *
+ * @param string $attr_def
+ * @return mixed The value.
+ */
+ public function get_attribute($attr_def)
+ {
+ return ($this->attributes[$attr_def] instanceof
property_boattribute ? $this->attributes[$attr_def] : null);
+ }
+
+
+ /**
+ * Fetches a list of attributes (without values) on this object.
+ *
+ * @return array
+ */
+ public function get_attribute_list()
+ {
+ return $this->attributes;
+ }
+
+
+ /**
+ * Removes an attribute and its value from the object.
+ *
+ * If used on a group the attribute will be removed completely on the
+ * group and items belonging to it.
+ *
+ * If used on an item it will only be removed from the item, which will
+ * then inherit the attribute from the group it belongs to.
+ *
+ * @abstract
+ * @param string $attr_def
+ */
+ public abstract function remove_attribute($attr_def);
+ }
+
Added: branches/dev-bim2/property/inc/class.bogroup.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.bogroup.inc.php
(rev 0)
+++ branches/dev-bim2/property/inc/class.bogroup.inc.php 2010-12-20
14:44:13 UTC (rev 6685)
@@ -0,0 +1,66 @@
+<?php
+
+ /**
+ * Description of classbogroupinc
+ *
+ * @author Espen
+ */
+ class property_bogroup extends property_boattribute_owner
+ {
+ private $id, $name, $bpn, $nat_group_no, $catalog;
+
+ public function __construct()
+ {
+
+ }
+
+ public function get_id() {
+ return $this->id;
+ }
+
+ public function set_id($id) {
+ $this->id = $id;
+ }
+
+ public function get_name()
+ {
+ return $this->name;
+ }
+
+ public function set_name($name)
+ {
+ $this->name = $name;
+ }
+
+ public function get_bpn()
+ {
+ return $this->bpn;
+ }
+
+ public function set_bpn($bpn)
+ {
+ $this->bpn = $bpn;
+ }
+
+ public function get_nat_group_no()
+ {
+ return $this->nat_group_no;
+ }
+
+ public function set_nat_group_no($nat_group_no)
+ {
+ $this->nat_group_no = $nat_group_no;
+ }
+
+ public function get_catalog()
+ {
+ return $this->catalog;
+ }
+
+ public function set_catalog(property_bocatalog $catalog)
+ {
+ $this->catalog = $catalot;
+ }
+
+
+ }
Added: branches/dev-bim2/property/inc/class.boitem.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.boitem.inc.php
(rev 0)
+++ branches/dev-bim2/property/inc/class.boitem.inc.php 2010-12-20 14:44:13 UTC
(rev 6685)
@@ -0,0 +1,91 @@
+<?php
+
+include_class('property', 'boattribute_owner', 'inc/');
+
+ /**
+ * FIXME: Description
+ *
+ * @author Espen
+ */
+ class property_boitem extends property_boattribute_owner
+ {
+ private $id, $installed_date, $location_id, $vendor_id;
+
+ /**
+ * Should contain the group object of which this item belongs to.
+ * @var property_bogroup
+ */
+ private $group;
+
+ public function __construct($id = null, $installed_date = null,
$location_id = null, $vendor_id = null)
+ {
+ $this->set_installed_date($installed_date);
+ $this->set_id($id);
+ $this->set_location_id($location_id);
+ $this->set_vendor_id($location_id);
+ }
+
+
+ public function remove_attribute($attr_def) {
+ $this->attributes[$attr_def] = null;
+ }
+
+ public function set_attribute($attr_def, property_boattribute $attr) {
+ $group_attrs = $this->group->get_attribute_list();
+ if(array_key_exists($attr_def, $group_attrs))
+ {
+ $this->attributes[$attr_def] = $attr;
+ return true;
+ }
+
+ // Return false if array key (the attr definition) doesn't exist
in group.
+ return false;
+ }
+
+
+ public function set_installed_date($installed_date)
+ {
+ $this->installed_date = $installed_date;
+ }
+
+ public function get_installed_date()
+ {
+ return (int) $this->installed_date;
+ }
+
+ public function get_id() {
+ return $this->id;
+ }
+
+ public function set_id($id) {
+ $this->id = $id;
+ }
+
+ public function set_group(property_bogroup $group)
+ {
+ $this->group = $group;
+ }
+
+ public function get_group()
+ {
+ return $this->group;
+ }
+
+ public function get_location_id() {
+ return $this->location_id;
+ }
+
+ public function set_location_id($location_id) {
+ $this->location_id = $location_id;
+ }
+
+ public function get_vendor_id() {
+ return $this->vendor_id;
+ }
+
+ public function set_vendor_id($vendor_id) {
+ $this->vendor_id = $vendor_id;
+ }
+
+
+ }
Modified: branches/dev-bim2/property/inc/class.menu.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.menu.inc.php 2010-12-20 09:58:55 UTC
(rev 6684)
+++ branches/dev-bim2/property/inc/class.menu.inc.php 2010-12-20 14:44:13 UTC
(rev 6685)
@@ -925,6 +925,31 @@
}
}
}
+ $menus['navigation']['item'] = array
+ (
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uiitem.index')),
+ 'text' => lang('BIM_Items'),
+ 'image' => array('property', 'custom'),
+ 'children' => array_merge(array
+ (
+ 'index' => array
+ (
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uiitem.index')),
+ 'text' => lang('Register')
+ ),
+ 'foo' => array
+ (
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uiitem.foo')),
+ 'text' => lang('Foo')
+ ),
+ 'bar' => array
+ (
+ 'url' =>
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>
'property.uiitem.bar')),
+ 'text' => lang('Bar'),
+ 'image' => array('property',
'project_tenant_claim')
+ )
+ ))
+ );
unset($entity_list);
unset($entity);
Added: branches/dev-bim2/property/inc/class.soitem.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.soitem.inc.php
(rev 0)
+++ branches/dev-bim2/property/inc/class.soitem.inc.php 2010-12-20 14:44:13 UTC
(rev 6685)
@@ -0,0 +1,187 @@
+<?php
+
+phpgw::import_class('property.soitem_group');
+phpgw::import_class('property.boitem');
+
+ /**
+ * Description of soitem
+ *
+ * @author Espen
+ */
+ class property_soitem
+ {
+ private $db;
+ private static $instance;
+ public $uicols;
+
+ private function __construct() {
+ $this->db = & $GLOBALS['phpgw']->db;
+ }
+
+
+ /**
+ * @return property_soitem
+ */
+ public static function singleton()
+ {
+ if (!isset(self::$instance))
+ {
+ $c = __CLASS__;
+ self::$instance = new $c;
+ }
+ return self::$instance;
+ }
+
+ /**
+ * Retreive any number of items.
+ * @param array $data
+ * @return array Array of zero or more items
+ */
+ public function read(array $data)
+ {
+ // TODO: Use data
+ $start = isset($data['start']) ? $data['start'] : 0;
+ $filter = $data['filter'] ? $data['filter'] : 'none';
+ $query = $data['query'];
+ $sort = $data['sort'] ? $data['sort'] : 'DESC';
+ $order = $data['order'];
+ $cat_id = $data['cat_id'];
+ $allrows = $data['allrows'];
+ $member_id = $data['member_id'] ? $data['member_id'] : 0;
+ $dry_run = $data['dry_run'];
+
+ $uicols = array();
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'id';
+ $uicols['descr'][] = lang('ID');
+ $uicols['statustext'][] = lang('ID');
+ $uicols['datatype'][] = false;
+ $uicols['attib_id'][] = false;
+
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'group';
+ $uicols['descr'][] = 'Gruppe';
+ $uicols['statustext'][] = 'Gruppe';
+ $uicols['datatype'][] = false;
+ $uicols['attib_id'][] = false;
+
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'location';
+ $uicols['descr'][] = 'Location';
+ $uicols['statustext'][] = 'Location';
+ $uicols['datatype'][] = false;
+ $uicols['attib_id'][] = false;
+
+ $uicols['input_type'][] = 'text';
+ $uicols['name'][] = 'installed';
+ $uicols['descr'][] = 'Installert';
+ $uicols['statustext'][] = 'Installert';
+ $uicols['datatype'][] = false;
+ $uicols['attib_id'][] = false;
+
+ $this->uicols = $uicols;
+
+ $select_cols = array(
+ 'i.id',
+ 'i.group_id',
+ 'i.location_id',
+ 'i.vendor_id',
+ 'i.installed'
+ );
+ $from_tables = array('fm_item i');
+ $joins = array(
+ //$this->db->left_join.' fm_item_group g ON i.group_id = g.id',
+ $this->db->left_join.' fm_vendor v ON i.vendor_id = v.id'
+ );
+ $where_clauses = array(' WHERE 1=1');
+
+ if($specific_item_id) {
+ // FIXME Sanitize input!!
+ $where_clauses[] = "i.id = $specific_item_id";
+ }
+
+ $sql = 'SELECT ' . implode($select_cols, ', ') .
+ ' FROM ' . implode($from_tables, ', ') .
+ implode($joins, ' ') .
+ implode($where_clauses, ' AND ');
+
+ $this->db->query($sql);
+ $i = 0;
+ while($this->db->next_record())
+ {
+ $items[$i]['id'] = $this->db->f('id');
+ $items[$i]['group'] = $this->db->f('group_id');
+ $items[$i]['location'] = $this->db->f('location_id');
+ $items[$i]['vendor'] = $this->db->f('vendor_id');
+ $items[$i]['installed']= $this->db->f('installed');
+
+ $i++;
+ }
+
+ return $items;
+ }
+
+
+ /**
+ * Creates fully populated objects out of an item array.
+ *
+ * @param array $items Array of items in the same format as that
returned from get_items().
+ * @return mixed Array of item objects og null if failed.
+ */
+ private function populate(array $items)
+ {
+ if(!is_array($items))
+ {
+ return null;
+ }
+
+ $return_objects = array();
+ $sogroup = property_sogroup::singleton();
+
+ foreach($items as $item)
+ {
+ $item_obj = new property_boitem($items['installed_date']);
+ $item_obj->set_group($sogroup->get($item['group_id']));
+
+ $return_objects[] = $item_obj;
+ }
+
+ return $return_objects;
+ }
+
+
+ /**
+ * Save changes on an item to database or insert a new one if ID is
empty.
+ *
+ * @param property_boitem $obj
+ */
+ public function save(property_boitem $obj)
+ {
+ // If item has an ID, do an update, otherwise, do an insert
+ $ins_or_upd = ($obj->get_id() != null ? 'UPDATE' : 'INSERT INTO');
+ $table = 'fm_item';
+ $cols = array('id', 'group_id', 'location_id', 'vendor_id',
'installed');
+ $values = array($obj->get_id(),
+ $obj->get_group()->get_id(),
+ $obj->get_location_id(),
+ $obj->get_vendor_id(),
+ $obj->get_installed_date());
+ }
+
+
+ /**
+ * Get total number of records (rows) in item table
+ *
+ * @return integer No. of records
+ */
+ public function total_records()
+ {
+ $sql = 'SELECT COUNT(id) AS rows FROM fm_item';
+
+ $this->db->query($sql);
+ // Move pointer to first row
+ $this->db->next_record();
+ // Get value of 'rows' column
+ return (int) $this->db->f('rows');
+ }
+ }
Added: branches/dev-bim2/property/inc/class.soitem_group.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.soitem_group.inc.php
(rev 0)
+++ branches/dev-bim2/property/inc/class.soitem_group.inc.php 2010-12-20
14:44:13 UTC (rev 6685)
@@ -0,0 +1,109 @@
+<?php
+
+ /**
+ * Description of sogroup
+ *
+ * @author Espen
+ */
+ class property_soitem_group {
+ private $db;
+ private static $instance;
+
+ private function __construct() {
+ $this->db = & $GLOBALS['phpgw']->db;
+ }
+
+
+ /**
+ * @return property_sogroup
+ */
+ public static function singleton()
+ {
+ if (!isset(self::$instance))
+ {
+ $c = __CLASS__;
+ self::$instance = new $c;
+ }
+ return self::$instance;
+ }
+
+ /**
+ * Retreive any number of groups.
+ * @param array $data
+ * @return array Array of zero or more groups
+ */
+ public function read(array $data)
+ {
+ $start = isset($data['start']) ? $data['start'] : 0;
+ $filter = isset($data['filter']) ? $data['filter'] : 'none';
+ $query = $data['query'];
+ $sort = isset($data['sort']) ? $data['sort'] : 'DESC';
+ $order = $data['order'];
+ $allrows = $data['allrows'];
+ $dry_run = $data['dry_run'];
+
+ $ret = array();
+
+ $entity_table = 'fm_item_group';
+ $cols = array($entity_table.'.*');
+ $where_clauses = array(' WHERE 1=1');
+ $joins = array();
+
+ $sql = 'SELECT ' . implode($cols, ', ') .
+ " FROM $entity_table ".
+ implode($joins, ' ') .
+ implode($where_clauses, ' AND ');
+
+ $this->db->query($sql);
+ $i = 0;
+ while($this->db->next_record()) {
+ $items[$i]['id'] = $this->db->f('id');
+ $items[$i]['name'] = $this->db->f('name');
+ $items[$i]['ngno'] = $this->db->f('nat_group_no');
+ $items[$i]['bpn'] = $this->db->f('bpn');
+ $items[$i]['parent'] = $this->db->f('parent_group');
+ $items[$i]['catalog_id']= $this->db->f('catalog_id');
+
+ $i++;
+ }
+
+ return $items;
+ }
+
+ // TODO
+ public function read_single($id)
+ {
+
+ }
+
+
+
+ /**
+ * Creates fully populated objects out of an item array.
+ *
+ * @param array $items Array of items in the same format as that
returned from get_items().
+ * @return mixed Array of item objects og null if failed.
+ */
+ public function populate(array $groups) {
+ if(!is_array($groups)) {
+ return null;
+ }
+
+ $return_objects = array();
+ $socatalog = property_socatalog::get_instance();
+
+ foreach($groups as $group) {
+ $group_obj = new property_bogroup();
+ $group_obj->set_bpn($group['bpn']);
+ $group_obj->set_name($group['name']);
+ $group_obj->set_nat_group_no($group['ngno']);
+ $group_obj->set_catalog($socatalog->get($group['catalog_id']));
+
+ $return_objects[] = $group_obj;
+ }
+
+ return $return_objects;
+ }
+
+
+ }
Added: branches/dev-bim2/property/inc/class.uiitem.inc.php
===================================================================
--- branches/dev-bim2/property/inc/class.uiitem.inc.php
(rev 0)
+++ branches/dev-bim2/property/inc/class.uiitem.inc.php 2010-12-20 14:44:13 UTC
(rev 6685)
@@ -0,0 +1,473 @@
+<?php
+phpgw::import_class('phpgwapi.yui');
+phpgw::import_class('property.soitem');
+phpgw::import_class('property.soitem_group');
+phpgw::import_class('phpgwapi.datetime');
+/**
+ * FIXME: Description
+ * @package property
+ */
+
+class property_uiitem {
+ private $so;
+ private $sogroup;
+ private $bocommon;
+ public $public_functions = array
+ (
+ 'index' => true,
+ 'testdata' => true,
+ 'emptydb' => true
+ );
+
+ public function __construct() {
+ $this->bocommon = CreateObject('property.bocommon');
+
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+ $GLOBALS['phpgw_info']['flags']['menu_selection'] =
'property::item::index';
+
+ $this->so = property_soitem::singleton();
+ $this->sogroup = property_soitem_group::singleton();
+ }
+
+
+
+ function index() {
+ $menu_sub = array(
+ 'tenant'=>'invoice',
+ 'owner' =>'admin',
+ 'vendor'=>'invoice'
+ );
+
+ $dry_run = false;
+
+ $datatable = array();
+
+ if(phpgw::get_var('phpgw_return_as') != 'json') {
+ // Set base URL. FIXME: Add more URL parameters when needed
+ $datatable['config']['base_url'] =
$GLOBALS['phpgw']->link('/index.php', array
+ (
+ 'menuaction'=> 'property.uiitem.index',
+ ));
+ $datatable['config']['allow_allrows'] = true;
+ $datatable['config']['base_java_url'] =
"menuaction:'property.uiitem.index',"
+ ."group:'all'";
+
+ $values_combo_box_0 = $this->sogroup->read(null);
+ $default_value = array('id' => -1, 'name' => 'Alle grupper');
+ array_unshift($values_combo_box_0, $default_value);
+
+ $datatable['actions']['form'] = array(
+ array(
+ 'action' => $GLOBALS['phpgw']->link('/index.php',
+ array(
+ 'menuaction' => 'property.uiitem.index',
+ 'group_id' => 0
+ )
+ ),
+ 'fields' => array(
+ 'field' => array(
+ array(
+ 'id' => 'btn_group_id',
+ 'name' => 'group_id',
+ 'value' => lang('Group'),
+ 'type' => 'button',
+ 'style' => 'filter',
+ 'tab_index' => 1
+ ),
+ array(
+ 'type'=> 'link',
+ 'id' => 'btn_columns',
+ 'url' =>
"Javascript:window.open('".$GLOBALS['phpgw']->link('/index.php',
+ array(
+ 'menuaction' =>
'property.uiitem.columns',
+ 'role' => $this->role
+ ))."','','width=350,height=370')",
+ 'value' => lang('columns'),
+ 'tab_index' => 6
+ ),
+ array(
+ 'type' => 'button',
+ 'id' => 'btn_new',
+ 'value' => lang('add'),
+ 'tab_index' => 5
+ ),
+ array(
+ 'id' => 'btn_search',
+ 'name' => 'search',
+ 'value' => lang('search'),
+ 'type' => 'button',
+ 'tab_index' => 4
+ ),
+ array(
+ 'name' => 'query',
+ 'id' => 'txt_query',
+ 'value' => '',//$query,
+ 'type' => 'text',
+ 'onkeypress' => 'return pulsar(event)',
+ 'size' => 28,
+ 'tab_index' => 3
+ )
+ ),
+ 'hidden_value' => array(
+ array(
+ 'id' => 'values_combo_box_0',
+ 'value' =>
$this->bocommon->select2string($values_combo_box_0)
+ )
+ )
+ )
+ )
+ );
+
+ $dry_run=true;
+ }
+
+ $item_list = $this->so->read($dry_run);
+
+ $uicols = $this->so->uicols;
+ $uicols_count = count($uicols['name']);
+
+ $j=0;
+ if(is_array($item_list)) {
+ // For each item...
+ foreach($item_list as $item) {
+ // For each column definition...
+ for($i=0; $i < $uicols_count; $i++) {
+
+ if($uicols['input_type'][$i] != 'hidden') {
+ $datatable['rows']['row'][$j]['column'][$i]['value']
= $item[$uicols['name'][$i]];
+ $datatable['rows']['row'][$j]['column'][$i]['name']
= $uicols['name'][$i];
+ $datatable['rows']['row'][$j]['column'][$i]['lookup']
= '$lookup';
+ $datatable['rows']['row'][$j]['column'][$i]['align']
= (isset($uicols['align'][$i]) ? $uicols['align'][$i] : 'center');
+
+ /*if($uicols['datatype'][$i] == 'link' &&
$item[$uicols['name'][$i]]) {
+
$datatable['rows']['row'][$j]['column'][$i]['value'] = lang('link');
+
$datatable['rows']['row'][$j]['column'][$i]['link'] =
$item[$uicols['name'][$i]];
+
$datatable['rows']['row'][$j]['column'][$i]['target'] = '_blank';
+ }*/
+ }
+ else {
+ $datatable['rows']['row'][$j]['column'][$i]['name']
= $uicols['name'][$i];
+ $datatable['rows']['row'][$j]['column'][$i]['value']
= $item[$uicols['name'][$i]];
+ }
+
+ $datatable['rows']['row'][$j]['hidden'][$i]['value'] =
$item[$uicols['name'][$i]];
+ $datatable['rows']['row'][$j]['hidden'][$i]['name'] =
$uicols['name'][$i];
+ }
+
+ $j++;
+ }
+ }
+
+ // NO pop-up
+ $datatable['rowactions']['action'] = array();
+
+ $parameters = array
+ (
+ 'parameter' => array
+ (
+ array
+ (
+ 'name' => 'item_id',
+ 'source' => 'id'
+ )
+ )
+ );
+
+
+ $datatable['rowactions']['action'][] = array(
+ 'my_name' => 'view',
+ 'text' => lang('view'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction' => 'property.uiitem.view',
+ 'role' => $this->role
+ )),
+ 'parameters' => $parameters
+ );
+ $datatable['rowactions']['action'][] = array(
+ 'my_name' => 'view',
+ 'text' => lang('open view in new
window'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction' => 'property.uiitem.view',
+ 'role' => $this->role,
+ 'target' => '_blank'
+ )),
+ 'parameters' => $parameters
+ );
+
+
+ $datatable['rowactions']['action'][] = array(
+ 'my_name' => 'edit',
+ 'text' => lang('edit'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction'=> 'property.uiitem.edit',
+ 'role' => $this->role
+ )),
+ 'parameters' => $parameters
+ );
+ $datatable['rowactions']['action'][] = array(
+ 'my_name' => 'edit',
+ 'text' => lang('open edit in new
window'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction' => 'property.uiitem.edit',
+ 'role' => $this->role,
+ 'target' => '_blank'
+ )),
+ 'parameters' => $parameters
+ );
+
+ $datatable['rowactions']['action'][] = array(
+ 'my_name' => 'delete',
+ 'text' => lang('delete'),
+ 'confirm_msg' => lang('do you really want to delete this
entry'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction' => 'property.uiitem.delete',
+ 'role' => $this->role
+ )),
+ 'parameters' => $parameters
+ );
+ $datatable['rowactions']['action'][] = array(
+ 'my_name' => 'add',
+ 'text' => lang('add'),
+ 'action' =>
$GLOBALS['phpgw']->link('/index.php',array
+ (
+ 'menuaction' => 'property.uiitem.edit',
+ 'role' => $this->role
+ ))
+ );
+
+ unset($parameters);
+
+
+ for ($i=0; $i < $uicols_count; $i++) {
+
+ //all colums should be have formatter
+ $datatable['headers']['header'][$i]['formatter'] =
($uicols['formatter'][$i]==''? '""' : $uicols['formatter'][$i]);
+
+ if($uicols['input_type'][$i] != 'hidden') {
+ $datatable['headers']['header'][$i]['name']
= $uicols['name'][$i];
+ $datatable['headers']['header'][$i]['text']
= $uicols['descr'][$i];
+ $datatable['headers']['header'][$i]['visible']
= true;
+ $datatable['headers']['header'][$i]['format']
= $this->bocommon->translate_datatype_format($uicols['datatype'][$i]);
+ $datatable['headers']['header'][$i]['sortable']
= false;
+
+ // If datatype is not T or CH
+ if(!in_array($uicols['datatype'][$i], array('T', 'CH'))) {
+ $datatable['headers']['header'][$i]['sortable']
= true;
+ $datatable['headers']['header'][$i]['sort_field'] =
$uicols['name'][$i];
+ }
+ }
+ /*else {
+ $datatable['headers']['header'][$i]['name']
= 'id2';
+ $datatable['headers']['header'][$i]['text']
= $uicols['descr'][$i];
+ $datatable['headers']['header'][$i]['visible']
= false;
+ $datatable['headers']['header'][$i]['sortable']
= false;
+ $datatable['headers']['header'][$i]['format']
= 'hidden';
+ }*/
+ }
+
+ // path for property.js
+ $datatable['property_js'] =
$GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property.js";
+
+ // Pagination and sort values
+ $datatable['pagination']['records_start'] = (int)
$this->bo->start;
+ $datatable['pagination']['records_limit'] =
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+ $datatable['pagination']['records_returned']= count($item_list);
+ $datatable['pagination']['records_total'] =
$this->so->total_records();
+
+ //$datatable['sorting']['order'] = phpgw::get_var('order',
'string'); // Column
+ //$datatable['sorting']['sort'] = phpgw::get_var('sort',
'string'); // ASC / DESC
+
+
+ if((phpgw::get_var("start")== "") &&
(phpgw::get_var("order",'string')== ""))
+ {
+ $datatable['sorting']['order'] = 'id'; // name
key Column in myColumnDef
+ $datatable['sorting']['sort'] = 'asc'; // ASC
/ DESC
+ }
+ else
+ {
+ $datatable['sorting']['order'] =
phpgw::get_var('order', 'string'); // name of column of Database
+ $datatable['sorting']['sort'] =
phpgw::get_var('sort', 'string'); // ASC / DESC
+ }
+
+
+//-- BEGIN----------------------------- JSON CODE
------------------------------
+
+ //values for Pagination
+ $json = array
+ (
+ 'recordsReturned' =>
$datatable['pagination']['records_returned'],
+ 'totalRecords' =>
(int)$datatable['pagination']['records_total'],
+ 'startIndex' =>
$datatable['pagination']['records_start'],
+ 'sort' =>
$datatable['sorting']['order'],
+ 'dir' =>
$datatable['sorting']['sort'],
+ 'records' => array()
+ );
+
+ // values for datatable
+ if(isset($datatable['rows']['row']) &&
is_array($datatable['rows']['row'])) {
+ foreach( $datatable['rows']['row'] as $row ) {
+ $json_row = array();
+ foreach( $row['column'] as $column) {
+ if(isset($column['format']) && $column['format']==
"link" && $column['java_link']==true) {
+ $json_row[$column['name']] = "<a href='#'
id='".$column['link']."' onclick='javascript:filter_data(this.id);'>"
.$column['value']."</a>";
+ }
+ elseif(isset($column['format']) && $column['format']==
"link") {
+ $json_row[$column['name']] = "<a
href='".$column['link']."'>" .$column['value']."</a>";
+ }else {
+ $json_row[$column['name']] = $column['value'];
+ }
+ }
+ $json['records'][] = $json_row;
+ }
+ }
+
+ // right in datatable
+ if(isset($datatable['rowactions']['action']) &&
is_array($datatable['rowactions']['action'])) {
+ $json ['rights'] = $datatable['rowactions']['action'];
+ }
+
+ if( phpgw::get_var('phpgw_return_as') == 'json' )
+ {
+ return $json;
+ }
+ $datatable['json_data'] = json_encode($json);
+//-------------------- JSON CODE ----------------------
+
+ phpgwapi_yui::load_widget('dragdrop');
+ phpgwapi_yui::load_widget('datatable');
+ phpgwapi_yui::load_widget('menu');
+ phpgwapi_yui::load_widget('connection');
+ //// cramirez: necesary for include a partucular js
+ phpgwapi_yui::load_widget('loader');
+ //cramirez: necesary for use opener . Avoid error JS
+ phpgwapi_yui::load_widget('tabview');
+ phpgwapi_yui::load_widget('paginator');
+ //FIXME this one is only needed when $lookup==true - so there is
probably an error
+ phpgwapi_yui::load_widget('animation');
+
+ // Prepare template variables and process XSLT
+ $template_vars = array();
+ $template_vars['datatable'] = $datatable;
+ $GLOBALS['phpgw']->xslttpl->add_file(array('datatable'));
+ $GLOBALS['phpgw']->xslttpl->set_var('phpgw', $template_vars);
+
+ if ( !isset($GLOBALS['phpgw']->css) ||
!is_object($GLOBALS['phpgw']->css) ) {
+ $GLOBALS['phpgw']->css = createObject('phpgwapi.css');
+ }
+ // Prepare CSS Style
+ $GLOBALS['phpgw']->css->validate_file('datatable');
+ $GLOBALS['phpgw']->css->validate_file('property');
+
$GLOBALS['phpgw']->css->add_external_file('property/templates/base/css/property.css');
+
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/datatable/assets/skins/sam/datatable.css');
+
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/container/assets/skins/sam/container.css');
+
$GLOBALS['phpgw']->css->add_external_file('phpgwapi/js/yahoo/paginator/assets/skins/sam/paginator.css');
+
+ //Title of Page
+ $GLOBALS['phpgw_info']['flags']['app_header'] = lang('actor') . ': ' .
lang('list ' . $this->role);
+
+ // Prepare YUI Library
+ $GLOBALS['phpgw']->js->validate_file( 'yahoo', 'item.index',
'property' );
+
+ //$this->save_sessiondata();
+ }
+
+
+ public function testdata() {
+ // BIM testdata
+ $GLOBALS['phpgw']->db->transaction_begin();
+
+ $GLOBALS['phpgw']->db->query("INSERT INTO fm_item_catalog (name,
description) VALUES ('NOBB', 'Norsk Byggevarebase')");
+
+ $GLOBALS['phpgw']->db->query("INSERT INTO fm_item_group (name,
nat_group_no, bpn, parent_group, catalog_id) VALUES ('Doors', 'X', 123, NULL,
(SELECT id FROM fm_item_catalog WHERE name = 'NOBB' LIMIT 1))");
+ $GLOBALS['phpgw']->db->query("INSERT INTO fm_item_group (name,
nat_group_no, bpn, parent_group, catalog_id) VALUES ('Windows', 'X', 123, NULL,
(SELECT id FROM fm_item_catalog WHERE name = 'NOBB' LIMIT 1))");
+
+ $GLOBALS['phpgw']->db->query("INSERT INTO fm_attr_data_type
(display_name, function_name) VALUES ('integer', 'dt_int')");
+
+ $GLOBALS['phpgw']->db->query("INSERT INTO fm_attr_group (name, sort)
VALUES ('Dimensions', 1)");
+ $GLOBALS['phpgw']->db->query("INSERT INTO fm_attr_group (name, sort)
VALUES ('Layout', 2)");
+
+ $GLOBALS['phpgw']->db->query("INSERT INTO fm_attr_def
+ (name, display_name, description, data_type_id, unit_id,
attr_group_id)
+ VALUES (
+ 'height',
+ 'Height',
+ NULL,
+ (SELECT id FROM fm_attr_data_type WHERE function_name =
'dt_int'),
+ 'mm',
+ (SELECT id FROM fm_attr_group WHERE name = 'Dimensions')
+ )"
+ );
+ $GLOBALS['phpgw']->db->query("INSERT INTO fm_attr_def
+ (name, display_name, description, data_type_id, unit_id,
attr_group_id)
+ VALUES (
+ 'width',
+ 'Width',
+ NULL,
+ (SELECT id FROM fm_attr_data_type WHERE function_name =
'dt_int'),
+ 'mm',
+ (SELECT id FROM fm_attr_group WHERE name = 'Dimensions')
+ )"
+ );
+ $GLOBALS['phpgw']->db->query("INSERT INTO fm_attr_def
+ (name, display_name, description, data_type_id, unit_id,
attr_group_id)
+ VALUES (
+ 'depth',
+ 'Depth',
+ NULL,
+ (SELECT id FROM fm_attr_data_type WHERE function_name =
'dt_int'),
+ 'mm',
+ (SELECT id FROM fm_attr_group WHERE name = 'Dimensions')
+ )"
+ );
+ $GLOBALS['phpgw']->db->query("INSERT INTO fm_attr_def
+ (name, display_name, description, data_type_id, unit_id,
attr_group_id)
+ VALUES (
+ 'tiles',
+ 'No of tiles',
+ NULL,
+ (SELECT id FROM fm_attr_data_type WHERE function_name =
'dt_int'),
+ 'mm',
+ (SELECT id FROM fm_attr_group WHERE name = 'Layout')
+ )"
+ );
+ // Items
+ $GLOBALS['phpgw']->db->query("INSERT INTO fm_item
+ (group_id, location_id, vendor_id, installed)
+ VALUES (
+ (SELECT id FROM fm_item_group WHERE name = 'Doors'),
+ 1,
+ 1,
+ ".time()."
+ )"
+ );
+ $GLOBALS['phpgw']->db->query("INSERT INTO fm_item
+ (group_id, location_id, vendor_id, installed)
+ VALUES (
+ (SELECT id FROM fm_item_group WHERE name = 'Doors'),
+ 1,
+ 1,
+ ".time()."
+ )"
+ );
+ $GLOBALS['phpgw']->db->transaction_commit();
+ }
+
+ public function emptydb() {
+ $GLOBALS['phpgw']->db->query("DELETE FROM fm_item_attr");
+ $GLOBALS['phpgw']->db->query("DELETE FROM fm_item_group_attr");
+ $GLOBALS['phpgw']->db->query("DELETE FROM fm_attr_def");
+ $GLOBALS['phpgw']->db->query("DELETE FROM fm_attr_value");
+ $GLOBALS['phpgw']->db->query("DELETE FROM fm_attr_group");
+ $GLOBALS['phpgw']->db->query("DELETE FROM fm_attr_choice");
+ $GLOBALS['phpgw']->db->query("DELETE FROM fm_attr_data_type");
+ $GLOBALS['phpgw']->db->query("DELETE FROM fm_item");
+ $GLOBALS['phpgw']->db->query("DELETE FROM fm_item_group");
+ $GLOBALS['phpgw']->db->query("DELETE FROM fm_item_catalog");
+ }
+
+}
Added: branches/dev-bim2/property/js/yahoo/item.index.js
===================================================================
--- branches/dev-bim2/property/js/yahoo/item.index.js
(rev 0)
+++ branches/dev-bim2/property/js/yahoo/item.index.js 2010-12-20 14:44:13 UTC
(rev 6685)
@@ -0,0 +1,74 @@
+//--------------------------------------------------------
+// Declaration of actor.index vars
+//--------------------------------------------------------
+
+ //define SelectButton
+ var oMenuButton_0;
+ var selectsButtons = [
+ {order:0,
var_URL:'group_id',name:'btn_group_id',style:'districtbutton',dependiente:''}
+ ]
+
+ // define buttons
+ var oNormalButton_0, oNormalButton_1;
+ var normalButtons = [
+ {order:0, name:'btn_search', funct:"onSearchClick"},
+ {order:1, name:'btn_new', funct:"onNewClick"}
+ ]
+
+ // define Text buttons
+ var textImput = [
+ {order:0, name:'query', id:'txt_query'}
+ ]
+
+ // define the hidden column in datatable
+ var config_values = {
+ date_search : 0 //if search has link "Data search"
+ }
+
+ var linktoolTips =[
+ {name:'btn_columns', title:'columns', description:'Choose
columns'}
+ ]
+/****************************************************************************************/
+
+ this.particular_setting = function()
+ {
+ if(flag_particular_setting=='init')
+ {
+ //focus initial
+ oMenuButton_0.focus();
+ }
+ else if(flag_particular_setting=='update')
+ {
+ // nothing
+ }
+ }
+/****************************************************************************************/
+
+ this.myParticularRenderEvent = function()
+ {
+ //don't delete it
+ }
+/****************************************************************************************/
+
+ YAHOO.util.Event.addListener(window, "load", function()
+ {
+
YAHOO.util.Dom.getElementsByClassName('toolbar','div')[0].style.display =
'none';
+ var loader = new YAHOO.util.YUILoader();
+ loader.addModule({
+ name: "anyone", //module name; must be unique
+ type: "js", //can be "js" or "css"
+ fullpath: property_js //'property_js' have the path for
property.js, is render in HTML
+ });
+
+ loader.require("anyone");
+
+ //Insert JSON utility on the page
+
+ loader.insert();
+ });
+
+
+
+
+
+
Modified: branches/dev-bim2/property/setup/setup.inc.php
===================================================================
--- branches/dev-bim2/property/setup/setup.inc.php 2010-12-20 09:58:55 UTC
(rev 6684)
+++ branches/dev-bim2/property/setup/setup.inc.php 2010-12-20 14:44:13 UTC
(rev 6685)
@@ -12,7 +12,7 @@
*/
$setup_info['property']['name'] = 'property';
- $setup_info['property']['version'] = '0.9.17.600';
+ $setup_info['property']['version'] = '0.9.17.601';
$setup_info['property']['app_order'] = 8;
$setup_info['property']['enable'] = 1;
$setup_info['property']['app_group'] = 'office';
@@ -191,7 +191,17 @@
'fm_jasper_input_type',
'fm_jasper_format_type',
'fm_jasper_input',
- 'fm_custom_menu_items'
+ 'fm_custom_menu_items',
+ 'fm_item_catalog',
+ 'fm_item_group',
+ 'fm_item',
+ 'fm_attr_data_type',
+ 'fm_attr_def',
+ 'fm_attr_value',
+ 'fm_item_group_attr',
+ 'fm_item_attr',
+ 'fm_attr_choice',
+ 'fm_attr_group'
);
/* The hooks this app includes, needed for hooks registration */
Modified: branches/dev-bim2/property/setup/tables_current.inc.php
===================================================================
--- branches/dev-bim2/property/setup/tables_current.inc.php 2010-12-20
09:58:55 UTC (rev 6684)
+++ branches/dev-bim2/property/setup/tables_current.inc.php 2010-12-20
14:44:13 UTC (rev 6685)
@@ -2157,5 +2157,144 @@
'fk' => array(),
'ix' => array(),
'uc' => array()
+ ),
+ 'fm_item_catalog' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto','nullable' =>
False),
+ 'name' => array('type' => 'varchar',
'precision' => 50,'nullable' => False),
+ 'description' => array('type' =>
'text','nullable' => True)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+ 'fm_item_group' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto','nullable' =>
False),
+ 'name' => array('type' => 'varchar',
'precision' => 10,'nullable' => False),
+ 'nat_group_no' => array('type' => 'varchar',
'precision' => 5,'nullable' => False),
+ 'bpn' => array('type' => 'int', 'precision' =>
4,'nullable' => False),
+ 'parent_group' => array('type' => 'int',
'precision' => 4,'nullable' => True),
+ 'catalog_id' => array('type' => 'int',
'precision' => 4,'nullable' => False)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(
+ 'fm_item_catalog' => array('catalog_id' =>
'id'),
+ 'fm_item_group' => array('parent_group' =>
'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+ 'fm_item' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto','nullable' =>
False),
+ 'group_id' => array('type' => 'int',
'precision' => 4,'nullable' => False),
+ 'location_id' => array('type' => 'int',
'precision' => 4,'nullable' => False),
+ 'vendor_id' => array('type' => 'int',
'precision' => 4,'nullable' => False),
+ 'installed' => array('type' => 'int',
'precision' => 4,'nullable' => False)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(
+ 'fm_item_group' => array('group_id' => 'id'),
+ 'fm_locations' => array('location_id' => 'id'),
+ 'fm_vendor' => array('vendor_id' => 'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+ 'fm_attr_data_type' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto','nullable' =>
False),
+ 'display_name' => array('type' => 'varchar',
'precision' => 20,'nullable' => False),
+ 'function_name' => array('type' => 'varchar',
'precision' => 20,'nullable' => False)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+ 'fm_attr_def' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto','nullable' =>
False),
+ 'name' => array('type' => 'varchar',
'precision' => 10,'nullable' => False),
+ 'display_name' => array('type' => 'varchar',
'precision' => 20,'nullable' => False),
+ 'description' => array('type' =>
'text','nullable' => True),
+ 'data_type_id' => array('type' => 'int',
'precision' => 4,'nullable' => False),
+ 'unit_id' => array('type' => 'varchar',
'precision' => 20,'nullable' => False),
+ 'attr_group_id' => array('type' => 'int',
'precision' => 4,'nullable' => False)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(
+ 'fm_attr_group' => array('attr_group_id' =>
'id'),
+ 'fm_attr_group' => array('attr_group_id' =>
'id'),
+ 'fm_attr_data_type' => array('data_type_id' =>
'id'),
+ 'fm_standard_unit' => array('unit_id' => 'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+ 'fm_attr_value' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto','nullable' =>
False),
+ 'val_num' => array('type' => 'int', 'precision'
=> 4,'nullable' => True),
+ 'val_str' => array('type' => 'text','nullable'
=> True),
+ 'created_at' => array('type' => 'int',
'precision' => 4,'nullable' => True),
+ 'created_by' => array('type' => 'int',
'precision' => 4,'nullable' => True),
+ 'expired_at' => array('type' => 'int',
'precision' => 4,'nullable' => True),
+ 'expired_by' => array('type' => 'int',
'precision' => 4,'nullable' => True)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+ 'fm_item_group_attr' => array(
+ 'fd' => array(
+ 'group_id' => array('type' => 'int',
'precision' => 4,'nullable' => False),
+ 'attr_def_id' => array('type' => 'int',
'precision' => 4,'nullable' => False),
+ 'value_id' => array('type' => 'int',
'precision' => 4,'nullable' => False),
+ 'active' => array('type' => 'int', 'precision'
=> 4,'nullable' => False)
+ ),
+ 'pk' => array('attr_def_id','group_id'),
+ 'fk' => array(
+ 'fm_attr_def' => array('attr_def_id' => 'id'),
+ 'fm_item_group' => array('group_id' => 'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+ 'fm_item_attr' => array(
+ 'fd' => array(
+ 'item_id' => array('type' => 'int', 'precision'
=> 4,'nullable' => False),
+ 'attr_def_id' => array('type' => 'int',
'precision' => 4,'nullable' => False),
+ 'value_id' => array('type' => 'int',
'precision' => 4,'nullable' => False),
+ 'active' => array('type' => 'int', 'precision'
=> 4,'nullable' => False)
+ ),
+ 'pk' => array('attr_def_id','item_id'),
+ 'fk' => array(
+ 'fm_attr_def' => array('attr_def_id' => 'id'),
+ 'fm_item' => array('item_id' => 'id'),
+ 'fm_attr_value' => array('value_id' => 'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+ 'fm_attr_choice' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto','nullable' =>
False),
+ 'value_id' => array('type' => 'int',
'precision' => 4,'nullable' => False),
+ 'attr_def_id' => array('type' => 'int',
'precision' => 4,'nullable' => False)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array('fm_attr_def' => array('attr_def_id' =>
'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+ 'fm_attr_group' => array(
+ 'fd' => array(
+ 'id' => array('type' => 'auto','nullable' =>
False),
+ 'name' => array('type' => 'varchar',
'precision' => 20,'nullable' => False),
+ 'sort' => array('type' => 'int', 'precision' =>
4,'nullable' => False,'default' => '5')
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array()
)
);
Modified: branches/dev-bim2/property/setup/tables_update.inc.php
===================================================================
--- branches/dev-bim2/property/setup/tables_update.inc.php 2010-12-20
09:58:55 UTC (rev 6684)
+++ branches/dev-bim2/property/setup/tables_update.inc.php 2010-12-20
14:44:13 UTC (rev 6685)
@@ -4740,4 +4740,196 @@
return $GLOBALS['setup_info']['property']['currentver'];
}
}
+
+ /**
+ * Update property version from 0.9.17.600 to 0.9.17.601
+ * Add BIM tables
+ *
+ */
+ $test[] = '0.9.17.600';
+ function property_upgrade0_9_17_600()
+ {
+ $GLOBALS['phpgw']->locations->add('.admin.item', 'Items
administration', 'property');
+
+ $tables = array
+ (
+ 'fm_attr_data_type' => array
+ (
+ 'fd' => array(
+ 'id' => array('type' => 'auto', 'precision' => 4,
'nullable' => false),
+ 'display_name' => array('type' => 'varchar', 'precision'
=> 20, 'nullable' => false),
+ 'function_name' => array('type' => 'varchar', 'precision'
=> 20, 'nullable' => false)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array('display_name', 'function_name')
+ ),
+
+
+ 'fm_item_catalog' => array
+ (
+ 'fd' => array
+ (
+ 'id' => array('type' => 'auto',
'precision' => 4, 'nullable' => false),
+ 'name' => array('type' => 'varchar',
'precision' => 50, 'nullable' => false),
+ 'description' => array('type' =>
'text', 'nullable' => false)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+
+ 'fm_attr_group' => array
+ (
+ 'fd' => array(
+ 'id' => array('type' => 'auto', 'precision' => 4,
'nullable' => false),
+ 'name' => array('type' => 'varchar', 'precision' =>
20, 'nullable' => false),
+ 'sort' => array('type' => 'int', 'precision' => 4,
'nullable' => false, 'default' => 5)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array('name')
+ ),
+ 'fm_attr_def' => array
+ (
+ 'fd' => array
+ (
+ 'id' => array('type' => 'auto',
'precision' => 4, 'nullable' => false),
+ 'name' => array('type' => 'varchar',
'precision' => 10, 'nullable' => false),
+ 'display_name' => array('type' =>
'varchar', 'precision' => 20, 'nullable' => false),
+ 'description' => array('type' =>
'text', 'nullable' => false),
+ 'data_type_id' => array('type' =>
'int', 'precision' => 4, 'nullable' => false),
+ 'unit_id' => array('type' => 'varchar',
'precision' => 20, 'nullable' => false),
+ 'attr_group_id' => array('type' =>
'int', 'precision' => 4, 'nullable' => false)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array('fm_attr_data_type' =>
array('data_type_id' => 'id') ,
+
'fm_standard_unit' => array('unit_id' => 'id'),
+ 'fm_attr_group'
=> array('attr_group_id' => 'id')),
+ 'ix' => array(),
+ 'uc' => array('name')
+ ),
+
+ 'fm_attr_value' => array
+ (
+ 'fd' => array
+ (
+ 'id' => array('type' => 'auto',
'precision' => 4, 'nullable' => false),
+ 'val_num' => array('type' => 'int',
'precision' => 4, 'nullable' => true),
+ 'val_str' => array('type' => 'text',
'nullable' => true),
+ 'created_at' => array('type' => 'int',
'precision' => 4, 'nullable' => true),
+ 'created_by' => array('type' => 'int',
'precision' => 4, 'nullable' => true),
+ 'expired_at' => array('type' => 'int',
'precision' => 4, 'nullable' => true),
+ 'expired_by' => array('type' => 'int',
'precision' => 4, 'nullable' => true),
+ ),
+ 'pk' => array('id'),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+
+
+ 'fm_item_group' => array
+ (
+ 'fd' => array
+ (
+ 'id' => array('type' => 'auto',
'precision' => 4, 'nullable' => false),
+ 'name' => array('type' => 'varchar',
'precision' => 10, 'nullable' => false),
+ 'nat_group_no' => array('type' =>
'varchar', 'precision' => 5, 'nullable' => false),
+ 'bpn' => array('type' => 'int',
'precision' => 4, 'nullable' => false),
+ 'parent_group' => array('type' => 'int', 'precision' => 4,
'nullable' => true),
+ 'catalog_id' => array('type' => 'int', 'precision' => 4,
'nullable' => false)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array('fm_item_group' =>
array('parent_group' => 'id'), 'fm_item_catalog' => array('catalog_id' =>
'id')),
+ 'ix' => array(),
+ 'uc' => array('name')
+ ),
+
+
+ 'fm_item' => array
+ (
+ 'fd' => array
+ (
+ 'id' => array('type' => 'auto',
'precision' => 4, 'nullable' => false),
+ 'group_id' => array('type' => 'int',
'precision' => 4, 'nullable' => false),
+ 'location_id' => array('type' => 'int',
'precision' => 4, 'nullable' => false),
+ 'vendor_id' => array('type' => 'int',
'precision' => 4, 'nullable' => false),
+ 'installed' => array('type' => 'int',
'precision' => 4, 'nullable' => false),
+ ),
+ 'pk' => array('id'),
+ 'fk' => array('fm_item_group' =>
array('group_id' => 'id'),
+ 'fm_locations' => array('location_id' => 'id'),
+ 'fm_vendor' => array('vendor_id' => 'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+
+
+ 'fm_item_attr' => array
+ (
+ 'fd' => array
+ (
+ 'item_id' => array('type' => 'int',
'precision' => 4, 'nullable' => false),
+ 'attr_def_id' => array('type' => 'int',
'precision' => 4, 'nullable' => false),
+ 'value_id' => array('type' => 'int', 'precision' => 4,
'nullable' => false),
+ 'active' => array('type' => 'int',
'precision' => 4, 'nullable' => false, 'default' => 1)
+ ),
+ 'pk' => array('item_id', 'attr_def_id'),
+ 'fk' => array('fm_item' => array('item_id' =>
'id'),
+ 'fm_attr_def' => array('attr_def_id' => 'id'),
+ 'fm_attr_value' => array('value_id' => 'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+
+
+ 'fm_item_group_attr' => array
+ (
+ 'fd' => array
+ (
+ 'group_id' => array('type' => 'int',
'precision' => 4, 'nullable' => false),
+ 'attr_def_id' => array('type' => 'int',
'precision' => 4, 'nullable' => false),
+ 'value_id' => array('type' => 'int', 'precision' => 4,
'nullable' => false),
+ 'active' => array('type' => 'int',
'precision' => 4, 'nullable' => false, 'default' => 1)
+ ),
+ 'pk' => array('group_id', 'attr_def_id'),
+ 'fk' => array('fm_item_group' =>
array('group_id' => 'id'),
+ 'fm_attr_def' => array('attr_def_id' => 'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
+ 'fm_attr_choice' => array
+ (
+ 'fd' => array(
+ 'id' => array('type' => 'auto', 'precision' => 4,
'nullable' => false),
+ 'value_id' => array('type' => 'int', 'precision' => 4,
'nullable' => false),
+ 'attr_def_id' => array('type' => 'int', 'precision' =>
4, 'nullable' => false)
+ ),
+ 'pk' => array('id'),
+ 'fk' => array('fm_attr_def' => array('attr_def_id' =>
'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ )
+ );
+
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+ foreach ( $tables as $table => $def )
+ {
+ $GLOBALS['phpgw_setup']->oProc->CreateTable($table,
$def);
+ }
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['property']['currentver'] =
'0.9.17.601';
+ return $GLOBALS['setup_info']['property']['currentver'];
+ }
+ }
+
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [6685] Merge of dev-bim branch, revisions 4247 - 4564,
Petur Bjorn Thorsteinsson <=