fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11685] Merge 11680:11684 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [11685] Merge 11680:11684 from trunk
Date: Thu, 13 Feb 2014 12:22:31 +0000

Revision: 11685
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11685
Author:   sigurdne
Date:     2014-02-13 12:22:30 +0000 (Thu, 13 Feb 2014)
Log Message:
-----------
Merge 11680:11684 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php
    branches/Version-1_0-branch/property/inc/class.uiimport.inc.php
    
branches/Version-1_0-branch/property/inc/export/default/Agresso_Bergen_Kostfordeling
    
branches/Version-1_0-branch/property/inc/import/default/Import_fra_Service_EBF
    branches/Version-1_0-branch/property/setup/phpgw_no.lang

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


Property changes on: branches/Version-1_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352,8354-8368,8370-8396,8398-8430,8432,8434-8440,8442-8445,8447-8453,8455-8456,8458,8460,8462-8464,8466-8473,8475-8479,8481,8483-8501,8503-8523,8525,8527-8531,8533,8535-8536,8538-8550,8552-8554,8556-8557,8559-8579,8581-8587,8589,8591-8592,8594-8595,8597-8601,8603-8610,8612-8613,8615,8617,8619-8645,8647-8650,8652-8661,8663-8666,8668-8669,8671-8683,8685-8691,8693-8730,8732-8737,8739,8741-8767,8769,8771-8772,8774,8776-8797,8799-8812,8814-8819,8821,8823-8833,8835-8837,8839,8841,8843-8849,8852-8858,8860-8867,8869-8870,8872,8874-8877,8879,8881,8883-8888,8890,8892-8901,8903-8911,8913-8917,8920-8923,8925-8933,8935-8938,8940-8943,8945,8947-8948,8950,8952-8953,8955-8962,8964,8966,8968-8970,8972-8975,8977-8983,8985-8993,8995-9001,9003,9005,9007,9009,9011-9019,9021-9023,9025,9027-9028,9030-9044,9046-9047,9049-9050,9052-9056,9058-9059,9061,9063-9064,9066-9068,9071-9092,9094-9112,9114-9117,9119,9121-9160,9162-9166,9169-9207,9209-9211,9213-9215,9217,9219,9221-9253,9255,9257,9259-9260,9262,9264-9269,9271-9273,9275,9277-9278,9280,9282-9283,9285-9289,9291-9299,9301-9310,9312-9313,9315-9320,9322-9324,9326-9338,9340-9342,9344,9346-9348,9350-9358,9360-9362,9364-9366,9368-9374,9376-9382,9384,9386,9388-9390,9392-9396,9398-9402,9404-9410,9412,9414,9416-9417,9419-9425,9427,9429-9430,9432,9434-9463,9465-9502,9504-9506,9508-9521,9523-9526,9528,9530-9537,9539,9541-9551,9553,9555-9556,9558-9578,9580-9581,9583,9585,9587,9589,9591-9624,9626-9655,9657-9700,9702-9726,9728-9729,9731-9749,9751,9753-9754,9756-9832,9834-9836,9838-9839,9841-9846,9848-9850,9852-9858,9860-9863,9865,9867,9869-9871,9873-9893,9895,9897-9912,9914-9919,9921-9928,9930-9952,9954,9956,9958-9963,9965-9993,9995-9997,9999-10001,10003-10004,10006-10007,10009-10012,10014-10031,10033-10073,10075-10107,10109-10165,10167-10210,10222-10226,10228-10311,10313-10378,10380,10382,10384-10393,10395-10478,10480-10482,10484-10494,10496-10503,10505,10507,10509-10521,10523,10525-10528,10530-10540,10542-10543,10545-10568,10570-10584,10586-10590,10592-10594,10596,10598-10599,10601-10611,10613,10615,10617-10626,10628-10636,10638,10640-10654,10656-10658,10660,10662-10672,10674,10676-10682,10684,10686,10688-10690,10692-10694,10696-10697,10699-10701,10703,10705-10706,10708-10724,10726-10731,10734,10736-10748,10750-10796,10798-10939,10941,10943,10945,10947-10953,10955,10957-10961,10963,10965-10966,10968-11001,11003-11030,11032-11034,11036,11038,11040,11042-11053,11055-11059,11061-11062,11064-11068,11070-11073,11075-11077,11079-11083,11085,11087-11088,11090-11093,11095-11108,11110-11111,11113,11115-11116,11118-11120,11122,11124-11129,11131-11132,11134,11136,11138,11140-11151,11153-11161,11163-11185,11187-11189,11191-11229,11231,11233,11235-11264,11266-11267,11269-11278,11280-11282,11284-11291,11293-11295,11297,11299-11302,11304,11306,11309,11311,11313-11316,11318-11323,11325-11332,11334,11336-11344,11346,11348-11354,11356,11358-11360,11363-11386,11388-11389,11391-11392,11394,11396-11403,11405-11406,11408,11410,11412,11415,11417,11419-11420,11422,11424-11429,11431-11442,11444-11445,11447-11460,11462-11464,11466-11470,11472-11475,11477-11478,11480-11487,11489-11492,11494,11496,11498,11500-11502,11504-11506,11508,11510-11511,11513,11515,11517-11523,11525-11526,11528-11531,11533,11535-11538,11540-11546,11548-11560,11563-11572,11574,11576,11578,11580-11581,11583,11585,11587,11589-11592,11594-11595,11597,11599,11601,11603,11605-11607,11609-11611,11613,11615-11619,11621-11622,11624-11630,11632,11634-11635,11637,11639-11640,11642,11644-11655,11657-11659,11661-11675,11677-11679
   + 
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352,8354-8368,8370-8396,8398-8430,8432,8434-8440,8442-8445,8447-8453,8455-8456,8458,8460,8462-8464,8466-8473,8475-8479,8481,8483-8501,8503-8523,8525,8527-8531,8533,8535-8536,8538-8550,8552-8554,8556-8557,8559-8579,8581-8587,8589,8591-8592,8594-8595,8597-8601,8603-8610,8612-8613,8615,8617,8619-8645,8647-8650,8652-8661,8663-8666,8668-8669,8671-8683,8685-8691,8693-8730,8732-8737,8739,8741-8767,8769,8771-8772,8774,8776-8797,8799-8812,8814-8819,8821,8823-8833,8835-8837,8839,8841,8843-8849,8852-8858,8860-8867,8869-8870,8872,8874-8877,8879,8881,8883-8888,8890,8892-8901,8903-8911,8913-8917,8920-8923,8925-8933,8935-8938,8940-8943,8945,8947-8948,8950,8952-8953,8955-8962,8964,8966,8968-8970,8972-8975,8977-8983,8985-8993,8995-9001,9003,9005,9007,9009,9011-9019,9021-9023,9025,9027-9028,9030-9044,9046-9047,9049-9050,9052-9056,9058-9059,9061,9063-9064,9066-9068,9071-9092,9094-9112,9114-9117,9119,9121-9160,9162-9166,9169-9207,9209-9211,9213-9215,9217,9219,9221-9253,9255,9257,9259-9260,9262,9264-9269,9271-9273,9275,9277-9278,9280,9282-9283,9285-9289,9291-9299,9301-9310,9312-9313,9315-9320,9322-9324,9326-9338,9340-9342,9344,9346-9348,9350-9358,9360-9362,9364-9366,9368-9374,9376-9382,9384,9386,9388-9390,9392-9396,9398-9402,9404-9410,9412,9414,9416-9417,9419-9425,9427,9429-9430,9432,9434-9463,9465-9502,9504-9506,9508-9521,9523-9526,9528,9530-9537,9539,9541-9551,9553,9555-9556,9558-9578,9580-9581,9583,9585,9587,9589,9591-9624,9626-9655,9657-9700,9702-9726,9728-9729,9731-9749,9751,9753-9754,9756-9832,9834-9836,9838-9839,9841-9846,9848-9850,9852-9858,9860-9863,9865,9867,9869-9871,9873-9893,9895,9897-9912,9914-9919,9921-9928,9930-9952,9954,9956,9958-9963,9965-9993,9995-9997,9999-10001,10003-10004,10006-10007,10009-10012,10014-10031,10033-10073,10075-10107,10109-10165,10167-10210,10222-10226,10228-10311,10313-10378,10380,10382,10384-10393,10395-10478,10480-10482,10484-10494,10496-10503,10505,10507,10509-10521,10523,10525-10528,10530-10540,10542-10543,10545-10568,10570-10584,10586-10590,10592-10594,10596,10598-10599,10601-10611,10613,10615,10617-10626,10628-10636,10638,10640-10654,10656-10658,10660,10662-10672,10674,10676-10682,10684,10686,10688-10690,10692-10694,10696-10697,10699-10701,10703,10705-10706,10708-10724,10726-10731,10734,10736-10748,10750-10796,10798-10939,10941,10943,10945,10947-10953,10955,10957-10961,10963,10965-10966,10968-11001,11003-11030,11032-11034,11036,11038,11040,11042-11053,11055-11059,11061-11062,11064-11068,11070-11073,11075-11077,11079-11083,11085,11087-11088,11090-11093,11095-11108,11110-11111,11113,11115-11116,11118-11120,11122,11124-11129,11131-11132,11134,11136,11138,11140-11151,11153-11161,11163-11185,11187-11189,11191-11229,11231,11233,11235-11264,11266-11267,11269-11278,11280-11282,11284-11291,11293-11295,11297,11299-11302,11304,11306,11309,11311,11313-11316,11318-11323,11325-11332,11334,11336-11344,11346,11348-11354,11356,11358-11360,11363-11386,11388-11389,11391-11392,11394,11396-11403,11405-11406,11408,11410,11412,11415,11417,11419-11420,11422,11424-11429,11431-11442,11444-11445,11447-11460,11462-11464,11466-11470,11472-11475,11477-11478,11480-11487,11489-11492,11494,11496,11498,11500-11502,11504-11506,11508,11510-11511,11513,11515,11517-11523,11525-11526,11528-11531,11533,11535-11538,11540-11546,11548-11560,11563-11572,11574,11576,11578,11580-11581,11583,11585,11587,11589-11592,11594-11595,11597,11599,11601,11603,11605-11607,11609-11611,11613,11615-11619,11621-11622,11624-11630,11632,11634-11635,11637,11639-11640,11642,11644-11655,11657-11659,11661-11675,11677-11679,11681-11684

Modified: branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php    
2014-02-13 12:19:03 UTC (rev 11684)
+++ branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php    
2014-02-13 12:22:30 UTC (rev 11685)
@@ -1,39 +1,39 @@
 <?php
        /**
-       * phpGroupWare - property: a Facilities Management System.
-       *
-       * @author Sigurd Nes <address@hidden>
-       * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software 
Foundation, Inc. http://www.fsf.org/
-       * This file is part of phpGroupWare.
-       *
-       * phpGroupWare is free software; you can redistribute it and/or modify
-       * it under the terms of the GNU General Public License as published by
-       * the Free Software Foundation; either version 2 of the License, or
-       * (at your option) any later version.
-       *
-       * phpGroupWare is distributed in the hope that it will be useful,
-       * but WITHOUT ANY WARRANTY; without even the implied warranty of
-       * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-       * GNU General Public License for more details.
-       *
-       * You should have received a copy of the GNU General Public License
-       * along with phpGroupWare; if not, write to the Free Software
-       * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 
 USA
-       *
-       * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
-       * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
-       * @package property
-       * @subpackage eco
-       * @version $Id$
-       */
+        * phpGroupWare - property: a Facilities Management System.
+        *
+        * @author Sigurd Nes <address@hidden>
+        * @copyright Copyright (C) 2003-2014 Free Software Foundation, Inc. 
http://www.fsf.org/
+        * This file is part of phpGroupWare.
+        *
+        * phpGroupWare is free software; you can redistribute it and/or modify
+        * it under the terms of the GNU General Public License as published by
+        * the Free Software Foundation; either version 2 of the License, or
+        * (at your option) any later version.
+        *
+        * phpGroupWare is distributed in the hope that it will be useful,
+        * but WITHOUT ANY WARRANTY; without even the implied warranty of
+        * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+        * GNU General Public License for more details.
+        *
+        * You should have received a copy of the GNU General Public License
+        * along with phpGroupWare; if not, write to the Free Software
+        * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
02110-1301  USA
+        *
+        * @license http://www.gnu.org/licenses/gpl.html GNU General Public 
License
+        * @internal Development of this application was funded by 
http://www.bergen.kommune.no/bbb_/ekstern/
+        * @package property
+        * @subpackage eco
+        * @version $Id$
+        */
 
        /**
         * Description
         * @package property
         */
-
        class property_soinvoice
        {
+
                public $total_records = 0;
                public $sum_amount = 0;
                public $role = array();
@@ -41,13 +41,13 @@
 
                function __construct()
                {
-                       $this->account_id       = 
$GLOBALS['phpgw_info']['user']['account_id'];
-                       $this->acl                      = & 
$GLOBALS['phpgw']->acl;
-                       $this->db           = & $GLOBALS['phpgw']->db;
-                       $this->join                     = & $this->db->join;
-                       $this->left_join        = & $this->db->left_join;
-                       $this->like                     = & $this->db->like;
-                       $this->config           = 
CreateObject('phpgwapi.config','property');
+                       $this->account_id = 
$GLOBALS['phpgw_info']['user']['account_id'];
+                       $this->acl = & $GLOBALS['phpgw']->acl;
+                       $this->db = & $GLOBALS['phpgw']->db;
+                       $this->join = & $this->db->join;
+                       $this->left_join = & $this->db->left_join;
+                       $this->like = & $this->db->like;
+                       $this->config = CreateObject('phpgwapi.config', 
'property');
                        $this->config->read();
                        $this->invoice_approval = 
isset($this->config->config_data['invoice_approval']) && 
$this->config->config_data['invoice_approval'] ? 
$this->config->config_data['invoice_approval'] : 2;
                }
@@ -56,47 +56,47 @@
                {
                        $valid_order = array
                                (
-                                       'bilagsnr'                      => true,
-                                       'spvend_code'           => true,
-                                       'fakturadato'           => true,
-                                       'oppsynsigndato'        => true,
-                                       'saksigndato'           => true,
-                                       'budsjettsigndato'      => true,
-                                       'periode'                       => true
-                               );
+                               'bilagsnr'                       => true,
+                               'spvend_code'            => true,
+                               'fakturadato'            => true,
+                               'oppsynsigndato'         => true,
+                               'saksigndato'            => true,
+                               'budsjettsigndato'       => true,
+                               'periode'                        => true
+                       );
 
-                       $start                  = isset($data['start']) && 
$data['start'] ? $data['start'] : 0;
-                       $query                  = 
isset($data['query'])?$data['query']:'';
-                       $sort                   = isset($data['sort']) && 
$data['sort'] ? $data['sort']:'DESC';
-                       $order                  = isset($data['order']) && 
$valid_order[$data['order']] ? $data['order']:'';
-                       $cat_id                 = isset($data['cat_id']) && 
$data['cat_id'] ? $data['cat_id']:0;
-                       $user_lid               = isset($data['user_lid']) && 
$data['user_lid']?$data['user_lid']:'none';
-                       $paid                   = 
isset($data['paid'])?$data['paid']:'';
-                       $start_date     = isset($data['start_date']) && 
$data['start_date'] ? $data['start_date'] : mktime(0,0,0,'01','01',date('Y'));
-                       $end_date               = isset($data['end_date']) && 
$data['end_date'] ? $data['end_date'] : time();
-                       $vendor_id              = 
isset($data['vendor_id'])?$data['vendor_id']:'';
-                       $loc1                   = 
isset($data['loc1'])?$data['loc1']:'';
-                       $workorder_id   = 
isset($data['workorder_id'])?$data['workorder_id']:'';
-                       $project_id     = 
isset($data['project_id'])?$data['project_id']:'';
-                       $allrows                = 
isset($data['allrows'])?$data['allrows']:'';
-                       $voucher_id     = 
isset($data['voucher_id'])?$data['voucher_id']:'';
-                       $b_account_class= 
isset($data['b_account_class'])?$data['b_account_class']:'';
-                       $district_id    = 
isset($data['district_id'])?$data['district_id']:'';
-                       $invoice_id             = $data['invoice_id'] ? 
$data['invoice_id'] :'';
-                       $ecodimb                = 
isset($data['ecodimb'])?$data['ecodimb']:'';
+                       $start = isset($data['start']) && $data['start'] ? 
$data['start'] : 0;
+                       $query = isset($data['query']) ? $data['query'] : '';
+                       $sort = isset($data['sort']) && $data['sort'] ? 
$data['sort'] : 'DESC';
+                       $order = isset($data['order']) && 
$valid_order[$data['order']] ? $data['order'] : '';
+                       $cat_id = isset($data['cat_id']) && $data['cat_id'] ? 
$data['cat_id'] : 0;
+                       $user_lid = isset($data['user_lid']) && 
$data['user_lid'] ? $data['user_lid'] : 'none';
+                       $paid = isset($data['paid']) ? $data['paid'] : '';
+                       $start_date = isset($data['start_date']) && 
$data['start_date'] ? $data['start_date'] : mktime(0, 0, 0, '01', '01', 
date('Y'));
+                       $end_date = isset($data['end_date']) && 
$data['end_date'] ? $data['end_date'] : time();
+                       $vendor_id = isset($data['vendor_id']) ? 
$data['vendor_id'] : '';
+                       $loc1 = isset($data['loc1']) ? $data['loc1'] : '';
+                       $workorder_id = isset($data['workorder_id']) ? 
$data['workorder_id'] : '';
+                       $project_id = isset($data['project_id']) ? 
$data['project_id'] : '';
+                       $allrows = isset($data['allrows']) ? $data['allrows'] : 
'';
+                       $voucher_id = isset($data['voucher_id']) ? 
$data['voucher_id'] : '';
+                       $b_account_class = isset($data['b_account_class']) ? 
$data['b_account_class'] : '';
+                       $district_id = isset($data['district_id']) ? 
$data['district_id'] : '';
+                       $invoice_id = $data['invoice_id'] ? $data['invoice_id'] 
: '';
+                       $ecodimb = isset($data['ecodimb']) ? $data['ecodimb'] : 
'';
 
-                       $join_tables    = '';
-                       $filtermethod   = '';
-                       $querymethod    = '';
+                       $join_tables = '';
+                       $filtermethod = '';
+                       $querymethod = '';
 
                        $this->db->query("SELECT * FROM fm_ecoart");
                        $art_list = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
-                               $art_list[$this->db->f('id')] = 
$this->db->f('descr',true);
+                               $art_list[$this->db->f('id')] = 
$this->db->f('descr', true);
                        }
 
-                       if ($order)
+                       if($order)
                        {
                                $ordermethod = " ORDER BY $order $sort";
                        }
@@ -105,95 +105,95 @@
                                $ordermethod = ' order by bilagsnr DESC';
                        }
 
-                       $where= 'WHERE';
+                       $where = 'WHERE';
 
-                       if ($user_lid=='none' || !$user_lid)
+                       if($user_lid == 'none' || !$user_lid)
                        {
                                return array();
                        }
-                       else if ($user_lid!='all')
+                       else if($user_lid != 'all')
                        {
                                $filtermethod = " WHERE ( oppsynsmannid= 
'$user_lid' or saksbehandlerid= '$user_lid' or budsjettansvarligid= 
'$user_lid')";
-                               $where= 'AND';
+                               $where = 'AND';
                        }
 
-                       if ($cat_id > 0)
+                       if($cat_id > 0)
                        {
                                $filtermethod .= " $where typeid='$cat_id' ";
-                               $where= 'AND';
+                               $where = 'AND';
                        }
 
                        if($ecodimb)
                        {
-                               $filtermethod .= " $where dimb = " . 
(int)$ecodimb;
-                               $where= 'AND';
+                               $filtermethod .= " $where dimb = " . (int) 
$ecodimb;
+                               $where = 'AND';
                        }
 
-                       if ($district_id > 0 && $paid)
+                       if($district_id > 0 && $paid)
                        {
                                $filtermethod .= " $where  
district_id='$district_id' ";
                                $join_tables = " $this->join fm_location1 ON 
fm_ecobilagoverf.loc1 = fm_location1.loc1"
-                                       . " $this->join fm_part_of_town ON 
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id)";
-                               $where= 'AND';
+                               . " $this->join fm_part_of_town ON 
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id)";
+                               $where = 'AND';
                        }
 
-                       if ($vendor_id)
+                       if($vendor_id)
                        {
                                $filtermethod .= " $where  spvend_code 
='{$vendor_id}' ";
-                               $where= 'AND';
+                               $where = 'AND';
                        }
-                       if ($loc1)
+                       if($loc1)
                        {
                                $filtermethod .= " $where  dima {$this->like} 
'%$loc1%' ";
-                               $where= 'AND';
+                               $where = 'AND';
                        }
 
-                       if ($invoice_id)
+                       if($invoice_id)
                        {
                                $filtermethod .= " $where fakturanr 
='{$invoice_id}'";
-                               $where= 'AND';
+                               $where = 'AND';
                        }
 
-                       if ($paid)
+                       if($paid)
                        {
                                $table = 'fm_ecobilagoverf';
 
-                               if ($b_account_class)
+                               if($b_account_class)
                                {
                                        $filtermethod .= " $where  
fm_b_account.category ='$b_account_class' ";
-                                       $where= 'AND';
+                                       $where = 'AND';
                                        $join_tables .= " $this->join 
fm_b_account ON fm_ecobilagoverf.spbudact_code = fm_b_account.id";
                                }
 
-                               if (!$workorder_id && !$voucher_id && 
!$invoice_id)
+                               if(!$workorder_id && !$voucher_id && 
!$invoice_id)
                                {
-                                       $start_periode = date('Ym',$start_date);
-                                       $end_periode = date('Ym',$end_date);
+                                       $start_periode = date('Ym', 
$start_date);
+                                       $end_periode = date('Ym', $end_date);
 
                                        $filtermethod .= " $where (periode 
>='$start_periode' AND periode <= '$end_periode')";
-                                       $where= 'AND';
+                                       $where = 'AND';
                                }
                        }
                        else
                        {
-                               $table ='fm_ecobilag';
+                               $table = 'fm_ecobilag';
                        }
 
                        $no_q = false;
-                       if ($voucher_id)
+                       if($voucher_id)
                        {
-                               $filtermethod = " WHERE bilagsnr = " . 
(int)$voucher_id . " OR bilagsnr_ut = '{$voucher_id}'";// OR spvend_code = ". 
(int)$query;
+                               $filtermethod = " WHERE bilagsnr = " . (int) 
$voucher_id . " OR bilagsnr_ut = '{$voucher_id}'";// OR spvend_code = ". 
(int)$query;
                                $no_q = true;
                        }
 
-                       if ($workorder_id)
+                       if($workorder_id)
                        {
                                $filtermethod = " WHERE pmwrkord_code 
='$workorder_id' ";
                                $no_q = true;
                        }
-                       else if ($project_id)
+                       else if($project_id)
                        {
-                               $this->db->query("SELECT id FROM fm_workorder 
WHERE project_id='{$project_id}'",__LINE__,__FILE__);
+                               $this->db->query("SELECT id FROM fm_workorder 
WHERE project_id='{$project_id}'", __LINE__, __FILE__);
                                $_workorders = array(-1);
                                while($this->db->next_record())
                                {
@@ -202,7 +202,7 @@
 
                                $filtermethod = ' WHERE pmwrkord_code IN (' . 
implode(',', $_workorders) . ')';
                                $filtermethod .= " AND (periode 
>='$start_periode' AND periode <= '$end_periode')";
-                               $no_q = true;                   
+                               $no_q = true;
                        }
 
                        if($query && !$no_q)
@@ -215,183 +215,180 @@
                        $sql = "SELECT bilagsnr, bilagsnr_ut, count(bilagsnr) 
as invoice_count, sum(belop) as belop, sum(godkjentbelop) as 
godkjentbelop,spvend_code,fakturadato FROM  $table $join_tables $filtermethod 
$querymethod GROUP BY periode, 
bilagsnr,bilagsnr_ut,spvend_code,fakturadato,oppsynsigndato,saksigndato,budsjettsigndato";
                        $sql2 = "SELECT DISTINCT bilagsnr FROM  $table 
$join_tables $filtermethod $querymethod";
 
-                       
if($GLOBALS['phpgw_info']['server']['db_type']=='postgres')
+                       if($GLOBALS['phpgw_info']['server']['db_type'] == 
'postgres')
                        {
-                               $sql_count = 'SELECT count(bilagsnr) as cnt, 
sum(godkjentbelop) AS sum_amount FROM (SELECT DISTINCT bilagsnr, 
sum(godkjentbelop) as godkjentbelop '. substr($sql2,strripos($sql2,'FROM')) .' 
GROUP BY bilagsnr) AS t';
-               //_debug_array($sql_count);
-                               $this->db->query($sql_count,__LINE__,__FILE__);
+                               $sql_count = 'SELECT count(bilagsnr) as cnt, 
sum(godkjentbelop) AS sum_amount FROM (SELECT DISTINCT bilagsnr, 
sum(godkjentbelop) as godkjentbelop ' . substr($sql2, strripos($sql2, 'FROM')) 
. ' GROUP BY bilagsnr) AS t';
+                               //_debug_array($sql_count);
+                               $this->db->query($sql_count, __LINE__, 
__FILE__);
                                $this->db->next_record();
-                               $this->total_records            = 
$this->db->f('cnt');
-                               $this->sum_amount                       = 
$this->db->f('sum_amount');
+                               $this->total_records = $this->db->f('cnt');
+                               $this->sum_amount = $this->db->f('sum_amount');
                        }
                        else
                        {
-                               $this->db->query($sql2,__LINE__,__FILE__);
+                               $this->db->query($sql2, __LINE__, __FILE__);
                                $this->total_records = $this->db->num_rows();
 
                                $sql3 = "SELECT sum(godkjentbelop) as 
sum_amount FROM $table $join_tables $filtermethod $querymethod";
-                               $this->db->query($sql3,__LINE__,__FILE__);
+                               $this->db->query($sql3, __LINE__, __FILE__);
                                $this->db->next_record();
-                               $this->sum_amount               = 
$this->db->f('sum_amount');
+                               $this->sum_amount = $this->db->f('sum_amount');
                        }
 
                        if(!$allrows)
                        {
-                               $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__);
+                               $this->db->limit_query($sql . $ordermethod, 
$start, __LINE__, __FILE__);
                        }
                        else
                        {
-                               $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
+                               $this->db->query($sql . $ordermethod, __LINE__, 
__FILE__);
                        }
 
                        $temp = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $temp[] = array
                                        (
-                                               'voucher_id'            => 
$this->db->f('bilagsnr'),
-                                               'voucher_out_id'        => 
$this->db->f('bilagsnr_ut'),
-                                               'invoice_count'         => 
$this->db->f('invoice_count'),
-                                               'amount'                        
=> $this->db->f('belop'),
-                                               'approved_amount'       => 
$this->db->f('godkjentbelop')
-                                       );
+                                       'voucher_id'             => 
$this->db->f('bilagsnr'),
+                                       'voucher_out_id'         => 
$this->db->f('bilagsnr_ut'),
+                                       'invoice_count'          => 
$this->db->f('invoice_count'),
+                                       'amount'                         => 
$this->db->f('belop'),
+                                       'approved_amount'        => 
$this->db->f('godkjentbelop')
+                               );
                        }
 
-                       $invoice        = array();
+                       $invoice = array();
 
-                       if ($temp)
+                       if($temp)
                        {
-                               $role= $this->check_role();
+                               $role = $this->check_role();
                                $i = 0;
                                foreach($temp as $invoice_temp)
                                {
                                        $voucher_id = 
$invoice_temp['voucher_id'];
 
                                        $sql = "SELECT 
pmwrkord_code,spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
-                                               . " 
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
-                                               . " 
forfallsdato,periode,periodization,periodization_start,artid,kidnr,kreditnota,currency
 "
-                                               . " FROM {$table} {$this->join} 
fm_vendor ON fm_vendor.id = {$table}.spvend_code WHERE bilagsnr = {$voucher_id} 
"
-                                               . " GROUP BY 
bilagsnr,pmwrkord_code,spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
-                                               . " 
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
-                                               . " 
forfallsdato,periode,periodization,periodization_start,artid,kidnr,kreditnota,currency";
+                                       . " 
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
+                                       . " 
forfallsdato,periode,periodization,periodization_start,artid,kidnr,kreditnota,currency
 "
+                                       . " FROM {$table} {$this->join} 
fm_vendor ON fm_vendor.id = {$table}.spvend_code WHERE bilagsnr = {$voucher_id} 
"
+                                       . " GROUP BY 
bilagsnr,pmwrkord_code,spvend_code,oppsynsmannid,saksbehandlerid,budsjettansvarligid,"
+                                       . " 
utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,fakturadato,org_name,"
+                                       . " 
forfallsdato,periode,periodization,periodization_start,artid,kidnr,kreditnota,currency";
 
-                                       
$this->db->query($sql,__LINE__,__FILE__);
+                                       $this->db->query($sql, __LINE__, 
__FILE__);
 
                                        $this->db->next_record();
 
-                                       $timestamp_voucher_date= 
mktime(0,0,0,date('m',strtotime($this->db->f('fakturadato'))),date('d',strtotime($this->db->f('fakturadato'))),date('y',strtotime($this->db->f('fakturadato'))));
-                                       $timestamp_payment_date= 
mktime(0,0,0,date('m',strtotime($this->db->f('forfallsdato'))),date('d',strtotime($this->db->f('forfallsdato'))),date('y',strtotime($this->db->f('forfallsdato'))));
+                                       $timestamp_voucher_date = mktime(0, 0, 
0, date('m', strtotime($this->db->f('fakturadato'))), date('d', 
strtotime($this->db->f('fakturadato'))), date('y', 
strtotime($this->db->f('fakturadato'))));
+                                       $timestamp_payment_date = mktime(0, 0, 
0, date('m', strtotime($this->db->f('forfallsdato'))), date('d', 
strtotime($this->db->f('forfallsdato'))), date('y', 
strtotime($this->db->f('forfallsdato'))));
 
                                        if($this->db->f('oppsynsmannid') && 
$this->db->f('oppsynsigndato'))
                                        {
-                                               
$invoice[$i]['jan_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($this->db->f('oppsynsigndato')));
+                                               $invoice[$i]['jan_date'] = 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
strtotime($this->db->f('oppsynsigndato')));
                                        }
                                        else
                                        {
-                                               $invoice[$i]['jan_date']        
='';
+                                               $invoice[$i]['jan_date'] = '';
                                        }
                                        if($this->db->f('saksbehandlerid') && 
$this->db->f('saksigndato'))
                                        {
-                                               
$invoice[$i]['super_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($this->db->f('saksigndato')));
+                                               $invoice[$i]['super_date'] = 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
strtotime($this->db->f('saksigndato')));
                                        }
                                        else
                                        {
-                                               $invoice[$i]['super_date']      
='';
+                                               $invoice[$i]['super_date'] = '';
                                        }
 
                                        if($this->db->f('budsjettansvarligid') 
&& $this->db->f('budsjettsigndato'))
                                        {
-                                               
$invoice[$i]['budget_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($this->db->f('budsjettsigndato')));
+                                               $invoice[$i]['budget_date'] = 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
strtotime($this->db->f('budsjettsigndato')));
                                        }
                                        else
                                        {
-                                               $invoice[$i]['budget_date']     
='';
+                                               $invoice[$i]['budget_date'] = 
'';
                                        }
 
                                        if($this->db->f('utbetalingid') && 
$this->db->f('utbetalingsigndato'))
                                        {
-                                               
$invoice[$i]['transfer_date']=date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($this->db->f('utbetalingsigndato')));
+                                               $invoice[$i]['transfer_date'] = 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
strtotime($this->db->f('utbetalingsigndato')));
                                        }
                                        else
                                        {
-                                               $invoice[$i]['transfer_date']   
='';
+                                               $invoice[$i]['transfer_date'] = 
'';
                                        }
 
-                                       $invoice[$i]['counter']                 
                = $i;
-                                       $invoice[$i]['current_user']            
        = $GLOBALS['phpgw_info']['user']['account_lid'];
-                                       $invoice[$i]['voucher_id']              
                = $voucher_id;
-                                       $invoice[$i]['voucher_out_id']          
        = $invoice_temp['voucher_out_id'];
-                                       $invoice[$i]['invoice_count']           
        = $invoice_temp['invoice_count'];
-                                       $invoice[$i]['vendor_id']               
                = $this->db->f('spvend_code');
-                                       $invoice[$i]['vendor']                  
                = $this->db->f('org_name',true);
-                                       $invoice[$i]['is_janitor']              
                = $role['is_janitor'];
-                                       $invoice[$i]['is_supervisor']           
        = $role['is_supervisor'];
-                                       $invoice[$i]['is_budget_responsible']   
= $role['is_budget_responsible'];
-                                       $invoice[$i]['is_transfer']             
                = $role['is_transfer'];
-                                       $invoice[$i]['janitor']                 
                = $this->db->f('oppsynsmannid');
-                                       $invoice[$i]['supervisor']              
                = $this->db->f('saksbehandlerid');
-                                       $invoice[$i]['budget_responsible']      
        = $this->db->f('budsjettansvarligid');
-                                       $invoice[$i]['transfer_id']             
                = $this->db->f('utbetalingid');
-                                       $invoice[$i]['voucher_date']            
        = 
$GLOBALS['phpgw']->common->show_date($timestamp_voucher_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                                       $invoice[$i]['payment_date']            
        = 
$GLOBALS['phpgw']->common->show_date($timestamp_payment_date,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                                       $invoice[$i]['period']                  
                = $this->db->f('periode');
-                                       $invoice[$i]['periodization']           
        = $this->db->f('periodization');
-                                       $invoice[$i]['periodization_start']     
        = $this->db->f('periodization_start');
+                                       $invoice[$i]['counter'] = $i;
+                                       $invoice[$i]['current_user'] = 
$GLOBALS['phpgw_info']['user']['account_lid'];
+                                       $invoice[$i]['voucher_id'] = 
$voucher_id;
+                                       $invoice[$i]['voucher_out_id'] = 
$invoice_temp['voucher_out_id'];
+                                       $invoice[$i]['invoice_count'] = 
$invoice_temp['invoice_count'];
+                                       $invoice[$i]['vendor_id'] = 
$this->db->f('spvend_code');
+                                       $invoice[$i]['vendor'] = 
$this->db->f('org_name', true);
+                                       $invoice[$i]['is_janitor'] = 
$role['is_janitor'];
+                                       $invoice[$i]['is_supervisor'] = 
$role['is_supervisor'];
+                                       $invoice[$i]['is_budget_responsible'] = 
$role['is_budget_responsible'];
+                                       $invoice[$i]['is_transfer'] = 
$role['is_transfer'];
+                                       $invoice[$i]['janitor'] = 
$this->db->f('oppsynsmannid');
+                                       $invoice[$i]['supervisor'] = 
$this->db->f('saksbehandlerid');
+                                       $invoice[$i]['budget_responsible'] = 
$this->db->f('budsjettansvarligid');
+                                       $invoice[$i]['transfer_id'] = 
$this->db->f('utbetalingid');
+                                       $invoice[$i]['voucher_date'] = 
$GLOBALS['phpgw']->common->show_date($timestamp_voucher_date, 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                                       $invoice[$i]['payment_date'] = 
$GLOBALS['phpgw']->common->show_date($timestamp_payment_date, 
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                                       $invoice[$i]['period'] = 
$this->db->f('periode');
+                                       $invoice[$i]['periodization'] = 
$this->db->f('periodization');
+                                       $invoice[$i]['periodization_start'] = 
$this->db->f('periodization_start');
 
-                                       $invoice[$i]['type']                    
                = $art_list[$this->db->f('artid')];
-                                       $invoice[$i]['kidnr']                   
                = $this->db->f('kidnr');
-                                       $invoice[$i]['kreditnota']              
                = $this->db->f('kreditnota');
-                                       $invoice[$i]['currency']                
                = $this->db->f('currency');
-                                       $invoice[$i]['order_id']                
                = $this->db->f('pmwrkord_code');
-                                       $invoice[$i]['amount']                  
                = $invoice_temp['amount'];
-                                       $invoice[$i]['approved_amount']         
        = $invoice_temp['approved_amount'];
-                                       $invoice[$i]['num_days']                
                = 
intval(($timestamp_payment_date-$timestamp_voucher_date)/(24*3600));
-                                       $invoice[$i]['timestamp_voucher_date']  
= $timestamp_voucher_date;
+                                       $invoice[$i]['type'] = 
$art_list[$this->db->f('artid')];
+                                       $invoice[$i]['kidnr'] = 
$this->db->f('kidnr');
+                                       $invoice[$i]['kreditnota'] = 
$this->db->f('kreditnota');
+                                       $invoice[$i]['currency'] = 
$this->db->f('currency');
+                                       $invoice[$i]['order_id'] = 
$this->db->f('pmwrkord_code');
+                                       $invoice[$i]['amount'] = 
$invoice_temp['amount'];
+                                       $invoice[$i]['approved_amount'] = 
$invoice_temp['approved_amount'];
+                                       $invoice[$i]['num_days'] = 
intval(($timestamp_payment_date - $timestamp_voucher_date) / (24 * 3600));
+                                       $invoice[$i]['timestamp_voucher_date'] 
= $timestamp_voucher_date;
 
-                                       
if($invoice[$i]['current_user']==$invoice[$i]['janitor'] && 
$invoice[$i]['jan_date'])
+                                       if($invoice[$i]['current_user'] == 
$invoice[$i]['janitor'] && $invoice[$i]['jan_date'])
                                        {
-                                               
$invoice[$i]['sign_orig']='sign_janitor';
+                                               $invoice[$i]['sign_orig'] = 
'sign_janitor';
                                        }
-                                       else 
if($invoice[$i]['current_user']==$invoice[$i]['supervisor'] && 
$invoice[$i]['super_date'])
+                                       else if($invoice[$i]['current_user'] == 
$invoice[$i]['supervisor'] && $invoice[$i]['super_date'])
                                        {
-                                               
$invoice[$i]['sign_orig']='sign_supervisor';
+                                               $invoice[$i]['sign_orig'] = 
'sign_supervisor';
                                        }
-                                       else 
if($invoice[$i]['current_user']==$invoice[$i]['budget_responsible'] && 
$invoice[$i]['budget_date'])
+                                       else if($invoice[$i]['current_user'] == 
$invoice[$i]['budget_responsible'] && $invoice[$i]['budget_date'])
                                        {
-                                               
$invoice[$i]['sign_orig']='sign_budget_responsible';
+                                               $invoice[$i]['sign_orig'] = 
'sign_budget_responsible';
                                        }
 
                                        $i++;
-
                                }
                        }
                        //_debug_array($invoice);
                        //_debug_array($invoice_temp);
 
                        return $invoice;
-
                }
 
-
                function read_invoice_sub($data)
                {
-                       $start          = isset($data['start']) && 
$data['start'] ? (int)$data['start'] : 0;
-                       $filter         = isset($data['filter']) ? 
$data['filter'] : 'none';
-                       $sort           = isset($data['sort']) ? $data['sort'] 
: 'DESC';
-                       $order          = isset($data['order']) ? 
$data['order'] : '';
-                       $voucher_id     = isset($data['voucher_id']) && 
$data['voucher_id'] ? (int)$data['voucher_id'] : 0;
-                       $paid           = isset($data['paid']) ? $data['paid'] 
: '';
-                       $project_id     = isset($data['project_id']) && 
$data['project_id'] ? (int)$data['project_id'] : 0;
-                       $order_id       = isset($data['order_id']) && 
$data['order_id'] ? $data['order_id'] : 0 ;//might be bigint
-                       $results        = isset($data['results']) && 
$data['results'] ? (int)$data['results'] : 0;
-                       $allrows        = isset($data['allrows']) ? 
$data['allrows'] : '';
-                       if ($paid)
+                       $start = isset($data['start']) && $data['start'] ? 
(int) $data['start'] : 0;
+                       $filter = isset($data['filter']) ? $data['filter'] : 
'none';
+                       $sort = isset($data['sort']) ? $data['sort'] : 'DESC';
+                       $order = isset($data['order']) ? $data['order'] : '';
+                       $voucher_id = isset($data['voucher_id']) && 
$data['voucher_id'] ? (int) $data['voucher_id'] : 0;
+                       $paid = isset($data['paid']) ? $data['paid'] : '';
+                       $project_id = isset($data['project_id']) && 
$data['project_id'] ? (int) $data['project_id'] : 0;
+                       $order_id = isset($data['order_id']) && 
$data['order_id'] ? $data['order_id'] : 0;//might be bigint
+                       $results = isset($data['results']) && $data['results'] 
? (int) $data['results'] : 0;
+                       $allrows = isset($data['allrows']) ? $data['allrows'] : 
'';
+                       if($paid)
                        {
                                $table = 'fm_ecobilagoverf';
                        }
                        else
                        {
-                               $table ='fm_ecobilag';
+                               $table = 'fm_ecobilag';
                        }
 
                        switch($order)
@@ -415,54 +412,54 @@
                        $filtermethod = '';
                        $where = 'WHERE';
 
-                       if ($voucher_id)
+                       if($voucher_id)
                        {
                                $filtermethod .= " {$where} bilagsnr= 
'$voucher_id'";
                                $where = 'AND';
                        }
-                       else if (!$order_id)
+                       else if(!$order_id)
                        {
                                return array();
                        }
 
-                       if ($order_id)
+                       if($order_id)
                        {
                                $filtermethod .= " {$where} pmwrkord_code= 
'{$order_id}'";
                                $where = 'AND';
                        }
 
-                       if ($project_id)
+                       if($project_id)
                        {
                                $filtermethod .= " {$where} fm_project.id = 
'{$project_id}'";
                                $where = 'AND';
                        }
 
                        $sql = "SELECT 
$table.*,fm_workorder.status,fm_workorder.charge_tenant,org_name,"
-                               . 
"fm_workorder.claim_issued,fm_workorder_status.closed,periodization_id,project_type_id"
-                               . " FROM {$table}"
-                               . " {$this->left_join} fm_workorder ON 
fm_workorder.id = $table.pmwrkord_code"
-                               . " {$this->left_join} fm_workorder_status ON 
fm_workorder.status = fm_workorder_status.id"
-                               . " {$this->left_join} fm_project ON 
fm_workorder.project_id = fm_project.id"
-                               . " {$this->join} fm_vendor ON 
$table.spvend_code = fm_vendor.id $filtermethod";
+                       . 
"fm_workorder.claim_issued,fm_workorder_status.closed,periodization_id,project_type_id"
+                       . " FROM {$table}"
+                       . " {$this->left_join} fm_workorder ON fm_workorder.id 
= $table.pmwrkord_code"
+                       . " {$this->left_join} fm_workorder_status ON 
fm_workorder.status = fm_workorder_status.id"
+                       . " {$this->left_join} fm_project ON 
fm_workorder.project_id = fm_project.id"
+                       . " {$this->join} fm_vendor ON $table.spvend_code = 
fm_vendor.id $filtermethod";
 
-                       $this->db->query('SELECT count(*) AS cnt ' . 
substr($sql,strripos($sql,' FROM')),__LINE__,__FILE__);
+                       $this->db->query('SELECT count(*) AS cnt ' . 
substr($sql, strripos($sql, ' FROM')), __LINE__, __FILE__);
                        $this->db->next_record();
-                       $this->total_records            = $this->db->f('cnt');
+                       $this->total_records = $this->db->f('cnt');
 
 
                        if(!$allrows)
                        {
-                               $this->db->limit_query($sql . 
$ordermethod,$start,__LINE__,__FILE__, $results);
+                               $this->db->limit_query($sql . $ordermethod, 
$start, __LINE__, __FILE__, $results);
                        }
                        else
                        {
-                               $this->db->query($sql . 
$ordermethod,__LINE__,__FILE__);
+                               $this->db->query($sql . $ordermethod, __LINE__, 
__FILE__);
                        }
 
                        $i = 0;
 
                        $invoice = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $status_line = 0;
                                if($this->db->f('budsjettsigndato'))
@@ -480,40 +477,40 @@
 
                                $invoice[] = array
                                        (
-                                               'counter'                       
        => $i,
-                                               'claim_issued'                  
=> $this->db->f('claim_issued'),
-                               //              'project_id'                    
=> $this->db->f('project_id'),
-                                               'workorder_id'                  
=> $this->db->f('pmwrkord_code'),
-                                               'order_id'                      
        => $this->db->f('pmwrkord_code'),
-                                               'status'                        
        => $this->db->f('status',true),
-                                               'closed'                        
        => !!$this->db->f('closed'),
-                                               'project_type_id'               
=> $this->db->f('project_type_id'),
-                                               'periodization_id'              
=> $this->db->f('periodization_id'),
-                                               'voucher_id'                    
=> $this->db->f('bilagsnr'),
-                                               'voucher_out_id'                
=> $this->db->f('bilagsnr_ut'),
-                                               'id'                            
        => $this->db->f('id'),
-                                               'invoice_id'                    
=> $this->db->f('fakturanr'),
-                                               'budget_account'                
=> $this->db->f('spbudact_code'),
-                                               'dima'                          
        => $this->db->f('dima'),
-                                               'dimb'                          
        => $this->db->f('dimb'),
-                                               'dimd'                          
        => $this->db->f('dimd'),
-                                               'dime'                          
        => $this->db->f('dime'),
-                                               'remark'                        
        => !!$this->db->f('merknad',true),
-                                               'tax_code'                      
        => $this->db->f('mvakode'),
-                                               'amount'                        
        => $this->db->f('belop'),
-                                               'approved_amount'               
=> $this->db->f('godkjentbelop'),
-                                               'charge_tenant'                 
=> $this->db->f('charge_tenant'),
-                                               'vendor'                        
        => $this->db->f('org_name',true),
-                       //                      'paid_percent'                  
=> $this->db->f('paid_percent'),
-                                               'project_group'                 
=> $this->db->f('project_id'),
-                                               'external_ref'                  
=> $this->db->f('external_ref'),
-                                               'currency'                      
        => $this->db->f('currency'),
-                                               'budget_responsible'    => 
$this->db->f('budsjettansvarligid'),
-                                               'budsjettsigndato'              
=> $this->db->f('budsjettsigndato'),
-                                               'transfer_time'                 
=> $this->db->f('overftid'),
-                                               'line_text'                     
        => $this->db->f('line_text',true),
-                                               'status_line'                   
=> $status_line
-                                       );
+                                       'counter'                        => $i,
+                                       'claim_issued'           => 
$this->db->f('claim_issued'),
+                                       //              'project_id'            
        => $this->db->f('project_id'),
+                                       'workorder_id'           => 
$this->db->f('pmwrkord_code'),
+                                       'order_id'                       => 
$this->db->f('pmwrkord_code'),
+                                       'status'                         => 
$this->db->f('status', true),
+                                       'closed'                         => 
!!$this->db->f('closed'),
+                                       'project_type_id'        => 
$this->db->f('project_type_id'),
+                                       'periodization_id'       => 
$this->db->f('periodization_id'),
+                                       'voucher_id'             => 
$this->db->f('bilagsnr'),
+                                       'voucher_out_id'         => 
$this->db->f('bilagsnr_ut'),
+                                       'id'                             => 
$this->db->f('id'),
+                                       'invoice_id'             => 
$this->db->f('fakturanr'),
+                                       'budget_account'         => 
$this->db->f('spbudact_code'),
+                                       'dima'                           => 
$this->db->f('dima'),
+                                       'dimb'                           => 
$this->db->f('dimb'),
+                                       'dimd'                           => 
$this->db->f('dimd'),
+                                       'dime'                           => 
$this->db->f('dime'),
+                                       'remark'                         => 
!!$this->db->f('merknad', true),
+                                       'tax_code'                       => 
$this->db->f('mvakode'),
+                                       'amount'                         => 
$this->db->f('belop'),
+                                       'approved_amount'        => 
$this->db->f('godkjentbelop'),
+                                       'charge_tenant'          => 
$this->db->f('charge_tenant'),
+                                       'vendor'                         => 
$this->db->f('org_name', true),
+                                       //                      'paid_percent'  
                => $this->db->f('paid_percent'),
+                                       'project_group'          => 
$this->db->f('project_id'),
+                                       'external_ref'           => 
$this->db->f('external_ref'),
+                                       'currency'                       => 
$this->db->f('currency'),
+                                       'budget_responsible' => 
$this->db->f('budsjettansvarligid'),
+                                       'budsjettsigndato'       => 
$this->db->f('budsjettsigndato'),
+                                       'transfer_time'          => 
$this->db->f('overftid'),
+                                       'line_text'                      => 
$this->db->f('line_text', true),
+                                       'status_line'            => $status_line
+                               );
 
                                $i++;
                        }
@@ -523,24 +520,24 @@
 
                function read_invoice_sub_sum($data)
                {
-                       $start          = isset($data['start']) && 
$data['start'] ? (int)$data['start'] : 0;
-                       $filter         = isset($data['filter']) ? 
$data['filter'] : 'none';
-                       $sort           = isset($data['sort']) ? $data['sort'] 
: 'DESC';
-                       $order          = isset($data['order']) ? 
$data['order'] : '';
-                       $voucher_id     = isset($data['voucher_id']) && 
$data['voucher_id'] ? (int)$data['voucher_id'] : 0;
-                       $paid           = isset($data['paid']) ? $data['paid'] 
: '';
-                       $year           = isset($data['year']) ? $data['year'] 
: '';
-                       $project_id     = isset($data['project_id']) && 
$data['project_id'] ? (int)$data['project_id'] : 0;
-                       $order_id       = isset($data['order_id']) && 
$data['order_id'] ? $data['order_id'] : 0 ;//might be bigint
+                       $start = isset($data['start']) && $data['start'] ? 
(int) $data['start'] : 0;
+                       $filter = isset($data['filter']) ? $data['filter'] : 
'none';
+                       $sort = isset($data['sort']) ? $data['sort'] : 'DESC';
+                       $order = isset($data['order']) ? $data['order'] : '';
+                       $voucher_id = isset($data['voucher_id']) && 
$data['voucher_id'] ? (int) $data['voucher_id'] : 0;
+                       $paid = isset($data['paid']) ? $data['paid'] : '';
+                       $year = isset($data['year']) ? $data['year'] : '';
+                       $project_id = isset($data['project_id']) && 
$data['project_id'] ? (int) $data['project_id'] : 0;
+                       $order_id = isset($data['order_id']) && 
$data['order_id'] ? $data['order_id'] : 0;//might be bigint
 
-                       if ($paid)
+                       if($paid)
                        {
                                $table = 'fm_ecobilagoverf';
                                $overftid = ',overftid';
                        }
                        else
                        {
-                               $table ='fm_ecobilag';
+                               $table = 'fm_ecobilag';
                                $overftid = '';
                        }
 
@@ -559,214 +556,212 @@
                        $filtermethod = '';
                        $where = 'WHERE';
 
-                       if ($voucher_id)
+                       if($voucher_id)
                        {
                                $filtermethod .= " {$where} bilagsnr= 
'$voucher_id'";
                                $where = 'AND';
                        }
 
-                       if ($order_id)
+                       if($order_id)
                        {
                                $filtermethod .= " {$where} pmwrkord_code= 
'{$order_id}'";
                                $where = 'AND';
                        }
 
-                       if ($project_id)
+                       if($project_id)
                        {
                                $filtermethod .= " {$where} fm_project.id = 
'{$project_id}'";
                                $where = 'AND';
                        }
 
-                       if ($year)
+                       if($year)
                        {
                                $filtermethod .= " {$where} ({$table}.periode > 
{$year}00 AND {$table}.periode < {$year}13 OR {$table}.periode IS NULL)";
                                $where = 'AND';
                        }
 
                        $groupmethod = "GROUP BY 
pmwrkord_code,bilagsnr,bilagsnr_ut,fakturanr,"
-                               . " 
currency,budsjettansvarligid,org_name,periode,periodization,periodization_start";
+                       . " 
currency,budsjettansvarligid,org_name,periode,periodization,periodization_start";
 
                        $sql = "SELECT DISTINCT 
pmwrkord_code,bilagsnr,bilagsnr_ut,fakturanr,sum(belop) as belop, 
sum(godkjentbelop) as godkjentbelop,"
-                               . " 
currency,budsjettansvarligid,org_name,periode,periodization,periodization_start"
-                               . " FROM {$table}"
-                               . " {$this->join} fm_ecoart ON fm_ecoart.id = 
$table.artid"
-                               . " {$this->join} fm_workorder ON 
fm_workorder.id = $table.pmwrkord_code"
-                               . " {$this->join} fm_project ON 
fm_workorder.project_id = fm_project.id"
-                               . " {$this->join} fm_vendor ON 
{$table}.spvend_code = fm_vendor.id {$filtermethod} {$groupmethod}";
+                       . " 
currency,budsjettansvarligid,org_name,periode,periodization,periodization_start"
+                       . " FROM {$table}"
+                       . " {$this->join} fm_ecoart ON fm_ecoart.id = 
$table.artid"
+                       . " {$this->join} fm_workorder ON fm_workorder.id = 
$table.pmwrkord_code"
+                       . " {$this->join} fm_project ON fm_workorder.project_id 
= fm_project.id"
+                       . " {$this->join} fm_vendor ON {$table}.spvend_code = 
fm_vendor.id {$filtermethod} {$groupmethod}";
 
-                       $this->db->query($sql . $ordermethod,__LINE__,__FILE__);
+                       $this->db->query($sql . $ordermethod, __LINE__, 
__FILE__);
                        $this->total_records = $this->db->num_rows();
 
                        $values = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $values[] = array
-                               (
-                                       'workorder_id'                  => 
$this->db->f('pmwrkord_code'),
-                                       'voucher_id'                    => 
$this->db->f('bilagsnr'),
-                                       'voucher_out_id'                => 
$this->db->f('bilagsnr_ut'),
-                                       'invoice_id'                    => 
$this->db->f('fakturanr'),
-                                       'amount'                                
=> $this->db->f('belop'),
-                                       'approved_amount'               => 
$this->db->f('godkjentbelop'),
-                                       'vendor'                                
=> $this->db->f('org_name',true),
-                                       'currency'                              
=> $this->db->f('currency'),
-                                       'period'                                
=> $this->db->f('periode'),
-                                       'periodization'                 => 
$this->db->f('periodization'),
-                                       'periodization_start'   => 
$this->db->f('periodization_start'),
-                                       'budget_responsible'    => 
$this->db->f('budsjettansvarligid')
+                                       (
+                                       'workorder_id'                   => 
$this->db->f('pmwrkord_code'),
+                                       'voucher_id'                     => 
$this->db->f('bilagsnr'),
+                                       'voucher_out_id'                 => 
$this->db->f('bilagsnr_ut'),
+                                       'invoice_id'                     => 
$this->db->f('fakturanr'),
+                                       'amount'                                
 => $this->db->f('belop'),
+                                       'approved_amount'                => 
$this->db->f('godkjentbelop'),
+                                       'vendor'                                
 => $this->db->f('org_name', true),
+                                       'currency'                              
 => $this->db->f('currency'),
+                                       'period'                                
 => $this->db->f('periode'),
+                                       'periodization'                  => 
$this->db->f('periodization'),
+                                       'periodization_start'    => 
$this->db->f('periodization_start'),
+                                       'budget_responsible'     => 
$this->db->f('budsjettansvarligid')
                                );
                        }
 
-                       foreach ($values as &$entry)
+                       foreach($values as &$entry)
                        {
                                $sql = "SELECT 
budsjettsigndato{$overftid},fm_ecoart.descr as type"
                                . " FROM {$table} {$this->join} fm_ecoart ON 
fm_ecoart.id = $table.artid"
                                . " WHERE pmwrkord_code = 
'{$entry['workorder_id']}' AND bilagsnr = '{$entry['voucher_id']}' AND 
fakturanr = '{$entry['invoice_id']}'";
 
-                               $this->db->query($sql,__LINE__,__FILE__);
+                               $this->db->query($sql, __LINE__, __FILE__);
                                $this->db->next_record();
-                               $entry['budsjettsigndato']      = 
$this->db->f('budsjettsigndato');
-                               $entry['transfer_time']         = 
$this->db->f('overftid');
-                               $entry['type']                          = 
$this->db->f('type');
+                               $entry['budsjettsigndato'] = 
$this->db->f('budsjettsigndato');
+                               $entry['transfer_time'] = 
$this->db->f('overftid');
+                               $entry['type'] = $this->db->f('type');
                        }
 
                        return $values;
                }
 
-
                function read_consume($data)
                {
                        if(is_array($data))
                        {
-                               $start                  = isset($data['start']) 
&& $data['start'] ? $data['start'] : 0;
-                               $filter                 = 
isset($data['filter'])?$data['filter']:'none';
-                               $query                  = 
isset($data['query'])?$data['query']:'';
-                               $sort                   = 
isset($data['sort'])?$data['sort']:'DESC';
-                               $order                  = 
isset($data['order'])?$data['order']:'';
-                               $cat_id                 = 
isset($data['cat_id']) && $data['cat_id'] ? (int)$data['cat_id']:0;
-                               $start_date     = isset($data['start_date']) && 
$data['start_date'] ? $data['start_date'] : 0;
-                               $end_date               = 
isset($data['end_date']) && $data['end_date'] ? $data['end_date'] : time();
-                               $vendor_id              = 
isset($data['vendor_id'])?(int)$data['vendor_id']:0;
-                               $loc1                   = 
isset($data['loc1'])?$data['loc1']:'';
-                               $district_id    = 
isset($data['district_id'])?(int)$data['district_id']:0;
-                               $workorder_id   = isset($data['workorder_id']) 
&& $data['workorder_id'] ? $data['workorder_id']:0;
-                               $b_account_class = 
isset($data['b_account_class'])?$data['b_account_class']:'';
-                               $b_account              = 
isset($data['b_account']) ? $data['b_account'] : '';
-                               $ecodimb                = 
isset($data['ecodimb'])?$data['ecodimb']:'';
+                               $start = isset($data['start']) && 
$data['start'] ? $data['start'] : 0;
+                               $filter = isset($data['filter']) ? 
$data['filter'] : 'none';
+                               $query = isset($data['query']) ? $data['query'] 
: '';
+                               $sort = isset($data['sort']) ? $data['sort'] : 
'DESC';
+                               $order = isset($data['order']) ? $data['order'] 
: '';
+                               $cat_id = isset($data['cat_id']) && 
$data['cat_id'] ? (int) $data['cat_id'] : 0;
+                               $start_date = isset($data['start_date']) && 
$data['start_date'] ? $data['start_date'] : 0;
+                               $end_date = isset($data['end_date']) && 
$data['end_date'] ? $data['end_date'] : time();
+                               $vendor_id = isset($data['vendor_id']) ? (int) 
$data['vendor_id'] : 0;
+                               $loc1 = isset($data['loc1']) ? $data['loc1'] : 
'';
+                               $district_id = isset($data['district_id']) ? 
(int) $data['district_id'] : 0;
+                               $workorder_id = isset($data['workorder_id']) && 
$data['workorder_id'] ? $data['workorder_id'] : 0;
+                               $b_account_class = 
isset($data['b_account_class']) ? $data['b_account_class'] : '';
+                               $b_account = isset($data['b_account']) ? 
$data['b_account'] : '';
+                               $ecodimb = isset($data['ecodimb']) ? 
$data['ecodimb'] : '';
                        }
 
                        $where = 'AND';
 
                        if($b_account_class)
                        {
-                               $filtermethod= " $where 
fm_b_account.category='$b_account_class'";
-                               $where= 'AND';
+                               $filtermethod = " $where 
fm_b_account.category='$b_account_class'";
+                               $where = 'AND';
                        }
                        else
                        {
-                               $select_account_class=',fm_b_account.category 
as b_account_class';
-                               $group_account_class=', 
spbudact_code,fm_b_account.category';
+                               $select_account_class = ',fm_b_account.category 
as b_account_class';
+                               $group_account_class = ', 
spbudact_code,fm_b_account.category';
                        }
 
-                       if ($b_account)
+                       if($b_account)
                        {
                                $filtermethod .= " {$where} fm_b_account.id = 
'{$b_account}'";
-                               $where= 'AND';
-                               $select_account_class=',fm_b_account.id as 
b_account_class';
-                               $group_account_class=', 
spbudact_code,fm_b_account.id';
-
+                               $where = 'AND';
+                               $select_account_class = ',fm_b_account.id as 
b_account_class';
+                               $group_account_class = ', 
spbudact_code,fm_b_account.id';
                        }
 
 
-                       if ($vendor_id)
+                       if($vendor_id)
                        {
                                $filtermethod .= " $where (spvend_code = 
$vendor_id)";
-                               $where= 'AND';
+                               $where = 'AND';
                        }
 
                        if($loc1)
                        {
                                $filtermethod .=" $where (dima $this->like 
'%$loc1%')";
-                               $where= 'AND';
+                               $where = 'AND';
                        }
 
 
-                       if ($district_id)
+                       if($district_id)
                        {
                                $filtermethod.= " $where district_id= 
$district_id ";
-                               $where= 'AND';
+                               $where = 'AND';
                        }
 
-                       if ($workorder_id)
+                       if($workorder_id)
                        {
                                $filtermethod.= " $where pmwrkord_code = 
'{$workorder_id}'";
-                               $where= 'AND';
+                               $where = 'AND';
                        }
 
 
-                       if ($cat_id>0)
+                       if($cat_id > 0)
                        {
                                $filtermethod .= " $where typeid = $cat_id";
-                               $where= 'AND';
+                               $where = 'AND';
                        }
 
                        if($ecodimb)
                        {
-                               $filtermethod .= " $where dimb = " . 
(int)$ecodimb;
-                               $where= 'AND';
+                               $filtermethod .= " $where dimb = " . (int) 
$ecodimb;
+                               $where = 'AND';
                        }
 
-                       $start_periode = date('Ym',$start_date);
-                       $end_periode = date('Ym',$end_date);
+                       $start_periode = date('Ym', $start_date);
+                       $end_periode = date('Ym', $end_date);
 
                        $sql = "SELECT district_id,periode,sum(godkjentbelop) 
as consume {$select_account_class}"
-                               . " FROM  fm_ecobilagoverf {$this->join} 
fm_location1 ON (fm_ecobilagoverf.loc1 = fm_location1.loc1) "
-                               . " {$this->join} fm_part_of_town ON 
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id) "
-                               . " {$this->join} fm_b_account ON 
(fm_ecobilagoverf.spbudact_code = fm_b_account.id) "
-                               . " WHERE (periode >='{$start_periode}' AND 
periode <= '{$end_periode}' {$filtermethod})"
-                               . " GROUP BY district_id,periode 
$group_account_class"
-                               . " ORDER BY periode";
+                       . " FROM  fm_ecobilagoverf {$this->join} fm_location1 
ON (fm_ecobilagoverf.loc1 = fm_location1.loc1) "
+                       . " {$this->join} fm_part_of_town ON 
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id) "
+                       . " {$this->join} fm_b_account ON 
(fm_ecobilagoverf.spbudact_code = fm_b_account.id) "
+                       . " WHERE (periode >='{$start_periode}' AND periode <= 
'{$end_periode}' {$filtermethod})"
+                       . " GROUP BY district_id,periode $group_account_class"
+                       . " ORDER BY periode";
                        //echo $sql;
 
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->query($sql, __LINE__, __FILE__);
                        $this->total_records = $this->db->num_rows();
 
                        $consume = array();
 
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $consume[] = array
-                               (
-                                       'consume'               => 
round($this->db->f('consume')),
-                                       'period'                => 
$this->db->f('periode'),
-                                       'district_id'   => 
$this->db->f('district_id'),
-                                       'account_class' => $b_account_class ? 
$b_account_class : $this->db->f('b_account_class'),
-                                       'paid'                  => 'x'
+                                       (
+                                       'consume'                => 
round($this->db->f('consume')),
+                                       'period'                 => 
$this->db->f('periode'),
+                                       'district_id'    => 
$this->db->f('district_id'),
+                                       'account_class'  => $b_account_class ? 
$b_account_class : $this->db->f('b_account_class'),
+                                       'paid'                   => 'x'
                                );
                        }
 
                        $filtermethod = ltrim($filtermethod, ' AND ');
 
                        $sql = "SELECT district_id,periode,sum(godkjentbelop) 
as consume {$select_account_class}"
-                               . " FROM  fm_ecobilag {$this->join} 
fm_location1 ON (fm_ecobilag.loc1 = fm_location1.loc1) "
-                               . " {$this->join} fm_part_of_town ON 
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id) "
-                               . " {$this->join} fm_b_account ON 
(fm_ecobilag.spbudact_code = fm_b_account.id) "
-                               . " WHERE ({$filtermethod})"
-                               . " GROUP BY district_id,periode 
$group_account_class"
-                               . " ORDER BY periode";
+                       . " FROM  fm_ecobilag {$this->join} fm_location1 ON 
(fm_ecobilag.loc1 = fm_location1.loc1) "
+                       . " {$this->join} fm_part_of_town ON 
(fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id) "
+                       . " {$this->join} fm_b_account ON 
(fm_ecobilag.spbudact_code = fm_b_account.id) "
+                       . " WHERE ({$filtermethod})"
+                       . " GROUP BY district_id,periode $group_account_class"
+                       . " ORDER BY periode";
 
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->query($sql, __LINE__, __FILE__);
                        $this->total_records += $this->db->num_rows();
 
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $consume[] = array
-                               (
-                                       'consume'               => 
round($this->db->f('consume')),
-                                       'period'                => 
$this->db->f('periode'),
-                                       'district_id'   => 
$this->db->f('district_id'),
-                                       'account_class' => $b_account_class ? 
$b_account_class : $this->db->f('b_account_class'),
-                                       'paid'                  => ''
+                                       (
+                                       'consume'                => 
round($this->db->f('consume')),
+                                       'period'                 => 
$this->db->f('periode'),
+                                       'district_id'    => 
$this->db->f('district_id'),
+                                       'account_class'  => $b_account_class ? 
$b_account_class : $this->db->f('b_account_class'),
+                                       'paid'                   => ''
                                );
                        }
 
@@ -775,37 +770,37 @@
 
                function check_for_updates($values)
                {
-                       $update=false;
+                       $update = false;
 
-                       if($values['sign_orig']!=$values['sign'])
+                       if($values['sign_orig'] != $values['sign'])
                        {
-                               $update=true;
+                               $update = true;
                                return $update;
                        }
 
                        $sql = "SELECT * FROM fm_ecobilag WHERE bilagsnr=" . 
$values['voucher_id'];
-                       $this->db->limit_query($sql,0,__LINE__,__FILE__,1);
+                       $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
 
                        $this->db->next_record();
 
-                       if( ($this->db->f('utbetalingsigndato') && 
!$values['transfer']) || (!$this->db->f('utbetalingsigndato') && 
$values['transfer']))
+                       if(($this->db->f('utbetalingsigndato') && 
!$values['transfer']) || (!$this->db->f('utbetalingsigndato') && 
$values['transfer']))
                        {
-                               $update=true;
+                               $update = true;
                                return $update;
                        }
 
-                       if( ($this->db->f('kreditnota') && 
!$values['kreditnota']) || (!$this->db->f('kreditnota') && 
$values['kreditnota']) )
+                       if(($this->db->f('kreditnota') && 
!$values['kreditnota']) || (!$this->db->f('kreditnota') && 
$values['kreditnota']))
                        {
-                               $update=true;
+                               $update = true;
                                return $update;
                        }
 
-                       $timestamp_voucher_date= 
mktime(0,0,0,date('m',strtotime($this->db->f('fakturadato'))),date('d',strtotime($this->db->f('fakturadato'))),date('y',strtotime($this->db->f('fakturadato'))));
-                       $timestamp_payment_date= 
mktime(0,0,0,date('m',strtotime($this->db->f('forfallsdato'))),date('d',strtotime($this->db->f('forfallsdato'))),date('y',strtotime($this->db->f('forfallsdato'))));
+                       $timestamp_voucher_date = mktime(0, 0, 0, date('m', 
strtotime($this->db->f('fakturadato'))), date('d', 
strtotime($this->db->f('fakturadato'))), date('y', 
strtotime($this->db->f('fakturadato'))));
+                       $timestamp_payment_date = mktime(0, 0, 0, date('m', 
strtotime($this->db->f('forfallsdato'))), date('d', 
strtotime($this->db->f('forfallsdato'))), date('y', 
strtotime($this->db->f('forfallsdato'))));
 
-                       if( 
((intval(($timestamp_payment_date-$timestamp_voucher_date)/(24*3600)))!=$values['num_days'])
 )
+                       if(((intval(($timestamp_payment_date - 
$timestamp_voucher_date) / (24 * 3600))) != $values['num_days']))
                        {
-                               $update=true;
+                               $update = true;
                                return $update;
                        }
                }
@@ -816,117 +811,126 @@
                        $receipt = array();
                        $GLOBALS['phpgw']->db->transaction_begin();
 
-                       while($entry=each($values['counter']))
+                       while($entry = each($values['counter']))
                        {
-                               $local_error='';
+                               $local_error = false;
 
-                               $n=$entry[0];
+                               $n = $entry[0];
 
                                //_debug_array($entry);
-                               $id                     = 
(int)$values['id'][$n];
+                               $id = (int) $values['id'][$n];
                                $approved_amount = 
isset($values['approved_amount'][$n]) && $values['approved_amount'][$n] ? 
str_replace(',', '.', $values['approved_amount'][$n]) : 0;
                                if(!$approved_amount || $approved_amount == 
'00.0')
                                {
                                        $GLOBALS['phpgw']->db->query("UPDATE 
fm_ecobilag SET godkjentbelop = $approved_amount WHERE id='$id'");
-                                       $receipt['message'][] = 
array('msg'=>lang('Voucher is updated '));
+                                       $receipt['message'][] = array('msg' => 
lang('Voucher is updated '));
                                        continue;
                                }
 
-                               if ($values['budget_account'][$n])
+                               if($values['budget_account'][$n])
                                {
-                                       
$budget_account=$values['budget_account'][$n];
+                                       $budget_account = 
$values['budget_account'][$n];
 
                                        $GLOBALS['phpgw']->db->query("select 
count(*) as cnt from fm_b_account  where id ='{$budget_account}'");
                                        $GLOBALS['phpgw']->db->next_record();
-                                       if ($GLOBALS['phpgw']->db->f('cnt') == 
0)
+                                       if($GLOBALS['phpgw']->db->f('cnt') == 0)
                                        {
-                                               $receipt['error'][] = 
array('msg'=> lang('This account is not valid:'). " ".$budget_account);
-                                               $local_error= true;
+                                               $receipt['error'][] = 
array('msg' => lang('This account is not valid:') . " " . $budget_account);
+                                               $local_error = true;
                                        }
                                }
                                else
                                {
-                                       $receipt['error'][] = 
array('msg'=>lang('Budget account is missing:'));
-                                       $local_error= true;
+                                       $receipt['error'][] = array('msg' => 
lang('Budget account is missing:'));
+                                       $local_error = true;
                                }
 
                                if(!$values['dimd'][$n])
                                {
-                                       $dimd_field="dimd=NULL";
+                                       $dimd_field = "dimd=NULL";
+                                       $local_error = true;
+                                       $receipt['error'][] = array('msg' => 
lang('Dim D is mandatory'));
                                }
                                else
                                {
-                                       $dimd=$values['dimd'][$n];
+                                       $dimd = $values['dimd'][$n];
                                        $GLOBALS['phpgw']->db->query("select 
count(*) as cnt from fm_ecodimd where id ='$dimd'");
                                        $GLOBALS['phpgw']->db->next_record();
-                                       if ($GLOBALS['phpgw']->db->f('cnt') == 
0)
+                                       if($GLOBALS['phpgw']->db->f('cnt') == 0)
                                        {
-                                               $receipt['error'][] = 
array('msg'=>lang('This Dim D is not valid:'). " ".$dimd);
-                                               $local_error= true;
+                                               $receipt['error'][] = 
array('msg' => lang('This Dim D is not valid:') . " " . $dimd);
+                                               $local_error = true;
                                        }
 
-                                       $dimd_field="dimd="."'" . $dimd . "'";
+                                       $dimd_field = "dimd=" . "'" . $dimd . 
"'";
                                }
 
-                               if (!$values['dima'][$n])
+                               if(!$values['dima'][$n])
                                {
-                                       $dima_field="dima=NULL";
-                                       $receipt['error'][] = 
array('msg'=>lang('Dim A is missing'));
-                                       $local_error= true;
+                                       $dima_field = "dima=NULL";
+                                       $receipt['error'][] = array('msg' => 
lang('Dim A is missing'));
+                                       $local_error = true;
                                }
                                else
                                {
-                                       
$dima_check=substr($values['dima'][$n],0,4);
+                                       $dima_check = 
substr($values['dima'][$n], 0, 4);
                                        $GLOBALS['phpgw']->db->query("select 
loc1, kostra_id from fm_location1 where loc1 = '$dima_check' ");
                                        $GLOBALS['phpgw']->db->next_record();
-                                       if (!$GLOBALS['phpgw']->db->f('loc1'))
+                                       if(!$GLOBALS['phpgw']->db->f('loc1'))
                                        {
-                                               $receipt['error'][] = 
array('msg'=>lang('This Dim A is not valid:'). " ".$values['dima'][$n]);
-                                               $local_error= true;
+                                               $receipt['error'][] = 
array('msg' => lang('This Dim A is not valid:') . " " . $values['dima'][$n]);
+                                               $local_error = true;
                                        }
 
-                                       if 
(!$GLOBALS['phpgw']->db->f('kostra_id') || 
$GLOBALS['phpgw']->db->f('kostra_id') == 0)
+                                       
if(!$GLOBALS['phpgw']->db->f('kostra_id') || 
$GLOBALS['phpgw']->db->f('kostra_id') == 0)
                                        {
-                                               $receipt['error'][] = 
array('msg'=>'objektet mangler tjeneste - utgått? '. " ".$values['dima'][$n]);
-                                               $local_error= true;
+                                               $receipt['error'][] = 
array('msg' => 'objektet mangler tjeneste - utgått? ' . " " . 
$values['dima'][$n]);
+                                               $local_error = true;
                                        }
 
                                        //      $dima_field="dima="."'" . 
$values['dima'][$n] . "'";
-                                       $dima_field="dima="."'" . 
$values['dima'][$n] . "',loc1=" . "'" . substr($values['dima'][$n],0,4) . "'";
+                                       $dima_field = "dima=" . "'" . 
$values['dima'][$n] . "',loc1=" . "'" . substr($values['dima'][$n], 0, 4) . "'";
 
-                                       $kostra_field="kostra_id="."'" . 
$GLOBALS['phpgw']->db->f('kostra_id') . "'";
-
+                                       $kostra_field = "kostra_id=" . "'" . 
$GLOBALS['phpgw']->db->f('kostra_id') . "'";
                                }
 
-                               if (! $local_error)
+                               if(!$local_error)
                                {
-                                       $tax_code       = 
(int)$values['tax_code'][$n];
-                                       $dimb           = 
isset($values['dimb'][$n]) && $values['dimb'][$n] ? (int)$values['dimb'][$n] : 
'NULL';
-                                       
$workorder_id=$values['workorder_id'][$n];
+                                       $tax_code = (int) 
$values['tax_code'][$n];
+                                       $dimb = isset($values['dimb'][$n]) && 
$values['dimb'][$n] ? (int) $values['dimb'][$n] : 'NULL';
+                                       $workorder_id = 
$values['workorder_id'][$n];
                                        if(isset($values['close_order'][$n]) && 
$values['close_order'][$n] && !$values['close_order_orig'][$n])
                                        {
-                                               
$update_status[$workorder_id]='X';
+                                               $update_status[$workorder_id] = 
'X';
                                        }
 
                                        if((!isset($values['close_order'][$n]) 
|| !$values['close_order'][$n]) && (isset($values['close_order_orig'][$n]) && 
$values['close_order_orig'][$n]))
                                        {
-                                               
$update_status[$workorder_id]='R';
+                                               $update_status[$workorder_id] = 
'R';
                                        }
 
-/*
-                                       if(isset($values['paid_percent'][$n]) 
&& $values['paid_percent'][$n])
+                                       /*
+                                         if(isset($values['paid_percent'][$n]) 
&& $values['paid_percent'][$n])
+                                         {
+                                         $update_paid_percent[$workorder_id] = 
$values['paid_percent'][$n];
+                                         }
+                                        */
+                                       if($values['workorder_id'][$n])
                                        {
-                                               
$update_paid_percent[$workorder_id] = $values['paid_percent'][$n];
+                                               
$GLOBALS['phpgw']->db->query("SELECT id FROM fm_workorder WHERE id = 
'{$values['workorder_id'][$n]}'", __LINE__, __FILE__);
+                                               if($this->db->next_record())
+                                               {
+                                                       
$GLOBALS['phpgw']->db->query("UPDATE fm_workorder SET category = 
'{$values['dimd'][$n]}' WHERE id='{$values['workorder_id'][$n]}'", __LINE__, 
__FILE__);
+                                               }
                                        }
-*/
-                                       $GLOBALS['phpgw']->db->query("UPDATE 
fm_ecobilag SET $dima_field ,$kostra_field,{$dimd_field}, mvakode = 
{$tax_code},spbudact_code = '{$budget_account}',dimb = $dimb,godkjentbelop = 
$approved_amount WHERE id='$id'");
 
-                                       $receipt['message'][] = 
array('msg'=>lang('Voucher is updated '));
-                               }
+                                       $GLOBALS['phpgw']->db->query("UPDATE 
fm_ecobilag SET $dima_field ,$kostra_field,{$dimd_field}, mvakode = 
{$tax_code},spbudact_code = '{$budget_account}',dimb = $dimb,godkjentbelop = 
$approved_amount WHERE id='{$id}'", __LINE__, __FILE__);
 
+                                       $receipt['message'][] = array('msg' => 
lang('Voucher is updated '));
+                               }
                        }
 
-                       if ($update_status)
+                       if($update_status)
                        {
                                $closed = 
isset($this->config->config_data['workorder_closed_status']) && 
$this->config->config_data['workorder_closed_status'] ? 
$this->config->config_data['workorder_closed_status'] : '';
                                $reopen = 
isset($this->config->config_data['workorder_reopen_status']) && 
$this->config->config_data['workorder_reopen_status'] ? 
$this->config->config_data['workorder_reopen_status'] : '';
@@ -940,48 +944,52 @@
                                        throw new 
Exception('property_soinvoice::update_invoice_sub() - "workorder_reopen_status" 
not configured');
                                }
 
-                               $status_code=array('X' => $closed,'R' => 
$reopen);
+                               $status_code = array('X' => $closed, 'R' => 
$reopen);
 
-                               $historylog_workorder   = 
CreateObject('property.historylog','workorder');
+                               $historylog_workorder = 
CreateObject('property.historylog', 'workorder');
 
-                               foreach ($update_status as $id => $entry)
+                               foreach($update_status as $id => $entry)
                                {
-                                       $this->db->query("SELECT type FROM 
fm_orders WHERE id={$id}",__LINE__,__FILE__);
+                                       $this->db->query("SELECT type FROM 
fm_orders WHERE id={$id}", __LINE__, __FILE__);
                                        $this->db->next_record();
-                                       switch ( $this->db->f('type') )
+                                       switch($this->db->f('type'))
                                        {
                                                case 'workorder':
-                                                       
$historylog_workorder->add($entry,$id,$status_code[$entry]);
-                                                       
$GLOBALS['phpgw']->db->query("UPDATE fm_workorder set status=" . 
"'{$status_code[$entry]}'" . "where id=$id");
-                                                       $receipt['message'][] = 
array('msg'=>lang('Workorder %1 is %2',$id, $status_code[$entry]));
+                                                       
$GLOBALS['phpgw']->db->query("SELECT id FROM fm_workorder WHERE 
status='{$status_code[$entry]}' AND id = {$id}");
+                                                       
if(!$this->db->next_record())
+                                                       {
+                                                               
$historylog_workorder->add($entry, $id, $status_code[$entry]);
+                                                               
$GLOBALS['phpgw']->db->query("UPDATE fm_workorder set 
status='{$status_code[$entry]}' WHERE id = {$id}");
+                                                               
$receipt['message'][] = array('msg' => lang('Workorder %1 is %2', $id, 
$status_code[$entry]));
+                                                       }
                                                        break;
                                        }
                                }
                        }
 
-/*
-                       if (isset($update_paid_percent) AND 
is_array($update_paid_percent))
-                       {
-                               $workorder = 
CreateObject('property.soworkorder');
-                               foreach ($update_paid_percent as $workorder_id 
=> $paid_percent)
-                               {
-                                       $paid_percent = (int) $paid_percent;
-                                       $GLOBALS['phpgw']->db->query("UPDATE 
fm_workorder set paid_percent={$paid_percent} WHERE id= '$workorder_id'");
+                       /*
+                         if (isset($update_paid_percent) AND 
is_array($update_paid_percent))
+                         {
+                         $workorder = CreateObject('property.soworkorder');
+                         foreach ($update_paid_percent as $workorder_id => 
$paid_percent)
+                         {
+                         $paid_percent = (int) $paid_percent;
+                         $GLOBALS['phpgw']->db->query("UPDATE fm_workorder set 
paid_percent={$paid_percent} WHERE id= '$workorder_id'");
 
-                                       $this->db->query("SELECT type FROM 
fm_orders WHERE id='{$workorder_id}'",__LINE__,__FILE__);
-                                       $this->db->next_record();
-                                       switch ( $this->db->f('type') )
-                                       {
-                                       case 'workorder':
-                                               $this->db->query("SELECT 
project_id FROM fm_workorder WHERE id='{$workorder_id}'",__LINE__,__FILE__);
-                                               $this->db->next_record();
-                                               $project_id = 
$this->db->f('project_id');
-                                               
$workorder->update_planned_cost($project_id);
-                                               break;
-                                       }
-                               }
-                       }
-*/
+                         $this->db->query("SELECT type FROM fm_orders WHERE 
id='{$workorder_id}'",__LINE__,__FILE__);
+                         $this->db->next_record();
+                         switch ( $this->db->f('type') )
+                         {
+                         case 'workorder':
+                         $this->db->query("SELECT project_id FROM fm_workorder 
WHERE id='{$workorder_id}'",__LINE__,__FILE__);
+                         $this->db->next_record();
+                         $project_id = $this->db->f('project_id');
+                         $workorder->update_planned_cost($project_id);
+                         break;
+                         }
+                         }
+                         }
+                        */
                        $GLOBALS['phpgw']->db->transaction_commit();
 
                        return $receipt;
@@ -991,32 +999,32 @@
                {
                        $this->db->transaction_begin();
 
-                       $id = (int)$values['id'];
+                       $id = (int) $values['id'];
 
-                       $table ='fm_ecobilag';
+                       $table = 'fm_ecobilag';
 
                        if($paid) // only minor corrections are allowed
                        {
                                $table = 'fm_ecobilagoverf';
 
                                $value_set = array
-                               (
-               //                      'project_id'    => 
$values['project_group'] ? $values['project_group'] : '',
-                                       'pmwrkord_code' => $values['order_id'],
-               //                      'process_log'   => 
$this->db->db_addslashes($values['process_log']),
-               //                      'process_code'  => 
$values['process_code'],
+                                       (
+                                       //                      'project_id'    
=> $values['project_group'] ? $values['project_group'] : '',
+                                       'pmwrkord_code' => $values['order_id'],
+                               //                      'process_log'   => 
$this->db->db_addslashes($values['process_log']),
+                               //                      'process_code'  => 
$values['process_code'],
                                );
 
-                               $value_set      = 
$this->db->validate_update($value_set);
+                               $value_set = 
$this->db->validate_update($value_set);
 
-                               $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$id}" ,__LINE__,__FILE__);
+                               $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$id}", __LINE__, __FILE__);
 
                                return $this->db->transaction_commit();
                        }
 
-                       if( $values['approve'] != $values['sign_orig'] )
+                       if($values['approve'] != $values['sign_orig'])
                        {
-                               switch ( $values['sign_orig'] )
+                               switch($values['sign_orig'])
                                {
                                        case 'is_janitor':
                                                $value_set['oppsynsigndato'] = 
null;
@@ -1029,18 +1037,18 @@
                                                break;
                                }
 
-                               switch ( $values['approve'] )
+                               switch($values['approve'])
                                {
                                        case 'is_janitor':
-                                               $value_set['oppsynsigndato'] = 
date( $this->db->datetime_format() );
+                                               $value_set['oppsynsigndato'] = 
date($this->db->datetime_format());
                                                $value_set['oppsynsmannid'] = 
$values['my_initials'];
                                                break;
                                        case 'is_supervisor':
-                                               $value_set['saksigndato'] = 
date( $this->db->datetime_format() );
+                                               $value_set['saksigndato'] = 
date($this->db->datetime_format());
                                                $value_set['saksbehandlerid'] = 
$values['my_initials'];
                                                break;
                                        case 'is_budget_responsible':
-                                               $value_set['budsjettsigndato'] 
= date( $this->db->datetime_format() );
+                                               $value_set['budsjettsigndato'] 
= date($this->db->datetime_format());
                                                
$value_set['budsjettansvarligid'] = $values['my_initials'];
                                                break;
                                }
@@ -1048,39 +1056,39 @@
 
                                if(isset($value_set['budsjettansvarligid']) && 
!$value_set['budsjettansvarligid'])
                                {
-                                       phpgwapi_cache::message_set( 'Mangler 
anviser','error');
+                                       phpgwapi_cache::message_set('Mangler 
anviser', 'error');
                                }
                                else
                                {
-                                       $value_set      = 
$this->db->validate_update($value_set);
-                                       $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$id}" ,__LINE__,__FILE__);
+                                       $value_set = 
$this->db->validate_update($value_set);
+                                       $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$id}", __LINE__, __FILE__);
                                }
                        }
 
                        $value_set = array
-                       (
-                               'godkjentbelop' => $values['approved_amount'],
-                               'project_id'    => $values['project_group'] ? 
$values['project_group'] : '',
-                               'pmwrkord_code' => $values['order_id'],
-                               'process_log'   => 
$this->db->db_addslashes($values['process_log']),
-                               'process_code'  => $values['process_code'],
+                               (
+                               'godkjentbelop'  => $values['approved_amount'],
+                               'project_id'     => $values['project_group'] ? 
$values['project_group'] : '',
+                               'pmwrkord_code'  => $values['order_id'],
+                               'process_log'    => 
$this->db->db_addslashes($values['process_log']),
+                               'process_code'   => $values['process_code'],
                        );
 
 
-                       $value_set      = 
$this->db->validate_update($value_set);
+                       $value_set = $this->db->validate_update($value_set);
 
-                       $this->db->query("UPDATE {$table} SET $value_set WHERE 
id= {$id}" ,__LINE__,__FILE__);
+                       $this->db->query("UPDATE {$table} SET $value_set WHERE 
id= {$id}", __LINE__, __FILE__);
 
                        if(!$values['approved_amount'])
                        {
-                               $this->db->query("UPDATE {$table} SET 
godkjentbelop = 0 WHERE id= {$id}" ,__LINE__,__FILE__);
+                               $this->db->query("UPDATE {$table} SET 
godkjentbelop = 0 WHERE id= {$id}", __LINE__, __FILE__);
                        }
 
                        if(isset($values['split_line']) && 
$values['split_amount'] && isset($values['split_amount']) && 
$values['split_amount'])
                        {
                                $metadata = $this->db->metadata($table);
-                               $sql ="SELECT * FROM {$table} WHERE id= {$id}";
-                               $this->db->query($sql,__LINE__,__FILE__);
+                               $sql = "SELECT * FROM {$table} WHERE id= {$id}";
+                               $this->db->query($sql, __LINE__, __FILE__);
                                $this->db->next_record();
 
                                $value_set = array();
@@ -1089,49 +1097,49 @@
                                {
                                        if($_field->name != 'id')
                                        {
-                                               $value_set[$_field->name] = 
$this->db->f($_field->name,true);
+                                               $value_set[$_field->name] = 
$this->db->f($_field->name, true);
                                        }
                                }
 
-                               $this->db->query( "INSERT INTO {$table} (" . 
implode( ',', array_keys($value_set) ) . ')'
-                                       . ' VALUES (' . 
$this->db->validate_insert( array_values($value_set) ) . ')',__LINE__,__FILE__);
+                               $this->db->query("INSERT INTO {$table} (" . 
implode(',', array_keys($value_set)) . ')'
+                               . ' VALUES (' . 
$this->db->validate_insert(array_values($value_set)) . ')', __LINE__, __FILE__);
 
-                               $new_id = 
$this->db->get_last_insert_id($table,'id');
+                               $new_id = $this->db->get_last_insert_id($table, 
'id');
 
-                               $this->db->query("SELECT belop FROM {$table} 
WHERE id={$id}",__LINE__,__FILE__);
+                               $this->db->query("SELECT belop FROM {$table} 
WHERE id={$id}", __LINE__, __FILE__);
                                $this->db->next_record();
                                $amount = $this->db->f('belop');
                                $new_amount = $amount - $values['split_amount'];
 
-                               $value_set= array
-                               (
-                                       'belop'                 => $new_amount,
-                                       'godkjentbelop' => $new_amount,
+                               $value_set = array
+                                       (
+                                       'belop'                  => $new_amount,
+                                       'godkjentbelop'  => $new_amount,
                                );
-                               $value_set      = 
$this->db->validate_update($value_set);
-                               $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$id}" ,__LINE__,__FILE__);
+                               $value_set = 
$this->db->validate_update($value_set);
+                               $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$id}", __LINE__, __FILE__);
 
-                               $value_set= array
-                               (
-                                       'belop'                 => 
$values['split_amount'],
-                                       'godkjentbelop' => 
$values['split_amount'],
+                               $value_set = array
+                                       (
+                                       'belop'                  => 
$values['split_amount'],
+                                       'godkjentbelop'  => 
$values['split_amount'],
                                );
-                               $value_set      = 
$this->db->validate_update($value_set);
-                               $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$new_id}" ,__LINE__,__FILE__);
+                               $value_set = 
$this->db->validate_update($value_set);
+                               $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$new_id}", __LINE__, __FILE__);
                        }
 
                        return $this->db->transaction_commit();
                }
 
-               function read_remark($id='',$paid='')
+               function read_remark($id = '', $paid = '')
                {
-                       if ($paid)
+                       if($paid)
                        {
                                $table = 'fm_ecobilagoverf';
                        }
                        else
                        {
-                               $table ='fm_ecobilag';
+                               $table = 'fm_ecobilag';
                        }
 
                        $this->db->query(" SELECT merknad from $table  where 
id= '$id'");
@@ -1151,26 +1159,25 @@
                        {
                                $dimb = (int) $dimb;
                                $filter_dimb = $dimb ? "AND ecodimb = {$dimb}" 
: '';
-                               $this->db->query("SELECT user_id FROM 
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id IN (1, 2, 
3) {$filter_dimb} AND expired_on IS NULL AND active_from < " . time(). ' AND 
(active_to > ' . time() . ' OR active_to = 0)');
+                               $this->db->query("SELECT user_id FROM 
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id IN (1, 2, 
3) {$filter_dimb} AND expired_on IS NULL AND active_from < " . time() . ' AND 
(active_to > ' . time() . ' OR active_to = 0)');
                                $this->db->next_record();
                                $this->role['is_janitor'] = 
!!$this->db->f('user_id');
 
-                               $this->db->query("SELECT user_id FROM 
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id IN (2, 3) 
{$filter_dimb} AND expired_on IS NULL AND active_from < " . time(). ' AND 
(active_to > ' . time() . ' OR active_to = 0)');
+                               $this->db->query("SELECT user_id FROM 
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id IN (2, 3) 
{$filter_dimb} AND expired_on IS NULL AND active_from < " . time() . ' AND 
(active_to > ' . time() . ' OR active_to = 0)');
                                $this->db->next_record();
                                $this->role['is_supervisor'] = 
!!$this->db->f('user_id');
 
-                               $this->db->query("SELECT user_id FROM 
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id IN (3) 
{$filter_dimb} AND expired_on IS NULL AND active_from < " . time(). ' AND 
(active_to > ' . time() . ' OR active_to = 0)');
+                               $this->db->query("SELECT user_id FROM 
fm_ecodimb_role_user WHERE user_id = {$this->account_id} AND role_id IN (3) 
{$filter_dimb} AND expired_on IS NULL AND active_from < " . time() . ' AND 
(active_to > ' . time() . ' OR active_to = 0)');
                                $this->db->next_record();
                                $this->role['is_budget_responsible'] = 
!!$this->db->f('user_id');
-
                        }
                        else
                        {
                                $this->role = array(
-                                       'is_janitor'                            
=> $this->acl->check('.invoice', 32, 'property'),
-                                       'is_supervisor'                         
=> $this->acl->check('.invoice', 64, 'property'),
-                                       'is_budget_responsible'         => 
$this->acl->check('.invoice', 128, 'property'),
-                                       'is_transfer'                           
=> $this->acl->check('.invoice', 16, 'property')
+                                       'is_janitor'                     => 
$this->acl->check('.invoice', 32, 'property'),
+                                       'is_supervisor'                  => 
$this->acl->check('.invoice', 64, 'property'),
+                                       'is_budget_responsible'  => 
$this->acl->check('.invoice', 128, 'property'),
+                                       'is_transfer'                    => 
$this->acl->check('.invoice', 16, 'property')
                                );
                        }
                        return $this->role;
@@ -1180,7 +1187,7 @@
                {
                        $filter_dimb = $dimb ? "AND ecodimb = {$dimb}" : '';
                        $role_id = (int) $role_id;
-                       switch ($role_id)
+                       switch($role_id)
                        {
                                case 1:
                                        $role_filter = "role_id IN (1, 2, 3)";
@@ -1204,17 +1211,17 @@
                        . " ORDER BY account_lastname ASC, account_firstname 
ASC";
 
 //_debug_array($sql);
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->query($sql, __LINE__, __FILE__);
 
                        $values = array();
                        while($this->db->next_record())
                        {
                                $id = $this->db->f('account_lid');
                                $values[] = array
-                               (
-                                       'id'            => $id,
-                                       'name'          => 
$this->db->f('account_lastname') . ', ' . $this->db->f('account_firstname'),
-                                       'selected'      => $selected == $id ? 1 
: 0
+                                       (
+                                       'id'             => $id,
+                                       'name'           => 
$this->db->f('account_lastname') . ', ' . $this->db->f('account_firstname'),
+                                       'selected'       => $selected == $id ? 
1 : 0
                                );
                        }
                        return $values;
@@ -1222,14 +1229,14 @@
 
                function get_default_dimb_role_user($role_id, $dimb)
                {
-                       $dimb           = (int) $dimb;
-                       $role_id        = (int) $role_id;
+                       $dimb = (int) $dimb;
+                       $role_id = (int) $role_id;
                        $sql = "SELECT user_id FROM fm_ecodimb_role_user"
-                       ." WHERE role_id = {$role_id} AND ecodimb = {$dimb} AND 
expired_on IS NULL AND default_user = 1  AND active_from < " . time(). ' AND 
(active_to > ' . time() . ' OR active_to = 0)';
+                       . " WHERE role_id = {$role_id} AND ecodimb = {$dimb} 
AND expired_on IS NULL AND default_user = 1  AND active_from < " . time() . ' 
AND (active_to > ' . time() . ' OR active_to = 0)';
 //_debug_array($sql);
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->query($sql, __LINE__, __FILE__);
                        $this->db->next_record();
-                       return (int)$this->db->f('user_id');
+                       return (int) $this->db->f('user_id');
                }
 
                function check_count($voucher_id)
@@ -1239,10 +1246,10 @@
                        $this->db->next_record();
 
                        $check_count = array
-                       (
-                               'dima_count'                            => 
$this->db->f('dima_count'),
-                               'spbudact_code_count'           => 
$this->db->f('spbudact_code_count'),
-                               'invoice_count'                         => 
$this->db->f('invoice_count'),
+                               (
+                               'dima_count'                     => 
$this->db->f('dima_count'),
+                               'spbudact_code_count'    => 
$this->db->f('spbudact_code_count'),
+                               'invoice_count'                  => 
$this->db->f('invoice_count'),
                        );
 
                        $this->db->query("select count(kostra_id) as 
kostra_count  from fm_ecobilag where bilagsnr ='$voucher_id' and kostra_id > 
0");
@@ -1252,8 +1259,7 @@
                        return $check_count;
                }
 
-
-               function update_period($voucher_id='',$period='')
+               function update_period($voucher_id = '', $period = '')
                {
                        $receipt = array();
                        $this->db->transaction_begin();
@@ -1262,11 +1268,11 @@
 
                        $this->db->transaction_commit();
 
-                       $receipt['message'][] = array('msg'=>lang('voucher 
period is updated'));
+                       $receipt['message'][] = array('msg' => lang('voucher 
period is updated'));
                        return $receipt;
                }
 
-               function update_periodization($voucher_id='',$periodization='')
+               function update_periodization($voucher_id = '', $periodization 
= '')
                {
                        $receipt = array();
                        $this->db->transaction_begin();
@@ -1284,11 +1290,11 @@
 
                        $this->db->transaction_commit();
 
-                       $receipt['message'][] = array('msg'=>lang('voucher 
periodization is updated'));
+                       $receipt['message'][] = array('msg' => lang('voucher 
periodization is updated'));
                        return $receipt;
                }
 
-               function 
update_periodization_start($voucher_id='',$periodization_start='')
+               function update_periodization_start($voucher_id = '', 
$periodization_start = '')
                {
                        $receipt = array();
                        $this->db->transaction_begin();
@@ -1297,19 +1303,18 @@
 
                        $this->db->transaction_commit();
 
-                       $receipt['message'][] = array('msg'=>lang('voucher 
periodization start is updated'));
+                       $receipt['message'][] = array('msg' => lang('voucher 
periodization start is updated'));
                        return $receipt;
                }
 
-
                function increment_bilagsnr()
                {
                        $name = 'Bilagsnummer';
                        $now = time();
                        $this->db->query("SELECT value, start_date FROM 
fm_idgenerator WHERE name = '{$name}' AND start_date < {$now} ORDER BY 
start_date DESC");
                        $this->db->next_record();
-                       $bilagsnr = $this->db->f('value') +1;
-                       $start_date = (int)$this->db->f('start_date');
+                       $bilagsnr = $this->db->f('value') + 1;
+                       $start_date = (int) $this->db->f('start_date');
 
                        $this->db->query("UPDATE fm_idgenerator SET value = 
value + 1 WHERE name = '{$name}' AND start_date = $start_date");
                        return $bilagsnr;
@@ -1319,9 +1324,9 @@
                {
                        $name = 'Bilagsnummer';
                        $now = time();
-                       $this->db->query("SELECT value FROM fm_idgenerator 
WHERE name = '{$name}' AND start_date < {$now} ORDER BY start_date DESC" );
+                       $this->db->query("SELECT value FROM fm_idgenerator 
WHERE name = '{$name}' AND start_date < {$now} ORDER BY start_date DESC");
                        $this->db->next_record();
-                       $bilagsnr = $this->db->f('value')+1;
+                       $bilagsnr = $this->db->f('value') + 1;
 
                        return $bilagsnr;
                }
@@ -1333,33 +1338,31 @@
                        return $this->db->f('cnt');
                }
 
-
                function tax_code_list()
                {
                        $this->db->query("SELECT * FROM fm_ecomva ORDER BY id 
ASC ");
                        $values = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $id = $this->db->f('id');
                                $values[] = array
-                               (
-                                       'id'    => $id,
-                                       'name'  => $id,
+                                       (
+                                       'id'     => $id,
+                                       'name'   => $id,
                                );
                        }
                        return $values;
                }
 
-
                function get_lisfm_ecoart()
                {
                        $this->db->query("SELECT * FROM fm_ecoart order by id 
asc ");
                        $art_list = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $art_list[] = Array(
-                                       'id'        => $this->db->f('id'),
-                                       'name'       => $this->db->f('descr')
+                                       'id'     => $this->db->f('id'),
+                                       'name'   => $this->db->f('descr')
                                );
                        }
 
@@ -1372,11 +1375,11 @@
                {
                        $this->db->query("SELECT * FROM fm_ecobilag_category 
order by id asc ");
                        $category = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $category[] = Array(
-                                       'id'        => $this->db->f('id'),
-                                       'name'       => $this->db->f('descr')
+                                       'id'     => $this->db->f('id'),
+                                       'name'   => $this->db->f('descr')
                                );
                        }
                        return $category;
@@ -1404,7 +1407,7 @@
                        $selected_found = false;
                        $this->db->query($sql);
                        $dimb_list = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $id = $this->db->f('id');
                                if($id == $selected)
@@ -1413,9 +1416,9 @@
                                }
 
                                $dimb_list[] = array
-                               (
-                                       'id'        => $id,
-                                       'name'       => 
$this->db->f('descr',true)
+                                       (
+                                       'id'     => $id,
+                                       'name'   => $this->db->f('descr', true)
                                );
                        }
 
@@ -1423,7 +1426,7 @@
                        {
                                $this->db->query("SELECT descr FROM fm_ecodimb 
WHERE id={$selected}");
                                $this->db->next_record();
-                               array_unshift($dimb_list, array ('id' => 
$selected, 'name' => '**' . $this->db->f('descr',true) . '**' ) );
+                               array_unshift($dimb_list, array('id' => 
$selected, 'name' => '**' . $this->db->f('descr', true) . '**'));
                        }
 
                        return $dimb_list;
@@ -1434,26 +1437,27 @@
                {
                        $this->db->query("SELECT * FROM fm_ecodimd order by id 
asc ");
                        $dimd_list = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $dimd_list[] = Array(
-                                       'id'        => $this->db->f('id'),
-                                       'name'       => $this->db->f('descr')
+                                       'id'     => $this->db->f('id'),
+                                       'name'   => $this->db->f('descr')
                                );
                        }
                        return $dimd_list;
                }
+
                //---------------------
 
                function select_tax_code_list()
                {
                        $this->db->query("SELECT * FROM fm_ecomva order by id 
asc ");
                        $tax_code_list = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $tax_code_list[] = Array(
-                                       'id'        => $this->db->f('id'),
-                                       'name'       => $this->db->f('descr')
+                                       'id'     => $this->db->f('id'),
+                                       'name'   => $this->db->f('descr')
                                );
                        }
                        return $tax_code_list;
@@ -1462,14 +1466,14 @@
                function select_account_class()
                {
                        $sql = "SELECT id from fm_b_account_category order by 
id";
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->query($sql, __LINE__, __FILE__);
 
                        $class = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $class[] = Array(
-                                       'id'    => $this->db->f('id'),
-                                       'name'  => $this->db->f('id')
+                                       'id'     => $this->db->f('id'),
+                                       'name'   => $this->db->f('id')
                                );
                        }
                        return $class;
@@ -1477,7 +1481,7 @@
 
                function delete($bilagsnr)
                {
-                       $this->db->query("DELETE FROM fm_ecobilag WHERE 
bilagsnr ='" . $bilagsnr  ."'",__LINE__,__FILE__);
+                       $this->db->query("DELETE FROM fm_ecobilag WHERE 
bilagsnr ='" . $bilagsnr . "'", __LINE__, __FILE__);
                }
 
                function read_single_voucher($bilagsnr = 0, $id = 0, $paid = 
false)
@@ -1488,16 +1492,16 @@
                                $table = 'fm_ecobilagoverf';
                        }
 
-                       $bilagsnr =(int)$bilagsnr;
-                       $id = (int)$id;
+                       $bilagsnr = (int) $bilagsnr;
+                       $id = (int) $id;
 
                        if($bilagsnr)
                        {
-                               $filtermethod= "WHERE bilagsnr ='$bilagsnr'";
+                               $filtermethod = "WHERE bilagsnr ='$bilagsnr'";
                        }
-                       else if ($id)
+                       else if($id)
                        {
-                               $filtermethod= " WHERE {$table}.id ='{$id}'";
+                               $filtermethod = " WHERE {$table}.id ='{$id}'";
                        }
                        else
                        {
@@ -1505,83 +1509,83 @@
                        }
 
                        $sql = "SELECT {$table}.*,fm_workorder_status.descr as 
status, fm_workorder.charge_tenant,org_name,"
-                               . " fm_workorder.claim_issued, 
fm_workorder.continuous, fm_workorder_status.closed FROM {$table}"
-                               . " {$this->left_join} fm_workorder ON 
fm_workorder.id = {$table}.pmwrkord_code"
-                               . " {$this->left_join} fm_workorder_status ON 
fm_workorder.status = fm_workorder_status.id"
-                               . " {$this->left_join} fm_project ON 
fm_workorder.project_id = fm_project.id"
-                               . " {$this->join} fm_vendor ON 
$table.spvend_code = fm_vendor.id {$filtermethod}";
+                       . " fm_workorder.claim_issued, fm_workorder.continuous, 
fm_workorder_status.closed FROM {$table}"
+                       . " {$this->left_join} fm_workorder ON fm_workorder.id 
= {$table}.pmwrkord_code"
+                       . " {$this->left_join} fm_workorder_status ON 
fm_workorder.status = fm_workorder_status.id"
+                       . " {$this->left_join} fm_project ON 
fm_workorder.project_id = fm_project.id"
+                       . " {$this->join} fm_vendor ON $table.spvend_code = 
fm_vendor.id {$filtermethod}";
 
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->query($sql, __LINE__, __FILE__);
 
                        $values = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $values[] = array
                                        (
-                                               'voucher_id'                    
=> $this->db->f('bilagsnr'),
-                                               'voucher_out_id'                
=> $this->db->f('bilagsnr_ut'),
-                                               'id'                            
        => $this->db->f('id'),
-                                               'art'                           
        => $this->db->f('artid'),
-                                               'type'                          
        => $this->db->f('typeid'),
-                                               'dim_a'                         
        => $this->db->f('dima'),
-                                               'dim_b'                         
        => $this->db->f('dimb'),
-                                               'dim_d'                         
        => $this->db->f('dimd'),
-                                               'dim_e'                         
        => $this->db->f('dime'),
-                                               'tax_code'                      
        => $this->db->f('mvakode'),
-                                               'invoice_id'                    
=> $this->db->f('fakturanr'),
-                                               'kid_nr'                        
        => $this->db->f('kidnr'),
-                                               'vendor_id'                     
        => $this->db->f('spvend_code'),
-                                               'vendor'                        
        => $this->db->f('org_name', true),
-                                               'janitor'                       
        => $this->db->f('oppsynsmannid'),
-                                               'supervisor'                    
=> $this->db->f('saksbehandlerid'),
-                                               'budget_responsible'    => 
$this->db->f('budsjettansvarligid'),
-                                               'invoice_date'                  
=> $this->db->f('fakturadato'),
-                                               'project_id'                    
=> $this->db->f('project_id'),
-                                               'project_group'                 
=> $this->db->f('project_id'),
-                                               'payment_date'                  
=> $this->db->f('forfallsdato'),
-                                               'merknad'                       
        => $this->db->f('merknad',true),
-                                               'line_text'                     
        => $this->db->f('line_text',true),
-                                               'b_account_id'                  
=> $this->db->f('spbudact_code'),
-                                               'amount'                        
        => $this->db->f('belop'),
-                                               'approved_amount'               
=> $this->db->f('godkjentbelop'),
-                                               'order'                         
        => $this->db->f('pmwrkord_code'),
-                                               'order_id'                      
        => $this->db->f('pmwrkord_code'),
-                                               'kostra_id'                     
        => $this->db->f('kostra_id'),
-                                               'currency'                      
        => $this->db->f('currency'),
-                                               'process_code'                  
=> $this->db->f('process_code'),
-                                               'process_log'                   
=> $this->db->f('process_log',true),
-                                               'oppsynsigndato'                
=> $this->db->f('oppsynsigndato'),
-                                               'saksigndato'                   
=> $this->db->f('saksigndato'),
-                                               'budsjettsigndato'              
=> $this->db->f('budsjettsigndato'),
-                                               'charge_tenant'                 
=> $this->db->f('charge_tenant'),
-                                               'external_ref'                  
=> $this->db->f('external_ref'),
-                                               'status'                        
        => $this->db->f('status'),
-                                               'closed'                        
        => $this->db->f('closed'),
-                                               'parked'                        
        => $this->db->f('kreditnota'),
-                                               'period'                        
        => $this->db->f('periode'),
-                                               'periodization'                 
=> $this->db->f('periodization'),
-                                               'periodization_start'   => 
$this->db->f('periodization_start'),
-                                               'continuous'                    
=> $this->db->f('continuous'),
-                                       );
+                                       'voucher_id'                     => 
$this->db->f('bilagsnr'),
+                                       'voucher_out_id'                 => 
$this->db->f('bilagsnr_ut'),
+                                       'id'                                    
 => $this->db->f('id'),
+                                       'art'                                   
 => $this->db->f('artid'),
+                                       'type'                                  
 => $this->db->f('typeid'),
+                                       'dim_a'                                 
 => $this->db->f('dima'),
+                                       'dim_b'                                 
 => $this->db->f('dimb'),
+                                       'dim_d'                                 
 => $this->db->f('dimd'),
+                                       'dim_e'                                 
 => $this->db->f('dime'),
+                                       'tax_code'                              
 => $this->db->f('mvakode'),
+                                       'invoice_id'                     => 
$this->db->f('fakturanr'),
+                                       'kid_nr'                                
 => $this->db->f('kidnr'),
+                                       'vendor_id'                             
 => $this->db->f('spvend_code'),
+                                       'vendor'                                
 => $this->db->f('org_name', true),
+                                       'janitor'                               
 => $this->db->f('oppsynsmannid'),
+                                       'supervisor'                     => 
$this->db->f('saksbehandlerid'),
+                                       'budget_responsible'     => 
$this->db->f('budsjettansvarligid'),
+                                       'invoice_date'                   => 
$this->db->f('fakturadato'),
+                                       'project_id'                     => 
$this->db->f('project_id'),
+                                       'project_group'                  => 
$this->db->f('project_id'),
+                                       'payment_date'                   => 
$this->db->f('forfallsdato'),
+                                       'merknad'                               
 => $this->db->f('merknad', true),
+                                       'line_text'                             
 => $this->db->f('line_text', true),
+                                       'b_account_id'                   => 
$this->db->f('spbudact_code'),
+                                       'amount'                                
 => $this->db->f('belop'),
+                                       'approved_amount'                => 
$this->db->f('godkjentbelop'),
+                                       'order'                                 
 => $this->db->f('pmwrkord_code'),
+                                       'order_id'                              
 => $this->db->f('pmwrkord_code'),
+                                       'kostra_id'                             
 => $this->db->f('kostra_id'),
+                                       'currency'                              
 => $this->db->f('currency'),
+                                       'process_code'                   => 
$this->db->f('process_code'),
+                                       'process_log'                    => 
$this->db->f('process_log', true),
+                                       'oppsynsigndato'                 => 
$this->db->f('oppsynsigndato'),
+                                       'saksigndato'                    => 
$this->db->f('saksigndato'),
+                                       'budsjettsigndato'               => 
$this->db->f('budsjettsigndato'),
+                                       'charge_tenant'                  => 
$this->db->f('charge_tenant'),
+                                       'external_ref'                   => 
$this->db->f('external_ref'),
+                                       'status'                                
 => $this->db->f('status'),
+                                       'closed'                                
 => $this->db->f('closed'),
+                                       'parked'                                
 => $this->db->f('kreditnota'),
+                                       'period'                                
 => $this->db->f('periode'),
+                                       'periodization'                  => 
$this->db->f('periodization'),
+                                       'periodization_start'    => 
$this->db->f('periodization_start'),
+                                       'continuous'                     => 
$this->db->f('continuous'),
+                               );
                        }
 
-/*
-                       if($values)
-                       {
-                               $bilagsnr = (int)$values[0]['voucher_id'];
-                               $sql= "SELECT * FROM fm_ecobilag_process_log 
WHERE bilagsnr = {$bilagsnr}";
-                               $this->db->query($sql,__LINE__,__FILE__);
-                               $this->db->next_record();
-                               $process_log    = 
$this->db->f('process_log',true);
-                               $process_code   = $this->db->f('process_code');
+                       /*
+                         if($values)
+                         {
+                         $bilagsnr = (int)$values[0]['voucher_id'];
+                         $sql= "SELECT * FROM fm_ecobilag_process_log WHERE 
bilagsnr = {$bilagsnr}";
+                         $this->db->query($sql,__LINE__,__FILE__);
+                         $this->db->next_record();
+                         $process_log  = $this->db->f('process_log',true);
+                         $process_code = $this->db->f('process_code');
 
-                               foreach ($values as &$line)
-                               {
-                                       $line['process_log'] = $process_log;
-                                       $line['process_code'] = $process_code;
-                               }
-                       }
-*/
+                         foreach ($values as &$line)
+                         {
+                         $line['process_log'] = $process_log;
+                         $line['process_code'] = $process_code;
+                         }
+                         }
+                        */
                        //_debug_array($values);
                        return $values;
                }
@@ -1593,220 +1597,220 @@
                        $receipt = array();
                        foreach($values['counter'] as $n)
                        {
-                               $local_error='';
+                               $local_error = '';
 
                                if($values['voucher_id'][$n])
                                {
-                                       $voucher_id=$values['voucher_id'][$n];
+                                       $voucher_id = $values['voucher_id'][$n];
 
-                                       
$check_value=array('voucher_id'=>$voucher_id,
-                                               'sign_orig'             => 
$values['sign_orig'][$n],
-                                               'sign'                  => 
isset($values['sign'][$n])?$values['sign'][$n]:'',
-                                               'transfer'              => 
isset($values['transfer'][$n])?$values['transfer'][$n]:'',
-                                               'kreditnota'    => 
isset($values['kreditnota'][$n])?$values['kreditnota'][$n]:'',
-                                               'num_days'              => 
$values['num_days'][$n]);
+                                       $check_value = array('voucher_id' => 
$voucher_id,
+                                               'sign_orig'      => 
$values['sign_orig'][$n],
+                                               'sign'           => 
isset($values['sign'][$n]) ? $values['sign'][$n] : '',
+                                               'transfer'       => 
isset($values['transfer'][$n]) ? $values['transfer'][$n] : '',
+                                               'kreditnota' => 
isset($values['kreditnota'][$n]) ? $values['kreditnota'][$n] : '',
+                                               'num_days'       => 
$values['num_days'][$n]);
 
                                        
if($this->check_for_updates($check_value))
                                        {
 
                                                $check_count = 
$this->check_count($voucher_id);
 
-                                               if 
(!($check_count['dima_count'] == $values['invoice_count'][$n]))
+                                               if(!($check_count['dima_count'] 
== $values['invoice_count'][$n]))
                                                {
-                                                       $receipt['error'][] = 
array('msg'=>lang('Dima is missing from sub invoice in:'). " 
".$values['voucher_id'][$n]);
-                                                       $local_error= true;
+                                                       $receipt['error'][] = 
array('msg' => lang('Dima is missing from sub invoice in:') . " " . 
$values['voucher_id'][$n]);
+                                                       $local_error = true;
                                                }
 
-                                               if 
(!($check_count['spbudact_code_count'] == $values['invoice_count'][$n]))
+                                               
if(!($check_count['spbudact_code_count'] == $values['invoice_count'][$n]))
                                                {
-                                                       $receipt['error'][] = 
array('msg'=>lang('Budget code is missing from sub invoice in :'). " 
".$values['voucher_id'][$n]);
-                                                       $local_error= true;
+                                                       $receipt['error'][] = 
array('msg' => lang('Budget code is missing from sub invoice in :') . " " . 
$values['voucher_id'][$n]);
+                                                       $local_error = true;
                                                }
 
-                                               if 
(!($check_count['kostra_count'] == $values['invoice_count'][$n]))
+                                               
if(!($check_count['kostra_count'] == $values['invoice_count'][$n]))
                                                {
-                                                       $receipt['error'][] = 
array('msg'=>'Tjenestekode mangler for undebilag: ' . " 
".$values['voucher_id'][$n]);
-                                                       $local_error= true;
+                                                       $receipt['error'][] = 
array('msg' => 'Tjenestekode mangler for undebilag: ' . " " . 
$values['voucher_id'][$n]);
+                                                       $local_error = true;
                                                }
 
-                                               if 
($this->check_claim($voucher_id))
+                                               
if($this->check_claim($voucher_id))
                                                {
-                                                       $receipt['error'][] = 
array('msg'=>lang('Tenant claim is not issued for project in voucher 
%1',$voucher_id));
-                                                       $local_error= true;
+                                                       $receipt['error'][] = 
array('msg' => lang('Tenant claim is not issued for project in voucher %1', 
$voucher_id));
+                                                       $local_error = true;
                                                }
 
                                                $blank_date = '';
-                                               $sign_field='';
-                                               $sign_id='';
-                                               $sign_date_field='';
-                                               $sign_date='';
-                                               $kommma='';
-                                               $wait_for_kreditnota='';
-                                               $user_lid       
=$GLOBALS['phpgw_info']['user']['account_lid'];
+                                               $sign_field = '';
+                                               $sign_id = '';
+                                               $sign_date_field = '';
+                                               $sign_date = '';
+                                               $kommma = '';
+                                               $wait_for_kreditnota = '';
+                                               $user_lid = 
$GLOBALS['phpgw_info']['user']['account_lid'];
 
-                                               if 
(($values['sign'][$n]=='sign_none') && 
($values['sign_orig'][$n]=='sign_janitor'))
+                                               if(($values['sign'][$n] == 
'sign_none') && ($values['sign_orig'][$n] == 'sign_janitor'))
                                                {
                                                        $blank_date = 
'oppsynsigndato= NULL';
-                                                       $sign_field='';
-                                                       $sign_id='';
-                                                       $sign_date_field='';
-                                                       $sign_date='';
-                                                       $kommma='';
+                                                       $sign_field = '';
+                                                       $sign_id = '';
+                                                       $sign_date_field = '';
+                                                       $sign_date = '';
+                                                       $kommma = '';
                                                }
-                                               else if 
(($values['sign'][$n]=='sign_none') && 
($values['sign_orig'][$n]=='sign_supervisor'))
+                                               else if(($values['sign'][$n] == 
'sign_none') && ($values['sign_orig'][$n] == 'sign_supervisor'))
                                                {
                                                        $blank_date = 
'saksigndato= NULL';
-                                                       $sign_field='';
-                                                       $sign_id='';
-                                                       $sign_date_field='';
-                                                       $sign_date='';
-                                                       $kommma='';
+                                                       $sign_field = '';
+                                                       $sign_id = '';
+                                                       $sign_date_field = '';
+                                                       $sign_date = '';
+                                                       $kommma = '';
                                                }
-                                               else if 
(($values['sign'][$n]=='sign_none') && 
($values['sign_orig'][$n]=='sign_budget_responsible'))
+                                               else if(($values['sign'][$n] == 
'sign_none') && ($values['sign_orig'][$n] == 'sign_budget_responsible'))
                                                {
                                                        $blank_date = 
'budsjettsigndato= NULL';
-                                                       $sign_field='';
-                                                       $sign_id='';
-                                                       $sign_date_field='';
-                                                       $sign_date='';
-                                                       $kommma='';
+                                                       $sign_field = '';
+                                                       $sign_id = '';
+                                                       $sign_date_field = '';
+                                                       $sign_date = '';
+                                                       $kommma = '';
                                                }
-                                               else if 
($values['sign'][$n]=='sign_janitor' && !$values['sign_orig'][$n])
+                                               else if($values['sign'][$n] == 
'sign_janitor' && !$values['sign_orig'][$n])
                                                {
                                                        $blank_date = '';
                                                        $sign_field = 
'oppsynsmannid=';
                                                        $sign_id = 
"'$user_lid'";
                                                        $sign_date_field = 
'oppsynsigndato=';
-                                                       $sign_date="'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma=",";
+                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
+                                                       $kommma = ",";
                                                }
-                                               else if 
($values['sign'][$n]=='sign_janitor' && 
$values['sign_orig'][$n]=='sign_supervisor')
+                                               else if($values['sign'][$n] == 
'sign_janitor' && $values['sign_orig'][$n] == 'sign_supervisor')
                                                {
                                                        $blank_date = 
'saksigndato= NULL';
                                                        $sign_field = 
'oppsynsmannid=';
                                                        $sign_id = 
"'$user_lid'";
                                                        $sign_date_field = 
'oppsynsigndato=';
-                                                       $sign_date="'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma=",";
+                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
+                                                       $kommma = ",";
                                                }
-                                               else if 
($values['sign'][$n]=='sign_janitor' && 
$values['sign_orig'][$n]=='sign_budget_responsible')
+                                               else if($values['sign'][$n] == 
'sign_janitor' && $values['sign_orig'][$n] == 'sign_budget_responsible')
                                                {
                                                        $blank_date = 
'budsjettsigndato= NULL';
                                                        $sign_field = 
'oppsynsmannid=';
                                                        $sign_id = 
"'$user_lid'";
                                                        $sign_date_field = 
'oppsynsigndato=';
-                                                       $sign_date="'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma=",";
+                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
+                                                       $kommma = ",";
                                                }
-                                               else if 
($values['sign'][$n]=='sign_supervisor' && !$values['sign_orig'][$n])
+                                               else if($values['sign'][$n] == 
'sign_supervisor' && !$values['sign_orig'][$n])
                                                {
                                                        $blank_date = '';
                                                        $sign_field = 
'saksbehandlerid=';
                                                        $sign_id = 
"'$user_lid'";
                                                        $sign_date_field = 
'saksigndato=';
-                                                       $sign_date="'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma=",";
+                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
+                                                       $kommma = ",";
                                                }
-                                               else if 
($values['sign'][$n]=='sign_supervisor' && 
$values['sign_orig'][$n]=='sign_janitor')
+                                               else if($values['sign'][$n] == 
'sign_supervisor' && $values['sign_orig'][$n] == 'sign_janitor')
                                                {
                                                        $blank_date = 
'oppsynsigndato= NULL';
                                                        $sign_field = 
'saksbehandlerid=';
                                                        $sign_id = 
"'$user_lid'";
                                                        $sign_date_field = 
'saksigndato=';
-                                                       $sign_date="'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma=",";
+                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
+                                                       $kommma = ",";
                                                }
-                                               else if 
($values['sign'][$n]=='sign_supervisor' && 
$values['sign_orig'][$n]=='sign_budget_responsible')
+                                               else if($values['sign'][$n] == 
'sign_supervisor' && $values['sign_orig'][$n] == 'sign_budget_responsible')
                                                {
                                                        $blank_date = 
'budsjettsigndato= NULL';
                                                        $sign_field = 
'saksbehandlerid=';
                                                        $sign_id = 
"'$user_lid'";
                                                        $sign_date_field = 
'saksigndato=';
-                                                       $sign_date="'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma=",";
+                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
+                                                       $kommma = ",";
                                                }
-                                               else if 
($values['sign'][$n]=='sign_budget_responsible' && 
$values['sign_orig'][$n]=='sign_janitor')
+                                               else if($values['sign'][$n] == 
'sign_budget_responsible' && $values['sign_orig'][$n] == 'sign_janitor')
                                                {
                                                        $blank_date = 
'oppsynsigndato= NULL';
                                                        $sign_field = 
'budsjettansvarligid=';
                                                        $sign_id = 
"'$user_lid'";
                                                        $sign_date_field = 
'budsjettsigndato=';
-                                                       $sign_date="'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma=",";
+                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
+                                                       $kommma = ",";
                                                }
-                                               else if 
($values['sign'][$n]=='sign_budget_responsible' && 
$values['sign_orig'][$n]=='sign_supervisor')
+                                               else if($values['sign'][$n] == 
'sign_budget_responsible' && $values['sign_orig'][$n] == 'sign_supervisor')
                                                {
                                                        $blank_date = 
'saksigndato= NULL';
                                                        $sign_field = 
'budsjettansvarligid=';
                                                        $sign_id = 
"'$user_lid'";
                                                        $sign_date_field = 
'budsjettsigndato=';
-                                                       $sign_date="'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma=",";
+                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
+                                                       $kommma = ",";
                                                }
-                                               else if 
($values['sign'][$n]=='sign_budget_responsible' && !$values['sign_orig'][$n])
+                                               else if($values['sign'][$n] == 
'sign_budget_responsible' && !$values['sign_orig'][$n])
                                                {
                                                        $blank_date = '';
                                                        $sign_field = 
'budsjettansvarligid=';
                                                        $sign_id = 
"'$user_lid'";
                                                        $sign_date_field = 
'budsjettsigndato=';
-                                                       $sign_date="'" . 
date($this->db->datetime_format()) . "'";
-                                                       $kommma=",";
+                                                       $sign_date = "'" . 
date($this->db->datetime_format()) . "'";
+                                                       $kommma = ",";
                                                }
 
 
-                                               if($blank_date )
+                                               if($blank_date)
                                                {
-                                                       $kommma_blank=",";
+                                                       $kommma_blank = ",";
                                                }
                                                else
                                                {
-                                                       $kommma_blank='';
+                                                       $kommma_blank = '';
                                                }
 
-                                               
$transfer_sign_field='utbetalingid=';
-                                               
$transfer_date_field='utbetalingsigndato=';
+                                               $transfer_sign_field = 
'utbetalingid=';
+                                               $transfer_date_field = 
'utbetalingsigndato=';
 
-                                               if 
(!($values['num_days_orig'][$n]==$values['num_days'][$n]))
+                                               
if(!($values['num_days_orig'][$n] == $values['num_days'][$n]))
                                                {
-                                                       $payment_date = 
date($this->db->date_format(),$values['timestamp_voucher_date'][$n]+(24*3600*$values['num_days'][$n]));
+                                                       $payment_date = 
date($this->db->date_format(), $values['timestamp_voucher_date'][$n] + (24 * 
3600 * $values['num_days'][$n]));
                                                        
$GLOBALS['phpgw']->db->query("UPDATE fm_ecobilag set forfallsdato= 
'$payment_date' where bilagsnr='$voucher_id'");
                                                }
 
-                                               $transfer_id="Null".",";
-                                               $transfer_date="Null";
+                                               $transfer_id = "Null" . ",";
+                                               $transfer_date = "Null";
 
-                                               if ($values['transfer'][$n])
+                                               if($values['transfer'][$n])
                                                {
-                                                       if 
($this->check_for_transfer($voucher_id))
+                                                       
if($this->check_for_transfer($voucher_id))
                                                        {
-                                                               
$transfer_id="'$user_lid',";
-                                                               
$transfer_date="'" . date($this->db->datetime_format()) . "'";
+                                                               $transfer_id = 
"'$user_lid',";
+                                                               $transfer_date 
= "'" . date($this->db->datetime_format()) . "'";
                                                        }
                                                        else
                                                        {
-                                                               
$receipt['error'][] = array('msg'=>'Dette bilaget er ikkje godkjent: ' . " 
".$voucher_id);
-                                                               $local_error= 
true;
+                                                               
$receipt['error'][] = array('msg' => 'Dette bilaget er ikkje godkjent: ' . " " 
. $voucher_id);
+                                                               $local_error = 
true;
                                                        }
                                                }
 
-                                               if ($values['kreditnota'][$n])
+                                               if($values['kreditnota'][$n])
                                                {
-                                                       $wait_for_kreditnota=1;
-                                                       $transfer_date="Null";
+                                                       $wait_for_kreditnota = 
1;
+                                                       $transfer_date = "Null";
                                                }
                                                else
                                                {
-                                                       
$wait_for_kreditnota='NULL';
+                                                       $wait_for_kreditnota = 
'NULL';
                                                }
 
-                                               if (! $local_error)
+                                               if(!$local_error)
                                                {
-                                                       $sql= "UPDATE 
fm_ecobilag SET $blank_date $kommma_blank $sign_field $sign_id $kommma 
$sign_date_field $sign_date $kommma $transfer_sign_field $transfer_id 
$transfer_date_field $transfer_date ,kreditnota=$wait_for_kreditnota  where 
bilagsnr='$voucher_id'";
+                                                       $sql = "UPDATE 
fm_ecobilag SET $blank_date $kommma_blank $sign_field $sign_id $kommma 
$sign_date_field $sign_date $kommma $transfer_sign_field $transfer_id 
$transfer_date_field $transfer_date ,kreditnota=$wait_for_kreditnota  where 
bilagsnr='$voucher_id'";
                                                        
$GLOBALS['phpgw']->db->transaction_begin();
                                                        
$GLOBALS['phpgw']->db->query($sql);
                                                        
if($GLOBALS['phpgw']->db->transaction_commit())
                                                        {
-                                                               
$receipt['message'][] = array('msg'=> lang('voucher is updated: ') . 
$voucher_id);
+                                                               
$receipt['message'][] = array('msg' => lang('voucher is updated: ') . 
$voucher_id);
                                                        }
                                                }
                                        }
@@ -1822,27 +1826,27 @@
                        return $receipt;
                }
 
-               function check_for_transfer($voucher_id='')
+               function check_for_transfer($voucher_id = '')
                {
-                       $allow_transfer=false;
+                       $allow_transfer = false;
 
                        $sql = "SELECT * FROM fm_ecobilag WHERE 
bilagsnr='$voucher_id'";
-                       $this->db->limit_query($sql,0,__LINE__,__FILE__,1);
+                       $this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
 
                        $this->db->next_record();
 
                        if($this->invoice_approval == 1)
                        {
-                               if ($this->db->f('budsjettsigndato'))
+                               if($this->db->f('budsjettsigndato'))
                                {
-                                       $allow_transfer=true;
+                                       $allow_transfer = true;
                                }
                        }
                        else
                        {
-                               if ($this->db->f('budsjettsigndato') && 
($this->db->f('oppsynsigndato') || $this->db->f('saksigndato')))
+                               if($this->db->f('budsjettsigndato') && 
($this->db->f('oppsynsigndato') || $this->db->f('saksigndato')))
                                {
-                                       $allow_transfer=true;
+                                       $allow_transfer = true;
                                }
                        }
 
@@ -1868,14 +1872,13 @@
                        }
 
                        $sql = "SELECT count(*) as cnt FROM fm_ecobilag 
$this->left_join fm_workorder on fm_ecobilag.pmwrkord_code = fm_workorder.id "
-                               . " {$condition} AND 
fm_workorder.charge_tenant=1 AND fm_workorder.claim_issued IS NULL";
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       . " {$condition} AND fm_workorder.charge_tenant=1 AND 
fm_workorder.claim_issued IS NULL";
+                       $this->db->query($sql, __LINE__, __FILE__);
                        $this->db->next_record();
                        return $this->db->f('cnt');
                }
 
-
-               public function get_single_line($id,$paid = false)
+               public function get_single_line($id, $paid = false)
                {
                        $line = $this->read_single_voucher(0, $id, $paid);
                        return $line[0];
@@ -1884,30 +1887,30 @@
                public function get_historical_accounting_periods()
                {
                        $sql = "SELECT DISTINCT periode FROM fm_ecobilagoverf 
ORDER BY periode DESC";
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->query($sql, __LINE__, __FILE__);
 
                        $values = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $periode = $this->db->f('periode');
                                $values[] = array
-                               (
-                                       'id'    => $periode,
-                                       'name'  => $periode
+                                       (
+                                       'id'     => $periode,
+                                       'name'   => $periode
                                );
                        }
 
                        $i = 0;
-                       foreach ($values as &$periode)
+                       foreach($values as &$periode)
                        {
                                if($i > 5)
                                {
                                        break;
                                }
                                $sql = "SELECT count(id) as cnt FROM 
fm_ecobilagoverf WHERE periode = {$periode['id']}";
-                               $this->db->query($sql,__LINE__,__FILE__);
+                               $this->db->query($sql, __LINE__, __FILE__);
                                $this->db->next_record();
-                               $periode['name'] = $periode['name'] . ' [' . 
sprintf("%010s",$this->db->f('cnt')) . ']';
+                               $periode['name'] = $periode['name'] . ' [' . 
sprintf("%010s", $this->db->f('cnt')) . ']';
                                $i ++;
                        }
                        return $values;
@@ -1924,21 +1927,21 @@
 //                     $filter .= ' AND manual_record IS NULL';
 
                        $sql = "SELECT * FROM fm_ecobilagoverf {$filter} ORDER 
BY periode DESC, id ASC";
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->query($sql, __LINE__, __FILE__);
 
                        $values = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
                                $values[] = $this->db->Record;
                        }
                        return $values;
                }
 
-
                /*
-               * Orders without related historic invoices, tagged as 
'delivered'
-               *  - And orders related to active (not processed) invoices.
-               */
+                * Orders without related historic invoices, tagged as 
'delivered'
+                *  - And orders related to active (not processed) invoices.
+                */
+
                public function get_deposition()
                {
                        $sql = "SELECT "
@@ -1951,20 +1954,21 @@
                        . " {$this->join} fm_project ON 
(fm_workorder.project_id = fm_project.id)"
                        . " {$this->join} fm_ecobilag ON (fm_workorder.id = 
fm_ecobilag.pmwrkord_code)"
                        . " GROUP BY art, kostnadssted, project_group, currency 
ORDER BY kostnadssted,project_group, art, currency ASC";
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->query($sql, __LINE__, __FILE__);
 
                        $values = array();
-                       while ($this->db->next_record())
+                       while($this->db->next_record())
                        {
-                                       $values[] = $this->db->Record;
+                               $values[] = $this->db->Record;
                        }
 
                        return $values;
                }
 
                /*
-               *  Forward vouchers to other responsible
-               */
+                *  Forward vouchers to other responsible
+                */
+
                public function forward($data)
                {
                        $condition = '';
@@ -1981,44 +1985,44 @@
                        }
 
                        $receipt = array();
-                       $local_error= false;
+                       $local_error = false;
                        if($condition)
                        {
                                //start check
                                $check_count = 
$this->check_count($data['voucher_id']);
 
-                               if($global_check )
+                               if($global_check)
                                {
-                                       if (!($check_count['dima_count'] == 
$check_count['invoice_count']))
+                                       if(!($check_count['dima_count'] == 
$check_count['invoice_count']))
                                        {
-                                               phpgwapi_cache::message_set( 
lang('Dima is missing from sub invoice in:'). " ".$data['voucher_id'],'error' );
-                                               $local_error= true;
+                                               
phpgwapi_cache::message_set(lang('Dima is missing from sub invoice in:') . " " 
. $data['voucher_id'], 'error');
+                                               $local_error = true;
                                        }
 
-                                       if 
(!($check_count['spbudact_code_count'] == $check_count['invoice_count']))
+                                       
if(!($check_count['spbudact_code_count'] == $check_count['invoice_count']))
                                        {
-                                               phpgwapi_cache::message_set( 
lang('Budget code is missing from sub invoice in :'). " 
".$data['voucher_id'],'error');
-                                               $local_error= true;
+                                               
phpgwapi_cache::message_set(lang('Budget code is missing from sub invoice in 
:') . " " . $data['voucher_id'], 'error');
+                                               $local_error = true;
                                        }
 
-                                       if (!($check_count['kostra_count'] == 
$check_count['invoice_count']))
+                                       if(!($check_count['kostra_count'] == 
$check_count['invoice_count']))
                                        {
-                                               phpgwapi_cache::message_set( 
'Tjenestekode mangler for undebilag: ' . " ".$data['voucher_id'],'error');
-                                               $local_error= true;
+                                               
phpgwapi_cache::message_set('Tjenestekode mangler for undebilag: ' . " " . 
$data['voucher_id'], 'error');
+                                               $local_error = true;
                                        }
 
-                                       if 
($this->check_claim($data['voucher_id']))
+                                       
if($this->check_claim($data['voucher_id']))
                                        {
-                                               phpgwapi_cache::message_set( 
lang('Tenant claim is not issued for project in voucher 
%1',$data['voucher_id']),'error');
-                                               $local_error= true;
+                                               
phpgwapi_cache::message_set(lang('Tenant claim is not issued for project in 
voucher %1', $data['voucher_id']), 'error');
+                                               $local_error = true;
                                        }
                                }
                                else
                                {
-                                       if ($this->check_claim(0, 
$data['line_id']))
+                                       if($this->check_claim(0, 
$data['line_id']))
                                        {
-                                               phpgwapi_cache::message_set( 
lang('Tenant claim is not issued for project in voucher 
%1',$data['voucher_id']),'error');
-                                               $local_error= true;
+                                               
phpgwapi_cache::message_set(lang('Tenant claim is not issued for project in 
voucher %1', $data['voucher_id']), 'error');
+                                               $local_error = true;
                                        }
                                }
 
@@ -2031,17 +2035,17 @@
 
                                $value_set = array();
 
-                               foreach ($data['forward'] as $role => $user_lid)
+                               foreach($data['forward'] as $role => $user_lid)
                                {
-                                       $value_set[$role] =  $user_lid;
+                                       $value_set[$role] = $user_lid;
                                }
 
-                               if( $data['approve'] != $data['sign_orig'] )
+                               if($data['approve'] != $data['sign_orig'])
                                {
-                                       switch ( $data['sign_orig'] )
+                                       switch($data['sign_orig'])
                                        {
                                                case 'is_janitor':
-                                                               
$value_set['oppsynsigndato'] = null;
+                                                       
$value_set['oppsynsigndato'] = null;
                                                        break;
                                                case 'is_supervisor':
                                                        
$value_set['saksigndato'] = null;
@@ -2051,18 +2055,18 @@
                                                        break;
                                        }
 
-                                       switch ( $data['approve'] )
+                                       switch($data['approve'])
                                        {
                                                case 'is_janitor':
-                                                       
$value_set['oppsynsigndato'] = date( $this->db->datetime_format() );
-                                                               
$value_set['oppsynsmannid'] = $data['my_initials'];
+                                                       
$value_set['oppsynsigndato'] = date($this->db->datetime_format());
+                                                       
$value_set['oppsynsmannid'] = $data['my_initials'];
                                                        break;
                                                case 'is_supervisor':
-                                                       
$value_set['saksigndato'] = date( $this->db->datetime_format() );
+                                                       
$value_set['saksigndato'] = date($this->db->datetime_format());
                                                        
$value_set['saksbehandlerid'] = $data['my_initials'];
                                                        break;
                                                case 'is_budget_responsible':
-                                                       
$value_set['budsjettsigndato'] = date( $this->db->datetime_format() );
+                                                       
$value_set['budsjettsigndato'] = date($this->db->datetime_format());
                                                        
$value_set['budsjettansvarligid'] = $data['my_initials'];
                                                        break;
                                        }
@@ -2070,19 +2074,18 @@
 
                                if(isset($value_set['budsjettansvarligid']) && 
!$value_set['budsjettansvarligid'])
                                {
-                                       phpgwapi_cache::message_set( 'Mangler 
anviser','error');
+                                       phpgwapi_cache::message_set('Mangler 
anviser', 'error');
                                }
                                else
                                {
-                                       $value_set      = 
$this->db->validate_update($value_set);
-                                       return $this->db->query("UPDATE 
fm_ecobilag SET $value_set {$condition}",__LINE__,__FILE__);
+                                       $value_set = 
$this->db->validate_update($value_set);
+                                       return $this->db->query("UPDATE 
fm_ecobilag SET $value_set {$condition}", __LINE__, __FILE__);
                                }
                        }
 
                        return false;
                }
 
-
                function get_order_info($order_id)
                {
                        $order_info = array();
@@ -2090,36 +2093,36 @@
                        $order_id = (int) $order_id;
                        $sql = "SELECT 
fm_workorder.location_code,fm_workorder.vendor_id,fm_workorder.account_id,fm_workorder.ecodimb,fm_workorder.category,
 fm_workorder.user_id,fm_workorder.title"
                        . " FROM fm_workorder {$this->join} fm_project ON 
fm_workorder.project_id = fm_project.id WHERE fm_workorder.id = {$order_id}";
-                       $this->db->query($sql,__LINE__,__FILE__);
-                       if(     $this->db->next_record())
+                       $this->db->query($sql, __LINE__, __FILE__);
+                       if($this->db->next_record())
                        {
                                $order_info['order_exist'] = true;
                        }
-                       if ($this->db->f('location_code'))
+                       if($this->db->f('location_code'))
                        {
-                               $parts = 
explode('-',$this->db->f('location_code'));
+                               $parts = explode('-', 
$this->db->f('location_code'));
                                $order_info['dima'] = implode('', $parts);
                                $order_info['loc1'] = $parts[0];
                        }
 
-                       $order_info['vendor_id']                        = 
$this->db->f('vendor_id');
-                       $order_info['spbudact_code']            = 
$this->db->f('account_id');
-                       $order_info['dimb']                                     
= $this->db->f('ecodimb');
-                       $order_info['dime']                                     
= $this->db->f('category');
-                       $order_info['title']                            = 
$this->db->f('title',true);
+                       $order_info['vendor_id'] = $this->db->f('vendor_id');
+                       $order_info['spbudact_code'] = 
$this->db->f('account_id');
+                       $order_info['dimb'] = $this->db->f('ecodimb');
+                       $order_info['dime'] = $this->db->f('category');
+                       $order_info['title'] = $this->db->f('title', true);
 
-                       $janitor_user_id                                        
= $this->db->f('user_id');
-                       $order_info['janitor']                          = 
$GLOBALS['phpgw']->accounts->get($janitor_user_id)->lid;
-                       $supervisor_user_id                                     
= $this->get_default_dimb_role_user(2, $order_info['dimb']);
+                       $janitor_user_id = $this->db->f('user_id');
+                       $order_info['janitor'] = 
$GLOBALS['phpgw']->accounts->get($janitor_user_id)->lid;
+                       $supervisor_user_id = 
$this->get_default_dimb_role_user(2, $order_info['dimb']);
                        if($supervisor_user_id)
                        {
-                               $order_info['supervisor']               = 
$GLOBALS['phpgw']->accounts->get($supervisor_user_id)->lid;
+                               $order_info['supervisor'] = 
$GLOBALS['phpgw']->accounts->get($supervisor_user_id)->lid;
                        }
 
-                       $budget_responsible_user_id                     = 
$this->get_default_dimb_role_user(3, $order_info['dimb']);
+                       $budget_responsible_user_id = 
$this->get_default_dimb_role_user(3, $order_info['dimb']);
                        if($budget_responsible_user_id)
                        {
-                               $order_info['budget_responsible']       = 
$GLOBALS['phpgw']->accounts->get($budget_responsible_user_id)->lid;
+                               $order_info['budget_responsible'] = 
$GLOBALS['phpgw']->accounts->get($budget_responsible_user_id)->lid;
                        }
 
                        if(!$order_info['budget_responsible'])
@@ -2131,56 +2134,54 @@
                        return $order_info;
                }
 
-
                public function update_voucher_by_changed_order($line_id, 
$order_id)
                {
                        $order_info = $this->get_order_info($order_id);
-                       if (!$order_info['order_exist'])
+                       if(!$order_info['order_exist'])
                        {
                                phpgwapi_cache::message_set(lang('not a valid 
order'), 'error');
                                return false;
                        }
 
                        $GLOBALS['phpgw']->db->transaction_begin();
-                       $this->db->query("SELECT * FROM fm_ecobilag WHERE id =" 
. (int)$line_id,__LINE__,__FILE__);
+                       $this->db->query("SELECT * FROM fm_ecobilag WHERE id =" 
. (int) $line_id, __LINE__, __FILE__);
 
                        $this->db->next_record();
-                       $old_janitor                    =  
$this->db->f('oppsynsmannid');
-                       $old_supervisor                 =  
$this->db->f('saksbehandlerid');
-                       $old_budget_responsible =  
$this->db->f('budsjettansvarligid');
+                       $old_janitor = $this->db->f('oppsynsmannid');
+                       $old_supervisor = $this->db->f('saksbehandlerid');
+                       $old_budget_responsible = 
$this->db->f('budsjettansvarligid');
 
                        $value_set = array();
-                       
+
                        if($old_janitor != $order_info['janitor'])
                        {
-                               $value_set['oppsynsigndato']    = '';           
        
+                               $value_set['oppsynsigndato'] = '';
                        }
 
                        if($old_supervisor != $order_info['supervisor'])
                        {
-                               $value_set['saksigndato']       = '';           
        
+                               $value_set['saksigndato'] = '';
                        }
 
                        if($old_budget_responsible != 
$order_info['budget_responsible'])
                        {
-                               $value_set['budsjettsigndato']  = '';           
        
+                               $value_set['budsjettsigndato'] = '';
                        }
 
-                       $value_set['pmwrkord_code']                     = 
$order_id;
-                       $value_set['dima']                                      
= $order_info['dima'];
-                       $value_set['dimb']                                      
= $order_info['dimb'];
-                       $value_set['dime']                                      
= $order_info['dime'];
-                       $value_set['loc1']                                      
= $order_info['loc1'];
-                       $value_set['line_text']                         = 
$order_info['title'];
-                       $value_set['spbudact_code']                     = 
$order_info['spbudact_code'];
-                       $value_set['oppsynsmannid']                     = 
$order_info['janitor'];
-                       $value_set['saksbehandlerid']           = 
$order_info['supervisor'];
-                       $value_set['budsjettansvarligid']       = 
$order_info['budget_responsible'];
-                       $value_set['project_id']                        = 
execMethod('property.soXport.get_project',$order_id);
-                       $value_set      = 
$this->db->validate_update($value_set);
-                       $this->db->query("UPDATE fm_ecobilag SET $value_set 
WHERE id =" . (int)$line_id,__LINE__,__FILE__);
+                       $value_set['pmwrkord_code'] = $order_id;
+                       $value_set['dima'] = $order_info['dima'];
+                       $value_set['dimb'] = $order_info['dimb'];
+                       $value_set['dime'] = $order_info['dime'];
+                       $value_set['loc1'] = $order_info['loc1'];
+                       $value_set['line_text'] = $order_info['title'];
+                       $value_set['spbudact_code'] = 
$order_info['spbudact_code'];
+                       $value_set['oppsynsmannid'] = $order_info['janitor'];
+                       $value_set['saksbehandlerid'] = 
$order_info['supervisor'];
+                       $value_set['budsjettansvarligid'] = 
$order_info['budget_responsible'];
+                       $value_set['project_id'] = 
execMethod('property.soXport.get_project', $order_id);
+                       $value_set = $this->db->validate_update($value_set);
+                       $this->db->query("UPDATE fm_ecobilag SET $value_set 
WHERE id =" . (int) $line_id, __LINE__, __FILE__);
                        return $GLOBALS['phpgw']->db->transaction_commit();
-
                }
 
                public function update_voucher2($data)
@@ -2191,9 +2192,9 @@
                                return false;
                        }
 
-                       $this->db->query("SELECT pmwrkord_code as order_id FROM 
fm_ecobilag WHERE id = " . (int)$data['line_id'],__LINE__,__FILE__);
+                       $this->db->query("SELECT pmwrkord_code as order_id FROM 
fm_ecobilag WHERE id = " . (int) $data['line_id'], __LINE__, __FILE__);
                        $this->db->next_record();
-                       if($data['order_id']!=$this->db->f('order_id'))
+                       if($data['order_id'] != $this->db->f('order_id'))
                        {
                                
if($this->update_voucher_by_changed_order($data['line_id'], $data['order_id']))
                                {
@@ -2215,39 +2216,39 @@
                        $value_set['periodization_start'] = 
$data['periodization_start'];
                        $value_set['kreditnota'] = !!$data['park_invoice'];
 
-                       $value_set      = 
$this->db->validate_update($value_set);
-                       $this->db->query("UPDATE fm_ecobilag SET $value_set 
WHERE bilagsnr =" . (int)$data['voucher_id'],__LINE__,__FILE__);
+                       $value_set = $this->db->validate_update($value_set);
+                       $this->db->query("UPDATE fm_ecobilag SET $value_set 
WHERE bilagsnr =" . (int) $data['voucher_id'], __LINE__, __FILE__);
                        unset($value_set);
 
                        $value_set_line = array();
 
-                       $value_set_line['pmwrkord_code']        = 
$data['order_id'];
-                       $value_set_line['dimb']                         = 
$data['dim_b'];
-                       $value_set_line['dima']                         = 
$data['dim_a'];
-                       $value_set_line['dime']                         = 
$data['dim_e'];
-                       $value_set_line['mvakode']                      = 
$data['tax_code'];
-                       $value_set_line['project_id']           = 
$data['project_group'];
-                       $value_set_line['spbudact_code']        = 
$data['b_account_id'];
-                       $value_set_line['line_text']            = 
$this->db->db_addslashes($data['line_text']);
-                       $value_set_line['process_log']          = 
$this->db->db_addslashes($data['process_log']);
-                       $value_set_line['process_code']         = 
$data['process_code'];
+                       $value_set_line['pmwrkord_code'] = $data['order_id'];
+                       $value_set_line['dimb'] = $data['dim_b'];
+                       $value_set_line['dima'] = $data['dim_a'];
+                       $value_set_line['dime'] = $data['dim_e'];
+                       $value_set_line['mvakode'] = $data['tax_code'];
+                       $value_set_line['project_id'] = $data['project_group'];
+                       $value_set_line['spbudact_code'] = 
$data['b_account_id'];
+                       $value_set_line['line_text'] = 
$this->db->db_addslashes($data['line_text']);
+                       $value_set_line['process_log'] = 
$this->db->db_addslashes($data['process_log']);
+                       $value_set_line['process_code'] = $data['process_code'];
 
-                       $value_set_line = 
$this->db->validate_update($value_set_line);
-                       $this->db->query("UPDATE fm_ecobilag SET 
{$value_set_line} WHERE id = " . (int)$data['line_id'],__LINE__,__FILE__);
+                       $value_set_line = 
$this->db->validate_update($value_set_line);
+                       $this->db->query("UPDATE fm_ecobilag SET 
{$value_set_line} WHERE id = " . (int) $data['line_id'], __LINE__, __FILE__);
                        unset($value_set_line);
 
                        //update workorder
                        if($data['order_id'] && $data['b_account_id'])
                        {
-                               $this->db->query("SELECT type FROM fm_orders 
WHERE id={$data['order_id']}",__LINE__,__FILE__);
+                               $this->db->query("SELECT type FROM fm_orders 
WHERE id={$data['order_id']}", __LINE__, __FILE__);
                                $this->db->next_record();
-                               switch ( $this->db->f('type') )
+                               switch($this->db->f('type'))
                                {
                                        case 'workorder':
-                                               $value_set_line['account_id']   
                = $data['b_account_id'];
-                                               $value_set_line['category']     
                        = $data['dim_e'];
+                                               $value_set_line['account_id'] = 
$data['b_account_id'];
+                                               $value_set_line['category'] = 
$data['dim_e'];
 
-                                               $value_set_line = 
$this->db->validate_update($value_set_line);
+                                               $value_set_line = 
$this->db->validate_update($value_set_line);
                                                $this->db->query("UPDATE 
fm_workorder SET {$value_set_line} WHERE id='{$data['order_id']}'");
                                                unset($value_set_line);
                                                break;
@@ -2256,10 +2257,10 @@
 
                        foreach($data['approved_amount'] as $line_id => 
$approved_amount)
                        {
-                               $approved_amount                = 
str_replace(array(' ', ','),array('','.'),$approved_amount);
+                               $approved_amount = str_replace(array(' ', ','), 
array('', '.'), $approved_amount);
                                if(is_numeric($approved_amount))
                                {
-                                       $this->db->query("UPDATE fm_ecobilag 
SET godkjentbelop = '$approved_amount' WHERE id = 
'{$line_id}'",__LINE__,__FILE__);
+                                       $this->db->query("UPDATE fm_ecobilag 
SET godkjentbelop = '$approved_amount' WHERE id = '{$line_id}'", __LINE__, 
__FILE__);
                                }
                                else
                                {
@@ -2276,9 +2277,9 @@
                                                continue;
                                        }
 
-                                       $split_amount           = 
str_replace(array(' ', ','),array('','.'),$split_amount);
+                                       $split_amount = str_replace(array(' ', 
','), array('', '.'), $split_amount);
 
-                                       if(!is_numeric($split_amount ))
+                                       if(!is_numeric($split_amount))
                                        {
                                                
phpgwapi_cache::message_set(lang('Not a valid amount'), 'error');
                                                continue;
@@ -2286,7 +2287,7 @@
 
                                        $table = 'fm_ecobilag';
 
-                                       $this->db->query("SELECT belop FROM 
{$table} WHERE id={$id}",__LINE__,__FILE__);
+                                       $this->db->query("SELECT belop FROM 
{$table} WHERE id={$id}", __LINE__, __FILE__);
                                        $this->db->next_record();
                                        $amount = $this->db->f('belop');
 
@@ -2308,86 +2309,86 @@
                                        }
 
                                        $metadata = $this->db->metadata($table);
-                                       $sql ="SELECT * FROM {$table} WHERE id= 
{$id}";
-                                       
$this->db->query($sql,__LINE__,__FILE__);
+                                       $sql = "SELECT * FROM {$table} WHERE 
id= {$id}";
+                                       $this->db->query($sql, __LINE__, 
__FILE__);
                                        $this->db->next_record();
 
                                        $value_set = array();
 
-                                       $skip_values = array('id','project_id', 
'pmwrkord_code', 'dima', 'dime', 'loc1', 'mvakode', 'dimd', 'merknad', 
'line_text','oppsynsmannid','saksbehandlerid','oppsynsigndato','saksigndato','budsjettsigndato','process_code',
 'process_log');
+                                       $skip_values = array('id', 
'project_id', 'pmwrkord_code', 'dima', 'dime', 'loc1', 'mvakode', 'dimd', 
'merknad', 'line_text', 'oppsynsmannid', 'saksbehandlerid', 'oppsynsigndato', 
'saksigndato', 'budsjettsigndato', 'process_code', 'process_log');
 
                                        foreach($metadata as $_field)
                                        {
                                                if(!in_array($_field->name, 
$skip_values))
                                                {
-                                                       
$value_set[$_field->name] = $this->db->f($_field->name,true);
+                                                       
$value_set[$_field->name] = $this->db->f($_field->name, true);
                                                }
                                        }
 
-                                       $this->db->query( "INSERT INTO {$table} 
(" . implode( ',', array_keys($value_set) ) . ')'
-                                               . ' VALUES (' . 
$this->db->validate_insert( array_values($value_set) ) . ')',__LINE__,__FILE__);
+                                       $this->db->query("INSERT INTO {$table} 
(" . implode(',', array_keys($value_set)) . ')'
+                                       . ' VALUES (' . 
$this->db->validate_insert(array_values($value_set)) . ')', __LINE__, __FILE__);
 
-                                       $new_id = 
$this->db->get_last_insert_id($table,'id');
+                                       $new_id = 
$this->db->get_last_insert_id($table, 'id');
 
 
-                                       $value_set= array
-                                       (
-                                               'belop'                 => 
$split_amount,
-                                               'godkjentbelop' => $split_amount
+                                       $value_set = array
+                                               (
+                                               'belop'                  => 
$split_amount,
+                                               'godkjentbelop'  => 
$split_amount
                                        );
-                                       $value_set      = 
$this->db->validate_update($value_set);
-                                       $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$id}" ,__LINE__,__FILE__);
+                                       $value_set = 
$this->db->validate_update($value_set);
+                                       $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$id}", __LINE__, __FILE__);
 
-                                       $value_set= array
-                                       (
-                                               'belop'                 => 
$amount - $split_amount,
-                                               'godkjentbelop' => $amount - 
$split_amount,
-                                               'splitt'                => $id
+                                       $value_set = array
+                                               (
+                                               'belop'                  => 
$amount - $split_amount,
+                                               'godkjentbelop'  => $amount - 
$split_amount,
+                                               'splitt'                 => $id
                                        );
-                                       $value_set      = 
$this->db->validate_update($value_set);
-                                       $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$new_id}" ,__LINE__,__FILE__);
+                                       $value_set = 
$this->db->validate_update($value_set);
+                                       $this->db->query("UPDATE {$table} SET 
$value_set WHERE id= {$new_id}", __LINE__, __FILE__);
                                }
                        }
 
-/*
-                       if($data['process_log'] || $data['process_code'])
-                       {
-                               $valueset_log = array
-                               (
-                                       'bilagsnr'              => 
$data['voucher_id'],
-                                       'process_code'  => 
$data['process_code'],
-                                       'process_log'   => 
$this->db->db_addslashes($data['process_log']),
-                                       'user_id'               => 
$this->account_id,
-                                       'entry_date'    => time(),
-                                       'modified_date' => time()
-                               );
+                       /*
+                         if($data['process_log'] || $data['process_code'])
+                         {
+                         $valueset_log = array
+                         (
+                         'bilagsnr'            => $data['voucher_id'],
+                         'process_code'        => $data['process_code'],
+                         'process_log' => 
$this->db->db_addslashes($data['process_log']),
+                         'user_id'             => $this->account_id,
+                         'entry_date'  => time(),
+                         'modified_date'       => time()
+                         );
 
-                               $sql = "SELECT id FROM fm_ecobilag_process_log 
WHERE bilagsnr = '{$data['voucher_id']}'";
-                               $this->db->query($sql,__LINE__,__FILE__);
-                               if($this->db->next_record())
-                               {
-                                       $process_log_id = 
(int)$this->db->f('id');
-                                       $valueset_log   = 
$this->db->validate_update($valueset_log);
-                                       $this->db->query("UPDATE 
fm_ecobilag_process_log SET $valueset_log WHERE id = 
$process_log_id",__LINE__,__FILE__);
-                               }
-                               else
-                               {
-                                       $cols = implode(',', 
array_keys($valueset_log));
-                                       $values = 
$this->db->validate_insert($valueset_log);
-                                       $this->db->query("INSERT INTO 
fm_ecobilag_process_log ({$cols}) VALUES ({$values})",__LINE__,__FILE__);
-                               }
-                       }
+                         $sql = "SELECT id FROM fm_ecobilag_process_log WHERE 
bilagsnr = '{$data['voucher_id']}'";
+                         $this->db->query($sql,__LINE__,__FILE__);
+                         if($this->db->next_record())
+                         {
+                         $process_log_id = (int)$this->db->f('id');
+                         $valueset_log = 
$this->db->validate_update($valueset_log);
+                         $this->db->query("UPDATE fm_ecobilag_process_log SET 
$valueset_log WHERE id = $process_log_id",__LINE__,__FILE__);
+                         }
+                         else
+                         {
+                         $cols = implode(',', array_keys($valueset_log));
+                         $values       = 
$this->db->validate_insert($valueset_log);
+                         $this->db->query("INSERT INTO fm_ecobilag_process_log 
({$cols}) VALUES ({$values})",__LINE__,__FILE__);
+                         }
+                         }
 
-*/
-                       if( isset($data['order_id']) && $data['order_id'])
+                        */
+                       if(isset($data['order_id']) && $data['order_id'])
                        {
                                if(isset($data['close_order']) && 
$data['close_order'] && !$data['close_order_orig'])
                                {
-                                       
execMethod('property.soworkorder.close_orders',array($data['order_id']));
+                                       
execMethod('property.soworkorder.close_orders', array($data['order_id']));
                                }
                                if(isset($data['close_order_orig']) && 
$data['close_order_orig'] && !$data['close_order'])
                                {
-                                       
execMethod('property.soworkorder.reopen_orders',array($data['order_id']));
+                                       
execMethod('property.soworkorder.reopen_orders', array($data['order_id']));
                                }
                        }
 
@@ -2405,9 +2406,9 @@
 
                        if($data['janitor_lid'])
                        {
-                               if( stripos($data['janitor_lid'],'*') === 0)
+                               if(stripos($data['janitor_lid'], '*') === 0)
                                {
-                                       $data['janitor_lid'] = 
ltrim($data['janitor_lid'],'*');
+                                       $data['janitor_lid'] = 
ltrim($data['janitor_lid'], '*');
                                        $filtermethod .= " $where 
oppsynsigndato IS NULL";
                                        $where = 'AND';
                                }
@@ -2417,10 +2418,10 @@
 
                        if($data['supervisor_lid'])
                        {
-                               if( stripos($data['supervisor_lid'],'*') === 0)
+                               if(stripos($data['supervisor_lid'], '*') === 0)
                                {
-                                       $data['supervisor_lid'] = 
ltrim($data['supervisor_lid'],'*');
-               //                      $filtermethod .= " $where 
oppsynsigndato IS NOT NULL AND saksigndato IS NULL";
+                                       $data['supervisor_lid'] = 
ltrim($data['supervisor_lid'], '*');
+                                       //                      $filtermethod 
.= " $where oppsynsigndato IS NOT NULL AND saksigndato IS NULL";
                                        $filtermethod .= " $where saksigndato 
IS NULL";
                                        $where = 'AND';
                                }
@@ -2431,9 +2432,9 @@
 
                        if($data['budget_responsible_lid'])
                        {
-                               if( 
stripos($data['budget_responsible_lid'],'*') === 0)
+                               if(stripos($data['budget_responsible_lid'], 
'*') === 0)
                                {
-                                       $data['budget_responsible_lid'] = 
ltrim($data['budget_responsible_lid'],'*');
+                                       $data['budget_responsible_lid'] = 
ltrim($data['budget_responsible_lid'], '*');
                                        $filtermethod .= " $where saksigndato 
IS NOT NULL AND budsjettsigndato IS NULL";
                                        $where = 'AND';
                                }
@@ -2443,7 +2444,7 @@
 
                        if($data['query'])
                        {
-                               switch ($data['criteria'])
+                               switch($data['criteria'])
                                {
                                        case 'voucher_id':
                                                $query = (int) $data['query'];
@@ -2466,7 +2467,7 @@
                                                break;
 
                                        case 'b_account':
-                                               $query =  $data['query'];
+                                               $query = $data['query'];
                                                $querymethod = " $where 
spbudact_code = '{$query}'";
                                                break;
 
@@ -2482,10 +2483,10 @@
                        }
 
                        $sql = "SELECT bilagsnr,bilagsnr_ut, org_name, 
currency, kreditnota, fm_ecoart.descr as type, godkjentbelop, forfallsdato, 
oppsynsigndato, saksigndato,budsjettsigndato"
-                       ." FROM fm_ecobilag"
-                       ." {$this->join} fm_vendor ON fm_vendor.id = 
fm_ecobilag.spvend_code"
-                       ." {$this->join} fm_ecoart ON fm_ecoart.id = 
fm_ecobilag.artid"
-                       ." $filtermethod $querymethod ORDER BY forfallsdato 
ASC, bilagsnr ASC";
+                       . " FROM fm_ecobilag"
+                       . " {$this->join} fm_vendor ON fm_vendor.id = 
fm_ecobilag.spvend_code"
+                       . " {$this->join} fm_ecoart ON fm_ecoart.id = 
fm_ecobilag.artid"
+                       . " $filtermethod $querymethod ORDER BY forfallsdato 
ASC, bilagsnr ASC";
 
                        $lang_voucer = lang('voucher id');
                        $lang_vendor = lang('vendor');
@@ -2495,19 +2496,19 @@
                        $lang_approved_amount = lang('approved amount');
                        $lang_payment_date = lang('payment date');
 
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->query($sql, __LINE__, __FILE__);
                        $values = array();
 
                        while($this->db->next_record())
                        {
                                $bilagsnr = $this->db->f('bilagsnr');
 
-                               $values[$bilagsnr]['bilagsnr_ut']               
= $this->db->f('bilagsnr_ut');
-                               $values[$bilagsnr]['org_name']                  
= $this->db->f('org_name', true);
-                               $values[$bilagsnr]['currency']                  
= $this->db->f('currency');
-                               $values[$bilagsnr]['kreditnota']                
= $this->db->f('kreditnota');
-                               $values[$bilagsnr]['type']                      
        = $this->db->f('type');
-                               $values[$bilagsnr]['payment_date']              
= $this->db->f('forfallsdato');
+                               $values[$bilagsnr]['bilagsnr_ut'] = 
$this->db->f('bilagsnr_ut');
+                               $values[$bilagsnr]['org_name'] = 
$this->db->f('org_name', true);
+                               $values[$bilagsnr]['currency'] = 
$this->db->f('currency');
+                               $values[$bilagsnr]['kreditnota'] = 
$this->db->f('kreditnota');
+                               $values[$bilagsnr]['type'] = 
$this->db->f('type');
+                               $values[$bilagsnr]['payment_date'] = 
$this->db->f('forfallsdato');
 
                                if(isset($values[$bilagsnr]['godkjentbelop']))
                                {
@@ -2536,28 +2537,20 @@
                        }
 
                        $voucers = array();
-                       foreach ($values as $bilagsnr => $entry)
+                       foreach($values as $bilagsnr => $entry)
                        {
-                               $payment_date = 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'],strtotime($entry['payment_date']));
+                               $payment_date = 
date($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat'], 
strtotime($entry['payment_date']));
                                $status = $entry['status'];
                                sort($status);
 
                                $voucher_id = $entry['bilagsnr_ut'] ? 
$entry['bilagsnr_ut'] : $bilagsnr;
-                               $name = sprintf("{$lang_payment_date}: % 10s | 
{$lang_voucer}:% 8s | {$lang_vendor}: % 50s | {$lang_currency}: % 3s | 
{$lang_parked}: % 1s | {$lang_type}: % 12s | {$lang_approved_amount}: % 19s | 
Status: % 1s",
-                                                       $payment_date,
-                                                       $voucher_id,
-                                                       
trim(strtoupper($entry['org_name'])),
-                                                       $entry['currency'],
-                                                       $entry['kreditnota'] ? 
'X' : '',
-                                                       $entry['type'],
-                                                       
number_format($entry['godkjentbelop'], 2, ',', ' '),
-                                                       $status[0]
-                                               );
+                               $name = sprintf("{$lang_payment_date}: % 10s | 
{$lang_voucer}:% 8s | {$lang_vendor}: % 50s | {$lang_currency}: % 3s | 
{$lang_parked}: % 1s | {$lang_type}: % 12s | {$lang_approved_amount}: % 19s | 
Status: % 1s", $payment_date, $voucher_id, 
trim(strtoupper($entry['org_name'])), $entry['currency'], $entry['kreditnota'] 
? 'X' : '', $entry['type'], number_format($entry['godkjentbelop'], 2, ',', ' 
'), $status[0]
+                               );
 
                                $voucers[] = array
-                               (
-                                       'id'    => $bilagsnr,
-                                       'name'  => $name
+                                       (
+                                       'id'     => $bilagsnr,
+                                       'name'   => $name
                                );
                        }
 
@@ -2568,9 +2561,10 @@
                {
                        $vendor_id = (int) $vendor_id;
                        $sql = "SELECT max(cast(fakturanr as int)) as 
invoice_num FROM fm_ecobilagoverf WHERE spvend_code = {$vendor_id}";
-                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->query($sql, __LINE__, __FILE__);
                        $this->db->next_record();
-                       $invoice_num = $this->db->f('invoice_num') +1;
+                       $invoice_num = $this->db->f('invoice_num') + 1;
                        return $invoice_num;
                }
-       }
+
+       }       
\ No newline at end of file

Modified: branches/Version-1_0-branch/property/inc/class.uiimport.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiimport.inc.php     
2014-02-13 12:19:03 UTC (rev 11684)
+++ branches/Version-1_0-branch/property/inc/class.uiimport.inc.php     
2014-02-13 12:22:30 UTC (rev 11685)
@@ -53,20 +53,22 @@
                        
                        $this->valid_tables = array
                        (
-                               'fm_vendor'                                     
        => 'fm_vendor (' . lang('vendor') . ')',
-                               'fm_condition_survey'                   => 
'fm_condition_survey (' . lang('condition survey') . ')',
-                               'fm_ecodimb'                                    
=> 'fm_ecodimb (' . lang('dimb') . ')',
-                               'fm_budget'                                     
        => 'fm_budget (' . lang('budget') . ')',
-                               'fm_department'                                 
=> 'fm_department (' . lang('department') . ')',
-                               'fm_eco_periodization_outline'  => 
'fm_eco_periodization_outline (' . lang('periodization outline') . ')',
-                               'fm_eco_periodization'                  => 
'fm_eco_periodization (' . lang('periodization') . ')',
+                               'fm_vendor'                                     
        => array('name' => 'fm_vendor (' . lang('vendor') . ')', 'permission' 
=> PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT),
+                               'fm_condition_survey'                   => 
array('name' => 'fm_condition_survey (' . lang('condition survey') . ')', 
'permission' => PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT),
+                               'fm_ecodimb'                                    
=> array('name' => 'fm_ecodimb (' . lang('dimb') . ')', 'permission' => 
PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT),
+                               'fm_budget'                                     
        => array('name' => 'fm_budget (' . lang('budget') . ')', 'permission' 
=> PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT),
+                               'fm_department'                                 
=> array('name' => 'fm_department (' . lang('department') . ')', 'permission' 
=> PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT),
+                               'fm_eco_periodization_outline'  => array('name' 
=> 'fm_eco_periodization_outline (' . lang('periodization outline') . ')', 
'permission' => PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT),
+                               'fm_eco_periodization'                  => 
array('name' => 'fm_eco_periodization (' . lang('periodization') . ')', 
'permission' => PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT),
+                               'fm_ecodimd'                                    
=> array('name' => 'fm_ecodimd', 'permission' => PHPGW_ACL_READ | PHPGW_ACL_ADD 
| PHPGW_ACL_EDIT),
+                               'phpgw_categories'                              
=> array('name' => 'phpgw_categories (' . lang('categories') . ')', 
'permission' => PHPGW_ACL_READ),
                        );
 
                        $location_types = 
execMethod('property.soadmin_location.select_location_type');
                        
                        foreach ($location_types as $location_type)
                        {
-                               
$this->valid_tables["fm_location{$location_type['id']}"] = 
"fm_location{$location_type['id']} ({$location_type['name']})";
+                               
$this->valid_tables["fm_location{$location_type['id']}"] = array('name' => 
"fm_location{$location_type['id']} ({$location_type['name']})", 'permission' => 
PHPGW_ACL_READ | PHPGW_ACL_ADD | PHPGW_ACL_EDIT);
                        }
 
                        if($this->table && !in_array($this->table, 
array_keys($this->valid_tables)))
@@ -285,7 +287,7 @@
                                {
                                        $selected = $import_settings['table'] 
== $table ? 'selected =  "selected"' : '';
                                        $table_option .=  <<<HTML
-                                       <option 
value='{$table}'{$selected}>{$table_info}</option>
+                                       <option 
value='{$table}'{$selected}>{$table_info['name']}::{$table_info['permission']}</option>
 HTML;
                                }
 
@@ -392,6 +394,13 @@
                        $_fields = array();
                        if(!$location_id && $this->table)
                        {
+                               $_permission = 
$this->valid_tables[$this->table]['permission'];
+
+                               if(! ($_permission & PHPGW_ACL_READ) )
+                               {
+                                       throw new Exception("No READ-right for 
{$this->table}");
+                               }
+
                                $metadata = $this->db->metadata($this->table);
 
                                foreach ($metadata as $field => $info)
@@ -502,6 +511,13 @@
                        $metadata = array();
                        if($this->table && $this->fields)
                        {
+                               $_permission = 
$this->valid_tables[$this->table]['permission'];
+
+                               if(! ($_permission & PHPGW_ACL_ADD) )
+                               {
+                                       throw new Exception("No ADD-right for 
{$this->table}");
+                               }
+
                                $metadata = $this->db->metadata($this->table);
 
                                if(phpgw::get_var('debug', 'bool'))
@@ -509,7 +525,6 @@
                                        _debug_array($metadata);
                                }
 
-
                                foreach($this->fields as $field)
                                {
                                        if($field && !isset($metadata[$field]))

Modified: 
branches/Version-1_0-branch/property/inc/export/default/Agresso_Bergen_Kostfordeling
===================================================================
--- 
branches/Version-1_0-branch/property/inc/export/default/Agresso_Bergen_Kostfordeling
        2014-02-13 12:19:03 UTC (rev 11684)
+++ 
branches/Version-1_0-branch/property/inc/export/default/Agresso_Bergen_Kostfordeling
        2014-02-13 12:22:30 UTC (rev 11685)
@@ -256,7 +256,7 @@
                                $BilagOverf['splitt'],
                                $BilagOverf['kildeid'],
                                $BilagOverf['kidnr'],
-                               $BilagOverf[typeid],
+                               $BilagOverf['typeid'],
                                $BilagOverf['fakturadato'],
                                $BilagOverf['forfallsdato'],
                                $BilagOverf['regtid'],
@@ -301,7 +301,7 @@
 
 //                     $download = 'on';
 //                     $download = False;
-                       $pre_transfer=True;
+                       $pre_transfer=false;
 //                     $this->debug=True;
 
                        //Generer batch ID

Modified: 
branches/Version-1_0-branch/property/inc/import/default/Import_fra_Service_EBF
===================================================================
--- 
branches/Version-1_0-branch/property/inc/import/default/Import_fra_Service_EBF  
    2014-02-13 12:19:03 UTC (rev 11684)
+++ 
branches/Version-1_0-branch/property/inc/import/default/Import_fra_Service_EBF  
    2014-02-13 12:22:30 UTC (rev 11685)
@@ -257,7 +257,7 @@
                                }
                                else
                                {
-                                       $buffer[$this->id]['dime'] = 
$workorder['cat_id']; // Dim 6
+                                       $buffer[$this->id]['dime'] = 
strlen($workorder['cat_id']) == 4 ? $workorder['cat_id'] : ''; // Dim 6
                                        $buffer[$this->id]['spbudact_code'] = 
$workorder['b_account_id'];
                                }
                        }

Modified: branches/Version-1_0-branch/property/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/property/setup/phpgw_no.lang    2014-02-13 
12:19:03 UTC (rev 11684)
+++ branches/Version-1_0-branch/property/setup/phpgw_no.lang    2014-02-13 
12:22:30 UTC (rev 11685)
@@ -16,7 +16,7 @@
 accounting     property        no      Regnskap
 accounting categories  property        no      Kategorier regnskap
 accounting dim b       property        no      Ansvarssted
-accounting dim d       property        no      Regnskap dim d
+accounting dim d       property        no      Regnskap dim 6
 accounting tax property        no      Regnskap mva-kode
 accounting voucher category    property        no      Regnskap kategorier 
faktura
 accounting voucher type        property        no      Regnskap type faktura
@@ -556,7 +556,7 @@
 no authorities demands property        no      Ingen myndighetskrav
 no dimb        property        no      K Ikke valgt
 Please select dimb!    property        no      Angi Ansvarssted
-dim d  property        no      Dim D
+dim d  property        no      Dim 6
 dime   property        no      Kategori
 directory created      property        no      katalog er opprettet
 disable        property        no      Deaktiver
@@ -1134,7 +1134,7 @@
 no criteria    property        no      kriterie ikke valgt
 no datatype    property        no      Datatype ikke valgt
 no dim b       property        no      Ansvarssted ikke valgt
-no dim d       property        no      Dim D ikke valgt
+no dim d       property        no      Dim 6 ikke valgt
 no district    property        no      Distrikt ikke valgt
 no document type       property        no      Ingen dokument-type
 no entity type property        no      Entitet type ikke valgt
@@ -1575,7 +1575,7 @@
 select the date for the first value    property        no      angi dato for 
første verdi
 select the date for the update property        no      angi dato for 
oppdatering
 select the dim b for this invoice. to do not use dim b -  select no dim b      
property        no      velg Ansvarssted for bilag. For ikke å bruke 
Ansvarssted - velg Ansvarssted IKKE VALGT
-select the dim d for this activity. to do not use dim d -  select no dim d     
property        no      velg DIM D for bilag. For ikke å bruke DIM D - velg 
DIMD IKKE VALGT
+select the dim d for this activity. to do not use dim d -  select no dim d     
property        no      velg DIM 6 for bilag. For ikke å bruke DIM 6 - velg 
DIMD IKKE VALGT
 select the district the part of town belongs to.       property        no      
Velg hvilke distrikt denne bydelen tilhører
 select the district the selection belongs to. to do not use a district select 
no district      property        no      velg distrikt utvalget tilhører. For 
ikke å bruke distrikt velg DISTRIKT IKKE VALGT
 select the document type the document belongs to.      property        no      
Velg dokumenttype for dette dokumentet
@@ -1788,7 +1788,8 @@
 this building_id id does not exist!    property        no      Denne bygnings 
ID eksisterer ikke
 this building is already registered!   property        no      denne bygningen 
er allrerede registert
 this dim a is not valid:       property        no      DIMA er ikke gyldig:
-this dim d is not valid:       property        no      Denne Dim D er ikke 
gyldig:
+this dim d is not valid:       property        no      Denne Dim 6 er ikke 
gyldig:
+dim d is mandatory     property        no      Dim 6 er obligatorisk
 this entrance id does not exist!       property        no      Denne inngang 
ID eksisterer ikke
 this entrance_id id does not exist!    property        no      Denne bygnings 
ID eksisterer ikke
 this entrance is already registered!   property        no      denne inngangen 
er allrerede registert




reply via email to

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