[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11023] property: inventory
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11023] property: inventory |
Date: |
Wed, 03 Apr 2013 13:29:54 +0000 |
Revision: 11023
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11023
Author: sigurdne
Date: 2013-04-03 13:29:48 +0000 (Wed, 03 Apr 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/js/yahoo/entity.edit.js
trunk/property/templates/base/entity.xsl
Modified: trunk/property/inc/class.boentity.inc.php
===================================================================
--- trunk/property/inc/class.boentity.inc.php 2013-04-03 07:09:25 UTC (rev
11022)
+++ trunk/property/inc/class.boentity.inc.php 2013-04-03 13:29:48 UTC (rev
11023)
@@ -697,11 +697,18 @@
return $values;
}
- public function save_inventory($values)
+ public function add_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);
+ return $this->so->add_inventory($values);
}
+ public function edit_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->edit_inventory($values);
+ }
+
}
Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php 2013-04-03 07:09:25 UTC (rev
11022)
+++ trunk/property/inc/class.soentity.inc.php 2013-04-03 13:29:48 UTC (rev
11023)
@@ -2379,7 +2379,8 @@
$sql = "SELECT fm_bim_item_inventory.*,
fm_standard_unit.name AS unit FROM fm_bim_item_inventory"
. " {$this->join} fm_standard_unit ON
fm_bim_item_inventory.unit_id = fm_standard_unit.id"
- . " {$filtermethod}";
+ . " {$filtermethod}"
+ . " ORDER BY p_location_id, p_id";
$this->db->query($sql,__LINE__,__FILE__);
$inventory = array();
@@ -2401,38 +2402,14 @@
);
}
-//_debug_array($inventory);
return $inventory;
-/*
- id integer NOT NULL DEFAULT nextval('seq_fm_bim_item_inventory'::regclass),
- location_id integer NOT NULL,
- item_id integer NOT NULL,
- p_location_id integer,
- p_id integer,
- unit_id integer NOT NULL,
- inventory integer NOT NULL,
- write_off integer NOT NULL,
- bookable smallint NOT NULL,
- active_from bigint,
- active_to bigint,
- created_on bigint NOT NULL,
- created_by integer NOT NULL,
- expired_on bigint,
- expired_by bigint,
- remark text,
-
-*/
-
}
- public function save_inventory($values)
+ public function add_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');
+ $p_id =
execMethod('property.solocation.get_item_id',$values['location_code']);
if(!$p_location_id && !$p_id)
{
@@ -2464,4 +2441,61 @@
.
$this->db->validate_insert(array_values($value_set)) . ')',__LINE__,__FILE__);
}
+
+
+ public function edit_inventory($values)
+ {
+ $p_location_id =
$GLOBALS['phpgw']->locations->get_id('property', '.location.' .
count(explode('-', $values['location_code'])));
+
+ $p_id =
execMethod('property.solocation.get_item_id',$values['location_code']);
+
+ $inventory_id = (int)$values['inventory_id'];
+
+ if(!$inventory_id)
+ {
+ throw new Exception('ERROR: Not a valid id');
+ }
+
+ $this->db->transaction_begin();
+
+ $table = 'fm_bim_item_inventory';
+
+ $value_set = array
+ (
+ 'expired_on' => time(),
+ 'expired_by' => $this->account,
+ );
+
+ $value_set =
$this->db->validate_update($value_set);
+ $this->db->query("UPDATE {$table} SET $value_set WHERE
id = {$inventory_id}",__LINE__,__FILE__);
+
+ $sql = "SELECT * FROM fm_bim_item_inventory WHERE id =
{$inventory_id}";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ $inventory = array();
+ $this->db->next_record();
+
+ $value_set = array
+ (
+ 'location_id' =>
$this->db->f('location_id'),
+ 'item_id' =>
$this->db->f('item_id'),
+ 'p_location_id' =>
$this->db->f('p_location_id'),
+ 'p_id' =>
$this->db->f('p_id'),
+ 'unit_id' =>
$this->db->f('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,
+ 'remark' =>
$this->db->db_addslashes($values['remark'])
+ );
+
+ $this->db->query("INSERT INTO {$table} (" .
implode(',',array_keys($value_set)) . ') VALUES ('
+ .
$this->db->validate_insert(array_values($value_set)) . ')',__LINE__,__FILE__);
+
+ return $this->db->transaction_commit();
+ }
+
}
Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php 2013-04-03 07:09:25 UTC (rev
11022)
+++ trunk/property/inc/class.uientity.inc.php 2013-04-03 13:29:48 UTC (rev
11023)
@@ -2159,6 +2159,7 @@
array('key' =>
'remark','label'=>lang('remark'),'sortable'=>false,'resizeable'=>true),
array('key' =>
'location_id','hidden'=>true),
array('key' =>
'id','hidden'=>true),
+ // array('key' =>
'inventory_id','label'=>lang('id'),'sortable'=>false,'resizeable'=>false),
array('key' =>
'inventory_id','hidden'=>true),
)
)
@@ -2931,30 +2932,10 @@
{
$values['location_id'] = $location_id;
$values['item_id'] = $id;
- $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(!$values['unit_id'])
- {
-
$receipt['error'][]=array('msg'=>lang('Please select a unit !'));
- }
+ $values['inventory_id'] = $inventory_id;
if(!isset($receipt['error']))
{
- $this->bo->save_inventory($values);
+ $this->bo->edit_inventory($values);
$receipt['message'][]=array('msg'=>
'Ok');
$values = array();
}
@@ -2984,6 +2965,7 @@
'system_location' => $system_location,
'location_id' => $location_id,
'item_id' => $id,
+ 'inventory_id' => $inventory_id,
'unit_list' =>
array('options' => $unit_list),
'lock_unit' => $lock_unit,
'value_inventory' => $values['inventory']
? $values['inventory'] : $inventory[0]['inventory'],
@@ -3063,7 +3045,7 @@
}
if(!isset($receipt['error']))
{
- $this->bo->save_inventory($values);
+ $this->bo->add_inventory($values);
$receipt['message'][]=array('msg'=>
'Ok');
$values = array();
}
Modified: trunk/property/js/yahoo/entity.edit.js
===================================================================
--- trunk/property/js/yahoo/entity.edit.js 2013-04-03 07:09:25 UTC (rev
11022)
+++ trunk/property/js/yahoo/entity.edit.js 2013-04-03 13:29:48 UTC (rev
11023)
@@ -55,9 +55,9 @@
newTR = document.createElement('tr');
td_sum('Sum');
- td_empty(1);
+ td_empty(3);
td_sum(tmp_sum1);
- td_empty(6);
+ td_empty(5);
myfoot = tableYUI.createTFoot();
myfoot.setAttribute("id","myfoot");
@@ -112,6 +112,7 @@
{
var oArgs = {menuaction:'property.uientity.get_inventory',
location_id:location_id, id: id};
var requestUrl = phpGWLink('index.php', oArgs, true);
+//alert(requestUrl);
execute_async(myDataTable_3, oArgs);
}
Modified: trunk/property/templates/base/entity.xsl
===================================================================
--- trunk/property/templates/base/entity.xsl 2013-04-03 07:09:25 UTC (rev
11022)
+++ trunk/property/templates/base/entity.xsl 2013-04-03 13:29:48 UTC (rev
11023)
@@ -19,6 +19,16 @@
<!-- edit inventory -->
<xsl:template xmlns:php="http://php.net/xsl" match="edit_inventory">
+ <script type="text/javascript">
+ function edit_inventory()
+ {
+ var location_id = '<xsl:value-of
select="location_id"/>';
+ var item_id = '<xsl:value-of
select="item_id"/>';
+ document.form.submit();
+ // parent.refresh_inventory(location_id, item_id);
+ parent.TINY.box.hide();
+ }
+ </script>
<div align = 'left'>
@@ -56,6 +66,7 @@
<xsl:value-of select="item_id"/>
<input type="hidden"
name="location_id" value="{location_id}"/>
<input type="hidden" name="id"
value="{item_id}"/>
+ <input type="hidden"
name="inventory_id" value="{inventory_id}"/>
</td>
</tr>
@@ -103,18 +114,6 @@
<tr>
<td>
- <label ><xsl:value-of
select="php:function('lang', 'write off')" /></label>
- </td>
- <td>
- <input type="text"
name="values[write_off]" value="{value_write_off}" size="12">
- <xsl:attribute
name="title">
- <xsl:value-of
select="lang_write_off_statustext"/>
- </xsl:attribute>
- </input>
- </td>
- </tr>
- <tr>
- <td>
<label><xsl:value-of
select="php:function('lang', 'bookable')" /></label>
</td>
<td>
@@ -180,7 +179,8 @@
<xsl:variable name="lang_save">
<xsl:value-of
select="php:function('lang', 'save')"/>
</xsl:variable>
- <input type="submit"
name="values[save]" value="{$lang_save}">
+ <input type="hidden"
name="values[save]" value="1"/>
+ <input type="button" name="send"
value="{$lang_save}" onClick="edit_inventory();">
<xsl:attribute name="title">
<xsl:value-of
select="php:function('lang', 'save values and exit')"/>
</xsl:attribute>
@@ -272,7 +272,7 @@
</input>
</td>
</tr>
-
+<!--
<tr>
<td>
<label ><xsl:value-of
select="php:function('lang', 'write off')" /></label>
@@ -285,6 +285,7 @@
</input>
</td>
</tr>
+-->
<tr>
<td>
<label><xsl:value-of
select="php:function('lang', 'bookable')" /></label>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11023] property: inventory,
Sigurd Nes <=