fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [10673] Merge 10661:10672 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [10673] Merge 10661:10672 from trunk
Date: Tue, 15 Jan 2013 09:25:44 +0000

Revision: 10673
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10673
Author:   sigurdne
Date:     2013-01-15 09:25:43 +0000 (Tue, 15 Jan 2013)
Log Message:
-----------
Merge 10661:10672 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php
    branches/Version-1_0-branch/property/inc/class.sobudget.inc.php
    branches/Version-1_0-branch/property/inc/class.soproject.inc.php
    branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
    branches/Version-1_0-branch/property/inc/class.uibudget.inc.php
    branches/Version-1_0-branch/property/inc/class.uientity.inc.php
    branches/Version-1_0-branch/property/inc/class.uiproject.inc.php
    branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php
    branches/Version-1_0-branch/property/inc/export/default/El_anlegg_LRS_2
    branches/Version-1_0-branch/property/js/yahoo/workorder.edit.js
    branches/Version-1_0-branch/property/setup/setup.inc.php
    branches/Version-1_0-branch/property/setup/tables_current.inc.php
    branches/Version-1_0-branch/property/setup/tables_update.inc.php
    branches/Version-1_0-branch/property/templates/base/attributes_form.xsl
    branches/Version-1_0-branch/property/templates/base/css/base.css
    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
   + 
/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

Modified: branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php  
2013-01-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php  
2013-01-15 09:25:43 UTC (rev 10673)
@@ -82,7 +82,8 @@
                        $b_account                      = 
phpgw::get_var('b_account');
                        $district_id            = phpgw::get_var('district_id', 
'int');
                        $criteria_id            = phpgw::get_var('criteria_id', 
'int');
-                       $this->allrows                  = 
phpgw::get_var('allrows', 'bool');
+                       $this->allrows          = phpgw::get_var('allrows', 
'bool');
+                       $this->obligation       = phpgw::get_var('obligation', 
'bool');
 
                        $this->start            = $start ? $start : 0;
                        $this->criteria_id      = isset($criteria_id) && 
$criteria_id ? $criteria_id : '';
@@ -462,7 +463,8 @@
                                'wo_hour_cat_id' => $this->wo_hour_cat_id,
                                
'start_date'=>$start_date,'end_date'=>$end_date,'allrows'=>$data['allrows'],
                                
'b_group'=>$this->b_group,'ecodimb'=>$this->ecodimb, 
'paid'=>$this->paid,'b_account' => $this->b_account,
-                               'district_id' => 
$this->district_id,'dry_run'=>$data['dry_run'], 'criteria' => 
$this->get_criteria($this->criteria_id)));
+                               'district_id' => 
$this->district_id,'dry_run'=>$data['dry_run'], 'criteria' => 
$this->get_criteria($this->criteria_id),
+                               'obligation' => $this->obligation) );
 
                        $this->total_records = $this->so->total_records;
 
@@ -819,6 +821,11 @@
                        return $ser_list;
                }
 
+               public function get_budget($order_id)
+               {
+                       return $this->so->get_budget($order_id);
+               }
+
                /**
                * Recalculate actual cost from payment history for all 
workorders
                *

Modified: branches/Version-1_0-branch/property/inc/class.sobudget.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.sobudget.inc.php     
2013-01-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/inc/class.sobudget.inc.php     
2013-01-15 09:25:43 UTC (rev 10673)
@@ -529,7 +529,7 @@
                        $year                   = isset($data['year']) ? 
(int)$data['year'] : '';
                        $grouping               = isset($data['grouping']) ? 
$data['grouping'] : '';
                        $revision               = isset($data['revision']) ? 
$data['revision'] : 1;
-                       $year                   = isset($data['year']) ? 
$data['year'] : '';
+                       $year                   = isset($data['year']) &&  
$data['year'] ? (int)$data['year'] : 0;
                        $cat_id                 = isset($data['cat_id']) ? 
$data['cat_id'] : '';
                        $details                = isset($data['details']) ? 
$data['details'] : '';
                        $dimb_id                = isset($data['dimb_id'])  && 
$data['dimb_id'] ? (int)$data['dimb_id'] : 0;
@@ -567,6 +567,9 @@
                        $filtermethod .= " WHERE (fm_workorder.start_date >= 
$start_date AND fm_workorder.start_date <= $end_date";
                        $filtermethod .= " OR fm_workorder_status.closed IS 
NULL AND fm_workorder.start_date < $start_date)";
 
+                       $filtermethod = " WHERE (fm_workorder_budget.year = 
$year OR fm_workorder_status.closed IS NULL)";
+
+
                        $where = 'AND';
 
                        $cat_ids = array();
@@ -651,17 +654,20 @@
                                $_taxcode[$this->db->f('id')] = 
$this->db->f('percent');
                        }
 
-                       $sql = "SELECT fm_workorder.id, 
fm_workorder_status.closed, fm_workorder.budget, 
combined_cost,fm_location1.mva,fm_workorder.start_date,"
+                       $sql = "SELECT fm_workorder.id, 
fm_workorder_status.closed, sum(fm_workorder_budget.budget) AS budget, 
sum(fm_workorder_budget.combined_cost) AS combined_cost,"
+                               . " fm_location1.mva,fm_workorder.start_date,"
                                . " 
fm_orders_actual_cost_view.actual_cost,pending_cost, 
fm_b_account.{$b_account_field} as {$b_account_field}, district_id, 
fm_workorder.ecodimb"
                                . " 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->join} fm_b_account ON 
fm_workorder.account_id = fm_b_account.id"
                                . " {$this->join} fm_project ON  
fm_workorder.project_id = fm_project.id"
                                . " {$this->left_join} 
fm_orders_actual_cost_view ON  fm_workorder.id = 
fm_orders_actual_cost_view.order_id"
                                . " {$this->left_join} 
fm_orders_pending_cost_view ON  fm_workorder.id = 
fm_orders_pending_cost_view.order_id"
                                . " {$_join_district}"
                                . " {$this->join} fm_part_of_town ON 
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id"
-                               . " {$filtermethod} {$querymethod} {$where} 
{$filtermethod_direction}";
+                               . " {$filtermethod} {$querymethod} {$where} 
{$filtermethod_direction}"
+                               . " GROUP BY fm_workorder.id, 
fm_workorder_status.closed,fm_location1.mva,fm_workorder.start_date,fm_orders_actual_cost_view.actual_cost,pending_cost,
 fm_b_account.{$b_account_field}, district_id, fm_workorder.ecodimb";
 
                        //_debug_array($sql);
                        //die();

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-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/inc/class.soproject.inc.php    
2013-01-15 09:25:43 UTC (rev 10673)
@@ -293,6 +293,12 @@
 
                                $joinmethod .= " {$this->join} 
fm_project_status ON ($entity_table.status = fm_project_status.id))";
                                $paranthesis .='(';
+
+                               $joinmethod .= " {$this->left_join} 
fm_project_budget ON ($entity_table.id = fm_project_budget.project_id))";
+                               $paranthesis .='(';
+                               $joinmethod .= " {$this->left_join} 
fm_project_buffer_budget ON ($entity_table.id = 
fm_project_buffer_budget.buffer_project_id))";
+                               $paranthesis .='(';
+
 /*
                                $joinmethod .= " {$this->left_join} 
fm_workorder ON ($entity_table.id = fm_workorder.project_id))";
                                $paranthesis .='(';
@@ -531,6 +537,14 @@
                                $filtermethod .= " $where fm_project.start_date 
>= $start_date AND fm_project.start_date <= $end_date ";
                                $where= 'AND';
                        }
+
+                       if ($filter_year && $filter_year != 'all')
+                       {
+                               $filter_year = (int)$filter_year;
+                               $filtermethod .= " $where 
(fm_project_budget.year={$filter_year} OR 
fm_project_buffer_budget.year={$filter_year})";
+                               $where= 'AND';
+                       }
+
                        //_debug_array($criteria);
                        $querymethod = '';
                        if($query)
@@ -701,24 +715,32 @@
 
                                                $sql_filter_period = 'AND 
periode IN (' . implode(',', $_year_arr) . ')';
 
-                                               $sql_workder  = 'SELECT 
fm_workorder.id, budget, combined_cost, billable_hours, closed, 
sum(fm_orders_paid_or_pending_view.amount) AS actual_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->left_join} 
fm_orders_paid_or_pending_view ON (fm_workorder.id = 
fm_orders_paid_or_pending_view.order_id {$sql_filter_period})"
-                                               . " WHERE project_id = 
'{$project['project_id']}' {$sql_workder_date_filter} "
-                                               . " GROUP BY fm_workorder.id, 
budget, combined_cost, billable_hours, closed";
+                                       //      . " {$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))"
+                                               . " 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);
 
                                        }
                                        else
                                        {
-                                               $sql_workder  = 'SELECT 
fm_workorder.id, budget, combined_cost, billable_hours, closed, actual_cost, 
pending_cost'//, contract_sum, addition, calculation, 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_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}";
+                                               . " WHERE project_id = 
'{$project['project_id']}' {$sql_workder_date_filter}"
+                                               . " GROUP BY fm_workorder.id, 
billable_hours, closed, actual_cost, pending_cost";
+
                                        }
-//_debug_array($sql_workder);
+//~ _debug_array($sql_workder);
 
                                        
$this->db->query($sql_workder,__LINE__,__FILE__);
 
@@ -821,39 +843,40 @@
                        if ($this->db->next_record())
                        {
                                $project = array
-                                       (
-                                               'project_id'                    
=> $this->db->f('id'),
-                                               'project_type_id'               
=> $this->db->f('project_type_id'),
-                                               'title'                         
        => $this->db->f('title'),
-                                               'name'                          
        => $this->db->f('name'),
-                                               'location_code'                 
=> $this->db->f('location_code'),
-                                               'key_fetch'                     
        => $this->db->f('key_fetch'),
-                                               'key_deliver'                   
=> $this->db->f('key_deliver'),
-                                               'other_branch'                  
=> $this->db->f('other_branch'),
-                                               'key_responsible'               
=> $this->db->f('key_responsible'),
-                                               'descr'                         
        => $this->db->f('descr', true),
-                                               'status'                        
        => $this->db->f('status'),
-                                               'budget'                        
        => (int)$this->db->f('budget'),
-                       //                      'planned_cost'                  
=> (int)$this->db->f('planned_cost'),
-                                               'reserve'                       
        => (int)$this->db->f('reserve'),
-                                               'tenant_id'                     
        => $this->db->f('tenant_id'),
-                                               'user_id'                       
        => $this->db->f('user_id'),
-                                               'coordinator'                   
=> $this->db->f('coordinator'),
-                                               'access'                        
        => $this->db->f('access'),
-                                               'start_date'                    
=> $this->db->f('start_date'),
-                                               'end_date'                      
        => $this->db->f('end_date'),
-                                               'cat_id'                        
        => $this->db->f('category'),
-                                               'grants'                        
        => (int)$this->grants[$this->db->f('user_id')],
-                                               'p_num'                         
        => $this->db->f('p_num'),
-                                               'p_entity_id'                   
=> $this->db->f('p_entity_id'),
-                                               'p_cat_id'                      
        => $this->db->f('p_cat_id'),
-                                               'contact_phone'                 
=> $this->db->f('contact_phone'),
-                                               'project_group'                 
=> $this->db->f('project_group'),
-                                               'ecodimb'                       
        => $this->db->f('ecodimb'),
-                                               'b_account_id'                  
=> $this->db->f('account_group'),
-                                               'contact_id'                    
=> $this->db->f('contact_id'),
-                                               'inherit_location'              
=>  $this->db->f('inherit_location')
-                                       );
+                               (
+                                       'project_id'                    => 
$this->db->f('id'),
+                                       'project_type_id'               => 
$this->db->f('project_type_id'),
+                                       'title'                                 
=> $this->db->f('title'),
+                                       'name'                                  
=> $this->db->f('name'),
+                                       'location_code'                 => 
$this->db->f('location_code'),
+                                       'key_fetch'                             
=> $this->db->f('key_fetch'),
+                                       'key_deliver'                   => 
$this->db->f('key_deliver'),
+                                       'other_branch'                  => 
$this->db->f('other_branch'),
+                                       'key_responsible'               => 
$this->db->f('key_responsible'),
+                                       'descr'                                 
=> $this->db->f('descr', true),
+                                       'status'                                
=> $this->db->f('status'),
+                                       'budget'                                
=> (int)$this->db->f('budget'),
+                       //              'planned_cost'                  => 
(int)$this->db->f('planned_cost'),
+                                       'reserve'                               
=> (int)$this->db->f('reserve'),
+                                       'tenant_id'                             
=> $this->db->f('tenant_id'),
+                                       'user_id'                               
=> $this->db->f('user_id'),
+                                       'coordinator'                   => 
$this->db->f('coordinator'),
+                                       'access'                                
=> $this->db->f('access'),
+                                       'start_date'                    => 
$this->db->f('start_date'),
+                                       'end_date'                              
=> $this->db->f('end_date'),
+                                       'cat_id'                                
=> $this->db->f('category'),
+                                       'grants'                                
=> (int)$this->grants[$this->db->f('user_id')],
+                                       'p_num'                                 
=> $this->db->f('p_num'),
+                                       'p_entity_id'                   => 
$this->db->f('p_entity_id'),
+                                       'p_cat_id'                              
=> $this->db->f('p_cat_id'),
+                                       'contact_phone'                 => 
$this->db->f('contact_phone'),
+                                       'project_group'                 => 
$this->db->f('project_group'),
+                                       'ecodimb'                               
=> $this->db->f('ecodimb'),
+                                       'b_account_id'                  => 
$this->db->f('account_group'),
+                                       'contact_id'                    => 
$this->db->f('contact_id'),
+                                       'inherit_location'              => 
$this->db->f('inherit_location'),
+                                       'periodization_id'              => 
$this->db->f('periodization_id')
+                               );
 
                                if ( isset($values['attributes']) && 
is_array($values['attributes']) )
                                {
@@ -1382,6 +1405,11 @@
 
                                        
$this->_update_buffer_budget($project['transfer_target'], date('Y'), 
$project['transfer_amount'], $project['id'],null,$project['transfer_remark']);
 
+                                       $this->db->query("SELECT sum(amount_in) 
AS amount_in, sum(amount_out) AS amount_out FROM fm_project_buffer_budget WHERE 
buffer_project_id = " . (int)$project['transfer_target'],__LINE__,__FILE__);
+                                       $this->db->next_record();
+                                       $new_budget 
=(int)$this->db->f('amount_in') - (int)$this->db->f('amount_out');
+                                       $this->db->query("UPDATE fm_project SET 
budget = {$new_budget} WHERE id = " . 
(int)$project['transfer_target'],__LINE__,__FILE__);
+
                                        if(isset($project['transfer_remark']) 
&& $project['transfer_remark'])
                                        {
                                                
$historylog->add('RM',$project['id'],$project['transfer_remark'], false);
@@ -1791,7 +1819,7 @@
                                $transferred = 
$this->update_budget($from_project, $year, $periodization_id, $amount_in, 
false, 'subtract');
                                if(!$transferred == $amount_in)
                                {
-                                       throw new 
Exception('property_soproject::update_buffer_budget() - failed to transefer the 
full amount');
+                                       throw new 
Exception('property_soproject::update_buffer_budget() - failed to transfer the 
full amount');
                                }
                        }
                }
@@ -1809,7 +1837,7 @@
                                $acc_partial = 0;
 
                                $orig_budget = $this->get_budget($project_id);
-//_debug_array($orig_budget);
+
                                $hit = false;
                                foreach ($orig_budget as $entry)
                                {
@@ -1869,6 +1897,11 @@
 
                                        $this->_update_budget($project_id, 
$year, $month, $budget, $action);                                    
                                }
+                               
+                               if(!$hit)
+                               {
+                                       throw new 
Exception('property_soproject::update_buffer_budget() - found no active budget 
to transfer from');                            
+                               }
 
                                return $acc_partial;
                        }
@@ -2018,9 +2051,9 @@
                        $project_budget = array();
                        $project_total_budget = 0;
 
-                       $sql = "SELECT fm_project_budget.year, 
fm_project_budget.month, fm_project_budget.budget, fm_project_budget.closed, 
fm_project_budget.active, sum(combined_cost) AS order_amount, start_date"
+                       $sql = "SELECT fm_project_budget.year, 
fm_project_budget.month, fm_project_budget.budget, fm_project_budget.closed, 
fm_project_budget.active, sum(combined_cost) AS order_amount"
                        . " FROM fm_project_budget {$this->left_join} 
fm_workorder ON fm_project_budget.project_id = fm_workorder.project_id WHERE 
fm_project_budget.project_id = {$project_id}"
-                       . " GROUP BY fm_project_budget.year, 
fm_project_budget.month, fm_project_budget.budget, fm_project_budget.closed, 
fm_project_budget.active,start_date"
+                       . " GROUP BY fm_project_budget.year, 
fm_project_budget.month, fm_project_budget.budget, fm_project_budget.closed, 
fm_project_budget.active"
                        . " ORDER BY fm_project_budget.year, 
fm_project_budget.month";
                        $this->db->query($sql,__LINE__,__FILE__);
 //     _debug_array($sql);
@@ -2485,6 +2518,7 @@
 
                        for ($i=0;$i<count($workorder_id);$i++)
                        {
+                               $this->db->query("DELETE FROM 
fm_workorder_budget WHERE order_id='{$workorder_id[$i]}'",__LINE__,__FILE__);
                                $this->db->query("DELETE FROM fm_wo_hours WHERE 
workorder_id='{$workorder_id[$i]}'",__LINE__,__FILE__);
                                $this->db->query("DELETE FROM 
fm_workorder_history  WHERE  
history_record_id='{$workorder_id[$i]}'",__LINE__,__FILE__);
                        }

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-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php  
2013-01-15 09:25:43 UTC (rev 10673)
@@ -138,6 +138,7 @@
                        $start_date             = isset($data['start_date']) && 
$data['start_date'] ? (int)$data['start_date'] : 0;
                        $end_date               = isset($data['end_date']) && 
$data['end_date'] ? (int)$data['end_date'] : 0;
                        $allrows                = isset($data['allrows']) ? 
$data['allrows'] : '';
+                       $obligation             = isset($data['obligation']) ? 
$data['obligation'] : '';
                        $wo_hour_cat_id = isset($data['wo_hour_cat_id']) ? 
$data['wo_hour_cat_id'] : '';
                        $b_group                = isset($data['b_group']) ? 
$data['b_group'] : '';
                        $ecodimb                = isset($data['ecodimb']) ? 
$data['ecodimb'] : '';
@@ -598,8 +599,18 @@
                                $end_date       = $end_date + 3600 * 16 + 
phpgwapi_datetime::user_timezone();
                                $start_date     = $start_date - 3600 * 8 + 
phpgwapi_datetime::user_timezone();
 
-                               $filtermethod .= " $where 
fm_workorder.start_date >= $start_date AND fm_workorder.start_date <= $end_date 
";
+                               $filtermethod .= " $where 
(fm_workorder.start_date >= $start_date AND fm_workorder.start_date <= 
$end_date";
+                               if($obligation)
+                               {
+                                       $filtermethod .= " OR 
fm_workorder_status.closed IS NULL)";
+                               }
+                               else
+                               {
+                                       $filtermethod .= ')';
+                               }
+
                                $where= 'AND';
+
                        }
 
                        $querymethod = '';
@@ -735,10 +746,13 @@
                                . " {$this->join} fm_workorder_status ON 
fm_workorder.status = fm_workorder_status.id"
                                . ' WHERE fm_workorder.id IN (' . implode(',', 
$_order_list ) .') GROUP BY fm_workorder.id, closed';
 */
-                               $sql_cost = "SELECT fm_workorder.id as 
order_id,closed, actual_cost, pending_cost"
+                               $sql_cost = "SELECT fm_workorder.id as 
order_id,closed, actual_cost, pending_cost,"
+                               . " sum(fm_workorder_budget.budget) AS budget, 
sum(fm_workorder_budget.combined_cost) AS combined_cost"
                                . " FROM fm_workorder {$this->left_join} 
fm_orders_pending_cost_view ON fm_workorder.id = 
fm_orders_pending_cost_view.order_id"
                                . " {$this->join} fm_workorder_status ON 
fm_workorder.status = fm_workorder_status.id"
-                               . ' WHERE fm_workorder.id IN (' . implode(',', 
$_order_list ) .')';
+                               . " {$this->join} fm_workorder_budget ON 
(fm_workorder.id = fm_workorder_budget.order_id)"
+                               . ' WHERE fm_workorder.id IN (' . implode(',', 
$_order_list ) .')'
+                               . " GROUP BY fm_workorder.id,closed, 
actual_cost, pending_cost";
 
                                unset($_order_list);
                                $this->db->query($sql_cost,__LINE__,__FILE__);
@@ -747,6 +761,8 @@
                                        
$_actual_cost_arr[$this->db->f('order_id')] = array
                                        (
                                                'actual_cost'   => 
$this->db->f('actual_cost') + (float)$this->db->f('pending_cost'),
+                                               'budget'                => 
$this->db->f('budget'),
+                                               'combined_cost' => 
$this->db->f('combined_cost'),
                                                'closed'                => 
!!$this->db->f('closed')
                                        );
                                }
@@ -767,6 +783,9 @@
 
                                if 
(isset($_actual_cost_arr[$workorder['workorder_id']]))
                                {
+                                       $workorder['budget'] = 
$_actual_cost_arr[$workorder['workorder_id']]['budget'];
+                                       $workorder['combined_cost'] = 
$_actual_cost_arr[$workorder['workorder_id']]['combined_cost'];
+
                                        $_combined_cost = 
$workorder['combined_cost'];
                        //              $_pending_cost = 
round($this->db2->f('pending_cost'));
 
@@ -836,50 +855,60 @@
                        if ($this->db->next_record())
                        {
                                $workorder = array
-                                       (
-                                               'id'                            
        => $this->db->f('id'),
-                                               'workorder_id'                  
=> $this->db->f('id'), // FIXME
-                                               'project_id'                    
=> $this->db->f('project_id'),
-                                               'title'                         
        => $this->db->f('title'),
-                                               'name'                          
        => $this->db->f('name'),
-                                               'key_fetch'                     
        => $this->db->f('key_fetch'),
-                                               'key_deliver'                   
=> $this->db->f('key_deliver'),
-                                               'key_responsible'               
=> $this->db->f('key_responsible'),
-                                               'charge_tenant'                 
=> $this->db->f('charge_tenant'),
-                                               'descr'                         
        => stripslashes($this->db->f('descr')),
-                                               'status'                        
        => $this->db->f('status'),
-                                               'budget'                        
        => (int)$this->db->f('budget'),
-                                               'calculation'                   
=> $this->db->f('calculation'),
-                                               'b_account_id'                  
=> (int)$this->db->f('account_id'),
-                                               'addition_percentage'   => 
(int)$this->db->f('addition'),
-                                               'addition_rs'                   
=> (int)$this->db->f('rig_addition'),
-                       //                      'act_mtrl_cost'                 
=> $this->db->f('act_mtrl_cost'),
-                       //                      'act_vendor_cost'               
=> $this->db->f('act_vendor_cost'),
-                                               'user_id'                       
        => $this->db->f('user_id'),
-                                               'vendor_id'                     
        => $this->db->f('vendor_id'),
-                       //                      'coordinator'                   
=> $this->db->f('coordinator'),
-                                               'access'                        
        => $this->db->f('access'),
-                                               'start_date'                    
=> $this->db->f('start_date'),
-                                               'end_date'                      
        => $this->db->f('end_date'),
-                                               'cat_id'                        
        => $this->db->f('category'),
-                                               'chapter_id'                    
=> $this->db->f('chapter_id'),
-                                               'chapter'                       
        => $this->db->f('chapter'),
-                                               'deviation'                     
        => $this->db->f('deviation'),
-                                               'ecodimb'                       
        => $this->db->f('ecodimb'),
-                                               'location_code'                 
=> $this->db->f('location_code'),
-                                               'p_num'                         
        => $this->db->f('p_num'),
-                                               'p_entity_id'                   
=> $this->db->f('p_entity_id'),
-                                               'p_cat_id'                      
        => $this->db->f('p_cat_id'),
-                                               'contact_phone'                 
=> $this->db->f('contact_phone'),
-                                               'tenant_id'                     
        => $this->db->f('tenant_id'),
-                                               'cat_id'                        
        => $this->db->f('category'),
-                                               'grants'                        
        => (int)$this->grants[$this->db->f('user_id')],
-                                               'billable_hours'                
=> $this->db->f('billable_hours'),
-                                               'contract_sum'                  
=> $this->db->f('contract_sum'),
-                                               'approved'                      
        => $this->db->f('approved'),
-                                               'mail_recipients'               
=> explode(',', trim($this->db->f('mail_recipients'),',')),
-                                               'actual_cost'                   
=> $this->db->f('actual_cost')
-                                       );
+                               (
+                                       'id'                                    
=> $this->db->f('id'),
+                                       'workorder_id'                  => 
$this->db->f('id'), // FIXME
+                                       'project_id'                    => 
$this->db->f('project_id'),
+                                       'title'                                 
=> $this->db->f('title'),
+                                       'name'                                  
=> $this->db->f('name'),
+                                       'key_fetch'                             
=> $this->db->f('key_fetch'),
+                                       'key_deliver'                   => 
$this->db->f('key_deliver'),
+                                       'key_responsible'               => 
$this->db->f('key_responsible'),
+                                       'charge_tenant'                 => 
$this->db->f('charge_tenant'),
+                                       'descr'                                 
=> stripslashes($this->db->f('descr')),
+                                       'status'                                
=> $this->db->f('status'),
+                                       'calculation'                   => 
$this->db->f('calculation'),
+                                       'b_account_id'                  => 
(int)$this->db->f('account_id'),
+                                       'addition_percentage'   => 
(int)$this->db->f('addition'),
+                                       'addition_rs'                   => 
(int)$this->db->f('rig_addition'),
+                       //              'act_mtrl_cost'                 => 
$this->db->f('act_mtrl_cost'),
+                       //              'act_vendor_cost'               => 
$this->db->f('act_vendor_cost'),
+                                       'user_id'                               
=> $this->db->f('user_id'),
+                                       'vendor_id'                             
=> $this->db->f('vendor_id'),
+                       //              'coordinator'                   => 
$this->db->f('coordinator'),
+                                       'access'                                
=> $this->db->f('access'),
+                                       'start_date'                    => 
$this->db->f('start_date'),
+                                       'end_date'                              
=> $this->db->f('end_date'),
+                                       'cat_id'                                
=> $this->db->f('category'),
+                                       'chapter_id'                    => 
$this->db->f('chapter_id'),
+                                       'chapter'                               
=> $this->db->f('chapter'),
+                                       'deviation'                             
=> $this->db->f('deviation'),
+                                       'ecodimb'                               
=> $this->db->f('ecodimb'),
+                                       'location_code'                 => 
$this->db->f('location_code'),
+                                       'p_num'                                 
=> $this->db->f('p_num'),
+                                       'p_entity_id'                   => 
$this->db->f('p_entity_id'),
+                                       'p_cat_id'                              
=> $this->db->f('p_cat_id'),
+                                       'contact_phone'                 => 
$this->db->f('contact_phone'),
+                                       'tenant_id'                             
=> $this->db->f('tenant_id'),
+                                       'cat_id'                                
=> $this->db->f('category'),
+                                       'grants'                                
=> (int)$this->grants[$this->db->f('user_id')],
+                                       'billable_hours'                => 
$this->db->f('billable_hours'),
+                                       'approved'                              
=> $this->db->f('approved'),
+                                       'mail_recipients'               => 
explode(',', trim($this->db->f('mail_recipients'),',')),
+                                       'actual_cost'                   => 
$this->db->f('actual_cost')
+                               );
+
+                               $sql = "SELECT periodization_id,"
+                                       . " sum(fm_workorder_budget.budget) AS 
budget, sum(fm_workorder_budget.combined_cost) AS combined_cost,"
+                                       . " 
sum(fm_workorder_budget.contract_sum) AS contract_sum"
+                                       . " FROM fm_workorder {$this->join} 
fm_project ON fm_workorder.project_id = fm_project.id"
+                                       . " {$this->join} fm_workorder_budget 
ON fm_workorder.id = fm_workorder_budget.order_id"
+                                       . " WHERE fm_workorder.id = 
'{$workorder_id}' GROUP BY periodization_id";
+
+                               $this->db->query($sql,__LINE__,__FILE__);
+                               $this->db->next_record();
+                               $workorder['budget']                    = 
(int)$this->db->f('budget');
+                               $workorder['contract_sum']              = 
$this->db->f('contract_sum');
                        }
 
                        //_debug_array($workorder);
@@ -1116,6 +1145,7 @@
                        $workorder['contract_sum']              = 
str_replace(array(' ',','),array('','.'),$workorder['contract_sum']);
 
 
+                       $combined_cost = 0;
                        if ( abs((int)$workorder['contract_sum']) > 0)
                        {
                                $addition = 1 + 
((int)$workorder['addition_percentage']/100);
@@ -1164,13 +1194,22 @@
 
                        $this->db->query("INSERT INTO fm_orders (id,type) 
VALUES ({$id},'workorder')");
 
+
+/*
                        $this->db->query("SELECT periodization_id FROM 
fm_project WHERE id = {$workorder['project_id']}",__LINE__,__FILE__);
                        $this->db->next_record();
                        $periodization_id = $this->db->f('periodization_id');
-
+*/
+                       $periodization_id = 
isset($workorder['budget_periodization']) && $workorder['budget_periodization'] 
? (int) $workorder['budget_periodization'] : 0;
 //                     $this->_update_project_budget($workorder['project_id'], 
date('Y', $workorder['start_date']), $periodization_id, $combined_cost);
-                       $this->_update_order_budget($id, date('Y', 
$workorder['start_date']), $periodization_id, 
$workorder['budget'],$combined_cost);
+                       if($combined_cost)
+                       {
+                               $this->_update_order_budget($id, 
$workorder['budget_year'], $periodization_id, $workorder['budget'], 
$workorder['contract_sum'], $combined_cost);
+                       }
 
+
+
+
 /*
                        if($workorder['charge_tenant'])
                        {
@@ -1222,14 +1261,12 @@
                        $workorder['title'] = 
$this->db->db_addslashes($workorder['title']);
                        $workorder['billable_hours'] = 
(float)str_replace(',','.', $workorder['billable_hours']);
 
-                       $this->db->query("SELECT 
status,budget,calculation,billable_hours,approved,combined_cost FROM 
fm_workorder WHERE id = {$workorder['id']}",__LINE__,__FILE__);
+                       $this->db->query("SELECT 
status,calculation,billable_hours,approved FROM fm_workorder WHERE id = 
{$workorder['id']}",__LINE__,__FILE__);
                        $this->db->next_record();
 
                        $old_status                     = 
$this->db->f('status');
-                       $old_budget                     = 
$this->db->f('budget');
                        $old_billable_hours     = 
$this->db->f('billable_hours');
                        $old_approved           = $this->db->f('approved');
-                       $old_combined_cost      = $this->db->f('combined_cost');
 
                        if 
(isset($GLOBALS['phpgw_info']['user']['preferences']['common']['currency']))
                        {
@@ -1243,14 +1280,14 @@
                                $addition = 1 + 
((int)$workorder['addition_percentage']/100);
                                $combined_cost = 
(int)$workorder['contract_sum'] * $addition;
                        }
-                       else if ($this->db->f('calculation') > 0)
+/*                     else if ($this->db->f('calculation') > 0)
                        {
                                $calculation = $this->db->f('calculation');
                                $config = 
CreateObject('phpgwapi.config','property');
                                $config->read_repository();
                                $tax = 1+(($config->config_data['fm_tax'])/100);
                                $combined_cost = $calculation * $tax;
-                       }
+                       }*/
                        else
                        {
                                $combined_cost = (int)$workorder['budget'];
@@ -1279,7 +1316,7 @@
                                'end_date'                      => 
$workorder['end_date'],
                                'descr'                         => 
$workorder['descr'],
                                'budget'                        => 
(int)$workorder['budget'],
-                               'combined_cost'         => $combined_cost,
+//                             'combined_cost'         => $combined_cost,
                                'key_deliver'           => 
$workorder['key_deliver'],
                                'key_fetch'                     => 
$workorder['key_fetch'],
                                'account_id'            => 
$workorder['b_account_id'],
@@ -1291,7 +1328,7 @@
                                'ecodimb'                       => 
$workorder['ecodimb'],
                                'category'                      => 
$workorder['cat_id'],
                                'billable_hours'        => 
$workorder['billable_hours'],
-                               'contract_sum'          => 
$workorder['contract_sum'],
+//                             'contract_sum'          => 
$workorder['contract_sum'],
                                'approved'                      => 
$workorder['approved'],
                                'mail_recipients'       => 
isset($workorder['vendor_email']) && is_array($workorder['vendor_email']) ? 
implode(',', $workorder['vendor_email']) : '',
                        );
@@ -1343,15 +1380,45 @@
                        $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__);
 
+                       if($workorder['delete_b_period'])
+                       {
+                               $this->db->query("SELECT sum(budget) AS budget 
FROM fm_workorder_budget WHERE order_id = 
'{$workorder['id']}'",__LINE__,__FILE__);
+                               $this->db->next_record();
+                               $old_budget             = 
$this->db->f('budget');
 
+                               
$this->delete_period_from_budget($workorder['id'], 
$workorder['delete_b_period']);
+
+                               $this->db->query("SELECT sum(budget) AS budget 
FROM fm_workorder_budget WHERE order_id = 
'{$workorder['id']}'",__LINE__,__FILE__);
+                               $this->db->next_record();
+                               $new_budget             = 
$this->db->f('budget');
+
+                               $historylog->add('B', $workorder['id'], 
$new_budget, $old_budget);
+
+                       }
+
+/*
                        $this->db->query("SELECT periodization_id FROM 
fm_project WHERE id = {$workorder['project_id']}",__LINE__,__FILE__);
                        $this->db->next_record();
                        $periodization_id = $this->db->f('periodization_id');
-
+*/
+                       $periodization_id = 
isset($workorder['budget_periodization']) && $workorder['budget_periodization'] 
? (int) $workorder['budget_periodization'] : 0;
 //                     $this->_update_project_budget($workorder['project_id'], 
date('Y', $workorder['start_date']), $periodization_id, 
$combined_cost,$old_combined_cost);
-                       $this->_update_order_budget($workorder['id'], date('Y', 
$workorder['start_date']), $periodization_id, 
$workorder['budget'],$combined_cost);
+                       if($combined_cost)
+                       {
+                               $this->db->query("SELECT sum(budget) AS budget 
FROM fm_workorder_budget WHERE order_id = 
'{$workorder['id']}'",__LINE__,__FILE__);
+                               $this->db->next_record();
+                               $old_budget             = 
$this->db->f('budget');
 
+                               $this->_update_order_budget($workorder['id'], 
$workorder['budget_year'], $periodization_id, $workorder['budget'], 
$workorder['contract_sum'], $combined_cost);
 
+                               $this->db->query("SELECT sum(budget) AS budget 
FROM fm_workorder_budget WHERE order_id = 
'{$workorder['id']}'",__LINE__,__FILE__);
+                               $this->db->next_record();
+                               $new_budget             = 
$this->db->f('budget');
+
+                               $historylog->add('B', $workorder['id'], 
$new_budget, $old_budget);
+                       }
+
+
 /*                     if($workorder['charge_tenant'])
                        {
                                $this->db->query("UPDATE fm_project set 
charge_tenant = 1 WHERE id =" . $workorder['project_id']);
@@ -1439,10 +1506,6 @@
                                }
                        }
 
-                       if ($old_budget != $workorder['budget'])
-                       {
-                               $historylog->add('B', $workorder['id'], 
$workorder['budget'], $old_budget);
-                       }
 
                        if (isset($workorder['new_project_id']) && 
$workorder['new_project_id'] && ($workorder['new_project_id'] != 
$workorder['project_id']))
                        {
@@ -1473,12 +1536,12 @@
                {
                        $this->db->transaction_begin();
                        $this->interlink->delete_at_target('property', 
'.project.workorder', $workorder_id, $this->db);
-                       $this->db->query("DELETE FROM fm_workorder WHERE id='" 
. $workorder_id . "'",__LINE__,__FILE__);
+                       $this->db->query("DELETE FROM fm_workorder_budget WHERE 
order_id='{$workorder_id}'",__LINE__,__FILE__);
                        $this->db->query("DELETE FROM fm_workorder_history  
WHERE  history_record_id='" . $workorder_id   . "'",__LINE__,__FILE__);
                        $this->db->query("DELETE FROM fm_wo_hours WHERE 
workorder_id='" . $workorder_id   . "'",__LINE__,__FILE__);
                        $this->db->query("DELETE FROM fm_orders WHERE id='" . 
$workorder_id . "'",__LINE__,__FILE__);
+                       $this->db->query("DELETE FROM fm_workorder WHERE id='" 
. $workorder_id . "'",__LINE__,__FILE__);
                        $this->db->transaction_commit();
-
                }
 
                public function get_user_list()
@@ -1598,7 +1661,222 @@
                        }
                }
 
+
                /**
+               * Get periodized budget for an order
+               *
+               * @return array Array with budget information.
+               */
+
+               function get_budget($order_id)
+               {
+                       if(!$order_id)
+                       {
+                               return array();
+                       }
+
+                       $closed_period = array();
+                       $active_period = array();
+                       $_dummy_period = '';
+
+                       $sql = "SELECT fm_workorder_budget.budget, 
fm_workorder_budget.combined_cost, year, month, 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";
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $order_budget = array();
+                       while ($this->db->next_record())
+                       {
+                               $period = sprintf("%s%02d",
+                                                       $this->db->f('year'),
+                                                       $this->db->f('month')
+                                               );
+                               $_dummy_period = $period;
+
+                               $order_budget[$period] = array
+                               (
+                                       'order_id'                      => 
$order_id,
+                                       'budget'                        => 
(int)$this->db->f('budget'),
+                                       'combined_cost'         => 
(int)$this->db->f('combined_cost'),
+                                       'year'                          => 
(int)$this->db->f('year'),
+                                       'month'                         => 
(int)$this->db->f('month'),
+                                       'actual_cost'           => 0, //for 
now..
+                                       'closed_order'          => false,
+                               );
+
+                               $closed_period[$period] = false;
+                               $active_period[$period] = true;
+                       }
+
+//                     if ( $order_budget )
+                       {
+                               $sql = "SELECT order_id, periode, amount AS 
actual_cost"
+                               . " FROM fm_workorder {$this->join} 
fm_orders_paid_or_pending_view ON fm_workorder.id = 
fm_orders_paid_or_pending_view.order_id"
+                               . " WHERE order_id = '{$order_id}' ORDER BY 
periode ASC";
+//_debug_array($sql);
+                               $this->db->query($sql,__LINE__,__FILE__);
+                               while ($this->db->next_record())
+                               {
+                                       $periode = $this->db->f('periode');
+                                       if(!$periode)
+                                       {
+                                               $periode = date('Ym');
+                                               $_dummy_period = $_dummy_period 
? $_dummy_period : $periode;
+                                       }
+
+                                       $year = substr( $periode, 0, 4 );
+
+                                       $_found = false;
+                                       if(isset($order_budget[$periode]))
+                                       {
+                                               
$order_budget[$periode]['actual_cost'] += $this->db->f('actual_cost');
+                                               $_found = true;
+                                       }
+                                       else
+                                       {
+                                               for ($i=0;$i<13;$i++)
+                                               {
+                                                       $_period = $year . 
sprintf("%02s", $i);
+                                                       
if(isset($order_budget[$_period]))
+                                                       {
+                                                               
$order_budget[$_period]['actual_cost'] += $this->db->f('actual_cost');
+//_debug_array($test+=$this->db->f('actual_cost'));
+                                                               $_found = true;
+                                                               break;
+                                                       }
+                                               }
+                                       }
+
+                                       if(!$_found)
+                                       {
+                                               
$order_budget[$_dummy_period]['year'] = substr( $_dummy_period, 0, 4 );
+                                               
$order_budget[$_dummy_period]['month'] = substr( $_dummy_period, -2);
+                                               
$order_budget[$_dummy_period]['actual_cost'] += $this->db->f('actual_cost');
+                                       }
+                               }
+                       }
+
+                       $sort_period = array();
+                       $values = array();
+//_debug_array($project_budget);die();
+//$test = 0;
+                       $_delay_period = 0;
+                       foreach ($order_budget as $period => $_budget)
+                       {
+                               $_sum_orders = 0;
+                               $_sum_oblications = 0;
+                               $_actual_cost = 0;
+
+                               $_actual_cost += $_budget['actual_cost'];
+//_debug_array( $test+= $_budget['actual_cost']);
+                               $_sum_orders += $_budget['combined_cost'];
+
+                               if(!$_budget['closed_order'])
+                               {
+                                       $_sum_oblications += 
$_budget['combined_cost'];
+                                       $_sum_oblications -= 
$_budget['actual_cost'];
+
+                       //              if($project_total_budget >= 0)
+                                       if($_budget['budget'] >= 0)
+                                       {
+                                               if($_sum_oblications < 0)
+                                               {
+                                                       $_sum_oblications = 0;
+                                               }
+                                       }
+                                       else // income
+                                       {
+                                               if($_sum_oblications > 0)
+                                               {
+                                                       $_sum_oblications = 0;
+                                               }
+                                       }
+                               }
+
+                               //override if periode is closed
+                               if(!isset($active_period[$period]) || 
!$active_period[$period])
+                               {
+                                       $_delay_period += $_sum_oblications;
+                                       $_sum_oblications = 0;
+                               }
+                               //override if periode is closed
+                               if(isset($closed_period[$period]) && 
$closed_period[$period])
+                               {
+                                       $_sum_oblications = 0;
+                               }
+
+                               if(isset($active_period[$period]) && 
$active_period[$period] && $_delay_period)
+                               {
+                                       $_sum_oblications[] += $_delay_period;
+                                       $_delay_period =0;
+                               }
+//die();
+                               $values[] = array
+                               (
+                                       'year'                                  
=> $_budget['year'],
+                                       'month'                                 
=> $_budget['month'] > 0 ? sprintf("%02s", $_budget['month']) : '',
+                                       'period'                                
=> $period,
+                                       'budget'                                
=> $_budget['budget'],
+                                       'sum_orders'                    => 
$_sum_orders,
+                                       'sum_oblications'               => 
$_sum_oblications,
+                                       'actual_cost'                   => 
$_actual_cost,
+                               );
+
+                               $sort_period[] = $period;
+                       }
+                       
+                       if($values)
+                       {
+                               array_multisort($sort_period, SORT_ASC, 
$values);
+                       }
+
+
+                       foreach ($values as &$entry)
+                       {
+       //                      $entry['year'] = substr( $entry['period'], 0, 4 
);
+       //                      $month = substr( $entry['period'], 4, 2 );
+       //                      $entry['month'] = $month == '00' ? '' : $month;
+                               if($active_period[$entry['period']])
+                               {
+                                       $_diff_start = abs($entry['budget']) > 
0 ? $entry['budget'] : $entry['sum_orders'];
+                                       $entry['diff'] = $_diff_start - 
$entry['sum_oblications'] - $entry['actual_cost'];
+                               }
+                               else
+                               {
+                                       $entry['diff'] =  0;
+                               }
+                               $_deviation = $entry['budget'] - 
$entry['actual_cost'];
+                               $deviation = abs($entry['actual_cost']) > 0 ? 
$_deviation : 0;
+                               $entry['deviation_period'] = $deviation;
+                               $entry['deviation_acc'] += $deviation;
+                               $entry['deviation_percent_period'] = 
$deviation/$entry['budget'] * 100;
+                               $entry['deviation_percent_acc'] = 
$entry['deviation_acc']/$entry['budget'] * 100;
+                               $entry['closed'] = 
$closed_period[$entry['period']];
+                               $entry['active'] = 
$active_period[$entry['period']];
+                       }
+                       return $values;
+               }
+
+
+               /**
+               * Delete entries from periodized workorder budget
+               *
+               * @return void
+               */
+
+               function delete_period_from_budget($order_id, $data)
+               {
+                       foreach($data as $entry)
+                       {
+                               $when = explode('_', $entry);
+                               $sql = "DELETE FROM fm_workorder_budget 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
                *
                * @return void
@@ -1662,7 +1940,12 @@
                        $tax = 1+(($config->config_data['fm_tax'])/100);
 
 //                     $this->db->query("UPDATE fm_project_budget SET 
order_amount = 0",__LINE__,__FILE__);
+/**
+ * FIXME: won't work for periodized order that last several years
+ *
+ **/
 
+/*
                        foreach ($orders as $id => $dummy)
                        {
                                $this->db->query("SELECT project_id, 
start_date, combined_cost, budget,calculation,contract_sum,addition,ecodimb 
FROM fm_workorder WHERE id = {$id}",__LINE__,__FILE__);
@@ -1708,9 +1991,9 @@
                                }
 
                //              $this->_update_project_budget($project_id, 
date('Y', $start_date), $periodization_id, $combined_cost);
-                               $this->_update_order_budget($id, date('Y', 
$start_date), $periodization_id, $budget, $combined_cost);
+                               $this->_update_order_budget($id, date('Y', 
$start_date), $periodization_id, $budget, $contract_sum, $combined_cost);
                        }
-
+*/
                        $config = CreateObject('phpgwapi.config','property');
                        $config->read_repository();
 
@@ -1787,19 +2070,25 @@
                **/
                public function update_order_budget($order_id)
                {
-                       $this->db->query("SELECT fm_workorder.start_date, 
periodization_id, fm_workorder.budget, combined_cost"
+                       $this->db->query("SELECT fm_workorder_budget.year, 
periodization_id,"
+                       . " sum(fm_workorder_budget.budget) AS budget, 
sum(fm_workorder_budget.combined_cost) AS combined_cost,"
+                       . " sum(fm_workorder_budget.contract_sum) AS 
contract_sum"
                        . " FROM fm_workorder {$this->join} fm_project ON 
fm_workorder.project_id = fm_project.id"
-                       . " WHERE fm_workorder.id = 
'{$order_id}'",__LINE__,__FILE__);
-                       $this->db->next_record();
-                       $start_date                     = 
$this->db->f('start_date');
-                       $periodization_id       = 
(int)$this->db->f('periodization_id');
-                       $budget                         = 
$this->db->f('budget');
-                       $combined_cost          = $this->db->f('combined_cost');
+                       . " {$this->join} fm_workorder_budget ON 
fm_workorder.id = fm_workorder_budget.order_id"
+                       . " WHERE fm_workorder.id = '{$order_id}' GROUP BY 
year, periodization_id",__LINE__,__FILE__);
 
-                       $this->_update_order_budget($order_id, date('Y', 
$start_date), $periodization_id, $budget,$combined_cost);
+                       while($this->db->next_record())
+                       {
+                               $start_date                     = 
$this->db->f('start_date');
+                               $periodization_id       = 
(int)$this->db->f('periodization_id');
+                               $budget                         = 
$this->db->f('budget');
+                               $contract_sum           = 
$this->db->f('contract_sum');
+                               $combined_cost          = 
$this->db->f('combined_cost');
+                               $this->_update_order_budget($order_id, 
date('Y', $start_date), $periodization_id, $budget, $contract_sum, 
$combined_cost);
+                       }
                }
 
-               private function _update_order_budget($order_id, $year, 
$periodization_id, $budget, $combined_cost = 0)
+               private 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');
@@ -1833,7 +2122,7 @@
                                );
 
                        }
-                       $sql = "DELETE FROM fm_workorder_budget WHERE order_id 
= '{$order_id}'";
+                       $sql = "DELETE FROM fm_workorder_budget WHERE order_id 
= '{$order_id}' AND year = {$year}";
                        $this->db->query($sql,__LINE__,__FILE__);
 
                        foreach ($periodization_outline as $outline)
@@ -1842,18 +2131,22 @@
                                {
                                        $partial_budget = $budget * 
$outline['dividend'] / $outline['divisor'];
                                        $partial_cost = $combined_cost * 
$outline['dividend'] / $outline['divisor'];
+                                       $partial_contract = $contract_sum * 
$outline['dividend'] / $outline['divisor'];
+
                                }
                                else
                                {
                                        $partial_budget = $budget * 
$outline['value'] / 100;
                                        $partial_cost = $combined_cost * 
$outline['value'] / 100;
+                                       $partial_contract = $contract_sum * 
$outline['value'] / 100;
+
                                }
 
-                               $this->_update_budget($order_id, $year, 
$outline['month'], $partial_budget, $partial_cost);
+                               $this->_update_budget($order_id, $year, 
$outline['month'], $partial_budget, $partial_contract, $partial_cost);
                        }
                }
 
-               private function _update_budget($order_id, $year, $month, 
$budget,$combined_cost)
+               private function _update_budget($order_id, $year, $month, 
$budget,$contract_sum,$combined_cost)
                {
                        $month = (int) $month;
                        $budget = (int) $budget;
@@ -1864,7 +2157,7 @@
                        $this->db->query($sql,__LINE__,__FILE__);
                        if ($this->db->next_record())
                        {
-                               $sql = "UPDATE fm_workorder_budget SET budget = 
'{$budget}', combined_cost = '{$combined_cost}', modified_date = {$now} WHERE 
order_id = '{$order_id}' AND year = {$year} AND month = {$month}";
+                               $sql = "UPDATE fm_workorder_budget SET budget = 
'{$budget}', contract_sum ='{$contract_sum}', combined_cost = 
'{$combined_cost}', modified_date = {$now} WHERE order_id = '{$order_id}' AND 
year = {$year} AND month = {$month}";
                                $this->db->query($sql,__LINE__,__FILE__);
                        }
                        else
@@ -1875,6 +2168,7 @@
                                        'year'                          => 
$year,
                                        'month'                         => 
$month,
                                        'budget'                        => 
$budget,
+                                       'contract_sum'          => 
$contract_sum,
                                        'combined_cost'         => 
$combined_cost,
                                        'user_id'                       => 
$this->account,
                                        'entry_date'            => $now,
@@ -1883,6 +2177,8 @@
 
                                $cols = implode(',', array_keys($value_set));
                                $values = 
$this->db->validate_insert(array_values($value_set));
+//_debug_array($values);die();
+
                                $this->db->query("INSERT INTO 
fm_workorder_budget ({$cols}) VALUES ({$values})",__LINE__,__FILE__);
                        }
                }

Modified: branches/Version-1_0-branch/property/inc/class.uibudget.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uibudget.inc.php     
2013-01-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/inc/class.uibudget.inc.php     
2013-01-15 09:25:43 UTC (rev 10673)
@@ -1346,7 +1346,7 @@
                                                        'budget_cost'           
=> number_format($entry['budget_cost'], 0, ',', ' '),
                                                        'obligation_ex'         
=> $entry['obligation'],
                                                        'obligation'            
=> number_format($entry['obligation'], 0, ',', ' '),
-                                                       'link_obligation'       
=> $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiworkorder.index', 'filter'=>'all', 'paid'=>1, 'district_id'=> 
$entry['district_id'], 'b_group'=> $entry['grouping'], 'b_account' 
=>$entry['b_account'], 'start_date'=> $start_date, 'end_date'=> $end_date, 
'ecodimb' => $entry['ecodimb'], 'status_id' => 'all')),
+                                                       'link_obligation'       
=> $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiworkorder.index', 'filter'=>'all', 'paid'=>1, 'district_id'=> 
$entry['district_id'], 'b_group'=> $entry['grouping'], 'b_account' 
=>$entry['b_account'], 'start_date'=> $start_date, 'end_date'=> $end_date, 
'ecodimb' => $entry['ecodimb'], 'status_id' => 'all', 'obligation' => true)),
                                                        'actual_cost_ex'        
=> $entry['actual_cost'],
                                                        'actual_cost'           
=> number_format($entry['actual_cost'], 0, ',', ' '),
                                                        'link_actual_cost'      
=> $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiinvoice.consume', 'district_id'=> $entry['district_id'], 
'b_account_class'=> $entry['grouping'], 'b_account' =>$entry['b_account'],  
'start_date'=> $start_date, 'end_date'=> $end_date, 'ecodimb' => 
$entry['ecodimb'], 'submit_search'=>true)),

Modified: branches/Version-1_0-branch/property/inc/class.uientity.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uientity.inc.php     
2013-01-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/inc/class.uientity.inc.php     
2013-01-15 09:25:43 UTC (rev 10673)
@@ -1784,7 +1784,7 @@
                                                        
$attributes[$i]['attributes'][] = array
                                                        (
                                                                'datatype' => 
'section',
-                                                               'descr' => 
"<H{$group['level']}> {$group['descr']} </H{$group['level']}>",
+                                                               'descr' => '<H' 
. ($group['level'] + 1) .  "> {$group['descr']} </H" . ($group['level'] + 1) . 
'>',
                                                                'level' => 
$group['level'],
                                                        );
                                                        
$attributes[$i]['attributes'] = array_merge($attributes[$i]['attributes'], 
$group['attributes']);

Modified: branches/Version-1_0-branch/property/inc/class.uiproject.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiproject.inc.php    
2013-01-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/inc/class.uiproject.inc.php    
2013-01-15 09:25:43 UTC (rev 10673)
@@ -1711,6 +1711,8 @@
 
                        //---datatable 
settings---------------------------------------------------      
 
+                       $sum_actual_cost = 0;
+                       $sum_oblications = 0;
 
                        if($id)
                        {
@@ -1718,9 +1720,17 @@
                                $lang_delete = lang('Check to delete period');
                                $lang_close = lang('Check to close period');
                                $lang_active = lang('Check to activate period');
+                               $values['sum'] = 0;
 
                                foreach($content_budget as & $b_entry)
                                {
+                                       if($b_entry['active'])
+                                       {
+                                               $sum_actual_cost        += 
$b_entry['actual_cost'];
+                                               $sum_oblications        += 
$b_entry['sum_oblications'];
+                                               $values['sum']          += 
$b_entry['budget'];
+                                       }
+
                                        $checked = $b_entry['closed'] ? 
'checked="checked"' : '';
                                        $checked2 = $b_entry['active'] ? 
'checked="checked"' : '';                                      
 
@@ -1730,20 +1740,24 @@
                                        $b_entry['closed_orig'] = "<input 
type='checkbox' name='values[closed_orig_b_period][]' 
value='{$b_entry['year']}_{$b_entry['month']}' $checked>";
                                        $b_entry['active'] = "<input 
type='checkbox' name='values[active_b_period][]' 
value='{$b_entry['year']}_{$b_entry['month']}' title='{$lang_active}' 
$checked2>";
                                        $b_entry['active_orig'] = "<input 
type='checkbox' name='values[active_orig_b_period][]' 
value='{$b_entry['year']}_{$b_entry['month']}' $checked2>";
-                                       $value_remainder -= 
$b_entry['sum_orders'];
-                                       $value_remainder -= 
$b_entry['actual_cost'];
+                                       
                                }
                                unset($b_entry);
                        }
 
+                       if(isset($values['reserve']) && $values['reserve']!=0)
+                       {
+                               
$reserve_remainder=$values['reserve']-$values['deviation'];
+                               $remainder_percent= 
number_format(($reserve_remainder/$values['reserve'])*100, 2, ',', '');
+                               $values['sum'] = $values['sum'] + 
$values['reserve'];
+                       }
+
+                       $value_remainder = $values['sum'] - $sum_actual_cost - 
$sum_oblications;
                        $values['sum']  = number_format($values['sum'], 0, ',', 
' ');
                        $value_remainder = number_format($value_remainder, 0, 
',', ' ');
 
-
 //_debug_array($content_budget);die();
 
-
-
                        if( isset($values['project_type_id']) && 
$values['project_type_id']==3)
                        {
 

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-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php  
2013-01-15 09:25:43 UTC (rev 10673)
@@ -104,6 +104,7 @@
                        $this->b_account                        = 
$this->bo->b_account;
                        $this->district_id                      = 
$this->bo->district_id;
                        $this->criteria_id                      = 
$this->bo->criteria_id;
+                       $this->obligation                       = 
$this->bo->obligation;
                }
 
                function save_sessiondata()
@@ -246,7 +247,8 @@
                                                'b_group'                       
=> $this->b_group,
                                                'paid'                          
=> $this->paid,
                                                'district_id'           => 
$this->district_id,
-                                               'criteria_id'           => 
$this->criteria_id
+                                               'criteria_id'           => 
$this->criteria_id,
+                                               'obligation'            => 
$this->obligation
 
                                        ));
                                $datatable['config']['allow_allrows'] = false;
@@ -262,6 +264,7 @@
                                        ."b_account:'{$this->b_account}',"
                                        ."ecodimb:'{$this->ecodimb}',"
                                        ."filter:'{$this->filter}',"
+                                       ."obligation:'{$this->obligation}',"
                                        ."status_id:'{$this->status_id}',"
                                        ."second_display:1,"
                                        ."criteria_id:'{$this->criteria_id}',"
@@ -1361,6 +1364,7 @@
                        if($id)
                        {
                                $record_history = 
$this->bo->read_record_history($id);
+//_debug_array($content_budget);die();
                        }
                        else
                        {
@@ -1781,6 +1785,69 @@
                                );
 
 
+
+//---------
+                       $content_budget = $this->bo->get_budget($id);
+
+                       $lang_delete = lang('Check to delete period');
+                       $lang_close = lang('Check to close period');
+                       $lang_active = lang('Check to activate period');
+
+                       foreach($content_budget as & $b_entry)
+                       {
+                               $checked = $b_entry['closed'] ? 
'checked="checked"' : '';
+                               $checked2 = $b_entry['active'] ? 
'checked="checked"' : '';                                      
+
+                               $b_entry['flag_active'] = $b_entry['active'];
+                               $b_entry['delete_period'] = "<input 
type='checkbox' name='values[delete_b_period][]' 
value='{$b_entry['year']}_{$b_entry['month']}' title='{$lang_delete}'>";
+                               $b_entry['closed'] = "<input type='checkbox' 
name='values[closed_b_period][]' value='{$b_entry['year']}_{$b_entry['month']}' 
title='{$lang_close}' $checked>";
+                               $b_entry['closed_orig'] = "<input 
type='checkbox' name='values[closed_orig_b_period][]' 
value='{$b_entry['year']}_{$b_entry['month']}' $checked>";
+                               $b_entry['active'] = "<input type='checkbox' 
name='values[active_b_period][]' value='{$b_entry['year']}_{$b_entry['month']}' 
title='{$lang_active}' $checked2>";
+                               $b_entry['active_orig'] = "<input 
type='checkbox' name='values[active_orig_b_period][]' 
value='{$b_entry['year']}_{$b_entry['month']}' $checked2>";
+                                       
+                       }
+                       unset($b_entry);
+
+
+                       $datavalues[] = array
+                               (
+                                       'name'                                  
=> "5",
+                                       'values'                                
=> json_encode($content_budget),
+                                       'total_records'                 => 
count($content_budget),
+                                       'edit_action'                   => "''",
+                                       'is_paginator'                  => 1,
+                                       'footer'                                
=> 0
+                               );
+
+                       $myColumnDefs[] = array
+                               (
+                                       'name'          => "5",
+                                       '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_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'),
+                                                                               
                                array('key' => 
'deviation_period','label'=>lang('deviation'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+                                                                               
                                array('key' => 
'deviation_acc','label'=>lang('deviation'). '::' . 
lang('accumulated'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+                                                                               
                                array('key' => 
'deviation_percent_period','label'=>lang('deviation') . '::' . 
lang('percent'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
+                                                                               
                                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' => 'flag_active','hidden' => true),
+                                                                               
                                array('key' => 
'delete_period','label'=>lang('Delete'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter')
+                                                                               
                        )
+                                                                               
                )
+
+                               );
+
+//---------
+
+
+
                        $link_claim = '';
                        
if(isset($values['charge_tenant'])?$values['charge_tenant']:'')
                        {
@@ -1818,184 +1885,207 @@
                        
                        $value_coordinator = isset($project['coordinator']) ? 
$GLOBALS['phpgw']->accounts->get($project['coordinator'])->__toString() : 
$GLOBALS['phpgw']->accounts->get($this->account)->__toString();
 
-                       $data = array
+                       $year   = date('Y') -1;
+                       $limit  = $year + 8;
+
+                       while ($year < $limit)
+                       {
+                               $year_list[] = array
                                (
-                                       'mode'                                  
                                => $mode,
-                                       'value_coordinator'                     
                        => $value_coordinator,
-                                       'event_data'                            
                        => $event_data,
-                                       'link_claim'                            
                        => $link_claim,
-                                       'lang_claim'                            
                        => lang('claim'),
-                                       'suppressmeter'                         
                        => isset($config->config_data['project_suppressmeter']) 
&& $config->config_data['project_suppressmeter'] ? 1 : '',
-                                       'suppresscoordination'                  
                => $suppresscoordination,
-                                       'property_js'                           
                        => 
json_encode($GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property2.js"),
-                                       'datatable'                             
                                => $datavalues,
-                                       'myColumnDefs'                          
                        => $myColumnDefs,
-                                       'myButtons'                             
                                => $myButtons,
-                                       'tabs'                                  
                                => 
self::_generate_tabs(array(),array('documents' => $id?false:true, 'history' => 
$id?false:true),$selected_tab),
-                                       'msgbox_data'                           
                        => $GLOBALS['phpgw']->common->msgbox($msgbox_data),
-                                       'value_origin'                          
                        => isset($values['origin']) ? $values['origin'] : '',
-                                       'value_origin_type'                     
                        => isset($origin)?$origin:'',
-                                       'value_origin_id'                       
                        => isset($origin_id)?$origin_id:'',
+                                       'id'    =>  $year,
+                                       'name'  =>  $year
+                               );
+                               $year++;
+                       }
 
-                                       'calculate_action'                      
                        => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiwo_hour.index')),
-                                       'lang_calculate'                        
                        => lang('Calculate Workorder'),
-                                       'lang_calculate_statustext'             
                => lang('Calculate workorder by adding items from vendors 
prizebook or adding general hours'),
+                       if(isset($receipt['error']) && $receipt['error'])
+                       {
+                               $year_list = $this->bocommon->select_list( 
$_POST['values']['budget_year'], $year_list );
+                       }
 
-                                       'send_action'                           
                        => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>'property.uiwo_hour.view',
 'from'=>'index')),
-                                       'lang_send'                             
                                => $this->bo->order_sent_adress ? lang('ReSend 
Workorder') :lang('Send Workorder'),
-                                       'lang_send_statustext'                  
                => lang('send this workorder to vendor'),
+                       $sogeneric              = 
CreateObject('property.sogeneric');
+                       $sogeneric->get_location_info('periodization',false);
+                       $periodization_data     = 
$sogeneric->read_single(array('id' => 
(int)$project['periodization_id']),array());
 
-                                       'project_link'                          
                        => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiproject.edit')),
-                                       'b_group_data'                          
                        => $b_group_data,
-                                       'b_account_data'                        
                        => $b_account_data,
+                       $data = array
+                       (
+                               'periodization_data'                            
        => $periodization_data,
+                               'year_list'                                     
                        => array('options' => $year_list),
+                               'mode'                                          
                        => $mode,
+                               'value_coordinator'                             
                => $value_coordinator,
+                               'event_data'                                    
                => $event_data,
+                               'link_claim'                                    
                => $link_claim,
+                               'lang_claim'                                    
                => lang('claim'),
+                               'suppressmeter'                                 
                => isset($config->config_data['project_suppressmeter']) && 
$config->config_data['project_suppressmeter'] ? 1 : '',
+                               'suppresscoordination'                          
        => $suppresscoordination,
+                               'property_js'                                   
                => 
json_encode($GLOBALS['phpgw_info']['server']['webserver_url']."/property/js/yahoo/property2.js"),
+                               'datatable'                                     
                        => $datavalues,
+                               'myColumnDefs'                                  
                => $myColumnDefs,
+                               'myButtons'                                     
                        => $myButtons,
+                               'tabs'                                          
                        => self::_generate_tabs(array(),array('documents' => 
$id?false:true, 'history' => $id?false:true),$selected_tab),
+                               'msgbox_data'                                   
                => $GLOBALS['phpgw']->common->msgbox($msgbox_data),
+                               'value_origin'                                  
                => isset($values['origin']) ? $values['origin'] : '',
+                               'value_origin_type'                             
                => isset($origin)?$origin:'',
+                               'value_origin_id'                               
                => isset($origin_id)?$origin_id:'',
+                               'calculate_action'                              
                => $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiwo_hour.index')),
+                               'lang_calculate'                                
                => lang('Calculate Workorder'),
+                               'lang_calculate_statustext'                     
        => lang('Calculate workorder by adding items from vendors prizebook or 
adding general hours'),
 
-                                       'lang_start_date_statustext'            
        => lang('Select the estimated end date for the Project'),
-                                       'lang_start_date'                       
                        => lang('Workorder start date'),
-                                       'value_start_date'                      
                        => $values['start_date'],
+                               'send_action'                                   
                => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=>'property.uiwo_hour.view',
 'from'=>'index')),
+                               'lang_send'                                     
                        => $this->bo->order_sent_adress ? lang('ReSend 
Workorder') :lang('Send Workorder'),
+                               'lang_send_statustext'                          
        => lang('send this workorder to vendor'),
 
-                                       'lang_end_date_statustext'              
                => lang('Select the estimated end date for the Project'),
-                                       'lang_end_date'                         
                        => lang('Workorder end date'),
-                                       'value_end_date'                        
                        => $values['end_date'],
+                               'project_link'                                  
                => $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiproject.edit')),
+                               'b_group_data'                                  
                => $b_group_data,
+                               'b_account_data'                                
                => $b_account_data,
 
-                                       'lang_copy_workorder'                   
                => lang('Copy workorder ?'),
-                                       'lang_copy_workorder_statustext'        
        => lang('Choose Copy Workorder to copy this workorder to a new 
workorder'),
+                               'lang_start_date_statustext'                    
=> lang('Select the estimated end date for the Project'),
+                               'lang_start_date'                               
                => lang('Workorder start date'),
+                               'value_start_date'                              
                => $values['start_date'],
 
-                                       'lang_contact_phone'                    
                => lang('Contact phone'),
-                                       'contact_phone'                         
                        => 
(isset($project['contact_phone'])?$project['contact_phone']:''),
+                               'lang_end_date_statustext'                      
        => lang('Select the estimated end date for the Project'),
+                               'lang_end_date'                                 
                => lang('Workorder end date'),
+                               'value_end_date'                                
                => $values['end_date'],
 
-                                       'lang_charge_tenant'                    
                => lang('Charge tenant'),
-                                       'lang_charge_tenant_statustext'         
        => lang('Choose charge tenant if the tenant i to pay for this project'),
-                                       'charge_tenant'                         
                        => 
(isset($values['charge_tenant'])?$values['charge_tenant']:''),
+                               'lang_copy_workorder'                           
        => lang('Copy workorder ?'),
+                               'lang_copy_workorder_statustext'                
=> lang('Choose Copy Workorder to copy this workorder to a new workorder'),
 
-                                       'lang_power_meter'                      
                        => lang('Power meter'),
-                                       'lang_power_meter_statustext'           
        => lang('Enter the power meter'),
-                                       'value_power_meter'                     
                        => 
(isset($project['power_meter'])?$project['power_meter']:''),
+                               'lang_contact_phone'                            
        => lang('Contact phone'),
+                               'contact_phone'                                 
                => 
(isset($project['contact_phone'])?$project['contact_phone']:''),
 
-                                       'lang_addition_rs'                      
                        => lang('Rig addition'),
-                                       'lang_addition_rs_statustext'           
        => lang('Enter any round sum addition per order'),
-                                       'value_addition_rs'                     
                        => 
(isset($values['addition_rs'])?$values['addition_rs']:''),
+                               'lang_charge_tenant'                            
        => lang('Charge tenant'),
+                               'lang_charge_tenant_statustext'                 
=> lang('Choose charge tenant if the tenant i to pay for this project'),
+                               'charge_tenant'                                 
                => 
(isset($values['charge_tenant'])?$values['charge_tenant']:''),
 
-                                       'lang_addition_percentage'              
                => lang('Percentage addition'),
-                                       'lang_addition_percentage_statustext'   
=> lang('Enter any persentage addition per unit'),
-                                       'value_addition_percentage'             
                => 
(isset($values['addition_percentage'])?$values['addition_percentage']:''),
+                               'lang_power_meter'                              
                => lang('Power meter'),
+                               'lang_power_meter_statustext'                   
=> lang('Enter the power meter'),
+                               'value_power_meter'                             
                => (isset($project['power_meter'])?$project['power_meter']:''),
 
-                                       'lang_budget'                           
                        => lang('Budget'),
-                                       'value_budget'                          
                        => (isset($values['budget'])?$values['budget']:''),
-                                       'lang_budget_statustext'                
                => lang('Enter the budget'),
+                               'lang_addition_rs'                              
                => lang('Rig addition'),
+                               'lang_addition_rs_statustext'                   
=> lang('Enter any round sum addition per order'),
+                               'value_addition_rs'                             
                => (isset($values['addition_rs'])?$values['addition_rs']:''),
 
-                                       'lang_incl_tax'                         
                        => lang('incl tax'),
-                                       'lang_calculation'                      
                        => lang('Calculation'),
-                                       'value_calculation'                     
                        => 
(isset($values['calculation'])?$values['calculation']:''),
-                                       'value_sum_estimated_cost'              
                => $sum_estimated_cost,
+                               'lang_addition_percentage'                      
        => lang('Percentage addition'),
+                               'lang_addition_percentage_statustext'   => 
lang('Enter any persentage addition per unit'),
+                               'value_addition_percentage'                     
        => 
(isset($values['addition_percentage'])?$values['addition_percentage']:''),
+
+                               'lang_budget'                                   
                => lang('Budget'),
+                               'value_budget'                                  
                => isset($receipt['error']) && $receipt['error'] ? 
$_POST['values']['budget'] : '',
+                               'lang_budget_statustext'                        
        => lang('Enter the budget'),
+
+                               'lang_incl_tax'                                 
                => lang('incl tax'),
+                               'lang_calculation'                              
                => lang('Calculation'),
+                               'value_calculation'                             
                => (isset($values['calculation'])?$values['calculation']:''),
+                               'value_sum_estimated_cost'                      
        => $sum_estimated_cost,
                                        
-                                       'value_contract_sum'                    
                => $values['contract_sum'],
+                               'value_contract_sum'                            
        => isset($receipt['error']) && $receipt['error'] ? 
$_POST['values']['contract_sum'] : '',
 
-                                       'actual_cost'                           
                        => 
(isset($values['actual_cost'])?$values['actual_cost']:''),
-                                       'lang_actual_cost'                      
                        => lang('Actual cost'),
-                                       'ecodimb_data'                          
                        => $ecodimb_data,
-                                       'vendor_data'                           
                        => $vendor_data,
-                                       'location_data'                         
                        => $location_data,
-                                       'location_template_type'                
                => $location_template_type,
-                                       'form_action'                           
                        => $mode == 'edit' ? 
$GLOBALS['phpgw']->link('/index.php',$link_data) : 
$GLOBALS['phpgw']->link('/home.php'),//avoid accidents
-                                       'done_action'                           
                        => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiworkorder.index')),
-                                       'lang_year'                             
                                => lang('Year'),
-                                       'lang_save'                             
                                => lang('save'),
-                                       'lang_done'                             
                                => lang('done'),
-                                       'lang_title'                            
                        => lang('Title'),
-                                       'value_title'                           
                        => $values['title'],
-                                       'lang_project_name'                     
                        => lang('Project name'),
-                                       'value_project_name'                    
                => (isset($project['name'])?$project['name']:''),
+                               'actual_cost'                                   
                => (isset($values['actual_cost'])?$values['actual_cost']:''),
+                               'lang_actual_cost'                              
                => lang('Actual cost'),
+                               'ecodimb_data'                                  
                => $ecodimb_data,
+                               'vendor_data'                                   
                => $vendor_data,
+                               'location_data'                                 
                => $location_data,
+                               'location_template_type'                        
        => $location_template_type,
+                               'form_action'                                   
                => $mode == 'edit' ? 
$GLOBALS['phpgw']->link('/index.php',$link_data) : 
$GLOBALS['phpgw']->link('/home.php'),//avoid accidents
+                               'done_action'                                   
                => $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiworkorder.index')),
+                               'lang_year'                                     
                        => lang('Year'),
+                               'lang_save'                                     
                        => lang('save'),
+                               'lang_done'                                     
                        => lang('done'),
+                               'lang_title'                                    
                => lang('Title'),
+                               'value_title'                                   
                => $values['title'],
+                               'lang_project_name'                             
                => lang('Project name'),
+                               'value_project_name'                            
        => (isset($project['name'])?$project['name']:''),
 
-                                       'lang_project_id'                       
                        => lang('Project ID'),
-                                       'value_project_id'                      
                        => $values['project_id'],
+                               'lang_project_id'                               
                => lang('Project ID'),
+                               'value_project_id'                              
                => $values['project_id'],
 
-                                       'lang_workorder_id'                     
                        => lang('Workorder ID'),
-                                       'value_workorder_id'                    
                => (isset($id)?$id:''),
+                               'lang_workorder_id'                             
                => lang('Workorder ID'),
+                               'value_workorder_id'                            
        => (isset($id)?$id:''),
 
-                                       'lang_title_statustext'                 
                => lang('Enter Workorder title'),
+                               'lang_title_statustext'                         
        => lang('Enter Workorder title'),
 
-                                       'lang_other_branch'                     
                        => lang('Other branch'),
-                                       'lang_other_branch_statustext'          
        => lang('Enter other branch if not found in the list'),
-                                       'value_other_branch'                    
                => 
(isset($project['other_branch'])?$project['other_branch']:''),
+                               'lang_other_branch'                             
                => lang('Other branch'),
+                               'lang_other_branch_statustext'                  
=> lang('Enter other branch if not found in the list'),
+                               'value_other_branch'                            
        => (isset($project['other_branch'])?$project['other_branch']:''),
 
-                                       'lang_descr_statustext'                 
                => lang('Enter a short description of the workorder'),
-                                       'lang_descr'                            
                        => lang('Description'),
-                                       'value_descr'                           
                        => $values['descr'],
+                               'lang_descr_statustext'                         
        => lang('Enter a short description of the workorder'),
+                               'lang_descr'                                    
                => lang('Description'),
+                               'value_descr'                                   
                => $values['descr'],
 
-                                       'lang_remark_statustext'                
                => lang('Enter a remark to add to the history of the order'),
-                                       'lang_remark'                           
                        => lang('remark'),
-                                       'value_remark'                          
                        => (isset($values['remark'])?$values['remark']:''),
+                               'lang_remark_statustext'                        
        => lang('Enter a remark to add to the history of the order'),
+                               'lang_remark'                                   
                => lang('remark'),
+                               'value_remark'                                  
                => (isset($values['remark'])?$values['remark']:''),
 
-                                       'lang_done_statustext'                  
                => lang('Back to the list'),
-                                       'lang_save_statustext'                  
                => lang('Save the workorder'),
-                                       //      'lang_no_cat'                   
                                => lang('Select category'),
-                                       //      'lang_cat_statustext'           
                        => lang('Select the category the project belongs to. To 
do not use a category select NO CATEGORY'),
-                                       //      'select_name'                   
                                => 'values[cat_id]',
-                                       //      'value_cat_id'                  
                                => 
(isset($values['cat_id'])?$values['cat_id']:''),
-                                       //      'cat_list'                      
                                        => $categories['cat_list'],
+                               'lang_done_statustext'                          
        => lang('Back to the list'),
+                               'lang_save_statustext'                          
        => lang('Save the workorder'),
+                               //      'lang_no_cat'                           
                        => lang('Select category'),
+                               //      'lang_cat_statustext'                   
                => lang('Select the category the project belongs to. To do not 
use a category select NO CATEGORY'),
+                               //      'select_name'                           
                        => 'values[cat_id]',
+                               //      'value_cat_id'                          
                        => (isset($values['cat_id'])?$values['cat_id']:''),
+                               //      'cat_list'                              
                                => $categories['cat_list'],
 
-                                       'lang_cat_sub'                          
                        => lang('category'),
-                                       'cat_sub_list'                          
                        => $this->bocommon->select_list($values['cat_id'] ? 
$values['cat_id']: $project['cat_id'], $cat_sub),
-                                       'cat_sub_name'                          
                        => 'values[cat_id]',
-                                       'lang_cat_sub_statustext'               
                => lang('select sub category'),
+                               'lang_cat_sub'                                  
                => lang('category'),
+                               'cat_sub_list'                                  
                => $this->bocommon->select_list($values['cat_id'] ? 
$values['cat_id']: $project['cat_id'], $cat_sub),
+                               'cat_sub_name'                                  
                => 'values[cat_id]',
+                               'lang_cat_sub_statustext'                       
        => lang('select sub category'),
 
-                                       'sum_workorder_budget'                  
                => 
(isset($values['sum_workorder_budget'])?$values['sum_workorder_budget']:''),
-                                       'workorder_budget'                      
                        => 
(isset($values['workorder_budget'])?$values['workorder_budget']:''),
+                               'sum_workorder_budget'                          
        => 
(isset($values['sum_workorder_budget'])?$values['sum_workorder_budget']:''),
+                               'workorder_budget'                              
                => 
(isset($values['workorder_budget'])?$values['workorder_budget']:''),
 
-                                       'lang_coordinator'                      
                        => lang('Coordinator'),
-                                       'lang_sum'                              
                                => lang('Sum'),
-                                       'select_user_name'                      
                        => 'values[coordinator]',
-                                       'user_list'                             
                                => array('options' => $user_list),
-                                       'status_list'                           
                        => 
$this->bo->select_status_list('select',$values['status']),
-                                       'status_name'                           
                        => 'values[status]',
-                                       'lang_no_status'                        
                        => lang('Select status'),
-                                       'lang_status'                           
                        => lang('Status'),
-                                       'lang_status_statustext'                
                => lang('What is the current status of this workorder ?'),
-                                       'lang_confirm_status'                   
                => lang('Confirm status'),
-                                       'lang_confirm_statustext'               
                => lang('Confirm status to the history'),
+                               'lang_coordinator'                              
                => lang('Coordinator'),
+                               'lang_sum'                                      
                        => lang('Sum'),
+                               'select_user_name'                              
                => 'values[coordinator]',
+                               'user_list'                                     
                        => array('options' => $user_list),
+                               'status_list'                                   
                => $this->bo->select_status_list('select',$values['status']),
+                               'status_name'                                   
                => 'values[status]',
+                               'lang_no_status'                                
                => lang('Select status'),
+                               'lang_status'                                   
                => lang('Status'),
+                               'lang_status_statustext'                        
        => lang('What is the current status of this workorder ?'),
+                               'lang_confirm_status'                           
        => lang('Confirm status'),
+                               'lang_confirm_statustext'                       
        => lang('Confirm status to the history'),
 
-                                       'branch_list'                           
                        => 
$boproject->select_branch_p_list($project['project_id']),
-                                       'lang_branch'                           
                        => lang('branch'),
-                                       'lang_branch_statustext'                
                => lang('Select the branches for this project'),
+                               'branch_list'                                   
                => $boproject->select_branch_p_list($project['project_id']),
+                               'lang_branch'                                   
                => lang('branch'),
+                               'lang_branch_statustext'                        
        => lang('Select the branches for this project'),
 
-                                       'key_responsible_list'                  
                => $boproject->select_branch_list($project['key_responsible']),
-                                       'lang_key_responsible'                  
                => lang('key responsible'),
+                               'key_responsible_list'                          
        => $boproject->select_branch_list($project['key_responsible']),
+                               'lang_key_responsible'                          
        => lang('key responsible'),
 
-                                       'key_fetch_list'                        
                        => 
$this->bo->select_key_location_list((isset($values['key_fetch'])?$values['key_fetch']:'')),
-                                       'lang_no_key_fetch'                     
                        => lang('Where to fetch the key'),
-                                       'lang_key_fetch'                        
                        => lang('key fetch location'),
-                                       'lang_key_fetch_statustext'             
                => lang('Select where to fetch the key'),
+                               'key_fetch_list'                                
                => 
$this->bo->select_key_location_list((isset($values['key_fetch'])?$values['key_fetch']:'')),
+                               'lang_no_key_fetch'                             
                => lang('Where to fetch the key'),
+                               'lang_key_fetch'                                
                => lang('key fetch location'),
+                               'lang_key_fetch_statustext'                     
        => lang('Select where to fetch the key'),
 
-                                       'key_deliver_list'                      
                        => 
$this->bo->select_key_location_list((isset($values['key_deliver'])?$values['key_deliver']:'')),
-                                       'lang_no_key_deliver'                   
                => lang('Where to deliver the key'),
-                                       'lang_key_deliver'                      
                        => lang('key deliver location'),
-                                       'lang_key_deliver_statustext'           
        => lang('Select where to deliver the key'),
+                               'key_deliver_list'                              
                => 
$this->bo->select_key_location_list((isset($values['key_deliver'])?$values['key_deliver']:'')),
+                               'lang_no_key_deliver'                           
        => lang('Where to deliver the key'),
+                               'lang_key_deliver'                              
                => lang('key deliver location'),
+                               'lang_key_deliver_statustext'                   
=> lang('Select where to deliver the key'),
 
-                                       'value_approved'                        
                        => isset($values['approved']) ? $values['approved'] : 
'',
-                                       'need_approval'                         
                        => $need_approval,
-                                       'lang_ask_approval'                     
                        => lang('Ask for approval'),
-                                       'lang_ask_approval_statustext'          
        => lang('Check this to send a mail to your supervisor for approval'),
-                                       'value_approval_mail_address'           
        => $supervisor_email,
-                                       'currency'                              
                                => 
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
-                                       'link_view_file'                        
                        => 
$GLOBALS['phpgw']->link('/index.php',$link_file_data),
-                                       'link_to_files'                         
                        => 
(isset($config->config_data['files_url'])?$config->config_data['files_url']:''),
-                                       'files'                                 
                                => isset($values['files'])?$values['files']:'',
-                                       'lang_files'                            
                        => lang('files'),
-                                       'lang_filename'                         
                        => lang('Filename'),
-                                       'lang_file_action'                      
                        => lang('Delete file'),
-                                       'lang_view_file_statustext'             
                => lang('click to view file'),
-                                       'lang_file_action_statustext'           
        => lang('Check to delete file'),
-                                       'lang_upload_file'                      
                        => lang('Upload file'),
-                                       'lang_file_statustext'                  
                => lang('Select file to upload'),
-                                       'value_billable_hours'                  
                => $values['billable_hours'],
-                                       'base_java_url'                         
                        => 
"{menuaction:'property.bocommon.get_vendor_email',phpgw_return_as:'json'}",
-                                       'base_java_notify_url'                  
                => 
"{menuaction:'property.notify.update_data',location_id:{$location_id},location_item_id:'{$id}'}",
-                                       'edit_action'                           
                        => 
$GLOBALS['phpgw']->link('/index.php',array('menuaction' => 
'property.uiworkorder.edit', 'id' => $id)),
-                                       'lang_edit_statustext'                  
                => lang('Edit this entry '),
-                                       'lang_edit'                             
                                => lang('Edit'),
-                                       'value_extra_mail_address'              
                => $value_extra_mail_address,
-                                       'lean'                                  
                                => $_lean ? 1 : 0
-                               );
+                               'value_approved'                                
                => isset($values['approved']) ? $values['approved'] : '',
+                               'need_approval'                                 
                => $need_approval,
+                               'lang_ask_approval'                             
                => lang('Ask for approval'),
+                               'lang_ask_approval_statustext'                  
=> lang('Check this to send a mail to your supervisor for approval'),
+                               'value_approval_mail_address'                   
=> $supervisor_email,
+                               'currency'                                      
                        => 
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
+                               'link_view_file'                                
                => $GLOBALS['phpgw']->link('/index.php',$link_file_data),
+                               'link_to_files'                                 
                => 
(isset($config->config_data['files_url'])?$config->config_data['files_url']:''),
+                               'files'                                         
                        => isset($values['files'])?$values['files']:'',
+                               'lang_files'                                    
                => lang('files'),
+                               'lang_filename'                                 
                => lang('Filename'),
+                               'lang_file_action'                              
                => lang('Delete file'),
+                               'lang_view_file_statustext'                     
        => lang('click to view file'),
+                               'lang_file_action_statustext'                   
=> lang('Check to delete file'),
+                               'lang_upload_file'                              
                => lang('Upload file'),
+                               'lang_file_statustext'                          
        => lang('Select file to upload'),
+                               'value_billable_hours'                          
        => $values['billable_hours'],
+                               'base_java_url'                                 
                => 
"{menuaction:'property.bocommon.get_vendor_email',phpgw_return_as:'json'}",
+                               'base_java_notify_url'                          
        => 
"{menuaction:'property.notify.update_data',location_id:{$location_id},location_item_id:'{$id}'}",
+                               'edit_action'                                   
                => $GLOBALS['phpgw']->link('/index.php',array('menuaction' => 
'property.uiworkorder.edit', 'id' => $id)),
+                               'lang_edit_statustext'                          
        => lang('Edit this entry '),
+                               'lang_edit'                                     
                        => lang('Edit'),
+                               'value_extra_mail_address'                      
        => $value_extra_mail_address,
+                               'lean'                                          
                        => $_lean ? 1 : 0
+                       );
 
                        $appname                                                
= lang('Workorder');
 

Modified: 
branches/Version-1_0-branch/property/inc/export/default/El_anlegg_LRS_2
===================================================================
--- branches/Version-1_0-branch/property/inc/export/default/El_anlegg_LRS_2     
2013-01-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/inc/export/default/El_anlegg_LRS_2     
2013-01-15 09:25:43 UTC (rev 10673)
@@ -70,12 +70,12 @@
                        while ($this->db->next_record())
                        {
                                xmlwriter_start_element($memory,'Maalepunkt');
-                                       xmlwriter_write_element($memory,'ID', 
'TJ'); 
-                                       
xmlwriter_write_element($memory,'Verdi', 
substr($this->db->f('maalepunkt_id'),-8)); 
-                                       
xmlwriter_write_element($memory,'Firma', 'BB'); 
-                                       
xmlwriter_write_element($memory,'Beskrivelse', $this->db->f('address')); 
-                                       
xmlwriter_write_element($memory,'PeriodeFra', $PeriodFrom); 
-                                       
xmlwriter_write_element($memory,'PeriodeTil', $PeriodTo); 
+                                       xmlwriter_write_element($memory,'ID', 
'TJ');
+                                       
xmlwriter_write_element($memory,'Verdi', 
substr($this->db->f('maalepunkt_id'),-8));
+                                       
xmlwriter_write_element($memory,'Beskrivelse', $this->db->f('address'));
+                                       
xmlwriter_write_element($memory,'Firma', 'BB');
+                                       
xmlwriter_write_element($memory,'PeriodeFra', $PeriodFrom);
+                                       
xmlwriter_write_element($memory,'PeriodeTil', $PeriodTo);
                                        
xmlwriter_write_element($memory,'Status', 'N');
                                    
xmlwriter_start_element($memory,'BegrepsLister');
                                                
xmlwriter_start_element($memory,'BegrepsListe');
@@ -114,12 +114,12 @@
                                                                
xmlwriter_write_comment($memory , 'Fagkode' );
                                                                
xmlwriter_write_element($memory,'ID', 'B1');
                                                                
xmlwriter_write_element($memory,'Verdi', '999');
-                                                       
xmlwriter_end_element($memory); 
+                                                       
xmlwriter_end_element($memory);
                                                        
xmlwriter_start_element($memory,'Begrep');
                                                                
xmlwriter_write_comment($memory , 'AV' );
                                                                
xmlwriter_write_element($memory,'ID', 'AV');
                                                                
xmlwriter_write_element($memory,'Verdi', '');
-                                                       
xmlwriter_end_element($memory); 
+                                                       
xmlwriter_end_element($memory);
                                                xmlwriter_end_element($memory);
                                        xmlwriter_end_element($memory);
                                xmlwriter_end_element($memory);
@@ -137,7 +137,7 @@
                protected function log_end()
                {
                        $msgbox_data =  
$GLOBALS['phpgw']->common->msgbox_data($this->receipt);
-       
+
                        $insert_values= array
                        (
                                0,
@@ -325,7 +325,7 @@
                        return  $transfer_ok;
                }
 
-               protected function phpftp_connect() 
+               protected function phpftp_connect()
                {
                        $server                         = 
$this->config->config_data['common']['host'];
                        $user                           = 
$this->config->config_data['common']['user'];

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-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/js/yahoo/workorder.edit.js     
2013-01-15 09:25:43 UTC (rev 10673)
@@ -2,6 +2,9 @@
 var  myPaginator_1, myDataTable_1;
 var  myPaginator_2, myDataTable_2;
 var  myPaginator_3, myDataTable_3;
+var  myPaginator_4, myDataTable_4;
+var  myPaginator_5, myDataTable_5;
+
 var lightbox;
 var vendor_id;
 
@@ -27,6 +30,20 @@
                }
        };
 
+       var FormatterAmount0 = function(elCell, oRecord, oColumn, oData)
+       {
+               var amount = YAHOO.util.Number.format(oData, {decimalPlaces:0, 
decimalSeparator:",", thousandsSeparator:" "});
+               elCell.innerHTML = "<div align=\"right\">"+amount+"</div>";
+       }       
+       var FormatterAmount2 = function(elCell, oRecord, oColumn, oData)
+       {
+               var amount = YAHOO.util.Number.format(oData, {decimalPlaces:2, 
decimalSeparator:",", thousandsSeparator:" "});
+               elCell.innerHTML = "<div align=\"right\">"+amount+"</div>";
+       }       
+       var FormatterCenter = function(elCell, oRecord, oColumn, oData)
+       {
+               elCell.innerHTML = "<center>"+oData+"</center>";
+       }
 
        var oArgs_invoicehandler_2 = {menuaction:'property.uiinvoice2.index'};
        var sUrl_invoicehandler_2 = phpGWLink('index.php', 
oArgs_invoicehandler_2);
@@ -58,6 +75,8 @@
        this.myParticularRenderEvent = function()
        {
                this.addFooterDatatable(myPaginator_2,myDataTable_2);
+               this.addFooterDatatable5(myPaginator_5,myDataTable_5);
+
        }
 
        this.showlightbox_manual_invoide = function(workorder_id)
@@ -100,7 +119,7 @@
 
                if(typeof(tableYUI)=='undefined')
                {
-                       tableYUI = 
YAHOO.util.Dom.getElementsByClassName("yui-dt-data","tbody")[1].parentNode;
+                       tableYUI = 
YAHOO.util.Dom.getElementsByClassName("yui-dt-data","tbody")[2].parentNode;
                        tableYUI.setAttribute("id","tableYUI");
                }
                else
@@ -122,6 +141,66 @@
                myfoot.appendChild(newTR);
        }
 
+       this.getTotalSum_active = 
function(name_column,round,paginator,datatable)
+       {
+               if(!paginator.getPageRecords())
+               {
+                       return '0,00';
+               }
+               begin = end = 0;
+               end = datatable.getRecordSet().getLength();
+
+               tmp_sum = 0;
+               for(i = begin; i < end; i++)
+               {
+                       
if(datatable.getRecordSet().getRecords(0)[i].getData('flag_active'))
+                       {
+                               tmp_sum = tmp_sum + 
parseFloat(datatable.getRecordSet().getRecords(0)[i].getData(name_column));
+                       }
+               }
+
+               return tmp_sum = YAHOO.util.Number.format(tmp_sum, 
{decimalPlaces:round, decimalSeparator:",", thousandsSeparator:" "});
+       }
+
+
+       this.addFooterDatatable5 = function(paginator,datatable)
+       {
+               tmp_sum1 = getTotalSum_active('budget',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);
+               tmp_sum6 = 
getTotalSum_active('deviation',0,paginator,datatable);
+
+               if(typeof(tableYUI0)=='undefined')
+               {
+                       tableYUI0 = 
YAHOO.util.Dom.getElementsByClassName("yui-dt-data","tbody")[1].parentNode;
+                       tableYUI0.setAttribute("id","tableYUI0");
+               }
+               else
+               {
+                       tableYUI0.deleteTFoot();
+               }
+
+               //Create ROW
+               newTR = document.createElement('tr');
+
+               td_sum('Sum');
+               td_empty(1);
+               td_sum(tmp_sum1);
+//             td_sum(tmp_sum2);
+               td_sum(tmp_sum3);
+               td_sum(tmp_sum4);
+               td_sum(tmp_sum5);
+               td_sum(tmp_sum6);
+               td_empty(9);
+
+               myfoot = tableYUI0.createTFoot();
+               myfoot.setAttribute("id","myfoot");
+               myfoot.appendChild(newTR);
+       }
+
+
  
/********************************************************************************/
 
 
/********************************************************************************/
     

Modified: branches/Version-1_0-branch/property/setup/setup.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/setup.inc.php    2013-01-15 
08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/setup/setup.inc.php    2013-01-15 
09:25:43 UTC (rev 10673)
@@ -12,7 +12,7 @@
        */
 
        $setup_info['property']['name']                 = 'property';
-       $setup_info['property']['version']              = '0.9.17.661';
+       $setup_info['property']['version']              = '0.9.17.662';
        $setup_info['property']['app_order']    = 8;
        $setup_info['property']['enable']               = 1;
        $setup_info['property']['app_group']    = 'office';

Modified: branches/Version-1_0-branch/property/setup/tables_current.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/tables_current.inc.php   
2013-01-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/setup/tables_current.inc.php   
2013-01-15 09:25:43 UTC (rev 10673)
@@ -556,7 +556,9 @@
                                'year' => array('type' => 'int','precision' => 
4,'nullable' => False),
                                'month' => array('type' => 'int','precision' => 
2,'nullable' => False,'default' => 0),
                                'budget' => array('type' => 
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' => 
'0.00'),
+                               'contract_sum' => array('type' => 
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' => 
'0.00'),
                                'combined_cost' => array('type' => 
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' => 
'0.00'),
+                               'active' => array('type' => 'int','precision' 
=> 2,'nullable' => True),
                                'user_id' => array('type' => 'int','precision' 
=> 4,'nullable' => True),
                                'entry_date' => array('type' => 
'int','precision' => 4,'nullable' => True),
                                'modified_date' => array('type' => 
'int','precision' => 4,'nullable' => True)

Modified: branches/Version-1_0-branch/property/setup/tables_update.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/tables_update.inc.php    
2013-01-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/setup/tables_update.inc.php    
2013-01-15 09:25:43 UTC (rev 10673)
@@ -7215,3 +7215,39 @@
                        return $GLOBALS['setup_info']['property']['currentver'];
                }
        }
+
+       /**
+       * Update property version from 0.9.17.661 to 0.9.17.662
+       * Add year and active-flag to project_buffer_budget
+       */
+       $test[] = '0.9.17.661';
+       function property_upgrade0_9_17_661()
+       {
+               $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_workorder_budget','active',array(
+                       'type'                  => 'int',
+                       'precision'             => 2,
+                       'nullable'              => true,
+                       'default'               => 1
+                       )
+               );
+
+               
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_workorder_budget','contract_sum', 
array(
+                       'type'          => 'decimal',
+                       'precision' => '20',
+                       'scale'         => '2',
+                       'nullable'      => True,
+                       'default'       => '0.00'
+                       )
+               );
+
+               $GLOBALS['phpgw_setup']->oProc->query('UPDATE 
fm_workorder_budget SET active = 1',__LINE__,__FILE__);
+
+               if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+               {
+                       $GLOBALS['setup_info']['property']['currentver'] = 
'0.9.17.662';
+                       return $GLOBALS['setup_info']['property']['currentver'];
+               }
+       }

Modified: 
branches/Version-1_0-branch/property/templates/base/attributes_form.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/attributes_form.xsl     
2013-01-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/templates/base/attributes_form.xsl     
2013-01-15 09:25:43 UTC (rev 10673)
@@ -6,8 +6,8 @@
        <!-- New template-->
        <xsl:template xmlns:php="http://php.net/xsl"; name="attributes_values">
                <xsl:for-each select="attributes_group">
-                       <div id="{link}">
-                               <table cellpadding="2" cellspacing="2" 
width="100%" align="center" border="0">
+                       <div id="{link}" class="fields_wrp">
+                               <table style="float:left;">
                                        <xsl:apply-templates 
select="attributes"/>
                                </table>
                        </div>
@@ -25,7 +25,7 @@
                <xsl:choose>
                        <xsl:when test="datatype='section'">
                                <tr>
-                                       <td colspan='2'>
+                                       <td  colspan="2">
                                                <xsl:value-of select="descr" 
disable-output-escaping="yes"/>                            
                                        </td>
                                </tr>
@@ -35,7 +35,7 @@
                <tr>
                        <xsl:choose>
                                <xsl:when test="not(hide_row)">
-                                       <td align="left" width="19%" 
valign="top" title="{$statustext}">
+                                       <td  class="first" 
title="{$statustext}">
                                                <label>
                                                <xsl:choose>
                                                        <xsl:when 
test="helpmsg=1">
@@ -72,7 +72,7 @@
                                </xsl:when>
                        </xsl:choose>
 
-                       <td align="left">
+                       <td>
                                <xsl:choose>
                                        <xsl:when test="name!=''">
                                                <input type="hidden" 
name="values_attribute[{counter}][name]" value="{name}"/>
@@ -120,7 +120,7 @@
                                                                </select>
                                                        </xsl:when>
                                                        <xsl:when 
test="datatype='AB'">
-                                                               <table>
+                                                               <table 
style="float:left;">
                                                                        <tr>
                                                                                
<td>
                                                                                
        <xsl:variable name="contact_name">
@@ -468,7 +468,7 @@
                                                                </table>
                                                        </xsl:when>
                                                        <xsl:when 
test="datatype='T'">
-                                                               <textarea 
id="id_{name}" cols="{//textareacols}" rows="{//textarearows}" 
name="values_attribute[{counter}][value]">
+                                                               <textarea 
id="id_{name}"  name="values_attribute[{counter}][value]">
                                                                        
<xsl:choose>
                                                                                
<xsl:when test="disabled!=''">
                                                                                
        <xsl:attribute name="disabled">

Modified: branches/Version-1_0-branch/property/templates/base/css/base.css
===================================================================
--- branches/Version-1_0-branch/property/templates/base/css/base.css    
2013-01-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/templates/base/css/base.css    
2013-01-15 09:25:43 UTC (rev 10673)
@@ -2,117 +2,117 @@
  * Conflicts with portico
 body, div, input, p, select, textarea
 {
-       font-family: Verdana, Arial, Helvetica, sans-serif;
-       font-size: 11px;
+  font-family: Verdana, Arial, Helvetica, sans-serif;
+  font-size: 11px;
 }
 */
 a
 {
-       text-decoration: none;
+  text-decoration: none;
 }
 
 a:hover, a:active
 {
-       text-decoration: underline;
+  text-decoration: underline;
 }
 
 img
 {
-       border: 0px;
+  border: 0px;
 }
 
 
 textarea
 {
-/*     white-space: normal;*/
+  /*   white-space: normal;*/
 }
 
 br
 {
-       clear: left;
+  clear: left;
 }
 
 thead
 {
-       background-color: #d3dce3;
-       font-weight: bold;
-       text-align: center;
+  background-color: #d3dce3;
+  font-weight: bold;
+  text-align: center;
 }
 
 .button_group
 {
-       text-align: center;
+  text-align: center;
 }
 
 .link_group
 {
-       text-align: center;
+  text-align: center;
 }
 .msg
 {
-       color: #f00;
-       font-weight: bold;
-       text-align: center;
+  color: #f00;
+  font-weight: bold;
+  text-align: center;
 }
 .yui-dt .yui-dt-hidden
 {
-       border-right:0px solid #ff0 !important;
+  border-right:0px solid #ff0 !important;
 }
 .yui-tt .bd
 {
-       background-color:#fffbeb !important;
-       border-color:#D4C237 #A6982B #A6982B;
-       border-width:0px !important;
-       color:#000000 !important;
-       left:0 !important;
-       padding:0 !important;
-       font-family: tahoma !important;
-       font-size: 11px !important;
+  background-color:#fffbeb !important;
+  border-color:#D4C237 #A6982B #A6982B;
+  border-width:0px !important;
+  color:#000000 !important;
+  left:0 !important;
+  padding:0 !important;
+  font-family: tahoma !important;
+  font-size: 11px !important;
 }
 .tooltip-table
 {
-       width:200px !important;
+  width:200px !important;
 }
 .tooltip
 {
-       background-color:#0066cc !important;
-       color:#FFFFFF !important;
-       font-weight: bold !important;
-       font-family: tahoma !important;
-       font-size: 11px !important;
+  background-color:#0066cc !important;
+  color:#FFFFFF !important;
+  font-weight: bold !important;
+  font-family: tahoma !important;
+  font-size: 11px !important;
 }
 .nolink a
 {
-       color:#FFFFFF !important;
-       text-decoration: none !important;
+  color:#FFFFFF !important;
+  text-decoration: none !important;
 }
 .nolink a visited
 {
-       color:#FFFFFF !important;
-       text-decoration: none !important;
+  color:#FFFFFF !important;
+  text-decoration: none !important;
 }
 
 #curtain {
-    background: none repeat scroll 0 0 #000000;
-    display: none;
-    height: 100%;
-    left: 0;
-    opacity: 0.5;
-    position: absolute;
-    top: 0;
-    width: 100%;
-    z-index: 1;
+  background: none repeat scroll 0 0 #000000;
+  display: none;
+  height: 100%;
+  left: 0;
+  opacity: 0.5;
+  position: absolute;
+  top: 0;
+  width: 100%;
+  z-index: 1;
 }
 
 #popupBox {
-    background: none repeat scroll 0 0 #fff;
-    display: none;
-    height: 50%;
-    left: 80px;
-    position: absolute;
-    top: 80px;
-    width: 800px;
-    z-index: 2;
+  background: none repeat scroll 0 0 #fff;
+  display: none;
+  height: 50%;
+  left: 80px;
+  position: absolute;
+  top: 80px;
+  width: 800px;
+  z-index: 2;
 }
 
 /*
@@ -228,22 +228,22 @@
 
 dl.form dd input[type="text"],  dl.form dd .autocomplete,
 dl.form-col dd input[type="text"],  dl.form-col dd .autocomplete {
-    width: 15em;
+  width: 15em;
 }
 dl.form dd .autocomplete,
 dl.form-col dd .autocomplete,
 dl.form-2col dd .autocomplete {
-    padding-bottom: 2em;
+  padding-bottom: 2em;
 }
 
 div.autocomplete {
-    width: 15em;
-       position: relative;
-    padding-bottom: 2em;
+  width: 15em;
+  position: relative;
+  padding-bottom: 2em;
 }
 /* ie fix. autocomplete dropdown is displayed behind some elements if the 
z-index is not set */
 div.autocomplete input {
-       z-index: 500;
+  z-index: 500;
 }
 
 
@@ -423,7 +423,6 @@
 }
 #dt-dlg_c .underlay {overflow:hidden;}
 .inprogress {position:absolute;} /* transitional progressive enhancement state 
*/
-}
 
 dl.controller-description {
   width: 70%;
@@ -522,17 +521,17 @@
 }
 
 #innertoolbar-button, input[type="submit"], input[type="button"]{
-    background: none repeat scroll 0 0 #4F9AEA;
-    border: 1px solid #4685C8;
-    border-radius: 4px 4px 4px 4px;
-    color: #FFFFFF;
-    cursor: pointer;
-    padding: 3px 15px;
+  background: none repeat scroll 0 0 #4F9AEA;
+  border: 1px solid #4685C8;
+  border-radius: 4px 4px 4px 4px;
+  color: #FFFFFF;
+  cursor: pointer;
+  padding: 3px 15px;
 }
 
 input[type="submit"][disabled]
 {
-    background: none repeat scroll 0 0 #A3D1FF;
+  background: none repeat scroll 0 0 #A3D1FF;
 }
 
 #innertoolbar-button {
@@ -661,9 +660,9 @@
 }
 
 dl.proplist, dl.proplist-col {
-    margin: 0;
-    padding-left: 0;
-    width: 50%;
+  margin: 0;
+  padding-left: 0;
+  width: 50%;
 }
 
 #details .proplist dd, #details .proplist-col dd{
@@ -790,9 +789,9 @@
 }
 
 .btn-sm {
-    font-size: 12px;
-    padding: 1px 4px;
-    text-align: center;
+  font-size: 12px;
+  padding: 1px 4px;
+  text-align: center;
 }
 
 .btn.cancel, .btn_m.cancel, .btn-sm.cancel {
@@ -802,18 +801,18 @@
 }
 
 .btn.non-focus {
-    background: none repeat scroll 0 0 #A0C8F2;
-    border: 1px solid #74B0EF;
-    color: #0A3E74;
+  background: none repeat scroll 0 0 #A0C8F2;
+  border: 1px solid #74B0EF;
+  color: #0A3E74;
 }
 
 .btn.focus, .btn_m.focus {
-    background: none repeat scroll 0 0 #F57056;
-    border-color: #EE836F #CB563F #CB563F;
-    border-style: solid none;
-    border-width: 1px 0;
-    color: #FFFFFF;
-    margin-top: 1px;
+  background: none repeat scroll 0 0 #F57056;
+  border-color: #EE836F #CB563F #CB563F;
+  border-style: solid none;
+  border-width: 1px 0;
+  color: #FFFFFF;
+  margin-top: 1px;
 }
 
 /* =======================================  MAIN CONTENT  
========================================= */
@@ -1291,15 +1290,15 @@
 }
 
 .input_error_msg {
-    background: none repeat scroll 0 0 #FBE3E4;
-    border-bottom-right-radius: 4px;
-    color: #D12F19;
-    display: block;
-    margin-bottom: 5px;
-    margin-top: 5px;
-    padding: 5px;
-    text-align: center;
-    width: 90%;
+  background: none repeat scroll 0 0 #FBE3E4;
+  border-bottom-right-radius: 4px;
+  color: #D12F19;
+  display: block;
+  margin-bottom: 5px;
+  margin-top: 5px;
+  padding: 5px;
+  text-align: center;
+  width: 90%;
 }
 
 .error_msg {
@@ -1329,7 +1328,57 @@
 
 
 .yui-navset .content-wrp {
-       margin-top: 0;
+  margin-top: 0;
 }
 
+.fields_wrp {
+  padding: 15px;
+}
 
+.fields_wrp td {
+  padding: 7px 0;
+  vertical-align: top;
+}
+
+.fields_wrp td.first {
+  padding-right: 5px;
+  text-align: left;
+  width: 250px;
+}
+
+.fields_wrp label {
+  font-size: 13px;
+  font-weight: normal;
+  line-height: 1.5em;
+}
+
+.fields_wrp h2 {
+  font-size: 20px;
+  margin: 0;
+}
+
+.fields_wrp textarea {
+  width: 250px;
+}
+
+.autocomplete ul{
+  background: none repeat scroll 0 0 #FFFFFF;
+  border: 1px solid #AEC6E3;
+  position:absolute;
+}
+
+.autocomplete li{
+  background: none repeat scroll 0 0 #D4E1F8;
+  list-style: none outside none;
+  margin: 2px;
+  padding: 4px 8px;
+  cursor: pointer;
+}
+
+.yui-skin-sam .autocomplete .yui-ac-content {
+    overflow: visible;
+}
+
+.yui-skin-sam .autocomplete .yui-ac-content li {
+    white-space: wrap;
+}
\ No newline at end of file

Modified: branches/Version-1_0-branch/property/templates/base/workorder.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/workorder.xsl   
2013-01-15 08:35:45 UTC (rev 10672)
+++ branches/Version-1_0-branch/property/templates/base/workorder.xsl   
2013-01-15 09:25:43 UTC (rev 10673)
@@ -523,6 +523,7 @@
                                                                        
<xsl:call-template name="cat_sub_select"/>
                                                                </td>
                                                        </tr>
+
                                                        <tr>
                                                                <td 
valign="top">
                                                                        
<xsl:value-of select="php:function('lang', 'contract sum')"/>
@@ -562,8 +563,51 @@
                                                                        <input 
type="text" name="values[addition_rs]" value="{value_addition_rs}" 
onMouseout="window.status='';return true;"><xsl:attribute 
name="title"><xsl:value-of 
select="lang_addition_rs_statustext"/></xsl:attribute></input><xsl:text> 
</xsl:text> [ <xsl:value-of select="currency"/> ]
                                                                </td>
                                                        </tr>
+                                                               <td 
valign="top">
+                                                                       
<xsl:value-of select="php:function('lang', 'when')"/>
+                                                               </td>
+                                                               <td>
+                                                                       <table>
+                                                                               
<tr>
+                                                                               
        <td>
+                                                                               
                <select name="values[budget_year]">
+                                                                               
                        <xsl:attribute name="title">
+                                                                               
                                <xsl:value-of select="php:function('lang', 
'year')"/>
+                                                                               
                        </xsl:attribute>
+                                                                               
                        <option value="0">
+                                                                               
                                <xsl:value-of select="php:function('lang', 
'year')"/>
+                                                                               
                        </option>
+                                                                               
                        <xsl:apply-templates select="year_list/options"/>
+                                                                               
                </select>
+                                                                               
        </td>
+                                                                               
        <xsl:choose>
+                                                                               
                <xsl:when test="periodization_data/id !=''">
+                                                                               
                        <td>
+                                                                               
                                <input type="checkbox" 
name="values[budget_periodization]" value="{periodization_data/id}" 
checked='checked'>
+                                                                               
                                        <xsl:attribute name="title">
+                                                                               
                                                <xsl:value-of 
select="php:function('lang', 'periodization')"/>
+                                                                               
                                                <xsl:text>::</xsl:text>
+                                                                               
                                                <xsl:value-of 
select="periodization_data/descr"/>
+                                                                               
                                        </xsl:attribute>
+                                                                               
                                </input>
+                                                                               
                        </td>
+                                                                               
                </xsl:when>
+                                                                               
        </xsl:choose>
+                                                                               
</tr>
+                                                                       </table>
+                                                               </td>
+
                                                        <tr>
+                                                               <td 
valign="top">
+                                                                       
<xsl:value-of select="php:function('lang', 'budget')"/>
+                                                               </td>
                                                                <td>
+                                                                       <div 
id="paging_5"/>
+                                                                       <div 
id="datatable-container_5"/>
+                                                               </td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td>
                                                                        
<xsl:choose>
                                                                                
<xsl:when test="link_claim !=''">
                                                                                
        <a href="{link_claim}">




reply via email to

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