phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] demo inc/class.bodemo.inc.php inc/class.sodemo....


From: Sigurd Nes
Subject: [Phpgroupware-cvs] demo inc/class.bodemo.inc.php inc/class.sodemo....
Date: Sun, 19 Nov 2006 19:02:36 +0000

CVSROOT:        /sources/phpgroupware
Module name:    demo
Changes by:     Sigurd Nes <sigurdne>   06/11/19 19:02:36

Modified files:
        inc            : class.bodemo.inc.php class.sodemo.inc.php 
                         class.uidemo.inc.php hook_admin.inc.php 
        setup          : default_records.inc.php setup.inc.php 
                         tables_current.inc.php 
        templates/base : demo.xsl 
Added files:
        inc/custom     : demo_custom.php 
        templates/base : attributes_form.xsl attributes_view.xsl 

Log message:
        partially updated for custom fields and custom funtions

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/demo/inc/class.bodemo.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/demo/inc/class.sodemo.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/demo/inc/class.uidemo.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/demo/inc/hook_admin.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/demo/inc/custom/demo_custom.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/demo/setup/default_records.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/demo/setup/setup.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/demo/setup/tables_current.inc.php?cvsroot=phpgroupware&r1=1.1.1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/demo/templates/base/demo.xsl?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/demo/templates/base/attributes_form.xsl?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/demo/templates/base/attributes_view.xsl?cvsroot=phpgroupware&rev=1.1

Patches:
Index: inc/class.bodemo.inc.php
===================================================================
RCS file: /sources/phpgroupware/demo/inc/class.bodemo.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- inc/class.bodemo.inc.php    15 Nov 2006 14:52:25 -0000      1.2
+++ inc/class.bodemo.inc.php    19 Nov 2006 19:02:36 -0000      1.3
@@ -8,7 +8,7 @@
        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
        * @package hrm
        * @subpackage demo
-       * @version $Id: class.bodemo.inc.php,v 1.2 2006/11/15 14:52:25 sigurdne 
Exp $
+       * @version $Id: class.bodemo.inc.php,v 1.3 2006/11/19 19:02:36 sigurdne 
Exp $
        */
 
        /**
@@ -39,6 +39,7 @@
                {
                        $this->currentapp       = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
                        $this->so                       = 
CreateObject($this->currentapp.'.sodemo');
+                       $this->custom           = 
createObject('phpgwapi.custom_fields');
 
                        if ($session)
                        {
@@ -87,6 +88,26 @@
                        {
                                $this->allrows = $allrows;
                        }
+
+                       switch($GLOBALS['phpgw_info']['server']['db_type'])
+                       {
+                               case 'mssql':
+                                       $this->dateformat               = "M d 
Y";
+                                       $this->datetimeformat   = "M d Y g:iA";
+                                       break;
+                               case 'mysql':
+                                       $this->dateformat               = 
"Y-m-d";
+                                       $this->datetimeformat   = "Y-m-d G:i:s";
+                                       break;
+                               case 'pgsql':
+                                       $this->dateformat               = 
"Y-m-d";
+                                       $this->datetimeformat   = "Y-m-d G:i:s";
+                                       break;
+                               case 'postgres':
+                                       $this->dateformat               = 
"Y-m-d";
+                                       $this->datetimeformat   = "Y-m-d G:i:s";
+                                       break;
+                       }
                }
 
 
@@ -118,14 +139,22 @@
                function read()
                {
                        $demo_info = $this->so->read(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
-                                                                               
        'allrows'=>$this->allrows));
+                                                                               
        'cat_id'=>$this->cat_id,'allrows'=>$this->allrows));
                        $this->total_records = $this->so->total_records;
                        return $demo_info;
                }
 
-               function read_single($id)
+               function read_single($id='')
                {
-                       $values =$this->so->read_single($id);
+                       $values['attributes'] = 
$this->custom->get_attribs('demo', '.demo_location', 0, '', 'ASC', 
'attrib_sort', true, true);
+                       
+                       if($id)
+                       {
+                               $values = $this->so->read_single($id,$values);
+                       }
+                       
+                       $values = 
$this->custom->prepare_attributes($values,$appname='demo', 
$location='.demo_location');
+                       
                        $dateformat = 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
                        if($values['entry_date'])
                        {
@@ -135,16 +164,52 @@
                        return $values;
                }
 
+               function save($values,$values_attribute='')
+               {
+                       if(is_array($values_attribute))
+                       {
+                               for ($i=0;$i<count($values_attribute);$i++)
+                               {
+                                       
if($values_attribute[$i]['datatype']=='CH' && $values_attribute[$i]['value'])
+                                       {
+                                               $values_attribute[$i]['value'] 
= serialize($values_attribute[$i]['value']);
+                                       }
+                                       
if($values_attribute[$i]['datatype']=='R' && $values_attribute[$i]['value'])
+                                       {
+                                               $values_attribute[$i]['value'] 
= $values_attribute[$i]['value'][0];
+                                       }
+
+                                       
if($values_attribute[$i]['datatype']=='N' && $values_attribute[$i]['value'])
+                                       {
+                                               $values_attribute[$i]['value'] 
= str_replace(",",".",$values_attribute[$i]['value']);
+                                       }
 
-               function save($values)
+                                       
if($values_attribute[$i]['datatype']=='D' && $values_attribute[$i]['value'])
                {
+                                               $values_attribute[$i]['value'] 
= 
date($this->dateformat,$this->date_to_timestamp($values_attribute[$i]['value']));
+                                       }
+                               }
+                       }
+
+
                        if (isset($values['demo_id']) && $values['demo_id'])
                        {
-                               $receipt = $this->so->edit($values);
+                               $receipt = 
$this->so->edit($values,$values_attribute);
                        }
                        else
                        {
-                               $receipt = $this->so->add($values);
+                               $receipt = 
$this->so->add($values,$values_attribute);
+                       }
+
+                       $custom_functions = 
$this->custom->read_custom_function(array('appname'=>'demo','location' => 
'.demo_location','allrows'=>True));
+
+                       if (isSet($custom_functions) AND 
is_array($custom_functions))
+                       {
+                               foreach($custom_functions as $entry)
+                               {
+                                       if (is_file(PHPGW_APP_INC . SEP . 
'custom' . SEP . $entry['file_name']) && $entry['active'])
+                                       include (PHPGW_APP_INC . SEP . 'custom' 
. SEP . $entry['file_name']);
+                               }
                        }
 
                        return $receipt;
@@ -191,4 +256,55 @@
                        }
                        return $category_list;
                }
+
+               /**
+               * Preserve attribute values from post in case of an error
+               *
+               * @param array $values_attribute attribute definition and 
values from posting
+               * @param array $values value set with 
+               * @return array Array with attribute definition and values
+               */
+               function 
preserve_attribute_values($values='',$values_attribute='')
+               {
+                       return 
$this->custom->preserve_attribute_values($values,$values_attribute);
+               }
+
+               function date_array($date)
+               {
+                       if(!$date)
+                       {
+                               $date_array['day']      = date("d");
+                               $date_array['month']    = date("m");
+                               $date_array['year']     = date("Y");
+                       }
+                       else
+                       {
+                               $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                               $dateformat = str_replace(".","",$dateformat);
+                               $dateformat = str_replace("-","",$dateformat);
+                               $dateformat = str_replace("/","",$dateformat);
+                               $y=strpos($dateformat,'y');
+                               $d=strpos($dateformat,'d');
+                               $m=strpos($dateformat,'m');
+
+                               $dateparts = explode('/', $date);
+                               $date_array['day']      = $dateparts[$d];
+                               $date_array['month']    = $dateparts[$m];
+                               $date_array['year']     = $dateparts[$y];
+                       }
+
+                       return $date_array;
+               }
+
+               function date_to_timestamp($date)
+               {
+                       if($date)
+                       {
+                               $date_array     = $this->date_array($date);
+                               $date   = mktime 
(8,0,0,$date_array['month'],$date_array['day'],$date_array['year']);
+                       }
+                       return $date;
+               }
+
+
        }

Index: inc/class.sodemo.inc.php
===================================================================
RCS file: /sources/phpgroupware/demo/inc/class.sodemo.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- inc/class.sodemo.inc.php    15 Nov 2006 14:52:25 -0000      1.2
+++ inc/class.sodemo.inc.php    19 Nov 2006 19:02:36 -0000      1.3
@@ -8,7 +8,7 @@
        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
        * @package hrm
        * @subpackage demo
-       * @version $Id: class.sodemo.inc.php,v 1.2 2006/11/15 14:52:25 sigurdne 
Exp $
+       * @version $Id: class.sodemo.inc.php,v 1.3 2006/11/19 19:02:36 sigurdne 
Exp $
        */
 
        /**
@@ -53,6 +53,7 @@
                                $sort           = 
(isset($data['sort'])?$data['sort']:'DESC');
                                $order          = 
(isset($data['order'])?$data['order']:'');
                                $allrows        = 
(isset($data['allrows'])?$data['allrows']:'');
+                               $cat_id         = 
(isset($data['cat_id'])?$data['cat_id']:0);
                        }
 
                        $table = 'phpgw_demo_table';
@@ -69,6 +70,11 @@
                                $where= 'AND';
                        }
 
+                       if ($cat_id > 0)
+                       {
+                               $filtermethod .= " $where category='$cat_id' ";
+                               $where= 'AND';
+                       }
 
                        if ($order)
                        {
@@ -117,7 +123,7 @@
                }
 
 
-               function read_single($id)
+               function read_single($id,$values='')
                {
                        $sql = 'SELECT * FROM phpgw_demo_table where id=' . 
intval($id);
 
@@ -133,13 +139,19 @@
                                $values['zip']                  = 
$this->db->f('zip');
                                $values['entry_date']   = 
$this->db->f('entry_date');
                                $values['user_id']              = 
$this->db->f('user_id');
+                               $values['cat_id']               = 
$this->db->f('category');
                                $values['grants']               = 
(int)$this->grants[$this->db->f('user_id')];
+
+                               for ($i=0;$i<count($values['attributes']);$i++)
+                               {
+                                       $values['attributes'][$i]['value']      
= $this->db->f($values['attributes'][$i]['column_name']);
                        }
-                       return $values;
                }
 
+                       return $values;
+               }
 
-               function add($values)
+               function add($values,$values_attribute='')
                {
                        $this->db->transaction_begin();
 
@@ -154,13 +166,72 @@
                                $values['zip'],
                                $values['town'],
                                $values['remark'],
+                               (int)$values['cat_id'],
                                $this->account,
                                time()
                                );
 
+                       if(isset($values['extra']) && 
is_array($values['extra']))
+                       {
+                               while (is_array($values['extra']) && 
list($input_name,$value) = each($values['extra']))
+                               {
+                                       if($value)
+                                       {
+                                               $cols[] = $input_name;
+                                               $vals[] = $value;
+                                       }
+                               }
+                       }
+
+                       if (isset($values_attribute) AND 
is_array($values_attribute))
+                       {
+                               foreach($values_attribute as $entry)
+                               {
+                                       if($entry['value'])
+                                       {
+                                               if($entry['datatype']!='AB' && 
$entry['datatype']!='VENDOR' && $entry['datatype']!='user')
+                                               {
+                                                       if($entry['datatype'] 
== 'C' || $entry['datatype'] == 'T' || $entry['datatype'] == 'V')
+                                                       {
+                                                               $entry['value'] 
= $this->db->db_addslashes($entry['value']);
+                                                       }
+                                               
+                                                       if($entry['datatype'] 
== 'pwd' && $entry['value'] && $entry['value2'])
+                                                       {
+                                                               
if($entry['value'] == $entry['value2'])
+                                                               {
+                                                                       $cols[] 
= $entry['name'];
+                                                                       $vals[] 
= md5($entry['value']);
+                                                               }
+                                                               else
+                                                               {
+                                                                       
$receipt['error'][]=array('msg'=>lang('Passwords do not match!'));
+                                                               }
+                                                       }
+                                                       else
+                                                       {
+                                                               $cols[] = 
$entry['name'];
+                                                               $vals[] = 
$entry['value'];
+                                                       }
+
+                                                       if($entry['history'] == 
1)
+                                                       {
+                                                               
$history_set[$entry['attrib_id']] = $entry['value'];
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+
                        $insert_values  = 
$this->db->validate_insert($insert_values);
-                       $this->db->query("INSERT INTO phpgw_demo_table 
(name,address,zip,town, remark,user_id,entry_date) "
-                               . "VALUES ($insert_values)",__LINE__,__FILE__);
+
+                       if($cols)
+                       {
+                               $cols   = "," . implode(",", $cols);
+                               $vals   = "," . 
$this->db->validate_insert($vals);
+                       }
+                       $this->db->query("INSERT INTO phpgw_demo_table 
(name,address,zip,town, remark,category,user_id,entry_date $cols) "
+                               . "VALUES ($insert_values 
$vals)",__LINE__,__FILE__);
 
                        $receipt['message'][]=array('msg'=>lang('demo item has 
been saved'));
                        $receipt['demo_id']= 
$this->db->get_last_insert_id('phpgw_demo_table','id');
@@ -170,7 +241,7 @@
                        return $receipt;
                }
 
-               function edit($values)
+               function edit($values,$values_attribute='')
                {
                        $this->db->transaction_begin();
 
@@ -179,9 +250,49 @@
                        $value_set['zip']                       = 
$values['zip'];
                        $value_set['remark']            = 
$this->db->db_addslashes($values['remark']);
                        $value_set['town']                      = 
$this->db->db_addslashes($values['town']);
+                       $value_set['category']          = 
(int)$values['cat_id'];
 
-                       $value_set      = 
$this->db->validate_update($value_set);
+                       if(isset($values['extra']) && 
is_array($values['extra']))
+                       {
+                               while (is_array($values['extra']) && 
list($column,$value) = each($values['extra']))
+                               {
+                                       $value_set[$column]     = $value;
+                               }
+                       }
 
+                       if (isset($values_attribute) AND 
is_array($values_attribute))
+                       {
+                               foreach($values_attribute as $entry)
+                               {
+                                       if($entry['datatype']!='AB' && 
$entry['datatype']!='VENDOR' && $entry['datatype']!='user')
+                                       {
+                                               if($entry['datatype'] == 'C' || 
$entry['datatype'] == 'T' || $entry['datatype'] == 'V')
+                                               {
+                                                       $entry['value'] = 
$this->db->db_addslashes($entry['value']);
+                                               }
+                                               if($entry['datatype'] == 'pwd')
+                                               {
+                                                       if($entry['value'] || 
$entry['value2'])
+                                                       {
+                                                               
if($entry['value'] == $entry['value2'])
+                                                               {
+                                                                       
$value_set[$entry['name']]      = md5($entry['value']);
+                                                               }
+                                                               else
+                                                               {
+                                                                       
$receipt['error'][]=array('msg'=>lang('Passwords do not match!'));
+                                                               }
+                                                       }
+                                               }
+                                               else
+                                               {
+                                                       
$value_set[$entry['name']]      = $entry['value'];
+                                               }
+                                       }
+                               }
+                       }
+                       
+                       $value_set      = 
$this->db->validate_update($value_set);
 
                        $this->db->query("UPDATE phpgw_demo_table set 
$value_set WHERE id=" . $values['demo_id'],__LINE__,__FILE__);
 

Index: inc/class.uidemo.inc.php
===================================================================
RCS file: /sources/phpgroupware/demo/inc/class.uidemo.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- inc/class.uidemo.inc.php    15 Nov 2006 14:52:25 -0000      1.2
+++ inc/class.uidemo.inc.php    19 Nov 2006 19:02:36 -0000      1.3
@@ -8,7 +8,7 @@
        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
        * @package hrm
        * @subpackage demo
-       * @version $Id: class.uidemo.inc.php,v 1.2 2006/11/15 14:52:25 sigurdne 
Exp $
+       * @version $Id: class.uidemo.inc.php,v 1.3 2006/11/19 19:02:36 sigurdne 
Exp $
        */
 
        /**
@@ -39,6 +39,7 @@
                {
                        $GLOBALS['phpgw_info']['flags']['xslt_app'] = True;
                        $this->currentapp               = 
$GLOBALS['phpgw_info']['flags']['currentapp'];
+                       $this->cats                             = 
CreateObject('phpgwapi.categories');
                        $this->nextmatchs               = 
CreateObject('phpgwapi.nextmatchs');
                        $this->account                  = 
$GLOBALS['phpgw_info']['user']['account_id'];
                        $this->bo                               = 
CreateObject($this->currentapp.'.bodemo',true);
@@ -200,6 +201,7 @@
                        (
                                'msgbox_data'                                   
                => $GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                'links'                                         
                        => $links,
+                               'cat_filter'                                    
                => $this->cats->formatted_xslt_list(array('select_name' => 
'cat_id','selected' => $this->cat_id,'globals' => True,'link_data' => 
$link_data)),
                                'allow_allrows'                                 
                => True,
                                'allrows'                                       
                        => $this->allrows,
                                'start_record'                                  
                => $this->start,
@@ -232,7 +234,8 @@
 
                function edit()
                {
-                       if(!$this->acl->check('.demo_location', PHPGW_ACL_ADD))
+                       $acl_location = '.demo_location';
+                       if(!$this->acl->check($acl_location, PHPGW_ACL_ADD))
                        {
                                $this->no_access();
                                return;
@@ -247,17 +250,36 @@
 
                        $demo_id        = 
get_var('demo_id',array('POST','GET'));
                        $values         = get_var('values',array('POST'));
+                       $values_attribute  = 
get_var('values_attribute',array('POST'));
 
-                       $GLOBALS['phpgw']->xslttpl->add_file(array('demo'));
+                       $insert_record_values = 
$GLOBALS['phpgw']->session->appsession('insert_record_values'. 
$acl_location,'demo');
+
+                       for ($j=0;$j<count($insert_record_values);$j++)
+                       {
+                               
$insert_record['extra'][$insert_record_values[$j]]      = 
$insert_record_values[$j];
+                       }
+
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('demo','attributes_form'));
 
                        if (isset($values) && is_array($values))
                        {
-                               if(!$this->acl->check('.demo_location', 
PHPGW_ACL_EDIT))
+                               if(!$this->acl->check($acl_location, 
PHPGW_ACL_EDIT))
                                {
                                        $this->no_access($links);
                                        return;
                                }
 
+                               if(isset($insert_record['extra']) && 
is_array($insert_record['extra']))
+                               {
+                                       while 
(is_array($insert_record['extra']) && list($key,$column) = 
each($insert_record['extra']))
+                                       {
+                                               if($_POST[$key])
+                                               {
+                                                       
$values['extra'][$column]       = $_POST[$key];
+                                               }
+                                       }
+                               }
+
                                if ((isset($values['save']) && $values['save']) 
|| (isset($values['apply']) && $values['apply']))
                                {
 
@@ -285,7 +307,7 @@
 
                                        if(!isset($receipt['error']) || 
!$receipt['error'])
                                        {
-                                               $receipt = 
$this->bo->save($values);
+                                               $receipt = 
$this->bo->save($values,$values_attribute);
                                                $demo_id = $receipt['demo_id'];
 
                                                if (isset($values['save']) && 
$values['save'])
@@ -301,13 +323,16 @@
                                }
                        }
 
+                       $values = $this->bo->read_single($demo_id);
 
-                       if ($demo_id)
+                       /* Preserve attribute values from post */
+                       if(isset($receipt['error']) && (isset( 
$values_attribute) && is_array( $values_attribute)))
                        {
-                               if(!isset($receipt['error']) || 
!$receipt['error'])
-                               {
-                                       $values = 
$this->bo->read_single($demo_id);
+                               $values = 
$this->bo->preserve_attribute_values($values,$values_attribute);
                                }
+
+                       if ($demo_id)
+                       {
                                $function_msg = lang('edit demo');
                        }
                        else
@@ -350,6 +375,11 @@
                                'lang_save_status_text'         => lang('Save 
the training'),
                                'lang_apply'                            => 
lang('apply'),
                                'lang_apply_status_text'        => lang('Apply 
the values'),
+
+                               'lang_category'                         => 
lang('category'),
+                               'lang_no_cat'                           => 
lang('no category'),
+                               'cat_select'                            => 
$this->cats->formatted_xslt_list(array('select_name' => 
'values[cat_id]','selected' => $values['cat_id'])),
+                               'attributes_values'                     => 
$values['attributes'],
                        );
 
                        $appname                = lang('demo');
@@ -380,7 +410,7 @@
                        $demo_id        = 
get_var('demo_id',array('POST','GET'));
                        $values         = get_var('values',array('POST'));
 
-                       $GLOBALS['phpgw']->xslttpl->add_file(array('demo'));
+                       
$GLOBALS['phpgw']->xslttpl->add_file(array('demo','attributes_view'));
 
                        if ($demo_id)
                        {
@@ -392,7 +422,6 @@
                                return;
                        }
 
-
                        $data = array
                        (
                                'value_entry_date'                      => 
(isset($values['entry_date'])?$values['entry_date']:''),
@@ -413,6 +442,9 @@
                                'form_action'                   => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction'=> 
$this->currentapp.'.uidemo.index','output'=>$output)),
                                'lang_cancel'                   => 
lang('cancel'),
                                'value_id'                              => 
$demo_id,
+                               'lang_category'                         => 
lang('category'),
+                               'value_cat'                                     
=> $this->cats->id2name($values['cat_id']),
+                               'attributes_values'                     => 
$values['attributes'],
                        );
 
                        $appname        = lang('demo');

Index: inc/hook_admin.inc.php
===================================================================
RCS file: /sources/phpgroupware/demo/inc/hook_admin.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- inc/hook_admin.inc.php      10 Nov 2006 15:05:23 -0000      1.1.1.1
+++ inc/hook_admin.inc.php      19 Nov 2006 19:02:36 -0000      1.2
@@ -8,7 +8,7 @@
        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
        * @package demo
        * @subpackage admin
-       * @version $Id: hook_admin.inc.php,v 1.1.1.1 2006/11/10 15:05:23 
sigurdne Exp $
+       * @version $Id: hook_admin.inc.php,v 1.2 2006/11/19 19:02:36 sigurdne 
Exp $
        */
 
                {
@@ -16,6 +16,8 @@
                        (
                                'Global Categories'             => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.uicategories.index', 'appname' => $appname)),
                                'Configure Access Permissions'  => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'preferences.uiadmin_acl.list_acl', 'acl_app' => $appname)),
+                               'custom fields'                 => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.ui_custom.list_attribute', 'appname' => $appname)),
+                               'custom functions'              => 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'admin.ui_custom.list_custom_function', 'appname' =>  $appname))
                        );
                        
$GLOBALS['phpgw']->common->display_mainscreen($appname,$file);
                }

Index: setup/default_records.inc.php
===================================================================
RCS file: /sources/phpgroupware/demo/setup/default_records.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- setup/default_records.inc.php       15 Nov 2006 14:52:25 -0000      1.2
+++ setup/default_records.inc.php       19 Nov 2006 19:02:36 -0000      1.3
@@ -8,7 +8,7 @@
        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
        * @package demo
        * @subpackage setup
-       * @version $Id: default_records.inc.php,v 1.2 2006/11/15 14:52:25 
sigurdne Exp $
+       * @version $Id: default_records.inc.php,v 1.3 2006/11/19 19:02:36 
sigurdne Exp $
        */
 
 
@@ -19,7 +19,7 @@
 
        $GLOBALS['phpgw_setup']->oProc->query("DELETE FROM phpgw_acl_location 
WHERE appname = 'demo'");
        $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_acl_location 
(appname,id, descr) VALUES ('demo', '.', 'Top')");
-       $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_acl_location 
(appname,id, descr, allow_grant) VALUES ('demo', '.demo_location', 'Demo 
location',1)");
+       $GLOBALS['phpgw_setup']->oProc->query("INSERT INTO phpgw_acl_location 
(appname,id, descr, allow_grant,allow_c_attrib,c_attrib_table) VALUES ('demo', 
'.demo_location', 'Demo location',1,1,'phpgw_demo_table')");
        $GLOBALS['phpgw_setup']->oProc->query("SELECT max(account_id) as 
account_id from phpgw_accounts WHERE account_type = 'u'");
        $GLOBALS['phpgw_setup']->oProc->next_record();
        $account_id = $GLOBALS['phpgw_setup']->oProc->f('account_id');

Index: setup/setup.inc.php
===================================================================
RCS file: /sources/phpgroupware/demo/setup/setup.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- setup/setup.inc.php 12 Nov 2006 10:56:36 -0000      1.2
+++ setup/setup.inc.php 19 Nov 2006 19:02:36 -0000      1.3
@@ -8,12 +8,12 @@
        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
        * @package demo
        * @subpackage setup
-       * @version $Id: setup.inc.php,v 1.2 2006/11/12 10:56:36 sigurdne Exp $
+       * @version $Id: setup.inc.php,v 1.3 2006/11/19 19:02:36 sigurdne Exp $
        */
 
        $setup_info['demo']['name']      = 'demo';
        $setup_info['demo']['title']     = 'Demo application';
-       $setup_info['demo']['version']   = '0.9.17.000';
+       $setup_info['demo']['version']   = '0.9.17.001';
        $setup_info['demo']['app_order'] = 20;
        $setup_info['demo']['enable']    = 1;
        $setup_info['demo']['globals_checked']    = True;

Index: setup/tables_current.inc.php
===================================================================
RCS file: /sources/phpgroupware/demo/setup/tables_current.inc.php,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -b -r1.1.1.1 -r1.2
--- setup/tables_current.inc.php        10 Nov 2006 15:05:23 -0000      1.1.1.1
+++ setup/tables_current.inc.php        19 Nov 2006 19:02:36 -0000      1.2
@@ -8,7 +8,7 @@
        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
        * @package hrm
        * @subpackage setup
-       * @version $Id: tables_current.inc.php,v 1.1.1.1 2006/11/10 15:05:23 
sigurdne Exp $
+       * @version $Id: tables_current.inc.php,v 1.2 2006/11/19 19:02:36 
sigurdne Exp $
        */
 
        $phpgw_baseline = array(
@@ -24,6 +24,7 @@
                                'zip' => array('type' => 'int','precision' => 
'4','nullable' => True),
                                'town' => array('type' => 'varchar','precision' 
=> '255','nullable' => False),
                                'remark' => array('type' => 'text','nullable' 
=> True),
+                               'category' => array('type' => 'int','precision' 
=> '4','nullable' => True),
                        ),
                        'pk' => array('id'),
                        'fk' => array(),

Index: templates/base/demo.xsl
===================================================================
RCS file: /sources/phpgroupware/demo/templates/base/demo.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- templates/base/demo.xsl     15 Nov 2006 14:52:25 -0000      1.2
+++ templates/base/demo.xsl     19 Nov 2006 19:02:36 -0000      1.3
@@ -1,4 +1,4 @@
-<!-- $Id: demo.xsl,v 1.2 2006/11/15 14:52:25 sigurdne Exp $ -->
+<!-- $Id: demo.xsl,v 1.3 2006/11/19 19:02:36 sigurdne Exp $ -->
 
        <xsl:template name="app_data">
                <xsl:choose>
@@ -31,6 +31,9 @@
                                </xsl:when>
                        </xsl:choose>
                        <tr>
+                               <td>
+                                       <xsl:call-template name="categories"/>
+                               </td>
                                <td align="right">
                                        <xsl:call-template name="search_field"/>
                                </td>
@@ -38,14 +41,16 @@
                        <tr>
                                <td colspan="3" width="100%">
                                        <xsl:call-template name="nextmatchs"/>
-                                       <!--    <xsl:with-param 
name="nextmatchs_params"/>
-                                       </xsl:call-template> -->
                                </td>
                        </tr>
                </table>
                <table width="100%" cellpadding="2" cellspacing="2" 
align="center">
                                <xsl:apply-templates select="table_header"/>
+                       <xsl:choose>
+                               <xsl:when test="values != ''">
                                <xsl:apply-templates select="values"/>
+                               </xsl:when>
+                       </xsl:choose>
                                <xsl:apply-templates select="table_add"/>
                </table>
        </xsl:template>
@@ -148,6 +153,9 @@
                                </xsl:when>
                        </xsl:choose>
                        <tr>
+                               <td>
+                                       <xsl:call-template name="categories"/>
+                               </td>
                                <td align="right">
                                        <xsl:call-template name="search_field"/>
                                </td>
@@ -155,14 +163,16 @@
                        <tr>
                                <td colspan="3" width="100%">
                                        <xsl:call-template name="nextmatchs"/>
-                                       <!--    <xsl:with-param 
name="nextmatchs_params"/>
-                                       </xsl:call-template> -->
                                </td>
                        </tr>
                </table>
                <table width="100%" cellpadding="2" cellspacing="2" 
align="center">
                                <xsl:apply-templates select="table_header"/>
+                       <xsl:choose>
+                               <xsl:when test="values != ''">
                                <xsl:apply-templates select="values"/>
+                               </xsl:when>
+                       </xsl:choose>
                                <xsl:apply-templates select="table_add"/>
                </table>
                </card>
@@ -206,6 +216,14 @@
                                </xsl:when>
                        </xsl:choose>   
                        <tr>
+                               <td>
+                                       <xsl:value-of select="lang_category"/>
+                               </td>
+                               <td>
+                                       <xsl:call-template name="categories"/>
+                               </td>
+                       </tr>
+                       <tr>
                                <td valign="top" width="10%">
                                        <xsl:value-of select="lang_name"/>
                                </td>
@@ -270,6 +288,12 @@
                                        </textarea>
                                </td>
                        </tr>
+                       <tr>
+                               <td colspan="2" align="left">                   
        
+                                       <xsl:call-template 
name="attributes_form"/>
+                               </td>
+                       </tr>
+
                        <tr height="50">
                                <td colspan = "2" align = "center"><table><tr>
                                <td valign="bottom">
@@ -333,11 +357,20 @@
                                        </td>
                                </tr>
                        <tr>
+                               <td>
+                                       <xsl:value-of select="lang_category"/>
+                               </td>
+                               <td>
+                                       <xsl:value-of select="value_cat"/>
+                               </td>
+                       </tr>
+
+                       <tr>
                                <td valign="top" width="10%">
                                        <xsl:value-of select="lang_name"/>
                                </td>
                                <td>
-                                       <input type="text" readonly="true" 
size="60" name="values[name]" value="{value_name}"> </input>
+                                       <input type="text" readonly="true" 
size="60" value="{value_name}"> </input>
                                </td>
                        </tr>
                        <tr>
@@ -345,7 +378,7 @@
                                        <xsl:value-of select="lang_address"/>
                                </td>
                                <td>
-                                       <input type="text" readonly="true" 
size="60" name="values[address]" value="{value_address}"></input>
+                                       <input type="text" readonly="true" 
size="60" value="{value_address}"></input>
                                </td>
                        </tr>
                        <tr>
@@ -353,9 +386,9 @@
                                        <xsl:value-of select="lang_zip"/>
                                </td>
                                <td>
-                                       <input type="text" readonly="true" 
size="6" name="values[zip]" value="{value_zip}"></input>
+                                       <input type="text" readonly="true" 
size="6" value="{value_zip}"></input>
                                        <xsl:value-of select="lang_town"/>
-                                       <input type="text" readonly="true" 
size="40" name="values[town]" value="{value_town}"></input>
+                                       <input type="text" readonly="true" 
size="40" value="{value_town}"></input>
                                </td>
                        </tr>
                        <tr>
@@ -363,11 +396,16 @@
                                        <xsl:value-of select="lang_remark"/>
                                </td>
                                <td>
-                                       <textarea cols="60" readonly="true" 
rows="10" name="values[remark]">
+                                       <textarea cols="60" readonly="true" 
rows="10">
                                                <xsl:value-of 
select="value_remark"/>           
                                        </textarea>
                                </td>
                        </tr>
+                       <tr>
+                               <td colspan="2" align="left">                   
        
+                                       <xsl:call-template 
name="attributes_view"/>
+                               </td>
+                       </tr>
                </table>
                <table cellpadding="2" cellspacing="2" width="80%" 
align="center">
                        <tr height="50">

Index: inc/custom/demo_custom.php
===================================================================
RCS file: inc/custom/demo_custom.php
diff -N inc/custom/demo_custom.php
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ inc/custom/demo_custom.php  19 Nov 2006 19:02:36 -0000      1.1
@@ -0,0 +1,9 @@
+<?php
+
+//_debug_array($values);
+//_debug_array($values_attribute);
+
+
+       // Demo - custom function
+
+       echo "<h1>Custom function: do something!</h1>";

Index: templates/base/attributes_form.xsl
===================================================================
RCS file: templates/base/attributes_form.xsl
diff -N templates/base/attributes_form.xsl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ templates/base/attributes_form.xsl  19 Nov 2006 19:02:36 -0000      1.1
@@ -0,0 +1,347 @@
+<!-- $Id: attributes_form.xsl,v 1.1 2006/11/19 19:02:36 sigurdne Exp $ -->
+
+       <xsl:template name="attributes_form">
+               <xsl:apply-templates select="attributes_values"/>
+       </xsl:template>
+
+       <xsl:template match="attributes_values">
+               <xsl:variable name="lang_attribute_statustext"><xsl:value-of 
select="lang_attribute_statustext"/></xsl:variable>
+                       <tr>
+                               <xsl:attribute name="class">
+                                       <xsl:choose>
+                                               <xsl:when test="@class">
+                                                       <xsl:value-of 
select="@class"/>
+                                               </xsl:when>
+                                               <xsl:when test="position() mod 
2 = 0">
+                                                       
<xsl:text>row_off</xsl:text>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       
<xsl:text>row_on</xsl:text>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:attribute>
+
+                               <td class="{class}" align="left" valign="top">
+                                       <xsl:value-of select="input_text"/>
+                                       <xsl:choose>
+                                               <xsl:when test="helpmsg=1">
+                                                       <xsl:variable 
name="help_url"><xsl:value-of select="//help_url"/>&amp;attrib_id=<xsl:value-of 
select="attrib_id"/></xsl:variable>
+                                                       <xsl:variable 
name="lang_help"><xsl:value-of select="//lang_help"/></xsl:variable>
+                                                       <a href="javascript:var 
w=window.open('{$help_url}','','width=550,height=400,scrollbars')">
+                                                       <xsl:text> 
[</xsl:text><xsl:value-of select="$lang_help"/><xsl:text>]</xsl:text></a>
+                                               </xsl:when>
+                                       </xsl:choose>
+                                       <xsl:choose>
+                                               <xsl:when test="datatype='D'">
+                                                       
<xsl:text>[</xsl:text><xsl:value-of 
select="//lang_dateformat"/><xsl:text>]</xsl:text>                  
+                                               </xsl:when>
+                                       </xsl:choose>
+                                       <xsl:choose>
+                                               <xsl:when test="datatype='pwd'">
+                                                       <br/>
+                                                       <xsl:text>[ </xsl:text>
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="value!=''">
+                                                                       
<xsl:value-of select="//lang_edit"/>
+                                                               </xsl:when>
+                                                               <xsl:otherwise>
+                                                                       
<xsl:value-of select="//lang_add"/>
+                                                               </xsl:otherwise>
+                                                       </xsl:choose>
+                                                       <xsl:text> ]</xsl:text>
+                                               </xsl:when>
+                                       </xsl:choose>
+                               </td>
+                               <td align="left">
+                                       <xsl:choose>
+                                               <xsl:when test="name!=''">
+                                                       <input type="hidden" 
name="values_attribute[{counter}][name]" value="{name}"></input>
+                                                       <input type="hidden" 
name="values_attribute[{counter}][datatype]" value="{datatype}"></input>
+                                                       <input type="hidden" 
name="values_attribute[{counter}][history]" value="{history}"></input>
+                                                       <input type="hidden" 
name="values_attribute[{counter}][attrib_id]" value="{attrib_id}"></input>
+                                                       <input type="hidden" 
name="values_attribute[{counter}][allow_null]" value="{allow_null}"></input>
+                                                       <input type="hidden" 
name="values_attribute[{counter}][input_text]" value="{input_text}"></input>
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="datatype='R'">
+                                                                       
<xsl:call-template name="choice"/>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='CH'">
+                                                                       
<xsl:call-template name="choice"/>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='LB'">
+                                                                       <select 
name="values_attribute[{counter}][value]" class="forms" 
onMouseover="window.status='{statustext}'; return true;" 
onMouseout="window.status='';return true;">
+                                                                               
<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="//lang_none"/></option>
+                                                                               
<xsl:for-each select="choice">  
+                                                                               
        <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+                                                                               
        <xsl:choose>
+                                                                               
                <xsl:when test="checked='checked'">
+                                                                               
                        <option value="{$id}" selected="selected"><xsl:value-of 
disable-output-escaping="yes" select="value"/></option>
+                                                                               
                </xsl:when>
+                                                                               
                <xsl:otherwise>
+                                                                               
                        <option value="{$id}"><xsl:value-of 
disable-output-escaping="yes" select="value"/></option>
+                                                                               
                </xsl:otherwise>
+                                                                               
        </xsl:choose>                           
+                                                                               
</xsl:for-each>
+                                                                       
</select>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='AB'">
+                                                                       
<xsl:variable name="contact_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="5" onMouseout="window.status='';return true;" >
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="disabled!=''">
+                                                                               
                <xsl:attribute name="disabled">
+                                                                               
                        <xsl:text> disabled</xsl:text>
+                                                                               
                </xsl:attribute>
+                                                                               
        </xsl:when>
+                                                                               
</xsl:choose>
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>'; return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                                       <input  
size="30" type="text" name="{$contact_name}" value="{contact_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>
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>'; return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='VENDOR'">
+                                                                       
<xsl:variable name="vendor_name"><xsl:value-of 
select="name"/><xsl:text>_org_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" onMouseout="window.status='';return true;" >
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="disabled!=''">
+                                                                               
                <xsl:attribute name="disabled">
+                                                                               
                        <xsl:text> disabled</xsl:text>
+                                                                               
                </xsl:attribute>
+                                                                               
        </xsl:when>
+                                                                               
</xsl:choose>
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>'; return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                                       <input  
size="30" type="text" name="{$vendor_name}" value="{vendor_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>
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>'; return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </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>
+                                                                       <input 
type="text" name="{name}" value="{value}" onClick="{$lookup_function}" 
readonly="readonly" size="6" onMouseout="window.status='';return true;" >
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="disabled!=''">
+                                                                               
                <xsl:attribute name="disabled">
+                                                                               
                        <xsl:text> disabled</xsl:text>
+                                                                               
                </xsl:attribute>
+                                                                               
        </xsl:when>
+                                                                               
</xsl:choose>
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>'; return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                                       <input  
size="30" type="text" name="{$user_name}" value="{user_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>
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>'; return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='D'">
+                                                                       <input 
type="text" name="values_attribute[{counter}][value]" value="{value}" 
onFocus="{//dateformat_validate}" onKeyUp="{//onKeyUp}" onBlur="{//onBlur}" 
size="12" maxlength="10"  onMouseout="window.status='';return true;" >
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="disabled!=''">
+                                                                               
                <xsl:attribute name="disabled">
+                                                                               
                        <xsl:text> disabled</xsl:text>
+                                                                               
                </xsl:attribute>
+                                                                               
        </xsl:when>
+                                                                               
</xsl:choose>
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>';return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='T'">
+                                                                       
<textarea cols="40" rows="6" name="values_attribute[{counter}][value]" 
wrap="virtual" onMouseout="window.status='';return true;">
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="disabled!=''">
+                                                                               
                <xsl:attribute name="disabled">
+                                                                               
                        <xsl:text> disabled</xsl:text>
+                                                                               
                </xsl:attribute>
+                                                                               
        </xsl:when>
+                                                                               
</xsl:choose>
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>';return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                               
<xsl:value-of select="value"/>          
+                                                                       
</textarea>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='pwd'">
+                                                                       <table>
+                                                                               
<tr>
+                                                                               
        <td>
+                                                                               
                <input type="password" 
name="values_attribute[{counter}][value]"  size="30" 
onMouseout="window.status='';return true;" >
+                                                                               
                        <xsl:choose>
+                                                                               
                                <xsl:when test="disabled!=''">
+                                                                               
                                        <xsl:attribute name="disabled">
+                                                                               
                                                <xsl:text> disabled</xsl:text>
+                                                                               
                                        </xsl:attribute>
+                                                                               
                                </xsl:when>
+                                                                               
                        </xsl:choose>
+                                                                               
                        <xsl:attribute name="onMouseover">
+                                                                               
                                <xsl:text>window.status='</xsl:text>
+                                                                               
                                        <xsl:value-of select="statustext"/>
+                                                                               
                                        <xsl:text> - </xsl:text>
+                                                                               
                                        <xsl:value-of select="datatype_text"/>
+                                                                               
                                <xsl:text>';return true;</xsl:text>
+                                                                               
                        </xsl:attribute>
+                                                                               
                </input>
+                                                                               
        </td>
+                                                                               
</tr>
+                                                                               
<tr>
+                                                                               
        <td>
+                                                                               
                <input type="password" 
name="values_attribute[{counter}][value2]"  size="30" 
onMouseout="window.status='';return true;" >
+                                                                               
                        <xsl:choose>
+                                                                               
                                <xsl:when test="disabled!=''">
+                                                                               
                                        <xsl:attribute name="disabled">
+                                                                               
                                                <xsl:text> disabled</xsl:text>
+                                                                               
                                        </xsl:attribute>
+                                                                               
                                        </xsl:when>
+                                                                               
                        </xsl:choose>
+                                                                               
                        <xsl:attribute name="onMouseover">
+                                                                               
                                <xsl:text>window.status='</xsl:text>
+                                                                               
                                        <xsl:value-of select="statustext"/>
+                                                                               
                                        <xsl:text> - </xsl:text>
+                                                                               
                                        <xsl:value-of select="datatype_text"/>
+                                                                               
                                <xsl:text>';return true;</xsl:text>
+                                                                               
                        </xsl:attribute>
+                                                                               
                </input>
+                                                                               
        </td>
+                                                                               
</tr>
+                                                                       </table>
+                                                               </xsl:when>
+                                                               <xsl:otherwise>
+                                                                       <input 
type="text" name="values_attribute[{counter}][value]" value="{value}" size="30" 
onMouseout="window.status='';return true;" >
+                                                                               
<xsl:choose>
+                                                                               
        <xsl:when test="disabled!=''">
+                                                                               
                <xsl:attribute name="disabled">
+                                                                               
                        <xsl:text> disabled</xsl:text>
+                                                                               
                </xsl:attribute>
+                                                                               
        </xsl:when>
+                                                                               
</xsl:choose>
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
                <xsl:text> - </xsl:text>
+                                                                               
                <xsl:value-of select="datatype_text"/>
+                                                                               
        <xsl:text>';return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </xsl:otherwise>
+                                                       </xsl:choose>
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="history=1">
+                                                                       <input 
type="text" name="values_attribute[{counter}][date]" value="" 
onFocus="{//dateformat_validate}" onKeyUp="{//onKeyUp}" onBlur="{//onBlur}" 
size="12" maxlength="10"  onMouseout="window.status='';return true;" >
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="//lang_history_date_statustext"/>
+                                                                               
        <xsl:text>';return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                                       
+                                                                       
<xsl:variable name="link_history"><xsl:value-of 
select="link_history"/></xsl:variable>
+                                                                       
<xsl:variable name="lang_history_help"><xsl:value-of 
select="//lang_history_help"/></xsl:variable>
+                                                                       
<xsl:variable name="lang_history"><xsl:value-of 
select="//lang_history"/></xsl:variable>
+                                                                       <a 
href="javascript:var 
w=window.open('{$link_history}','','width=550,height=400,scrollbars')"
+                                                                       
onMouseOver="overlib('{$lang_history_help}', CAPTION, '{$lang_history}')"
+                                                                       
onMouseOut="nd()">
+                                                                       
<xsl:value-of select="//lang_history"/></a>                                     
+
+                                                               </xsl:when>
+                                                       </xsl:choose>
+                                               </xsl:when>
+                                       </xsl:choose>
+                               </td>
+                       </tr>
+       </xsl:template>
+
+       <xsl:template name="choice">
+               <xsl:variable name="counter"><xsl:value-of 
select="counter"/></xsl:variable>
+                       <table cellpadding="2" cellspacing="2" width="50%" 
align="left">
+                               <xsl:for-each select="choice" >
+                                       <tr>
+                                               <xsl:attribute name="class">
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="@class">
+                                                                       
<xsl:value-of select="@class"/>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="position() mod 2 = 0">
+                                                                       
<xsl:text>row_off</xsl:text>
+                                                               </xsl:when>
+                                                               <xsl:otherwise>
+                                                                       
<xsl:text>row_on</xsl:text>
+                                                               </xsl:otherwise>
+                                                       </xsl:choose>
+                                               </xsl:attribute>
+                                       <td align="left">
+                                               <xsl:value-of select="value"/>
+                                               <xsl:text> </xsl:text>
+                                       </td>
+                                       <td align="left">
+                                               <xsl:choose>
+                                                       <xsl:when 
test="checked='checked'">
+                                                               <input 
type="{input_type}" name="values_attribute[{$counter}][value][]" value="{id}" 
checked="checked"></input>
+                                                       </xsl:when>
+                                                       <xsl:otherwise>
+                                                               <input 
type="{input_type}" name="values_attribute[{$counter}][value][]" 
value="{id}"></input>
+                                                       </xsl:otherwise>
+                                               </xsl:choose>
+                                       </td>
+                                       </tr>
+                               </xsl:for-each>                         
+                       </table>
+       </xsl:template>

Index: templates/base/attributes_view.xsl
===================================================================
RCS file: templates/base/attributes_view.xsl
diff -N templates/base/attributes_view.xsl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ templates/base/attributes_view.xsl  19 Nov 2006 19:02:36 -0000      1.1
@@ -0,0 +1,179 @@
+<!-- $Id: attributes_view.xsl,v 1.1 2006/11/19 19:02:36 sigurdne Exp $ -->
+
+       <xsl:template name="attributes_view">
+               <xsl:apply-templates select="attributes_values"/>
+       </xsl:template>
+
+       <xsl:template match="attributes_values">
+               <xsl:variable name="lang_attribute_statustext"><xsl:value-of 
select="lang_attribute_statustext"/></xsl:variable>
+                       <tr>
+                               <xsl:attribute name="class">
+                                       <xsl:choose>
+                                               <xsl:when test="@class">
+                                                       <xsl:value-of 
select="@class"/>
+                                               </xsl:when>
+                                               <xsl:when test="position() mod 
2 = 0">
+                                                       
<xsl:text>row_off</xsl:text>
+                                               </xsl:when>
+                                               <xsl:otherwise>
+                                                       
<xsl:text>row_on</xsl:text>
+                                               </xsl:otherwise>
+                                       </xsl:choose>
+                               </xsl:attribute>
+
+                               <td align="left" valign="top">
+                                       <xsl:value-of select="input_text"/>
+                                       <xsl:choose>
+                                               <xsl:when test="datatype='D'">
+                                                       
<xsl:text>[</xsl:text><xsl:value-of 
select="//lang_dateformat"/><xsl:text>]</xsl:text>                  
+                                               </xsl:when>
+                                       </xsl:choose>
+                               </td>
+                               <td align="left">
+                                       <xsl:choose>
+                                               <xsl:when test="name!=''">
+                                                       <input type="hidden" 
name="values_attribute[{counter}][name]" value="{name}"></input>
+                                                       <input type="hidden" 
name="values_attribute[{counter}][datatype]" value="{datatype}"></input>
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="datatype='R'">
+                                                                       
<xsl:call-template name="choice_view"/>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='CH'">
+                                                                       
<xsl:call-template name="choice_view"/>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='LB'">
+                                                                       <select 
disabled="disabled" class="forms" onMouseover="window.status='{statustext}'; 
return true;" onMouseout="window.status='';return true;">
+                                                                               
<option value=""><xsl:value-of select="//lang_none"/></option>
+                                                                               
<xsl:for-each select="choice">  
+                                                                               
        <xsl:variable name="id"><xsl:value-of select="id"/></xsl:variable>
+                                                                               
        <xsl:choose>
+                                                                               
                <xsl:when test="checked='checked'">
+                                                                               
                        <option value="{$id}" selected="selected"><xsl:value-of 
disable-output-escaping="yes" select="value"/></option>
+                                                                               
                </xsl:when>
+                                                                               
                <xsl:otherwise>
+                                                                               
                        <option value="{$id}"><xsl:value-of 
disable-output-escaping="yes" select="value"/></option>
+                                                                               
                </xsl:otherwise>
+                                                                               
        </xsl:choose>                           
+                                                                               
</xsl:for-each>
+                                                                       
</select>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='AB'">
+                                                                       <input 
type="text" value="{value}" readonly="readonly" size="5" 
onMouseout="window.status='';return true;" >
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>'; return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                                       <input  
size="30" type="text" value="{contact_name}"  readonly="readonly"> 
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>'; return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='VENDOR'">
+                                                                       <input 
type="text" value="{value}" readonly="readonly" size="6" 
onMouseout="window.status='';return true;" >
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>'; return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                                       <input  
size="30" type="text" value="{vendor_name}"  readonly="readonly"> 
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>'; return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='D'">
+                                                                       <input 
type="text" name="values_attribute[{counter}][value]" value="{value}" 
readonly="readonly" size="12" maxlength="10"  
onMouseout="window.status='';return true;" >
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>';return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="datatype='T'">
+                                                                       
<textarea cols="40" rows="6" name="values_attribute[{counter}][value]" 
wrap="virtual" readonly="readonly" onMouseout="window.status='';return true;">
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>';return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                               
<xsl:value-of select="value"/>          
+                                                                       
</textarea>
+                                                               </xsl:when>
+                                                               <xsl:otherwise>
+                                                                       <input 
type="text" name="values_attribute[{counter}][value]" value="{value}" 
readonly="readonly" size="30" onMouseout="window.status='';return true;" >
+                                                                               
<xsl:attribute name="onMouseover">
+                                                                               
        <xsl:text>window.status='</xsl:text>
+                                                                               
                <xsl:value-of select="statustext"/>
+                                                                               
        <xsl:text>';return true;</xsl:text>
+                                                                               
</xsl:attribute>
+                                                                       </input>
+                                                               </xsl:otherwise>
+                                                       </xsl:choose>
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="history=1">                                                               
      
+                                                                       
<xsl:variable name="link_history"><xsl:value-of 
select="link_history"/></xsl:variable>
+                                                                       
<xsl:variable name="lang_history_help"><xsl:value-of 
select="//lang_history_help"/></xsl:variable>
+                                                                       
<xsl:variable name="lang_history"><xsl:value-of 
select="//lang_history"/></xsl:variable>
+                                                                       <a 
href="javascript:var 
w=window.open('{$link_history}','','width=550,height=400,scrollbars')"
+                                                                       
onMouseOver="overlib('{$lang_history_help}', CAPTION, '{$lang_history}')"
+                                                                       
onMouseOut="nd()">
+                                                                       
<xsl:value-of select="//lang_history"/></a>                                     
+
+                                                               </xsl:when>
+                                                       </xsl:choose>
+
+                                               </xsl:when>
+                                       </xsl:choose>
+                               </td>
+                       </tr>
+       </xsl:template>
+
+
+       <xsl:template name="choice_view">
+               <xsl:variable name="counter"><xsl:value-of 
select="counter"/></xsl:variable>
+                       <table cellpadding="2" cellspacing="2" width="50%" 
align="left">
+                               <xsl:for-each select="choice" >
+                                       <tr>
+                                               <xsl:attribute name="class">
+                                                       <xsl:choose>
+                                                               <xsl:when 
test="@class">
+                                                                       
<xsl:value-of select="@class"/>
+                                                               </xsl:when>
+                                                               <xsl:when 
test="position() mod 2 = 0">
+                                                                       
<xsl:text>row_off</xsl:text>
+                                                               </xsl:when>
+                                                               <xsl:otherwise>
+                                                                       
<xsl:text>row_on</xsl:text>
+                                                               </xsl:otherwise>
+                                                       </xsl:choose>
+                                               </xsl:attribute>
+                                       <td align="left">
+                                               <xsl:value-of select="value"/>
+                                               <xsl:text> </xsl:text>
+                                       </td>
+                                       <xsl:variable 
name="checked"><xsl:value-of select="checked"/></xsl:variable>
+                                       <td align="left">
+                                               <xsl:choose>
+                                                       <xsl:when 
test="checked='checked'">
+                                                               <input 
type="{input_type}" name="values_attribute[{$counter}][value][]" value="{id}" 
checked="$checked" disabled="disabled"></input>
+                                                       </xsl:when>
+                                                       <xsl:otherwise>
+                                                               <input 
type="{input_type}" name="values_attribute[{$counter}][value][]" value="{id}" 
disabled="disabled"></input>
+                                                       </xsl:otherwise>
+                                               </xsl:choose>
+                                       </td>
+                                       </tr>
+                               </xsl:for-each>                         
+                       </table>
+       </xsl:template>
+
+




reply via email to

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