fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11024] property: inventory


From: Sigurd Nes
Subject: [Fmsystem-commits] [11024] property: inventory
Date: Thu, 04 Apr 2013 08:13:59 +0000

Revision: 11024
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11024
Author:   sigurdne
Date:     2013-04-04 08:13:58 +0000 (Thu, 04 Apr 2013)
Log Message:
-----------
property: inventory

Modified Paths:
--------------
    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

Added Paths:
-----------
    trunk/property/js/yahoo/entity.edit_inventory.js

Modified: trunk/property/inc/class.soentity.inc.php
===================================================================
--- trunk/property/inc/class.soentity.inc.php   2013-04-03 13:29:48 UTC (rev 
11023)
+++ trunk/property/inc/class.soentity.inc.php   2013-04-04 08:13:58 UTC (rev 
11024)
@@ -2445,12 +2445,7 @@
 
                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');   
                
@@ -2469,10 +2464,14 @@
                        $value_set      = 
$this->db->validate_update($value_set);
                        $this->db->query("UPDATE {$table} SET $value_set WHERE 
id = {$inventory_id}",__LINE__,__FILE__);
 
+                       if(!(int)$values['inventory'])
+                       {
+                               return $this->db->transaction_commit();         
        
+                       }
+
                        $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
@@ -2497,5 +2496,4 @@
 
                        return $this->db->transaction_commit();
                }
-
        }

Modified: trunk/property/inc/class.uientity.inc.php
===================================================================
--- trunk/property/inc/class.uientity.inc.php   2013-04-03 13:29:48 UTC (rev 
11023)
+++ trunk/property/inc/class.uientity.inc.php   2013-04-04 08:13:58 UTC (rev 
11024)
@@ -33,6 +33,12 @@
         */
        phpgw::import_class('phpgwapi.yui');
 
+       /**
+       * Import the jQuery class
+       */
+       phpgw::import_class('phpgwapi.jquery');
+
+
        class property_uientity
        {
                var $grants;
@@ -1757,10 +1763,14 @@
                                }
 
                                
phpgwapi_yui::tabview_setup('entity_edit_tabview');
+                               
+                                                               
+                               $active_tab = phpgw::get_var('active_tab');
+                               
                                if($category['location_level'] > 0)
                                {
-                                       $tabs['location']       = array('label' 
=> lang('location'), 'link' => '#location');
-                                       $active_tab = 'location';
+                                       $tabs['location']       = array('label' 
=> lang('location'), 'link' => '#location', 'function' => 
"set_tab('location')");
+                                       $active_tab = $active_tab ? $active_tab 
: 'location';
                                }
 
                                $location = 
".{$this->type}.{$this->entity_id}.{$this->cat_id}";
@@ -1777,7 +1787,7 @@
                                                {
                                                        $_tab_name = 
str_replace(' ', '_', $group['name']);
                                                        $active_tab = 
$active_tab ? $active_tab : $_tab_name;
-                                                       $tabs[$_tab_name] = 
array('label' => $group['name'], 'link' => '#' . $_tab_name);
+                                                       $tabs[$_tab_name] = 
array('label' => $group['name'], 'link' => "#{$_tab_name}", 'function' => 
"set_tab('{$_tab_name}')");
                                                        $group['link'] = 
$_tab_name;
                                                        $attributes[] = $group;
                                                        $i ++;
@@ -1804,7 +1814,7 @@
 
                                if($category['fileupload'] || 
(isset($values['files']) &&  $values['files']))
                                {
-                                       $tabs['files']  = array('label' => 
lang('files'), 'link' => '#files');
+                                       $tabs['files']  = array('label' => 
lang('files'), 'link' => '#files', 'function' => "set_tab('files')");
                                }
 /*
                                if($category['jasperupload'])
@@ -2041,12 +2051,12 @@
 
                                        if($documents)
                                        {
-                                               $tabs['document']       = 
array('label' => lang('document'), 'link' => '#document');
+                                               $tabs['document']       = 
array('label' => lang('document'), 'link' => '#document', 'function' => 
"set_tab('document')");
                                                $documents = 
json_encode($documents);                           
                                        }
                                }
 
-                               $tabs['related']        = array('label' => 
lang('log'), 'link' => '#related');
+                               $tabs['related']        = array('label' => 
lang('log'), 'link' => '#related', 'function' => "set_tab('related')");
                                $_target = array();
                                if(isset($values['target']) && 
$values['target'])
                                {
@@ -2130,7 +2140,7 @@
 
                                if($category['enable_bulk'])
                                {
-                                       $tabs['inventory']      = array('label' 
=> lang('inventory'), 'link' => '#inventory');
+                                       $tabs['inventory']      = array('label' 
=> lang('inventory'), 'link' => '#inventory', 'function' => 
"set_tab('inventory')");
 
                                        $_inventory = $this->get_inventory($id);
 
@@ -2151,7 +2161,7 @@
                                                'values'        =>      
json_encode(array(      
                                                                array('key' => 
'where','label'=>lang('where'),'sortable'=>false,'resizeable'=>true),
                                                                array('key' => 
'edit','label'=>lang('edit'),'sortable'=>false,'resizeable'=>true, 'formatter' 
=> 'FormatterEdit'),
-                                                               array('key' => 
'delete','label'=>lang('delete'),'sortable'=>false,'resizeable'=>true, 
'formatter' => 'FormatterCenter'),
+                                                       //      array('key' => 
'delete','label'=>lang('delete'),'sortable'=>false,'resizeable'=>true, 
'formatter' => 'FormatterCenter'),
                                                                array('key' => 
'unit','label'=>lang('unit'),'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'),
@@ -2159,7 +2169,6 @@
                                                                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),
                                                        )
                                                )
@@ -2236,6 +2245,7 @@
                                        'textareacols'                          
        => 
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'])
 && $GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'] ? 
$GLOBALS['phpgw_info']['user']['preferences']['property']['textareacols'] : 40,
                                        'textarearows'                          
        => 
isset($GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'])
 && $GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] ? 
$GLOBALS['phpgw_info']['user']['preferences']['property']['textarearows'] : 6,
                                        'tabs'                                  
                => phpgwapi_yui::tabview_generate($tabs, $active_tab),
+                                       'active_tab'                            
        => $active_tab,
                                        'integration'                           
        => $integration,
                                //      'value_integration_src'                 
=> $integration_src,
                                        'base_java_url'                         
        =>      "{menuaction:'property.uientity.get_files',".
@@ -2939,6 +2949,30 @@
                                        $receipt['message'][]=array('msg'=> 
'Ok');
                                        $values = array();                      
                
                                }
+
+
+                               if( phpgw::get_var('phpgw_return_as') == 'json' 
)
+                               {
+
+                                       if(!$receipt['error'])
+                                       {
+                                               $result =  array
+                                               (
+                                                       'status'        => 
'updated'
+                                               );
+                                       }
+                                       else
+                                       {
+                                               $result =  array
+                                               (
+                                                       'status'        => 
'error'
+                                               );
+                                       }
+
+                                       $result['receipt'] = $receipt;
+                                       return $result;
+                               }
+
                        }
 
                        $msgbox_data = $this->bocommon->msgbox_data($receipt);
@@ -2981,8 +3015,10 @@
                        
$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' );
+                       phpgwapi_jquery::load_widget('core');
 
+                       $GLOBALS['phpgw']->js->validate_file( 'yahoo', 
'entity.edit_inventory', 'property' );
+
                        $function_msg   = lang('add inventory');
 
                        $GLOBALS['phpgw_info']['flags']['app_header'] = 
$system_location['appname'] . '::' . $system_location['descr'] . '::' . 
$function_msg;

Modified: trunk/property/js/yahoo/entity.edit.js
===================================================================
--- trunk/property/js/yahoo/entity.edit.js      2013-04-03 13:29:48 UTC (rev 
11023)
+++ trunk/property/js/yahoo/entity.edit.js      2013-04-04 08:13:58 UTC (rev 
11024)
@@ -55,7 +55,7 @@
                newTR = document.createElement('tr');
 
                td_sum('Sum');
-               td_empty(3);
+               td_empty(2);
                td_sum(tmp_sum1);
                td_empty(5);
 
@@ -207,3 +207,95 @@
        
 })();
 
+
+// jquery
+$(document).ready(function(){
+
+       $("#edit_inventory").live("submit", function(e){
+
+               e.preventDefault();
+
+               var thisForm = $(this);
+               var submitBnt = $(thisForm).find("input[type='submit']");
+               var requestUrl = $(thisForm).attr("action");
+               $.ajax({
+                       type: 'POST',
+                       url: requestUrl + "&phpgw_return_as=json&" + 
$(thisForm).serialize(),
+                       success: function(data) {
+                               if(data)
+                               {
+                                       if(data.sessionExpired)
+                                       {
+                                               alert('Sesjonen er utløpt - du 
må logge inn på nytt');
+                                               return;
+                                       }
+
+                               var obj = data;
+                       
+                               var submitBnt = 
$(thisForm).find("input[type='submit']");
+                               if(obj.status == "updated")
+                               {
+                                       $(submitBnt).val("Lagret");
+                                       }
+                                       else
+                                       {
+                                       $(submitBnt).val("Feil ved lagring");   
                                
+                                       }
+                                                
+                               // Changes text on save button back to original
+                               window.setTimeout(function() {
+                                               $(submitBnt).val('Lagre');
+                                               
$(submitBnt).addClass("not_active");
+                               }, 1000);
+
+                                       var ok = true;
+                                       var htmlString = "";
+                                       if(data['receipt'] != null)
+                                       {
+                                               if(data['receipt']['error'] != 
null)
+                                               {
+                                                       ok = false;
+                                                       for ( var i = 0; i < 
data['receipt']['error'].length; ++i )
+                                                       {
+                                                               htmlString += 
"<div class=\"error\">";
+                                                               htmlString += 
data['receipt']['error'][i]['msg'];
+                                                               htmlString += 
'</div>';
+                                                       }
+                                       
+                                               }
+                                               
if(typeof(data['receipt']['message']) != 'undefined')
+                                               {
+                                                       for ( var i = 0; i < 
data['receipt']['message'].length; ++i )
+                                                       {
+                                                               htmlString += 
"<div class=\"msg_good\">";
+                                                               htmlString += 
data['receipt']['message'][i]['msg'];
+                                                               htmlString += 
'</div>';
+                                                       }
+                                       
+                                               }
+                                               $("#receipt").html(htmlString);
+                                       }
+                                       
+                                       if(ok)
+                                       {
+                                               parent.closeJS_remote();
+                                       //      parent.hide_popupBox();
+                                       }
+                               }
+                       }
+               });
+       });
+
+       $("#workorder_cancel").live("submit", function(e){
+               if($("#lean").val() == 0)
+               {
+                       return;
+               }
+               e.preventDefault();
+               parent.closeJS_remote();
+//             parent.hide_popupBox();
+       });
+
+});
+
+

Added: trunk/property/js/yahoo/entity.edit_inventory.js
===================================================================
--- trunk/property/js/yahoo/entity.edit_inventory.js                            
(rev 0)
+++ trunk/property/js/yahoo/entity.edit_inventory.js    2013-04-04 08:13:58 UTC 
(rev 11024)
@@ -0,0 +1,90 @@
+// jquery
+$(document).ready(function(){
+
+       $("#edit_inventory").live("submit", function(e){
+
+               e.preventDefault();
+
+               var thisForm = $(this);
+               var submitBnt = $(thisForm).find("input[type='submit']");
+               var requestUrl = $(thisForm).attr("action");
+               $.ajax({
+                       type: 'POST',
+                       url: requestUrl + "&phpgw_return_as=json&" + 
$(thisForm).serialize(),
+                       success: function(data) {
+                               if(data)
+                               {
+                                       if(data.sessionExpired)
+                                       {
+                                               alert('Sesjonen er utløpt - du 
må logge inn på nytt');
+                                               return;
+                                       }
+
+                               var obj = data;
+                       
+                               var submitBnt = 
$(thisForm).find("input[type='submit']");
+                               if(obj.status == "updated")
+                               {
+                                       $(submitBnt).val("Lagret");
+                                       }
+                                       else
+                                       {
+                                       $(submitBnt).val("Feil ved lagring");   
                                
+                                       }
+                                                
+                               // Changes text on save button back to original
+                               window.setTimeout(function() {
+                                               $(submitBnt).val('Lagre');
+                                               
$(submitBnt).addClass("not_active");
+                               }, 1000);
+
+                                       var ok = true;
+                                       var htmlString = "";
+                                       if(data['receipt'] != null)
+                                       {
+                                               if(data['receipt']['error'] != 
null)
+                                               {
+                                                       ok = false;
+                                                       for ( var i = 0; i < 
data['receipt']['error'].length; ++i )
+                                                       {
+                                                               htmlString += 
"<div class=\"error\">";
+                                                               htmlString += 
data['receipt']['error'][i]['msg'];
+                                                               htmlString += 
'</div>';
+                                                       }
+                                       
+                                               }
+                                               
if(typeof(data['receipt']['message']) != 'undefined')
+                                               {
+                                                       for ( var i = 0; i < 
data['receipt']['message'].length; ++i )
+                                                       {
+                                                               htmlString += 
"<div class=\"msg_good\">";
+                                                               htmlString += 
data['receipt']['message'][i]['msg'];
+                                                               htmlString += 
'</div>';
+                                                       }
+                                       
+                                               }
+                                               $("#receipt").html(htmlString);
+                                       }
+                                       
+                                       if(ok)
+                                       {
+                                               parent.TINY.box.hide();
+                                       }
+                               }
+                       }
+               });
+       });
+
+       $("#workorder_cancel").live("submit", function(e){
+               if($("#lean").val() == 0)
+               {
+                       return;
+               }
+               e.preventDefault();
+               parent.closeJS_remote();
+//             parent.hide_popupBox();
+       });
+
+});
+
+

Modified: trunk/property/templates/base/entity.xsl
===================================================================
--- trunk/property/templates/base/entity.xsl    2013-04-03 13:29:48 UTC (rev 
11023)
+++ trunk/property/templates/base/entity.xsl    2013-04-04 08:13:58 UTC (rev 
11024)
@@ -39,7 +39,7 @@
                                <xsl:value-of select="php:function('lang', 
'inventory')" />
                </xsl:variable>
 
-               <form name="form" id="form" action="{$action_url}" 
method="post">
+               <form name="form" id="edit_inventory" action="{$action_url}" 
method="post">
 
         <fieldset>
                <legend>
@@ -48,6 +48,7 @@
                        <xsl:value-of select="php:function('lang', 'edit 
inventory')" />
                </legend>
 
+                       <div id="receipt"></div>
                        <table>
                                <xsl:choose>
                                        <xsl:when test="msgbox_data != ''">
@@ -180,7 +181,7 @@
                                                <xsl:value-of 
select="php:function('lang', 'save')"/>
                                        </xsl:variable>
                                        <input type="hidden" 
name="values[save]" value="1"/>
-                                       <input type="button" name="send" 
value="{$lang_save}" onClick="edit_inventory();">
+                                       <input type="submit" name="send" 
value="{$lang_save}">
                                                <xsl:attribute name="title">
                                                        <xsl:value-of 
select="php:function('lang', 'save values and exit')"/>
                                                </xsl:attribute>
@@ -399,6 +400,11 @@
                        </xsl:when>
                </xsl:choose>
                <script type="text/javascript">
+                       function set_tab(active_tab)
+                       {
+                               document.form.active_tab.value = active_tab;    
                
+                       }
+
                        var property_js = <xsl:value-of select="property_js"/>;
                        var base_java_url = <xsl:value-of 
select="base_java_url"/>;
                        var datatable = new Array();
@@ -425,6 +431,7 @@
                                <xsl:value-of select="form_action"/>
                        </xsl:variable>
                        <form id="form" name="form" action="{$form_action}" 
method="post" ENCTYPE="multipart/form-data">
+                               <input type="hidden" name="active_tab" 
value="{active_tab}"/>
                                <table cellpadding="2" cellspacing="2" 
width="80%" align="center">
                                        <xsl:choose>
                                                <xsl:when test="msgbox_data != 
''">




reply via email to

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