fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10159] admin-functionality for bim type requirements


From: Erik Holm-Larsen
Subject: [Fmsystem-commits] [10159] admin-functionality for bim type requirements
Date: Tue, 09 Oct 2012 06:04:51 +0000

Revision: 10159
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10159
Author:   erikhl
Date:     2012-10-09 06:04:50 +0000 (Tue, 09 Oct 2012)
Log Message:
-----------
admin-functionality for bim type requirements

Modified Paths:
--------------
    trunk/logistic/inc/class.sobim_type_requirement.inc.php
    trunk/logistic/inc/class.soproject.inc.php
    trunk/logistic/inc/class.uibim_type_requirement.inc.php
    trunk/logistic/inc/model/class.bim_item_type_requirement.inc.php
    trunk/logistic/js/logistic/bim_type_requirement.js
    trunk/logistic/setup/phpgw_no.lang
    trunk/logistic/templates/base/bim_type_requirement_item.xsl

Modified: trunk/logistic/inc/class.sobim_type_requirement.inc.php
===================================================================
--- trunk/logistic/inc/class.sobim_type_requirement.inc.php     2012-10-09 
06:03:50 UTC (rev 10158)
+++ trunk/logistic/inc/class.sobim_type_requirement.inc.php     2012-10-09 
06:04:50 UTC (rev 10159)
@@ -156,7 +156,25 @@
 
                protected function update($object)
                {
+                       $id = intval($object->get_id());
 
+                       $values = array(
+                               'entity_id = ' . 
$this->marshal($object->get_entity_id(), 'int'),
+                               'category_id = ' . 
$this->marshal($object->get_category_id(), 'int'),
+                               'cust_attribute_id = ' . 
$this->marshal($object->get_cust_attribute_id(), 'string'),
+                               'project_type_id = ' . 
$this->marshal($object->get_project_type_id(), 'int')
+                       );
+
+                       $result = $this->db->query('UPDATE 
lg_bim_item_type_requirement SET ' . join(',', $values) . " WHERE id=$id", 
__LINE__,__FILE__);
+
+                       if( $result )
+                       {
+                               return $id;
+                       }
+                       else
+                       {
+                               return 0;
+                       }
                }
 
                public static function get_instance()

Modified: trunk/logistic/inc/class.soproject.inc.php
===================================================================
--- trunk/logistic/inc/class.soproject.inc.php  2012-10-09 06:03:50 UTC (rev 
10158)
+++ trunk/logistic/inc/class.soproject.inc.php  2012-10-09 06:04:50 UTC (rev 
10159)
@@ -233,7 +233,7 @@
                }
 
 
-               private function get_project_type_label($id)
+               public function get_project_type_label($id)
                {
                        $sql = "SELECT name FROM lg_project_type where id=$id";
                        $this->db3->query($sql, __LINE__, __FILE__);
@@ -244,23 +244,44 @@
                        }
                }
 
-               public function get_project_types()
+               public function get_project_types($selected_id = null)
                {
                        $project_type_array = array();
-                       $project_type_array[] = array(
-                               'id' => '',
-                               'name' => lang('all_types'),
-                               'selected' => 1
-                       );
+                       if(!$selected_id)
+                       {
+                               $project_type_array[] = array(
+                                       'id' => '',
+                                       'name' => lang('all_types'),
+                                       'selected' => 1
+                               );
+                       }
+                       else
+                       {
+                               $project_type_array[] = array(
+                                       'id' => '',
+                                       'name' => lang('all_types')
+                               );
+                       }
                        $sql = "SELECT * FROM lg_project_type";
                        $this->db->query($sql, __LINE__, __FILE__);
 
                        while ($this->db->next_record())
                        {
+                               if(!$selected_id == null && $this->db->f('id') 
== $selected_id)
+                               {
                                $project_type_array[] = array(
                                                'id' => $this->db->f('id'),
+                                               'name' => 
$this->unmarshal($this->db->f('name'), 'string'),
+                                               'selected' => 1
+                                               );
+                               }
+                               else
+                               {
+                                       $project_type_array[] = array(
+                                               'id' => $this->db->f('id'),
                                                'name' => 
$this->unmarshal($this->db->f('name'), 'string')
                                                );
+                               }
                        }
                        return $project_type_array;
                }

Modified: trunk/logistic/inc/class.uibim_type_requirement.inc.php
===================================================================
--- trunk/logistic/inc/class.uibim_type_requirement.inc.php     2012-10-09 
06:03:50 UTC (rev 10158)
+++ trunk/logistic/inc/class.uibim_type_requirement.inc.php     2012-10-09 
06:04:50 UTC (rev 10159)
@@ -191,20 +191,25 @@
                                        'source' => 
self::link(array('menuaction' => 'logistic.uibim_type_requirement.index', 
'phpgw_return_as' => 'json')),
                                        'field' => array(
                                                array(
-                                                       'key' => 'entiry_id',
+                                                       'key' => 'id',
+                                                       'label' => lang('ID'),
+                                                       'sortable' => true,
+                                                       'formatter' => 
'YAHOO.portico.formatLink'
+                                               ),
+                                               array(
+                                                       'key' => 'entity_label',
                                                        'label' => 
lang('Entity'),
                                                        'sortable' => true
                                                ),
                                                array(
-                                                       'key' => 'category_id',
+                                                       'key' => 
'category_label',
                                                        'label' => 
lang('Category'),
                                                        'sortable' => true
                                                ),
                                                array(
-                                                       'key' => 'id',
-                                                       'label' => lang('ID'),
-                                                       'sortable' => true,
-                                                       'formatter' => 
'YAHOO.portico.formatLink'
+                                                       'key' => 
'project_type_label',
+                                                       'label' => 
lang('Project_type'),
+                                                       'sortable' => true
                                                ),
                                                array(
                                                        'key' => 'link',
@@ -224,6 +229,8 @@
 
                public function edit()
                {
+                       $entity_so      = 
CreateObject('property.soadmin_entity');
+                       $custom = createObject('phpgwapi.custom_fields');
                        $req_type_id = phpgw::get_var('id');
                        if($req_type_id && is_numeric($req_type_id))
                        {
@@ -254,14 +261,46 @@
                                $entity_list = 
execMethod('property.soadmin_entity.read', array('allrows' => true));
 
                                array_unshift($entity_list,array 
('id'=>'','name'=> lang('select value')));
-                               $project_type_array = 
$this->so_project->get_project_types();
+                               if($req_type->get_entity_id())
+                               {
+                                       foreach ($entity_list as &$e)
+                                       {
+                                               if($e['id'] == 
$req_type->get_entity_id())
+                                               {
+                                                       $e['selected'] = 1;
+                                               }
+                                       }
+                                       $category_list = 
$entity_so->read_category(array('allrows'=>true,'entity_id'=>$req_type->get_entity_id()));
+                                       foreach ($category_list as &$c)
+                                       {
+                                               if($c['id'] == 
$req_type->get_category_id())
+                                               {
+                                                       $c['selected'] = 1;
+                                               }
+                                       }
 
+                                       $attributes = 
$custom->find('property',".entity.{$req_type->get_entity_id()}.{$req_type->get_category_id()}",
 0, '','','',true, true);
+                                       $selected_attributes = explode(',', 
$req_type->get_cust_attribute_id());
+                                       foreach ($attributes as &$a)
+                                       {
+                                               if(in_array($a['id'], 
$selected_attributes))
+                                               {
+                                                       $a['checked'] = 
'checked';
+                                               }
+                                       }
+                               }
+                               $project_type_array = 
$this->so_project->get_project_types($req_type->get_project_type_id());
+
                                $data = array
                                                (
+                                               'value_id' => !empty($req_type) 
? $req_type->get_id() : 0,
                                                'img_go_home' => 
'rental/templates/base/images/32x32/actions/go-home.png',
                                                'entities' => $entity_list,
+                                               'categories' => $category_list,
+                                               'attributes' => $attributes,
                                                'project_types' => 
$project_type_array,
-                                               'editable' => true
+                                               'editable' => true,
+                                               'req_type' => $req_type
                                        );
 
                                $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('logistic') . '::' . lang('Project type');
@@ -299,21 +338,43 @@
                        $entity_so      = 
CreateObject('property.soadmin_entity');
                        $custom = createObject('phpgwapi.custom_fields');
                        $req_type_id = phpgw::get_var('id');
+                       if(isset($_POST['edit']))
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'logistic.uibim_type_requirement.edit', 'id' => 
$req_type_id));
+                       }
+
                        if($req_type_id && is_numeric($req_type_id))
                        {
                                $req_type = $this->so->get_single($req_type_id);
                                $entity = 
$entity_so->read_single($req_type->get_entity_id());
                                $category = 
$entity_so->read_single_category($req_type->get_entity_id(),$req_type->get_category_id());
+                               $all_attributes = 
$custom->find('property',".entity.{$req_type->get_entity_id()}.{$req_type->get_category_id()}",
 0, '','','',true, true);
+                               $attributes = array();
+                               $selected_attributes = explode(',', 
$req_type->get_cust_attribute_id());
+                               foreach ($all_attributes as $attr)
+                               {
+                                       if(in_array($attr['id'], 
$selected_attributes))
+                                       {
+                                               $attributes[] = $attr;
+                                       }
+                               }
 
-                               $project_type_array = 
$this->so_project->get_project_types();
+                               $objects = $this->so_project->get(null, null, 
null, null, null, 'project_type', array('id' => 
$req_type->get_project_type_id()));
+                               if (count($objects) > 0)
+                               {
+                                       $keys = array_keys($objects);
+                                       $project_type = $objects[$keys[0]];
+                               }
 
                                $data = array
                                                (
+                                               'value_id' => !empty($req_type) 
? $req_type->get_id() : 0,
                                                'img_go_home' => 
'rental/templates/base/images/32x32/actions/go-home.png',
                                                'req_type' => $req_type,
                                                'entity' => $entity,
                                                'category' => $category,
-                                               'attributes' => $attributes
+                                               'attributes' => $attributes,
+                                               'project_type' => $project_type
                                        );
 
                                $GLOBALS['phpgw_info']['flags']['app_header'] = 
lang('logistic') . '::' . lang('Project type');

Modified: trunk/logistic/inc/model/class.bim_item_type_requirement.inc.php
===================================================================
--- trunk/logistic/inc/model/class.bim_item_type_requirement.inc.php    
2012-10-09 06:03:50 UTC (rev 10158)
+++ trunk/logistic/inc/model/class.bim_item_type_requirement.inc.php    
2012-10-09 06:04:50 UTC (rev 10159)
@@ -116,12 +116,23 @@
 
                public function serialize()
                {
+                       $entity_so      = 
CreateObject('property.soadmin_entity');
+                       $project_so = CreateObject('logistic.soproject');
+                       $entity = 
$entity_so->read_single($this->get_entity_id());
+                       $category = 
$entity_so->read_single_category($this->get_entity_id(),$this->get_category_id());
+                       $entity_label = $entity['name'];
+                       $category_label = $category['name'];
+                       $project_type_label  = 
$project_so->get_project_type_label($this->get_project_type_id());
+
                        return array(
                                'id' => $this->get_id(),
                                'entity_id' => $this->get_entity_id(),
+                               'entity_label' => $entity_label,
                                'category_id' => $this->get_category_id(),
+                               'category_label' => $category_label,
                                'atributes' => $this->get_cust_attribute_id(),
-                               'project_type_id' => 
$this->get_project_type_id()
+                               'project_type_id' => 
$this->get_project_type_id(),
+                               'project_type_label' => $project_type_label
                        );
                }
        }
\ No newline at end of file

Modified: trunk/logistic/js/logistic/bim_type_requirement.js
===================================================================
--- trunk/logistic/js/logistic/bim_type_requirement.js  2012-10-09 06:03:50 UTC 
(rev 10158)
+++ trunk/logistic/js/logistic/bim_type_requirement.js  2012-10-09 06:04:50 UTC 
(rev 10159)
@@ -1,6 +1,6 @@
 $(document).ready(function(){
 
-        $("#location_id").change(function () {
+        $("#entity_id").change(function () {
                 var oArgs = 
{menuaction:'logistic.uibim_type_requirement.get_bim_level1', entity_id: 
$(this).val()};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
 
@@ -21,19 +21,19 @@
                                                htmlString  += "<option 
value='" + data[i].id + "'" + selected + ">" + data[i].name + "</option>";
                                });
 
-                                       $("#categories").html( htmlString );
+                                       $("#category_id").html( htmlString );
                                }
                                else
                                {
                                        htmlString  += "";
-                                       $("#categories").html( htmlString );
+                                       $("#category_id").html( htmlString );
                                }
                        }
                });
         });
 
-        $("#categories").change(function () {
-                var oArgs = 
{menuaction:'logistic.uibim_type_requirement.get_bim_level2', entity_id: 
$("#location_id").val(), cat_id: $(this).val()};
+        $("#category_id").change(function () {
+                var oArgs = 
{menuaction:'logistic.uibim_type_requirement.get_bim_level2', entity_id: 
$("#entity_id").val(), cat_id: $(this).val()};
                 var requestUrl = phpGWLink('index.php', oArgs, true);
 
                 var htmlString = "";

Modified: trunk/logistic/setup/phpgw_no.lang
===================================================================
--- trunk/logistic/setup/phpgw_no.lang  2012-10-09 06:03:50 UTC (rev 10158)
+++ trunk/logistic/setup/phpgw_no.lang  2012-10-09 06:04:50 UTC (rev 10159)
@@ -16,6 +16,7 @@
 t_view_requirements    logistic        no      Vis registrerte behov på denne 
aktiviteten
 t_new_booking  logistic        no      Registrer ny booking på denne 
aktiviteten
 t_view_bookings        logistic        no      Vis registrerte bookinger på 
denne aktiviteten
+t_new_type_requirement logistic        no      Nytt type-krav
 Project_type   logistic        no      Prosjekttype
 settings       logistic        no      innstillinger
 Project types  logistic        no      Prosjekttyper
@@ -31,5 +32,23 @@
 Project type name updated              logistic        no      
Prosjekttypenavn oppdatert
 Add activity   logistic        no      Legg til aktivitet
 Add sub activity       logistic        no      Legg til subaktivitet
+Entity logistic        no      Entitet
+Category       logistic        no      Kategori
+Attributes     logistic        no      Attributter
+Chosen attributes      logistic        no      Valgte attributter
+Administrate requirements      logistic        no      Administrer type-krav
+bim_type_requirement   logistic        no      Type-krav
+Varchar        logistic        no      Text
+Contact        logistic        no      Kontakt
+Entity types   logistic        no      Entitetstyper
+select value   logistic        no      Velg
+Listbox        logistic        no      Nedtrekksliste
+Custom listboks        logistic        no      Egendefinert nedtrekksliste
+Memo   logistic        no      Tekstfelt
+Integer        logistic        no      Tall
+Muliple radio  logistic        no      Flervalgs radioknapp
+Muliple checkbox       logistic        no      Flervalgs avkrysningsboks
+event  logistic        no      Hendelse
+Link   logistic        no      Lenke
 Add requirement to activity    logistic        no      Legg krav til 
aktiviteten
 Add requirement        logistic        no      Legg til krav
\ No newline at end of file

Modified: trunk/logistic/templates/base/bim_type_requirement_item.xsl
===================================================================
--- trunk/logistic/templates/base/bim_type_requirement_item.xsl 2012-10-09 
06:03:50 UTC (rev 10158)
+++ trunk/logistic/templates/base/bim_type_requirement_item.xsl 2012-10-09 
06:04:50 UTC (rev 10159)
@@ -4,7 +4,7 @@
 <div class="yui-navset yui-navset-top">
        <div class="identifier-header">
                <h1><img src="{img_go_home}" />
-                               <xsl:value-of select="php:function('lang', 
'Project')" />
+                               <xsl:value-of select="php:function('lang', 
'Administrate requirements')" />
                </h1>
        </div>
        <div class="yui-content">
@@ -14,62 +14,104 @@
                                </input>
                                <dl class="proplist-col">
                                        <dt>
-                                               <label for="name"><xsl:value-of 
select="php:function('lang','Project title')" /></label>
+                                               <label><xsl:value-of 
select="php:function('lang', 'Project_type')" /></label>
                                        </dt>
-                                       <dt>
-                                               <label>Prosjekttype</label>
-                                       </dt>
                                        <dd>
                                                <xsl:choose>
                                                        <xsl:when 
test="editable">
                                                                <select 
name="project_type_id" id="project_type_id">
                                                                        
<xsl:for-each select="project_types">
                                                                                
<option value="{id}">
+                                                                               
        <xsl:if test="selected">
+                                                                               
                <xsl:attribute name="selected" value="selected" />
+                                                                               
        </xsl:if>
                                                                                
        <xsl:value-of select="name"/>
                                                                                
</option>
                                                                        
</xsl:for-each>
                                                                </select>
                                                        </xsl:when>
                                                        <xsl:otherwise>
-                                                               <xsl:value-of 
select="req_type/project_type_id" />
+                                                               <xsl:value-of 
select="project_type/name" />
                                                        </xsl:otherwise>
                                                </xsl:choose>
                                        </dd>
                                        <xsl:choose>
                                                <xsl:when test="editable">
                                                        <dt>
-                                                               
<label>BIM</label>
+                                                               
<label><xsl:value-of select="php:function('lang', 'Entity')" /></label>
                                                        </dt>
                                                        <dd>
-                                                               <select 
name="location_id" id="location_id">
+                                                               <select 
name="entity_id" id="entity_id">
                                                                        
<xsl:for-each select="entities">
                                                                                
<option value="{id}">
+                                                                               
        <xsl:if test="selected">
+                                                                               
                <xsl:attribute name="selected" value="selected" />
+                                                                               
        </xsl:if>
                                                                                
        <xsl:value-of select="name"/>
                                                                                
</option>
                                                                        
</xsl:for-each>
                                                                </select>
                                                        </dd>
                                                        <dt>
-                                                               
<label>BIM2</label>
+                                                               
<label><xsl:value-of select="php:function('lang', 'Category')" /></label>
                                                        </dt>
                                                        <dd>
-                                                               <select 
name="categories" id="categories">
+                                                               <select 
name="category_id" id="category_id">
+                                                                       <xsl:if 
test="req_type/category_id">
+                                                                               
<xsl:for-each select="categories">
+                                                                               
        <option value="{id}">
+                                                                               
                <xsl:if test="selected">
+                                                                               
                        <xsl:attribute name="selected" value="selected" />
+                                                                               
                </xsl:if>
+                                                                               
                <xsl:value-of select="name"/>
+                                                                               
        </option>
+                                                                               
</xsl:for-each>
+                                                                       
</xsl:if>
                                                                </select>
                                                        </dd>
                                                        <dt>
-                                                               
<label>BIM3</label>
+                                                               
<label><xsl:value-of select="php:function('lang', 'Attributes')" /></label>
                                                        </dt>
                                                        <dd>
                                                                <div 
id="attributes">
+                                                                       <xsl:if 
test="attributes != null">
+                                                                               
<xsl:if test="req_type/cust_attribute_id">
+                                                                               
        <xsl:for-each select="attributes">
+                                                                               
                <xsl:choose>
+                                                                               
                        <xsl:when test="checked">
+                                                                               
                                <input type='checkbox' name='attributes[]' 
id='attributes[]' value='{id}' checked='checked'/><xsl:value-of 
select="input_text" /> <xsl:value-of select="trans_datatype" /><br/>
+                                                                               
                        </xsl:when>
+                                                                               
                        <xsl:otherwise>
+                                                                               
                                <input type='checkbox' name='attributes[]' 
id='attributes[]' value='{id}'/><xsl:value-of select="input_text" /> 
<xsl:value-of select="trans_datatype" /><br/>
+                                                                               
                        </xsl:otherwise>
+                                                                               
                </xsl:choose>
+                                                                               
        </xsl:for-each>
+                                                                               
</xsl:if>
+                                                                       
</xsl:if>
                                                                </div>
                                                        </dd>
                                                </xsl:when>
                                                <xsl:otherwise>
-                                                       <xsl:value-of 
select="entity/name" />
-                                                       <xsl:value-of 
select="category/name" />
-                                                       <xsl:for-each 
select="attributes">
-                                                               <xsl:value-of 
select="name" /><br/>
-                                                       </xsl:for-each>
+                                                       <dt>
+                                                               
<label><xsl:value-of select="php:function('lang', 'Entity')" /></label>
+                                                       </dt>
+                                                       <dd>
+                                                               <xsl:value-of 
select="entity/name" />
+                                                       </dd>
+                                                       <dt>
+                                                               
<label><xsl:value-of select="php:function('lang', 'Category')" /></label>
+                                                       </dt>
+                                                       <dd>
+                                                               <xsl:value-of 
select="category/name" />
+                                                       </dd>
+                                                       <dt>
+                                                               
<label><xsl:value-of select="php:function('lang', 'Chosen attributes')" 
/></label>
+                                                       </dt>
+                                                       <dd>
+                                                               <xsl:for-each 
select="attributes">
+                                                                       
<xsl:value-of select="input_text" /> (<xsl:value-of select="trans_datatype" 
/>)<br/>
+                                                               </xsl:for-each>
+                                                       </dd>
                                                </xsl:otherwise>
                                        </xsl:choose>
                                </dl>




reply via email to

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