fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11010] property: inventory


From: Sigurd Nes
Subject: [Fmsystem-commits] [11010] property: inventory
Date: Wed, 20 Mar 2013 13:03:03 +0000

Revision: 11010
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11010
Author:   sigurdne
Date:     2013-03-20 13:03:02 +0000 (Wed, 20 Mar 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.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-03-20 09:04:22 UTC (rev 
11009)
+++ trunk/property/inc/class.boentity.inc.php   2013-03-20 13:03:02 UTC (rev 
11010)
@@ -680,10 +680,18 @@
                        return $this->so->read_entity_to_link($data);
                }
 
-               public function get_inventory($id = 0)
+               public function get_inventory($location_id, $id = 0)
                {
-                       $location_id = 
$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type], 
".{$this->type}.{$this->entity_id}.{$this->cat_id}");
                        $values = $this->so->get_inventory( array('id' => $id, 
'location_id' => $location_id) );
+
+                       $interlink      = CreateObject('property.interlink');
+
+                       foreach ($values as &$entry)
+                       {
+                               $link_info = 
$interlink->get_location_link($entry['p_location_id'], $entry['p_id'],'view');
+                               $entry['where'] = "<a 
href='{$link_info['link']}'>{$link_info['name']}</a>";
+                       }
+
                        return $values;
                }
 

Modified: trunk/property/inc/class.interlink.inc.php
===================================================================
--- trunk/property/inc/class.interlink.inc.php  2013-03-20 09:04:22 UTC (rev 
11009)
+++ trunk/property/inc/class.interlink.inc.php  2013-03-20 13:03:02 UTC (rev 
11010)
@@ -191,6 +191,50 @@
                /**
                 * Get relation of the interlink
                 *
+                * @param integer $location_id the location
+                * @param integer $id                   the id of the 
referenced item
+                *
+                * @return string the linkt to the the related item
+                */
+
+               public function get_location_link($location_id, $id, $action = 
'view')
+               {
+                       $system_location = 
$GLOBALS['phpgw']->locations->get_name($location_id);
+
+                       $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');
+                               $name = $id;
+                       }
+                       else if( preg_match('/.entity./i', 
$system_location['location']) )
+                       {
+                               $name = 
execMethod('property.soentity.get_short_description', 
+                                                       array('location_id' => 
$location_id, 'id' => $id));
+                       }
+
+                       $link = 
$this->get_relation_link($system_location['location'], $id, $action);
+                       if ($link)
+                       {
+                               return array
+                               (
+                                       'name'  => $name,
+                                       'link'  => $link
+                               );
+                       }
+                       else
+                       {
+                               return array();
+                       }
+               }
+
+
+               /**
+                * Get relation of the interlink
+                *
                 * @param array   $linkend_location the location
                 * @param integer $id                      the id of the 
referenced item
                 *
@@ -273,6 +317,15 @@
                        {
                                $link = array('menuaction' => 
'controller.uicheck_list.view_control_info', 'check_list_id' => $id);
                        }
+                       else if( substr($type, 1, 8) == 'location' )
+                       {
+                               $type           = explode('.',$type);
+                               $link = array
+                                       (
+                                               'menuaction'    => 
"property.uilocation.{$function}",
+                                               'location_code' => $id,
+                                       );
+                       }
 
                        return $GLOBALS['phpgw']->link('/index.php',$link);     
                }

Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php   2013-03-20 09:04:22 UTC (rev 
11009)
+++ trunk/property/inc/class.soentity.inc.php   2013-03-20 13:03:02 UTC (rev 
11010)
@@ -2378,6 +2378,7 @@
                                $inventory[] = array
                                (
                                        'inventory'             => 
$this->db->f('inventory'),
+                                       'unit_id'               => 
$this->db->f('unit_id'),
                                        'unit'                  => 
$this->db->f('unit', true),
                                        'remark'                => 
$this->db->f('remark', true),
                                        'p_location_id' => 
$this->db->f('p_location_id'),

Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php   2013-03-20 09:04:22 UTC (rev 
11009)
+++ trunk/property/inc/class.uientity.inc.php   2013-03-20 13:03:02 UTC (rev 
11010)
@@ -60,6 +60,7 @@
                                'index'                 => true,
                                'addfiles'              => true,
                                'get_files'             => true,
+                               'get_inventory' => true,
                                'add_inventory' => true
                        );
 
@@ -2139,7 +2140,7 @@
                                                'total_records'                 
=> count($_inventory),
                                                'edit_action'                   
=> "''",
                                                'is_paginator'                  
=> 1,
-                                               'footer'                        
        => 0
+                                               'footer'                        
        => 1
                                        );
 
        
@@ -2149,8 +2150,8 @@
                                                'values'        =>      
json_encode(array(      
                                                                array('key' => 
'where','label'=>lang('where'),'sortable'=>false,'resizeable'=>true),
                                                                array('key' => 
'unit','label'=>lang('unit'),'sortable'=>false,'resizeable'=>true),
-                                                               array('key' => 
'inventory','label'=>lang('count'),'sortable'=>false,'resizeable'=>true),
-                                                               array('key' => 
'bookable','label'=>lang('bookable'),'sortable'=>false,'resizeable'=>true),
+                                                               array('key' => 
'inventory','label'=>lang('count'),'sortable'=>false,'resizeable'=>true, 
'formatter' => 'FormatterAmount0'),
+                                                               array('key' => 
'bookable','label'=>lang('bookable'),'sortable'=>false,'resizeable'=>true, 
'formatter' => 'FormatterCenter'),
                                                                array('key' => 
'calendar','label'=>lang('calendar'),'sortable'=>false,'resizeable'=>true),
                                                                array('key' => 
'remark','label'=>lang('remark'),'sortable'=>false,'resizeable'=>true),
                                                        )
@@ -2852,19 +2853,45 @@
 
                public function get_inventory($id = 0)
                {
-                       return $this->bo->get_inventory($id);
+                       if(!$id)
+                       {
+                               $location_id    = phpgw::get_var('location_id', 
'int');
+                               $id                     = phpgw::get_var('id', 
'int');
+                               $system_location = 
$GLOBALS['phpgw']->locations->get_name($location_id);
+                               $location = 
explode('.',$system_location['location']);
+                               $this->bo->type = $location[1];
+                               $this->bo->entity_id = $location[1];
+                               $this->bo->cat_id = $location[3];
+                       }
+                       else
+                       {
+                               $location_id = 
$GLOBALS['phpgw']->locations->get_id($this->type_app[$this->type], 
".{$this->type}.{$this->entity_id}.{$this->cat_id}");
+                       }
+
+                       $inventory =  $this->bo->get_inventory($location_id, 
$id);
+
+                       if( phpgw::get_var('phpgw_return_as') == 'json' )
+                       {
+
+                               if(count($inventory))
+                               {
+                                       return json_encode($inventory);
+                               }
+                               else
+                               {
+                                       return "";
+                               }
+                       }
+                       
+                       return $inventory;
                }
 
                public function add_inventory()
                {
                        $location_id    = phpgw::get_var('location_id', 'int');
-                       $item_id                = phpgw::get_var('id', 'int');
+                       $id                             = phpgw::get_var('id', 
'int');
                        $system_location = 
$GLOBALS['phpgw']->locations->get_name($location_id);
-/*
-_debug_array($location_id);
-_debug_array($item_id);
-_debug_array($system_location);
-*/
+
                        $this->acl_add  = 
$this->acl->check($system_location['location'], PHPGW_ACL_ADD, 
$system_location['appname']);
 
                        if(!$this->acl_add)
@@ -2873,13 +2900,24 @@
                                $GLOBALS['phpgw']->common->phpgw_exit();
                        }
 
+                       $unit_id = '';
+                       if( $inventory = $this->bo->get_inventory($location_id, 
$id) )
+                       {
+                               $unit_id        = $inventory[0]['unit_id'];     
                
+                       }
+
+                       $lock_unit = !!$unit_id;
+
+                       $receipt = array();
                        $values         = phpgw::get_var('values');
                        
+                       $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']              = $item_id;
+                               $values['item_id']              = $id;
                                $insert_record                  = 
$GLOBALS['phpgw']->session->appsession('insert_record','property');
 
                                if(is_array($insert_record_entity))
@@ -2897,30 +2935,19 @@
                                        
$receipt['error'][]=array('msg'=>lang('Please select a location !'));
                                }
 
-                               if(isset($values_attribute) && 
is_array($values_attribute))
+                               if(!$values['unit_id'])
                                {
-                                       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']));                                              
-                                               }
-                                       }
+                                       
$receipt['error'][]=array('msg'=>lang('Please select a unit !'));
                                }
-
                                if(!isset($receipt['error']))
                                {
-                                       $receipt = 
$this->bo->save_inventory($values);
+                                       $this->bo->save_inventory($values);
+                                       $receipt['message'][]=array('msg'=> 
'Ok');
+                                       $values = array();                      
                
                                }
                        }
 
-
-                       $unit_id        = $values['unit_id'];
+                       $msgbox_data = $this->bocommon->msgbox_data($receipt);
                        
                        $unit_list = execMethod('property.bogeneric.get_list', 
array('type' => 'unit',  'selected' => $unit_id));
 
@@ -2937,12 +2964,13 @@
                        
                        $data = array
                        (
+                               'msgbox_data'           => 
$GLOBALS['phpgw']->common->msgbox($msgbox_data),
                                'location_data'         => $location_data,
                                'system_location'       => $system_location,
                                'location_id'           => $location_id,
-                               'item_id'                       => $item_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'],

Modified: trunk/property/js/yahoo/entity.edit.js
===================================================================
--- trunk/property/js/yahoo/entity.edit.js      2013-03-20 09:04:22 UTC (rev 
11009)
+++ trunk/property/js/yahoo/entity.edit.js      2013-03-20 13:03:02 UTC (rev 
11010)
@@ -1,7 +1,8 @@
 var  myDataSource, myDataTable, myContextMenu;
 var  myPaginator_0, myDataTable_0
 var  myPaginator_1, myDataTable_1;
-
+var  myPaginator_2, myDataTable_2;
+var  myPaginator_3, myDataTable_3;
 
/********************************************************************************/
 var FormatterCenter = function(elCell, oRecord, oColumn, oData)
 {
@@ -12,8 +13,45 @@
 
        this.myParticularRenderEvent = function()
        {
+               this.addFooterDatatable3(myPaginator_3,myDataTable_3);
        }
 
+
+       var FormatterAmount0 = function(elCell, oRecord, oColumn, oData)
+       {
+               var amount = YAHOO.util.Number.format(oData, {decimalPlaces:0, 
decimalSeparator:",", thousandsSeparator:" "});
+               elCell.innerHTML = "<div align=\"right\">"+amount+"</div>";
+       }       
+
+       this.addFooterDatatable3 = function(paginator,datatable)
+       {
+               //call getSumPerPage(name of column) in property.js
+               tmp_sum1 = getTotalSum('inventory',0,paginator,datatable);
+
+               if(typeof(tableYUI)=='undefined')
+               {
+                       tableYUI = 
YAHOO.util.Dom.getElementsByClassName("yui-dt-data","tbody")[3].parentNode;
+                       tableYUI.setAttribute("id","tableYUI");
+               }
+               else
+               {
+                       tableYUI.deleteTFoot();
+               }
+
+               //Create ROW
+               newTR = document.createElement('tr');
+
+               td_sum('Sum');
+               td_empty(1);
+               td_sum(tmp_sum1);
+               td_empty(6);
+
+               myfoot = tableYUI.createTFoot();
+               myfoot.setAttribute("id","myfoot");
+               myfoot.appendChild(newTR);
+       }
+
+
        this.fileuploader = function()
        {
                var sUrl = phpGWLink('index.php', fileuploader_action);
@@ -40,14 +78,21 @@
                var oArgs = {menuaction:'property.uientity.add_inventory', 
location_id:location_id, id: id};
                var sUrl = phpGWLink('index.php', oArgs);
 
-               TINY.box.show({iframe:sUrl, 
boxid:'frameless',width:750,height:450,fixed:false,maskid:'darkmask',maskopacity:40,
 mask:true, animate:true,
-               close: true
-       //      closejs:function(){closeJS_local()}
+               TINY.box.show({iframe:sUrl, 
boxid:'frameless',width:750,height:550,fixed:false,maskid:'darkmask',maskopacity:40,
 mask:true, animate:true,
+               close: true,
+               closejs:function(){refresh_inventory(location_id, id)}
                });
        }
 
 
+       this.refresh_inventory = function(location_id, id)
+       {
+               var oArgs = {menuaction:'property.uientity.get_inventory', 
location_id:location_id, id: id};
+               var requestUrl = phpGWLink('index.php', oArgs, true);
+               execute_async(myDataTable_3, oArgs);
+       }
 
+
 YAHOO.util.Event.addListener(window, "load", function()
                {
                        var loader = new YAHOO.util.YUILoader();

Modified: trunk/property/templates/base/entity.xsl
===================================================================
--- trunk/property/templates/base/entity.xsl    2013-03-20 09:04:22 UTC (rev 
11009)
+++ trunk/property/templates/base/entity.xsl    2013-03-20 13:03:02 UTC (rev 
11010)
@@ -23,7 +23,7 @@
                        <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">
+               <form name="form" id="form" action="{$action_url}" 
method="post">
 
         <fieldset>
                <legend>
@@ -33,6 +33,15 @@
                </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>
@@ -51,6 +60,9 @@
                                        </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>
@@ -132,7 +144,7 @@
                                                <label><xsl:value-of 
select="php:function('lang', 'remark')" /></label>
                                        </td>
                                        <td>
-                                               <textarea cols="60" rows="10" 
name="values[remark]">
+                                               <textarea cols="60" rows="4" 
name="values[remark]">
                                                        <xsl:attribute 
name="title">
                                                                <xsl:value-of 
select="php:function('lang', 'remark')"/>
                                                        </xsl:attribute>




reply via email to

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