fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10683] Merge 10675:10682 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [10683] Merge 10675:10682 from trunk
Date: Thu, 17 Jan 2013 20:10:55 +0000

Revision: 10683
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10683
Author:   sigurdne
Date:     2013-01-17 20:10:53 +0000 (Thu, 17 Jan 2013)
Log Message:
-----------
Merge 10675:10682 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/property/inc/class.boinvoice.inc.php
    branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php
    branches/Version-1_0-branch/property/inc/class.soproject.inc.php
    branches/Version-1_0-branch/property/inc/class.sowo_hour.inc.php
    branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
    branches/Version-1_0-branch/property/inc/class.uiinvoice.inc.php
    branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php
    branches/Version-1_0-branch/property/inc/export/default/Basware_X114
    branches/Version-1_0-branch/property/js/yahoo/workorder.edit.js
    branches/Version-1_0-branch/property/templates/base/workorder.xsl

Property Changed:
----------------
    branches/Version-1_0-branch/


Property changes on: branches/Version-1_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352,8354-8368,8370-8396,8398-8430,8432,8434-8440,8442-8445,8447-8453,8455-8456,8458,8460,8462-8464,8466-8473,8475-8479,8481,8483-8501,8503-8523,8525,8527-8531,8533,8535-8536,8538-8550,8552-8554,8556-8557,8559-8579,8581-8587,8589,8591-8592,8594-8595,8597-8601,8603-8610,8612-8613,8615,8617,8619-8645,8647-8650,8652-8661,8663-8666,8668-8669,8671-8683,8685-8691,8693-8730,8732-8737,8739,8741-8767,8769,8771-8772,8774,8776-8797,8799-8812,8814-8819,8821,8823-8833,8835-8837,8839,8841,8843-8849,8852-8858,8860-8867,8869-8870,8872,8874-8877,8879,8881,8883-8888,8890,8892-8901,8903-8911,8913-8917,8920-8923,8925-8933,8935-8938,8940-8943,8945,8947-8948,8950,8952-8953,8955-8962,8964,8966,8968-8970,8972-8975,8977-8983,8985-8993,8995-9001,9003,9005,9007,9009,9011-9019,9021-9023,9025,9027-9028,9030-9044,9046-9047,9049-9050,9052-9056,9058-9059,9061,9063-9064,9066-9068,9071-9092,9094-9112,9114-9117,9119,9121-9160,9162-9166,9169-9207,9209-9211,9213-9215,9217,9219,9221-9253,9255,9257,9259-9260,9262,9264-9269,9271-9273,9275,9277-9278,9280,9282-9283,9285-9289,9291-9299,9301-9310,9312-9313,9315-9320,9322-9324,9326-9338,9340-9342,9344,9346-9348,9350-9358,9360-9362,9364-9366,9368-9374,9376-9382,9384,9386,9388-9390,9392-9396,9398-9402,9404-9410,9412,9414,9416-9417,9419-9425,9427,9429-9430,9432,9434-9463,9465-9502,9504-9506,9508-9521,9523-9526,9528,9530-9537,9539,9541-9551,9553,9555-9556,9558-9578,9580-9581,9583,9585,9587,9589,9591-9624,9626-9655,9657-9700,9702-9726,9728-9729,9731-9749,9751,9753-9754,9756-9832,9834-9836,9838-9839,9841-9846,9848-9850,9852-9858,9860-9863,9865,9867,9869-9871,9873-9893,9895,9897-9912,9914-9919,9921-9928,9930-9952,9954,9956,9958-9963,9965-9993,9995-9997,9999-10001,10003-10004,10006-10007,10009-10012,10014-10031,10033-10073,10075-10107,10109-10165,10167-10210,10222-10226,10228-10311,10313-10378,10380,10382,10384-10393,10395-10478,10480-10482,10484-10494,10496-10503,10505,10507,10509-10521,10523,10525-10528,10530-10540,10542-10543,10545-10568,10570-10584,10586-10590,10592-10594,10596,10598-10599,10601-10611,10613,10615,10617-10626,10628-10636,10638,10640-10654,10656-10658,10660,10662-10672,10674
   + 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352,8354-8368,8370-8396,8398-8430,8432,8434-8440,8442-8445,8447-8453,8455-8456,8458,8460,8462-8464,8466-8473,8475-8479,8481,8483-8501,8503-8523,8525,8527-8531,8533,8535-8536,8538-8550,8552-8554,8556-8557,8559-8579,8581-8587,8589,8591-8592,8594-8595,8597-8601,8603-8610,8612-8613,8615,8617,8619-8645,8647-8650,8652-8661,8663-8666,8668-8669,8671-8683,8685-8691,8693-8730,8732-8737,8739,8741-8767,8769,8771-8772,8774,8776-8797,8799-8812,8814-8819,8821,8823-8833,8835-8837,8839,8841,8843-8849,8852-8858,8860-8867,8869-8870,8872,8874-8877,8879,8881,8883-8888,8890,8892-8901,8903-8911,8913-8917,8920-8923,8925-8933,8935-8938,8940-8943,8945,8947-8948,8950,8952-8953,8955-8962,8964,8966,8968-8970,8972-8975,8977-8983,8985-8993,8995-9001,9003,9005,9007,9009,9011-9019,9021-9023,9025,9027-9028,9030-9044,9046-9047,9049-9050,9052-9056,9058-9059,9061,9063-9064,9066-9068,9071-9092,9094-9112,9114-9117,9119,9121-9160,9162-9166,9169-9207,9209-9211,9213-9215,9217,9219,9221-9253,9255,9257,9259-9260,9262,9264-9269,9271-9273,9275,9277-9278,9280,9282-9283,9285-9289,9291-9299,9301-9310,9312-9313,9315-9320,9322-9324,9326-9338,9340-9342,9344,9346-9348,9350-9358,9360-9362,9364-9366,9368-9374,9376-9382,9384,9386,9388-9390,9392-9396,9398-9402,9404-9410,9412,9414,9416-9417,9419-9425,9427,9429-9430,9432,9434-9463,9465-9502,9504-9506,9508-9521,9523-9526,9528,9530-9537,9539,9541-9551,9553,9555-9556,9558-9578,9580-9581,9583,9585,9587,9589,9591-9624,9626-9655,9657-9700,9702-9726,9728-9729,9731-9749,9751,9753-9754,9756-9832,9834-9836,9838-9839,9841-9846,9848-9850,9852-9858,9860-9863,9865,9867,9869-9871,9873-9893,9895,9897-9912,9914-9919,9921-9928,9930-9952,9954,9956,9958-9963,9965-9993,9995-9997,9999-10001,10003-10004,10006-10007,10009-10012,10014-10031,10033-10073,10075-10107,10109-10165,10167-10210,10222-10226,10228-10311,10313-10378,10380,10382,10384-10393,10395-10478,10480-10482,10484-10494,10496-10503,10505,10507,10509-10521,10523,10525-10528,10530-10540,10542-10543,10545-10568,10570-10584,10586-10590,10592-10594,10596,10598-10599,10601-10611,10613,10615,10617-10626,10628-10636,10638,10640-10654,10656-10658,10660,10662-10672,10674,10676-10682

Modified: branches/Version-1_0-branch/property/inc/class.boinvoice.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.boinvoice.inc.php    
2013-01-17 15:51:39 UTC (rev 10682)
+++ branches/Version-1_0-branch/property/inc/class.boinvoice.inc.php    
2013-01-17 20:10:53 UTC (rev 10683)
@@ -183,7 +183,7 @@
                        return $invoice;
                }
 
-               function read_invoice_sub($voucher_id='',$paid='')
+               function read_invoice_sub($voucher_id=0,$paid = false)
                {
                        $invoice = $this->so->read_invoice_sub(array('start' => 
$this->start,'query' => $this->query,'sort' => $this->sort,'order' => 
$this->order,
                                'user_lid' => $this->user_lid,'cat_id' => 
$this->cat_id,'voucher_id'=>$voucher_id,'paid' => $paid, 'results' => 
$this->results,'allrows'=>$this->allrows));
@@ -298,7 +298,7 @@
                        return $period_list;
                }
 
-               function tax_code_list($selected='')
+               function tax_code_list($selected='', $tax_codes = array())
                {
                        if(!$selected && $selected !== '0' )
                        {
@@ -308,7 +308,11 @@
                        {
                                $selected = (int)$selected;
                        }
-                       $tax_codes = $this->so->tax_code_list();
+
+                       if(! $tax_codes)
+                       {
+                               $tax_codes = $this->so->tax_code_list();
+                       }
                        
                        foreach ($tax_codes as &$tax_code)
                        {

Modified: branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php    
2013-01-17 15:51:39 UTC (rev 10682)
+++ branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php    
2013-01-17 20:10:53 UTC (rev 10683)
@@ -424,8 +424,10 @@
                        }
 
                        $sql = "SELECT 
$table.*,fm_workorder.status,fm_workorder.charge_tenant,org_name,"
-                               . "fm_workorder.claim_issued FROM $table"
+                               . 
"fm_workorder.claim_issued,fm_workorder_status.closed,periodization_id,project_type_id"
+                               . " FROM {$table}"
                                . " {$this->left_join} fm_workorder ON 
fm_workorder.id = $table.pmwrkord_code"
+                               . " {$this->left_join} fm_workorder_status ON 
fm_workorder.status = fm_workorder_status.id"
                                . " {$this->left_join} fm_project ON 
fm_workorder.project_id = fm_project.id"
                                . " {$this->join} fm_vendor ON 
$table.spvend_code = fm_vendor.id $filtermethod";
 
@@ -445,7 +447,6 @@
 
                        $i = 0;
 
-                       $closed = 
isset($this->config->config_data['workorder_closed_status']) && 
$this->config->config_data['workorder_closed_status'] ? 
$this->config->config_data['workorder_closed_status'] : 'closed';
                        $invoice = array();
                        while ($this->db->next_record())
                        {
@@ -471,7 +472,9 @@
                                                'workorder_id'                  
=> $this->db->f('pmwrkord_code'),
                                                'order_id'                      
        => $this->db->f('pmwrkord_code'),
                                                'status'                        
        => $this->db->f('status'),
-                                               'closed'                        
        => $this->db->f('status') == $closed,
+                                               'closed'                        
        => !!$this->db->f('closed'),
+                                               'project_type_id'               
=> $this->db->f('project_type_id'),
+                                               'periodization_id'              
=> $this->db->f('periodization_id'),
                                                'voucher_id'                    
=> $this->db->f('bilagsnr'),
                                                'voucher_out_id'                
=> $this->db->f('bilagsnr_ut'),
                                                'id'                            
        => $this->db->f('id'),
@@ -560,10 +563,10 @@
                        }
 
                        $groupmethod = "GROUP BY 
pmwrkord_code,bilagsnr,bilagsnr_ut,fakturanr,"
-                               . " currency,budsjettansvarligid,org_name";
+                               . " 
currency,budsjettansvarligid,org_name,periode";
                        
                        $sql = "SELECT DISTINCT 
pmwrkord_code,bilagsnr,bilagsnr_ut,fakturanr,sum(belop) as belop, 
sum(godkjentbelop) as godkjentbelop,"
-                               . " currency,budsjettansvarligid,org_name"
+                               . " 
currency,budsjettansvarligid,org_name,periode"
                                . " FROM $table"
                                . " {$this->join} fm_ecoart ON fm_ecoart.id = 
$table.artid"
                                . " {$this->join} fm_workorder ON 
fm_workorder.id = $table.pmwrkord_code"
@@ -586,6 +589,7 @@
                                        'approved_amount'               => 
$this->db->f('godkjentbelop'),
                                        'vendor'                                
=> $this->db->f('org_name'),
                                        'currency'                              
=> $this->db->f('currency'),
+                                       'period'                                
=> $this->db->f('periode'),
                                        'budget_responsible'    => 
$this->db->f('budsjettansvarligid')
                                );
                        }

Modified: branches/Version-1_0-branch/property/inc/class.soproject.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soproject.inc.php    
2013-01-17 15:51:39 UTC (rev 10682)
+++ branches/Version-1_0-branch/property/inc/class.soproject.inc.php    
2013-01-17 20:10:53 UTC (rev 10683)
@@ -47,6 +47,7 @@
                        $this->custom           = 
createObject('property.custom_fields');
 
                        $this->db           = & $GLOBALS['phpgw']->db;
+                       $this->db2           = clone ($this->db);
                        $this->join                     = & $this->db->join;
                        $this->left_join        = & $this->db->left_join;
                        $this->like                     = & $this->db->like;
@@ -689,10 +690,11 @@
                                        $project['actual_cost']         = 0;
                                        $project['billable_hours']      = 0;
 
+
                                        $sql_workder_date_filter = '';
                                        if ($start_date)
                                        {
-                                               $sql_workder_date_filter = "AND 
fm_workorder.start_date >= $start_date AND fm_workorder.start_date <= $end_date 
";
+                                               $sql_workder_date_filter = "AND 
fm_workorder.start_date >= {$start_date} AND fm_workorder.start_date <= 
{$end_date} ";
                                        }
 
 /*
@@ -705,24 +707,31 @@
 
 */
 
+                                       $get_spesific = false; 
                                        if ($filter_year && $filter_year != 
'all')
                                        {
+                                               $this->db->query("SELECT 
sum(fm_project_budget.budget) AS budget"
+                                                        . " FROM 
fm_project_budget WHERE project_id ='{$project['project_id']}' AND year = 
'{$filter_year}'",__LINE__,__FILE__);
+                                               $this->db->next_record();
+                                               $project['budget'] =  
$this->db->f('budget');
+
+                                               $get_spesific = true; 
                                                $_year_arr = array();
                                                for ($i=1;$i<14;$i++)
                                                {
                                                        $_year_arr[] = 
sprintf("%04s%02s", $filter_year, $i);
                                                }
 
-                                               $sql_filter_period = 'AND 
periode IN (' . implode(',', $_year_arr) . ')';
+                                               $sql_filter_period = 'AND 
(periode IN (' . implode(',', $_year_arr) . ') OR periode IS NULL)';
 
-                                               $sql_workder  = "SELECT 
fm_workorder.id, sum(fm_workorder_budget.budget) AS budget, 
sum(fm_workorder_budget.combined_cost) AS combined_cost,"
+                                               $sql_workder  = "SELECT 
fm_workorder.id,"// sum(fm_workorder_budget.budget) AS budget, 
sum(fm_workorder_budget.combined_cost) AS combined_cost,"
                                                . " billable_hours, closed, 
sum(fm_orders_paid_or_pending_view.amount) AS actual_cost"
                                                . " FROM fm_workorder"
                                                . " {$this->join} 
fm_workorder_status ON fm_workorder.status  = fm_workorder_status.id"
                                        //      . " {$this->join} 
fm_workorder_budget ON (fm_workorder.id = fm_workorder_budget.order_id AND year 
= '{$filter_year}')"
-                                               . " {$this->join} 
fm_workorder_budget ON (fm_workorder.id = fm_workorder_budget.order_id )"
-//                                             . " {$this->left_join} 
fm_orders_paid_or_pending_view ON (fm_workorder.id = 
fm_orders_paid_or_pending_view.order_id {$sql_filter_period})"
-                                               . " {$this->left_join} 
fm_orders_paid_or_pending_view ON (fm_workorder.id = 
fm_orders_paid_or_pending_view.order_id AND( periode < {$filter_year}13 OR 
periode IS NULL))"
+//                                             . " {$this->join} 
fm_workorder_budget ON (fm_workorder.id = fm_workorder_budget.order_id )"
+                                               . " {$this->left_join} 
fm_orders_paid_or_pending_view ON (fm_workorder.id = 
fm_orders_paid_or_pending_view.order_id {$sql_filter_period})"
+//                                             . " {$this->left_join} 
fm_orders_paid_or_pending_view ON (fm_workorder.id = 
fm_orders_paid_or_pending_view.order_id AND( periode < {$filter_year}13 OR 
periode IS NULL))"
                                                . " WHERE project_id = 
'{$project['project_id']}' {$sql_workder_date_filter} OR (project_id = 
'{$project['project_id']}' AND fm_workorder_status.closed IS NULL)"
                                                . " GROUP BY fm_workorder.id, 
billable_hours, closed";
 //_debug_array($sql_workder);
@@ -730,11 +739,16 @@
                                        }
                                        else
                                        {
+                                               $this->db->query("SELECT 
sum(fm_project_budget.budget) AS budget"
+                                                . " FROM fm_project_budget 
WHERE active =1 AND project_id ='{$project['project_id']}'",__LINE__,__FILE__);
+                                               $this->db->next_record();
+                                               $project['budget'] =  
$this->db->f('budget');
+
                                                $sql_workder  = "SELECT 
fm_workorder.id, sum(fm_workorder_budget.budget) AS budget, 
sum(fm_workorder_budget.combined_cost) AS combined_cost,"
                                                . " billable_hours, closed, 
actual_cost, pending_cost"
                                                . " FROM fm_workorder"
                                                . " {$this->join} 
fm_workorder_status ON fm_workorder.status  = fm_workorder_status.id"
-                                               . " {$this->join} 
fm_workorder_budget ON (fm_workorder.id = fm_workorder_budget.order_id)"
+                                               . " {$this->left_join} 
fm_workorder_budget ON (fm_workorder.id = fm_workorder_budget.order_id AND 
active = 1)"
                                                . " {$this->left_join} 
fm_orders_pending_cost_view ON fm_workorder.id = 
fm_orders_pending_cost_view.order_id"
                                                . " WHERE project_id = 
'{$project['project_id']}' {$sql_workder_date_filter}"
                                                . " GROUP BY fm_workorder.id, 
billable_hours, closed, actual_cost, pending_cost";
@@ -749,7 +763,23 @@
 
                                        while ($this->db->next_record())
                                        {
-                                               $_combined_cost = 
$this->db->f('combined_cost');
+                                               if(true)
+                                               {
+                                                       
$this->db2->query("SELECT sum(fm_workorder_budget.budget) AS budget,"
+                                                        . " 
sum(fm_workorder_budget.combined_cost) AS combined_cost"
+//                                                      . " FROM 
fm_workorder_budget WHERE year = {$filter_year} AND order_id =" . 
$this->db->f('id'),__LINE__,__FILE__);
+                                                        . " FROM 
fm_workorder_budget WHERE active =1 AND order_id =" . 
$this->db->f('id'),__LINE__,__FILE__);
+                                                        
$this->db2->next_record();
+
+                                                       $_combined_cost = 
$this->db2->f('combined_cost');
+                                                       $_budget = 
$this->db2->f('budget');
+                                               }
+                                               else
+                                               {
+                                                       $_combined_cost = 
$this->db->f('combined_cost');
+                                                       $_budget = 
$this->db->f('budget');
+                                               }
+
                                                $_actual_cost =  
$this->db->f('actual_cost') + (float)$this->db->f('pending_cost');
                                                if(!$this->db->f('closed'))
                                                {
@@ -766,7 +796,10 @@
                                                        {
                                                                $_obligation = 
$_combined_cost - $_actual_cost;
                                                        }
-                                                       
if((int)$this->db->f('budget') >= 0)
+
+//                                                     $_obligation = 
$_combined_cost - $_actual_cost;
+
+                                                       if((int)$_budget >= 0)
                                                        {
                                                                if($_obligation 
< 0)
                                                                {
@@ -920,7 +953,7 @@
                {
                        $project_id = (int) $project_id;
                        $values = array();
-                       $this->db->query("SELECT 
fm_workorder.title,combined_cost, fm_workorder.actual_cost, 
fm_workorder.budget, fm_workorder.id as workorder_id,fm_workorder.contract_sum,"
+                       $this->db->query("SELECT fm_workorder.title, 
fm_workorder.actual_cost, fm_workorder.id as 
workorder_id,fm_workorder.contract_sum,"
                                . " fm_workorder.vendor_id, 
fm_workorder.calculation,fm_workorder.rig_addition,fm_workorder.addition,fm_workorder.deviation,fm_workorder.charge_tenant,"
                                . " fm_workorder_status.descr as status, 
fm_workorder_status.closed, fm_workorder.account_id as b_account_id"
                                . " FROM fm_workorder {$this->join} 
fm_workorder_status ON fm_workorder.status = fm_workorder_status.id"
@@ -933,10 +966,8 @@
                                $values[] = array(
                                        'workorder_id'          => 
$this->db->f('workorder_id'),
                                        'title'                         => 
$this->db->f('title',true),
-                                       'budget'                        => 
(int)$this->db->f('budget'),
                                        'deviation'                     => 
$this->db->f('deviation'),
                                        'calculation'           => 
$this->db->f('calculation'),
-                                       'combined_cost'         => 
(int)$this->db->f('combined_cost'),
                                        'actual_cost'           => 0,
                                        'obligation'            => 0,
                                        'vendor_id'                     => 
$this->db->f('vendor_id'),
@@ -950,7 +981,6 @@
                                $_orders[] = $this->db->f('workorder_id');
                        }
 
-
                        if($_orders)
                        {
                                $_actual_cost_arr = array();
@@ -967,6 +997,15 @@
 
                        foreach ($values as &$entry)
                        {
+                               $this->db2->query("SELECT 
sum(fm_workorder_budget.budget) AS budget,"
+                                . " sum(fm_workorder_budget.combined_cost) AS 
combined_cost"
+                                . " FROM fm_workorder_budget WHERE active =1 
AND order_id ='{$entry['workorder_id']}'",__LINE__,__FILE__);
+                                $this->db2->next_record();
+
+                               $entry['combined_cost'] = 
$this->db2->f('combined_cost');
+                               $entry['budget'] = $this->db2->f('budget');
+
+
                                $_combined_cost = 
round($entry['combined_cost']);
 
                                $_actual_cost = 
isset($_actual_cost_arr[$entry['workorder_id']]) && 
$_actual_cost_arr[$entry['workorder_id']] ? 
$_actual_cost_arr[$entry['workorder_id']] : 0;
@@ -2068,11 +2107,12 @@
 
                        $project_total_budget = array_sum($project_budget);
 
-                       $sql = "SELECT fm_workorder.id AS order_id, 
fm_workorder_budget.combined_cost, fm_workorder_budget.budget, 
fm_workorder_budget.year, fm_workorder_budget.month, fm_workorder_status.closed"
+                       $sql = "SELECT fm_workorder.id AS order_id, 
sum(fm_workorder_budget.combined_cost) AS combined_cost, 
sum(fm_workorder_budget.budget) AS budget, fm_workorder_budget.year, 
fm_workorder_budget.month, fm_workorder_status.closed"
                                . " FROM fm_workorder"
                                . " {$this->join} fm_workorder_status ON 
fm_workorder.status = fm_workorder_status.id"
                                . " {$this->join} fm_workorder_budget ON 
fm_workorder.id = fm_workorder_budget.order_id"
-                               . " WHERE project_id = {$project_id}";
+                               . " WHERE fm_workorder_budget.active = 1 AND 
project_id = {$project_id}"
+                               . " GROUP BY fm_workorder.id, 
fm_workorder_budget.year, fm_workorder_budget.month, 
fm_workorder_status.closed";
 //     _debug_array($sql);die();
                        $this->db->query($sql,__LINE__,__FILE__);
 

Modified: branches/Version-1_0-branch/property/inc/class.sowo_hour.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.sowo_hour.inc.php    
2013-01-17 15:51:39 UTC (rev 10682)
+++ branches/Version-1_0-branch/property/inc/class.sowo_hour.inc.php    
2013-01-17 20:10:53 UTC (rev 10683)
@@ -741,16 +741,32 @@
                        }
 
                        $this->db->transaction_begin();
-                       $this->db->query("UPDATE fm_workorder SET calculation = 
'$calculation' WHERE id=$id",__LINE__,__FILE__);
+                       $this->db->query("UPDATE fm_workorder SET calculation = 
'{$calculation}' WHERE id = '{$id}'",__LINE__,__FILE__);
 
                        if($calculation > 0)
                        {
-                               $config         = 
CreateObject('phpgwapi.config','property');
+                               $soworkorder    = 
CreateObject('property.soworkorder');
+                               $config                 = 
CreateObject('phpgwapi.config','property');
                                $config->read();
                                $tax = 1+(($config->config_data['fm_tax'])/100);
                                $calculation = $calculation * $tax;
 
-                               $this->db->query("UPDATE fm_workorder SET 
combined_cost = '$calculation' WHERE id=$id",__LINE__,__FILE__);
+                               $this->db->query("UPDATE fm_workorder SET 
combined_cost = '{$calculation}' WHERE id = '{$id}'",__LINE__,__FILE__);
+
+                               $this->db->query("SELECT sum(budget) AS budget, 
sum(contract_sum) as contract_sum FROM fm_workorder_budget WHERE order_id = 
'{$id}'",__LINE__,__FILE__);
+                               $this->db->next_record();
+                               $budget                 = 
$this->db->f('budget');
+                               $contract_sum   = $this->db->f('contract_sum');
+                               
+                               $this->db->query("SELECT periodization_id"
+                               . " FROM fm_workorder {$this->join} fm_project 
ON (fm_workorder.project_id = fm_project.id)"
+                               . " WHERE fm_workorder.id = 
'{$id}'",__LINE__,__FILE__);
+
+                               $this->db->next_record();
+
+                               $periodization_id       = 
$this->db->f('periodization_id');
+
+                               $soworkorder->_update_order_budget($id, 
date('Y'), $periodization_id, $budget    , $contract_sum, $calculation);
                        }
 
                        $this->db->transaction_commit();

Modified: branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php  
2013-01-17 15:51:39 UTC (rev 10682)
+++ branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php  
2013-01-17 20:10:53 UTC (rev 10683)
@@ -1380,6 +1380,18 @@
                        $value_set_invoice      = 
$this->db->validate_update($value_set_invoice);
                        $this->db->query("UPDATE fm_ecobilag SET 
{$value_set_invoice} WHERE pmwrkord_code = '{$workorder['id']}'" 
,__LINE__,__FILE__);
 
+                       $_active_period = array
+                       (
+                               'active_b_period' => 
isset($workorder['active_b_period']) && $workorder['active_b_period'] ? 
$workorder['active_b_period'] : array(),
+                               'active_orig_b_period' => 
isset($workorder['active_orig_b_period']) && $workorder['active_orig_b_period'] 
? $workorder['active_orig_b_period'] : array()
+                       );
+
+                       $this->activate_period_from_budget($workorder['id'], 
$_active_period);
+
+                       unset($_close_period);
+                       unset($_active_period);
+
+
                        if($workorder['delete_b_period'])
                        {
                                $this->db->query("SELECT sum(budget) AS budget 
FROM fm_workorder_budget WHERE order_id = 
'{$workorder['id']}'",__LINE__,__FILE__);
@@ -1679,7 +1691,7 @@
                        $active_period = array();
                        $_dummy_period = '';
 
-                       $sql = "SELECT fm_workorder_budget.budget, 
fm_workorder_budget.combined_cost, year, month, closed"
+                       $sql = "SELECT fm_workorder_budget.budget, 
fm_workorder_budget.combined_cost, year, month, active, closed"
                        . " FROM fm_workorder {$this->join} fm_workorder_status 
ON fm_workorder.status = fm_workorder_status.id"
                        . " {$this->join} fm_workorder_budget ON 
fm_workorder.id = fm_workorder_budget.order_id WHERE order_id = '{$order_id}'"
                        . " ORDER BY year, month";
@@ -1706,7 +1718,7 @@
                                );
 
                                $closed_period[$period] = false;
-                               $active_period[$period] = true;
+                               $active_period[$period] = 
$this->db->f('active');
                        }
 
 //                     if ( $order_budget )
@@ -1875,7 +1887,49 @@
                        }
                }
 
+               /**
+               * Set active status on budget periods
+               *
+               * @return void
+               */
 
+               function activate_period_from_budget($order_id, $data)
+               {
+                       $close_period = array();
+                       $open_period = array();
+//_debug_array($data);die();
+                       foreach($data['active_orig_b_period'] as $period)
+                       {
+                               if(!in_array($period, $data['active_b_period']))
+                               {
+                                       $inactive_period[] = $period;
+                               }
+                       }
+
+                       foreach($data['active_b_period'] as $period)
+                       {
+                               if(!in_array($period, 
$data['active_orig_b_period']))
+                               {
+                                       $active_period[] = $period;
+                               }
+                       }
+
+                       foreach ($active_period as $period)
+                       {
+                               $when = explode('_', $period);
+                               $sql = "UPDATE fm_workorder_budget SET active = 
1 WHERE order_id = {$order_id} AND year =" . (int) $when[0] . ' AND month = ' . 
(int) $when[1];
+                               $this->db->query($sql,__LINE__,__FILE__);
+                       }
+
+                       foreach ($inactive_period as $period)
+                       {
+                               $when = explode('_', $period);
+                               $sql = "UPDATE fm_workorder_budget SET active = 
0 WHERE order_id = {$order_id} AND year =" . (int) $when[0] . ' AND month = ' . 
(int) $when[1];
+                               $this->db->query($sql,__LINE__,__FILE__);
+                       }
+               }
+
+
                /**
                * Recalculate actual cost from payment history for all 
workorders
                *
@@ -2088,9 +2142,8 @@
                        }
                }
 
-               private function _update_order_budget($order_id, $year, 
$periodization_id, $budget, $contract_sum, $combined_cost = 0)
+               public function _update_order_budget($order_id, $year, 
$periodization_id, $budget, $contract_sum, $combined_cost = 0)
                {
-                       $order_id = $order_id;//might be bigint
                        $year = $year ? (int) $year : date('Y');
 
                        $periodization_id = (int) $periodization_id;

Modified: branches/Version-1_0-branch/property/inc/class.uiinvoice.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiinvoice.inc.php    
2013-01-17 15:51:39 UTC (rev 10682)
+++ branches/Version-1_0-branch/property/inc/class.uiinvoice.inc.php    
2013-01-17 20:10:53 UTC (rev 10683)
@@ -1755,6 +1755,7 @@
                                }
                        }
 
+                       $content = array();
                        if ($voucher_id)
                        {
                                $this->bo->allrows = true;
@@ -1762,22 +1763,29 @@
                        }
 
                        $sum=0;
-                       $i      =0;
-                       if(is_array($content))
+
+                       $dimb_list                      = 
$this->bo->select_dimb_list();
+                       $tax_code_list          = $this->bo->tax_code_list();
+                       $_link_order            = 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiinvoice.view_order'));
+                       $_link_claim            = 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uitenant_claim.check'));
+                       
+                       foreach ($content as &$entry)
                        {
-                               while(each($content))
-                               {
-                                       $sum                                    
                                = $sum + $content[$i]['amount'];
-                                       $content[$i]['amount']                  
                = number_format($content[$i]['amount'], 2, ',', '');
-                                       $content[$i]['paid']                    
                = $paid;
-                                       $content[$i]['dimb_list']               
                = $this->bo->select_dimb_list($content[$i]['dimb']);
-                                       $content[$i]['tax_code_list']           
        = $this->bo->tax_code_list($content[$i]['tax_code']);
-                                       $content[$i]['link_order']              
                = $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiinvoice.view_order'));
-                                       $content[$i]['link_claim']              
                = $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uitenant_claim.check'));
-                                       $i++;
-                               }
+                               $sum                                            
+= $entry['amount'];
+                               $entry['amount']                        = 
number_format($entry['amount'], 2, ',', '');
+                               $entry['paid']                          = $paid;
+                               $entry['dimb_list']                     = 
$this->bocommon->select_list($entry['dimb'], $dimb_list);
+                               $entry['tax_code_list']         = 
$this->bo->tax_code_list($entry['tax_code'], $tax_code_list);
+                               $entry['link_order']            = $_link_order;
+                               $entry['link_claim']            = $_link_claim;
                        }
 
+                       unset($entry);
+                       unset($_link_order);
+                       unset($_link_claim);
+                       unset($dimb_list);
+                       unset($tax_code_list);
+
                        $uicols = array (
                                array(
                                        'col_name'=>'workorder'         
,'label'=>lang('Workorder'),    'className'=>'centerClasss', 'sortable'=>true,  
'sort_field'=>'pmwrkord_code',  'visible'=>true),
@@ -1826,244 +1834,245 @@
 
                        $j=0;
                        //---- llena DATATABLE-ROWS con los valores del READ
-                       if (isset($content) && is_array($content))
+                       $workorders = array();
+                       foreach($content as $invoices)
                        {
-                               $workorders = array();
-                               foreach($content as $invoices)
+                               for ($i=0;$i<count($uicols);$i++)
                                {
-                                       for ($i=0;$i<count($uicols);$i++)
+                                       $json_row[$uicols[$i]['col_name']] = "";
+
+                                       if($i == 0)
                                        {
-                                               
$json_row[$uicols[$i]['col_name']] = "";
-
-                                               if($i == 0)
+                                               
$json_row[$uicols[$i]['col_name']] .= " <input name='values[counter][".$j."]' 
id='values[counter][".$j."]'  class='myValuesForPHP'  type='hidden' 
value='".$invoices['counter']."'/>";
+                                               
$json_row[$uicols[$i]['col_name']] .= " <input name='values[id][".$j."]' 
id='values[id][".$j."]'  class='myValuesForPHP'  type='hidden' 
value='".$invoices['id']."'/>";
+                                               
$json_row[$uicols[$i]['col_name']] .= " <input 
name='values[workorder_id][".$j."]' id='values[workorder_id][".$j."]'  
class='myValuesForPHP'  type='hidden' value='".$invoices['workorder_id']."'/>";
+                                               
$json_row[$uicols[$i]['col_name']] .= " <a target='_blank' 
href='".$invoices['link_order'].'&order_id='.$invoices['workorder_id']."'>".$invoices['workorder_id']."</a>";
+                                       }
+                                       else if(($i == 1))
+                                       {
+                                               
$json_row[$uicols[$i]['col_name']]  .= $invoices['project_group'];
+                                       }
+                                       else if(($i == 2))
+                                       {
+                                               
if(!isset($invoices['workorder_id']) || !$invoices['workorder_id'])
                                                {
-                                                       
$json_row[$uicols[$i]['col_name']] .= " <input name='values[counter][".$j."]' 
id='values[counter][".$j."]'  class='myValuesForPHP'  type='hidden' 
value='".$invoices['counter']."'/>";
-                                                       
$json_row[$uicols[$i]['col_name']] .= " <input name='values[id][".$j."]' 
id='values[id][".$j."]'  class='myValuesForPHP'  type='hidden' 
value='".$invoices['id']."'/>";
-                                                       
$json_row[$uicols[$i]['col_name']] .= " <input 
name='values[workorder_id][".$j."]' id='values[workorder_id][".$j."]'  
class='myValuesForPHP'  type='hidden' value='".$invoices['workorder_id']."'/>";
-                                                       
$json_row[$uicols[$i]['col_name']] .= " <a target='_blank' 
href='".$invoices['link_order'].'&order_id='.$invoices['workorder_id']."'>".$invoices['workorder_id']."</a>";
+                                                       //nothing
                                                }
-                                               else if(($i == 1))
+                                               else if(!$invoices['paid'] && 
!array_key_exists($invoices['workorder_id'], $workorders))
                                                {
-                                                       
$json_row[$uicols[$i]['col_name']]  .= $invoices['project_group'];
-                                               }
-                                               else if(($i == 2))
-                                               {
-                                                       
if($invoices['workorder_id'] == "")
+                                                       $_checked = '';
+                                                       
if($invoices['closed']== 1)
                                                        {
-                                                               //nothing
+                                                               $_checked = 
'checked="checked"';
                                                        }
-                                                       else 
if($invoices['paid']== ""  && !array_key_exists($invoices['workorder_id'], 
$workorders))
+                                                       else 
if($invoices['project_type_id']== 1 && !$invoices['periodization_id']) // 
operation projekts
                                                        {
-                                                               
$json_row[$uicols[$i]['col_name']]  .= " <input 
name='values[close_order_orig][".$j."]' id='values[close_order_orig][".$j."]'  
class='myValuesForPHP '  type='hidden' value='".$invoices['closed']."'/>";
-                                                               
if($invoices['closed']== 1)
-                                                               {
-                                                                       
$json_row[$uicols[$i]['col_name']]  .= " <input 
name='values[close_order_tmp][".$j."]' id='values[close_order_tmp][".$j."]'  
class='close_order_tmp transfer_idClass'  type='checkbox' value='true' 
checked='checked' />";
-                                                               }
-                                                               else
-                                                               {
-                                                                       
$json_row[$uicols[$i]['col_name']]  .= " <input 
name='values[close_order_tmp][".$j."]' id='values[close_order_tmp][".$j."]'  
class='close_order_tmp transfer_idClass'  type='checkbox' value='true'/>";
-                                                               }
-                                                               
$json_row[$uicols[$i]['col_name']]  .= " <input 
name='values[close_order][".$j."]' id='values[close_order][".$j."]'  
class='myValuesForPHP close_order'  type='hidden' value=''/>";
+                                                               $_checked = 
'checked="checked"';
                                                        }
-                                                       else
+
+                                                       
$json_row[$uicols[$i]['col_name']]  .= " <input 
name='values[close_order_orig][{$j}]' id='values[close_order_orig][{$j}]' 
class='myValuesForPHP ' type='hidden' value='{$invoices['closed']}'/>";
+                                                       
$json_row[$uicols[$i]['col_name']]  .= " <input 
name='values[close_order_tmp][{$j}]' id='values[close_order_tmp][{$j}]' 
class='close_order_tmp transfer_idClass' type='checkbox' value='true' 
{$_checked}/>";
+                                                       
$json_row[$uicols[$i]['col_name']]  .= " <input 
name='values[close_order][{$j}]' id='values[close_order][{$j}]' 
class='myValuesForPHP close_order' type='hidden' value=''/>";
+                                               }
+                                               else
+                                               {
+                                                       
if($invoices['closed']== 1)
                                                        {
-                                                               
if($invoices['closed']== 1)
-                                                               {
-                                                                       
$json_row[$uicols[$i]['col_name']]  .= "<b>x</b>";
-                                                               }
+                                                               
$json_row[$uicols[$i]['col_name']]  .= "<b>x</b>";
                                                        }
                                                }
-                                               else if(($i == 3))
+                                       }
+                                       else if(($i == 3))
+                                       {
+                                               if($invoices['charge_tenant'] 
== 1)
                                                {
-                                                       
if($invoices['charge_tenant'] == 1)
+                                                       
if($invoices['claim_issued'] == '')
                                                        {
-                                                               
if($invoices['claim_issued'] == '')
-                                                               {
-                                                                       
$_workorder = execMethod('property.soworkorder.read_single', 
$invoices['workorder_id']);
-                                                                       
$json_row[$uicols[$i]['col_name']] .= " <a target='_blank' 
href='".$invoices['link_claim'].'&project_id='.$_workorder['project_id']."'>".lang('Claim')."</a>";
-                                                                       
unset($_workorder);
-                                                               }
-                                                               else
-                                                               {
-                                                                       
$json_row[$uicols[$i]['col_name']]  .= "<b>x</b>";
-                                                               }
+                                                               $_workorder = 
execMethod('property.soworkorder.read_single', $invoices['workorder_id']);
+                                                               
$json_row[$uicols[$i]['col_name']] .= " <a target='_blank' 
href='".$invoices['link_claim'].'&project_id='.$_workorder['project_id']."'>".lang('Claim')."</a>";
+                                                               
unset($_workorder);
                                                        }
                                                        else
                                                        {
-                                                               
$json_row[$uicols[$i]['col_name']]  .= "<b>-</b>";
+                                                               
$json_row[$uicols[$i]['col_name']]  .= "<b>x</b>";
                                                        }
-
                                                }
-                                               else if(($i == 4))
+                                               else
                                                {
-                                                       
$json_row[$uicols[$i]['col_name']]  .= $invoices['invoice_id'];
+                                                       
$json_row[$uicols[$i]['col_name']]  .= "<b>-</b>";
                                                }
 
-                                               else if(($i == 5))
+                                       }
+                                       else if(($i == 4))
+                                       {
+                                               
$json_row[$uicols[$i]['col_name']]  .= $invoices['invoice_id'];
+                                       }
+
+                                       else if(($i == 5))
+                                       {
+                                               if($invoices['paid'] == true)
                                                {
-                                                       if($invoices['paid'] == 
true)
-                                                       {
-                                                               
$json_row[$uicols[$i]['col_name']] .= $invoices['budget_account'];
-                                                       }
-                                                       else
-                                                       {
-                                                               
$json_row[$uicols[$i]['col_name']]  .= " <input 
name='values[budget_account][".$j."]' id='values[budget_account][".$j."]'  
class='myValuesForPHP'  type='text' size='7' 
value='".$invoices['budget_account']."'/>";
-                                                       }
+                                                       
$json_row[$uicols[$i]['col_name']] .= $invoices['budget_account'];
                                                }
-
-                                               else if(($i == 6))
+                                               else
                                                {
-                                                       
$json_row[$uicols[$i]['col_name']]  .= $invoices['amount'];
+                                                       
$json_row[$uicols[$i]['col_name']]  .= " <input 
name='values[budget_account][".$j."]' id='values[budget_account][".$j."]'  
class='myValuesForPHP'  type='text' size='7' 
value='".$invoices['budget_account']."'/>";
                                                }
+                                       }
 
-                                               else if(($i == 7))
+                                       else if(($i == 6))
+                                       {
+                                               
$json_row[$uicols[$i]['col_name']]  .= $invoices['amount'];
+                                       }
+
+                                       else if(($i == 7))
+                                       {
+
+                                               if($invoices['paid'] == true)
                                                {
+                                                       
$json_row[$uicols[$i]['col_name']] .= $invoices['approved_amount'];
+                                               }
+                                               else
+                                               {
+                                                       
$json_row[$uicols[$i]['col_name']]  .= " <input 
name='values[approved_amount][".$j."]' id='values[approved_amount][".$j."]'  
class='myValuesForPHP'  type='text' size='7' 
value='".$invoices['approved_amount']."'/>";
+                                               }
 
-                                                       if($invoices['paid'] == 
true)
-                                                       {
-                                                               
$json_row[$uicols[$i]['col_name']] .= $invoices['approved_amount'];
-                                                       }
-                                                       else
-                                                       {
-                                                               
$json_row[$uicols[$i]['col_name']]  .= " <input 
name='values[approved_amount][".$j."]' id='values[approved_amount][".$j."]'  
class='myValuesForPHP'  type='text' size='7' 
value='".$invoices['approved_amount']."'/>";
-                                                       }
 
+                                       }
 
-                                               }
+                                       else if(($i == 8))
+                                       {
+                                               
$json_row[$uicols[$i]['col_name']]  .= $invoices['currency'];
+                                       }
 
-                                               else if(($i == 8))
+                                       else if(($i == 9))
+                                       {
+                                               if($invoices['paid'] == true)
                                                {
-                                                       
$json_row[$uicols[$i]['col_name']]  .= $invoices['currency'];
+                                                       
$json_row[$uicols[$i]['col_name']]  .= $invoices['dima'];
                                                }
-
-                                               else if(($i == 9))
+                                               else
                                                {
-                                                       if($invoices['paid'] == 
true)
-                                                       {
-                                                               
$json_row[$uicols[$i]['col_name']]  .= $invoices['dima'];
-                                                       }
-                                                       else
-                                                       {
-                                                               
$json_row[$uicols[$i]['col_name']]  .= " <input name='values[dima][".$j."]' 
id='values[dima][".$j."]'  class='myValuesForPHP'  type='text' size='7' 
value='".$invoices['dima']."'/>";
-                                                       }
+                                                       
$json_row[$uicols[$i]['col_name']]  .= " <input name='values[dima][".$j."]' 
id='values[dima][".$j."]'  class='myValuesForPHP'  type='text' size='7' 
value='".$invoices['dima']."'/>";
                                                }
-                                               else if(($i == 10))
+                                       }
+                                       else if(($i == 10))
+                                       {
+                                               if($invoices['paid'] == true)
                                                {
-                                                       if($invoices['paid'] == 
true)
-                                                       {
-                                                               
$json_row[$uicols[$i]['col_name']]  .= $invoices['dimb'];
-                                                       }
-                                                       else
-                                                       {
+                                                       
$json_row[$uicols[$i]['col_name']]  .= $invoices['dimb'];
+                                               }
+                                               else
+                                               {
 
-                                                               
$json_row[$uicols[$i]['col_name']]  .= " <select 
name='values[dimb_tmp][".$j."]' id='values[dimb_tmp][".$j."]'  
class='dimb_tmp'><option value=''></option>";
+                                                       
$json_row[$uicols[$i]['col_name']]  .= " <select 
name='values[dimb_tmp][".$j."]' id='values[dimb_tmp][".$j."]'  
class='dimb_tmp'><option value=''></option>";
 
-                                                               for($k = 0 ;$k 
< count($invoices['dimb_list']) ; $k++)
+                                                       for($k = 0 ;$k < 
count($invoices['dimb_list']) ; $k++)
+                                                       {
+                                                               
if(isset($invoices['dimb_list'][$k]['selected']) && 
$invoices['dimb_list'][$k]['selected']!="")
                                                                {
-                                                                       
if(isset($invoices['dimb_list'][$k]['selected']) && 
$invoices['dimb_list'][$k]['selected']!="")
-                                                                       {
-                                                                               
$json_row[$uicols[$i]['col_name']]  .= "<option 
value='".$invoices['dimb_list'][$k]['id']."' selected 
>".$invoices['dimb_list'][$k]['name']."</option>";
-                                                                       }
-                                                                       else
-                                                                       {
-                                                                               
$json_row[$uicols[$i]['col_name']]  .= "<option 
value='".$invoices['dimb_list'][$k]['id']."'>".$invoices['dimb_list'][$k]['name']."</option>";
-                                                                       }
+                                                                       
$json_row[$uicols[$i]['col_name']]  .= "<option 
value='".$invoices['dimb_list'][$k]['id']."' selected 
>".$invoices['dimb_list'][$k]['name']."</option>";
                                                                }
-                                                               
$json_row[$uicols[$i]['col_name']]  .="</select>";
-                                                               
$json_row[$uicols[$i]['col_name']]  .= " <input name='values[dimb][".$j."]' 
id='values[dimb][".$j."]'  class='myValuesForPHP dimb'  type='hidden' 
value=''/>";
+                                                               else
+                                                               {
+                                                                       
$json_row[$uicols[$i]['col_name']]  .= "<option 
value='".$invoices['dimb_list'][$k]['id']."'>".$invoices['dimb_list'][$k]['name']."</option>";
+                                                               }
+                                                       }
+                                                       
$json_row[$uicols[$i]['col_name']]  .="</select>";
+                                                       
$json_row[$uicols[$i]['col_name']]  .= " <input name='values[dimb][".$j."]' 
id='values[dimb][".$j."]'  class='myValuesForPHP dimb'  type='hidden' 
value=''/>";
 
-                                                       }
                                                }
-                                               else if(($i == 11))
+                                       }
+                                       else if(($i == 11))
+                                       {
+                                               if($invoices['paid'] == true)
                                                {
-                                                       if($invoices['paid'] == 
true)
-                                                       {
-                                                               
$json_row[$uicols[$i]['col_name']]  .= $invoices['dimd'];
-                                                       }
-                                                       else
-                                                       {
-                                                               
$json_row[$uicols[$i]['col_name']]  .= " <input name='values[dimd][".$j."]' 
id='values[dimd][".$j."]'  class='myValuesForPHP'  type='text' size='4' 
value='".$invoices['dimd']."'/>";
-                                                       }
+                                                       
$json_row[$uicols[$i]['col_name']]  .= $invoices['dimd'];
                                                }
-                                               else if(($i == 12))
+                                               else
                                                {
-                                                       if($invoices['paid'] == 
true)
-                                                       {
-                                                               
$json_row[$uicols[$i]['col_name']]  .= $invoices['tax_code'];
-                                                       }
-                                                       else
-                                                       {
+                                                       
$json_row[$uicols[$i]['col_name']]  .= " <input name='values[dimd][".$j."]' 
id='values[dimd][".$j."]'  class='myValuesForPHP'  type='text' size='4' 
value='".$invoices['dimd']."'/>";
+                                               }
+                                       }
+                                       else if(($i == 12))
+                                       {
+                                               if($invoices['paid'] == true)
+                                               {
+                                                       
$json_row[$uicols[$i]['col_name']]  .= $invoices['tax_code'];
+                                               }
+                                               else
+                                               {
 
-                                                               
$json_row[$uicols[$i]['col_name']]  .= " <select 
name='values[tax_code_tmp][".$j."]' id='values[tax_code_tmp][".$j."]'  
class='tax_code_tmp'><option value=''></option>";
+                                                       
$json_row[$uicols[$i]['col_name']]  .= " <select 
name='values[tax_code_tmp][".$j."]' id='values[tax_code_tmp][".$j."]'  
class='tax_code_tmp'><option value=''></option>";
 
-                                                               for($k = 0 ;$k 
< count($invoices['tax_code_list']) ; $k++)
+                                                       for($k = 0 ;$k < 
count($invoices['tax_code_list']) ; $k++)
+                                                       {
+                                                               
if(isset($invoices['tax_code_list'][$k]['selected']) && 
$invoices['tax_code_list'][$k]['selected']!="")
                                                                {
-                                                                       
if(isset($invoices['tax_code_list'][$k]['selected']) && 
$invoices['tax_code_list'][$k]['selected']!="")
-                                                                       {
-                                                                               
$json_row[$uicols[$i]['col_name']]  .= "<option 
value='".$invoices['tax_code_list'][$k]['id']."'  selected 
>".$invoices['tax_code_list'][$k]['id']."</option>";
-                                                                       }
-                                                                       else
-                                                                       {
-                                                                               
$json_row[$uicols[$i]['col_name']]  .= "<option 
value='".$invoices['tax_code_list'][$k]['id']."'>".$invoices['tax_code_list'][$k]['id']."</option>";
-                                                                       }
+                                                                       
$json_row[$uicols[$i]['col_name']]  .= "<option 
value='".$invoices['tax_code_list'][$k]['id']."'  selected 
>".$invoices['tax_code_list'][$k]['id']."</option>";
                                                                }
-                                                               
$json_row[$uicols[$i]['col_name']]  .="</select>";
-                                                               
$json_row[$uicols[$i]['col_name']]  .= " <input name='values[tax_code][".$j."]' 
id='values[tax_code][".$j."]'  class='myValuesForPHP tax_code'  type='hidden' 
value=''/>";
+                                                               else
+                                                               {
+                                                                       
$json_row[$uicols[$i]['col_name']]  .= "<option 
value='".$invoices['tax_code_list'][$k]['id']."'>".$invoices['tax_code_list'][$k]['id']."</option>";
+                                                               }
+                                                       }
+                                                       
$json_row[$uicols[$i]['col_name']]  .="</select>";
+                                                       
$json_row[$uicols[$i]['col_name']]  .= " <input name='values[tax_code][".$j."]' 
id='values[tax_code][".$j."]'  class='myValuesForPHP tax_code'  type='hidden' 
value=''/>";
 
-                                                       }
                                                }
-                                               else if(($i == 13))
+                                       }
+                                       else if(($i == 13))
+                                       {
+                                               if($invoices['remark'] == true)
                                                {
-                                                       if($invoices['remark'] 
== true)
-                                                       {
-                                                               
$json_row[$uicols[$i]['col_name']] .= " <a 
href=\"javascript:openwindow('".$GLOBALS['phpgw']->link('/index.php', array
-                                                                       (
-                                                                               
'menuaction'=> 'property.uiinvoice.remark',
-                                                                               
'id'            => $invoices['id'],
-                                                                               
'paid'          => $invoices['paid']
-                                                                       )). 
"','550','400')\" >".lang('Remark')."</a>";
-                                                       }
-                                                       else
-                                                       {
-                                                               
$json_row[$uicols[$i]['col_name']]  .= "<b>-</b>";
-                                                       }
+                                                       
$json_row[$uicols[$i]['col_name']] .= " <a 
href=\"javascript:openwindow('".$GLOBALS['phpgw']->link('/index.php', array
+                                                               (
+                                                                       
'menuaction'=> 'property.uiinvoice.remark',
+                                                                       'id'    
        => $invoices['id'],
+                                                                       'paid'  
        => $invoices['paid']
+                                                               )). 
"','550','400')\" >".lang('Remark')."</a>";
                                                }
-                                               else if(($i == 14))
+                                               else
                                                {
-                                                       
if(isset($invoices['external_ref']) && $invoices['external_ref'])
-                                                       {
-                                                               //      
$json_row[$uicols[$i]['col_name']] = " <a target='_blank' 
href='".$baseurl_invoice. $invoices['external_ref']."'>{$lang_picture}</a>";
-                                                               
$json_row[$uicols[$i]['col_name']] = " <a 
href=\"javascript:openwindow('{$baseurl_invoice}{$invoices['external_ref']}','640','800')\"
 >{$lang_picture}</a>";
-                                                       }
-                                                       else
-                                                       {
-                                                               
$json_row[$uicols[$i]['col_name']]  .= "<b>-</b>";
-                                                       }
+                                                       
$json_row[$uicols[$i]['col_name']]  .= "<b>-</b>";
                                                }
-                                               else if($i == 15)
+                                       }
+                                       else if(($i == 14))
+                                       {
+                                               
if(isset($invoices['external_ref']) && $invoices['external_ref'])
                                                {
-                                                       
$json_row[$uicols[$i]['col_name']]  = $invoices['counter'];
+                                                       //      
$json_row[$uicols[$i]['col_name']] = " <a target='_blank' 
href='".$baseurl_invoice. $invoices['external_ref']."'>{$lang_picture}</a>";
+                                                       
$json_row[$uicols[$i]['col_name']] = " <a 
href=\"javascript:openwindow('{$baseurl_invoice}{$invoices['external_ref']}','640','800')\"
 >{$lang_picture}</a>";
                                                }
-                                               else if($i == 16)
+                                               else
                                                {
-                                                       
$json_row[$uicols[$i]['col_name']]  = $invoices['id'];
+                                                       
$json_row[$uicols[$i]['col_name']]  .= "<b>-</b>";
                                                }
-                                               else if($i == 17)
-                                               {
-                                                       
$json_row[$uicols[$i]['col_name']]  = $invoices['external_ref'];
-                                               }
                                        }
-
-                                       if($invoices['workorder_id'])
+                                       else if($i == 15)
                                        {
-                                               
$workorders[$invoices['workorder_id']] = true;
+                                               
$json_row[$uicols[$i]['col_name']]  = $invoices['counter'];
                                        }
+                                       else if($i == 16)
+                                       {
+                                               
$json_row[$uicols[$i]['col_name']]  = $invoices['id'];
+                                       }
+                                       else if($i == 17)
+                                       {
+                                               
$json_row[$uicols[$i]['col_name']]  = $invoices['external_ref'];
+                                       }
+                               }
 
-                                       $datatable['rows']['row'][] = $json_row;
-                                       $j++;
+                               if($invoices['workorder_id'])
+                               {
+                                       $workorders[$invoices['workorder_id']] 
= true;
                                }
+
+                               $datatable['rows']['row'][] = $json_row;
+                               $j++;
                        }
 
+
                        $current_Consult = array ();
                        for($i=0;$i<2;$i++)
                        {

Modified: branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php  
2013-01-17 15:51:39 UTC (rev 10682)
+++ branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php  
2013-01-17 20:10:53 UTC (rev 10683)
@@ -1678,6 +1678,7 @@
                                        'voucher_id'                    => 
$entry['transfer_time'] ? -1*$entry['voucher_id'] : $entry['voucher_id'],
                                        'voucher_out_id'                => 
$entry['voucher_out_id'],
                                        'status'                                
=> $entry['status'],
+                                       'period'                                
=> $entry['period'],
                                        'invoice_id'                    => 
$entry['invoice_id'],                                        
                                        'budget_account'                => 
$entry['budget_account'],
                                        'dima'                                  
=> $entry['dima'],
@@ -1723,6 +1724,7 @@
                                                                                
                                array('key' => 
'vendor','label'=>lang('vendor'),'sortable'=>false,'resizeable'=>true),
                                                                                
                                array('key' => 
'amount','label'=>lang('amount'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterRight'),
                                                                                
                                array('key' => 
'approved_amount','label'=>lang('approved 
amount'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterRight'),
+                                                                               
                                array('key' => 
'period','label'=>lang('period'),'sortable'=>false,'resizeable'=>true),
                                                                                
                                array('key' => 
'currency','label'=>lang('currency'),'sortable'=>false,'resizeable'=>true),
                                                                                
                                array('key' => 
'type','label'=>lang('type'),'sortable'=>false,'resizeable'=>true),
                                                                                
                                array('key' => 
'budget_responsible','label'=>lang('budget 
responsible'),'sortable'=>false,'resizeable'=>true),
@@ -1825,7 +1827,7 @@
                                        'values'        =>      
json_encode(array(      array('key' => 
'year','label'=>lang('year'),'sortable'=>false,'resizeable'=>true),
                                                                                
                                array('key' => 
'month','label'=>lang('month'),'sortable'=>false,'resizeable'=>true),
                                                                                
                                array('key' => 
'budget','label'=>lang('budget'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
-                                                                               
        //                      array('key' => 'sum_orders','label'=> 
lang('order'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+                                                                               
                                array('key' => 'sum_orders','label'=> 
lang('order'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
                                                                                
                                array('key' => 
'sum_oblications','label'=>lang('sum 
orders'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
                                                                                
                                array('key' => 
'actual_cost','label'=>lang('actual 
cost'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
                                                                                
                                array('key' => 
'diff','label'=>lang('difference'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
@@ -1835,8 +1837,8 @@
                                                                                
                                array('key' => 
'deviation_percent_acc','label'=>lang('percent'). '::' . 
lang('accumulated'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
                                                                                
                                //~ array('key' => 
'closed','label'=>lang('closed'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter'),
                                                                                
                                //~ array('key' => 'closed_orig','hidden' => 
true),
-                                                                               
                                //~ array('key' => 
'active','label'=>lang('active'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter'),
-                                                                               
                                //~ array('key' => 'active_orig','hidden' => 
true),
+                                                                               
                                array('key' => 
'active','label'=>lang('active'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter'),
+                                                                               
                                array('key' => 'active_orig','hidden' => true),
                                                                                
                                array('key' => 'flag_active','hidden' => true),
                                                                                
                                array('key' => 
'delete_period','label'=>lang('Delete'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter')
                                                                                
                        )

Modified: branches/Version-1_0-branch/property/inc/export/default/Basware_X114
===================================================================
--- branches/Version-1_0-branch/property/inc/export/default/Basware_X114        
2013-01-17 15:51:39 UTC (rev 10682)
+++ branches/Version-1_0-branch/property/inc/export/default/Basware_X114        
2013-01-17 20:10:53 UTC (rev 10683)
@@ -664,12 +664,7 @@
 
                                if($get_bilagsnr_ut)
                                {
-                                       $this->db->query("UPDATE fm_idgenerator 
SET value = value + 1 WHERE name = 'bilagsnr_ut'");
-                                       $this->db->query("SELECT value FROM 
fm_idgenerator WHERE name = 'bilagsnr_ut'");
-                                       $this->db->next_record();
-                                       $bilagsnr_ut = $this->db->f('value');
-       
-                                       $this->db->query("UPDATE fm_ecobilag 
SET bilagsnr_ut = {$bilagsnr_ut} WHERE bilagsnr = '$voucher_id'");
+                                       $bilagsnr_ut = 
$this->increment_voucher_id();
                                }
                        }
 
@@ -986,7 +981,19 @@
                        return $message;
                }
 
+               protected function increment_voucher_id()
+               {
+                       $name = 'bilagsnr_ut';
+                       $now = time();
+                       $this->db->query("SELECT value, start_date FROM 
fm_idgenerator WHERE name='{$name}' AND start_date < {$now} ORDER BY start_date 
DESC");
+                       $this->db->next_record();
+                       $next_id = $this->db->f('value') +1;
+                       $start_date = (int)$this->db->f('start_date');
+                       $this->db->query("UPDATE fm_idgenerator SET value = 
$next_id WHERE name = '{$name}' AND start_date = {$start_date}");
 
+                       return $next_id;
+               }
+
                protected function _delete_from_fm_ecobilag($bilagsnr)
                {
                        $bilagsnr = (int) $bilagsnr;

Modified: branches/Version-1_0-branch/property/js/yahoo/workorder.edit.js
===================================================================
--- branches/Version-1_0-branch/property/js/yahoo/workorder.edit.js     
2013-01-17 15:51:39 UTC (rev 10682)
+++ branches/Version-1_0-branch/property/js/yahoo/workorder.edit.js     
2013-01-17 20:10:53 UTC (rev 10683)
@@ -134,7 +134,7 @@
                td_empty(3);
                td_sum(tmp_sum1);
                td_sum(tmp_sum2);
-               td_empty(5);
+               td_empty(6);
 
                myfoot = tableYUI.createTFoot();
                myfoot.setAttribute("id","myfoot");
@@ -166,7 +166,7 @@
        this.addFooterDatatable5 = function(paginator,datatable)
        {
                tmp_sum1 = getTotalSum_active('budget',0,paginator,datatable);
- //            tmp_sum2 = 
getTotalSum_active('sum_orders',0,paginator,datatable);
+               tmp_sum2 = 
getTotalSum_active('sum_orders',0,paginator,datatable);
                tmp_sum3 = 
getTotalSum_active('sum_oblications',0,paginator,datatable);
                tmp_sum4 = 
getTotalSum_active('actual_cost',0,paginator,datatable);
                tmp_sum5 = getTotalSum_active('diff',0,paginator,datatable);
@@ -188,7 +188,7 @@
                td_sum('Sum');
                td_empty(1);
                td_sum(tmp_sum1);
-//             td_sum(tmp_sum2);
+               td_sum(tmp_sum2);
                td_sum(tmp_sum3);
                td_sum(tmp_sum4);
                td_sum(tmp_sum5);

Modified: branches/Version-1_0-branch/property/templates/base/workorder.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/workorder.xsl   
2013-01-17 15:51:39 UTC (rev 10682)
+++ branches/Version-1_0-branch/property/templates/base/workorder.xsl   
2013-01-17 20:10:53 UTC (rev 10683)
@@ -705,30 +705,26 @@
                                                                        </input>
                                                                </td>
                                                        </tr>
-                                                       <xsl:choose>
-                                                               <xsl:when 
test="value_workorder_id!='' and mode='edit'">
-                                                                       
<xsl:variable name="lang_add_invoice_statustext">
-                                                                               
<xsl:value-of select="php:function('lang', 'add invoice')"/>
-                                                                       
</xsl:variable>
-                                                                       <tr>
-                                                                               
<td valign="top">
+                                                       <tr>
+                                                               <td >
+                                                                       
<xsl:choose>
+                                                                               
<xsl:when test="value_workorder_id!='' and mode='edit'">
+                                                                               
        <xsl:variable name="lang_add_invoice_statustext">
+                                                                               
                <xsl:value-of select="php:function('lang', 'add invoice')"/>
+                                                                               
        </xsl:variable>
                                                                                
        <a href="javascript:showlightbox_manual_invoide({value_workorder_id})" 
title="{$lang_add_invoice_statustext}">
                                                                                
                <xsl:value-of select="php:function('lang', 'add invoice')"/>
                                                                                
        </a>
-                                                                               
</td>
-                                                                               
<td>
                                                                                
        <div id="manual_invoice_lightbox" 
style="background-color:#000000;color:#FFFFFF;display:none">
                                                                                
                <div class="hd" style="background-color:#000000;color:#000000; 
border:0; text-align:center">
                                                                                
                        <xsl:value-of select="php:function('lang', 'add 
invoice')"/>
                                                                                
                </div>
                                                                                
                <div class="bd" style="text-align:center;"> </div>
                                                                                
        </div>
-                                                                               
</td>
-                                                                       </tr>
-                                                               </xsl:when>
-                                                       </xsl:choose>
-                                                       <tr>
-                                                               <td colspan="2">
+                                                                               
</xsl:when>
+                                                                       
</xsl:choose>
+                                                               </td>
+                                                               <td>
                                                                        <div 
id="paging_2"> </div>
                                                                        <div 
id="datatable-container_2"/>
                                                                </td>




reply via email to

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