fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [13763] custom fields


From: Sigurd Nes
Subject: [Fmsystem-commits] [13763] custom fields
Date: Mon, 24 Aug 2015 09:09:04 +0000

Revision: 13763
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=13763
Author:   sigurdne
Date:     2015-08-24 09:09:03 +0000 (Mon, 24 Aug 2015)
Log Message:
-----------
custom fields

Modified Paths:
--------------
    trunk/admin/templates/base/custom.xsl
    trunk/phpgwapi/inc/class.custom_fields.inc.php
    trunk/property/templates/base/admin_entity.xsl

Modified: trunk/admin/templates/base/custom.xsl
===================================================================
--- trunk/admin/templates/base/custom.xsl       2015-08-24 09:08:04 UTC (rev 
13762)
+++ trunk/admin/templates/base/custom.xsl       2015-08-24 09:09:03 UTC (rev 
13763)
@@ -931,7 +931,14 @@
                                <td valign="top" colspan='2'>
                                        <xsl:value-of select="lang_new_value"/>
                                </td>
-                               <td valign="top" colspan='2'>
+                               <td valign="top">
+                                       <input type="text" 
name="values[new_choice_id]" size = '3'>
+                                               <xsl:attribute name="title">
+                                                       <xsl:value-of 
select="php:function('lang', 'new id for multiple choice')"/>
+                                               </xsl:attribute>
+                                       </input>
+                               </td>
+                               <td valign="top">
                                        <input type="text" 
name="values[new_choice]" onMouseout="window.status='';return true;">
                                                <xsl:attribute 
name="onMouseover">
                                                        
<xsl:text>window.status='</xsl:text>

Modified: trunk/phpgwapi/inc/class.custom_fields.inc.php
===================================================================
--- trunk/phpgwapi/inc/class.custom_fields.inc.php      2015-08-24 09:08:04 UTC 
(rev 13762)
+++ trunk/phpgwapi/inc/class.custom_fields.inc.php      2015-08-24 09:09:03 UTC 
(rev 13763)
@@ -404,9 +404,12 @@
                                        {
                                                return $values['id'];
                                        }
+                                       else
+                                       {
+                                               return 0;
+                                       }
                                }
-
-                               return 0;
+                               return $values['id'];
                        }
 
 
@@ -444,9 +447,10 @@
                                {
                                        return $values['id'];
                                }
+                               return 0;
                        }
 
-                       return 0;
+                       return $values['id'];
                }
 
                /**
@@ -924,24 +928,9 @@
                        
                        if(isset($attrib['new_choice']) && 
$attrib['new_choice'] && !$doubled )
                        {
-                               $choice_id = 
$this->_next_id('phpgw_cust_choice' ,array('location_id'=> $location_id, 
'attrib_id'=>$attrib_id));
-                               $choice_sort = $choice_id;
-
-                               $values= array(
-                                       $location_id,
-                                       $attrib_id,
-                                       $choice_id,
-                                       $choice_sort,
-                                       $attrib['new_choice']
-                                       );
-
-                               $values = $this->_db->validate_insert($values);
-
-                               $this->_db->query("INSERT INTO 
phpgw_cust_choice (location_id, attrib_id, id,choice_sort, value) "
-                               . "VALUES ($values)",__LINE__,__FILE__);
+                               $this->add_choice($location_id, $attrib_id, 
$attrib['new_choice'], $attrib['new_choice_id']);
                        }
 
-
                        if ( count($attrib['edit_choice'])  && !$doubled )
                        {
                                foreach ($attrib['edit_choice'] as $choice_id 
=> $value)
@@ -992,7 +981,39 @@
                        return false;
                }
 
+               /**
+                * Insert a new value for a list-attribute
+                * @param integer $location_id
+                * @param integer $attrib_id
+                * @param string $value
+                * @param integer $choice_id
 
+                */
+               public function add_choice($location_id,$attrib_id,$value, 
$choice_id = 0)
+               {
+                       if(!$choice_id)
+                       {
+                               $choice_id = 
$this->_next_id('phpgw_cust_choice' ,array('location_id'=> $location_id, 
'attrib_id'=>$attrib_id));
+                       }
+
+                       $this->_db->query("SELECT count(id) as cnt FROM 
phpgw_cust_choice WHERE location_id = {$location_id} AND attrib_id = 
{$attrib_id}",__LINE__,__FILE__);
+                       $this->_db->next_record();
+                       $choice_sort = (int)$this->_db->f('cnt') +1;
+
+                       $values= array(
+                               $location_id,
+                               $attrib_id,
+                               $choice_id,
+                               $choice_sort,
+                               $value
+                               );
+
+                       $values = $this->_db->validate_insert($values);
+
+                       $this->_db->query("INSERT INTO phpgw_cust_choice 
(location_id, attrib_id, id,choice_sort, value) "
+                       . "VALUES ({$values})",__LINE__,__FILE__);
+               }
+
                /**
                 * Get a list of attributes
                 *

Modified: trunk/property/templates/base/admin_entity.xsl
===================================================================
--- trunk/property/templates/base/admin_entity.xsl      2015-08-24 09:08:04 UTC 
(rev 13762)
+++ trunk/property/templates/base/admin_entity.xsl      2015-08-24 09:09:03 UTC 
(rev 13763)
@@ -2306,7 +2306,14 @@
                                <td valign="top" colspan="2">
                                        <xsl:value-of 
select="php:function('lang', 'new value')"/>
                                </td>
-                               <td valign="top" colspan="2">
+                               <td valign="top">
+                                       <input type="text" 
name="values[new_choice_id]" size = '3'>
+                                               <xsl:attribute name="title">
+                                                       <xsl:value-of 
select="php:function('lang', 'new id for multiple choice')"/>
+                                               </xsl:attribute>
+                                       </input>
+                               </td>
+                               <td valign="top">
                                        <input type="text" 
name="values[new_choice]">
                                                <xsl:attribute name="title">
                                                        <xsl:value-of 
select="php:function('lang', 'new value for multiple choice')"/>




reply via email to

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