fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11000] property: inventory


From: Sigurd Nes
Subject: [Fmsystem-commits] [11000] property: inventory
Date: Mon, 18 Mar 2013 14:35:56 +0000

Revision: 11000
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11000
Author:   sigurdne
Date:     2013-03-18 14:35:55 +0000 (Mon, 18 Mar 2013)
Log Message:
-----------
property: inventory

Modified Paths:
--------------
    trunk/property/inc/class.boentity.inc.php
    trunk/property/inc/class.soentity.inc.php
    trunk/property/inc/class.uientity.inc.php
    trunk/property/templates/base/entity.xsl

Modified: trunk/property/inc/class.boentity.inc.php
===================================================================
--- trunk/property/inc/class.boentity.inc.php   2013-03-18 12:41:17 UTC (rev 
10999)
+++ trunk/property/inc/class.boentity.inc.php   2013-03-18 14:35:55 UTC (rev 
11000)
@@ -686,4 +686,11 @@
                        return $this->so->get_inventory( array('id' => $id, 
'location_id' => $location_id) );
                }
 
+               public function save_inventory($values)
+               {
+                       $values['active_from']  = 
$this->bocommon->date_to_timestamp($values['active_from']);
+                       $values['active_to']    = 
$this->bocommon->date_to_timestamp($values['active_to']);
+                       return $this->so->save_inventory($values);
+               }
+
        }

Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php   2013-03-18 12:41:17 UTC (rev 
10999)
+++ trunk/property/inc/class.soentity.inc.php   2013-03-18 14:35:55 UTC (rev 
11000)
@@ -2410,8 +2410,55 @@
 
 */
 
+               }
 
+               public function save_inventory($values)
+               {
+                       $p_location_id = 
$GLOBALS['phpgw']->locations->get_id('property', '.location.' . 
count(explode('-', $values['location_code'])));
+                       
+                       $sql = "SELECT id FROM fm_locations WHERE location_code 
= '{$values['location_code']}'";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $p_id   = $this->db->f('id');
+                       
+                       if(!$p_location_id && !$p_id)
+                       {
+                               throw new Exception('ERROR: Not a valid 
location');                     
+                       }
+                       
+                       $table = 'fm_bim_item_inventory';
 
+                       $value_set = array
+                       (
+                               'location_id'           => 
$values['location_id'],
+                               'item_id'                       => 
$values['item_id'],
+                               'p_location_id'         => $p_location_id,
+                               'p_id'                          => $p_id,
+                               'unit_id'                       => 
$values['unit_id'],
+                               'inventory'                     => 
(int)$values['inventory'],
+                               'write_off'                     => 
(int)$values['write_off'],
+                               'bookable'                      => 
(int)$values['bookable'],
+                               'active_from'           => 
$values['active_from'],
+                               'active_to'                     => 
$values['active_to'],
+                               'created_on'            => time(),
+                               'created_by'            => $this->account,
+       //                      'expired_on'            => ,
+       //                      'expired_by'            => ,
+                               'remark'                        => 
$this->db->db_addslashes($values['remark'])
+                       );
 
+
+_debug_array($p_location_id);
+_debug_array($p_id);
+_debug_array($values);
+
+
+die();
+
+                               $this->db->query("INSERT INTO {$table} (" . 
implode(',',array_keys($value_set)) . ') VALUES ('
+                                . 
$this->db->validate_insert(array_values($value_set)) . ')',__LINE__,__FILE__);
+
+
                }
+
        }

Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php   2013-03-18 12:41:17 UTC (rev 
10999)
+++ trunk/property/inc/class.uientity.inc.php   2013-03-18 14:35:55 UTC (rev 
11000)
@@ -2874,12 +2874,68 @@
                        }
 
                        $values         = phpgw::get_var('values');
+                       
+
+                       if (isset($values['save']) && $values['save'])
+                       {
+                               $insert_record          = 
$GLOBALS['phpgw']->session->appsession('insert_record','property');
+
+                               if(is_array($insert_record_entity))
+                               {
+                                       for 
($j=0;$j<count($insert_record_entity);$j++)
+                                       {
+                                               
$insert_record['extra'][$insert_record_entity[$j]]      = 
$insert_record_entity[$j];
+                                       }
+                               }
+
+                               $values = 
$this->bocommon->collect_locationdata($values,$insert_record);
+
+                               if(!$values['location'])
+                               {
+                                       
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
+                               }
+
+                               if(isset($values_attribute) && 
is_array($values_attribute))
+                               {
+                                       foreach ($values_attribute as 
$attribute )
+                                       {
+                                               if($attribute['nullable'] != 1 
&& (!$attribute['value'] && !$values['extra'][$attribute['name']]))
+                                               {
+                                                       
$receipt['error'][]=array('msg'=>lang('Please enter value for attribute %1', 
$attribute['input_text']));
+                                               }
+
+                                               if(isset($attribute['value']) 
&& $attribute['value'] && $attribute['datatype'] == 'I' && ! 
ctype_digit($attribute['value']))
+                                               {
+                                                       
$receipt['error'][]=array('msg'=>lang('Please enter integer for attribute %1', 
$attribute['input_text']));                                              
+                                               }
+                                       }
+                               }
+
+                               if(!isset($receipt['error']))
+                               {
+                                       $receipt = 
$this->bo->save_inventory($values);
+                               }
+                       }
+
+
                        $unit_id        = $values['unit_id'];
                        
                        $unit_list = execMethod('property.bogeneric.get_list', 
array('type' => 'unit',  'selected' => $unit_id));
+
+                       $location_data = 
execMethod('property.bolocation.initiate_ui_location', array
+                       (
+                               'values'                => 
$values['location_data'],
+                               'type_id'               => 5,
+                               'no_link'               => false,
+                               'lookup_type'   => 'form',
+                               'tenant'                => false,
+                               'lookup_entity' => $lookup_entity,
+                               'entity_data'   => 
isset($values['p'])?$values['p']:''
+                       ));
                        
                        $data = array
                        (
+                               'location_data'         => $location_data,
                                'system_location'       => $system_location,
                                'location_id'           => $location_id,
                                'item_id'                       => $item_id,

Modified: trunk/property/templates/base/entity.xsl
===================================================================
--- trunk/property/templates/base/entity.xsl    2013-03-18 12:41:17 UTC (rev 
10999)
+++ trunk/property/templates/base/entity.xsl    2013-03-18 14:35:55 UTC (rev 
11000)
@@ -43,20 +43,10 @@
                                                <input type="hidden" 
name="item_id" value="{item_id}"/>
                                        </td>
                                </tr>
+
+                               <xsl:call-template name="location_form"/>
                                <tr>
                                        <td>
-                                               <label ><xsl:value-of 
select="php:function('lang', 'where')" /></label>
-                                       </td>
-                                       <td>
-                                               <input type="text" 
name="values[where]" value="{value_where}" size="12">
-                                                       <xsl:attribute 
name="title">
-                                                               <xsl:value-of 
select="lang_where_statustext"/>
-                                                       </xsl:attribute>
-                                               </input>
-                                       </td>
-                                       </tr>
-                               <tr>
-                                       <td>
                                                <label 
for="unit_id"><xsl:value-of select="php:function('lang', 'unit')" /></label>
                                        </td>
                                        <td>




reply via email to

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