fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [9186] property: invoice handling


From: Sigurd Nes
Subject: [Fmsystem-commits] [9186] property: invoice handling
Date: Thu, 19 Apr 2012 13:34:46 +0000

Revision: 9186
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9186
Author:   sigurdne
Date:     2012-04-19 13:34:45 +0000 (Thu, 19 Apr 2012)
Log Message:
-----------
property: invoice handling

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/js/yahoo/invoice2.index.js
    trunk/property/templates/base/invoice2.xsl

Modified: trunk/property/inc/class.boinvoice.inc.php
===================================================================
--- trunk/property/inc/class.boinvoice.inc.php  2012-04-19 13:11:28 UTC (rev 
9185)
+++ trunk/property/inc/class.boinvoice.inc.php  2012-04-19 13:34:45 UTC (rev 
9186)
@@ -813,6 +813,6 @@
 
                public function update_voucher2($data)
                {
-                       $receipt = $this->so->update_voucher2($data);
+                       return $this->so->update_voucher2($data);
                }
        }

Modified: trunk/property/inc/class.soinvoice.inc.php
===================================================================
--- trunk/property/inc/class.soinvoice.inc.php  2012-04-19 13:11:28 UTC (rev 
9185)
+++ trunk/property/inc/class.soinvoice.inc.php  2012-04-19 13:34:45 UTC (rev 
9186)
@@ -1967,7 +1967,7 @@
                        $receipt = $this->forward($data);
                        phpgwapi_cache::message_set(lang('voucher is updated'), 
'message');
 
-                       $GLOBALS['phpgw']->db->transaction_commit();
+                       return $GLOBALS['phpgw']->db->transaction_commit();
                }
 
                public function get_vouchers($data)

Modified: trunk/property/inc/class.uiinvoice2.inc.php
===================================================================
--- trunk/property/inc/class.uiinvoice2.inc.php 2012-04-19 13:11:28 UTC (rev 
9185)
+++ trunk/property/inc/class.uiinvoice2.inc.php 2012-04-19 13:34:45 UTC (rev 
9186)
@@ -28,12 +28,7 @@
 
        phpgw::import_class('phpgwapi.yui');
        phpgw::import_class('registration.uicommon');
-/*
-       include_class('registration', 'check_list', 'inc/model/');
-       include_class('registration', 'date_generator', 'inc/component/');
-       include_class('registration', 'status_checker', 'inc/helper/');
-       include_class('registration', 'date_helper', 'inc/helper/');
-*/     
+
        class property_uiinvoice2 extends registration_uicommon
        {
                var $cat_id;
@@ -60,7 +55,8 @@
                        'edit'                                                  
        => true,
                        'get_vouchers'                                          
=> true,
                        'get_single_voucher'                            => true,
-                       'get_single_line'                                       
=> true
+                       'get_single_line'                                       
=> true,
+                       'update_voucher'                                        
=> true
                );
 
                function __construct()
@@ -81,7 +77,7 @@
                        self::set_active_menu('property::invoice::invoice2');
                }
 
-               function index()
+               function update_voucher()
                {
                        $receipt = array();
                        $voucher_id     = phpgw::get_var('voucher_id', 'int');
@@ -101,183 +97,236 @@
                                $values['line_id'] = $line_id;
                                if(!$receipt['error'])
                                {
-                                       $receipt = 
$this->bo->update_voucher2($values);
+                                       if($this->bo->update_voucher2($values))
+                                       {
+                                               $result =  array
+                                               (
+                                                       'status'        => 
'updated'
+                                               );
+                                       }
+                                       else
+                                       {
+                                               $result =  array
+                                               (
+                                                       'status'        => 
'error'
+                                               );
+                                       }
                                }
+                       }
 
-                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'property.uiinvoice2.index', 'voucher_id' => $voucher_id, 
'line_id' => $line_id));
+                       if(phpgw::get_var('phpgw_return_as') == 'json')
+                       {
+                               return $result;
                        }
                        else
                        {
-                               if(phpgw::get_var('phpgw_return_as') == 'json')
-                               {
-                                       return $this->query();
-                               }
+                               $GLOBALS['phpgw']->redirect_link('/index.php', 
array('menuaction' => 'property.uiinvoice2.index', 'voucher_id' => $voucher_id, 
'line_id' => $line_id));
+                       }
+               }
 
-                               $janitor_list                           = 
$this->bocommon->get_user_list_right(32,$janitor,'.invoice');
-                               $supervisor_list                        = 
$this->bocommon->get_user_list_right(64,$supervisor,'.invoice');
-                               $budget_responsible_list        = 
$this->bocommon->get_user_list_right(128,$budget_responsible,'.invoice');
 
-                               $userlist_default = array();
-                               $userlist_default[] = array('id'=> '*' . 
$GLOBALS['phpgw']->accounts->get($this->account_id)->lid, 'name'=>lang('mine 
vouchers'));
-                               $userlist_default[] = 
array('id'=>'','name'=>lang('no user'));
+               function index()
+               {
+                       $receipt = array();
+                       $voucher_id     = phpgw::get_var('voucher_id', 'int');
+                       $line_id        = phpgw::get_var('line_id', 'int');
 
-                               $voucher_list = array('id' => '', 'name' => 
lang('select'));
+                       if(phpgw::get_var('phpgw_return_as') == 'json')
+                       {
+                               return $this->query();
+                       }
 
-                               foreach($userlist_default as $default)
-                               {
-                                       $janitor_list = 
array_merge(array($default), $janitor_list);
-                                       $supervisor_list = 
array_merge(array($default), $supervisor_list);
-                                       $budget_responsible_list = 
array_merge(array($default), $budget_responsible_list);
-                               }
+                       $janitor_list                           = 
$this->bocommon->get_user_list_right(32,$janitor,'.invoice');
+                       $supervisor_list                        = 
$this->bocommon->get_user_list_right(64,$supervisor,'.invoice');
+                       $budget_responsible_list        = 
$this->bocommon->get_user_list_right(128,$budget_responsible,'.invoice');
 
-                               $msgbox_data = array();
-                               if( phpgw::get_var('phpgw_return_as') != 'json' 
&& $receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages'))
-                               {
-                                       
phpgwapi_cache::session_clear('phpgwapi', 'phpgw_messages');
-                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($receipt);
-                                       $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
-                               }
+                       $userlist_default = array();
+                       $userlist_default[] = array('id'=> '*' . 
$GLOBALS['phpgw']->accounts->get($this->account_id)->lid, 'name'=>lang('mine 
vouchers'));
+                       $userlist_default[] = array('id'=>'','name'=>lang('no 
user'));
 
-                               $user = $GLOBALS['phpgw']->accounts->get( 
$GLOBALS['phpgw_info']['user']['id'] );
+                       $voucher_list = array('id' => '', 'name' => 
lang('select'));
 
-                               $data = array(
-                                       'msgbox_data'                   => 
$msgbox_data,
-                                       'invoice_layout_config' => 
json_encode(execMethod('phpgwapi.template_portico.retrieve_local', 
'invoice_layout_config')),
-                                       'preferences_url'       => 
$GLOBALS['phpgw']->link('/preferences/index.php'),
-                                       'preferences_text'      => 
lang('preferences'),
-                                       'home_url'              => 
$GLOBALS['phpgw']->link('/home.php'),
-                                       'home_text'             => lang('home'),
-                                       'home_icon'             => 'icon 
icon-home',
-                                       'about_url'             => 
$GLOBALS['phpgw']->link('/about.php', array('app' => 
$GLOBALS['phpgw_info']['flags']['currentapp']) ),
-                                       'about_text'    => lang('about'),
-                                       'logout_url'    => 
$GLOBALS['phpgw']->link('/logout.php'),
-                                       'logout_text'   => lang('logout'),
-                                       'user_fullname' => $user->__toString(),
-                                       'site_title'    => 
"{$GLOBALS['phpgw_info']['server']['site_title']}",
-                                       'filter_form'                           
=> array
-                                       (
-                                               'janitor_list'                  
        => array('options' => $janitor_list),
-                                               'supervisor_list'               
        => array('options' => $supervisor_list),
-                                               'budget_responsible_list'       
=> array('options' => $budget_responsible_list),
-                                       ),
-                                       'filter_invoice'                        
        => array
-                                       (
-                                               'voucher_list'                  
        => array('options' => $voucher_list),
-                                       ),
-                                       'voucher_info'                          
        => $this->get_single_line($line_id),
-                                       'datatable' => array(
-                                               'source' => 
self::link(array('menuaction' => 'property.uiinvoice2.query', 'voucher_id' => 
$voucher_id,'line_id' => $line_id,'phpgw_return_as' => 'json')),
-                                               'field' => array(
-                                                       array(
-                                                               'key' => 'id',
-                                                               'hidden' => true
-                                                       ),
-                                                       array(
-                                                                       'key' 
=> 'approve_line',
-                                                                       'label' 
=> lang('select'),
-                                                                       
'sortable' => false,
-                                                                       
'formatter' => 'FormatterCenter',
-                                                       ),
-                                                       array(
-                                                               'key'   =>      
'amount',
-                                                               'label' =>      
lang('amount'),
-                                                               'sortable'      
=>      true
-                                                       ),
-                                                       array(
-                                                               'key' => 
'approved_amount',
-                                                               'label' => 
lang('approved amount'),
-                                                               'sortable'      
=> true,
-               //                                              'formatter' => 
'FormatterRight',
-                                                       ),
-                                                       array(
-                                                                       'key' 
=> 'split',
-                                                                       'label' 
=> lang('split line'),
-                                                                       
'sortable' => false,
-                                                                       
'formatter' => 'FormatterCenter',
-                                                       ),
-                                                       array(
-                                                                       'key' 
=> 'budget_account',
-                                                                       'label' 
=> lang('budget account'),
-                                                                       
'sortable' => false,
-                                                                       
'formatter' => 'FormatterCenter',
-                                                       ),
+                       foreach($userlist_default as $default)
+                       {
+                               $janitor_list = array_merge(array($default), 
$janitor_list);
+                               $supervisor_list = array_merge(array($default), 
$supervisor_list);
+                               $budget_responsible_list = 
array_merge(array($default), $budget_responsible_list);
+                       }
 
-                                                       array(
-                                                                       'key' 
=> 'dima',
-                                                                       'label' 
=> lang('dim a'),
-                                                                       
'sortable' => false,
-                                                                       
'formatter' => 'FormatterCenter',
-                                                       ),
-                                                       array(
-                                                                       'key' 
=> 'dimb',
-                                                                       'label' 
=> lang('dim b'),
-                                                                       
'sortable' => false,
-                                                                       
'formatter' => 'FormatterCenter',
-                                                       ),
+                       $msgbox_data = array();
+                       if( phpgw::get_var('phpgw_return_as') != 'json' && 
$receipt = phpgwapi_cache::session_get('phpgwapi', 'phpgw_messages'))
+                       {
+                               phpgwapi_cache::session_clear('phpgwapi', 
'phpgw_messages');
+                               $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox_data($receipt);
+                               $msgbox_data = 
$GLOBALS['phpgw']->common->msgbox($msgbox_data);
+                       }
 
-                                                       array(
-                                                                       'key' 
=> 'order_id',
-                                                                       'label' 
=> lang('order'),
-                                                                       
'sortable' => false,
-                                                                       
'formatter' => 'FormatterCenter',
-                                                       ),
+                       $user = $GLOBALS['phpgw']->accounts->get( 
$GLOBALS['phpgw_info']['user']['id'] );
 
-                                                       array(
-                                                                       'key' 
=> 'project_group',
-                                                                       'label' 
=> lang('project group'),
-                                                                       
'sortable' => false,
-                                                                       
'formatter' => 'FormatterCenter',
-                                                       ),
 
+
+                       $myColumnDefs = array();
+                       $datavalues = array();
+                       $myButtons      = array();
+                       $myColumnDefs[0] = array
+                       (
+                               'name'          => "0",
+                               'values'        =>      json_encode(array(      
array('key' => 'value_email',   'label'=>lang('email'), 
'sortable'=>true,'resizeable'=>true),
+                                                                               
                        array('key' => 
'value_select','label'=>lang('select'),'sortable'=>false,'resizeable'=>true)))
+                       );      
+
+
+                       $content_email = 
$this->bocommon->get_vendor_email(isset($ticket['vendor_id'])?$ticket['vendor_id']:0);
+
+                       $datavalues[] = array
+                       (
+                               'name'                          => "0",
+                               'values'                        => 
json_encode(array()),
+                               'total_records'         => 0,
+                               'permission'            => "''",
+                               'is_paginator'          => 0,
+                               'edit_action'           => "''",
+                               'footer'                        => 0
+                       );
+
+                       $datatable_old = array
+                       (
+                                       'source' => 
self::link(array('menuaction' => 'property.uiinvoice2.query', 'voucher_id' => 
$voucher_id,'line_id' => $line_id,'phpgw_return_as' => 'json')),
+                                       'field' => array(
+                                               array(
+                                               'key' => 'id',
+                                               'hidden' => true
+                                               ),
+                                               array(
+                                                               'key' => 
'approve_line',
+                                                               'label' => 
lang('select'),
+                                                               'sortable' => 
false,
+                                                               'formatter' => 
'FormatterCenter',
+                                               ),
+                                               array(
+                                                       'key'   =>      
'amount',
+                                                       'label' =>      
lang('amount'),
+                                                       'sortable'      =>      
true
+                                               ),
+                                               array(
+                                                       'key' => 
'approved_amount',
+                                                       'label' => 
lang('approved amount'),
+                                                       'sortable'      => true,
+       //                                              'formatter' => 
'FormatterRight',
+                                               ),
+                                               array(
+                                                               'key' => 
'split',
+                                                               'label' => 
lang('split line'),
+                                                               'sortable' => 
false,
+                                                               'formatter' => 
'FormatterCenter',
+                                               ),
+                                               array(
+                                                               'key' => 
'budget_account',
+                                                               'label' => 
lang('budget account'),
+                                                               'sortable' => 
false,
+                                                               'formatter' => 
'FormatterCenter',
+                                               ),
                                                        array(
-                                                                       'key' 
=> 'line_text',
-                                                                       'label' 
=> lang('invoice line text'),
-                                                                       
'sortable' => false,
-                                                                       
'formatter' => 'FormatterCenter',
-                                                       ),
+                                                               'key' => 'dima',
+                                                               'label' => 
lang('dim a'),
+                                                               'sortable' => 
false,
+                                                               'formatter' => 
'FormatterCenter',
+                                               ),
+                                               array(
+                                                               'key' => 'dimb',
+                                                               'label' => 
lang('dim b'),
+                                                               'sortable' => 
false,
+                                                               'formatter' => 
'FormatterCenter',
+                                               ),
                                                        array(
-                                                               'key' => 
'actions',
-                                                               'hidden' => true
-                                                       ),
+                                                               'key' => 
'order_id',
+                                                               'label' => 
lang('order'),
+                                                               'sortable' => 
false,
+                                                               'formatter' => 
'FormatterCenter',
+                                               ),
                                                        array(
-                                                               'key' => 
'labels',
-                                                               'hidden' => true
-                                                       ),
+                                                               'key' => 
'project_group',
+                                                               'label' => 
lang('project group'),
+                                                               'sortable' => 
false,
+                                                               'formatter' => 
'FormatterCenter',
+                                               ),
                                                        array(
-                                                               'key' => 'ajax',
-                                                               'hidden' => true
-                                                       ),array(
-                                                               'key' => 
'parameters',
-                                                               'hidden' => true
-                                                       )                       
                
-                                               )
+                                                               'key' => 
'line_text',
+                                                               'label' => 
lang('invoice line text'),
+                                                               'sortable' => 
false,
+                                                               'formatter' => 
'FormatterCenter',
+                                               ),
+                                               array(
+                                                       'key' => 'actions',
+                                                       'hidden' => true
+                                               ),
+                                               array(
+                                                       'key' => 'labels',
+                                                       'hidden' => true
+                                               ),
+                                               array(
+                                                       'key' => 'ajax',
+                                                       'hidden' => true
+                                               ),array(
+                                                       'key' => 'parameters',
+                                                       'hidden' => true
+                                               )                               
        
                                        )
                                );
-/*
-    Art
-    Kategori
-    Koststed
-    Bestillingsnummer
-    Agressoprosjektnr
-    Postringstekst
-    Beløp
-*/
 
 
+
+                       $data = array
+                       (
+                               'td_count'                                      
        => '""',
+                               'base_java_url'                                 
=> "{menuaction:'property.uiinvoice2.update_voucher'}",
+                               'property_js'                                   
=> 
json_encode($GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property2.js"),
+                               'datatable'                                     
        => $datavalues,
+                               'myColumnDefs'                                  
=> $myColumnDefs,
+                               'myButtons'                                     
        => $myButtons,
+
+                               'msgbox_data'                                   
=> $msgbox_data,
+                               'invoice_layout_config'                 => 
json_encode(execMethod('phpgwapi.template_portico.retrieve_local', 
'invoice_layout_config')),
+                               'preferences_url'                               
=> $GLOBALS['phpgw']->link('/preferences/index.php'),
+                               'preferences_text'                              
=> lang('preferences'),
+                               'home_url'                                      
        => $GLOBALS['phpgw']->link('/home.php'),
+                               'home_text'                                     
        => lang('home'),
+                               'home_icon'                                     
        => 'icon icon-home',
+                               'about_url'                                     
        => $GLOBALS['phpgw']->link('/about.php', array('app' => 
$GLOBALS['phpgw_info']['flags']['currentapp']) ),
+                               'about_text'                                    
=> lang('about'),
+                               'logout_url'                                    
=> $GLOBALS['phpgw']->link('/logout.php'),
+                               'logout_text'                                   
=> lang('logout'),
+                               'user_fullname'                                 
=> $user->__toString(),
+                               'site_title'                                    
=> "{$GLOBALS['phpgw_info']['server']['site_title']}",
+                               'filter_form'                                   
=> array
+                                                                               
                        (
+                                                                               
                                'janitor_list'                          => 
array('options' => $janitor_list),
+                                                                               
                                'supervisor_list'                       => 
array('options' => $supervisor_list),
+                                                                               
                                'budget_responsible_list'       => 
array('options' => $budget_responsible_list),
+                                                                               
                        ),
+                               'filter_invoice'                                
        => array
+                                                                               
                        (
+                                                                               
                                'voucher_list'                  => 
array('options' => $voucher_list),
+                                                                               
                        ),
+                               'voucher_info'                                  
=> $this->get_single_line($line_id),
+                               'update_action'                                 
=> self::link(array('menuaction' => 'property.uiinvoice2.update_voucher')),
+                               'datatable_old'                                 
=> array()//$datatable_old;
+                       );
 //_debug_array($data);die();                   
+                       
$GLOBALS['phpgw']->css->add_external_file('/phpgwapi/js/yahoo/layout/assets/skins/sam/layout.css');
+                       phpgwapi_yui::load_widget('layout');
+                       phpgwapi_yui::load_widget('paginator');
+                       phpgwapi_yui::load_widget('loader');
 
-                               
$GLOBALS['phpgw']->css->add_external_file('/phpgwapi/js/yahoo/layout/assets/skins/sam/layout.css');
-                               phpgwapi_yui::load_widget('layout');
-                               phpgwapi_yui::load_widget('paginator');
 
-//                             self::add_javascript('registration', 'yahoo', 
'pending.index.js');
-                               self::add_javascript('controller', 
'controller', 'jquery.js');
-                               self::add_javascript('property', 'portico', 
'ajax_invoice.js');
-                               self::add_javascript('property', 'yahoo', 
'invoice2.index.js');
 
-                               self::render_template_xsl(array('invoice2', 
'common'), $data);
-                               $GLOBALS['phpgw_info']['flags']['noframework']  
= true;
-                       }       
+                       self::add_javascript('controller', 'controller', 
'jquery.js');
+                       self::add_javascript('property', 'portico', 
'ajax_invoice.js');
+                       self::add_javascript('property', 'yahoo', 
'invoice2.index.js');
+
+//                     self::render_template_xsl(array('invoice2', 'common'), 
$data);
+                       self::render_template_xsl(array('invoice2'), $data);
+                       $GLOBALS['phpgw_info']['flags']['noframework']  = true;
                }
        
 
@@ -506,7 +555,7 @@
                                        $voucher[0]['image_url']        = 
$_image_url;
                                }
                                $voucher_info['generic']['process_log'] = 
$voucher[0]['process_log'];
-       //                      $voucher[0]['image_url']        = 
'http://www.nettavisen.no/';
+                               $voucher[0]['image_url']        = 
'';//'http://www.nettavisen.no/';
                        }
                        else
                        {

Modified: trunk/property/js/portico/ajax_invoice.js
===================================================================
--- trunk/property/js/portico/ajax_invoice.js   2012-04-19 13:11:28 UTC (rev 
9185)
+++ trunk/property/js/portico/ajax_invoice.js   2012-04-19 13:34:45 UTC (rev 
9186)
@@ -115,7 +115,6 @@
     });
 
 
-//     $("#queryForm").submit(function(e){
        $("#search").click(function(e){
                var janitor_lid = $("#janitor_lid").val();
                var supervisor_lid = $("#supervisor_lid").val();
@@ -197,306 +196,71 @@
 
        $("#approve_line").live("click", function(e){
                var line_id = $(this).val();
-               var oArgs = {menuaction:'property.uiinvoice2.get_single_line'};
-               var requestUrl = phpGWLink('index.php', oArgs, true);
+               var voucher_id_orig = $("#voucher_id").val();
+               update_form_values(line_id, voucher_id_orig);
 
+    });
+
+
+       $("#voucher_form").live("submit", function(e){
+//             e.preventDefault();
+return;
+               var line_id = $("#line_id").val();
+               var voucher_id_orig = $("#voucher_id").val();
+               if(!line_id)
+               {
+                       alert('Du må velge linje i bilag');
+                       return;
+               }
+
+               var thisForm = $(this);
+               var submitBnt = $(thisForm).find("input[type='submit']");
+               var requestUrl = $(thisForm).attr("action");
                $.ajax({
                        type: 'POST',
-                       dataType: 'json',
-                       url: requestUrl + "&line_id=" + line_id,
+                       url: requestUrl + "&phpgw_return_as=json&" + 
$(thisForm).serialize(),
                        success: function(data) {
-                               var voucher = data['voucher'];
-                               if( voucher != null && voucher.length > 0)
+                               if(data)
                                {
-                                       $("#line_id").val( line_id );
-               
-                                       $("#voucher_id").val( 
voucher[0].voucher_id );
-                                       if( voucher[0].voucher_out_id )
-                                       {
-                                               $("#voucher_id_text").html( 
voucher[0].voucher_out_id );
-                                       }
-                                       else
-                                       {
-                                               $("#voucher_id_text").html( 
voucher[0].voucher_id );
-                                       }
+                       //      var obj = jQuery.parseJSON(data);
+                               var obj = data;
+                       
+                               var submitBnt = 
$(thisForm).find("input[type='submit']");
+                               if(obj.status == "updated")
+                               {
+                                       $(submitBnt).val("Lagret");
+                               /*
+                                       var oArgs = 
{menuaction:'property.uiinvoice2.get_vouchers'};
+                                       var requestUrl = phpGWLink('index.php', 
oArgs, true);
+                                       requestUrl = requestUrl + 
"&voucher_id_filter=" + $("#voucher_id").val();
+                                       
execute_async(datatable-container,requestUrl);
+                               */
 
-                                       $("#order_id").val( voucher[0].order_id 
);
-
-                                       if(voucher[0].order_id)
-                                       {
-                                               var oArgs_order = 
{menuaction:'property.uiinvoice.view_order', order_id: voucher[0].order_id};
-                                               var requestUrl_order = 
phpGWLink('index.php', oArgs_order);
-                                               var htmlString_order  =  " <a 
target= \"_blank\" href=\"" + requestUrl_order + "\" title=\"" + 
voucher[0].status + "\" > Bestilling</a>";
-                                               $("#order_text").html( 
htmlString_order );
                                        }
                                        else
                                        {
-                                               $("#order_text").html( 
'Bestilling' );
+                                       $(submitBnt).val("Feil ved lagring");   
                                
                                        }
+                                                
+                               // Changes text on save button back to original
+                               window.setTimeout(function() {
+                                               $(submitBnt).val('Lagre Linje');
+                                               
$(submitBnt).addClass("not_active");
+                               }, 1000);
 
-                                       $("#project_group").val( 
voucher[0].project_group );
+                                       update_form_values(line_id, 
voucher_id_orig);
+                               }
+                       }
+               });
+       });
 
-                                       if(voucher[0].external_ref)
-                                       {
-                                               
$("#invoice_id_text").html(voucher[0].external_ref );
-                                               
document.getElementById('image_content').src = voucher[0].image_url;
-                                       }
-                                       else
-                                       {
-                                               
$("#invoice_id_text").html('FakturaNr');
-                                               
document.getElementById('image_content').src = '';
-                                       }
 
-                                       $("#invoice_id").html( 
voucher[0].invoice_id );
-                                       $("#kid_nr").html( voucher[0].kid_nr );
-                                       $("#vendor").html( voucher[0].vendor );
-//                                     $("#janitor").html( voucher[0].janitor 
);
-//                                     $("#supervisor").html( 
voucher[0].supervisor );
-//                                     $("#budget_responsible").html( 
voucher[0].budget_responsible );
-                                       $("#invoice_date").html( 
voucher[0].invoice_date );
-                                       $("#payment_date").html( 
voucher[0].payment_date );
-                                       $("#b_account_id").val( 
voucher[0].b_account_id );
-                                       $("#dim_a").val( voucher[0].dim_a );
-//                                     $("#amount").html( 
data['generic'].amount );
-//                                     $("#approved_amount").html( 
data['generic'].approved_amount );
-                                       $("#currency").html( 
voucher[0].currency );
-                                       $("#process_log").html( 
data['generic'].process_log );
-                                       $("#my_initials").val( 
data['generic'].my_initials );
-                                       $("#sign_orig").val( 
data['generic'].sign_orig );
-                                       $("#line_text").val( 
voucher[0].line_text );
 
-               //                      $("#oppsynsigndato").html( 
voucher[0].oppsynsigndato );
-               //                      $("#saksigndato").html( 
voucher[0].saksigndato );
-               //                      $("#budsjettsigndato").html( 
voucher[0].budsjettsigndato );
-                                       if(voucher[0].merknad)
-                                       {
-                                               var oArgs_remark = 
{menuaction:'property.uiinvoice.remark', id: voucher[0].id};
-                                               var requestUrl_remark = 
phpGWLink('index.php', oArgs_remark);
 
-                                               var htmlString  =  " <a 
href=\"javascript:openwindow('" +requestUrl_remark + "','550','400')\" > 
Remark</a>";
 
-                                               $("#remark").html( htmlString );
-                                       }
-//---------
-                                       var checked_park_invoice = "";
-                                       var park_invoice_status = "";
-                                       if(voucher[0].parked)
-                                       {
-                                               checked_park_invoice = "checked 
= \"checked\"";
-                                               var park_invoice_status = " X";
-                                       }
-                                       var htmlString_park_invoice = "<input 
type=\"checkbox\" name=\"values[park_invoice]\" value=\"1\" title=\"park 
invoice\"" + checked_park_invoice + "></input>" + park_invoice_status;
-                                       $("#park_order").html( 
htmlString_park_invoice );
-//---------
-                                       var checked_close_order = "";
-                                       var close_order_status = " " + 
voucher[0].status;
-                                       if(voucher[0].closed)
-                                       {
-                                               checked_close_order = "checked 
= \"checked\"";
-                                       }
-                                       var htmlString_close_order = "<input 
type=\"checkbox\" name=\"values[close_order]\" value=\"1\" title=\"close 
order\"" + checked_close_order + "></input>" + close_order_status;
-                                       $("#close_order").html( 
htmlString_close_order );
-                                       $("#close_order_orig").val( 
voucher[0].closed );
-//---------
+//-------------
 
-                                       
if(data['generic']['dimb_list']['options'] != 'undefined')
-                                       {
-                                               var htmlString = "";
 
-                                               var obj = 
data['generic']['dimb_list']['options'];
-
-                                               $.each(obj, function(i) {
-                                                       var selected = '';
-                                                       if(obj[i].id == 
voucher[0].dim_b)
-                                                       {
-                                                               selected = ' 
selected';
-                                                       }
-                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
-                                               });
-
-                                               $("#dim_b").html( htmlString );
-                                       }
-                                       
if(data['generic']['tax_code_list']['options'] != 'undefined')
-                                       {
-                                               var htmlString = "";
-
-                                               htmlString  = 
"<option>Velg</option>"
-
-                                               var obj = 
data['generic']['tax_code_list']['options'];
-
-                                               $.each(obj, function(i) {
-                                                       var selected = '';
-                                                       if(obj[i].id == 
voucher[0].tax_code)
-                                                       {
-                                                               selected = ' 
selected';
-                                                       }
-                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
-                                               });
-
-                                               $("#tax_code").html( htmlString 
);
-                                       }
-
-                                       
if(data['generic']['period_list']['options'] != 'undefined')
-                                       {
-                                               var htmlString = "";
-
-                                               var obj = 
data['generic']['period_list']['options'];
-
-                                               $.each(obj, function(i) {
-                                                       var selected = '';
-                                                       if(obj[i].id == 
voucher[0].period)
-                                                       {
-                                                               selected = ' 
selected';
-                                                       }
-                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
-                                               });
-
-                                               $("#period").html( htmlString );
-                                       }
-                                       
if(data['generic']['periodization_list']['options'] != 'undefined')
-                                       {
-                                               var htmlString = "";
-
-                                               var obj = 
data['generic']['periodization_list']['options'];
-
-                                               $.each(obj, function(i) {
-                                                       var selected = '';
-                                                       if(obj[i].id == 
voucher[0].periodization)
-                                                       {
-                                                               selected = ' 
selected';
-                                                       }
-                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
-                                               });
-
-                                               $("#periodization").html( 
htmlString );
-                                       }
-                                       
if(data['generic']['periodization_start_list']['options'] != 'undefined')
-                                       {
-                                               var htmlString = "";
-
-                                               var obj = 
data['generic']['periodization_start_list']['options'];
-
-                                               $.each(obj, function(i) {
-                                                       var selected = '';
-                                                       if(obj[i].id == 
voucher[0].periodization_start)
-                                                       {
-                                                               selected = ' 
selected';
-                                                       }
-                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
-                                               });
-
-                                               $("#periodization_start").html( 
htmlString );
-                                       }
-
-                                       
if(data['generic']['process_code_list']['options'] != 'undefined')
-                                       {
-                                               var htmlString = "";
-
-                                               var obj = 
data['generic']['process_code_list']['options'];
-                                               $.each(obj, function(i) {
-                                                       var selected = '';
-                                                       if(obj[i].id == 
voucher[0].process_code)
-                                                       {
-                                                               selected = ' 
selected';
-                                                       }
-                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
-                                               });
-
-                                               $("#process_code").html( 
htmlString );
-                                       }
-
-                                       if(data['generic']['approved_list'] != 
'undefined')
-                                       {
-                                               for ( var i = 0; i < 
data['generic']['approved_list'].length; ++i )
-                                               {
-                                                       var role_sign = 
data['generic']['approved_list'][i].role_sign;
-                                                       var role_initials = 
data['generic']['approved_list'][i].initials;
-
-                                                       if( 
data['generic']['approved_list'][i].date )
-                                                       {
-                                                               var htmlString 
= role_initials + ": " + data['generic']['approved_list'][i].date;
-                                                       }
-                                                       else
-                                                       {
-                                                               var htmlString 
= "<select id=\"_" + role_sign + "\" name=\"values[forward][" + role_sign + 
"]\">";
-                                                               var obj = 
data['generic']['approved_list'][i]['user_list'].options;
-                                                               $.each(obj, 
function(i) {
-                                                                       var 
selected = '';
-                                                                       
if(obj[i].id == role_initials)
-                                                                       {
-                                                                               
selected = ' selected';
-                                                                       }
-                                                                       
htmlString  += "<option value='" + obj[i].id + "'" + selected + ">" + 
obj[i].name + "</option>";
-                                                               });
-
-                                                               htmlString  += 
"</select>";
-                                                       }
-                                                       $("#" + 
role_sign).html( htmlString );
-                                               }
-                                       }
-
-                                       
if(data['generic']['approve_list']['options'] != 'undefined')
-                                       {
-                                               var htmlString = "";
-
-                                               var obj = 
data['generic']['approve_list']['options'];
-
-                                               $.each(obj, function(i) {
-                                                       var selected = '';
-                                                       if(obj[i].selected != 
'undefined' && obj[i].selected == 1)
-                                                       {
-                                                               selected = ' 
selected';
-                                                       }
-                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
-                                               });
-
-                                               $("#approve_as").html( 
htmlString );
-                                       }
-                               }
-                               else
-                               {
-                                       $("#line_text").val( '' );
-                                       $("#voucher_id").val( '' );
-                                       $("#voucher_id_text").html( '' );
-                                       $("#order_id").val( '' );
-                                       $("#project_group").val( '' );
-                                       $("#invoice_id").html( '' );
-                                       $("#kid_nr").html( '' );
-                                       $("#vendor").html('' );
-//                                     $("#janitor").html( '' );
-//                                     $("#supervisor").html( '' );
-//                                     $("#budget_responsible").html( '' );
-                                       $("#close_order_orig").val( '' );
-                                       $("#my_initials").val( '' );
-                                       $("#sign_orig").val( '' );
-                                       $("#invoice_date").html( '' );
-                                       $("#payment_date").html( '' );
-                                       $("#b_account_id").val( '' );
-//                                     $("#amount").html( '' );
-//                                     $("#approved_amount").html( '' );
-                                       $("#currency").html( '' );
-                                       $("#oppsynsmannid").html( '' );
-                                       $("#saksbehandlerid").html( '' );
-                                       $("#budsjettansvarligid").html( '' );
-                                       $("#remark").html( '' );
-                                       $("#process_log").html( '' );
-                                       $("#dim_a").val('' );
-                                       $("#dim_b").html( 
"<option>Velg</option>" );
-                                       $("#period").html( 
"<option>Velg</option>" );
-                                       $("#periodization").html( 
"<option>Velg</option>" );
-                                       $("#periodization_start").html( 
"<option>Velg</option>" );
-                                       $("#process_code").html( 
"<option>Velg</option>" );
-                                       $("#tax_code").html( 
"<option>0</option>" );
-                                       $("#approve_as").html( 
"<option>Velg</option>" );
-                                       $("#order_text").html( 'Bestilling' );
-                                       $("#invoice_id_text").html('FakturaNr');
-                                       
document.getElementById('image_content').src = '';
-                               }
-                       }
-                       });
-    });
-
-
        // When control area is selected, controls are fetched from db and 
control select list is populated
        $("#control_area").change(function () {
                 var control_area_id = $(this).val();
@@ -533,109 +297,7 @@
                
     });
 
-       // When control area is selected, controls are fetched from db and 
control select list is populated
-/*     $("#control_group").change(function () {
-                var control_group_id = $(this).val();
-               var oArgs = 
{menuaction:'controller.uicontrol_group.get_control_area_by_control_group', 
phpgw_return_as:'json'};
-                var requestUrl = phpGWLink('index.php', oArgs, true);
-
-               //var requestUrl = 
"index.php?menuaction=controller.uicontrol_group.get_control_groups_by_control_area&phpgw_return_as=json"
-        
-               var htmlString = "";
-        
-               $.ajax({
-                       type: 'POST',
-                       dataType: 'json',
-                       url: requestUrl + "&control_group_id=" + 
control_group_id,
-                       success: function(data) {
-                               if( data != null){
-                                       htmlString  = "<option>Ingen 
kontrollområde</option>"
-                                       var obj = jQuery.parseJSON(data);
-                                       
-                                       $.each(obj, function(i) {
-                                               htmlString  += "<option 
value='" + obj[i].id + "'>" + obj[i].group_name + "</option>";
-                                       });
-                                                                               
                         
-                                       $("#control_group_id").html( htmlString 
);
-                                       }else {
-                                               htmlString  += "<option>Ingen 
kontrollområder</option>"
-                                               $("#control_group_id").html( 
htmlString );
-                                       }
-                       } 
-                       });
                
-    });
-*/
-
-       // file: add_component_to_control.xsl
-       // When component category is selected, corresponding component types 
are fetched from db and component type select list is populated
-       $("#ifc").change(function () {
-                var ifc_id = $(this).val();
-               
-                var oArgs = 
{menuaction:'controller.uicheck_list_for_component.get_component_types_by_category',
 phpgw_return_as:'json'};
-                var requestUrl = phpGWLink('index.php', oArgs, true);
-               //var requestUrl = 
"index.php?menuaction=controller.uicheck_list_for_component.get_component_types_by_category&phpgw_return_as=json"
-        
-               var htmlString = "";
-        
-               $.ajax({
-                       type: 'POST',
-                       dataType: 'json',
-                       url: requestUrl + "&ifc=" + ifc_id,
-                       success: function(data) {
-                               if( data != null){
-                                       htmlString  = "<option>Velg 
type</option>"
-                                       var obj = jQuery.parseJSON(data);
-                                       
-                                       $.each(obj, function(i) {
-                                               htmlString  += "<option 
value='" + obj[i].id + "'>" + obj[i].name + "</option>";
-                                       });
-                                                                               
                         
-                                       $("#bim_type_id").html( htmlString );
-                                       }else {
-                                               htmlString  += "<option>Ingen 
typer</option>"
-                                               $("#bim_type_id").html( 
htmlString );
-                                       }
-                       } 
-                       });
-               
-    });
-
-       // file: control.xsl
-       // When control area is selected, procedures are fetched from db and 
procedure select list is populated
-       $("#control_area_id").change(function () {
-                var control_area_id = $(this).val();
-               
-                var oArgs = 
{menuaction:'controller.uiprocedure.get_procedures'};
-                var requestUrl = phpGWLink('index.php', oArgs, true);
-               //var requestUrl = 
"index.php?menuaction=controller.uiprocedure.get_procedures&phpgw_return_as=json"
-        
-               var htmlString = "";
-        
-               $.ajax({
-                       type: 'POST',
-                       dataType: 'json',
-                       url: requestUrl + "&control_area_id=" + control_area_id,
-                       success: function(data) {
-                               if( data != null){
-                                       htmlString  = "<option>Velg 
prosedyre</option>"
-                                       var obj = jQuery.parseJSON(data);
-                                       
-                                       $.each(obj, function(i) {
-                                               htmlString  += "<option 
value='" + obj[i].id + "'>" + obj[i].title + "</option>";
-                                       });
-                                                                               
                         
-                                       $("#procedure_id").html( htmlString );
-                                       }
-                                       else
-                                       {
-                                               htmlString  += "<option>Ingen 
prosedyrer</option>"
-                                       $("#procedure_id").html( htmlString );  
                 
-                                       }
-                       } 
-                       });
-    });
-               
        $("#frm_save_control_groups").submit(function(e){
                var thisForm = $(this);
                var num_checked = $(this).find("input:checked").length;
@@ -1066,6 +728,320 @@
 
 });
 
+
+function update_form_values( line_id, voucher_id_orig ){
+               var oArgs = {menuaction:'property.uiinvoice2.get_single_line'};
+               var requestUrl = phpGWLink('index.php', oArgs, true);
+
+               $.ajax({
+                       type: 'POST',
+                       dataType: 'json',
+                       url: requestUrl + "&line_id=" + line_id,
+                       success: function(data) {
+                               var voucher = data['voucher'];
+                               if( voucher != null && voucher.length > 0)
+                               {
+                                       $("#line_id").val( line_id );
+               
+                                       var update_image = false;
+
+                                       if(voucher_id_orig != 
voucher[0].voucher_id)
+                                       {
+                                               update_image = true;
+                                       }
+                                       $("#voucher_id").val( 
voucher[0].voucher_id );
+                                       if( voucher[0].voucher_out_id )
+                                       {
+                                               $("#voucher_id_text").html( 
voucher[0].voucher_out_id );
+                                       }
+                                       else
+                                       {
+                                               $("#voucher_id_text").html( 
voucher[0].voucher_id );
+                                       }
+
+                                       $("#order_id").val( voucher[0].order_id 
);
+
+                                       if(voucher[0].order_id)
+                                       {
+                                               var oArgs_order = 
{menuaction:'property.uiinvoice.view_order', order_id: voucher[0].order_id};
+                                               var requestUrl_order = 
phpGWLink('index.php', oArgs_order);
+                                               var htmlString_order  =  " <a 
target= \"_blank\" href=\"" + requestUrl_order + "\" title=\"" + 
voucher[0].status + "\" > Bestilling</a>";
+                                               $("#order_text").html( 
htmlString_order );
+                                       }
+                                       else
+                                       {
+                                               $("#order_text").html( 
'Bestilling' );
+                                       }
+
+                                       $("#project_group").val( 
voucher[0].project_group );
+
+                                       if(update_image)
+                                       {
+                                               if(voucher[0].external_ref)
+                                               {
+                                                       
$("#invoice_id_text").html(voucher[0].external_ref );
+                                                       
document.getElementById('image_content').src = voucher[0].image_url;
+                                               }
+                                               else
+                                               {
+                                                       
$("#invoice_id_text").html('FakturaNr');
+                                                       
document.getElementById('image_content').src = '';
+                                               }
+                                       }
+
+                                       $("#invoice_id").html( 
voucher[0].invoice_id );
+                                       $("#kid_nr").html( voucher[0].kid_nr );
+                                       $("#vendor").html( voucher[0].vendor );
+//                                     $("#janitor").html( voucher[0].janitor 
);
+//                                     $("#supervisor").html( 
voucher[0].supervisor );
+//                                     $("#budget_responsible").html( 
voucher[0].budget_responsible );
+                                       $("#invoice_date").html( 
voucher[0].invoice_date );
+                                       $("#payment_date").html( 
voucher[0].payment_date );
+                                       $("#b_account_id").val( 
voucher[0].b_account_id );
+                                       $("#dim_a").val( voucher[0].dim_a );
+//                                     $("#amount").html( 
data['generic'].amount );
+//                                     $("#approved_amount").html( 
data['generic'].approved_amount );
+                                       $("#currency").html( 
voucher[0].currency );
+                                       $("#process_log").html( 
data['generic'].process_log );
+                                       $("#my_initials").val( 
data['generic'].my_initials );
+                                       $("#sign_orig").val( 
data['generic'].sign_orig );
+                                       $("#line_text").val( 
voucher[0].line_text );
+
+               //                      $("#oppsynsigndato").html( 
voucher[0].oppsynsigndato );
+               //                      $("#saksigndato").html( 
voucher[0].saksigndato );
+               //                      $("#budsjettsigndato").html( 
voucher[0].budsjettsigndato );
+                                       if(voucher[0].merknad)
+                                       {
+                                               var oArgs_remark = 
{menuaction:'property.uiinvoice.remark', id: voucher[0].id};
+                                               var requestUrl_remark = 
phpGWLink('index.php', oArgs_remark);
+
+                                               var htmlString  =  " <a 
href=\"javascript:openwindow('" +requestUrl_remark + "','550','400')\" > 
Remark</a>";
+
+                                               $("#remark").html( htmlString );
+                                       }
+//---------
+                                       var checked_park_invoice = "";
+                                       var park_invoice_status = "";
+                                       if(voucher[0].parked)
+                                       {
+                                               checked_park_invoice = "checked 
= \"checked\"";
+                                               var park_invoice_status = " X";
+                                       }
+                                       var htmlString_park_invoice = "<input 
type=\"checkbox\" name=\"values[park_invoice]\" value=\"1\" title=\"park 
invoice\"" + checked_park_invoice + "></input>" + park_invoice_status;
+                                       $("#park_order").html( 
htmlString_park_invoice );
+//---------
+                                       var checked_close_order = "";
+                                       var close_order_status = " " + 
voucher[0].status;
+                                       if(voucher[0].closed)
+                                       {
+                                               checked_close_order = "checked 
= \"checked\"";
+                                       }
+                                       var htmlString_close_order = "<input 
type=\"checkbox\" name=\"values[close_order]\" value=\"1\" title=\"close 
order\"" + checked_close_order + "></input>" + close_order_status;
+                                       $("#close_order").html( 
htmlString_close_order );
+                                       $("#close_order_orig").val( 
voucher[0].closed );
+//---------
+
+                                       
if(data['generic']['dimb_list']['options'] != 'undefined')
+                                       {
+                                               var htmlString = "";
+
+                                               var obj = 
data['generic']['dimb_list']['options'];
+
+                                               $.each(obj, function(i) {
+                                                       var selected = '';
+                                                       if(obj[i].id == 
voucher[0].dim_b)
+                                                       {
+                                                               selected = ' 
selected';
+                                                       }
+                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
+                                               });
+
+                                               $("#dim_b").html( htmlString );
+                                       }
+                                       
if(data['generic']['tax_code_list']['options'] != 'undefined')
+                                       {
+                                               var htmlString = "";
+
+                                               htmlString  = 
"<option>Velg</option>"
+
+                                               var obj = 
data['generic']['tax_code_list']['options'];
+
+                                               $.each(obj, function(i) {
+                                                       var selected = '';
+                                                       if(obj[i].id == 
voucher[0].tax_code)
+                                                       {
+                                                               selected = ' 
selected';
+                                                       }
+                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
+                                               });
+
+                                               $("#tax_code").html( htmlString 
);
+                                       }
+
+                                       
if(data['generic']['period_list']['options'] != 'undefined')
+                                       {
+                                               var htmlString = "";
+
+                                               var obj = 
data['generic']['period_list']['options'];
+
+                                               $.each(obj, function(i) {
+                                                       var selected = '';
+                                                       if(obj[i].id == 
voucher[0].period)
+                                                       {
+                                                               selected = ' 
selected';
+                                                       }
+                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
+                                               });
+
+                                               $("#period").html( htmlString );
+                                       }
+                                       
if(data['generic']['periodization_list']['options'] != 'undefined')
+                                       {
+                                               var htmlString = "";
+
+                                               var obj = 
data['generic']['periodization_list']['options'];
+
+                                               $.each(obj, function(i) {
+                                                       var selected = '';
+                                                       if(obj[i].id == 
voucher[0].periodization)
+                                                       {
+                                                               selected = ' 
selected';
+                                                       }
+                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
+                                               });
+
+                                               $("#periodization").html( 
htmlString );
+                                       }
+                                       
if(data['generic']['periodization_start_list']['options'] != 'undefined')
+                                       {
+                                               var htmlString = "";
+
+                                               var obj = 
data['generic']['periodization_start_list']['options'];
+
+                                               $.each(obj, function(i) {
+                                                       var selected = '';
+                                                       if(obj[i].id == 
voucher[0].periodization_start)
+                                                       {
+                                                               selected = ' 
selected';
+                                                       }
+                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
+                                               });
+
+                                               $("#periodization_start").html( 
htmlString );
+                                       }
+
+                                       
if(data['generic']['process_code_list']['options'] != 'undefined')
+                                       {
+                                               var htmlString = "";
+
+                                               var obj = 
data['generic']['process_code_list']['options'];
+                                               $.each(obj, function(i) {
+                                                       var selected = '';
+                                                       if(obj[i].id == 
voucher[0].process_code)
+                                                       {
+                                                               selected = ' 
selected';
+                                                       }
+                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
+                                               });
+
+                                               $("#process_code").html( 
htmlString );
+                                       }
+
+                                       if(data['generic']['approved_list'] != 
'undefined')
+                                       {
+                                               for ( var i = 0; i < 
data['generic']['approved_list'].length; ++i )
+                                               {
+                                                       var role_sign = 
data['generic']['approved_list'][i].role_sign;
+
+                                                       var role_initials = 
data['generic']['approved_list'][i].initials;
+
+                                                       if( 
data['generic']['approved_list'][i].date )
+                                                       {
+                                                               var htmlString 
= role_initials + ": " + data['generic']['approved_list'][i].date;
+                                                       }
+                                                       else
+                                                       {
+                                                               var htmlString 
= "<select id=\"_" + role_sign + "\" name=\"values[forward][" + role_sign + 
"]\">";
+                                                               var obj = 
data['generic']['approved_list'][i]['user_list'].options;
+                                                               $.each(obj, 
function(i) {
+                                                                       var 
selected = '';
+                                                                       
if(obj[i].id == role_initials)
+                                                                       {
+                                                                               
selected = ' selected';
+                                                                       }
+                                                                       
htmlString  += "<option value='" + obj[i].id + "'" + selected + ">" + 
obj[i].name + "</option>";
+                                                               });
+
+                                                               htmlString  += 
"</select>";
+                                                       }
+                                                       $("#" + 
role_sign).html( htmlString );
+                                               }
+                                       }
+
+                                       
if(data['generic']['approve_list']['options'] != 'undefined')
+                                       {
+                                               var htmlString = "";
+
+                                               var obj = 
data['generic']['approve_list']['options'];
+
+                                               $.each(obj, function(i) {
+                                                       var selected = '';
+                                                       if(obj[i].selected != 
'undefined' && obj[i].selected == 1)
+                                                       {
+                                                               selected = ' 
selected';
+                                                       }
+                                                       htmlString  += "<option 
value='" + obj[i].id + "'" + selected + ">" + obj[i].name + "</option>";
+                                               });
+
+                                               $("#approve_as").html( 
htmlString );
+                                       }
+                               }
+                               else
+                               {
+                                       $("#line_text").val( '' );
+                                       $("#voucher_id").val( '' );
+                                       $("#voucher_id_text").html( '' );
+                                       $("#order_id").val( '' );
+                                       $("#project_group").val( '' );
+                                       $("#invoice_id").html( '' );
+                                       $("#kid_nr").html( '' );
+                                       $("#vendor").html('' );
+//                                     $("#janitor").html( '' );
+//                                     $("#supervisor").html( '' );
+//                                     $("#budget_responsible").html( '' );
+                                       $("#close_order_orig").val( '' );
+                                       $("#my_initials").val( '' );
+                                       $("#sign_orig").val( '' );
+                                       $("#invoice_date").html( '' );
+                                       $("#payment_date").html( '' );
+                                       $("#b_account_id").val( '' );
+//                                     $("#amount").html( '' );
+//                                     $("#approved_amount").html( '' );
+                                       $("#currency").html( '' );
+                                       $("#oppsynsmannid").html( '' );
+                                       $("#saksbehandlerid").html( '' );
+                                       $("#budsjettansvarligid").html( '' );
+                                       $("#remark").html( '' );
+                                       $("#process_log").html( '' );
+                                       $("#dim_a").val('' );
+                                       $("#dim_b").html( 
"<option>Velg</option>" );
+                                       $("#period").html( 
"<option>Velg</option>" );
+                                       $("#periodization").html( 
"<option>Velg</option>" );
+                                       $("#periodization_start").html( 
"<option>Velg</option>" );
+                                       $("#process_code").html( 
"<option>Velg</option>" );
+                                       $("#tax_code").html( 
"<option>0</option>" );
+                                       $("#approve_as").html( 
"<option>Velg</option>" );
+                                       $("#order_text").html( 'Bestilling' );
+                                       $("#invoice_id_text").html('FakturaNr');
+                                       
document.getElementById('image_content').src = '';
+                               }
+                       }
+                       });
+
+}
+
+
+
 function clear_form( form ){
        // Clear form
        $(form).find(':input').each(function() {

Modified: trunk/property/js/yahoo/invoice2.index.js
===================================================================
--- trunk/property/js/yahoo/invoice2.index.js   2012-04-19 13:11:28 UTC (rev 
9185)
+++ trunk/property/js/yahoo/invoice2.index.js   2012-04-19 13:34:45 UTC (rev 
9186)
@@ -1,3 +1,23 @@
+var    myPaginator_0, myDataTable_0
+
+this.myParticularRenderEvent = function()
+{
+}
+
+
+YAHOO.util.Event.addListener(window, "load", function()
+{
+       loader = new YAHOO.util.YUILoader();
+       loader.addModule({
+               name: "anyone",
+               type: "js",
+           fullpath: property_js
+           });
+
+       loader.require("anyone");
+    loader.insert();
+});
+
 YAHOO.namespace ("INVOICE");
 
 
@@ -161,4 +181,43 @@
                elCell.innerHTML = "<center>"+oData+"</center>";
        }
 
+       this.execute_async = function(datatable, incoming_url)
+       {
+               if(typeof(incoming_url) != 'undefined')
+               {
+                       base_java_url = incoming_url;
+               }
 
+               ds = phpGWLink('index.php',base_java_url,true);
+               
+               var callback =
+               {
+                       success: function(o)
+                       {
+                               eval("values_ds ="+o.responseText);
+                               if(values_ds=="")
+                               {
+                                       update_datatable(datatable);
+                               }
+                               else
+                               {
+                                       eval("values_ds ="+values_ds);
+                                       update_datatable(datatable);
+                               }
+
+                       },
+                       failure: function(o) {window.alert('Server or your 
connection is dead.')},
+                       timeout: 10000,
+                       cache: false
+               }
+               try
+               {
+                       YAHOO.util.Connect.asyncRequest('POST',ds,callback);
+               }
+               catch(e_async)
+               {
+                  alert(e_async.message);
+               }
+       }
+
+

Modified: trunk/property/templates/base/invoice2.xsl
===================================================================
--- trunk/property/templates/base/invoice2.xsl  2012-04-19 13:11:28 UTC (rev 
9185)
+++ trunk/property/templates/base/invoice2.xsl  2012-04-19 13:34:45 UTC (rev 
9186)
@@ -47,6 +47,34 @@
 </style>
 
 <xsl:call-template name="invoice" />
+
+               <!--  DATATABLE DEFINITIONS-->
+               <script type="text/javascript">
+                       var property_js = <xsl:value-of select="property_js"/>;
+                       var base_java_url = <xsl:value-of 
select="base_java_url"/>;
+                       var datatable = new Array();
+                       var myColumnDefs = new Array();
+                       var myButtons = new Array();
+                       var td_count = <xsl:value-of select="td_count"/>;
+
+                       <xsl:for-each select="datatable">
+                               datatable[<xsl:value-of select="name"/>] = [
+                                       {
+                                               values:<xsl:value-of 
select="values"/>,
+                                               total_records: <xsl:value-of 
select="total_records"/>,
+                                               is_paginator:  <xsl:value-of 
select="is_paginator"/>,
+                                               edit_action:  <xsl:value-of 
select="edit_action"/>,
+                                               footer:<xsl:value-of 
select="footer"/>
+                                       }
+                               ]
+                       </xsl:for-each>
+                       <xsl:for-each select="myColumnDefs">
+                               myColumnDefs[<xsl:value-of select="name"/>] = 
<xsl:value-of select="values"/>
+                       </xsl:for-each>
+                       <xsl:for-each select="myButtons">
+                               myButtons[<xsl:value-of select="name"/>] = 
<xsl:value-of select="values"/>
+                       </xsl:for-each>
+               </script>
        
 </xsl:template>
 
@@ -60,7 +88,7 @@
                </script>
 
        <!-- IMPORTANT!!! Loads YUI javascript -->
-       <xsl:call-template name="common"/>
+<!--   <xsl:call-template name="common"/> -->
 
        <div class="yui-content">
                <div id="invoice-layout">
@@ -101,7 +129,7 @@
                                                        <xsl:apply-templates 
select="filter_form" />
                                                        <xsl:apply-templates 
select="filter_invoice" />
                                                </table>
-                                               <form action="#" 
name="voucher_form" id="voucher_form" method="post">
+                                               <form action="{update_action}" 
name="voucher_form" id="voucher_form" method="post">
                                                <table align = "center" 
width="95%">
                                                                <tr>
                                                                        <td 
colspan = '6'>
@@ -200,7 +228,7 @@
 <xsl:template match="filter_invoice" xmlns:php="http://php.net/xsl";>
        <tr>
                <td colspan='4'>
-                       <form id="invoice_queryForm">
+                       <form id="invoice_queryForm" name="invoice_queryForm">
                                <xsl:attribute name="method">
                                        <xsl:value-of 
select="phpgw:conditional(not(method), 'GET', method)"/>
                                </xsl:attribute>
@@ -213,8 +241,8 @@
                                <select id="voucher_id_filter" 
name="voucher_id_filter">
                                        <xsl:apply-templates 
select="voucher_list/options"/>
                                </select>
+                               <input type="text" name="refresch_voucher_id" 
id="refresch_voucher_id" value=""/>
                        </form>
-               
                        <form id="update_table_dummy" method='POST' action='' 
></form>
                </td>
        </tr>
@@ -227,7 +255,7 @@
                                <xsl:value-of select="php:function('lang', 
'voucher')" />
                        </td>
                        <td>
-                               <input type="hidden" name="voucher_id" 
id="voucher_id" value="{voucher_info/voucher/voucher_id} "/>
+                               <input type="hidden" name="voucher_id" 
id="voucher_id" value="{voucher_info/voucher/voucher_id}"/>
                                <input type="hidden" name="line_id" 
id="line_id" value="{voucher_info/voucher/id}"/>
                                <div id= 'voucher_id_text'>
                                  <xsl:value-of 
select="voucher_info/voucher/voucher_id"/>                      
@@ -553,16 +581,23 @@
 
 
 <xsl:template match="datatable" xmlns:php="http://php.net/xsl";>
+       <div id="paging_0"/>
+       <div id="datatable-container_0"/>
+
        <div id="data_paginator"/>
        <div id="datatable-container"/>
        
        <xsl:call-template name="datasource-definition" />
        <xsl:variable name="label_submit"><xsl:value-of 
select="php:function('lang', 'save')" /></xsl:variable>
-       <div class="row_on"><input type="submit" name="values[save_voucher]" 
id="save_voucher" value="{$label_submit}"/></div>
+       <div class="row_on"><input type="submit" name="values[update_voucher]" 
id="frm_update_voucher" value="{$label_submit}"/></div>
 </xsl:template>
 
+<xsl:template name="datasource-definition" xmlns:php="http://php.net/xsl";>
+</xsl:template>
 
-<xsl:template name="datasource-definition" xmlns:php="http://php.net/xsl";>
+
+
+<xsl:template name="datasource-definition_old" xmlns:php="http://php.net/xsl";>
        <script>
                YAHOO.namespace('portico');
         
@@ -588,7 +623,7 @@
                var main_source = '<xsl:value-of select="source"/>';
                var main_columnDefs = YAHOO.portico.columnDefs;
                var main_form = 'invoice_queryForm';
-               var main_filters = ['voucher_id_filter', 
'responsibility_roles_list'];
+               var main_filters = ['voucher_id_filter', 'refresch_voucher_id'];
                var main_container = 'datatable-container';
                var main_table_id = 'datatable';
                var main_pag = 'data_paginator';
@@ -597,7 +632,6 @@
                setDataSource(main_source, main_columnDefs, main_form, 
main_filters, main_container, main_pag, main_table_id, related_table ); 
                
        </script>
-        
 </xsl:template>
 
 <!-- options for use with select-->




reply via email to

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