fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11777] property: update orderinfo on voucher


From: Sigurd Nes
Subject: [Fmsystem-commits] [11777] property: update orderinfo on voucher
Date: Mon, 03 Mar 2014 19:26:06 +0000

Revision: 11777
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11777
Author:   sigurdne
Date:     2014-03-03 19:26:05 +0000 (Mon, 03 Mar 2014)
Log Message:
-----------
property: update orderinfo on voucher

Modified Paths:
--------------
    trunk/property/inc/class.boinvoice.inc.php
    trunk/property/inc/class.soinvoice.inc.php
    trunk/property/inc/class.uiinvoice2.inc.php
    trunk/property/js/portico/ajax_invoice.js
    trunk/property/templates/base/invoice2.xsl

Modified: trunk/property/inc/class.boinvoice.inc.php
===================================================================
--- trunk/property/inc/class.boinvoice.inc.php  2014-03-03 15:17:11 UTC (rev 
11776)
+++ trunk/property/inc/class.boinvoice.inc.php  2014-03-03 19:26:05 UTC (rev 
11777)
@@ -967,4 +967,15 @@
                {
                        return 
$this->so->get_auto_generated_invoice_num($vendor_id);
                }
+
+               /**
+                * Reasign an alter dimensions accordingly
+                * @param int $line_id
+                * @param bigint $order_id
+                * @return boolean true on success
+                */
+               public function reassign_order($line_id, $order_id)
+               {
+                       return $this->so->reassign_order($line_id, $order_id);
+               }
        }

Modified: trunk/property/inc/class.soinvoice.inc.php
===================================================================
--- trunk/property/inc/class.soinvoice.inc.php  2014-03-03 15:17:11 UTC (rev 
11776)
+++ trunk/property/inc/class.soinvoice.inc.php  2014-03-03 19:26:05 UTC (rev 
11777)
@@ -2583,4 +2583,58 @@
                        return $invoice_num;
                }
 
+               public function reassign_order($line_id, $order_id)
+               {
+                       $line_id = (int) $line_id;
+                       $order_info = $this->get_order_info($order_id); // 
henter default verdier selv om  $order_id ikke er gyldig.
+                       $value_set = array();
+
+                       if(!$order_id)
+                       {
+                               $merknad = 'Mangler bestillingsnummer';
+                               phpgwapi_cache::message_set(lang('Project is 
closed'), 'error');
+                               return false;
+                       }
+                       else if (!ctype_digit($order_id))
+                       {
+                               $remark = "bestillingsnummeret er på feil 
format: {$order_id}";
+                               phpgwapi_cache::message_set($remark, 'error');
+                               return false;
+                       }
+                       else if (!$order_info['order_exist'])
+                       {
+                               $remark = 'bestillingsnummeret ikke gyldig: ' . 
$order_id;
+                               phpgwapi_cache::message_set($remark, 'error');
+                               return false;
+                       }
+                       else
+                       {
+                               $value_set['project_id']                        
 = execMethod('property.soXport.get_project', $order_id);
+                       }
+
+                       $value_set['pmwrkord_code']             = $order_id;
+                       $value_set['dima']                              = 
$order_info['dima'];
+                       $value_set['dimb']                              = 
$order_info['dimb'];
+                       $value_set['dime']                              = 
$order_info['dime'];
+                       $value_set['loc1']                              = 
$order_info['loc1'];
+                       $value_set['line_text']                 = 
$order_info['title'];
+                       $value_set['spbudact_code'] = 
$order_info['spbudact_code'];
+                       if(isset($order_info['janitor']) && 
$order_info['janitor'])
+                       {
+                               $value_set['oppsynsmannid'] = 
$order_info['janitor'];
+                       }
+
+                       if(isset($order_info['supervisor']) && 
$order_info['supervisor'])
+                       {
+                               $value_set['saksbehandlerid']           = 
$order_info['supervisor'];
+                       }
+
+                       if(isset($order_info['budget_responsible']) && 
$order_info['budget_responsible'])
+                       {
+                               $value_set['budsjettansvarligid']       = 
$order_info['budget_responsible'];
+                       }
+                       $value_set      = 
$this->db->validate_update($value_set);
+                       return $this->db->query("UPDATE fm_ecobilag SET 
$value_set WHERE id = $line_id",__LINE__,__FILE__);
+
+               }
        }       

Modified: trunk/property/inc/class.uiinvoice2.inc.php
===================================================================
--- trunk/property/inc/class.uiinvoice2.inc.php 2014-03-03 15:17:11 UTC (rev 
11776)
+++ trunk/property/inc/class.uiinvoice2.inc.php 2014-03-03 19:26:05 UTC (rev 
11777)
@@ -123,7 +123,45 @@
                        $GLOBALS['phpgw']->redirect_link('/index.php', 
$link_data);
                }
 
+               /**
+                * Reasign an alter dimensions accordingly
+                * @param int $line_id
+                * @param bigint $order_id
+                * @return boolean true on success
+                */
+               public function reassign_order($line_id, $order_id, $voucher_id)
+               {
+                       if( $this->bo->reassign_order($line_id, $order_id))
+                       {
+                               phpgwapi_cache::message_set(lang('voucher is 
updated'), 'message');
 
+                               $result =  array
+                               (
+                                       'status'        => 'updated'
+                               );
+                       }
+                       else
+                       {
+                               $result =  array
+                               (
+                                       'status'        => 'error'
+                               );
+                       }
+                       if(phpgw::get_var('phpgw_return_as') == 'json')
+                       {
+                               if( $receipt = 
phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages'))
+                               {
+                                       
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
+                                       $result['receipt'] = $receipt;
+                               }
+                               return $result;
+                       }
+                       else
+                       {
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'property.uiinvoice2.index', 'voucher_id' => $voucher_id, 
'line_id' => $line_id));
+                       }
+               }
+
                function update_voucher()
                {
                        $receipt = array();
@@ -132,6 +170,12 @@
 
                        if($values = phpgw::get_var('values'))
                        {
+
+                               if($values['order_id'] != 
$values['order_id_orig'])
+                               {
+                                       return $this->reassign_order($line_id, 
$values['order_id'], $voucher_id);
+                               }
+
                                $order = 
execMethod('property.soworkorder.read_single',$values['order_id']);
                                $project = 
execMethod('property.soproject.read_single', $order['project_id']);
                                

Modified: trunk/property/js/portico/ajax_invoice.js
===================================================================
--- trunk/property/js/portico/ajax_invoice.js   2014-03-03 15:17:11 UTC (rev 
11776)
+++ trunk/property/js/portico/ajax_invoice.js   2014-03-03 19:26:05 UTC (rev 
11777)
@@ -24,6 +24,7 @@
                $("#line_id").val( '' );
                $("#line_text").val( '' );
                $("#order_id").val( '' );
+               $("#order_id_orig").val( '' );
                $("#project_group").val( '' );
                $("#invoice_id").html( '' );
                $("#kid_nr").html( '' );
@@ -121,31 +122,36 @@
                var dim_e = document.getElementById("dim_e").value;
                var dim_b = document.getElementById("dim_b").value;
                var dim_a = document.getElementById("dim_a").value;
+               var order_id = document.getElementById("order_id").value;
+               var order_id_orig = 
document.getElementById("order_id_orig").value;
 
-               if(periodization && ! periodization_start)
-               {
-                       alert('Du må velge startperiode');
-                       return;
-               }
 
-               if(!dim_e)
+               if(order_id_orig == order_id)
                {
-                       alert('Du må velge Kategori');
-                       return;
-               }
+                       if(periodization && ! periodization_start)
+                       {
+                               alert('Du må velge startperiode');
+                               return;
+                       }
 
-               if(!dim_b)
-               {
-                       alert('Du må velge Ansvarssted');
-                       return;
-               }
+                       if(!dim_e)
+                       {
+                               alert('Du må velge Kategori');
+                               return;
+                       }
 
-               if(!dim_a)
-               {
-                       alert('Du må angi Dim A');
-                       return;
+                       if(!dim_b)
+                       {
+                               alert('Du må velge Ansvarssted');
+                               return;
+                       }
+
+                       if(!dim_a)
+                       {
+                               alert('Du må angi Dim A');
+                               return;
+                       }
                }
-
                var thisForm = $(this);
                var submitBnt = $(thisForm).find("input[type='submit']");
                var requestUrl = $(thisForm).attr("action");
@@ -210,9 +216,9 @@
                                                }
                                        
                                        }
-                                       $("#receipt").html(htmlString);
                                        update_form_values(line_id, 
voucher_id_orig);
                                        update_voucher_filter();
+                                       $("#receipt").html(htmlString);
                                }
                        }
                });
@@ -304,6 +310,7 @@
                                }
 
                                $("#order_id").val( voucher[0].order_id );
+                               $("#order_id_orig").val( voucher[0].order_id );
 
                                if(voucher[0].order_id)
                                {
@@ -579,6 +586,7 @@
                                $("#voucher_id").val( '' );
                                $("#voucher_id_text").html( '' );
                                $("#order_id").val( '' );
+                               $("#order_id_orig").val( '' );
                                $("#project_group").val( '' );
                                $("#invoice_id").html( '' );
                                $("#kid_nr").html( '' );

Modified: trunk/property/templates/base/invoice2.xsl
===================================================================
--- trunk/property/templates/base/invoice2.xsl  2014-03-03 15:17:11 UTC (rev 
11776)
+++ trunk/property/templates/base/invoice2.xsl  2014-03-03 19:26:05 UTC (rev 
11777)
@@ -392,6 +392,7 @@
                        </td>
                        <td>
                                <input type="text" name="values[order_id]" 
id="order_id" value="{voucher_info/voucher/order_id}"/>
+                               <input type="hidden" 
name="values[order_id_orig]" id="order_id_orig" 
value="{voucher_info/voucher/order_id}"/>
                        </td>
                </tr>
                <tr class ='row_off'>




reply via email to

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