fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [7888] Merge 7848:7887 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [7888] Merge 7848:7887 from trunk
Date: Mon, 17 Oct 2011 13:49:52 +0000

Revision: 7888
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=7888
Author:   sigurdne
Date:     2011-10-17 13:49:52 +0000 (Mon, 17 Oct 2011)
Log Message:
-----------
Merge 7848:7887 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/booking/js/booking/datatable.js
    branches/Version-1_0-branch/controller/inc/class.socontrol_item.inc.php
    branches/Version-1_0-branch/controller/inc/class.socontrol_item_list.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicontrol_group.inc.php
    branches/Version-1_0-branch/controller/inc/class.uicontrol_item.inc.php
    
branches/Version-1_0-branch/controller/inc/model/class.control_item_list.inc.php
    branches/Version-1_0-branch/controller/inc/model/class.model.inc.php
    branches/Version-1_0-branch/controller/inc/model/class.procedure.inc.php
    branches/Version-1_0-branch/controller/js/controller/custom_ui.js
    branches/Version-1_0-branch/controller/js/yahoo/datatable.js
    branches/Version-1_0-branch/controller/setup/phpgw_no.lang
    branches/Version-1_0-branch/controller/setup/tables_current.inc.php
    branches/Version-1_0-branch/controller/templates/base/control.xsl
    branches/Version-1_0-branch/controller/templates/base/control_group.xsl
    branches/Version-1_0-branch/controller/templates/base/control_groups.xsl
    branches/Version-1_0-branch/controller/templates/base/control_item.xsl
    branches/Version-1_0-branch/controller/templates/base/control_items.xsl
    
branches/Version-1_0-branch/controller/templates/base/control_items_receipt.xsl
    branches/Version-1_0-branch/controller/templates/base/css/base.css
    branches/Version-1_0-branch/controller/templates/base/datatable.xsl
    branches/Version-1_0-branch/phpgwapi/inc/class.custom_fields.inc.php
    branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc.inc.php
    branches/Version-1_0-branch/phpgwapi/setup/setup.inc.php
    branches/Version-1_0-branch/phpgwapi/setup/tables_current.inc.php
    branches/Version-1_0-branch/phpgwapi/setup/tables_update.inc.php
    branches/Version-1_0-branch/property/inc/class.bogeneric.inc.php
    branches/Version-1_0-branch/property/inc/class.custom_fields.inc.php
    branches/Version-1_0-branch/property/inc/class.uiadmin_entity.inc.php
    branches/Version-1_0-branch/property/inc/class.uigeneric.inc.php
    branches/Version-1_0-branch/property/inc/class.uilookup.inc.php
    branches/Version-1_0-branch/property/templates/base/admin_entity.xsl
    branches/Version-1_0-branch/property/templates/base/attributes_form.xsl
    branches/Version-1_0-branch/rental/inc/class.bofellesdata.inc.php

Added Paths:
-----------
    branches/Version-1_0-branch/controller/js/controller/ajax.js
    branches/Version-1_0-branch/controller/js/controller/custom_drag_drop.js
    branches/Version-1_0-branch/controller/js/controller/yui_drag_drop.js
    
branches/Version-1_0-branch/controller/templates/base/control_group_items.xsl
    branches/Version-1_0-branch/controller/templates/base/control_group_tabs.xsl

Removed Paths:
-------------
    branches/Version-1_0-branch/controller/js/controller/custom_drag_drop.js

Property Changed:
----------------
    branches/Version-1_0-branch/


Property changes on: branches/Version-1_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847
   + 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887

Modified: branches/Version-1_0-branch/booking/js/booking/datatable.js
===================================================================
--- branches/Version-1_0-branch/booking/js/booking/datatable.js 2011-10-17 
13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/booking/js/booking/datatable.js 2011-10-17 
13:49:52 UTC (rev 7888)
@@ -117,7 +117,15 @@
                };
                return true;
     }
-        
+
+       YAHOO.util.Event.on(
+           YAHOO.util.Selector.query('select'), 'change', function (e) {
+               //var val = this.value;
+                       var state = getState();
+                       YAHOO.util.Dom.setStyle('list_flash', 'display', 
'none');
+                       History.navigate('state', state);
+       });
+
     YAHOO.util.Event.addListener('queryForm', "submit", function(e){
         YAHOO.util.Event.stopEvent(e);
                var state = getState();
@@ -167,4 +175,4 @@
        History.initialize("yui-history-field", "yui-history-iframe");
 };
 
-YAHOO.util.Event.addListener(window, "load", 
YAHOO.booking.initializeDataTable);
\ No newline at end of file
+YAHOO.util.Event.addListener(window, "load", 
YAHOO.booking.initializeDataTable);

Modified: 
branches/Version-1_0-branch/controller/inc/class.socontrol_item.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.socontrol_item.inc.php     
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/inc/class.socontrol_item.inc.php     
2011-10-17 13:49:52 UTC (rev 7888)
@@ -73,21 +73,22 @@
                $id = intval($control_item->get_id());
                        
                $values = array(
-                       '$purpose = ' . 
$this->marshal($control_item->get_purpose(), 'string'),
-                       'responsibility = ' . 
$this->marshal($control_item->get_responsibility(), 'int'),
-                       'description = ' . 
$this->marshal($control_item->get_description(), 'int'),
-                       'reference = ' . 
$this->marshal($control_item->get_reference(), 'int'),
-                       'attachment = ' . 
$this->marshal($control_item->get_attachment(), 'int')
+                       'title = ' . $this->marshal($control_item->get_title(), 
'string'),
+                       'required = ' . 
$this->marshal(($control_item->get_required() ? 'true' : 'false'), 'bool'),
+                       'what_to_do = ' . 
$this->marshal($control_item->get_what_to_do(), 'string'),
+                       'how_to_do = ' . 
$this->marshal($control_item->get_how_to_do(), 'string'),
+                       'control_group_id = ' . 
$this->marshal($control_item->get_control_group_id(), 'int'),
+                       'control_area_id = ' . 
$this->marshal($control_item->get_control_area_id(), 'int')
                );
                
-               //var_dump('UPDATE activity_activity SET ' . join(',', $values) 
. " WHERE id=$id");
+               //var_dump('UPDATE controller_control_item SET ' . join(',', 
$values) . " WHERE id=$id");
                $result = $this->db->query('UPDATE controller_control_item SET 
' . join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
                
                return isset($result);
        }
        
        /**
-        * Get single procedure
+        * Get single control item
         * 
         * @param       $id     id of the control_item to return
         * @return a controller_control_item
@@ -95,8 +96,9 @@
        function get_single($id)
        {
                $id = (int)$id;
-               
-               $sql = "SELECT p.* FROM controller_control_item p WHERE p.id = 
" . $id;
+               $joins = " {$this->left_join} controller_control_group ON 
(p.control_group_id = controller_control_group.id)";
+               $joins .= " {$this->left_join} controller_control_area ON 
(p.control_area_id = controller_control_area.id)";
+               $sql = "SELECT p.*, controller_control_group.group_name AS 
control_group_name, controller_control_area.title AS control_area_name FROM 
controller_control_item p {$joins} WHERE p.id = " . $id;
                $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
                $this->db->next_record();
                
@@ -106,7 +108,9 @@
                
$control_item->set_what_to_do($this->unmarshal($this->db->f('what_to_do', 
true), 'string'));
                
$control_item->set_how_to_do($this->unmarshal($this->db->f('how_to_do', true), 
'string'));
                
$control_item->set_control_group_id($this->unmarshal($this->db->f('control_group_id',
 true), 'int'));
+               
$control_item->set_control_group_name($this->unmarshal($this->db->f('control_group_name',
 true), 'string'));
                
$control_item->set_control_area_id($this->unmarshal($this->db->f('control_area_id',
 true), 'int'));
+               
$control_item->set_control_area_name($this->unmarshal($this->db->f('control_area_name',
 true), 'string'));
                
                return $control_item;
        }
@@ -130,6 +134,7 @@
                
                //$sql = "SELECT * FROM controller_procedure WHERE $condition 
$order";
                $sql = "SELECT * FROM controller_control_item $order";
+               //var_dump($sql);
                $this->db->limit_query($sql, $start, __LINE__, __FILE__, 
$limit);
                
                while ($this->db->next_record()) {
@@ -197,6 +202,10 @@
                {
                        $filter_clauses[] = "controller_control_item.id = 
{$this->marshal($filters[$this->get_id_field_name()],'int')}";
                }
+               if(isset($filters['available']))
+               {
+                       $filter_clauses[] = 
"(controller_control_item.control_group_id IS NULL OR 
controller_control_item.control_group_id=0)";
+               }
                
                if(count($filter_clauses))
                {
@@ -232,11 +241,11 @@
                return "SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition} {$order}";
        }
        
-       function get_control_items($control_group_id)
+       function get_control_items(int $control_group_id)
        {
                $results = array();
                
-               $sql = "SELECT * FROM controller_control_item WHERE 
control_group_id=$control_group_id";
+               $sql = "SELECT * FROM controller_control_item WHERE 
control_group_id={$control_group_id}";
                $this->db->limit_query($sql, $start, __LINE__, __FILE__, 
$limit);
                
                while ($this->db->next_record()) {
@@ -250,7 +259,6 @@
                        
                        $results[] = $control_item;
                }
-               
                return $results;
        }
        

Modified: 
branches/Version-1_0-branch/controller/inc/class.socontrol_item_list.inc.php
===================================================================
--- 
branches/Version-1_0-branch/controller/inc/class.socontrol_item_list.inc.php    
    2011-10-17 13:46:34 UTC (rev 7887)
+++ 
branches/Version-1_0-branch/controller/inc/class.socontrol_item_list.inc.php    
    2011-10-17 13:49:52 UTC (rev 7888)
@@ -1,7 +1,7 @@
 <?php
 phpgw::import_class('controller.socommon');
 
-include_class('controller', 'control_item', 'inc/model/');
+include_class('controller', 'control_item_list', 'inc/model/');
 
 class controller_socontrol_item_list extends controller_socommon
 {
@@ -37,10 +37,7 @@
                        $this->marshal($control_item_list->get_control_id(), 
'int'),
                        
$this->marshal($control_item_list->get_control_item_id(), 'int')
                );
-
                
-               var_dump("INSERT INTO controller_control_item_list (' . 
join(',', $cols) . ') VALUES (' . join(',', $values) . ')' ");
-               
                $result = $this->db->query( 'INSERT INTO 
controller_control_item_list (' . join(',', $cols) . ') VALUES (' . join(',', 
$values) . ')', __LINE__,__FILE__);
                $result = $this->db->query($sql, __LINE__,__FILE__);
 
@@ -63,54 +60,73 @@
         * @return boolean true if successful, false otherwise
         */
 
+/**
+        * Update the database values for an existing activity object.
+        *
+        * @param $activity the activity to be updated
+        * @return boolean true if successful, false otherwise
+        */
+
        function update($control_item_list)
        {       
-               /*
-               $id = intval($control_item->get_id());
+               $id = intval($control_item_list->get_id());
                        
                $values = array(
-                       '$purpose = ' . 
$this->marshal($control_item->get_purpose(), 'string'),
-                       'responsibility = ' . 
$this->marshal($control_item->get_responsibility(), 'int'),
-                       'description = ' . 
$this->marshal($control_item->get_description(), 'int'),
-                       'reference = ' . 
$this->marshal($control_item->get_reference(), 'int'),
-                       'attachment = ' . 
$this->marshal($control_item->get_attachment(), 'int')
+                       'control_id = ' . 
$this->marshal($control_item_list->get_control_id(), 'int'),
+                       'control_item_id = '. 
$this->marshal($control_item_list->get_control_item_id(), 'int'),
+                       'order_nr = ' . 
$this->marshal($control_item_list->get_order_nr(), 'int')
                );
                
-               //var_dump('UPDATE activity_activity SET ' . join(',', $values) 
. " WHERE id=$id");
-               $result = $this->db->query('UPDATE controller_control_item SET 
' . join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
-               
+               $result = $this->db->query('UPDATE controller_control_item_list 
SET ' . join(',', $values) . " WHERE id=$id", __LINE__,__FILE__);
+                               
                return isset($result);
-               */
        }
        
        /**
-        * Get single procedure
+        * Get single control_item_list
         * 
-        * @param       $id     id of the control_item to return
-        * @return a controller_control_item
+        * @param       $id     id of the control_item_list to return
+        * @return a controller_control_item_list
         */
        function get_single($id)
        {
-               /*
                $id = (int)$id;
                
-               $sql = "SELECT p.* FROM controller_control_item p WHERE p.id = 
" . $id;
+               $sql = "SELECT p.* FROM controller_control_item_list p WHERE 
p.id = " . $id;
                $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
                $this->db->next_record();
                
-               $control_item = new 
controller_control_item($this->unmarshal($this->db->f('id', true), 'int'));
-               $control_item->set_title($this->unmarshal($this->db->f('title', 
true), 'string'));
-               
$control_item->set_required($this->unmarshal($this->db->f('required', true), 
'bool'));
-               
$control_item->set_what_to_do($this->unmarshal($this->db->f('what_to_do', 
true), 'string'));
-               
$control_item->set_how_to_do($this->unmarshal($this->db->f('how_to_do', true), 
'string'));
-               
$control_item->set_control_group_id($this->unmarshal($this->db->f('control_group_id',
 true), 'int'));
-               
$control_item->set_control_area_id($this->unmarshal($this->db->f('control_area_id',
 true), 'int'));
+               $control_item_list = new 
controller_control_item_list($this->unmarshal($this->db->f('id', true), 'int'));
+               
$control_item_list->set_control_id($this->unmarshal($this->db->f('control_id', 
true), 'int'));
+               
$control_item_list->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
 true), 'int'));
+               
$control_item_list->set_order_nr($this->unmarshal($this->db->f('order_nr', 
true), 'int'));
                
-               return $control_item;
+               return $control_item_list;
+       }
+       
+       function get_single_2($control_id, $control_item_id)
+       {               
+               $sql = "SELECT p.* FROM controller_control_item_list p WHERE 
p.control_id = " . $control_id . " AND p.control_item_id = " . $control_item_id;
+               $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
+               $this->db->next_record();
                
-               */
+               $control_item_list = new 
controller_control_item_list($this->unmarshal($this->db->f('id', true), 'int'));
+               
$control_item_list->set_control_id($this->unmarshal($this->db->f('control_id', 
true), 'int'));
+               
$control_item_list->set_control_item_id($this->unmarshal($this->db->f('control_item_id',
 true), 'int'));
+               
$control_item_list->set_order_nr($this->unmarshal($this->db->f('order_nr', 
true), 'int'));
+               
+               return $control_item_list;
        }
        
+       function delete($control_id, $control_item_id)
+       {               
+               var_dump("DELETE FROM controller_control_item_list WHERE 
control_id = $control_id AND control_item_id = $control_item_id");
+               
+               $result = $this->db->query("DELETE FROM 
controller_control_item_list WHERE control_id = $control_id AND control_item_id 
= $control_item_id", __LINE__,__FILE__);
+                               
+               return isset($result);
+       }
+       
        /**
         * Get a list of procedure objects matching the specific filters
         * 
@@ -231,7 +247,6 @@
                }
                $order = $sort_field ? "ORDER BY {$this->marshal($sort_field, 
'field')} $dir ": '';
                
-               //var_dump("SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition} {$order}");
                //return "SELECT {$cols} FROM {$tables} {$joins} WHERE 
{$condition} {$order}";
                
                return "SELECT {$cols} FROM {$tables} WHERE {$condition} 
{$order}";

Modified: branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php  
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php  
2011-10-17 13:49:52 UTC (rev 7888)
@@ -14,9 +14,9 @@
 
        class controller_uicontrol extends controller_uicommon
        {
-               private $bo; 
-               private $so;
-               private $so_proc;
+               private $bo;
+               private $so_control;
+               private $so_procedure;
                private $so_control_group;
                private $so_control_area; 
                private $so_control_item;
@@ -33,8 +33,8 @@
                {
                        parent::__construct();
 
-                       $this->so = CreateObject('controller.socontrol');
-                       $this->so_proc = CreateObject('controller.soprocedure');
+                       $this->so_control = 
CreateObject('controller.socontrol');
+                       $this->so_procedure = 
CreateObject('controller.soprocedure');
                        $this->bo = CreateObject('property.boevent',true);
                        $this->so_control_group = 
CreateObject('controller.socontrol_group');
                        $this->so_control_area = 
CreateObject('controller.socontrol_area');
@@ -146,219 +146,227 @@
                        self::render_template_xsl('datatable', $data);
                }
                
-               public function index()
+       public function index()
                {
-                       if( isset($_POST['save_control']) )
+                       $add_document_link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'controller.uiexample.index') );
+                       
+                       // Show tab control details
+                       if(phpgw::get_var('view') == "view_control")
                        {
+                               $this->view_control();
+                       }
+                       // Save or update control details and show tab control 
groups
+                       else if( isset($_POST['save_control']) || 
phpgw::get_var('view') == "view_control_groups")
+                       {
                                $this->edit_control();  
                        }
-                       else if( isset($_POST['save_control_groups']) )
+                       // Save control groups and show tab control items
+                       else if( isset($_POST['save_control_groups']) || 
phpgw::get_var('view') == "view_control_items")
                        {
                                $this->edit_control_groups();
                        }
+                       // Save control items and show tab receipt
                        else if( isset($_POST['save_control_items']) )
                        {
                                $this->edit_control_items();
                        }
-                       else if( isset($_POST['show_receipt']) )
+                       // Save receipt
+                       else if( isset($_POST['save_receipt']) )
                        {
-                               $this->show_receipt();
+                               $this->save_receipt();
                        }
                        else{
                                $this->view_control();
                        }
                }
                
-               public function view_control(){
-                       $tabs = array
-                       (
-                               'details'                       => 
array('label' => lang('Details'), 'link' => '#details'),
-                               'control_groups'        => array('label' => 
lang('Control_groups'), 'link' => '#control_groups'),
-                               'control_items'         => array('label' => 
lang('Control_items'), 'link' => '#control_items'), 
-                               'receipt'                       => 
array('label' => lang('Receipt'), 'link' => '#receipt')
-                       );
-                       
-                       $add_document_link = 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
'controller.uiexample.index') );
-                               
-                       $procedure_array = 
$this->so_proc->get_procedure_array();
-                               
-                       foreach ($procedure_array as $procedure)
+       public function view_control()
+               {                       
+                       $control_id = phpgw::get_var('control_id');
+               
+                       // view control details
+                       if(isset($control_id) && $control_id > 0)
                        {
-                               $procedure_options[] = $procedure->toArray();
+                               $control = 
$this->so_control->get_single($control_id);  
                        }
-                               
-                       $control_area_array = 
$this->so_control_area->get_control_area_array();
+                                                               
+                       $procedures_array = 
$this->so_procedure->get_procedures_as_array();
+                       $control_areas_array = 
$this->so_control_area->get_control_areas_as_array();
                        
-                       foreach ($control_area_array as $control_area)
-                       {
-                               $control_area_options[] = 
$control_area->toArray();
-                       }
+                       $tabs = array( array(
+                                                       'label' => 
lang('Details')
+                                               ), array(
+                                                       'label' => 
lang('Control_groups')
+                                               ), array(
+                                                       'label' => 
lang('Control_items')
+                                               ), array(
+                                                       'label' => 
lang('Receipt')
+                                               ));
                        
-                       phpgwapi_yui::tabview_setup('control_tabview');
-                       
-                       
$GLOBALS['phpgw']->richtext->replace_element('description');
-                       $GLOBALS['phpgw']->richtext->generate_script();
-                       
                        $data = array
                        (
-                               'tabs'                                          
=> phpgwapi_yui::tabview_generate($tabs, 'details'),
+                               'tabs'                                          
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 0),
+                               'view'                                          
=> "control_details",
+                               'editable'                                      
=> true,
+                               'control'                                       
=> (isset($control)) ? $control->toArray(): null,
+                               'control_areas_array'           => 
$control_areas_array,
+                               'procedures_array'                      => 
$procedures_array,
                                'start_date'                            => 
$GLOBALS['phpgw']->yuical->add_listener('start_date',date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],
 time())),
-                               'end_date'                                      
=> 
$GLOBALS['phpgw']->yuical->add_listener('end_date',date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],
 time())),
-                               'value_id'                                      
=> !empty($control) ? $control->get_id() : 0,
-                               'img_go_home'                           => 
'rental/templates/base/images/32x32/actions/go-home.png',
-                               'editable'                                      
=> true,
-                               'control_area_options'          => 
array('options' => $control_area_options),
-                               'procedure_options'                     => 
array('options' => $procedure_options)
+                               'end_date'                                      
=> 
$GLOBALS['phpgw']->yuical->add_listener('end_date',date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],
 time()))
                        );
                        
                        self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
-                       self::render_template_xsl(array('control_tabs', 
'control', 'control_groups', 'control_items', 'control_items_receipt'), $data);
+                       self::render_template_xsl(array('control_tabs', 
'control'), $data);
+                       
$GLOBALS['phpgw']->richtext->replace_element('description');
+                       $GLOBALS['phpgw']->richtext->generate_script();
                }
                
                
-               public function edit_control(){
+       public function edit_control()
+               {
+                       $control_id = phpgw::get_var('control_id');             
                        
-                       $tabs = array
-                       (
-                               'details'                       => 
array('label' => lang('Details'), 'link' => '#details'),
-                               'control_groups'        => array('label' => 
lang('Control_groups'), 'link' => '#control_groups'),
-                               'control_items'         => array('label' => 
lang('Control_items'), 'link' => '#control_items'),
-                               'receipt'                       => 
array('label' => lang('Receipt'), 'link' => '#receipt')
-                       );
-                       
-                       $control_area_id = phpgw::get_var('control_area_id', 
'int');    
-                       
-                       if(isset($control)) // Edit control
-                       {
-                               $control = $this->so->populate($control);
-                               //$this->so->add($control);
-                       }else{
-                               $new_control = new controller_control();
-                               $control = $this->so->populate($new_control);
-                               $saved_control_id = $this->so->add($control);
+                       if(phpgw::get_var('view') == "view_control_groups"){
+                               $control = 
$this->so_control->get_single($control_id);
                        }
-                       
-                       $control_group_array = 
$this->so_control_group->get_control_groups($control_area_id);
-                       
-                       $control_area = 
$this->so_control_area->get_single($control_area_id);
-                       
-                       foreach ($control_group_array as $control_group)
+                       // update control details
+                       else if(isset($control_id) && $control_id > 0 )
                        {
-                               $control_groups[] = $control_group->serialize();
+                               $control = 
$this->so_control->get_single($control_id);
+                               $control->populate();
+                               $this->so_control->store($control);
                        }
+                       // add control details
+                       else {
+                               $control = new controller_control();
+                               $control->populate();
+                               $control_id = 
$this->so_control->store($control);
+                       }
+                                               
+                       $control_area = 
$this->so_control_area->get_single($control->get_control_area_id());
+                                               
+                       $control_groups_as_array = 
$this->so_control_group->get_control_groups_as_array($control->get_control_area_id());
                        
-                       phpgwapi_yui::tabview_setup('control_tabview');
+                       $tabs = array(
+                                               array(
+                                                       'label' => 
lang('Details'),
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.index', 'view' => "view_control", 'control_id' => 
$control_id))
+                                               ), 
+                                               array(
+                                                       'label' => 
lang('Control_groups')
+                                               ), 
+                                               array(
+                                                       'label' => 
lang('Control_items')
+                                               ), 
+                                               array(
+                                                       'label' => 
lang('Receipt')
+                                               )
+                                       );
                        
                        $data = array
                        (
-                               'tabs'                                          
=> phpgwapi_yui::tabview_generate($tabs, 'control_groups'),
-                               'value_id'                                      
=> !empty($control) ? $control->get_id() : 0,
-                               'img_go_home'                           => 
'rental/templates/base/images/32x32/actions/go-home.png',
+                               'tabs'                                          
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
+                               'view'                                          
=> "control_groups",
                                'editable'                                      
=> true,
-                               'control_id'                            => 
$saved_control_id,
+                               'control_id'                            => 
$control_id,
                                'control_area'                          => 
$control_area->toArray(),
-                               'control_groups'                        => 
$control_groups                                      
+                               'control_groups'                        => 
$control_groups_as_array
                        );
                        
                        self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
-                       self::render_template_xsl(array('control_tabs', 
'control', 'control_groups', 'control_items', 'control_items_receipt'), $data);
+                       self::render_template_xsl(array('control_tabs', 
'control_groups'), $data);
                }
                
                public function edit_control_groups(){
                        
-                       $tabs = array
-                       (
-                               'details'                       => 
array('label' => lang('Details'), 'link' => '#details'),
-                               'control_groups'        => array('label' => 
lang('Control_groups'), 'link' => '#control_groups'),
-                               'control_items'         => array('label' => 
lang('Control_items'), 'link' => '#control_items'),
-                               'receipt'                       => 
array('label' => lang('Receipt'), 'link' => '#receipt')
-                       );
+                       $control_id = phpgw::get_var('control_id', 'int');
                        
-                       $control_id = phpgw::get_var('control_id', 'int');      
-                       
                        $control_group_ids = array();
                        $control_group_ids = 
phpgw::get_var('control_group_ids');
 
-                       $control_items_2D = array();
-                       
-                       // Fetching control items for each control group and 
populate array that is sent to xslt template
+                       $groups_with_control_items = array();
+                                       
+                       // Fetching control items for each control group and 
populates array
                        foreach ($control_group_ids as $control_group_id)
                        {       
-                               $control_items_array = 
$this->so_control_item->get_control_items($control_group_id);    
+                               $group_control_items_array = 
$this->so_control_item->get_control_items_as_array($control_group_id);
                                
-                               $control_items = array();
-                               
-                               foreach ($control_items_array as $control_item)
-                               {
-                                       $control_items[] = 
$control_item->serialize();
-                               }                                       
-
                                $control_group = 
$this->so_control_group->get_single($control_group_id);
                                
-                               $control_items_2D[] = array("control_group" => 
$control_group->toArray(), "control_item" => $control_items);
-                       }
+                               $groups_with_control_items[] = 
array("control_group" => $control_group->toArray(), "group_control_items" => 
$group_control_items_array);
+                       }                       
                        
-                       phpgwapi_yui::tabview_setup('control_tabview');
+                       $tabs = array(
+                                               array(
+                                                       'label' => 
lang('Details'),
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.index', 'view' => "view_control", 'control_id' => 
$control_id))
+                                               ), 
+                                                       array(
+                                                       'label' => 
lang('Control_groups'),
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.index', 'view' => "view_control_groups", 
+                                                                               
                                                                               
'control_id' => $control_id, 'control_group_ids' => $control_group_ids))
+                                               ), 
+                                               array(
+                                                       'label' => 
lang('Control_items')
+                                               ), 
+                                               array(
+                                                       'label' => 
lang('Receipt')
+                                               )
+                                       );
                        
+                       
                        $data = array
                        (
-                               'tabs'                                  => 
phpgwapi_yui::tabview_generate($tabs, 'control_items'),
-                               'value_id'                              => 
!empty($control) ? $control->get_id() : 0,
-                               'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
-                               'choose_control_items'  => true,
-                               'control_id'                    => $control_id,
-                               'control_items'                 => 
$control_items_2D                    
+                               'tabs'                                          
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 2),
+                               'view'                                          
=> 'control_items',
+                               'control_group_ids'                     => 
implode($control_group_ids, ","),
+                               'control_id'                            => 
$control_id,
+                               'groups_with_control_items'     => 
$groups_with_control_items                   
                        );
                        
                        self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
                        self::add_javascript('controller', 'controller', 
'jquery.js');
                        self::add_javascript('controller', 'controller', 
'custom_ui.js');
-                       self::render_template_xsl(array('control_tabs', 
'control', 'control_groups', 'control_items', 'control_items_receipt'), $data);
+                       self::render_template_xsl(array('control_tabs', 
'control_items'), $data);
                }
                
-               public function edit_control_items(){
-                       
-                       //Setting up tab menu
-                       $tabs = array
-                       (
-                               'details'                       => 
array('label' => lang('Details'), 'link' => '#details'),
-                               'control_groups'        => array('label' => 
lang('Control_groups'), 'link' => '#control_groups'),
-                               'control_items'         => array('label' => 
lang('Control_items'), 'link' => '#control_items'),
-                               'receipt'                       => 
array('label' => lang('Receipt'), 'link' => '#receipt')
-                       );
-                               
+       public function edit_control_items()
+               {
                        $control_id = phpgw::get_var('control_id');
+                       $control_group_ids = 
phpgw::get_var('control_group_ids');
                        
-                       $control_item_ids = array();
                        // Fetching selected control items
                        $control_tag_ids = phpgw::get_var('control_tag_ids');
                        
-                       // Saving control items
+                       $control_item_ids = array();
+
+                       // Saving control items if submit save control items is 
clicked 
                        foreach ($control_tag_ids as $control_item_tag)
                        {       
-                               $control_item_id = substr($control_item_tag, 2, 
2);
-                               
+                               // Fetch control_item_id from tag string
+                               $control_item_id = substr($control_item_tag, 
strpos($control_item_tag, ":")+1, strlen($control_item_tag));
+                                                       
+                               // Saves control item
                                $control_item_list = new 
controller_control_item_list();
                                $control_item_list->set_control_id($control_id);
                                
$control_item_list->set_control_item_id($control_item_id);
-                                                               
                                
$this->so_control_item_list->add($control_item_list);
-                       }
-                       
+                       }       
+       
                        $control_group_ids = array();
                        
-                       //Putting control_group_ids in array
+                       //Putting control_group_ids in array control_group_ids
                        foreach ($control_tag_ids as $control_tag)
                        {       
-                               $control_group_id = substr($control_tag, 0, 1);
+                               $control_group_id = substr($control_tag, 0, 
strpos($control_tag, ":"));
 
                                if(!in_array($control_group_id, 
$control_group_ids))
                                        $control_group_ids[] = 
$control_group_id;  
                        }
                        
-                       $control_receipt_items = array();
+                       $saved_groups_with_items_array = array();
                        
-                       //Populating array that is displayed as receipe
+                       //Populating array with saved control items for each 
group
                        foreach ($control_group_ids as $control_group_id)
                        {       
                                $saved_control_items = 
$this->so_control_item->get_control_items_by_control_id_and_group($control_id, 
$control_group_id);
@@ -367,68 +375,69 @@
                                
                                $control_item = 
$this->so_control_item->get_single($control_item_id);
                                
-                               $control_receipt_items[] = 
array("control_group" => $control_group->toArray(), "control_items" => 
$saved_control_items);  
+                               $saved_groups_with_items_array[] = 
array("control_group" => $control_group->toArray(), "control_items" => 
$saved_control_items);
                        }
                        
-                       var_dump("Skriver ut control_receipt");
-                       print_r($control_receipt_items);
-                                               
-                       phpgwapi_yui::tabview_setup('control_tabview');
-                                       
+                       unset($_POST['save_control_items']); 
+                       
+                       $tabs = array(
+                                               array(
+                                                       'label' => 
lang('Details'),
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.index', 'view' => "view_control", 'control_id' => 
$control_id))
+                                               ), 
+                                               array(
+                                                       'label' => 
lang('Control_groups'),
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.index', 'view' => "view_control_groups", 
+                                                                               
                                                                               
'control_id' => $control_id, 'control_group_ids' => $control_group_ids))
+                                               ), 
+                                               array(
+                                                       'label' => 
lang('Control_items'),
+                                                       'link'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'controller.uicontrol.index', 'view' => "view_control_items", 
+                                                                               
                                                                               
'control_id' => $control_id, 'control_group_ids' => $control_group_ids))
+                                               ), 
+                                               array(
+                                                       'label' => 
lang('Receipt')
+                                               )
+                                       );
+                       
                        $data = array
                        (
-                               'tabs'                                  => 
phpgwapi_yui::tabview_generate($tabs, 'receipt'),
-                               'value_id'                              => 
!empty($control) ? $control->get_id() : 0,
-                               'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
+                               'tabs'                                  => 
$GLOBALS['phpgw']->common->create_tabs($tabs, 3),
+                               'view'                                  => 
"receipt",
                                'control_id'                    => $control_id,
-                               'control_receipt_items' => 
$control_receipt_items                       
+                               'control_receipt_items' => 
$saved_groups_with_items_array
                        );
                        
                        self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
                        self::add_javascript('controller', 'controller', 
'jquery.js');
                        self::add_javascript('controller', 'controller', 
'custom_ui.js');
+                       self::add_javascript('controller', 'controller', 
'ajax.js');
                        self::add_javascript('controller', 'controller', 
'yui_min_3_4_3.js');
                        self::add_javascript('controller', 'controller', 
'custom_drag_drop.js');
-                       self::render_template_xsl(array('control_tabs', 
'control', 'control_groups', 'control_items', 'control_items_receipt'), $data);
-
+                       self::render_template_xsl(array('control_tabs', 
'control_items_receipt'), $data);
                }
                
-               public function show_receipt(){
+       public function save_receipt(){
                        
-                       $tabs = array
-                       (
-                               'details'                       => 
array('label' => lang('Details'), 'link' => '#details'),
-                               'control_groups'        => array('label' => 
lang('Control_groups'), 'link' => '#control_groups'),
-                               'control_items'         => array('label' => 
lang('Control_items'), 'link' => '#control_items'),
-                               'receipt'                       => 
array('label' => lang('Receipt'), 'link' => '#receipt')
-                       );              
-                       
                        $control_id = phpgw::get_var('control_id');
                        
                        $control_item_ids = array();
                        $control_item_ids = phpgw::get_var('control_item_ids');
                        
-                       
-                       
                        foreach ($control_item_ids as $control_item_id)
-                       {       
+                       {
                                $control_item = 
$this->so_control_item->get_single($control_item_id);
                                                
                                $control_item_list = new 
controller_control_item_list();
                                $control_item_list->set_control_id($control_id);
                                
$control_item_list->set_control_item_id($control_item->get_id());
-                                                               
+                               
                                
$this->so_control_item_list->add($control_item_list);
                        }
                        
-                       phpgwapi_yui::tabview_setup('control_tabview');
-                       
                        $data = array
                        (
-                               'tabs'                                  => 
phpgwapi_yui::tabview_generate($tabs, 'control_items'),
-                               'value_id'                              => 
!empty($control) ? $control->get_id() : 0,
-                               'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
-                               'edit_control_items'    => false,
+                               'tabs'                                  => 
$GLOBALS['phpgw']->common->create_tabs($this->getTabMenu(), 3),
                                'control_id'                    => $control_id,
                                'control_items'                 => 
$control_items_2D                    
                        );
@@ -436,8 +445,7 @@
                        self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
                        self::add_javascript('controller', 'controller', 
'jquery.js');
                        self::add_javascript('controller', 'controller', 
'custom_ui.js');
-                       self::render_template_xsl(array('control_tabs', 
'control', 'control_groups', 'control_items', 'control_items_receipt'), $data);
-
+                       self::render_template_xsl(array('control_tabs', 
'control_items_receipt'), $data);
                }
                
                

Modified: 
branches/Version-1_0-branch/controller/inc/class.uicontrol_group.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicontrol_group.inc.php    
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol_group.inc.php    
2011-10-17 13:49:52 UTC (rev 7888)
@@ -13,6 +13,7 @@
                private $so;
                private $so_procedure;
                private $so_control_area;
+               private $so_control_item;
                
                public $public_functions = array
                (
@@ -29,6 +30,7 @@
                        $this->so = CreateObject('controller.socontrol_group');
                        $this->so_procedure = 
CreateObject('controller.soprocedure');
                        $this->so_control_area = 
CreateObject('controller.socontrol_area');
+                       $this->so_control_item = 
CreateObject('controller.socontrol_item');
                        $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"controller::control_group";
                }
                
@@ -150,7 +152,14 @@
                
                public function edit()
                {
+                       $tabs = array
+                       (
+                               'control_group'         => array('label' => 
lang('Control_group'), 'link' => '#control_group'),
+                               'control_items'         => array('label' => 
lang('Control_items'), 'link' => '#control_items')
+                       );
+                       $tab_to_display = 'control_group';
                        $control_group_id = phpgw::get_var('id');
+                       $new_control_group = false;
                        if(isset($control_group_id) && $control_group_id > 0)
                        {
                                $control_group = 
$this->so->get_single($control_group_id);
@@ -158,6 +167,7 @@
                        else
                        {
                                $control_group = new controller_control_group();
+                               $new_control_group = true;
                        }
 
                        if(isset($_POST['save_control_group'])) // The user has 
pressed the save button
@@ -195,7 +205,14 @@
                                                        $error = 
lang('messages_form_error');
                                                }
                                        }
-                                       
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uicontrol_group.view', 'id' => $ctrl_group_id));
+                                       if($new_control_group)
+                                       {
+                                               
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uicontrol_group.edit', 'id' => $ctrl_group_id));
+                                       }
+                                       else
+                                       {
+                                               
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uicontrol_group.view', 'id' => $ctrl_group_id));
+                                       }
                                }
                        }
                        else if(isset($_POST['cancel_control_group'])) // The 
user has pressed the cancel button
@@ -209,11 +226,139 @@
                                        
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' => 
'controller.uicontrol_group.index'));
                                }
                        }
+                       else if(isset($_POST['remove_control_group_items']))
+                       {
+                               $control_item_ids = array();
+                               // Fetching selected control items
+                               $control_tag_ids = 
phpgw::get_var('item_remove_ids');
+                               
+                               foreach ($control_tag_ids as $control_item_id)
+                               {
+                                       $curr_control_item = 
$this->so_control_item->get_single($control_item_id);
+                                       
$curr_control_item->set_control_group_id(null);
+                                                                       
+                                       
$this->so_control_item->store($curr_control_item);
+                               }
+                               
+                               $control_area_array = 
$this->so_control_area->get_control_area_array();
+                               $procedure_array = 
$this->so_procedure->get_procedures();
+                               
+       
+                               if($this->flash_msgs)
+                               {
+                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($this->flash_msgs);
+                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+                               }
+       
+                               foreach ($control_area_array as $control_area)
+                               {
+                                       
if($control_group->get_control_area_id() && $control_area->get_id() == 
$control_group->get_control_area_id())
+                                       {
+                                               $control_area_options[] = array
+                                               (
+                                                       'id'    => 
$control_area->get_id(),
+                                                       'name'  => 
$control_area->get_title(),
+                                                       'selected' => 'yes'
+                                               );
+                                       }
+                                       else
+                                       {
+                                               $control_area_options[] = array
+                                               (
+                                                       'id'    => 
$control_area->get_id(),
+                                                       'name'  => 
$control_area->get_title()
+                                               );
+                                       }
+                               }
+       
+                               foreach ($procedure_array as $procedure)
+                               {
+                                       if($control_group->get_procedure_id() 
&& $procedure->get_id() == $control_group->get_procedure_id())
+                                       {
+                                               $procedure_options[] = array
+                                               (
+                                                       'id'    => 
$procedure->get_id(),
+                                                       'name'  => 
$procedure->get_title(),
+                                                       'selected' => 'yes'
+                                               );
+                                       }
+                                       else
+                                       {
+                                               $procedure_options[] = array
+                                               (
+                                                       'id'    => 
$procedure->get_id(),
+                                                       'name'  => 
$procedure->get_title()
+                                               );
+                                       }
+                               }
+                               
+                               $building_part_options = 
$this->so->get_building_part_select_array($control_group->get_building_part_id());
+                               
+                               $control_group_array = 
$control_group->toArray();
+                               $control_items_array = 
$this->so_control_item->get(null,null,'controller_control_item.control_area_id',true,null,null,array('available'
 => 'yes'));
+                               
+                               $control_items = array();
+                               
+                               foreach ($control_items_array as $control_item)
+                               {
+                                       $control_items[] = 
$control_item->serialize();
+                               }
+                               
+                               $selected_control_items_array = 
controller_socontrol_item::get_instance()->get_control_items($control_group->get_id());
+                               
+                               $selected_control_items = array();
+                               
+                               foreach ($selected_control_items_array as 
$ctrl_item)
+                               {
+                                       $selected_control_items[] = 
$ctrl_item->serialize();
+                               }
+                               
phpgwapi_yui::tabview_setup('control_group_tabview');
+       
+                               $data = array
+                               (
+                                       'tabs'                                  
        => phpgwapi_yui::tabview_generate($tabs, 'control_items'),
+                                       'value_id'                              
        => !empty($control_group) ? $control_group->get_id() : 0,
+                                       'img_go_home'                           
=> 'rental/templates/base/images/32x32/actions/go-home.png',
+                                       'editable'                              
        => true,
+                                       'procedure'                             
        => array('options' => $procedure_options),
+                                       'control_area'                          
=> array('options' => $control_area_options),
+                                       'control_group'                         
=> $control_group_array,
+                                       'control_items'                         
=> $control_items,
+                                       'selected_control_items'        => 
$selected_control_items,
+                                       'building_part'                         
=> array('building_part_options' => $building_part_options),
+                               );
+       
+       
+                               $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('controller') . '::' . lang('Control_group');
+       
+                               self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
+                               
self::render_template_xsl(array('control_group_tabs','control_group','control_group_items'),
 $data);
+                       }
+                       else if(isset($_POST['save_control_group_items']))
+                       {
+                               $tab_to_display = 'control_group_items';
+                               //update control items with control group id
+                               //$control_group_id = 
phpgw::get_var('control_group_id');
+                               
+                               $control_item_ids = array();
+                               // Fetching selected control items
+                               $control_tag_ids = 
phpgw::get_var('control_tag_ids');
+                               
+                               foreach ($control_tag_ids as $control_item_id)
+                               {
+                                       $curr_control_item = 
$this->so_control_item->get_single($control_item_id);
+                                       
$curr_control_item->set_control_group_id($control_group_id);
+                                                                       
+                                       
$this->so_control_item->store($curr_control_item);
+                               }
+                               
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol_group.view', 'id' => 
$control_group_id));
+                       }
                        else
                        {
                        
                                $control_area_array = 
$this->so_control_area->get_control_area_array();
-                               $procedure_array = 
$this->so_procedure->get_procedure_array();
+                               $procedure_array = 
$this->so_procedure->get_procedures();
                                
        
                                if($this->flash_msgs)
@@ -267,16 +412,37 @@
                                $building_part_options = 
$this->so->get_building_part_select_array($control_group->get_building_part_id());
                                
                                $control_group_array = 
$control_group->toArray();
+                               $control_items_array = 
$this->so_control_item->get(null,null,'controller_control_item.control_area_id',true,null,null,array('available'
 => 'yes'));
+                               
+                               $control_items = array();
+                               
+                               foreach ($control_items_array as $control_item)
+                               {
+                                       $control_items[] = 
$control_item->serialize();
+                               }
+                               
+                               $selected_control_items_array = 
controller_socontrol_item::get_instance()->get_control_items($control_group->get_id());
+                               
+                               $selected_control_items = array();
+                               
+                               foreach ($selected_control_items_array as 
$ctrl_item)
+                               {
+                                       $selected_control_items[] = 
$ctrl_item->serialize();
+                               }
+                               
phpgwapi_yui::tabview_setup('control_group_tabview');
        
                                $data = array
                                (
-                                       'value_id'                              
=> !empty($control_group) ? $control_group->get_id() : 0,
-                                       'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
-                                       'editable'                              
=> true,
-                                       'procedure'                             
=> array('options' => $procedure_options),
-                                       'control_area'                  => 
array('options' => $control_area_options),
-                                       'control_group'                 => 
$control_group_array,
-                                       'building_part'                 => 
array('building_part_options' => $building_part_options),
+                                       'tabs'                                  
        => phpgwapi_yui::tabview_generate($tabs, $tab_to_display),
+                                       'value_id'                              
        => !empty($control_group) ? $control_group->get_id() : 0,
+                                       'img_go_home'                           
=> 'rental/templates/base/images/32x32/actions/go-home.png',
+                                       'editable'                              
        => true,
+                                       'procedure'                             
        => array('options' => $procedure_options),
+                                       'control_area'                          
=> array('options' => $control_area_options),
+                                       'control_group'                         
=> $control_group_array,
+                                       'control_items'                         
=> $control_items,
+                                       'selected_control_items'        => 
$selected_control_items,
+                                       'building_part'                         
=> array('building_part_options' => $building_part_options),
                                );
        
        
@@ -290,184 +456,11 @@
        
        //                      $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'controller.item', 'controller' );
        
-                               self::render_template_xsl('control_group', 
$data);
+                               self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
+                               
self::render_template_xsl(array('control_group_tabs','control_group','control_group_items'),
 $data);
                        }
                }
 
-/*             public function display_control_items()
-               {
-                       //$GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"controller::control_item_list";
-                       
-                       
self::set_active_menu('controller::control_item::control_item_list');
-                       if(phpgw::get_var('phpgw_return_as') == 'json') {
-                               return $this->display_control_items_json();
-                       }
-                       
-                       self::add_javascript('controller', 'yahoo', 
'datatable.js');
-                       phpgwapi_yui::load_widget('datatable');
-                       phpgwapi_yui::load_widget('paginator');
-                       
-                       $data = array(
-                               'form' => array(
-                                       'toolbar' => array(
-                                               'item' => array(
-                                                       array(
-                                                               'type' => 
'link',
-                                                               'value' => 
lang('New application'),
-                                                               'href' => 
self::link(array('menuaction' => 'controller.uicontrol_item.index'))
-                                                       ),
-                                                       array('type' => 
'filter', 
-                                                               'name' => 
'status',
-                                'text' => lang('Status').':',
-                                'list' => array(
-                                    array(
-                                        'id' => 'none',
-                                        'name' => lang('Not selected')
-                                    ), 
-                                    array(
-                                        'id' => 'NEW',
-                                        'name' => lang('NEW')
-                                    ), 
-                                    array(
-                                        'id' => 'PENDING',
-                                        'name' =>  lang('PENDING')
-                                    ), 
-                                    array(
-                                        'id' => 'REJECTED',
-                                        'name' => lang('REJECTED')
-                                    ), 
-                                    array(
-                                        'id' => 'ACCEPTED',
-                                        'name' => lang('ACCEPTED')
-                                    )
-                                )
-                            ),
-                                                       array('type' => 
'filter',
-                                                               'name' => 
'control_groups',
-                                'text' => lang('Control_group').':',
-                                'list' => 
$this->so_control_group->get_control_group_select_array(),
-                                                       ),
-                                                       array('type' => 
'filter',
-                                                               'name' => 
'control_areas',
-                                'text' => lang('Control_area').':',
-                                'list' => 
$this->so_control_area->get_control_area_select_array(),
-                                                       ),
-                                                       array('type' => 'text', 
-                                'text' => lang('searchfield'),
-                                                               'name' => 
'query'
-                                                       ),
-                                                       array(
-                                                               'type' => 
'submit',
-                                                               'name' => 
'search',
-                                                               'value' => 
lang('Search')
-                                                       ),
-                                                       array(
-                                                               'type' => 
'link',
-                                                               'value' => 
$_SESSION['showall'] ? lang('Show only active') : lang('Show all'),
-                                                               'href' => 
self::link(array('menuaction' => $this->url_prefix.'.toggle_show_inactive'))
-                                                       ),
-                                               ),
-                                       ),
-                               ),
-                               'datatable' => array(
-                                       'source' => 
self::link(array('menuaction' => 
'controller.uicontrol_item.display_control_items', 'phpgw_return_as' => 
'json')),
-                                       'field' => array(
-                                               array(
-                                                       'key' => 'id',
-                                                       'label' => lang('ID'),
-                                                       'sortable'      => true,
-                                                       'formatter' => 
'YAHOO.portico.formatLink'
-                                               ),                              
                
-                                               array(
-                                                       'key' => 'title',
-                                                       'label' => 
lang('Title'),
-                                                       'sortable'      => false
-                                               ),
-                                               array(
-                                                       'key' => 'required',
-                                                       'label' => 
lang('Required'),
-                                                       'sortable'      => true
-                                               ),
-                                               array(
-                                                       'key' => 'what_to_do',
-                                                       'label' => lang('What 
to do'),
-                                                       'sortable'      => false
-                                               ),
-                                               array(
-                                                       'key' => 'how_to_do',
-                                                       'label' => lang('How to 
do'),
-                                                       'sortable'      => true
-                                               ),
-                                               array(
-                                                       'key' => 
'control_group_id',
-                                                       'label' => 
lang('control_group_id'),
-                                                       'sortable'      => true
-                                               ),
-                                               array(
-                                                       'key' => 
'control_area_id',
-                                                       'label' => 
lang('control_area_id'),
-                                                       'sortable'      => true
-                                               ),
-                                               array(
-                                                       'key' => 'link',
-                                                       'hidden' => true
-                                               )
-                                       )
-                               ),
-                       );
-//_debug_array($data);
-
-                       self::render_template_xsl('datatable', $data);
-               }
-*/
-               
-/*             public function display_control_items_json()
-               {
-                       $params = array(
-                               'start' => phpgw::get_var('startIndex', 'int', 
'REQUEST', 0),
-                               'results' => phpgw::get_var('results', 'int', 
'REQUEST', null),
-                               'query' => phpgw::get_var('query'),
-                               'sort'  => phpgw::get_var('sort'),
-                               'dir'   => phpgw::get_var('dir'),
-                               'filters' => $filters
-                       );
-
-                       $user_rows_per_page = 10;
-                       
-                       // YUI variables for paging and sorting
-                       $start_index    = phpgw::get_var('startIndex', 'int');
-                       $num_of_objects = phpgw::get_var('results', 'int', 
'GET', $user_rows_per_page);
-                       $sort_field             = phpgw::get_var('sort');
-                       if($sort_field == null)
-                       {
-                               $sort_field = 'control_item_id';
-                       }
-                       $sort_ascending = phpgw::get_var('dir') == 'desc' ? 
false : true;
-                       //Create an empty result set
-                       $records = array();
-                       
-                       //Retrieve a contract identifier and load corresponding 
contract
-                       $control_item_id = phpgw::get_var('control_item_id');
-                       if(isset($control_item_id))
-                       {
-                               $control_item = 
rental_socontract::get_instance()->get_single($control_item_id);
-                       }
-                       
-                       $result_objects = 
controller_socontrol_item::get_instance()->get($start_index, $num_of_objects, 
$sort_field, $sort_ascending, $search_for, $search_type, $filters);
-                                                               
-                       $results = array();
-                       
-                       foreach($result_objects as $control_item_obj)
-                       {
-                               $results['results'][] = 
$control_item_obj->serialize(); 
-                       }
-
-                       array_walk($results["results"], array($this, 
"_add_links"), "controller.uicontrol_item.index");
-
-                       return $this->yui_results($results);
-               }
-*/
-               
                public function query()
                {
                        $params = array(
@@ -530,6 +523,12 @@
                public function view()
                {
                        $GLOBALS['phpgw_info']['flags']['app_header'] .= 
'::'.lang('view');
+                       
+                       $tabs = array
+                       (
+                               'control_group'         => array('label' => 
lang('Control_group'), 'link' => '#control_group'),
+                               'control_items'         => array('label' => 
lang('Control_items'), 'link' => '#control_items')
+                       );
                        //Retrieve the control_group object
                        $control_group_id = (int)phpgw::get_var('id');
                        if(isset($_POST['edit_control_group']))
@@ -557,19 +556,33 @@
                                }
                                
                                $control_group_array = 
$control_group->toArray();
-                               var_dump($control_group_array);
+                               //var_dump($control_group_array);
+                               
+                               $control_items_array = 
$this->so_control_item->get_control_items($control_group_id);
+                               
+                               $control_items = array();
+                               
+                               foreach ($control_items_array as $control_item)
+                               {
+                                       $control_items[] = 
$control_item->serialize();
+                               }
+                               
+                               
phpgwapi_yui::tabview_setup('control_group_tabview');
        
                                $data = array
                                (
-                                       'value_id'                              
=> !empty($control_group) ? $control_group->get_id() : 0,
-                                       'img_go_home'                   => 
'rental/templates/base/images/32x32/actions/go-home.png',
-                                       'control_group'                 => 
$control_group_array,
+                                       'tabs'                                  
        => phpgwapi_yui::tabview_generate($tabs, 'control_group'),
+                                       'value_id'                              
        => !empty($control_group) ? $control_group->get_id() : 0,
+                                       'img_go_home'                           
=> 'rental/templates/base/images/32x32/actions/go-home.png',
+                                       'control_group'                         
=> $control_group_array,
+                                       'selected_control_items'        => 
$control_items,
                                );
        
        
                                $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('controller') . '::' . lang('Control group');
        
-                               self::render_template_xsl('control_group', 
$data);
+                               self::add_javascript('controller', 'yahoo', 
'control_tabs.js');
+                               
self::render_template_xsl(array('control_group_tabs','control_group','control_group_items'),
 $data);
                        }
                }
                

Modified: 
branches/Version-1_0-branch/controller/inc/class.uicontrol_item.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicontrol_item.inc.php     
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol_item.inc.php     
2011-10-17 13:49:52 UTC (rev 7888)
@@ -3,6 +3,7 @@
        phpgw::import_class('property.boevent');
        phpgw::import_class('controller.socontrol');
        phpgw::import_class('controller.socontrol_item');
+       phpgw::import_class('controller.socontrol_item_list');
        phpgw::import_class('controller.socontrol_group');
        phpgw::import_class('controller.socontrol_area');
        
@@ -22,7 +23,9 @@
                        'edit'  =>      true,
                        'view'  =>      true,
                        'add'   =>      true,
-                       'display_control_items' => true
+                       'display_control_items' => true,
+                       'save_item_order'       => true,
+                       'delete_item_list'      => true
                );
 
                public function __construct()
@@ -30,6 +33,7 @@
                        parent::__construct();
                        $this->so = CreateObject('controller.socontrol');
                        $this->so_control_item = 
CreateObject('controller.socontrol_item');
+                       $this->so_control_item_list = 
CreateObject('controller.socontrol_item_list');
                        $this->so_control_group = 
CreateObject('controller.socontrol_group');
                        $this->so_control_area = 
CreateObject('controller.socontrol_area');
                        $GLOBALS['phpgw_info']['flags']['menu_selection'] = 
"controller::control_item";
@@ -155,7 +159,41 @@
                        $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'controller.uicontrol_item.edit'));
                }
                
+               public function save_item_order(){
                
+                       $control_id = phpgw::get_var('control_id');
+                       $control_group_id = phpgw::get_var('control_group_id');
+                       $order_nr = phpgw::get_var('order_nr');
+                       
+                       $status = true;
+                       foreach($order_nr as $order_tag){
+                               $control_item_id =      substr($order_tag, 
strpos($order_tag, ":")+1, strlen($order_tag));
+                               $order_nr = substr($order_tag, 0, 
strpos($order_tag, ":"));
+                               
+                               $control_item_list = 
$this->so_control_item_list->get_single_2($control_id, $control_item_id);
+                               
+                               if($order_nr != 
$control_item_list->get_order_nr() ){
+                                       
$control_item_list->set_order_nr($order_nr);
+                                       
+                                       if( 
!$this->so_control_item_list->update( $control_item_list )){
+                                               $status = false;        
+                                       }       
+                               }
+                       }
+                       
+                       return status;                  
+               }
+               
+               public function delete_item_list(){
+               
+                       $control_id = phpgw::get_var('control_id');
+                       $control_item_id = phpgw::get_var('control_item_id');   
                
+                                               
+                       $status = 
$this->so_control_item_list->delete($control_id, $control_item_id);
+                       
+                       return status;                  
+               }       
+               
                public function edit()
                {
                        $control_item_id = phpgw::get_var('id');

Modified: 
branches/Version-1_0-branch/controller/inc/model/class.control_item_list.inc.php
===================================================================
--- 
branches/Version-1_0-branch/controller/inc/model/class.control_item_list.inc.php
    2011-10-17 13:46:34 UTC (rev 7887)
+++ 
branches/Version-1_0-branch/controller/inc/model/class.control_item_list.inc.php
    2011-10-17 13:49:52 UTC (rev 7888)
@@ -8,6 +8,7 @@
                protected $id;
                protected $control_id;
                protected $control_item_id;
+               protected $order_nr;
                                
                /**
                 * Constructor.  Takes an optional ID.  If a contract is 
created from outside
@@ -15,11 +16,12 @@
                 * 
                 * @param int $id the id of this composite
                 */
+                       
                public function __construct(int $id = null)
                {
                        $this->id = (int)$id;
                }
-               
+               
                public function set_id($id)
                {
                        $this->id = $id;
@@ -40,6 +42,13 @@
                }
                
                public function get_control_item_id() { return 
$this->control_item_id; }
+               
+               public function set_order_nr($order_nr)
+               {
+                       $this->order_nr = $order_nr;
+               }
+               
+               public function get_order_nr() { return $this->order_nr; }
                                
                /**
                 * Get a static reference to the storage object associated with 
this model object

Modified: branches/Version-1_0-branch/controller/inc/model/class.model.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/model/class.model.inc.php        
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/inc/model/class.model.inc.php        
2011-10-17 13:49:52 UTC (rev 7888)
@@ -63,8 +63,8 @@
                return true;
        }
        
-public function toArray()
-               {
+       public function toArray()
+       {
 
 // Alternative 1
 //                     return get_object_vars($this);

Modified: 
branches/Version-1_0-branch/controller/inc/model/class.procedure.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/model/class.procedure.inc.php    
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/inc/model/class.procedure.inc.php    
2011-10-17 13:49:52 UTC (rev 7888)
@@ -12,12 +12,14 @@
                protected $description;
                protected $reference;
                protected $attachment;
+               protected $start_date;
+               protected $end_date;
                
                /**
-                * Constructor.  Takes an optional ID.  If a contract is 
created from outside
+                * Constructor.  Takes an optional ID.  If a procedure is 
created from outside
                 * the database the ID should be empty so the database can add 
one according to its logic.
                 * 
-                * @param int $id the id of this composite
+                * @param int $id the id of this procedure
                 */
                public function __construct(int $id = null)
                {
@@ -45,13 +47,13 @@
                
                public function get_purpose() { return $this->purpose; }
                
-               public function get_responsibility() { return 
$this->responsibility; }
-               
                public function set_responsibility($responsibility)
                {
                        $this->responsibility = $responsibility;
                }
                
+               public function get_responsibility() { return 
$this->responsibility; }
+               
                public function set_description($description)
                {
                        $this->description = $description;
@@ -73,6 +75,20 @@
                
                public function get_attachment() { return $this->attachment; }
                
+               public function set_start_date($start_date)
+               {
+                       $this->start_date = $start_date;
+               }
+               
+               public function get_start_date() { return $this->start_date; }
+               
+               public function set_end_date($end_date)
+               {
+                       $this->end_date = $end_date;
+               }
+               
+               public function get_end_date() { return $this->end_date; }
+               
                /**
                 * Get a static reference to the storage object associated with 
this model object
                 * 
@@ -96,7 +112,9 @@
                                        'purpose' => $this->get_purpose(),
                                        'responsibility' => 
$this->get_responsibility(),
                                        'reference' => $this->get_reference(),
-                                       'attachment' => $this->get_attachment()
+                                       'attachment' => $this->get_attachment(),
+                                       'start_date' => $this->get_start_date(),
+                                       'end_date' => $this->get_end_date()
                        );
                }
        }

Copied: branches/Version-1_0-branch/controller/js/controller/ajax.js (from rev 
7887, trunk/controller/js/controller/ajax.js)
===================================================================
--- branches/Version-1_0-branch/controller/js/controller/ajax.js                
                (rev 0)
+++ branches/Version-1_0-branch/controller/js/controller/ajax.js        
2011-10-17 13:49:52 UTC (rev 7888)
@@ -0,0 +1,33 @@
+$(document).ready(function(){
+
+       // Saves order of control items for a group
+       $(".frm_save_order").submit(function(e){
+               e.preventDefault();
+               var thisForm = $(this);
+               
+               var control_id = $("#control_id").val();
+               var control_group_id = 
$(this).find("input[name='control_group_id']").val();
+               var order_nr_array;
+               var requestUrl = $(thisForm).attr("action"); 
+               
+               $(this).find("input[name='order_nr[]']").each(function() {
+                       order_nr_array += $(this).val() + ",";
+               });
+
+               $.ajax({
+                         type: 'POST',
+                         url: requestUrl + "&control_id=" + control_id + "&" + 
$(this).serialize(),
+                         success: function() {
+                                 
+                                 // Changes text on save button
+                                 var this_submit_btn = 
$(thisForm).find("input[type='submit']");
+                                 $(this_submit_btn).val("Lagret");
+                                 
+                                 // Changes text on save button back to 
original
+                                 window.setTimeout(function() {
+                                         $(this_submit_btn).val('Lagre 
rekkefølge');
+                                        }, 1000);
+                               }
+                       });     
+       });
+});
\ No newline at end of file

Deleted: 
branches/Version-1_0-branch/controller/js/controller/custom_drag_drop.js
===================================================================
--- branches/Version-1_0-branch/controller/js/controller/custom_drag_drop.js    
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/js/controller/custom_drag_drop.js    
2011-10-17 13:49:52 UTC (rev 7888)
@@ -1,96 +0,0 @@
-YUI().use('dd-constrain', 'dd-proxy', 'dd-drop', function(Y) {
-    //Listen for all drop:over events
-    Y.DD.DDM.on('drop:over', function(e) {
-        //Get a reference to our drag and drop nodes
-        var drag = e.drag.get('node'),
-            drop = e.drop.get('node');
-        
-        //Are we dropping on a li node?
-        if (drop.get('tagName').toLowerCase() === 'li') {
-            //Are we not going up?
-            if (!goingUp) {
-                drop = drop.get('nextSibling');
-            }
-            //Add the node to this list
-            e.drop.get('node').get('parentNode').insertBefore(drag, drop);
-            //Resize this nodes shim, so we can drop on it later.
-            e.drop.sizeShim();
-        }
-    });
-    //Listen for all drag:drag events
-    Y.DD.DDM.on('drag:drag', function(e) {
-        //Get the last y point
-        var y = e.target.lastXY[1];
-        //is it greater than the lastY var?
-        if (y < lastY) {
-            //We are going up
-            goingUp = true;
-        } else {
-            //We are going down.
-            goingUp = false;
-        }
-        //Cache for next check
-        lastY = y;
-    });
-    //Listen for all drag:start events
-    Y.DD.DDM.on('drag:start', function(e) {
-        //Get our drag object
-        var drag = e.target;
-        //Set some styles here
-        drag.get('node').setStyle('opacity', '.25');
-        drag.get('dragNode').set('innerHTML', 
drag.get('node').get('innerHTML'));
-        drag.get('dragNode').setStyles({
-            opacity: '.5',
-            borderColor: drag.get('node').getStyle('borderColor'),
-            backgroundColor: drag.get('node').getStyle('backgroundColor')
-        });
-    });
-    //Listen for a drag:end events
-    Y.DD.DDM.on('drag:end', function(e) {
-        var drag = e.target;
-        //Put our styles back
-        drag.get('node').setStyles({
-            visibility: '',
-            opacity: '1'
-        });
-    });
-    //Listen for all drag:drophit events
-    Y.DD.DDM.on('drag:drophit', function(e) {
-        var drop = e.drop.get('node'),
-            drag = e.drag.get('node');
-
-        //if we are not on an li, we must have been dropped on a ul
-        if (drop.get('tagName').toLowerCase() !== 'li') {
-            if (!drop.contains(drag)) {
-                drop.appendChild(drag);
-            }
-        }
-    });
-    
-    //Static Vars
-    var goingUp = false, lastY = 0;
-
-    //Get the list of li's in the lists and make them draggable
-    var lis = Y.Node.all('#play ul li');
-    lis.each(function(v, k) {
-        var dd = new Y.DD.Drag({
-            node: v,
-            target: {
-                padding: '0 0 0 20'
-            }
-        }).plug(Y.Plugin.DDProxy, {
-            moveOnEnd: false
-        }).plug(Y.Plugin.DDConstrained, {
-            constrain2node: '#play'
-        });
-    });
-
-    //Create simple targets for the 2 lists.
-    var uls = Y.Node.all('#play ul');
-    uls.each(function(v, k) {
-        var tar = new Y.DD.Drop({
-            node: v
-        });
-    });
-    
-});
\ No newline at end of file

Copied: 
branches/Version-1_0-branch/controller/js/controller/custom_drag_drop.js (from 
rev 7887, trunk/controller/js/controller/custom_drag_drop.js)
===================================================================
--- branches/Version-1_0-branch/controller/js/controller/custom_drag_drop.js    
                        (rev 0)
+++ branches/Version-1_0-branch/controller/js/controller/custom_drag_drop.js    
2011-10-17 13:49:52 UTC (rev 7888)
@@ -0,0 +1,122 @@
+var placeholder;
+var drag_elem;
+var next_elem;
+var prev_elem;
+var adj_y;
+
+$(document).ready(function(){
+
+       // Drag row is clicked
+       $(".drag").mousedown(function(e){
+               placeholder = $(this).parent();
+               
+               adj_y = e.pageY - $(placeholder).position().top;
+               
+               next_elem = $(placeholder).next();
+               prev_elem = $(placeholder).prev();
+               drag_elem = $(placeholder).clone();
+                               
+               $(drag_elem).addClass("drag_elem");
+               $(drag_elem).removeClass("list_item");
+               
+               $(drag_elem).insertAfter(placeholder);
+               
+               $(drag_elem).css("left", $(placeholder).position().left + "px");
+               $(drag_elem).css("top",  $(placeholder).position().top + "px");
+                                                                       
+               start_drag();
+       });
+       
+       // Delete a control item list 
+       $(".delete").click(function(){
+               var thisElem = $(this);
+               var thisRow = $(this).parent();
+               
+               var url = $(thisElem).attr("href");
+       
+               // Sending request for deleting a control item list
+               $.ajax({
+                       type: 'POST',
+                       url: url,
+                       success: function() {
+                               $(thisRow).fadeOut("slow");
+                               
+                               var next_row = $(thisRow).next();
+                               
+                               // Updating order numbers for rows below 
deleted row  
+                               while( $(next_row).length > 0){
+                                       update_order_nr(next_row, "-");
+                                       next_row = $(next_row).next();
+                               }               
+                       }
+               });
+               
+               return false;
+       });
+});
+
+function start_drag(){
+       $(document).bind("mouseup", stop_drag);
+
+       $(document).bind("mousemove", function(e){
+               
+               var x = 0;
+               var y = e.pageY - adj_y;
+
+               $(drag_elem).css("left", x + "px");
+               $(drag_elem).css("top", y + "px");
+               
+               // Move drag element over next element
+               if( $(next_elem).length > 0 && e.pageY > 
$(next_elem).offset().top + $(next_elem).height()/2 ){
+                       $(placeholder).insertAfter(next_elem);
+                       next_elem = $(placeholder).next();
+                       prev_elem = $(placeholder).prev();
+                                       
+                       // Updating order number for drag element and previous 
element
+                       update_order_nr(placeholder, "+");
+                       update_order_nr(prev_elem, "-");
+               }
+               // Move drag element over previous element
+               else if( $(prev_elem).length > 0 && e.pageY < 
$(prev_elem).offset().top + $(prev_elem).height()/2 ){
+                       $(placeholder).insertBefore(prev_elem);
+                       prev_elem = $(placeholder).prev();
+                       next_elem = $(placeholder).next();
+                       
+                       // Updating order number for drag element and next 
element
+                       update_order_nr(placeholder, "-");
+                       update_order_nr(next_elem, "+");
+               }
+       }); 
+}
+
+// Release binding for mouse events
+function stop_drag(){
+       $(drag_elem).remove();
+
+       $(document).unbind("mousemove");
+       $(document).unbind("mouseup");
+}
+
+// Updates order number for hidden field and number in front of row
+function update_order_nr(element, sign){
+       var hidden_order_nr = $(element).find("input");
+       var order_value = $(hidden_order_nr).attr("value");
+       
+       var span_order_nr = $(element).find("span.order_nr");
+       
+       var order_nr = order_value.substring( 0, order_value.indexOf(":") );
+       
+       if(sign == "+")
+               var updated_order_nr = parseInt(order_nr) + 1;
+       else
+               var updated_order_nr = parseInt(order_nr) - 1;
+       
+       var id = order_value.substring( order_value.indexOf(":")+1,  
order_value.length );
+       updated_order_value = updated_order_nr + ":" + id;
+       
+       // Updating order number for hidden field       
+       $(hidden_order_nr).val(updated_order_value);
+       
+       // Updating order number in front of row
+       $(span_order_nr).text(updated_order_nr);
+}
\ No newline at end of file

Modified: branches/Version-1_0-branch/controller/js/controller/custom_ui.js
===================================================================
--- branches/Version-1_0-branch/controller/js/controller/custom_ui.js   
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/js/controller/custom_ui.js   
2011-10-17 13:49:52 UTC (rev 7888)
@@ -4,6 +4,7 @@
        $("ul.control_items ul:first").find("li ul").slideDown("slow");
        $("ul.control_items ul:first").addClass('active');
 
+       /* 
=============================================================================== 
*/
        
        $(".expand_list h4").click(function(){
                if( $(this).parent().parent().hasClass('active')){
@@ -17,6 +18,8 @@
                }
        });
        
+       /* 
=============================================================================== 
*/
+       
        $(".expand_all").click(function(){
                $(".expand_all").css("background", 
"url('controller/images/bg_expand_blue.png') no-repeat");
                $(".expand_all").css("color", "#FFFFFF");
@@ -47,8 +50,8 @@
                var control_group_id = chbox_id.substring( 
chbox_id.indexOf("_")+1, chbox_id.indexOf(":") );
                var control_item_id = chbox_id.substring( 
chbox_id.indexOf(":")+1,  chbox_id.length );
                
-               if ($("#hid_"+control_item_id).length > 0){
-                       $("#hid_"+control_item_id).remove();
+               if ($("#hid_" + control_item_id).length > 0){
+                       $("#hid_" + control_item_id).remove();
                }else{
                        $("#frm_control_items").prepend("<input type='hidden' 
id=hid_" + control_item_id +  " name='control_tag_ids[]' value=" + 
control_group_id + ":" +  control_item_id + " />");
                }

Copied: branches/Version-1_0-branch/controller/js/controller/yui_drag_drop.js 
(from rev 7887, trunk/controller/js/controller/yui_drag_drop.js)
===================================================================
--- branches/Version-1_0-branch/controller/js/controller/yui_drag_drop.js       
                        (rev 0)
+++ branches/Version-1_0-branch/controller/js/controller/yui_drag_drop.js       
2011-10-17 13:49:52 UTC (rev 7888)
@@ -0,0 +1,96 @@
+YUI().use('dd-constrain', 'dd-proxy', 'dd-drop', function(Y) {
+    //Listen for all drop:over events
+    Y.DD.DDM.on('drop:over', function(e) {
+        //Get a reference to our drag and drop nodes
+        var drag = e.drag.get('node'),
+            drop = e.drop.get('node');
+        
+        //Are we dropping on a li node?
+        if (drop.get('tagName').toLowerCase() === 'li') {
+            //Are we not going up?
+            if (!goingUp) {
+                drop = drop.get('nextSibling');
+            }
+            //Add the node to this list
+            e.drop.get('node').get('parentNode').insertBefore(drag, drop);
+            //Resize this nodes shim, so we can drop on it later.
+            e.drop.sizeShim();
+        }
+    });
+    //Listen for all drag:drag events
+    Y.DD.DDM.on('drag:drag', function(e) {
+        //Get the last y point
+        var y = e.target.lastXY[1];
+        //is it greater than the lastY var?
+        if (y < lastY) {
+            //We are going up
+            goingUp = true;
+        } else {
+            //We are going down.
+            goingUp = false;
+        }
+        //Cache for next check
+        lastY = y;
+    });
+    //Listen for all drag:start events
+    Y.DD.DDM.on('drag:start', function(e) {
+        //Get our drag object
+        var drag = e.target;
+        //Set some styles here
+        drag.get('node').setStyle('opacity', '.25');
+        drag.get('dragNode').set('innerHTML', 
drag.get('node').get('innerHTML'));
+        drag.get('dragNode').setStyles({
+            opacity: '.5',
+            borderColor: drag.get('node').getStyle('borderColor'),
+            backgroundColor: drag.get('node').getStyle('backgroundColor')
+        });
+    });
+    //Listen for a drag:end events
+    Y.DD.DDM.on('drag:end', function(e) {
+        var drag = e.target;
+        //Put our styles back
+        drag.get('node').setStyles({
+            visibility: '',
+            opacity: '1'
+        });
+    });
+    //Listen for all drag:drophit events
+    Y.DD.DDM.on('drag:drophit', function(e) {
+        var drop = e.drop.get('node'),
+            drag = e.drag.get('node');
+
+        //if we are not on an li, we must have been dropped on a ul
+        if (drop.get('tagName').toLowerCase() !== 'li') {
+            if (!drop.contains(drag)) {
+                drop.appendChild(drag);
+            }
+        }
+    });
+    
+    //Static Vars
+    var goingUp = false, lastY = 0;
+
+    //Get the list of li's in the lists and make them draggable
+    var lis = Y.Node.all('#play ul li');
+    lis.each(function(v, k) {
+        var dd = new Y.DD.Drag({
+            node: v,
+            target: {
+                padding: '0 0 0 20'
+            }
+        }).plug(Y.Plugin.DDProxy, {
+            moveOnEnd: false
+        }).plug(Y.Plugin.DDConstrained, {
+            constrain2node: '#play'
+        });
+    });
+
+    //Create simple targets for the 2 lists.
+    var uls = Y.Node.all('#play ul');
+    uls.each(function(v, k) {
+        var tar = new Y.DD.Drop({
+            node: v
+        });
+    });
+    
+});
\ No newline at end of file

Modified: branches/Version-1_0-branch/controller/js/yahoo/datatable.js
===================================================================
--- branches/Version-1_0-branch/controller/js/yahoo/datatable.js        
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/js/yahoo/datatable.js        
2011-10-17 13:49:52 UTC (rev 7888)
@@ -146,6 +146,14 @@
                return true;
     }
         
+       YAHOO.util.Event.on(
+           YAHOO.util.Selector.query('select'), 'change', function (e) {
+               //var val = this.value;
+                       var state = getState();
+                       YAHOO.util.Dom.setStyle('list_flash', 'display', 
'none');
+                       History.navigate('state', state);
+       });
+
     YAHOO.util.Event.addListener('queryForm', "submit", function(e){
         YAHOO.util.Event.stopEvent(e);
                var state = getState();

Modified: branches/Version-1_0-branch/controller/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/controller/setup/phpgw_no.lang  2011-10-17 
13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/setup/phpgw_no.lang  2011-10-17 
13:49:52 UTC (rev 7888)
@@ -40,6 +40,7 @@
 section        controller      no      Seksjon
 room   controller      no      Rom
 save   controller      no      Lagre
+save_order     controller      no      Lagre rekkefølge
 1-6 characters controller      no      1-6 tegn
 6 characters   controller      no      6 tegn
 active controller      no      Aktiv
@@ -246,4 +247,5 @@
 REJECTED       controller      no      Avvist
 New control group      controller      no      Ny kontrollgruppe
 Control group title    controller      no      Tittel
-Building part  controller      no      Bygningsdel
\ No newline at end of file
+Building part  controller      no      Bygningsdel
+remove controller      no      Fjern valgte elementer
\ No newline at end of file

Modified: branches/Version-1_0-branch/controller/setup/tables_current.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/setup/tables_current.inc.php 
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/setup/tables_current.inc.php 
2011-10-17 13:49:52 UTC (rev 7888)
@@ -28,7 +28,8 @@
                        'fd' => array(
                                'id' => array('type' => 'auto','precision' => 
4,'nullable' => False),
                                'control_id' => array('type' => 'int', 
'precision' => 4, 'nullable' => True),
-                               'control_item_id' => array('type' => 'int', 
'precision' => 4, 'nullable' => True)
+                               'control_item_id' => array('type' => 'int', 
'precision' => 4, 'nullable' => True),
+                               'order_nr' => array('type' => 'int', 
'precision' => 4, 'nullable' => True),
                        ),
                        'pk' => array('id'),
                        'fk' => array(),
@@ -85,7 +86,9 @@
                                'responsibility' => array('type' => 'varchar', 
'precision' => 255, 'nullable' => True),
                                'description' => array('type' => 'text', 
'nullable' => True),
                                'reference' => array('type' => 'varchar', 
'precision' => 255, 'nullable' => True),
-                               'attachment' => array('type' => 'varchar', 
'precision' => 255, 'nullable' => True)
+                               'attachment' => array('type' => 'varchar', 
'precision' => 255, 'nullable' => True),
+                               'start_date' => array('type' => 'int', 
'precision' => 8, 'nullable' => True),
+                               'end_date' => array('type' => 'int', 
'precision' => 8, 'nullable' => True)
                        ),
                        'pk' => array('id'),
                        'fk' => array(),

Modified: branches/Version-1_0-branch/controller/templates/base/control.xsl
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/control.xsl   
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/templates/base/control.xsl   
2011-10-17 13:49:52 UTC (rev 7888)
@@ -6,7 +6,7 @@
 
 <div class="yui-content">
        <div id="control_details">
-               <form action="#" method="post">
+               <form action="index.php?menuaction=controller.uicontrol.index" 
method="post">
                        <input type="hidden" name="control_id" 
value="{$control_id}" /> 
        
                        <dl class="proplist-col">

Modified: 
branches/Version-1_0-branch/controller/templates/base/control_group.xsl
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/control_group.xsl     
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/templates/base/control_group.xsl     
2011-10-17 13:49:52 UTC (rev 7888)
@@ -1,7 +1,7 @@
 <!-- item  -->
+<xsl:template name="control_group" xmlns:php="http://php.net/xsl";>
+<!-- <xsl:template match="data" xmlns:php="http://php.net/xsl";>  -->
 
-<xsl:template match="data" xmlns:php="http://php.net/xsl";>
-
 <xsl:call-template name="yui_booking_i18n"/>
 <div class="identifier-header">
 <h1><img src="{img_go_home}" /> 

Copied: 
branches/Version-1_0-branch/controller/templates/base/control_group_items.xsl 
(from rev 7887, trunk/controller/templates/base/control_group_items.xsl)
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/control_group_items.xsl   
                            (rev 0)
+++ 
branches/Version-1_0-branch/controller/templates/base/control_group_items.xsl   
    2011-10-17 13:49:52 UTC (rev 7888)
@@ -0,0 +1,53 @@
+<xsl:template name="control_items" xmlns:php="http://php.net/xsl";>
+
+<xsl:call-template name="yui_booking_i18n"/>
+<div class="identifier-header">
+<h1><img src="{img_go_home}" /> 
+       <xsl:value-of select="php:function('lang', 'Control_items')" />
+</h1>
+</div>
+
+<div class="yui-content">
+       <div>
+               <xsl:if test="selected_control_items">
+                       <h2>Valgte kontrollpunkt</h2>
+                       <form action="#" method="post"> 
+                               <ul class="control_items">
+                                       <xsl:for-each 
select="selected_control_items">
+                                               <xsl:variable 
name="control_item_id"><xsl:value-of select="id"/></xsl:variable>
+                                       <li><xsl:if test="//editable"><input 
type="checkbox"  name="item_remove_ids[]" 
value="{$control_item_id}"/></xsl:if><xsl:value-of select="title"/></li>
+                                       </xsl:for-each>
+                               </ul>
+                               <xsl:if test="//editable">
+                                       <div class="form-buttons">
+                                               <xsl:variable 
name="lang_remove"><xsl:value-of select="php:function('lang', 'remove')" 
/></xsl:variable>
+                                               <input type="submit" 
name="remove_control_group_items" value="{$lang_remove}" title = 
"{$lang_remove}" />
+                                       </div>
+                               </xsl:if>
+                       </form>
+               </xsl:if>
+          <!-- ===========================  CHOOSE CONTROL ITEMS  
=============================== -->
+          <xsl:choose>
+               <xsl:when test="editable">
+                       <h2>Velg kontrollpunkt</h2>
+                       <form action="#" method="post"> 
+                       
+                       <xsl:variable name="control_group_id"><xsl:value-of 
select="value_id"/></xsl:variable>
+                       <input type="hidden" name="control_group_id" 
value="{control_group_id}" />
+                       
+                       <ul class="control_items">
+                               <xsl:for-each select="control_items">
+                                       <xsl:variable 
name="control_item_id"><xsl:value-of select="id"/></xsl:variable>
+                                       <li><input type="checkbox"  
name="control_tag_ids[]" value="{$control_item_id}" /><xsl:value-of 
select="title"/></li>
+                               </xsl:for-each>
+                       </ul>           
+                       <div class="form-buttons">
+                               <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'save')" /></xsl:variable>
+                               <input type="submit" 
name="save_control_group_items" value="{$lang_save}" title = "{$lang_save}" />
+                       </div>
+                       </form>
+               </xsl:when>
+          </xsl:choose>
+       </div>
+</div>
+</xsl:template>
\ No newline at end of file

Copied: 
branches/Version-1_0-branch/controller/templates/base/control_group_tabs.xsl 
(from rev 7887, trunk/controller/templates/base/control_group_tabs.xsl)
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/control_group_tabs.xsl    
                            (rev 0)
+++ 
branches/Version-1_0-branch/controller/templates/base/control_group_tabs.xsl    
    2011-10-17 13:49:52 UTC (rev 7888)
@@ -0,0 +1,19 @@
+<!-- separate tabs and  inline tables-->
+
+<xsl:template match="data" xmlns:php="http://php.net/xsl";>
+       <div class="yui-navset yui-navset-top" id="control_group_tabview">
+               <xsl:value-of disable-output-escaping="yes" select="tabs" />
+               <div class="yui-content">
+                       <div id="control_group">
+                               <xsl:call-template name="control_group" />
+                       </div>
+                       <div id="control_items">
+                               <xsl:call-template name="control_items" />
+                       </div>
+               </div>
+       </div>
+       <!--  script type="text/javascript">
+               var resource_id = <xsl:value-of select="resource/id"/>;
+               var lang = <xsl:value-of select="php:function('js_lang', 
'Name', 'Category', 'Actions', 'Edit', 'Delete', 'Account', 'Role')"/>;
+       </script-->
+</xsl:template>
\ No newline at end of file

Modified: 
branches/Version-1_0-branch/controller/templates/base/control_groups.xsl
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/control_groups.xsl    
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/templates/base/control_groups.xsl    
2011-10-17 13:49:52 UTC (rev 7888)
@@ -5,7 +5,7 @@
        
                <h2><xsl:value-of select="control_area/title"/></h2>
                        
-               <form action="#" method="post">
+               <form action="index.php?menuaction=controller.uicontrol.index" 
method="post">
                <xsl:variable name="control_area_id"><xsl:value-of 
select="control_area/id"/></xsl:variable>
                <input type="hidden" name="control_area_id" 
value="{$control_area_id}" />
                
@@ -18,7 +18,7 @@
                <li><input type="checkbox"  name="control_group_ids[]" 
value="{$control_group_id}" /><xsl:value-of select="group_name"/></li>
                </xsl:for-each>
                </ul>
-               <div class="form-buttons">
+               <div>
                        <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'save')" /></xsl:variable>
                        <input type="submit" name="save_control_groups" 
value="{$lang_save}" title = "{$lang_save}" />
                        </div>

Modified: branches/Version-1_0-branch/controller/templates/base/control_item.xsl
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/control_item.xsl      
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/templates/base/control_item.xsl      
2011-10-17 13:49:52 UTC (rev 7888)
@@ -89,11 +89,12 @@
                                        <xsl:choose>
                                                <xsl:when test="editable">
                                                        <select 
id="control_group" name="control_group">
+                                                               <option 
value="0">Ingen valgt</option>
                                                                
<xsl:apply-templates select="control_group/options"/>
                                                        </select>
                                                </xsl:when>
                                                <xsl:otherwise>
-                                                       <xsl:value-of 
select="control_item/control_group_id" />
+                                                       <xsl:value-of 
select="control_item/control_group_name" />
                                                </xsl:otherwise>
                                        </xsl:choose>
                                        </dd>
@@ -108,7 +109,7 @@
                                                        </select>
                                                </xsl:when>
                                                <xsl:otherwise>
-                                                       <xsl:value-of 
select="control_item/control_area_id" />
+                                                       <xsl:value-of 
select="control_item/control_area_name" />
                                                </xsl:otherwise>
                                        </xsl:choose>
                                        </dd>                           

Modified: 
branches/Version-1_0-branch/controller/templates/base/control_items.xsl
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/control_items.xsl     
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/templates/base/control_items.xsl     
2011-10-17 13:49:52 UTC (rev 7888)
@@ -7,33 +7,35 @@
           <h2>Velg dine kontrollpunkt</h2>
           
                <h4 class="expand_header"><div class="expand_all">Vis 
alle</div><div class="collapse_all">Skjul alle</div></h4>
-               <form id="frm_control_items" action="#" method="post">  
-               
-               <xsl:variable name="control_id"><xsl:value-of 
select="control_id"/></xsl:variable>
-               <input type="hidden" name="control_id" value="{control_id}" />  
        
-               
-               <ul class="control_items">
-                       <xsl:for-each select="groups_with_control_items">
-                               <ul class="proplist-col expand_list">
-                       <li>
-                               <h4><img src="controller/images/arrow_left.png" 
width="14"/><span><xsl:value-of select="control_group/group_name"/></span></h4>
-                               <xsl:variable 
name="control_group_id"><xsl:value-of select="control_group/id"/></xsl:variable>
-                               <ul>            
-                                               <xsl:for-each 
select="group_control_items">
-                                                       <xsl:variable 
name="control_item_id"><xsl:value-of select="id"/></xsl:variable>
-                                                       
-                                               <li><xsl:number/>.  <input 
type="checkbox"  id="ch_{$control_group_id}:{$control_item_id}" 
value="{$control_group_id}:{$control_item_id}" /><xsl:value-of 
select="title"/></li> 
-                                               </xsl:for-each>
-                                       </ul>
-                               </li>
+               <form id="frm_control_items" 
action="index.php?menuaction=controller.uicontrol.index" method="post">    
+                       <xsl:variable name="control_id"><xsl:value-of 
select="control_id"/></xsl:variable>
+                       <input type="hidden" name="control_id" 
value="{control_id}" />
+                       
+                       <xsl:variable name="control_group_ids"><xsl:value-of 
select="control_group_ids"/></xsl:variable>
+                       <input type="hidden" name="control_group_ids[]" 
value="{control_group_ids}" />          
+                       
+                       <ul class="control_items">
+                               <xsl:for-each 
select="groups_with_control_items">
+                                       <ul class="itemlist expand_list">
+                               <li>
+                                       <h4><img 
src="controller/images/arrow_left.png" width="14"/><span><xsl:value-of 
select="control_group/group_name"/></span></h4>
+                                       <xsl:variable 
name="control_group_id"><xsl:value-of select="control_group/id"/></xsl:variable>
+                                       <ul>            
+                                                       <xsl:for-each 
select="group_control_items">
+                                                               <xsl:variable 
name="control_item_id"><xsl:value-of select="id"/></xsl:variable>
+                                                               
+                                                       <li><xsl:number/>.  
<input type="checkbox"  id="ch_{$control_group_id}:{$control_item_id}" 
value="{$control_group_id}:{$control_item_id}" /><xsl:value-of 
select="title"/></li> 
+                                                       </xsl:for-each>
+                                               </ul>
+                                       </li>
+                               </ul>
+                               </xsl:for-each>
                        </ul>
-                       </xsl:for-each>
-               </ul>
-               
-               <div class="form-buttons">
-                       <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'save')" /></xsl:variable>
-                       <input type="submit" name="save_control_items" 
value="{$lang_save}" title = "{$lang_save}" />
-               </div>
+                       
+                       <div>
+                               <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'save')" /></xsl:variable>
+                               <input type="submit" name="save_control_items" 
value="{$lang_save}" title = "{$lang_save}" />
+                       </div>
                </form>
                                                                
        </div>

Modified: 
branches/Version-1_0-branch/controller/templates/base/control_items_receipt.xsl
===================================================================
--- 
branches/Version-1_0-branch/controller/templates/base/control_items_receipt.xsl 
    2011-10-17 13:46:34 UTC (rev 7887)
+++ 
branches/Version-1_0-branch/controller/templates/base/control_items_receipt.xsl 
    2011-10-17 13:49:52 UTC (rev 7888)
@@ -3,38 +3,61 @@
 <div class="yui-content">
        <div>
        
-         <!-- ===========================  SHOW CONTROL ITEMS RECEIPT   
=============================== -->
-        
-         <h2>Kvittering</h2>
-         <form action="#" method="post">       
-               
+         <!-- ===========================  SHOWS CONTROL ITEMS RECEIPT   
=============================== -->
+
                <xsl:variable name="control_id"><xsl:value-of 
select="control_id"/></xsl:variable>
-               <input type="hidden" name="control_id" value="{control_id}" />
+               <input type="hidden" id="control_id" name="control_id" 
value="{control_id}" />
                
-               <ul class="proplist-col control_items">
+               <ul>
                        <xsl:for-each select="control_receipt_items">
-                       <ul>
-                       <li>
-                               <h3><xsl:value-of 
select="control_group/group_name"/></h3>
-                               <div id="play">
-                               <ul>            
-                                               <xsl:for-each 
select="control_items">
-                                                       <xsl:variable 
name="control_item_id"><xsl:value-of select="id"/></xsl:variable>
-                                               <li><xsl:number/>. 
<xsl:value-of select="title"/></li>  
-                                               </xsl:for-each>
-                                       </ul>
-                                       </div>
-                               </li>
-                       </ul>      
+                       <form 
action="index.php?menuaction=controller.uicontrol_item.save_item_order" 
class="frm_save_order">
+                               <ul class="itemlist control_items">
+                               <li>
+                                       <h3><xsl:value-of 
select="control_group/group_name"/></h3>
+                                       
+                                       <xsl:variable 
name="control_group_id"><xsl:value-of select="control_group/id"/></xsl:variable>
+                                               <input type="hidden" 
name="control_group_id" value="{$control_group_id}" />             
+                               
+                                       <ul id="list">
+                                                       <xsl:for-each 
select="control_items">
+                                                               <xsl:variable 
name="control_item_id"><xsl:value-of select="id"/></xsl:variable>
+                                                               <xsl:variable 
name="order_tag">
+                                                                       
<xsl:choose>
+                                                                               
<xsl:when test="order_nr > 0">
+                                                                               
        <xsl:value-of select="order_nr"/>
+                                                                               
</xsl:when>
+                                                                               
<xsl:otherwise>
+                                                                               
        <xsl:number/>
+                                                                               
</xsl:otherwise>
+                                                                       
</xsl:choose>:<xsl:value-of select="id"/>
+                                                               </xsl:variable>
+                                                                               
                                                
+                                                       <li class="list_item">
+                                                               <span 
class="drag">
+                                                                       <span 
class="order_nr"><xsl:number/></span>. <xsl:value-of select="title"/><input 
type="hidden" name="order_nr[]" value="{$order_tag}" />
+                                                               </span>
+                                                               <a 
class="delete">
+                                                                               
<xsl:attribute name="href">
+                                                                               
        
<xsl:text>index.php?menuaction=controller.uicontrol_item.delete_item_list</xsl:text>
+                                                                               
        <xsl:text>&amp;control_id=</xsl:text>
+                                                                               
        <xsl:value-of select="//control_id"/>
+                                                                               
        <xsl:text>&amp;control_item_id=</xsl:text>
+                                                                               
        <xsl:value-of select="id"/>
+                                                                               
</xsl:attribute>
+                                                                               
<span>x</span>
+                                                                       </a>
+                                                       </li>
+                                                       </xsl:for-each>
+                                               </ul>
+                                       </li>
+                               </ul>      
+                               <div>
+                                       <xsl:variable 
name="lang_save"><xsl:value-of select="php:function('lang', 'save_order')" 
/></xsl:variable>
+                                       <input type="submit" id="save_order" 
name="save_order" value="{$lang_save}" title = "{$lang_save}" />
+                               </div>  
+                       </form>
                        </xsl:for-each>
-               </ul>   
-               
-               <div class="form-buttons">
-               <xsl:variable name="lang_save"><xsl:value-of 
select="php:function('lang', 'save')" /></xsl:variable>
-               <input type="submit" name="show_receipt" value="{$lang_save}" 
title = "{$lang_save}" />
-               </div>
-       </form>
-                                               
+               </ul>                                   
        </div>
 </div>
 </xsl:template>
\ No newline at end of file

Modified: branches/Version-1_0-branch/controller/templates/base/css/base.css
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/css/base.css  
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/templates/base/css/base.css  
2011-10-17 13:49:52 UTC (rev 7888)
@@ -23,12 +23,7 @@
        float:left;
         font-weight: bolder;
         margin-right: 1em;
-       }
-
-div#invoice_details dd{
-       
-       }
-
+}
 div.content {
        margin: 2em;    
 }
@@ -480,6 +475,7 @@
     cursor: pointer;
     font-size: 17px;
     margin-bottom: 6px;
+    margin-top: 0;
 }
 
 ul.expand_list li ul {
@@ -520,10 +516,19 @@
     margin: 1em 0;
     padding-left: 20px;
 }
-ul.itemlist li{
-    margin: 3px 0;
+ul.itemlist li {
+    padding: 3px 0;
 }
 
+ul.itemlist li.odd{
+    background: none repeat scroll 0 0 #DBE7F5;
+}
+
+ul.itemlist h3 {
+    font-size: 18px;
+    margin: 0 0 5px;
+}
+
 .yui-content h2{
     margin: 1em 0;
     padding-left: 20px;        
@@ -565,3 +570,37 @@
     margin: 5px 0;
     padding-left: 15px;
 }
+
+.drag_elem{
+  z-index: 100;
+  position:absolute;
+  opacity: .50;
+  filter: alpha(opacity=50);
+}
+
+#list{
+  width: 650px;
+  position:relative;
+}
+
+.list_item{
+  position:relative;
+  z-index: 1;
+  opacity: 1;
+  filter: alpha(opacity=100);
+  top: 0px;
+  left: 0px;
+}
+
+.list_item:hover{
+  cursor: move;
+}
+
+.frm_save_order input[type='submit']{
+       margin: 0 0 15px 15px;
+    width: 120px;
+}      
+.delete {
+    cursor: pointer;
+    margin-left: 5px;
+}
\ No newline at end of file

Modified: branches/Version-1_0-branch/controller/templates/base/datatable.xsl
===================================================================
--- branches/Version-1_0-branch/controller/templates/base/datatable.xsl 
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/controller/templates/base/datatable.xsl 
2011-10-17 13:49:52 UTC (rev 7888)
@@ -133,6 +133,7 @@
                         </xsl:for-each>
                        </select>
                     </td>
+<!--
                                        <xsl:if test="onChangeSelect">
                                                <script type="text/javascript"> 
                                                        
YAHOO.util.Event.onDOMReady(function() {
@@ -161,6 +162,7 @@
                                                        });
                                                </script>
                                        </xsl:if>
+-->
                                </xsl:when>
                                <xsl:otherwise>
                                        <td valign="top">

Modified: branches/Version-1_0-branch/phpgwapi/inc/class.custom_fields.inc.php
===================================================================
--- branches/Version-1_0-branch/phpgwapi/inc/class.custom_fields.inc.php        
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/phpgwapi/inc/class.custom_fields.inc.php        
2011-10-17 13:49:52 UTC (rev 7888)
@@ -119,7 +119,9 @@
                                'pwd'   => lang('password'),
                                'user'  => 'phpgw_user',
                                'event' => lang('event'),
-                               'bolean'        => 'Bolean'
+                               'bolean'=> 'Bolean',
+                               'custom1'=> lang('Custom listbox'),//Custom 
listbox to generic lists
+                               'custom2'=> lang('Custom lookup'),//Custom 
lookup to generic lists
                        );
 
                        $this->_oProc                   = 
createObject('phpgwapi.schema_proc', 
$GLOBALS['phpgw_info']['server']['db_type']);
@@ -247,6 +249,15 @@
                                return -1;
                        }
 
+                       if(isset($attrib['get_list_function_input']) &&  
$attrib['get_list_function_input'])
+                       {
+                               $attrib['get_list_function_input'] = 
$this->_validate_function_input($attrib['get_list_function_input']);
+                       }
+                       if(isset($attrib['get_single_function_input']) &&  
$attrib['get_single_function_input'])
+                       {
+                               $attrib['get_single_function_input'] = 
$this->_validate_function_input($attrib['get_single_function_input']);
+                       }
+
                        $values = array
                        (
                                'location_id'   => $location_id,
@@ -266,7 +277,11 @@
                                'precision_'    => (int) 
$attrib['column_info']['precision'],
                                'scale'                 => (int) 
$attrib['column_info']['scale'],
                                'default_value' => '',
-                               'nullable'              => 
$attrib['column_info']['nullable']
+                               'nullable'              => 
$attrib['column_info']['nullable'],
+                               'get_list_function'     => 
$attrib['get_list_function'],
+                               'get_list_function_input' => 
$attrib['get_list_function_input'] ? 
$this->_db->db_addslashes(serialize($attrib['get_list_function_input'])) : '',
+                               'get_single_function'   => 
$attrib['get_single_function'],
+                               'get_single_function_input' => 
$attrib['get_single_function_input'] ? 
$this->_db->db_addslashes(serialize($attrib['get_single_function_input'])) : ''
                        );
 
                        if ( isset($attrib['search']) )
@@ -610,6 +625,15 @@
                 */
                function edit($attrib, $attrib_table = '', $doubled = false)
                {
+                       if(isset($attrib['get_list_function_input']) &&  
$attrib['get_list_function_input'])
+                       {
+                               $attrib['get_list_function_input'] = 
$this->_validate_function_input($attrib['get_list_function_input']);
+                       }
+                       if(isset($attrib['get_single_function_input']) &&  
$attrib['get_single_function_input'])
+                       {
+                               $attrib['get_single_function_input'] = 
$this->_validate_function_input($attrib['get_single_function_input']);
+                       }
+
                        // Checkboxes are only present if ticked, so we declare 
them here to stop errors
                        $attrib['search'] = isset($attrib['search']) ? 
!!$attrib['search'] : false;
                        $attrib['list'] = isset($attrib['list']) ? 
!!$attrib['list'] : false;
@@ -672,16 +696,20 @@
                        {
                                $value_set = array
                                (
-                                       'input_text'    => 
$attrib['input_text'],
-                                       'statustext'    => 
$attrib['statustext'],
-                                       'search'                => 
isset($attrib['search']) ? $attrib['search'] : '',
-                                       'list'                  => 
isset($attrib['list']) ? $attrib['list'] : '',
-                                       'history'               => 
isset($attrib['history']) ? $attrib['history'] : '',
-                                       'nullable'              => 
$attrib['column_info']['nullable'] == 'False' ? 'False' : 'True',
-                                       'disabled'              => 
isset($attrib['disabled']) ? $attrib['disabled'] : '',
-                                       'helpmsg'               => 
$attrib['helpmsg'],
-                                       'lookup_form'   => 
isset($attrib['lookup_form']) ? $attrib['lookup_form'] : '',
-                                       'group_id'              => 
$attrib['group_id']
+                                       'input_text'                    => 
$attrib['input_text'],
+                                       'statustext'                    => 
$attrib['statustext'],
+                                       'search'                                
=> isset($attrib['search']) ? $attrib['search'] : '',
+                                       'list'                                  
=> isset($attrib['list']) ? $attrib['list'] : '',
+                                       'history'                               
=> isset($attrib['history']) ? $attrib['history'] : '',
+                                       'nullable'                              
=> $attrib['column_info']['nullable'] == 'False' ? 'False' : 'True',
+                                       'disabled'                              
=> isset($attrib['disabled']) ? $attrib['disabled'] : '',
+                                       'helpmsg'                               
=> $attrib['helpmsg'],
+                                       'lookup_form'                   => 
isset($attrib['lookup_form']) ? $attrib['lookup_form'] : '',
+                                       'group_id'                              
=> $attrib['group_id'],
+                                       'get_list_function'             => 
$attrib['get_list_function'],
+                                       'get_list_function_input' => 
$attrib['get_list_function_input'] ? 
$this->_db->db_addslashes(serialize($attrib['get_list_function_input'])) : '',
+                                       'get_single_function'           => 
$attrib['get_single_function'],
+                                       'get_single_function_input' => 
$attrib['get_single_function_input'] ? 
$this->_db->db_addslashes(serialize($attrib['get_single_function_input'])) : ''
                                );
 
                                if($OldGroup != $attrib['group_id'])
@@ -959,28 +987,32 @@
                                $id = $this->_db->f('id');
                                $attribs[$id] = array
                                (
-                                       'id'                            => $id,
+                                       'id'                                    
=> $id,
                                        //'attrib_id'                   => 
$this->_db->f('id'), // FIXME
-                                       'entity_type'           => 
$this->_db->f('type_id'),
-                                       'group_id'                      => 
(int) $this->_db->f('group_id'),                                     
-                                       'attrib_sort'           => (int) 
$this->_db->f('attrib_sort'),
-                                       'list'                          => 
$this->_db->f('list'),
-                                       'lookup_form'           => 
$this->_db->f('lookup_form'),
-                                       'entity_form'           => 
$this->_db->f('entity_form'),
-                                       'column_name'           => 
$this->_db->f('column_name'),
-                                       'name'                          => 
$this->_db->f('column_name'),
-                                       'size'                          => 
$this->_db->f('size'),
-                                       'statustext'            => 
$this->_db->f('statustext', true),
-                                       'input_text'            => 
$this->_db->f('input_text', true),
-                                       'type_name'                     => 
$this->_db->f('type'),
-                                       'datatype'                      => 
$this->_db->f('datatype'),
-                                       'search'                        => 
$this->_db->f('search'),
-                                       'trans_datatype'        => 
$this->translate_datatype($this->_db->f('datatype')),
-                                       'nullable'                      => 
($this->_db->f('nullable') == 'True'),
-                                       //'allow_null'          => 
($this->_db->f('nullable') == 'True'), // FIXME
-                                       'history'                       => 
$this->_db->f('history'),
-                                       'disabled'                      => 
$this->_db->f('disabled'),
-                                       'helpmsg'                       => 
!!$this->_db->f('helpmsg')
+                                       'entity_type'                   => 
$this->_db->f('type_id'),
+                                       'group_id'                              
=> (int) $this->_db->f('group_id'),                                     
+                                       'attrib_sort'                   => 
(int) $this->_db->f('attrib_sort'),
+                                       'list'                                  
=> $this->_db->f('list'),
+                                       'lookup_form'                   => 
$this->_db->f('lookup_form'),
+                                       'entity_form'                   => 
$this->_db->f('entity_form'),
+                                       'column_name'                   => 
$this->_db->f('column_name'),
+                                       'name'                                  
=> $this->_db->f('column_name'),
+                                       'size'                                  
=> $this->_db->f('size'),
+                                       'statustext'                    => 
$this->_db->f('statustext', true),
+                                       'input_text'                    => 
$this->_db->f('input_text', true),
+                                       'type_name'                             
=> $this->_db->f('type'),
+                                       'datatype'                              
=> $this->_db->f('datatype'),
+                                       'search'                                
=> $this->_db->f('search'),
+                                       'trans_datatype'                => 
$this->translate_datatype($this->_db->f('datatype')),
+                                       'nullable'                              
=> ($this->_db->f('nullable') == 'True'),
+                                       //'allow_null'                  => 
($this->_db->f('nullable') == 'True'), // FIXME
+                                       'history'                               
=> $this->_db->f('history'),
+                                       'disabled'                              
=> $this->_db->f('disabled'),
+                                       'helpmsg'                               
=> !!$this->_db->f('helpmsg'),
+                                       'get_list_function'             => 
$this->_db->f('get_list_function'),
+                                       'get_list_function_input' => 
$this->_db->f('get_list_function_input') ? 
unserialize($this->_db->f('get_list_function_input', true)) : '',
+                                       'get_single_function'           => 
$this->_db->f('get_single_function'),
+                                       'get_single_function_input' => 
$this->_db->f('get_single_function_input') ? 
unserialize($this->_db->f('get_single_function_input', true)) : '',
 
                                );
                        }
@@ -1143,33 +1175,38 @@
 
                        $attrib = array
                        (
-                               'id'                    => $this->_db->f('id'),
-                               'group_id'              => 
$this->_db->f('group_id'),
-                               'column_name'   => $this->_db->f('column_name', 
true),
-                               'input_text'    => $this->_db->f('input_text', 
true),
-                               'statustext'    => $this->_db->f('statustext', 
true),
-                               'type_id'               => 
$this->_db->f('type_id'),
-                               'type_name'             => 
$this->_db->f('type_name'),
-                               'lookup_form'   => $this->_db->f('lookup_form'),
-                               'list'                  => 
!!$this->_db->f('list'),
-                               'search'                => 
!!$this->_db->f('search'),
-                               'history'               => 
!!$this->_db->f('history'),
-                               'location_id'   => $this->_db->f('location_id'),
+                               'id'                                    => 
$this->_db->f('id'),
+                               'group_id'                              => 
$this->_db->f('group_id'),
+                               'column_name'                   => 
$this->_db->f('column_name', true),
+                               'input_text'                    => 
$this->_db->f('input_text', true),
+                               'statustext'                    => 
$this->_db->f('statustext', true),
+                               'type_id'                               => 
$this->_db->f('type_id'),
+                               'type_name'                             => 
$this->_db->f('type_name'),
+                               'lookup_form'                   => 
$this->_db->f('lookup_form'),
+                               'list'                                  => 
!!$this->_db->f('list'),
+                               'search'                                => 
!!$this->_db->f('search'),
+                               'history'                               => 
!!$this->_db->f('history'),
+                               'location_id'                   => 
$this->_db->f('location_id'),
                                // FIXME this is broken it should be a small 
int and used as a bool
-                               'nullable'              => 
$this->_db->f('nullable') == 'True',
+                               'nullable'                              => 
$this->_db->f('nullable') == 'True',
                                // FIXME this isn't needed
-                               //'allow_null'  => $this->_db->f('nullable') == 
'True',
-                               'disabled'              => 
!!$this->_db->f('disabled'),
-                               'helpmsg'               => 
$this->_db->f('helpmsg', true),
-                               'column_info'   => array
-                                                                       (
-                                                                               
'precision'     => $this->_db->f('precision_'),
-                                                                               
'scale'         => $this->_db->f('scale'),
-                                                                               
'default'       => $this->_db->f('default_value', true),
-                                                                               
// more duplicated values
-                                                                               
'nullable'      => $this->_db->f('nullable'),
-                                                                               
'type'          => $this->_db->f('datatype')
-                                                                       )
+                               //'allow_null'                  => 
$this->_db->f('nullable') == 'True',
+                               'disabled'                              => 
!!$this->_db->f('disabled'),
+                               'helpmsg'                               => 
$this->_db->f('helpmsg', true),
+                               'get_list_function'             
=>$this->_db->f('get_list_function',true),
+                               'get_list_function_input' => 
$this->_db->f('get_list_function_input') ? 
unserialize($this->_db->f('get_list_function_input', true)) : '',
+                               'get_single_function'           
=>$this->_db->f('get_single_function',true),
+                               'get_single_function_input' => 
$this->_db->f('get_single_function_input') ? 
unserialize($this->_db->f('get_single_function_input', true)) : '',
+
+                               'column_info'                   => array
+                                                                               
(
+                                                                               
        'precision'     => $this->_db->f('precision_'),
+                                                                               
        'scale'         => $this->_db->f('scale'),
+                                                                               
        'default'       => $this->_db->f('default_value', true),
+                                                                               
        // more duplicated values
+                                                                               
        'nullable'      => $this->_db->f('nullable'),
+                                                                               
        'type'          => $this->_db->f('datatype')
+                                                                               
)
                        );
 
                        if ( $inc_choices )
@@ -1594,7 +1631,9 @@
                                'pwd'           => 'varchar',
                                'user'          => 'int',
                                'event'         => 'int',
-                               'bolean'        => 'int'
+                               'bolean'        => 'int',
+                               'custom1'       => 'int',
+                               'custom2'       => 'int',
                        );
 
                        if ( !isset($datatype_text[$datatype]) )
@@ -1627,7 +1666,9 @@
                                'pwd'           => 32,
                                'user'          => 4,
                                'event'         => 4,
-                               'bolean'        => 2
+                               'bolean'        => 2,
+                               'custom1'       => 4,
+                               'custom2'       => 4
                        );
 
                        if ( !isset($datatype_precision[$datatype]) )
@@ -1636,4 +1677,38 @@
                        }
                        return $datatype_precision[$datatype];
                }
+
+               /**
+                * validate and translate function input
+                *
+                * @param string $data the data to validate
+                *
+                * @return input in appropriate format: array or single value
+                */
+               protected function _validate_function_input($data)
+               {
+                       if(ctype_digit($data))
+                       {
+                               return $data;
+                       }
+                       else
+                       {
+                               $_test_input = 
str_replace(array("\n","\r","\t", 'Array', 'array', '[', ']', '(', ')', ' ', 
'&gt;'), array(',','','','','','','','','','',''), stripslashes($data));
+                               $_test_input= explode(',', $_test_input);
+                               if(is_array($_test_input))
+                               {
+                                       foreach($_test_input as $set)
+                                       {
+                                               $_set = explode('=', $set);
+                                               if(!$_set[1])
+                                               {
+                                                       continue;
+                                               }
+                                               $_set[0] = 
str_replace(array("'", '"'), '', $_set[0]);
+                                               $data_set[$_set[0]] = 
trim(str_replace(array('"', "'"), '', $_set[1]));
+                                       }
+                               }
+                               return $data_set;
+                       }
+               }
        }

Modified: branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc.inc.php
===================================================================
--- branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc.inc.php  
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/phpgwapi/inc/class.schema_proc.inc.php  
2011-10-17 13:49:52 UTC (rev 7888)
@@ -72,44 +72,49 @@
                                $sSequenceSQL = '';
                                $sTriggerSQL = '';
                                $this->m_oTranslator->indexes_sql = array();
-                               if($this->_GetTableSQL($sTableName, $aTableDef, 
$sTableSQL, $sSequenceSQL, $sTriggerSQL))
+                               
+                               try
                                {
-                                       $sTableSQL = "CREATE TABLE $sTableName 
(\n$sTableSQL\n)"
-                                               . 
$this->m_oTranslator->m_sStatementTerminator;
-                                       if($sSequenceSQL != '')
-                                       {
-                                               $sAllTableSQL .= $sSequenceSQL 
. "\n";
-                                       }
+                                       $this->_GetTableSQL($sTableName, 
$aTableDef, $sTableSQL, $sSequenceSQL, $sTriggerSQL);
+                               }
 
-                                       if($sTriggerSQL != '')
-                                       {
-                                               $sAllTableSQL .= $sTriggerSQL . 
"\n";
-                                       }
-                                       
-                                       $sAllTableSQL .= $sTableSQL . "\n\n";
-
-                                       // postgres and mssql
-                                       
if(isset($this->m_oTranslator->indexes_sql) && 
is_array($this->m_oTranslator->indexes_sql) && 
count($this->m_oTranslator->indexes_sql)>0)
-                                       {
-                                               
foreach($this->m_oTranslator->indexes_sql as $key => $sIndexSQL)
-                                               {
-                                                       $ix_name = 
$key.'_'.$sTableName.'_idx';
-                                                       $IndexSQL = 
str_replace(array('__index_name__','__table_name__'), 
array($ix_name,$sTableName), $sIndexSQL);
-                                                       $sAllTableSQL .= 
$IndexSQL . "\n\n";
-                                               }
-                                       }
-                               }
-                               else
+                               catch(Exception $e)
                                {
                                        if($bOutputHTML)
                                        {
                                                print('<br>SQL:<pre>' . 
$sAllTableSQL . '</pre><br>');
-                                               print('<br>Failed generating 
script for <b>' . $sTableName . '</b><br>');
-                                               echo '<pre style="text-align: 
left;">'.$sTableName.' = '; print_r($aTableDef); echo "</pre>\n";
                                        }
 
+                                       print('<br>Error: Failed generating 
script for <b>' . $sTableName . '</b><br>');
+                                       echo '<pre style="text-align: 
left;">'.$sTableName.' = '; print_r($aTableDef); echo "</pre>\n";
+                                       echo $e->getMessage();
                                        return false;
                                }
+                               
+                               $sTableSQL = "CREATE TABLE $sTableName 
(\n$sTableSQL\n)"
+                                       . 
$this->m_oTranslator->m_sStatementTerminator;
+                               if($sSequenceSQL != '')
+                               {
+                                       $sAllTableSQL .= $sSequenceSQL . "\n";
+                               }
+
+                               if($sTriggerSQL != '')
+                               {
+                                       $sAllTableSQL .= $sTriggerSQL . "\n";
+                               }
+                                       
+                               $sAllTableSQL .= $sTableSQL . "\n\n";
+
+                               // postgres and mssql
+                               if(isset($this->m_oTranslator->indexes_sql) && 
is_array($this->m_oTranslator->indexes_sql) && 
count($this->m_oTranslator->indexes_sql)>0)
+                               {
+                                       
foreach($this->m_oTranslator->indexes_sql as $key => $sIndexSQL)
+                                       {
+                                               $ix_name = 
$key.'_'.$sTableName.'_idx';
+                                               $IndexSQL = 
str_replace(array('__index_name__','__table_name__'), 
array($ix_name,$sTableName), $sIndexSQL);
+                                               $sAllTableSQL .= $IndexSQL . 
"\n\n";
+                                       }
+                               }
                        }
 
                        if($bOutputHTML)
@@ -321,29 +326,34 @@
                        while(list($sFieldName, $aFieldAttr) = 
each($aTableDef['fd']))
                        {
                                $sFieldSQL = '';
-                               if($this->_GetFieldSQL($aFieldAttr, $sFieldSQL))
+                               
+                               try
                                {
-                                       if($sTableSQL != '')
-                                       {
-                                               $sTableSQL .= ",\n";
-                                       }
+                                       $this->_GetFieldSQL($aFieldAttr, 
$sFieldSQL);
+                               }
+                               catch(Exception $e)
+                               {
+                                       $_message = "Error: GetFieldSQL failed 
for <b>{$sTableName}::{$sFieldName}</b>. ";
+                                       $_message .=  $e->getMessage();
+                                       throw new Exception($_message);
+                                       return False;
+                               }
+                               
+                               if($sTableSQL != '')
+                               {
+                                       $sTableSQL .= ",\n";
+                               }
 
-                                       $sTableSQL .= "$sFieldName $sFieldSQL";
+                               $sTableSQL .= "$sFieldName $sFieldSQL";
 
-                                       if($aFieldAttr['type'] == 'auto')
+                               if($aFieldAttr['type'] == 'auto')
+                               {
+                                       $sbufTriggerFD[] = $sFieldName;
+                                       
if($this->m_oTranslator->GetSequenceSQL($sTableName, $sSequenceSQL))
                                        {
-                                               $sbufTriggerFD[] = $sFieldName;
-                                               
if($this->m_oTranslator->GetSequenceSQL($sTableName, $sSequenceSQL))
-                                               {
-                                                       $sTableSQL .= sprintf(" 
DEFAULT nextval('seq_%s')", $sTableName);
-                                               }
+                                               $sTableSQL .= sprintf(" DEFAULT 
nextval('seq_%s')", $sTableName);
                                        }
                                }
-                               else
-                               {
-                                       if($DEBUG) { echo 'GetFieldSQL failed 
for ' . $sFieldName; }
-                                       return False;
-                               }
                        }
 
                        $sUCSQL = '';
@@ -521,9 +531,11 @@
                                if($DEBUG) { echo '<br>_GetFieldSQL(): Outgoing 
SQL:   ' . $sFieldSQL; }
                                return true;
                        }
+                       else
+                       {
+                               throw new Exception( 'Failed to translate 
field: type[' . $sType . '] precision[' . $iPrecision . '] scale[' . $iScale . 
']');
+                       }
 
-                       if($DEBUG) { echo '<br>Failed to translate field: 
type[' . $sType . '] precision[' . $iPrecision . '] scale[' . $iScale . 
']<br>'; }
-
                        return False;
                }
 

Modified: branches/Version-1_0-branch/phpgwapi/setup/setup.inc.php
===================================================================
--- branches/Version-1_0-branch/phpgwapi/setup/setup.inc.php    2011-10-17 
13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/phpgwapi/setup/setup.inc.php    2011-10-17 
13:49:52 UTC (rev 7888)
@@ -12,7 +12,7 @@
        // Basic information about this app
        $setup_info['phpgwapi']['name']      = 'phpgwapi';
        $setup_info['phpgwapi']['title']     = 'phpgwapi';
-       $setup_info['phpgwapi']['version']   = '0.9.17.535';
+       $setup_info['phpgwapi']['version']   = '0.9.17.536';
        $setup_info['phpgwapi']['versions']['current_header'] = '1.31';
        $setup_info['phpgwapi']['versions']['system'] = '1.0';
        $setup_info['phpgwapi']['enable']    = 3;

Modified: branches/Version-1_0-branch/phpgwapi/setup/tables_current.inc.php
===================================================================
--- branches/Version-1_0-branch/phpgwapi/setup/tables_current.inc.php   
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/phpgwapi/setup/tables_current.inc.php   
2011-10-17 13:49:52 UTC (rev 7888)
@@ -577,7 +577,11 @@
                                'disabled' => array('type' => 'int','precision' 
=> 2,'nullable' => true),
                                'lookup_form' => array('type' => 
'int','precision' => 2,'nullable' => true),
                                'custom' => array('type' => 'int','precision' 
=> 2,'nullable' => true,'default' => 1),
-                               'helpmsg' => array('type' => 'text','nullable' 
=> true)
+                               'helpmsg' => array('type' => 'text','nullable' 
=> true),
+                               'get_list_function' => array('type' => 
'varchar','precision' => 255,'nullable' => true),
+                               'get_list_function_input' => array('type' => 
'varchar','precision' => 255,'nullable' => true),
+                               'get_single_function' => array('type' => 
'varchar','precision' => 255,'nullable' => true),
+                               'get_single_function_input' => array('type' => 
'varchar','precision' => 255,'nullable' => true)
                        ),
                        'pk' => array('location_id', 'id'),
                        'fk' => array(),

Modified: branches/Version-1_0-branch/phpgwapi/setup/tables_update.inc.php
===================================================================
--- branches/Version-1_0-branch/phpgwapi/setup/tables_update.inc.php    
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/phpgwapi/setup/tables_update.inc.php    
2011-10-17 13:49:52 UTC (rev 7888)
@@ -2950,3 +2950,43 @@
                        return $GLOBALS['setup_info']['phpgwapi']['currentver'];
                }
        }
+
+       $test[] = '0.9.17.535';
+       /**
+       * Add custom attibute type that allows call to function of choice
+       *
+       * @return string the new version number
+       */
+       function phpgwapi_upgrade0_9_17_535()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cust_attribute','get_list_function',
 array(
+                       'type' => 'varchar',
+                       'precision' => 255,
+                       'nullable' => true
+               ));
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cust_attribute','get_list_function_input',
 array(
+                       'type' => 'varchar',
+                       'precision' => 255,
+                       'nullable' => true
+               ));
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cust_attribute','get_single_function',
 array(
+                       'type' => 'varchar',
+                       'precision' => 255,
+                       'nullable' => true
+               ));
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_cust_attribute','get_single_function_input',
 array(
+                       'type' => 'varchar',
+                       'precision' => 255,
+                       'nullable' => true
+               ));
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['phpgwapi']['currentver'] = 
'0.9.17.536';
+                       return $GLOBALS['setup_info']['phpgwapi']['currentver'];
+               }
+       }

Modified: branches/Version-1_0-branch/property/inc/class.bogeneric.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.bogeneric.inc.php    
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/property/inc/class.bogeneric.inc.php    
2011-10-17 13:49:52 UTC (rev 7888)
@@ -76,7 +76,7 @@
                        $this->cat_id           = isset($_REQUEST['cat_id'])  ? 
$cat_id :  $this->cat_id;
                        $this->allrows          = isset($allrows) ? $allrows : 
false;
 
-                       $this->location_info = 
$this->so->get_location_info($type, $type_id);
+//                     $this->location_info = 
$this->so->get_location_info($type, $type_id);
 
                }
 
@@ -103,9 +103,11 @@
                        $this->allrows  = $data['allrows'];
                }
 
-               public function get_location_info($type,$type_id)
+               public function get_location_info($type = '', $type_id = 0)
                {
-                       return $this->so->get_location_info($type,$type_id);
+                       $type = $type ? $type : $this->type;
+                       $type_id = $type_id ? $type_id : $this->type_id;
+                       return $this->location_info = 
$this->so->get_location_info($type,$type_id);
                }
 
                function column_list($selected='',$allrows='')

Modified: branches/Version-1_0-branch/property/inc/class.custom_fields.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.custom_fields.inc.php        
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/property/inc/class.custom_fields.inc.php        
2011-10-17 13:49:52 UTC (rev 7888)
@@ -188,6 +188,41 @@
                                        $lookup_functions[$m]['action'] = 
'Window1=window.open('."'" . $lookup_link ."'" 
.',"Search","left=50,top=100,width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
                                        $m++;
                                }
+                               else if($attributes['datatype'] == 'custom1') 
// select
+                               {
+                                       $attributes['choice'] = array();
+                                       if($attributes['get_list_function'])
+                                       {
+                                               $attributes['choice'] = 
execMethod($attributes['get_list_function'], 
$attributes['get_list_function_input']);
+                                       }
+                                       foreach ($attributes['choice'] as 
&$_choice)
+                                       {
+                                               $_choice['selected'] = 
$_choice['id'] == $attributes['value'] ? 1 : 0;
+                                       }                                       
+                               }
+                               else if($attributes['datatype'] == 'custom2') 
//lookup
+                               {
+                                       if($attributes['value'] && 
$attributes['get_single_function'])
+                                       {
+                                               
if(!$attributes['get_single_function_input'])
+                                               {
+                                                       
$attributes['get_single_function_input'] = $attributes['value'];
+                                               }
+                                               $attributes['custom_name'] = 
execMethod($attributes['get_single_function'], 
$attributes['get_single_function_input']);
+                                       }
+
+                                       $insert_record_values[]                 
= $attributes['name'];
+                                       $lookup_link                            
        = $GLOBALS['phpgw']->link('/index.php',array(
+                                               'menuaction'                    
=> 'property.uilookup.custom',
+                                               'column'                        
        => $attributes['name'],
+                                               'get_list_function'             
=> $attributes['get_list_function'],
+                                               'get_list_function_input'       
=> urlencode(serialize($attributes['get_list_function_input']))
+                                       ));
+
+                                       $lookup_functions[$m]['name']   = 
'lookup_'. $attributes['name'] .'()';
+                                       $lookup_functions[$m]['action'] = 
'Window1=window.open('."'" . $lookup_link ."'" 
.',"Search","left=50,top=100,width=800,height=700,toolbar=no,scrollbars=yes,resizable=yes");';
+                                       $m++;
+                               }
                                else if($attributes['datatype'] == 'user')
                                {
                                        if($attributes['value'])

Modified: branches/Version-1_0-branch/property/inc/class.uiadmin_entity.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiadmin_entity.inc.php       
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/property/inc/class.uiadmin_entity.inc.php       
2011-10-17 13:49:52 UTC (rev 7888)
@@ -2352,17 +2352,31 @@
                        }
 
                        $link_data = array
-                               (
-                                       'menuaction'    => 
'property.uiadmin_entity.edit_attrib',
-                                       'entity_id'             => $entity_id,
-                                       'cat_id'                => $cat_id,
-                                       'id'                    => $id,
-                                       'type'                  => $this->type
-                               );
+                       (
+                               'menuaction'    => 
'property.uiadmin_entity.edit_attrib',
+                               'entity_id'             => $entity_id,
+                               'cat_id'                => $cat_id,
+                               'id'                    => $id,
+                               'type'                  => $this->type
+                       );
 
-                       if($values['column_info']['type']=='R' || 
$values['column_info']['type']=='CH' || $values['column_info']['type']=='LB')
+                       $multiple_choice = false;
+                       $custom_get_list = false;
+                       $custom_get_single = false;
+                       switch($values['column_info']['type'])
                        {
-                               $multiple_choice= true;
+                               case 'R':
+                               case 'CH':
+                               case 'LB':
+                                       $multiple_choice = true;
+                                       break;
+                               case 'custom1';
+                                       $custom_get_list = true;
+                                       break;
+                               case 'custom2';
+                                       $custom_get_list = true;
+                                       $custom_get_single = true;
+                               default:
                        }
 
                        $entity = $this->bo->read_single($entity_id,false);
@@ -2371,69 +2385,38 @@
                        $msgbox_data = 
(isset($receipt)?$this->bocommon->msgbox_data($receipt):'');
 
                        $data = array
-                               (
-                                       'lang_entity'                           
                => lang('entity'),
-                                       'entity_name'                           
                => $entity['name'],
-                                       'lang_category'                         
                => lang('category'),
-                                       'category_name'                         
                => $category['name'],
+                       (
+                               'entity_name'                                   
        => $entity['name'],
+                               'category_name'                                 
        => $category['name'],
+                               'multiple_choice'                               
        => $multiple_choice,
+                               'value_choice'                                  
        => (isset($values['choice'])?$values['choice']:''),
+                               'custom_get_list'                               
        => $custom_get_list,
+                               'custom_get_single'                             
        => $custom_get_single,
+                               'msgbox_data'                                   
        => $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+                               'form_action'                                   
        => $GLOBALS['phpgw']->link('/index.php',$link_data),
+                               'done_action'                                   
        => $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiadmin_entity.list_attribute', 'entity_id'=> $entity_id, 'cat_id'=> 
$cat_id, 'type' => $this->type)),
+                               'value_id'                                      
                => $id,
+                               'value_column_name'                             
        => $values['column_name'],
+                               'value_input_text'                              
        => $values['input_text'],
+                               'value_statustext'                              
        => $values['statustext'],
+                               'datatype_list'                                 
        => $this->bocommon->select_datatype($values['column_info']['type']),
+                               'attrib_group_list'                             
        => $this->bo->get_attrib_group_list($entity_id,$cat_id, 
$values['group_id']),
+                               'value_precision'                               
        => $values['column_info']['precision'],
+                               'value_scale'                                   
        => $values['column_info']['scale'],
+                               'value_default'                                 
        => $values['column_info']['default'],
+                               'nullable_list'                                 
        => $this->bocommon->select_nullable($values['column_info']['nullable']),
+                               'value_lookup_form'                             
        => $values['lookup_form'],
+                               'value_list'                                    
        => $values['list'],
+                               'value_search'                                  
        => $values['search'],
+                               'value_history'                                 
        => $values['history'],
+                               'value_disabled'                                
        => $values['disabled'],
+                               'value_helpmsg'                                 
        => $values['helpmsg'],
+                               'value_get_list_function'                       
=> $values['get_list_function'],
+                               'value_get_list_function_input'         => 
print_r($values['get_list_function_input'],true),
+                               'value_get_single_function'                     
=> $values['get_single_function'],
+                               'value_get_single_function_input'       => 
print_r($values['get_single_function_input'],true)
+                       );
 
-                                       'lang_choice'                           
                => lang('Choice'),
-                                       'lang_new_value'                        
                => lang('New value'),
-                                       'lang_new_value_statustext'             
        => lang('New value for multiple choice'),
-                                       'multiple_choice'                       
                => (isset($multiple_choice)?$multiple_choice:''),
-                                       'value_choice'                          
                => (isset($values['choice'])?$values['choice']:''),
-                                       'lang_delete_value'                     
                => lang('Delete value'),
-                                       'lang_value'                            
                => lang('value'),
-                                       'lang_delete_choice_statustext'         
=> lang('Delete this value from the list of multiple choice'),
-
-                                       'msgbox_data'                           
                => $GLOBALS['phpgw']->common->msgbox($msgbox_data),
-                                       'form_action'                           
                => $GLOBALS['phpgw']->link('/index.php',$link_data),
-                                       'done_action'                           
                => $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiadmin_entity.list_attribute', 'entity_id'=> $entity_id, 'cat_id'=> 
$cat_id, 'type' => $this->type)),
-                                       'lang_id'                               
                        => lang('Attribute ID'),
-                                       'lang_entity_type'                      
                => lang('Entity type'),
-                                       'lang_no_entity_type'                   
        => lang('No entity type'),
-                                       'lang_save'                             
                        => lang('save'),
-                                       'lang_done'                             
                        => lang('done'),
-                                       'value_id'                              
                        => $id,
-
-                                       'lang_column_name'                      
                => lang('Column name'),
-                                       'value_column_name'                     
                => $values['column_name'],
-                                       'lang_column_name_statustext'           
=> lang('enter the name for the column'),
-
-                                       'lang_input_text'                       
                => lang('input text'),
-                                       'value_input_text'                      
                => $values['input_text'],
-                                       'lang_input_name_statustext'            
=> lang('enter the input text for records'),
-
-                                       'lang_id_attribtext'                    
        => lang('Enter the attribute ID'),
-                                       'lang_entity_statustext'                
        => lang('Select a entity type'),
-
-                                       'lang_statustext'                       
                => lang('Statustext'),
-                                       'lang_statustext_attribtext'            
=> lang('Enter a statustext for the inputfield in forms'),
-                                       'value_statustext'                      
                => $values['statustext'],
-
-                                       'lang_done_attribtext'                  
        => lang('Back to the list'),
-                                       'lang_save_attribtext'                  
        => lang('Save the attribute'),
-
-                                       'datatype_list'                         
                => 
$this->bocommon->select_datatype($values['column_info']['type']),
-
-                                       'attrib_group_list'                     
                => $this->bo->get_attrib_group_list($entity_id,$cat_id, 
$values['group_id']),
-
-                                       'value_precision'                       
                => $values['column_info']['precision'],
-
-                                       'value_scale'                           
                => $values['column_info']['scale'],
-
-                                       'value_default'                         
                => $values['column_info']['default'],
-
-                                       'nullable_list'                         
                => 
$this->bocommon->select_nullable($values['column_info']['nullable']),
-                                       'value_lookup_form'                     
                => $values['lookup_form'],
-                                       'value_list'                            
                => $values['list'],
-                                       'value_search'                          
                => $values['search'],
-                                       'value_history'                         
                => $values['history'],
-                                       'value_disabled'                        
                => $values['disabled'],
-                                       'value_helpmsg'                         
                => $values['helpmsg'],
-                               );
-                       //_debug_array($values);
-
                        $appname = lang('entity');
 
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang($this->type_app[$this->type]) . ' - ' . $appname . ': ' . $function_msg;

Modified: branches/Version-1_0-branch/property/inc/class.uigeneric.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uigeneric.inc.php    
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/property/inc/class.uigeneric.inc.php    
2011-10-17 13:49:52 UTC (rev 7888)
@@ -58,6 +58,7 @@
                        $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
                        $this->account                          = 
$GLOBALS['phpgw_info']['user']['account_id'];
                        $this->bo                                       = 
CreateObject('property.bogeneric',true);
+                       $this->bo->get_location_info();
                        $this->bocommon                         = & 
$this->bo->bocommon;
                        $this->custom                           = & 
$this->bo->custom;
 

Modified: branches/Version-1_0-branch/property/inc/class.uilookup.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uilookup.inc.php     
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/property/inc/class.uilookup.inc.php     
2011-10-17 13:49:52 UTC (rev 7888)
@@ -62,7 +62,8 @@
                                'project_group'         => true,
                                'ecodimb'                       => true,
                                'order_template'        => true,
-                               'response_template'     => true
+                               'response_template'     => true,
+                               'custom'                        => true
                        );
 
                function __construct()
@@ -3300,6 +3301,227 @@
                        $this->save_sessiondata();
                }
 
+               function custom()
+               {
+                       $get_list_function              = 
phpgw::get_var('get_list_function');
+                       $get_list_function_input        = 
urlencode(phpgw::get_var('get_list_function_input'));
+                       $column                                 = 
phpgw::get_var('column');
 
+                       if( phpgw::get_var('phpgw_return_as') != 'json' )
+                       {
+                               $datatable['config']['base_url']        = 
$GLOBALS['phpgw']->link('/index.php', array
+                               (
+                                       'menuaction'                    => 
'property.uilookup.custom',
+                                       'cat_id'                                
=> $this->cat_id,
+                                       'query'                                 
=> $this->query,
+                                       'filter'                                
=> $this->filter,
+                                       'get_list_function'             => 
$get_list_function,
+                                       'get_list_function_input' => 
$get_list_function_input
+                               ));
+                               $datatable['config']['allow_allrows'] = true;
 
+                               $datatable['config']['base_java_url'] = 
"menuaction:'property.uilookup.custom',"
+                                       ."cat_id:'{$this->cat_id}',"
+                                       ."query:'{$this->query}',"
+                                       ."filter:'{$this->filter}',"
+                                       
."get_list_function:'{$get_list_function}',"
+                                       
."get_list_function_input:'{$get_list_function_input}'";
+               
+                               $datatable['actions']['form'] = array
+                                       (
+                                               array
+                                               (
+                                                       'action'        => 
$GLOBALS['phpgw']->link('/index.php',
+                                                       array
+                                                       (
+                                                               'menuaction'    
        => 'property.uilookup.custom',
+                                                               'cat_id'        
                => $this->cat_id,
+                                                               'query'         
                => $this->query,
+                                                               'filter'        
                => $this->filter,
+                                                               
'get_list_function'     => $get_list_function,
+                                                               
'get_list_function_input' => $get_list_function_input
+                                                       )
+                                               ),
+                                               'fields'        => array
+                                               (
+                                                       'field' => array
+                                                       (
+                                                               array
+                                                               ( //boton  
SEARCH
+                                                                       'id' => 
'btn_search',
+                                                                       'name' 
=> 'search',
+                                                                       'value' 
   => lang('search'),
+                                                                       'type' 
=> 'button',
+                                                                       
'tab_index' => 2
+                                                               ),
+                                                               array
+                                                               ( // TEXT IMPUT
+                                                                       'name'  
   => 'query',
+                                                                       'id'    
 => 'txt_query',
+                                                                       'value' 
   => '',//'',//$query,
+                                                                       'type' 
=> 'text',
+                                                                       'size'  
  => 28,
+                                                                       
'onkeypress' => 'return pulsar(event)',
+                                                                       
'tab_index' => 1
+                                                               )
+                                                       ),
+                                                       'hidden_value' => array
+                                                       (
+                                                               )
+                                                       )
+                                               )
+                                       );
+                       }
+
+                       $uicols = array (
+                               'input_type'    =>      array('text','text'),
+                               'name'                  =>      
array('id','name'),
+                               'formatter'             =>      array('',''),
+                               'descr'                 =>      
array(lang('ID'),lang('name'))
+                       );
+
+                       $template_list = array();
+               //      $bo     = CreateObject('property.bogeneric',true);
+               //      $template_list = $bo->read();
+
+                       $template_list = execMethod($get_list_function, 
unserialize(urldecode($_GET['get_list_function_input'])));
+//_debug_array(unserialize(urldecode($get_list_function_input)));
+//_debug_array(unserialize(urldecode($_GET['get_list_function_input'])));
+                       $content = array();
+                       $j=0;
+                       if (isset($template_list) && is_array($template_list))
+                       {
+                               foreach($template_list as $template_entry)
+                               {
+                                       for 
($i=0;$i<count($uicols['name']);$i++)
+                                       {
+                                               
$datatable['rows']['row'][$j]['column'][$i]['value']    = 
$template_entry[$uicols['name'][$i]];
+                                               
$datatable['rows']['row'][$j]['column'][$i]['name']     = $uicols['name'][$i];
+                                       }
+                                       $j++;
+                               }
+                       }
+
+                       $uicols_count   = count($uicols['descr']);
+                       $datatable['rowactions']['action'] = array();
+                       for ($i=0;$i<$uicols_count;$i++)
+                       {
+                               //all colums should be have formatter
+                               
$datatable['headers']['header'][$i]['formatter'] = 
($uicols['formatter'][$i]==''?  '""' : $uicols['formatter'][$i]);
+
+                               $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]['sortable'] 
                = true;
+                               
$datatable['headers']['header'][$i]['sort_field']               = 
$uicols['name'][$i];
+                       }
+
+                       $custom_id              = $column;
+                       $custom_name    = $column . '_name';
+
+                       $function_exchange_values = '';
+
+                       $function_exchange_values .= 
'opener.document.getElementsByName("'.$custom_id.'")[0].value = "";' ."\r\n";
+                       $function_exchange_values .= 
'opener.document.getElementsByName("'.$custom_name.'")[0].value = "";' ."\r\n";
+
+                       $function_exchange_values .= 
'opener.document.getElementsByName("'.$custom_id.'")[0].value = 
data.getData("id");' ."\r\n";
+                       $function_exchange_values .= 
'opener.document.getElementsByName("'.$custom_name.'")[0].value = 
data.getData("name");' ."\r\n";
+
+                       $function_exchange_values .= 'window.close()';
+
+                       $datatable['exchange_values'] = 
$function_exchange_values;
+                       $datatable['valida'] = '';
+
+                       // 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->start;
+                       $datatable['pagination']['records_limit']       = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'];
+                       $datatable['pagination']['records_returned']= 
count($template_list);
+                       $datatable['pagination']['records_total']       = 
$this->bo->total_records;
+
+                       if ( (phpgw::get_var("start")== "") && 
(phpgw::get_var("order",'string')== ""))
+                       {
+                               $datatable['sorting']['order']                  
= 'id'; // name key Column in myColumnDef
+                               $datatable['sorting']['sort']                   
= 'name'; // 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
+                       }
+
+                       $appname                                                
= lang('template');
+                       $function_msg                                   = 
lang('list order template');
+
+
+                       //-- 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>";
+                                               }
+                                               else 
if(isset($column['format']) && $column['format']== "link")
+                                               {
+                                                       
$json_row[$column['name']] = "<a href='".$column['link']."' target='_blank'>" 
.$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 ----------------------
+
+                       // 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);
+
+
+                       //Title of Page
+                       $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('property') . ' - ' . $appname . ': ' . $function_msg;
+
+                       // Prepare YUI Library
+                       $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'lookup.tenant.index', 'property' );
+
+                       $this->save_sessiondata();
+               }
+
+
        }

Modified: branches/Version-1_0-branch/property/templates/base/admin_entity.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/admin_entity.xsl        
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/property/templates/base/admin_entity.xsl        
2011-10-17 13:49:52 UTC (rev 7888)
@@ -1185,7 +1185,7 @@
 
                                        <tr>
                                                <td class="th_text" 
align="left">
-                                                       <xsl:value-of 
select="lang_entity"/>
+                                                       <xsl:value-of 
select="php:function('lang', 'entity')" />
                                                </td>
                                                <td class="th_text" 
align="left">
                                                        <xsl:value-of 
select="entity_name"/>
@@ -1193,7 +1193,7 @@
                                        </tr>
                                        <tr>
                                                <td class="th_text" 
align="left">
-                                                       <xsl:value-of 
select="lang_category"/>
+                                                       <xsl:value-of 
select="php:function('lang', 'category')" />
                                                </td>
                                                <td class="th_text" 
align="left">
                                                        <xsl:value-of 
select="category_name"/>
@@ -1203,7 +1203,7 @@
                                                <xsl:when test="value_id != ''">
                                                        <tr>
                                                                <td 
valign="top">
-                                                                       
<xsl:value-of select="lang_id"/>
+                                                                       
<xsl:value-of select="php:function('lang', 'attribute id')" />
                                                                </td>
                                                                <td>
                                                                        
<xsl:value-of select="value_id"/>
@@ -1213,36 +1213,36 @@
                                        </xsl:choose>
                                        <tr>
                                                <td valign="top">
-                                                       <xsl:value-of 
select="lang_column_name"/>
+                                                       <xsl:value-of 
select="php:function('lang', 'column name')" />
                                                </td>
                                                <td>
                                                        <input type="text" 
name="values[column_name]" value="{value_column_name}" maxlength="50">
                                                                <xsl:attribute 
name="title">
-                                                                       
<xsl:value-of select="lang_column_name_statustext"/>
+                                                                       
<xsl:value-of select="php:function('lang', 'enter the name for the column')" />
                                                                </xsl:attribute>
                                                        </input>
                                                </td>
                                        </tr>
                                        <tr>
                                                <td valign="top">
-                                                       <xsl:value-of 
select="lang_input_text"/>
+                                                       <xsl:value-of 
select="php:function('lang', 'input text')" />
                                                </td>
                                                <td>
                                                        <input type="text" 
name="values[input_text]" value="{value_input_text}" size ="60" maxlength="50">
                                                                <xsl:attribute 
name="title">
-                                                                       
<xsl:value-of select="lang_input_text_statustext"/>
+                                                                       
<xsl:value-of select="php:function('lang', 'enter the input text for records')" 
/>
                                                                </xsl:attribute>
                                                        </input>
                                                </td>
                                        </tr>
                                        <tr>
                                                <td valign="top">
-                                                       <xsl:value-of 
select="lang_statustext"/>
+                                                       <xsl:value-of 
select="php:function('lang', 'statustext')" />
                                                </td>
                                                <td>
                                                        <textarea cols="60" 
rows="10" name="values[statustext]">
                                                                <xsl:attribute 
name="title">
-                                                                       
<xsl:value-of select="lang_statustext_attribtext"/>
+                                                                       
<xsl:value-of select="php:function('lang', 'enter a statustext for the 
inputfield in forms')" />
                                                                </xsl:attribute>
                                                                <xsl:value-of 
select="value_statustext"/>               
                                                        </textarea>
@@ -1417,10 +1417,10 @@
                                        </tr>
 
                                        <xsl:choose>
-                                               <xsl:when test="multiple_choice 
!= ''">
+                                               <xsl:when test="multiple_choice 
= 1">
                                                        <tr>
                                                                <td 
valign="top">
-                                                                       
<xsl:value-of select="lang_choice"/>
+                                                                       
<xsl:value-of select="php:function('lang', 'choice')" />
                                                                </td>
                                                                <td 
align="right">
                                                                        
<xsl:call-template name="choice"/>
@@ -1428,30 +1428,84 @@
                                                        </tr>
                                                </xsl:when>
                                        </xsl:choose>
+                                       <xsl:choose>
+                                               <xsl:when test="custom_get_list 
= 1">
+                                                       <tr>
+                                                               <td 
valign="top">
+                                                                       
<xsl:value-of select="php:function('lang', 'custom get list function')" />
+                                                               </td>
+                                                               <td>
+                                                                       <input 
type="text" name="values[get_list_function]" value="{value_get_list_function}" 
size='60'>
+                                                                               
<xsl:attribute name="title">
+                                                                               
        <xsl:text>&lt;app&gt;.&lt;class&gt;.&lt;function&gt;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td 
valign="top">
+                                                                       
<xsl:value-of select="php:function('lang', 'get list function input')" />
+                                                               </td>
+                                                               <td>
+                                                                       
<textarea cols="60" rows="10" name="values[get_list_function_input]">
+                                                                               
<xsl:attribute name="title">
+                                                                               
        <xsl:text>parameter1 = value1, parameter2 = value2...</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                               
<xsl:value-of select="value_get_list_function_input"/>          
+                                                                       
</textarea>
+                                                               </td>
+                                                       </tr>
+                                               </xsl:when>
+                                       </xsl:choose>
+                                       <xsl:choose>
+                                               <xsl:when 
test="custom_get_single = 1">
+                                                       <tr>
+                                                               <td 
valign="top">
+                                                                       
<xsl:value-of select="php:function('lang', 'custom get single function')" />
+                                                               </td>
+                                                               <td>
+                                                                       <input 
type="text" name="values[get_single_function]" 
value="{value_get_single_function}" size='60'>
+                                                                               
<xsl:attribute name="title">
+                                                                               
        <xsl:text>&lt;app&gt;.&lt;class&gt;.&lt;function&gt;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td 
valign="top">
+                                                                       
<xsl:value-of select="php:function('lang', 'get single function input')" />
+                                                               </td>
+                                                               <td>
+                                                                       
<textarea cols="60" rows="10" name="values[get_single_function_input]">
+                                                                               
<xsl:attribute name="title">
+                                                                               
        <xsl:text>parameter1 = value1, parameter2 = value2...</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                               
<xsl:value-of select="value_get_single_function_input"/>                
+                                                                       
</textarea>
+                                                               </td>
+                                                       </tr>
+                                               </xsl:when>
+                                       </xsl:choose>
+
                                        <tr height="50">
                                                <td>
-                                                       <xsl:variable 
name="lang_save"><xsl:value-of select="lang_save"/></xsl:variable>
-                                                       <input type="submit" 
name="values[save]" value="{$lang_save}" onMouseout="window.status='';return 
true;">
-                                                               <xsl:attribute 
name="onMouseover">
-                                                                       
<xsl:text>window.status='</xsl:text>
-                                                                       
<xsl:value-of select="lang_save_attribtext"/>
-                                                                       
<xsl:text>'; return true;</xsl:text>
+                                                       <xsl:variable 
name="lang_save"><xsl:value-of select="php:function('lang', 'save')" 
/></xsl:variable>
+                                                       <input type="submit" 
name="values[save]" value="{$lang_save}">
+                                                               <xsl:attribute 
name="title">
+                                                                       
<xsl:value-of select="php:function('lang', 'save the attribute')" />
                                                                </xsl:attribute>
                                                        </input>
                                                </td>
                                        </tr>
-
                                </form>
                                <tr>
                                        <td>
                                                <xsl:variable 
name="done_action"><xsl:value-of select="done_action"/></xsl:variable>
-                                               <xsl:variable 
name="lang_done"><xsl:value-of select="lang_done"/></xsl:variable>
+                                               <xsl:variable 
name="lang_done"><xsl:value-of select="php:function('lang', 'done')" 
/></xsl:variable>
                                                <form method="post" 
action="{$done_action}">
-                                                       <input type="submit" 
name="done" value="{$lang_done}" onMouseout="window.status='';return true;">
-                                                               <xsl:attribute 
name="onMouseover">
-                                                                       
<xsl:text>window.status='</xsl:text>
-                                                                       
<xsl:value-of select="lang_done_attribtext"/>
-                                                                       
<xsl:text>'; return true;</xsl:text>
+                                                       <input type="submit" 
name="done" value="{$lang_done}">
+                                                               <xsl:attribute 
name="title">
+                                                                       
<xsl:value-of select="php:function('lang', 'back to the list')" />
                                                                </xsl:attribute>
                                                        </input>
                                                </form>
@@ -1808,7 +1862,7 @@
                                                        <xsl:value-of 
select="php:function('lang', 'order')" />
                                                </td>
                                                <td class="th_text" width="15%" 
align="center">
-                                                       <xsl:value-of 
select="lang_delete_value"/>
+                                                       <xsl:value-of 
select="php:function('lang', 'delete value')" />
                                                </td>
                                        </tr>
                                        <xsl:for-each select="value_choice" >
@@ -1844,11 +1898,9 @@
                                                                </input>
                                                        </td>
                                                        <td align="center">
-                                                               <input 
type="checkbox" name="values[delete_choice][]" value="{id}"  
onMouseout="window.status='';return true;">
-                                                                       
<xsl:attribute name="onMouseover">
-                                                                               
<xsl:text>window.status='</xsl:text>
-                                                                               
<xsl:value-of select="//lang_delete_choice_statustext"/>
-                                                                               
<xsl:text>'; return true;</xsl:text>
+                                                               <input 
type="checkbox" name="values[delete_choice][]" value="{id}">
+                                                                       
<xsl:attribute name="title">
+                                                                               
<xsl:value-of select="php:function('lang', 'delete this value from the list of 
multiple choice')" />
                                                                        
</xsl:attribute>
                                                                </input>
                                                        </td>
@@ -1858,14 +1910,12 @@
                        </xsl:choose>
                        <tr>
                                <td valign="top" colspan='2'>
-                                       <xsl:value-of select="lang_new_value"/>
+                                       <xsl:value-of 
select="php:function('lang', 'new value')" />
                                </td>
                                <td valign="top" colspan='2'>
-                                       <input type="text" 
name="values[new_choice]" onMouseout="window.status='';return true;">
-                                               <xsl:attribute 
name="onMouseover">
-                                                       
<xsl:text>window.status='</xsl:text>
-                                                       <xsl:value-of 
select="lang_new_value_statustext"/>
-                                                       <xsl:text>'; return 
true;</xsl:text>
+                                       <input type="text" 
name="values[new_choice]">
+                                               <xsl:attribute name="title">
+                                                       <xsl:value-of 
select="php:function('lang', 'new value for multiple choice')" />
                                                </xsl:attribute>
                                        </input>
                                </td>

Modified: 
branches/Version-1_0-branch/property/templates/base/attributes_form.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/attributes_form.xsl     
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/property/templates/base/attributes_form.xsl     
2011-10-17 13:49:52 UTC (rev 7888)
@@ -209,6 +209,54 @@
                                                                                
</xsl:choose>
                                                                        </input>
                                                                </xsl:when>
+                                                               <xsl:when 
test="datatype='custom1'">
+                                                                       <select 
name="values_attribute[{counter}][value]" class="forms">
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="disabled!=''">
+                                                                               
                <xsl:attribute name="disabled">
+                                                                               
                        <xsl:text> disabled</xsl:text>
+                                                                               
                </xsl:attribute>
+                                                                               
        </xsl:when>
+                                                                               
</xsl:choose>
+                                                                               
<option value="">
+                                                                               
        <xsl:value-of select="php:function('lang', 'select')" />
+                                                                               
</option>
+                                                                               
<xsl:for-each select="choice">
+                                                                               
        <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+                                                                               
        <xsl:choose>
+                                                                               
                <xsl:when test="selected='1'">
+                                                                               
                        <option value="{$id}" selected="selected"><xsl:value-of 
disable-output-escaping="yes" select="name"/></option>
+                                                                               
                </xsl:when>
+                                                                               
                <xsl:otherwise>
+                                                                               
                        <option value="{$id}"><xsl:value-of 
disable-output-escaping="yes" select="name"/></option>
+                                                                               
                </xsl:otherwise>
+                                                                               
        </xsl:choose>
+                                                                               
</xsl:for-each>
+                                                                       
</select>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='custom2'">
+                                                                       
<xsl:variable name="custom_name"><xsl:value-of 
select="name"/><xsl:text>_name</xsl:text></xsl:variable>
+                                                                       
<xsl:variable name="lookup_function"><xsl:text>lookup_</xsl:text><xsl:value-of 
select="name"/><xsl:text>();</xsl:text></xsl:variable>
+                                                                       <input 
type="text" name="{name}" value="{value}" onClick="{$lookup_function}" 
readonly="readonly" size="6">
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="disabled!=''">
+                                                                               
                <xsl:attribute name="disabled">
+                                                                               
                        <xsl:text> disabled</xsl:text>
+                                                                               
                </xsl:attribute>
+                                                                               
        </xsl:when>
+                                                                               
</xsl:choose>
+                                                                       </input>
+                                                                       <input  
size="30" type="text" name="{$custom_name}" value="{custom_name}"  
onClick="{$lookup_function}" readonly="readonly"> 
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="disabled!=''">
+                                                                               
                <xsl:attribute name="disabled">
+                                                                               
                        <xsl:text> disabled</xsl:text>
+                                                                               
                </xsl:attribute>
+                                                                               
        </xsl:when>
+                                                                               
</xsl:choose>
+                                                                       </input>
+                                                               </xsl:when>
+                                                       
                                                                <xsl:when 
test="datatype='user'">
                                                                        
<xsl:variable name="user_name"><xsl:value-of 
select="name"/><xsl:text>_user_name</xsl:text></xsl:variable>
                                                                        
<xsl:variable name="lookup_function"><xsl:text>lookup_</xsl:text><xsl:value-of 
select="name"/><xsl:text>();</xsl:text></xsl:variable>

Modified: branches/Version-1_0-branch/rental/inc/class.bofellesdata.inc.php
===================================================================
--- branches/Version-1_0-branch/rental/inc/class.bofellesdata.inc.php   
2011-10-17 13:46:34 UTC (rev 7887)
+++ branches/Version-1_0-branch/rental/inc/class.bofellesdata.inc.php   
2011-10-17 13:49:52 UTC (rev 7888)
@@ -21,12 +21,11 @@
                
                public function get_db()
                {
-
                        $config = CreateObject('phpgwapi.config','rental');
                        $config->read();
 
-//                     $db = createObject('phpgwapi.db', null, null, true);
-                       $db = createObject('property.db_oci8');
+                       $db = createObject('phpgwapi.db', null, null, true);
+//                     $db = createObject('property.db_oci8'); // this one was 
intended for premilay testing
 
                        $db->debug = 
!!$config->config_data['external_db_debug'];
                        $db->Host = $config->config_data['external_db_host'];
@@ -167,6 +166,58 @@
                                                
                        return $result_units;
                }
+
+               /**
+                * Get id/name for result unit
+                * 
+                * @return array values prepared for standardized select/filter
+                */
+               public function get_result_units_wrapper()
+               {
+                       $result_units = $this->get_result_units();
+                       $values = array();
+                       foreach($result_units as $result_unit)
+                       {
+                               $values[] = array
+                               (
+                                       'id'    => $result_unit['ORG_UNIT_ID'],
+                                       'name'  => "{$result_unit['UNIT_ID']} - 
{$result_unit['ORG_UNIT_NAME']}"
+                               );
+                       }
+                       return $values;
+               }
+
+
+               /**
+                * Get id/name for org unit
+                * @param integer $level level in organization hierarchy
+                * 
+                * @return array values prepared for standardized select/filter
+                */
+               public function get_org_units($level = 1)
+               {
+                       $this->log(__class__, __function__);                    
+
+                       $level = (int) $level;
+                       $columns = "V_ORG_ENHET.ORG_ENHET_ID, 
V_ORG_ENHET.ORG_NAVN";
+                       $tables = "V_ORG_ENHET";
+                       $sql = "SELECT {$columns} FROM {$tables} WHERE 
V_ORG_ENHET.ORG_NIVAA = {$level} ORDER BY V_ORG_ENHET.ORG_NAVN ASC";
+                       $db = $this->get_db();
+                       $db->query($sql,__LINE__,__FILE__);                     
+               
+                       $values = array();
+                       while($db->next_record())
+                       {
+                               $values[] = array
+                               (
+                                       'id'    => (int)$db->f('ORG_ENHET_ID'),
+                                       'name'  => $db->f('ORG_NAVN'),
+                               );
+                       }
+                                               
+                       return $values;
+               }
+
                
                public function get_result_unit_with_leader($org_unit_id)
                {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]