fmsystem-commits
[Top][All Lists]
Advanced

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

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


From: Sigurd Nes
Subject: [Fmsystem-commits] [9189] property: invoice handling
Date: Fri, 20 Apr 2012 09:27:09 +0000

Revision: 9189
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=9189
Author:   sigurdne
Date:     2012-04-20 09:27:08 +0000 (Fri, 20 Apr 2012)
Log Message:
-----------
property: invoice handling

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

Modified: trunk/property/inc/class.soinvoice.inc.php
===================================================================
--- trunk/property/inc/class.soinvoice.inc.php  2012-04-19 20:13:58 UTC (rev 
9188)
+++ trunk/property/inc/class.soinvoice.inc.php  2012-04-20 09:27:08 UTC (rev 
9189)
@@ -1624,10 +1624,26 @@
                        return $allow_transfer;
                }
 
-               function check_claim($voucher_id='')
+               function check_claim($voucher_id = 0, $line_id = 0)
                {
+                       $condition = '';
+
+                       if($line_id)
+                       {
+                               $condition = 'WHERE fm_ecobilag.id =' . (int) 
$line_id;
+                       }
+                       else if($voucher_id)
+                       {
+                               $condition = 'WHERE fm_ecobilag.bilagsnr =' . 
(int) $voucher_id;
+                       }
+
+                       if(!$condition)
+                       {
+                               return false;
+                       }
+
                        $sql = "SELECT count(*) as cnt FROM fm_ecobilag 
$this->left_join fm_workorder on fm_ecobilag.pmwrkord_code = fm_workorder.id "
-                               . " WHERE bilagsnr='$voucher_id' AND 
fm_workorder.charge_tenant=1 AND fm_workorder.claim_issued IS NULL";
+                               . " {$condition} AND 
fm_workorder.charge_tenant=1 AND fm_workorder.claim_issued IS NULL";
                        $this->db->query($sql,__LINE__,__FILE__);
                        $this->db->next_record();
                        return $this->db->f('cnt');
@@ -1727,6 +1743,7 @@
                {
                        $condition = '';
 
+                       $global_check = false;
                        if(isset($data['forward']) && 
is_array($data['forward']) && isset($data['line_id']) && $data['line_id'])
                        {
                                $condition = 'WHERE id =' . (int) 
$data['line_id'];
@@ -1734,6 +1751,7 @@
                        else if(isset($data['forward']) && 
is_array($data['forward']) && isset($data['voucher_id']) && $data['voucher_id'])
                        {
                                $condition = 'WHERE bilagsnr =' . (int) 
$data['voucher_id'];
+                               $global_check = true;
                        }
                        
                        $receipt = array();
@@ -1743,38 +1761,45 @@
                                //start check
                                $check_count = 
$this->check_count($data['voucher_id']);
 
-                               if (!($check_count['dima_count'] == 
$check_count['invoice_count']))
+                               if($global_check )
                                {
-                                       $receipt['error'][] = 
array('msg'=>lang('Dima is missing from sub invoice in:'). " 
".$data['voucher_id']);
-                                       $local_error= true;
-                               }
+                                       if (!($check_count['dima_count'] == 
$check_count['invoice_count']))
+                                       {
+                                               phpgwapi_cache::message_set( 
lang('Dima is missing from sub invoice in:'). " ".$data['voucher_id'],'error' );
+                                               $local_error= true;
+                                       }
 
-                               if (!($check_count['spbudact_code_count'] == 
$check_count['invoice_count']))
-                               {
-                                       $receipt['error'][] = 
array('msg'=>lang('Budget code is missing from sub invoice in :'). " 
".$data['voucher_id']);
-                                       $local_error= true;
-                               }
+                                       if 
(!($check_count['spbudact_code_count'] == $check_count['invoice_count']))
+                                       {
+                                               phpgwapi_cache::message_set( 
lang('Budget code is missing from sub invoice in :'). " 
".$data['voucher_id'],'error');
+                                               $local_error= true;
+                                       }
 
-                               if (!($check_count['kostra_count'] == 
$check_count['invoice_count']))
-                               {
-                                       $receipt['error'][] = 
array('msg'=>'Tjenestekode mangler for undebilag: ' . " ".$data['voucher_id']);
-                                       $local_error= true;
+                                       if (!($check_count['kostra_count'] == 
$check_count['invoice_count']))
+                                       {
+                                               phpgwapi_cache::message_set( 
'Tjenestekode mangler for undebilag: ' . " ".$data['voucher_id'],'error');
+                                               $local_error= true;
+                                       }
+
+                                       if 
($this->check_claim($data['voucher_id']))
+                                       {
+                                               phpgwapi_cache::message_set( 
lang('Tenant claim is not issued for project in voucher 
%1',$data['voucher_id']),'error');
+                                               $local_error= true;
+                                       }
                                }
-
-                               if ($this->check_claim($data['voucher_id']))
+                               else
                                {
-                                       $receipt['error'][] = 
array('msg'=>lang('Tenant claim is not issued for project in voucher 
%1',$data['voucher_id']));
-                                       $local_error= true;
+                                       if ($this->check_claim(0, 
$data['line_id']))
+                                       {
+                                               phpgwapi_cache::message_set( 
lang('Tenant claim is not issued for project in voucher 
%1',$data['voucher_id']),'error');
+                                               $local_error= true;
+                                       }
                                }
 
+
                                if($local_error)
                                {
-                                       foreach ($receipt['error'] as $_error)
-                                       {
-                                               
phpgwapi_cache::message_set($_error['msg'], 'error');
-                                       }
-
-                                       return $receipt;
+                                       return false;
                                }
                                // end check
 

Modified: trunk/property/inc/class.uiinvoice2.inc.php
===================================================================
--- trunk/property/inc/class.uiinvoice2.inc.php 2012-04-19 20:13:58 UTC (rev 
9188)
+++ trunk/property/inc/class.uiinvoice2.inc.php 2012-04-20 09:27:08 UTC (rev 
9189)
@@ -56,7 +56,8 @@
                        'get_vouchers'                                          
=> true,
                        'get_single_voucher'                            => true,
                        'get_single_line'                                       
=> true,
-                       'update_voucher'                                        
=> true
+                       'update_voucher'                                        
=> true,
+                       'get_first_line'                                        
=> true
                );
 
                function __construct()
@@ -433,10 +434,27 @@
                        return $vouchers;
                }
 
+               /*not used*/
                public function get_single_voucher($voucher_id = 0)
                {
-                       
+                       $voucher = $this->bo->read_single_voucher($voucher_id); 
        
                }
+
+               /*
+               * Find and select the first line
+               */
+               public function get_first_line()
+               {
+                       $voucher_id =  phpgw::get_var('voucher_id', 'int');
+                       $voucher = $this->bo->read_invoice_sub($voucher_id);
+                       $ret = array('line_id' => 0);
+                       if($voucher)
+                       {
+                               $ret['line_id'] = $voucher[0]['id'];
+                       }
+                       return $ret;
+               }
+
                public function get_single_line($line_id = 0)
                {
                        $line_id        = $line_id ? $line_id : 
phpgw::get_var('line_id', 'int');

Modified: trunk/property/js/portico/ajax_invoice.js
===================================================================
--- trunk/property/js/portico/ajax_invoice.js   2012-04-19 20:13:58 UTC (rev 
9188)
+++ trunk/property/js/portico/ajax_invoice.js   2012-04-20 09:27:08 UTC (rev 
9189)
@@ -192,10 +192,30 @@
                $("#close_order_orig").val( '' );
                $("#park_order").html( '' );
 
-               base_java_url['voucher_id_filter'] = $(this).val();
-               execute_async(myDataTable_0);
+               var voucher_id = $(this).val();
+               var oArgs = {menuaction:'property.uiinvoice2.get_first_line'};
+               var requestUrl = phpGWLink('index.php', oArgs, true);
 
-               document.getElementById('image_content').src = '';
+               var line_id = 0;
+
+               $.ajax({
+                       type: 'POST',
+                       dataType: 'json',
+                       url: requestUrl + "&voucher_id=" + voucher_id,
+                       success: function(data) {
+                               if( data != null)
+                               {
+                                       line_id = data['line_id'];
+                                       base_java_url['line_id'] = line_id;
+                                       base_java_url['voucher_id_filter'] = 
voucher_id;
+                                       execute_async(myDataTable_0);
+                                       update_form_values(line_id, 0);
+                               }
+                       }
+                       });
+
+
+       //      document.getElementById('image_content').src = '';
        });
 
        $("#approve_line").live("click", function(e){

Modified: trunk/property/js/yahoo/invoice2.index.js
===================================================================
--- trunk/property/js/yahoo/invoice2.index.js   2012-04-19 20:13:58 UTC (rev 
9188)
+++ trunk/property/js/yahoo/invoice2.index.js   2012-04-20 09:27:08 UTC (rev 
9189)
@@ -26,9 +26,12 @@
 
                //Create ROW
                newTR = document.createElement('tr');
+               newTR.setAttribute("style","white-space:nowrap;");
 
+
+               td_empty(1);
                td_sum('Sum');
-               td_empty(2);
+               td_empty(1);
                td_sum(tmp_sum1);
                td_sum(tmp_sum2);
                td_empty(7);




reply via email to

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