[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11021] property: inventory
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11021] property: inventory |
Date: |
Tue, 02 Apr 2013 14:09:48 +0000 |
Revision: 11021
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11021
Author: sigurdne
Date: 2013-04-02 14:09:47 +0000 (Tue, 02 Apr 2013)
Log Message:
-----------
property: inventory
Modified Paths:
--------------
trunk/property/inc/class.boentity.inc.php
trunk/property/inc/class.interlink.inc.php
trunk/property/inc/class.soentity.inc.php
trunk/property/inc/class.solocation.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-04-02 10:32:06 UTC (rev
11020)
+++ trunk/property/inc/class.boentity.inc.php 2013-04-02 14:09:47 UTC (rev
11021)
@@ -680,9 +680,9 @@
return $this->so->read_entity_to_link($data);
}
- public function get_inventory($location_id, $id = 0)
+ public function get_inventory($location_id, $id, $inventory_id
= 0)
{
- $values = $this->so->get_inventory( array('id' => $id,
'location_id' => $location_id) );
+ $values = $this->so->get_inventory( array('id' => $id,
'location_id' => $location_id, 'inventory_id' => $inventory_id) );
$interlink = CreateObject('property.interlink');
Modified: trunk/property/inc/class.interlink.inc.php
===================================================================
--- trunk/property/inc/class.interlink.inc.php 2013-04-02 10:32:06 UTC (rev
11020)
+++ trunk/property/inc/class.interlink.inc.php 2013-04-02 14:09:47 UTC (rev
11021)
@@ -204,10 +204,7 @@
$name = 'N∕A';
if( preg_match('/.location./i',
$system_location['location']) )
{
- $sql = "SELECT location_code FROM fm_locations
WHERE id = '{$id}'";
- $this->_db->query($sql,__LINE__,__FILE__);
- $this->_db->next_record();
- $id = $this->_db->f('location_code');
+ $id =
execMethod('property.solocation.get_location_code',$id);
$name = $id;
}
else if( preg_match('/.entity./i',
$system_location['location']) )
Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php 2013-04-02 10:32:06 UTC (rev
11020)
+++ trunk/property/inc/class.soentity.inc.php 2013-04-02 14:09:47 UTC (rev
11021)
@@ -2359,18 +2359,28 @@
public function get_inventory($data = array())
{
-
$location_id = isset($data['location_id']) &&
$data['location_id'] ? (int)$data['location_id'] : 0;
$id = (int)$data['id'];
+ $inventory_id = isset($data['inventory_id']) &&
$data['inventory_id'] ? (int)$data['inventory_id'] : 0;
if(!$location_id || ! $id)
{
return array();
}
+
+ if($inventory_id)
+ {
+ $filtermethod = "WHERE fm_bim_item_inventory.id
= {$inventory_id}";
+ }
+ else
+ {
+ $filtermethod = "WHERE location_id =
{$location_id} AND fm_bim_item_inventory.item_id = {$id} AND expired_on IS
NULL";
+ }
$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"
- . " WHERE location_id = {$location_id} AND
fm_bim_item_inventory.item_id = {$id} AND expired_on IS NULL";
+ . " {$filtermethod}";
+
$this->db->query($sql,__LINE__,__FILE__);
$inventory = array();
while ($this->db->next_record())
Modified: trunk/property/inc/class.solocation.inc.php
===================================================================
--- trunk/property/inc/class.solocation.inc.php 2013-04-02 10:32:06 UTC (rev
11020)
+++ trunk/property/inc/class.solocation.inc.php 2013-04-02 14:09:47 UTC (rev
11021)
@@ -1820,6 +1820,15 @@
return $this->db->f('id');
}
+
+ public function get_location_code($id)
+ {
+ $sql = "SELECT location_code FROM fm_locations WHERE id
= '{$id}'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ return $this->db->f('location_code');
+ }
+
function get_children($criteria = '')
{
$join_method = '';
Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php 2013-04-02 10:32:06 UTC (rev
11020)
+++ trunk/property/inc/class.uientity.inc.php 2013-04-02 14:09:47 UTC (rev
11021)
@@ -2907,6 +2907,104 @@
echo lang('No Access');
$GLOBALS['phpgw']->common->phpgw_exit();
}
+ $unit_id = '';
+ if( $inventory = $this->bo->get_inventory($location_id,
$id, $inventory_id) )
+ {
+ $unit_id = $inventory[0]['unit_id'];
+ }
+
+ $location_code =
execMethod('property.solocation.get_location_code',$inventory[0]['p_id']);
+
+ $lock_unit = !!$unit_id;
+
+ $receipt = array();
+ $values = phpgw::get_var('values');
+
+ $bolocation =
CreateObject('property.bolocation');
+ $values['location_data'] =
$bolocation->read_single($location_code,array('view' => true));
+
+
+ $values['unit_id'] = $values['unit_id'] ?
$values['unit_id'] : $unit_id;
+
+
+ if (isset($values['save']) && $values['save'])
+ {
+ $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 !'));
+ }
+ if(!isset($receipt['error']))
+ {
+ $this->bo->save_inventory($values);
+ $receipt['message'][]=array('msg'=>
'Ok');
+ $values = array();
+ }
+ }
+
+ $msgbox_data = $this->bocommon->msgbox_data($receipt);
+
+ $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' => 'view',
+ 'tenant' => false,
+ 'lookup_entity' => $lookup_entity,
+ 'entity_data' =>
isset($values['p'])?$values['p']:''
+ ));
+
+ $dateformat =
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'];
+
+ $data = array
+ (
+ 'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
+ 'location_data' => $location_data,
+ 'system_location' => $system_location,
+ 'location_id' => $location_id,
+ 'item_id' => $id,
+ 'unit_list' =>
array('options' => $unit_list),
+ 'lock_unit' => $lock_unit,
+ 'value_inventory' => $values['inventory'],
+ 'value_write_off' => $values['write_off'],
+ 'bookable' =>
$values['bookable'] ? $values['bookable'] : $inventory[0]['bookable'],
+ 'value_active_from' =>
$values['active_from'] ? $values['active_from'] :
$GLOBALS['phpgw']->common->show_date($inventory[0]['active_from'],$dateformat ),
+ 'value_active_to' => $values['active_to']
? $values['active_to'] :
$GLOBALS['phpgw']->common->show_date($inventory[0]['active_to'],$dateformat ),
+ 'value_remark' => $values['remark'] ?
$values['remark'] : $inventory[0]['remark'],
+ );
+
+ $GLOBALS['phpgw']->jqcal->add_listener('active_from');
+ $GLOBALS['phpgw']->jqcal->add_listener('active_to');
+
$GLOBALS['phpgw']->xslttpl->add_file(array('entity','attributes_form',
'files'));
+ $GLOBALS['phpgw_info']['flags']['noframework'] = true;
+
+// $GLOBALS['phpgw']->js->validate_file( 'yahoo',
'entity.add_inventory', 'property' );
+
+ $function_msg = lang('add inventory');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
$system_location['appname'] . '::' . $system_location['descr'] . '::' .
$function_msg;
+
$GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('edit_inventory' => $data));
}
@@ -2985,7 +3083,7 @@
'lookup_entity' => $lookup_entity,
'entity_data' =>
isset($values['p'])?$values['p']:''
));
-
+
$data = array
(
'msgbox_data' =>
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
Modified: trunk/property/templates/base/entity.xsl
===================================================================
--- trunk/property/templates/base/entity.xsl 2013-04-02 10:32:06 UTC (rev
11020)
+++ trunk/property/templates/base/entity.xsl 2013-04-02 14:09:47 UTC (rev
11021)
@@ -7,6 +7,9 @@
<xsl:when test="empty">
<xsl:apply-templates select="empty"/>
</xsl:when>
+ <xsl:when test="edit_inventory">
+ <xsl:apply-templates select="edit_inventory"/>
+ </xsl:when>
<xsl:when test="add_inventory">
<xsl:apply-templates select="add_inventory"/>
</xsl:when>
@@ -14,6 +17,178 @@
</xsl:template>
+ <!-- edit inventory -->
+ <xsl:template xmlns:php="http://php.net/xsl" match="edit_inventory">
+
+ <div align = 'left'>
+
+ <xsl:variable name="action_url">
+ <xsl:value-of select="php:function('get_phpgw_link',
'/index.php', 'menuaction:property.uientity.add_inventory')" />
+ </xsl:variable>
+
+ <form name="form" id="form" action="{$action_url}"
method="post">
+
+ <fieldset>
+ <legend>
+ <xsl:value-of select="system_location/descr"/>
+ <xsl:text>::</xsl:text>
+ <xsl:value-of select="php:function('lang', 'edit
inventory')" />
+ </legend>
+
+ <table>
+ <xsl:choose>
+ <xsl:when test="msgbox_data != ''">
+ <tr>
+ <td align="left"
colspan="3">
+
<xsl:call-template name="msgbox"/>
+ </td>
+ </tr>
+ </xsl:when>
+ </xsl:choose>
+ <tr>
+ <td>
+ <label><xsl:value-of
select="php:function('lang', 'id')" /></label>
+ </td>
+ <td>
+ <xsl:value-of select="item_id"/>
+ <input type="hidden"
name="location_id" value="{location_id}"/>
+ <input type="hidden" name="id"
value="{item_id}"/>
+ </td>
+ </tr>
+
+ <xsl:call-template name="location_view"/>
+ <tr>
+ <td>
+ <label
for="unit_id"><xsl:value-of select="php:function('lang', 'unit')" /></label>
+ </td>
+ <td>
+ <select id = 'unit_id'
name="values[unit_id]" class="forms">
+ <xsl:if test="lock_unit
= 1">
+ <xsl:attribute
name="disabled" value="disabled"/>
+ </xsl:if>
+ <xsl:apply-templates
select="unit_list/options"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <label
for="inventory"><xsl:value-of select="php:function('lang', 'inventory')"
/></label>
+ </td>
+ <td>
+
+ <input type="text" id =
'inventory' name="values[inventory]" value="{value_inventory}" size="12">
+ <xsl:attribute
name="title">
+ <xsl:value-of
select="lang_inventory_statustext"/>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+
+ <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>
+ <input type="checkbox"
name="values[bookable]" value="1">
+ <xsl:attribute
name="title">
+ <xsl:value-of
select="php:function('lang', 'bookable')"/>
+ </xsl:attribute>
+ <xsl:if test="bookable
= '1'">
+ <xsl:attribute
name="checked">
+
<xsl:text>checked</xsl:text>
+ </xsl:attribute>
+ </xsl:if>
+ </input>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <label>
+ <xsl:value-of
select="php:function('lang', 'active from')"/>
+ </label>
+ </td>
+ <td>
+ <input type="text"
id="active_from" name="values[active_from]" size="10"
value="{value_active_from}" readonly="readonly">
+ <xsl:attribute
name="title">
+ <xsl:value-of
select="lang_active_from_statustext"/>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <label>
+ <xsl:value-of
select="php:function('lang', 'active to')"/>
+ </label>
+ </td>
+ <td>
+ <input type="text"
id="active_to" name="values[active_to]" size="10" value="{value_active_to}"
readonly="readonly">
+ <xsl:attribute
name="title">
+ <xsl:value-of
select="lang_active_to_statustext"/>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ <tr>
+
+ <td>
+ <label><xsl:value-of
select="php:function('lang', 'remark')" /></label>
+ </td>
+ <td>
+ <textarea cols="60" rows="4"
name="values[remark]">
+ <xsl:attribute
name="title">
+ <xsl:value-of
select="php:function('lang', 'remark')"/>
+ </xsl:attribute>
+ <xsl:value-of
select="value_remark"/>
+ </textarea>
+ </td>
+ </tr>
+ </table>
+ </fieldset>
+ <table>
+ <tr>
+ <td valign="bottom">
+ <xsl:variable name="lang_save">
+ <xsl:value-of
select="php:function('lang', 'save')"/>
+ </xsl:variable>
+ <input type="submit"
name="values[save]" value="{$lang_save}">
+ <xsl:attribute name="title">
+ <xsl:value-of
select="php:function('lang', 'save values and exit')"/>
+ </xsl:attribute>
+ </input>
+ </td>
+ <td align="right" valign="bottom">
+ <xsl:variable name="lang_cancel">
+ <xsl:value-of
select="php:function('lang', 'cancel')"/>
+ </xsl:variable>
+ <input type="submit"
name="values[cancel]" value="{$lang_cancel}">
+ <xsl:attribute name="title">
+ <xsl:value-of
select="php:function('lang', 'Back to the list')"/>
+ </xsl:attribute>
+ </input>
+ </td>
+ </tr>
+ </table>
+
+ </form>
+
+
+ </div>
+ </xsl:template>
+
+
<!-- add inventory -->
<xsl:template xmlns:php="http://php.net/xsl" match="add_inventory">
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11021] property: inventory,
Sigurd Nes <=