fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11547] Merge 11538:11546 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [11547] Merge 11538:11546 from trunk
Date: Thu, 19 Dec 2013 18:50:33 +0000

Revision: 11547
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11547
Author:   sigurdne
Date:     2013-12-19 18:50:32 +0000 (Thu, 19 Dec 2013)
Log Message:
-----------
Merge 11538:11546 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/booking/inc/class.bobooking.inc.php
    branches/Version-1_0-branch/property/inc/class.sobudget.inc.php
    branches/Version-1_0-branch/property/inc/class.uibudget.inc.php
    
branches/Version-1_0-branch/property/inc/cron/default/Import_fra_agresso_X205.php
    branches/Version-1_0-branch/property/inc/import/default/Import_fra_Service
    branches/Version-1_0-branch/property/js/portico/ajax_invoice.js
    branches/Version-1_0-branch/property/js/yahoo/budget.obligations.js

Added Paths:
-----------
    
branches/Version-1_0-branch/property/inc/export/default/Agresso_Bergen_Kostfordeling

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
   + 
/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

Modified: branches/Version-1_0-branch/booking/inc/class.bobooking.inc.php
===================================================================
--- branches/Version-1_0-branch/booking/inc/class.bobooking.inc.php     
2013-12-19 18:47:00 UTC (rev 11546)
+++ branches/Version-1_0-branch/booking/inc/class.bobooking.inc.php     
2013-12-19 18:50:32 UTC (rev 11547)
@@ -401,8 +401,17 @@
                                                // We need to use 24:00 instead 
of 00:00 to sort correctly
                                                $new_booking['to_'] = 
$new_booking['to_'] == '00:00' ? '24:00' : $new_booking['to_'];
                                                $new_bookings[] = $new_booking;
+
                                                if($date->format('Y-m-d') == 
$end->format('Y-m-d'))
+                                               {
                                                        break;
+                                               }
+
+                                               if($date->getTimestamp() > 
$end->getTimestamp())
+                                               {
+                                                       throw new 
InvalidArgumentException('start time( ' . $date->format('Y-m-d') . ' ) later 
than end time( ' . $end->format('Y-m-d') . " ) for 
{$booking['type']}#{$booking['id']}::{$booking['name']}");
+                                               }
+
                                                $date->modify('+1 day');
                                        }
                                        while(true);

Modified: branches/Version-1_0-branch/property/inc/class.sobudget.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.sobudget.inc.php     
2013-12-19 18:47:00 UTC (rev 11546)
+++ branches/Version-1_0-branch/property/inc/class.sobudget.inc.php     
2013-12-19 18:50:32 UTC (rev 11547)
@@ -525,7 +525,7 @@
                        $sort                   = isset($data['sort']) ? 
$data['sort'] : 'DESC';
                        $order                  = isset($data['order']) ? 
$data['order'] : '';
                        $allrows                = isset($data['allrows']) ? 
$data['allrows'] : '';
-                       $district_id    = isset($data['district_id']) ? 
$data['district_id'] : '';
+                       $filter_district_id     = isset($data['district_id']) 
&& $data['district_id'] ? (int)$data['district_id'] : 0;
                        $year                   = isset($data['year']) ? 
(int)$data['year'] : '';
                        $grouping               = isset($data['grouping']) ? 
$data['grouping'] : '';
                        $revision               = isset($data['revision']) ? 
$data['revision'] : 1;
@@ -580,9 +580,9 @@
                                $where = 'AND';
                        }
 
-                       if ($district_id > 0)
+                       if ($filter_district_id > 0)
                        {
-                               $filtermethod .= " {$where} district_id=" . 
(int)$district_id;
+                               $filtermethod .= " {$where} district_id=" . 
(int)$filter_district_id;
                                $where = 'AND';
                        }
 
@@ -673,6 +673,7 @@
                        {
 
                                $_id = $this->db->f('id');
+                               $district_id = $filter_district_id ? 
(int)$this->db->f('district_id') : 0;
 
 
 $projects[$this->db->f('project_id')] = 0;
@@ -682,7 +683,7 @@
                                (
                                        'actual_cost'                   => 0,
                                        'mva'                                   
=> (int)$this->db->f('mva'),
-                                       'district_id'                   => 
(int)$this->db->f('district_id'),
+                                       'district_id'                   => 
$district_id,
                                        'ecodimb'                               
=> (int)$this->db->f('ecodimb'),
                                        'b_account'                             
=> $this->db->f('b_account'),
                                );
@@ -764,9 +765,9 @@
                                $where = 'AND';
                        }
 
-                       if ($district_id > 0)
+                       if ($filter_district_id > 0)
                        {
-                               $filtermethod .= " $where district_id=" . 
(int)$district_id;
+                               $filtermethod .= " $where district_id=" . 
(int)$filter_district_id;
                                $where = 'AND';
                        }
 
@@ -805,10 +806,11 @@
                                $_hits = $this->db->f('hits');
                                $sum_hits += $_hits;
 
-                               
$obligations[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
 += $_budget;
-                               
$hits[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
 += $_hits;
+                               $district_id = $filter_district_id ? 
(int)$this->db->f('district_id') : 0;
+                               
$obligations[$this->db->f($b_account_field)][$district_id][(int)$this->db->f('ecodimb')]
 += $_budget;
+                               
$hits[$this->db->f($b_account_field)][$district_id][(int)$this->db->f('ecodimb')]
 += $_hits;
                                $accout_info[$this->db->f($b_account_field)] = 
true;
-                               $district[$this->db->f('district_id')] = true;
+                               $district[$district_id] = true;
                                $ecodimb[(int)$this->db->f('ecodimb')] = true;
                        }
 
@@ -829,9 +831,11 @@
                                $_actual_cost = 
round($this->db->f('actual_cost'));
                                $sum_actual_cost += 
round($this->db->f('actual_cost'));
 
-                               
$actual_cost[$this->db->f($b_account_field)][$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
 += $_actual_cost;
+                               $district_id = $filter_district_id ? 
(int)$this->db->f('district_id') : 0;
+
+                               
$actual_cost[$this->db->f($b_account_field)][$district_id][(int)$this->db->f('ecodimb')]
 += $_actual_cost;
                                $accout_info[$this->db->f($b_account_field)] = 
true;
-                               $district[$this->db->f('district_id')] = true;
+                               $district[$district_id] = true;
                                $ecodimb[(int)$this->db->f('ecodimb')] = true;
                        }
                        //_debug_array($actual_cost);die();
@@ -866,9 +870,9 @@
                                $where = 'AND';
                        }
 
-                       if ($district_id > 0)
+                       if ($filter_district_id > 0)
                        {
-                               $filtermethod .= " $where 
district_id='$district_id' ";
+                               $filtermethod .= " $where 
district_id='$filter_district_id' ";
                                $where = 'AND';
                        }
 
@@ -905,17 +909,16 @@
                        while ($this->db->next_record())
                        {
                                $_budget_cost = 
round($this->db->f('budget_cost'));
+                               $district_id = $filter_district_id ? 
(int)$this->db->f('district_id') : 0;
                                $sum_budget_cost += $_budget_cost;
-                               
$budget_cost[$this->db->f('b_account_field')][$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
 += $_budget_cost;
+                               
$budget_cost[$this->db->f('b_account_field')][$district_id][(int)$this->db->f('ecodimb')]
 += $_budget_cost;
                                $accout_info[$this->db->f('b_account_field')] = 
true;
-                               $district[$this->db->f('district_id')] = true;
+                               $district[$district_id] = true;
                                $ecodimb[(int)$this->db->f('ecodimb')] = true;
                        }
 
                        //_debug_array($budget_cost);die();
 
-
-
 // start service agreements
 
                        $filtermethod = " fm_s_agreement_budget.year = $year";
@@ -954,7 +957,7 @@
                        //_debug_array($sql);die();
                        $this->db->query($sql . $ordermethod,__LINE__,__FILE__);
 
-                       $_dummy_district = 1;
+                       $_dummy_district = $filter_district_id ? 
$filter_district_id : 0;
                        while ($this->db->next_record())
                        {
                                $_budget = round($this->db->f('budget'));

Modified: branches/Version-1_0-branch/property/inc/class.uibudget.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uibudget.inc.php     
2013-12-19 18:47:00 UTC (rev 11546)
+++ branches/Version-1_0-branch/property/inc/class.uibudget.inc.php     
2013-12-19 18:50:32 UTC (rev 11547)
@@ -117,7 +117,7 @@
 
                        $revision_list  = 
$this->bo->get_revision_filter_list($this->revision); // reset year
                        $this->year             = $this->bo->year;
-                       $this->revision = $this->bo->revision; 
+                       $this->revision = $this->bo->revision;
                        $GLOBALS['phpgw_info']['flags']['menu_selection'] .= 
'::budget';
 
                        $datatable = array();
@@ -159,7 +159,7 @@
                                array_unshift 
($values_combo_box[0],$default_value);
 
                                $values_combo_box[1]  = 
$this->bo->get_revision_filter_list($this->revision);
-                               $default_value = array 
('id'=>'','name'=>lang('no revision')); 
+                               $default_value = array 
('id'=>'','name'=>lang('no revision'));
                                if (count($values_combo_box[1]))
                                {
                                        array_unshift 
($values_combo_box[1],$default_value);
@@ -198,7 +198,7 @@
                                                'selected' => $_cat['selected'] 
? 1 : 0
                                        );
                                }
-                               
+
                                array_unshift ($values_combo_box[4],array 
('id'=>'', 'name'=>lang('no category')));
 
                                $values_combo_box[5]  = 
$this->bocommon->select_category_list(array('type'=>'dimb'));
@@ -273,7 +273,7 @@
                                                                        
'tab_index' => 5
                                                                ),
                                                                array
-                                                               ( 
+                                                               (
                                                                        'id' => 
'sel_dimb_id',
                                                                        'name' 
=> 'dimb_id',
                                                                        'value' 
=> lang('dimb'),
@@ -381,7 +381,7 @@
                                        'visible'=>true,        
'name'=>'category',     'label'=>lang('category'),      
'className'=>'rightClasss', 'sortable'=>false,  
'sort_field'=>'','formatter'=>''),
                                array(
                                        'visible'=>true,        
'name'=>'budget_cost',  'label'=>lang('budget_cost'),   
'className'=>'rightClasss', 'sortable'=>true,   
'sort_field'=>'budget_cost','formatter'=>'myFormatDate'),
-                       );                      
+                       );
 
                        $content = array();
                        $j = 0;
@@ -501,7 +501,7 @@
                        }
                        //Depended select: REVISION
                        $opt_cb_depend  = 
$this->bo->get_revision_filter_list($this->revision);
-                       $default_value = array ('id'=>'','name'=>lang('no 
revision')); 
+                       $default_value = array ('id'=>'','name'=>lang('no 
revision'));
                        if (count($opt_cb_depend))
                        {
                                array_unshift ($opt_cb_depend,$default_value);
@@ -527,7 +527,7 @@
                        }
                        $json['hidden']['dependent'][] = array ('id'    => 
$this->grouping,
                                'value' => 
$this->bocommon->select2String($opt_cb_depend)
-                       );                                                      
                        
+                       );
 
                        // right in datatable
                        if(isset($datatable['rowactions']['action']) && 
is_array($datatable['rowactions']['action']))
@@ -586,7 +586,7 @@
 
                        $revision_list  = 
$this->bo->get_revision_filter_list($this->revision,$basis=true); // reset year
                        $this->year             = $this->bo->year;
-                       $this->revision = $this->bo->revision; 
+                       $this->revision = $this->bo->revision;
                        $GLOBALS['phpgw_info']['flags']['menu_selection'] .= 
'::basis';
 
                        $datatable = array();
@@ -628,7 +628,7 @@
                                array_unshift 
($values_combo_box[0],$default_value);
 
                                $values_combo_box[1]  = 
$this->bo->get_revision_filter_list($this->revision,$basis=true);
-                               $default_value = array 
('id'=>'','name'=>lang('no revision')); 
+                               $default_value = array 
('id'=>'','name'=>lang('no revision'));
                                if (count($values_combo_box[1]))
                                {
                                        array_unshift 
($values_combo_box[1],$default_value);
@@ -809,7 +809,7 @@
                                        'visible'=>true,        
'name'=>'category',     'label'=>lang('category'),      
'className'=>'rightClasss', 'sortable'=>false,  
'sort_field'=>'','formatter'=>''),
                                array(
                                        'visible'=>true,        
'name'=>'budget_cost',  'label'=>lang('budget_cost'),   
'className'=>'rightClasss', 'sortable'=>true,   
'sort_field'=>'budget_cost','formatter'=>myFormatDate),
-                       );                      
+                       );
 
                        $content = array();
                        $j = 0;
@@ -928,7 +928,7 @@
                        }
                        //Depended select: REVISION
                        $opt_cb_depend  = 
$this->bo->get_revision_filter_list($this->revision,$basis=true);
-                       $default_value = array ('id'=>'','name'=>lang('no 
revision')); 
+                       $default_value = array ('id'=>'','name'=>lang('no 
revision'));
                        if (count($opt_cb_depend))
                        {
                                array_unshift ($opt_cb_depend,$default_value);
@@ -954,7 +954,7 @@
                        }
                        $json['hidden']['dependent'][] = array ('id'    => 
$this->grouping,
                                'value' => 
$this->bocommon->select2String($opt_cb_depend)
-                       );                                                      
                        
+                       );
 
                        // right in datatable
                        if(isset($datatable['rowactions']['action']) && 
is_array($datatable['rowactions']['action']))
@@ -1067,7 +1067,7 @@
                                                'selected' => $_cat['selected'] 
? 1 : 0
                                        );
                                }
-                               
+
                                array_unshift ($values_combo_box[2],array 
('id'=>'', 'name'=>lang('no category')));
 
 //_debug_array($values_combo_box[2]);
@@ -1144,7 +1144,7 @@
                                                                        'type'  
        => 'button',
                                                                        'style' 
        => 'filter',
                                                                        
'tab_index' => 3
-                                                               ),              
                                                
+                                                               ),*/
                                                                array
                                                                ( //boton       
GROUPING
                                                                        'id'    
        => 'btn_grouping',
@@ -1155,15 +1155,6 @@
                                                                        
'tab_index' => 4
                                                                ),
                                                                array
-                                                               ( //boton       
GROUPING
-                                                                       'id'    
        => 'btn_dimb_id',
-                                                                       'name'  
        => 'dimb_id',
-                                                                       'value' 
        => lang('dimb'),
-                                                                       'type'  
        => 'button',
-                                                                       'style' 
        => 'filter',
-                                                                       
'tab_index' => 5
-                                                               ),*/
-                                                               array
                                                                ( //boton       
USER
                                                                        //      
'id' => 'btn_user_id',
                                                                        'id' => 
'sel_cat_id',
@@ -1175,6 +1166,7 @@
                                                                        
'onchange'=> 'onChangeSelect("cat_id");',
                                                                        
'tab_index' => 3
                                                                ),
+/*
                                                                array
                                                                ( //boton       
USER
                                                                        //      
'id' => 'btn_user_id',
@@ -1187,6 +1179,7 @@
                                                                        
'onchange'=> 'onChangeSelect("grouping");',
                                                                        
'tab_index' => 4
                                                                ),
+*/
                                                                array
                                                                ( //boton       
USER
                                                                        //      
'id' => 'btn_user_id',
@@ -1261,17 +1254,12 @@
                                                                ( //div values  
combo_box_1
                                                                        'id' => 
'values_combo_box_1',
                                                                        'value' 
=> $this->bocommon->select2String($values_combo_box[1])
-                                                               )/*,
-                                                               array
-                                                               ( //div values  
combo_box_2
-                                                                       'id' => 
'values_combo_box_2',
-                                                                       'value' 
=> $this->bocommon->select2String($values_combo_box[2],'cat_id','name')
                                                                ),
                                                                array
                                                                ( //div values  
combo_box_3
-                                                                       'id' => 
'values_combo_box_3',
+                                                                       'id' => 
'values_combo_box_2',
                                                                        'value' 
=> $this->bocommon->select2String($values_combo_box[3])
-                                                               ),
+                                                               ),/*
                                                                array
                                                                ( //div values  
combo_box_4
                                                                        'id' => 
'values_combo_box_4',
@@ -1291,9 +1279,9 @@
                                        'col_name'=>'grouping',         
'visible'=>false,       'label'=>'',                            
'className'=>'',                                'sortable'=>false,      
'sort_field'=>'',                       'formatter'=>''),
                                array(
                                        'col_name'=>'b_account',                
'visible'=>true,        'label'=>lang('grouping'),      
'className'=>'centerClasss',    'sortable'=>true,       
'sort_field'=>'b_account',      'formatter'=>'myformatLinkPGW'),
+//                             array(
+//                                     'col_name'=>'district_id',      
'visible'=>true,        
'label'=>lang('district_id'),'className'=>'centerClasss',       
'sortable'=>false,      'sort_field'=>'',                       
'formatter'=>''),
                                array(
-                                       'col_name'=>'district_id',      
'visible'=>true,        
'label'=>lang('district_id'),'className'=>'centerClasss',       
'sortable'=>false,      'sort_field'=>'',                       
'formatter'=>''),
-                               array(
                                        'col_name'=>'ecodimb',          
'visible'=>true,        'label'=>lang('dimb'),  'className'=>'centerClasss',    
'sortable'=>false,      'sort_field'=>'',                       
'formatter'=>''),
                                array(
                                        'col_name'=>'hits_ex',          
'visible'=>false,       'label'=>'',                            
'className'=>'rightClasss',             'sortable'=>false,      
'sort_field'=>'',                       'formatter'=>''),
@@ -1319,7 +1307,7 @@
                                        'col_name'=>'diff_ex',          
'visible'=>false,       'label'=>'',                            
'className'=>'rightClasss',     'sortable'=>false,      'sort_field'=>'',       
                'formatter'=>''),
                                array(
                                        'col_name'=>'diff',                     
'visible'=>true,        'label'=>lang('difference'),'className'=>'rightClasss', 
        'sortable'=>false,      'sort_field'=>'',                       
'formatter'=>'')
-                               );      
+                               );
 
 
                        //FIXME
@@ -1334,7 +1322,7 @@
                        }
 
                        //_debug_array($location_list);
-       
+
                        $entry = $content = array();
                        $j = 0;
                        //cramirez: add this code because  "mktime" functions 
fire an error
@@ -1349,16 +1337,15 @@
                                $details = $this->details ? false : true;
 
                                $start_date = 
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,1,1,$this->year),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-                               $end_date       = 
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,12,31,$this->year),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
 
+                               $end_date       = 
$GLOBALS['phpgw']->common->show_date(mktime(0,0,0,12,31,$this->year),$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
 
-                               $sum_obligation = $sum_hits = $sum_budget_cost 
= $sum_actual_cost = 0;  
+                               $sum_obligation = $sum_hits = $sum_budget_cost 
= $sum_actual_cost = 0;
                                foreach($location_list as $entry)
                                {
-                                       //_debug_array($entry);
                                        $content[] = array
                                                (
                                                        'grouping'              
        => $entry['grouping'],
-                                                       'b_account'             
        => $entry['b_account'], 
+                                                       'b_account'             
        => $entry['b_account'],
                                                        'district_id'           
=> $entry['district_id'],
                                                        'ecodimb'               
        => $entry['ecodimb'],
                                                        'hits_ex'               
        => $entry['hits'],
@@ -1373,15 +1360,9 @@
                                                        'link_actual_cost'      
=> $GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiinvoice.consume', 'district_id'=> $entry['district_id'], 
'b_account_class'=> $entry['grouping'], 'b_account' =>$entry['b_account'],  
'start_date'=> $start_date, 'end_date'=> $end_date, 'ecodimb' => 
$entry['ecodimb'], 'submit_search'=>true)),
                                                        'diff_ex'               
        => $entry['budget_cost'] - $entry['actual_cost'] - $entry['obligation'],
                                                        'diff'                  
        => number_format($entry['budget_cost'] - $entry['actual_cost'] - 
$entry['obligation'], 0, ',', ' ')
-                                               );      
-
-                                       //                                      
$sum_obligation += $entry['obligation'];
-                                       //                                      
$sum_hits += $entry['hits'];
-                                       //                                      
$sum_budget_cost += $entry['budget_cost'];
-                                       //                                      
$sum_actual_cost += $entry['actual_cost'];                                      
+                                               );
                                }
 
-                               //                              $sum_diff = 
$sum_budget_cost - $sum_actual_cost - $sum_obligation;
                        }
 
                        $j=0;
@@ -2017,7 +1998,7 @@
                                                lang('grouping'),
                                                lang('district_id'),
                                                lang('dimb'),
-                                               lang('category'), 
+                                               lang('category'),
                                                lang('budget')
                                        );
                                        break;
@@ -2032,7 +2013,7 @@
                                                'grouping',
                                                'district_id',
                                                'ecodimb',
-                                               'category', 
+                                               'category',
                                                'budget_cost'
                                                );
                                        $descr = array
@@ -2044,20 +2025,20 @@
                                                lang('grouping'),
                                                lang('district_id'),
                                                lang('dimb'),
-                                               lang('category'), 
+                                               lang('category'),
                                                lang('budget')
                                        );
                                        break;
                                case 'obligations':
                                        $gross_list= 
$this->bo->read_obligations();
-                                       $sum_obligation = $sum_hits = 
$sum_budget_cost = $sum_actual_cost = 0;  
+                                       $sum_obligation = $sum_hits = 
$sum_budget_cost = $sum_actual_cost = 0;
                                        $list = array();
                                        foreach($gross_list as $entry)
                                        {
                                                $list[] = array
                                                (
                                                        'grouping'              
        => $entry['grouping'],
-                                                       'b_account'             
        => $entry['b_account'], 
+                                                       'b_account'             
        => $entry['b_account'],
                                                        'district_id'           
=> $entry['district_id'],
                                                        'ecodimb'               
        => $entry['ecodimb'],
                                                        'hits'                  
        => $entry['hits'],
@@ -2065,7 +2046,7 @@
                                                        'obligation'            
=> $entry['obligation'],
                                                        'actual_cost'           
=> $entry['actual_cost'],
                                                        'diff'                  
        => ($entry['budget_cost'] - $entry['actual_cost'] - 
$entry['obligation']),
-                                               );      
+                                               );
                                        }
                                        $names = array
                                        (

Modified: 
branches/Version-1_0-branch/property/inc/cron/default/Import_fra_agresso_X205.php
===================================================================
--- 
branches/Version-1_0-branch/property/inc/cron/default/Import_fra_agresso_X205.php
   2013-12-19 18:47:00 UTC (rev 11546)
+++ 
branches/Version-1_0-branch/property/inc/cron/default/Import_fra_agresso_X205.php
   2013-12-19 18:50:32 UTC (rev 11547)
@@ -233,13 +233,13 @@
                        if ( (int) 
$GLOBALS['phpgw_info']['server']['invoice_mail_reminder_time'] < (time() - 
(3600 * 24)) )
                        {
                                $toarray = array();
-                               $sql = 'SELECT DISTINCT oppsynsmannid as 
responsible FROM fm_ecobilag WHERE oppsynsigndato IS NULL AND oppsynsmannid IS 
NOT NULL';
+                               $sql = 'SELECT DISTINCT oppsynsmannid as 
responsible FROM fm_ecobilag WHERE oppsynsigndato IS NULL AND oppsynsmannid IS 
NOT NULL AND saksigndato IS NULL';
                                $this->db->query($sql,__LINE__,__FILE__);
                                while($this->db->next_record())
                                {
                                        $toarray[$this->db->f('responsible')] = 
true;
                                }
-                               $sql = 'SELECT DISTINCT saksbehandlerid as 
responsible FROM fm_ecobilag WHERE saksigndato IS NULL AND saksbehandlerid IS 
NOT NULL';
+                               $sql = 'SELECT DISTINCT saksbehandlerid as 
responsible FROM fm_ecobilag WHERE saksigndato IS NULL AND saksbehandlerid IS 
NOT NULL AND oppsynsigndato IS NULL';
                                $this->db->query($sql,__LINE__,__FILE__);
                                while($this->db->next_record())
                                {
@@ -604,25 +604,33 @@
                                        }
                                }
 
-                               $duplicate = false;
-                               $sql = "SELECT bilagsnr, external_ref FROM 
fm_ecobilag WHERE external_ref = '{$_data['SCANNINGNO']}'";
+                               $update_voucher = false;
+                               $sql = "SELECT bilagsnr, bilagsnr_ut FROM 
fm_ecobilag WHERE external_ref = '{$_data['SCANNINGNO']}'";
                                $this->db->query($sql,__LINE__,__FILE__);
                                if($this->db->next_record())
                                {
-                                       $duplicate = true;
+                                       $update_voucher = true;
+                                       $_bilagsnr_ut = 
$this->db->f('bilagsnr_ut');
                                        $bilagsnr = $this->db->f('bilagsnr');
-                                       $this->receipt['message'][] = 
array('msg' => "Ikke importert duplikat til arbeidsregister: 
{$_data['SCANNINGNO']}");
+
+                                       $buffer[$i]['bilagsnr']                 
= $bilagsnr;
+                                       $buffer[$i]['bilagsnr_ut']              
= $_bilagsnr_ut;
+
+                                       $this->receipt['message'][] = 
array('msg' => "Oppdatert med nye data i arbeidsregister: 
{$_data['SCANNINGNO']}");
                                }
 
                                $sql = "SELECT bilagsnr, bilagsnr_ut FROM 
fm_ecobilagoverf WHERE external_ref = '{$_data['SCANNINGNO']}'";
                                $this->db->query($sql,__LINE__,__FILE__);
                                if($this->db->next_record())
                                {
-                                       $duplicate = true;
+                                       $update_voucher = true;
                                        $_bilagsnr_ut = 
$this->db->f('bilagsnr_ut');
                                        $bilagsnr = $this->db->f('bilagsnr');
                                        $__bilagsnr = $_bilagsnr_ut ? 
$_bilagsnr_ut : $bilagsnr;
 
+                                       $buffer[$i]['bilagsnr']                 
= $bilagsnr;
+                                       $buffer[$i]['bilagsnr_ut']              
= $_bilagsnr_ut;
+
                                        if($_bilagsnr_ut)
                                        {
                                                $receipt = 
$this->export->RullTilbake(false,false,$_bilagsnr_ut);
@@ -726,6 +734,11 @@
 //_debug_array($order_info['toarray']);
                        if(!$this->skip_import)
                        {
+                               if($update_voucher && $bilagsnr)
+                               {
+                                       $this->db->query("DELETE FROM 
fm_ecobilag WHERE external_ref = '{$_data['SCANNINGNO']}'",__LINE__,__FILE__);
+                               }
+
                                if(!$bilagsnr)
                                {
                                        $bilagsnr = 
$this->invoice->next_bilagsnr();
@@ -763,38 +776,30 @@
                                        }
                                }
 
-                               if(!$duplicate)
+                               $GLOBALS['phpgw']->db->Exception_On_Error = 
true;
+
+                               try
                                {
-                                       
$GLOBALS['phpgw']->db->Exception_On_Error = true;
-                                       try
+                                       $bilagsnr = 
$this->import_end_file($buffer);
+                               }
+                               catch (Exception $e)
+                               {
+                                       if($e)
                                        {
-                                               $bilagsnr = 
$this->import_end_file($buffer);
+                                               
$GLOBALS['phpgw']->log->error(array(
+                                                       'text'  => 
'import_fra_agresso_X205::import() : error when trying to execute 
import_end_file(): %1',
+                                                       'p1'    => 
$e->getMessage(),
+                                                       'p2'    => '',
+                                                       'line'  => __LINE__,
+                                                       'file'  => __FILE__
+                                               ));
+                                               $this->receipt['error'][] = 
array('msg'=> $e->getMessage());
                                        }
-                                       catch (Exception $e)
-                                       {
-                                               if($e)
-                                               {
-                                                       
$GLOBALS['phpgw']->log->error(array(
-                                                               'text'  => 
'import_fra_agresso_X205::import() : error when trying to execute 
import_end_file(): %1',
-                                                               'p1'    => 
$e->getMessage(),
-                                                               'p2'    => '',
-                                                               'line'  => 
__LINE__,
-                                                               'file'  => 
__FILE__
-                                                       ));
+                                       return false;
+                               }
 
-                                                       
$this->receipt['error'][] = array('msg'=> $e->getMessage());
-                                               }
-                                               return false;
-                                       }
-
-                                       
$GLOBALS['phpgw']->db->Exception_On_Error = false;
-                                       return $bilagsnr;
-                               }
-                               else
-                               {
-                                       $duplicate  = false;
-                                       return $bilagsnr;
-                               }
+                               $GLOBALS['phpgw']->db->Exception_On_Error = 
false;
+                               return $bilagsnr;
                        }
                        $this->skip_import = false;
                        return false;

Copied: 
branches/Version-1_0-branch/property/inc/export/default/Agresso_Bergen_Kostfordeling
 (from rev 11546, 
trunk/property/inc/export/default/Agresso_Bergen_Kostfordeling)
===================================================================
--- 
branches/Version-1_0-branch/property/inc/export/default/Agresso_Bergen_Kostfordeling
                                (rev 0)
+++ 
branches/Version-1_0-branch/property/inc/export/default/Agresso_Bergen_Kostfordeling
        2013-12-19 18:50:32 UTC (rev 11547)
@@ -0,0 +1,1158 @@
+<?php
+       /**
+       * phpGroupWare - property: a Facilities Management System.
+       *
+       * @author Sigurd Nes <address@hidden>
+       * @copyright Copyright (C) 
2003,2004,2005,2006,2007,2008,2009,2010,2011,2012 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 export
+       * @version $Id: Agresso 11369 2013-10-11 15:29:13Z sigurdne $
+       */
+
+       /**
+        * Description
+        * @package property
+        */
+
+       class export_conv
+       {
+               //var $fil_katalog='c:/temp'; //On windows use 
"//computername/share/filename" or "\\\\computername\share\filename" to check 
files on network shares.
+
+               protected $old_files_deleted;
+               protected $debug;
+               protected $orders_affected = array();
+               protected $db;
+               protected $db2;
+               protected $soXport;
+               protected $config;
+
+               function __construct()
+               {
+                       $this->db               = & $GLOBALS['phpgw']->db;
+                       $this->join     = & $this->db->join;
+                       $this->db2              = clone($this->db);
+                       $this->soXport  = CreateObject('property.soXport');
+                       $this->config   = 
CreateObject('admin.soconfig',$GLOBALS['phpgw']->locations->get_id('property', 
'.invoice'));
+               }
+
+               function 
select_periods_with_invoice_to_transfer($pre_transfer='')
+               {
+                       if($pre_transfer)
+                       {
+                               $sql= "SELECT DISTINCT periode from fm_ecobilag 
WHERE utbetalingsigndato IS NULL";
+                       }
+                       else
+                       {
+                               $sql= "SELECT DISTINCT periode from fm_ecobilag 
WHERE budsjettsigndato is not null and (saksigndato is not null or 
oppsynsigndato is not null) and utbetalingsigndato is not null";
+                       }
+
+                       $periode = array();
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $periode[]      = $this->db->f('periode');
+                       }
+
+                       return $periode;
+               }
+
+               function log_end($batchid)
+               {
+                       $tid=date($this->soXport->datetimeformat);
+                       $sql= "insert into fm_ecologg (batchid,melding,tid) 
values ('$batchid','End transfer','$tid')";
+                       $this->db->query($sql,__LINE__,__FILE__);
+               }
+
+               function log_error($batchid,$error_desr)
+               {
+                       $tid=date($this->soXport->datetimeformat);
+                       $sql= "insert into fm_ecologg 
(batchid,ecobilagid,status,melding,tid) values 
('$batchid',NULL,0,'$error_desr','$tid')";
+                       $this->db->query($sql,__LINE__,__FILE__);
+               }
+
+               function increment_batchid()
+               {
+
+                       $this->db->query("update fm_idgenerator  set value = 
value + 1 where name = 'Ecobatchid'",__LINE__,__FILE__);
+                       $this->db->query("select value from fm_idgenerator  
where name = 'Ecobatchid'",__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $bilagsnr = $this->db->f('value');
+                       return $bilagsnr;
+
+               }
+
+               function next_batchid()
+               {
+
+                       $this->db->query("select value from fm_idgenerator  
where name = 'Ecobatchid'",__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $batchid = $this->db->f('value')+1;
+
+                       return $batchid;
+               }
+
+               //Lagre start melding
+               function log_start($batchid)
+               {
+                       $tid=date($this->soXport->datetimeformat);
+                       $sql= "insert into fm_ecologg (batchid,melding,tid) 
values ('$batchid','Start transfer','$tid')";
+                       $this->db->query($sql,__LINE__,__FILE__);
+               }
+
+               function get_vendor_info($vendor_id='')
+               {
+                       $sql = "select org_nr,konto_nr from fm_vendor where 
id='$vendor_id'";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->next_record();
+
+                       $vendor_info= array(
+                               'org_nr' => $this->db->f('org_nr'),
+                               'konto_nr' => $this->db->f('konto_nr')
+                               );
+
+                       return $vendor_info;
+               }
+
+               function get_order_title($order_id='')
+               {
+                       $sql = "select type from fm_orders where 
id='$order_id'";
+                       $this->db->query($sql,__LINE__,__FILE__);
+                       $this->db->next_record();
+
+                       switch($this->db->f('type'))
+                       {
+                               case 'workorder':
+                                       $sql2 = "select title from fm_workorder 
where id='$order_id'";
+                                       
$this->db->query($sql2,__LINE__,__FILE__);
+                                       $this->db->next_record();
+                                       $order_title = $this->db->f('title');
+                                       break;
+                               case 's_agreement':
+                                       $sql2 = "select descr as title from 
fm_s_agreement where id='$order_id'";
+                                       
$this->db->query($sql2,__LINE__,__FILE__);
+                                       $this->db->next_record();
+                                       $order_title = $this->db->f('title');
+                                       break;
+                       }
+
+                       return $order_title;
+               }
+
+
+               function select_invoice_rollback($day,$month,$year,$Filnavn)
+               {
+
+                       switch($GLOBALS['phpgw_info']['server']['db_type'])
+                       {
+                               case 'mssql':
+                                       $datepart_year          = 
"datepart(year,overftid)";
+                                       $datepart_month         = 
"datepart(month,overftid)";
+                                       $datepart_day           = 
"datepart(day,overftid)";
+                                       break;
+                               case 'mysql':
+                                       $datepart_year          = 
"YEAR(overftid)";
+                                       $datepart_month         = 
"MONTH(overftid)";
+                                       $datepart_day           = 
"DAYOFMONTH(overftid)";
+                                       break;
+                               case 'pgsql':
+                               case 'postgres':
+                                       $datepart_year          = 
"date_part('year',overftid)";
+                                       $datepart_month         = 
"date_part('month',overftid)";
+                                       $datepart_day           = 
"date_part('day',overftid)";
+                                       break;
+                       }
+
+
+               $sql = "SELECT * FROM fm_ecobilagoverf WHERE filnavn='$Filnavn' 
and $datepart_year=$year and $datepart_month=$month and $datepart_day= $day";
+                       $this->db->query($sql,__LINE__,__FILE__);
+
+                       $i = 0;
+                       while ($this->db->next_record())
+                       {
+                               $invoice_roleback[$i]['id']     = 
$this->db->f('id');
+                               $invoice_roleback[$i]['bilagsnr']       = 
$this->db->f('bilagsnr');
+                               $invoice_roleback[$i]['kidnr']  = 
$this->db->f('kidnr');
+                               $invoice_roleback[$i]['typeid'] = 
$this->db->f('typeid');
+                               $invoice_roleback[$i]['kildeid']        = 
$this->db->f('kildeid');
+                               $invoice_roleback[$i]['pmwrkord_code']  = 
$this->db->f('pmwrkord_code');
+                               $invoice_roleback[$i]['belop']  = 
$this->db->f('belop');
+                               $invoice_roleback[$i]['fakturadato']    = 
$this->db->f('fakturadato');
+                               $invoice_roleback[$i]['periode']        = 
$this->db->f('periode');
+                               $invoice_roleback[$i]['forfallsdato']   = 
$this->db->f('forfallsdato');
+                               $invoice_roleback[$i]['fakturanr']      = 
$this->db->f('fakturanr');
+                               $invoice_roleback[$i]['spbudact_code']  = 
$this->db->f('spbudact_code');
+                               $invoice_roleback[$i]['regtid'] = 
$this->db->f('regtid');
+                               $invoice_roleback[$i]['artid']  = 
$this->db->f('artid');
+                               $invoice_roleback[$i]['godkjentbelop']  = 
$this->db->f('godkjentbelop');
+                               $invoice_roleback[$i]['spvend_code']    = 
$this->db->f('spvend_code');
+                               $invoice_roleback[$i]['dima']   = 
$this->db->f('dima');
+                               $invoice_roleback[$i]['loc1']   = 
$this->db->f('loc1');
+                               $invoice_roleback[$i]['dimb']   = 
$this->db->f('dimb');
+                               $invoice_roleback[$i]['mvakode']        = 
$this->db->f('mvakode');
+                               $invoice_roleback[$i]['dimd']   = 
$this->db->f('dimd');
+                               $invoice_roleback[$i]['project_id']     = 
$this->db->f('project_id');
+                               $invoice_roleback[$i]['kostra_id']      = 
$this->db->f('kostra_id');
+                               $invoice_roleback[$i]['item_type']      = 
$this->db->f('item_type');
+                               $invoice_roleback[$i]['item_id']        = 
$this->db->f('item_id');
+
+                               if($this->db->f('oppsynsmannid'))
+                               {
+                                       $invoice_roleback[$i]['oppsynsmannid']  
= $this->db->f('oppsynsmannid');
+                               }
+                               if($this->db->f('saksbehandlerid'))
+                               {
+                                       
$invoice_roleback[$i]['saksbehandlerid']        = 
$this->db->f('saksbehandlerid');
+                               }
+
+                               $invoice_roleback[$i]['budsjettansvarligid']    
= $this->db->f('budsjettansvarligid');
+
+                               if($this->db->f('oppsynsigndato'))
+                               {
+                                       $invoice_roleback[$i]['oppsynsigndato'] 
= $this->db->f('oppsynsigndato');
+                               }
+                               if($this->db->f('saksigndato'))
+                               {
+                                       $invoice_roleback[$i]['saksigndato']    
= $this->db->f('saksigndato');
+                               }
+
+                               $invoice_roleback[$i]['budsjettsigndato']       
= $this->db->f('budsjettsigndato');
+                               $invoice_roleback[$i]['merknad']        = 
$this->db->f('merknad');
+                               $invoice_roleback[$i]['splitt'] = 
$this->db->f('splitt');
+                               $invoice_roleback[$i]['ordrebelop']     = 
$this->db->f('ordrebelop');
+                               $invoice_roleback[$i]['utbetalingid']   = 
$this->db->f('utbetalingid');
+                               $invoice_roleback[$i]['utbetalingsigndato']     
= $this->db->f('utbetalingsigndato');
+                               $i++;
+                       }
+                       return $invoice_roleback;
+           }
+
+
+               //rollback function
+               function bilag_update_overf($BilagOverf)
+               {
+                       $values= array(
+                               $BilagOverf['project_id'],
+                               $BilagOverf['kostra_id'],
+                               $BilagOverf['pmwrkord_code'],
+                               $BilagOverf['bilagsnr'],
+                               $BilagOverf['splitt'],
+                               $BilagOverf['kildeid'],
+                               $BilagOverf['kidnr'],
+                               $BilagOverf[typeid],
+                               $BilagOverf['fakturadato'],
+                               $BilagOverf['forfallsdato'],
+                               $BilagOverf['regtid'],
+                               $BilagOverf['artid'],
+                               $BilagOverf['spvend_code'],
+                               $BilagOverf['dimb'],
+                               $BilagOverf['oppsynsmannid'],
+                               $BilagOverf['saksbehandlerid'],
+                               $BilagOverf['budsjettansvarligid'],
+                               $BilagOverf['fakturanr'],
+                               $BilagOverf['spbudact_code'],
+                               $BilagOverf['dima'],
+                               $BilagOverf['loc1'],
+                               $BilagOverf['dimd'],
+                               $BilagOverf['mvakode'],
+                               $BilagOverf['periode'],
+                               
$this->db->db_addslashes($BilagOverf['merknad']),
+                               $BilagOverf['utbetalingid'],
+                               $BilagOverf['oppsynsigndato'],
+                               $BilagOverf['saksigndato'],
+                               $BilagOverf['budsjettsigndato'],
+                               $BilagOverf['utbetalingsigndato'],
+                               $BilagOverf['item_type'],
+                               $BilagOverf['item_id'],
+                               );
+
+                       $values = $this->db->validate_insert($values);
+
+                       $sql= "INSERT INTO fm_ecobilag 
(project_id,kostra_id,pmwrkord_code,bilagsnr,splitt,kildeid,kidnr,typeid,"
+                       . " 
fakturadato,forfallsdato,regtid,artid,spvend_code,dimb,oppsynsmannid,"
+                       . " 
saksbehandlerid,budsjettansvarligid,fakturanr,spbudact_code,dima,loc1,dimd,mvakode,"
+                       . " 
periode,merknad,utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,item_type,item_id,belop,godkjentbelop)"
+                       . " values ($values,"
+                       . $this->db->money_format($BilagOverf['belop']) . ","
+                       . $this->db->money_format($BilagOverf['godkjentbelop']) 
. ")";
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+               }
+
+               function 
overfor($download,$pre_transfer='',$force_period_year='')
+               {
+
+//                     $download = 'on';
+//                     $download = False;
+                       $pre_transfer=True;
+//                     $this->debug=True;
+
+                       //Generer batch ID
+                       $batchid = $this->soXport->next_batchid();
+                       if ($download=='on')
+                       {
+                               $this->increment_batchid();
+                               //Lagre melding
+                               $this->log_start($batchid);
+                       }
+
+                       //Velg ut alle perioder som har bilag som skal overføres
+                       if ($pre_transfer)
+                       {
+                               $periodes = 
$this->select_periods_with_invoice_to_transfer($pre_transfer);
+
+                               foreach ($periodes as $periode)
+                               {
+                                       
$this->OverforPeriode($batchid,$periode,$download,$pre_transfer);
+                               }
+                       }
+
+                       $pre_transfer=False;
+
+                       $periodes = 
$this->select_periods_with_invoice_to_transfer($pre_transfer);
+
+                       foreach ($periodes as $periode)
+                       {
+                               
$this->OverforPeriode($batchid,$periode,$download,$pre_transfer,$force_period_year);
+                       }
+
+                       //Lagre melding
+                       if ($download=='on' || $pre_transfer)
+                       {
+                               $this->log_end($batchid); //Lagre melding
+                       }
+
+                       if (!$download=='on')
+                       {
+                               $GLOBALS['phpgw_info']['flags']['noheader'] = 
true;
+                               $GLOBALS['phpgw_info']['flags']['nofooter'] = 
true;
+                               $GLOBALS['phpgw_info']['flags']['xslt_app'] = 
false;
+                               $GLOBALS['phpgw_info']['flags']['noframework'] 
= true;
+                               echo '&nbsp<a 
href="'.$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiXport.export')) . '">' . lang('Back') . '</a></br>';
+                               $GLOBALS['phpgw']->common->phpgw_exit();
+                       }
+
+                       return $receipt;
+               }
+
+               function errorhandler($batchid,$error_desr)
+               {
+                       $this->db->transaction_abort();
+
+                       $meld = $error_desr;
+
+                       phpgwapi_cache::message_set($error_desr, 'error'); 
+                       //Vis feilmelding
+//                     echo $meld;
+
+                       //Lagre feilmelding
+                       $this->log_error($batchid,$error_desr);
+               }
+
+               function RullTilbake($Filnavn,$Dato)
+               {
+                       $dateformat = 
strtolower($GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+                       $dateformat = str_replace(".","",$dateformat);
+                       $dateformat = str_replace("-","",$dateformat);
+                       $dateformat = str_replace("/","",$dateformat);
+                       $y=strpos($dateformat,'y');
+                       $d=strpos($dateformat,'d');
+                       $m=strpos($dateformat,'m');
+
+                       $dateparts = explode('/', $Dato);
+                       $day = $dateparts[$d];
+                       $month = $dateparts[$m];
+                       $year = $dateparts[$y];
+        /*             $date1 = mktime (2,0,0,$month,$day,$year);
+                       if ($date1)
+                       {
+                               $Dato=$date1;
+                       }
+
+                       $Dato= date("M d Y",$Dato);
+       */
+
+                       
$BilagOverf=$this->select_invoice_rollback($day,$month,$year,$Filnavn);
+                       $this->db->transaction_begin();
+
+                       for ($i=0;$i<count($BilagOverf);$i++)
+                       {
+                               $this->bilag_update_overf($BilagOverf[$i]);
+
+
+                               if($BilagOverf[$i]['pmwrkord_code'])
+                               {
+                                       
$orders_affected[$BilagOverf[$i]['pmwrkord_code']] = true;
+
+                                       $Belop = sprintf("%01.2f", 
$BilagOverf[$i]['ordrebelop'])*100;
+
+                                       if ($BilagOverf[$i]['dimd'] % 2 == 0)
+                                       {
+                                               
$actual_cost_field='act_mtrl_cost';
+                                       }
+                                       else
+                                       {
+                                               
$actual_cost_field='act_vendor_cost';
+                                       }
+
+                                       $operator='-';
+
+                                       
$this->soXport->correct_actual_cost($BilagOverf[$i]['pmwrkord_code'],$Belop,$actual_cost_field,$operator);
+                               }
+
+                               //Slett fra avviks tabell
+                       //      
$this->soXport->delete_avvik($BilagOverf[$i]['bilagsnr']);
+
+                               //Slett fra arkiv
+                               
$this->soXport->delete_invoice($BilagOverf[$i]['bilagsnr']);
+
+                               $antall = $antall + 1;
+                       }
+
+                       if($antall > 0)
+                       {
+                               $fil_katalog = 
$this->config->config_data['export']['path'];
+
+                               if(unlink ($fil_katalog. '/' . $Filnavn))
+                               {
+                                       $this->db->transaction_commit();
+                                       $receipt['message'][]= array('msg' => 
$antall . ' ' . lang('bilag/underbilag rullet tilbake'));
+                                       $receipt['message'][]= array('msg' => 
lang('File %1 is deleted',$Filnavn));
+                               }
+                               else
+                               {
+                                       $this->db->transaction_abort();
+                                       $receipt['message'][]= array('msg' => 
'Noe gikk galt!');
+                               }
+                       }
+                       else
+                       {
+                               $receipt['error'][]= array('msg' => lang('Sorry 
- None hits'));
+                       }
+                       return $receipt;
+               }
+
+
+               function LagFilnavn ($batchid,$pre_transfer='')
+               {
+                       if($pre_transfer)
+                       {
+                               $fil_katalog = 
$this->config->config_data['export']['pre_path'];
+
+                               // Slett gamle filer
+
+                               if(!$this->old_files_deleted)
+                               {
+                                       for ($i=0;$i<13;$i++)
+                                       {
+                                               @unlink($fil_katalog . '/FDA_' 
. $i. '.TXT');
+                                       }
+                                
+                                       $this->old_files_deleted= True;
+                               }
+
+
+                               $i = 1;
+                               do
+                               {
+                                       $Filnavn = $fil_katalog . '/FDA_' . $i. 
'.TXT';
+
+                                       //Sjekk om filen eksisterer
+                                       If (!file_exists($Filnavn))
+                                       {
+                                               return $Filnavn;
+                                       }
+
+                                       $i++;
+                               }
+                               while  ($i < 13);
+
+                       }
+                       else
+                       {
+                               $fil_katalog = 
$this->config->config_data['export']['path'];
+                               $continue = True;
+                               $i = 1;
+                               do
+                               {
+                                       $Filnavn = $fil_katalog . '/FDB' . 
date("dmy") . '_' . sprintf("%02s",$i) . '.TXT';
+
+                                       //Sjekk om filen eksisterer
+                                       If (!file_exists($Filnavn))
+                                       {
+                                               return $Filnavn;
+                                       }
+
+                                       $i++;
+                               }
+                               while  ($continue);
+                       }
+
+
+                       //Ingen løpenr er ledige, gi feilmelding
+                       return False;
+               }
+
+
+               private function 
get_vouchers_to_transfer($periode,$pre_transfer=false)
+               {
+                       if($pre_transfer)
+                       {
+                               $sql= "SELECT sum(belop) as belop, fakturanr, 
bilagsnr FROM fm_ecobilag WHERE periode='{$periode}' AND utbetalingsigndato IS 
NULL GROUP BY bilagsnr, fakturanr";
+                       }
+                       else
+                       {
+                               $sql="SELECT sum(belop) as belop, fakturanr, 
bilagsnr FROM fm_ecobilag WHERE periode='{$periode}' AND budsjettsigndato IS 
NOT NULL AND ( saksigndato IS NOT NULL OR oppsynsigndato IS NOT NULL ) AND 
utbetalingsigndato IS NOT NULL group by bilagsnr, fakturanr";
+                       }
+
+                       $this->db->query($sql,__LINE__,__FILE__);
+
+                       $values = array();
+                       while ($this->db->next_record())
+                       {
+                               $values[] = array
+                               (
+                                       'belop'         => 
$this->db->f('belop'),
+                                       'bilagsnr'      => 
$this->db->f('bilagsnr'),
+                                       'fakturanr' => 
$this->db->f('fakturanr'),
+                               );
+                       }
+
+
+                       foreach ($values as &$entry)
+                       {
+                               $sql= "SELECT fm_ecobilag.*,fm_ecouser.initials 
as saksbehandler FROM fm_ecobilag {$this->join} fm_ecouser ON 
fm_ecobilag.budsjettansvarligid=fm_ecouser.lid"
+                               . " WHERE bilagsnr='{$entry['bilagsnr']}' AND 
fakturanr = '{$entry['fakturanr']}'";
+
+                               $this->db->query($sql,__LINE__,__FILE__);
+                               $this->db->next_record();
+
+                               $entry['id']                                    
= $this->db->f('id');
+                               $entry['kidnr']                                 
= $this->db->f('kidnr');
+                               $entry['typeid']                                
= $this->db->f('typeid');
+                               $entry['kildeid']                               
= $this->db->f('kildeid');
+                               $entry['pmwrkord_code']                 = 
$this->db->f('pmwrkord_code');
+                               $entry['fakturadato']                   = 
$this->db->f('fakturadato');
+                               $entry['periode']                               
= $this->db->f('periode');
+                               $entry['forfallsdato']                  = 
$this->db->f('forfallsdato');
+                               $entry['fakturanr']                             
= $this->db->f('fakturanr');
+                               $entry['spbudact_code']                 = 
$this->db->f('spbudact_code');
+                               $entry['regtid']                                
= $this->db->f('regtid');
+                               $entry['artid']                                 
= $this->db->f('artid');
+                               $entry['godkjentbelop']                 = 
$entry['belop'];
+                               $entry['spvend_code']                   = 
$this->db->f('spvend_code');
+                               $entry['dima']                                  
= $this->db->f('dima');
+                               $entry['dimb']                                  
= $this->db->f('dimb');
+                               $entry['mvakode']                               
= $this->db->f('mvakode');
+                               $entry['dimd']                                  
= $this->db->f('dimd');
+                               $entry['dime']                                  
= $this->db->f('dime');
+                               $entry['oppsynsmannid']                 = 
$this->db->f('oppsynsmannid');
+                               $entry['saksbehandlerid']               = 
$this->db->f('saksbehandlerid');
+                               $entry['budsjettansvarligid']   = 
$this->db->f('budsjettansvarligid');
+                               $entry['oppsynsigndato']                = 
$this->db->f('oppsynsigndato');
+                               $entry['saksigndato']                   = 
$this->db->f('saksigndato');
+                               $entry['budsjettsigndato']              = 
$this->db->f('budsjettsigndato');
+                               $entry['merknad']                               
= $this->db->f('merknad');
+                               $entry['line_text']                             
= $this->db->f('line_text');
+                               $entry['splitt']                                
= $this->db->f('splitt');
+                               $entry['utbetalingid']                  = 
$this->db->f('utbetalingid');
+                               $entry['utbetalingsigndato']    = 
$this->db->f('utbetalingsigndato');
+                               $entry['saksbehandler']                 = 
$this->db->f('saksbehandler');
+                               $entry['invoice_line']                          
= $this->get_invoice($entry['bilagsnr'], $entry['fakturanr']);
+
+                       }
+
+                       return $values;
+               }
+
+
+               //Velg ut alle underbilag
+
+               private function get_invoice($bilagsnr, $fakturanr)
+               {
+                       if(!$fakturanr)
+                       {
+                               throw new Exception('Mangler fakturanr');
+                       }
+
+                       $sql= "SELECT fm_ecobilag.* 
,fm_part_of_town.district_id"
+                       . " FROM (fm_location1 {$this->join} fm_part_of_town ON 
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id)"
+                       . " {$this->join} fm_ecobilag ON fm_location1.loc1 = 
fm_ecobilag.loc1"
+                       . " WHERE bilagsnr='$bilagsnr' AND fakturanr = 
'{$fakturanr}'";
+
+                       $this->db2->query($sql,__LINE__,__FILE__);
+
+                       $values = array();
+                       while ($this->db2->next_record())
+                       {
+                               $values[] = array
+                               (
+                                       'id'                                    
=> $this->db2->f('id'),
+                                       'bilagsnr'                              
=> $this->db2->f('bilagsnr'),
+                                       'kidnr'                                 
=> $this->db2->f('kidnr'),
+                                       'typeid'                                
=> $this->db2->f('typeid'),
+                                       'kildeid'                               
=> $this->db2->f('kildeid'),
+                                       'pmwrkord_code'                 => 
$this->db2->f('pmwrkord_code'),
+                                       'belop'                                 
=> $this->db2->f('belop'),
+                                       'fakturadato'                   => 
$this->db2->f('fakturadato'),
+                                       'periode'                               
=> $this->db2->f('periode'),
+                                       'forfallsdato'                  => 
$this->db2->f('forfallsdato'),
+                                       'fakturanr'                             
=> $this->db2->f('fakturanr'),
+                                       'spbudact_code'                 => 
$this->db2->f('spbudact_code'),
+                                       'regtid'                                
=> $this->db2->f('regtid'),
+                                       'artid'                                 
=> $this->db2->f('artid'),
+                                       'godkjentbelop'                 => 
$this->db2->f('godkjentbelop'),
+                                       'spvend_code'                   => 
$this->db2->f('spvend_code'),
+                                       'dima'                                  
=> $this->db2->f('dima'),
+                                       'loc1'                                  
=> $this->db2->f('loc1'),
+                                       'dimb'                                  
=> $this->db2->f('dimb'),
+                                       'mvakode'                               
=> $this->db2->f('mvakode'),
+                                       'dimd'                                  
=> $this->db2->f('dimd'),
+                                       'dime'                                  
=> $this->db2->f('dime'),
+                                       'project_id'                    => 
$this->db2->f('project_id'),
+                                       'kostra_id'                             
=> $this->db2->f('kostra_id'),
+                                       'oppsynsmannid'                 => 
$this->db2->f('oppsynsmannid'),
+                                       'saksbehandlerid'               => 
$this->db2->f('saksbehandlerid'),
+                                       'budsjettansvarligid'   => 
$this->db2->f('budsjettansvarligid'),
+                                       'oppsynsigndato'                => 
$this->db2->f('oppsynsigndato'),
+                                       'saksigndato'                   => 
$this->db2->f('saksigndato'),
+                                       'budsjettsigndato'              => 
$this->db2->f('budsjettsigndato'),
+                                       'merknad'                               
=> $this->db2->f('merknad'),
+                                       'line_text'                             
=> $this->db2->f('line_text'),
+                                       'splitt'                                
=> $this->db2->f('splitt'),
+                                       'utbetalingid'                  => 
$this->db2->f('utbetalingid'),
+                                       'utbetalingsigndato'    => 
$this->db2->f('utbetalingsigndato'),
+                                       'district_id'                   => 
$this->db2->f('district_id'),
+                                       'item_type'                             
=> $this->db2->f('item_type'),
+                                       'item_id'                               
=> $this->db2->f('item_id')
+                               );
+
+                       }
+
+                       return $values;
+               }
+
+
+               function 
OverforPeriode($batchid,$periode,$download,$pre_transfer='',$force_period_year='')
+               {
+                       $BilagId = 'NULL';
+
+                       //Bestem filnavn
+
+
+                       $Filnavn = $this->LagFilnavn($batchid,$pre_transfer);
+                       if (!$Filnavn)
+                       {
+                               $message='LagFilnavn: Alle loepenr for filnavn 
er i bruk';
+                               $this->errorhandler($batchid,$message);
+                               phpgwapi_cache::message_set($message, 'error'); 
+                               return false;
+                       }
+
+                       //Test om filen kan opprettes og skrives til
+                       if (@fopen($Filnavn, "wb"))
+                       {
+                               unlink($Filnavn);
+                       }
+                       else
+                       {
+                               phpgwapi_cache::message_set('kan ikke lagre til 
fil: '. $Filnavn, 'error'); 
+                               return false;
+                       }
+
+                       //Velg ut alle hoved bilag som skal overføres
+
+                       $this->db->transaction_begin();
+
+                       $oRsBilag =  
$this->get_vouchers_to_transfer($periode,$pre_transfer);
+
+                       $buffer = '';
+
+                       foreach($oRsBilag as $invoice)
+                       {
+
+                               $tranfser_bilag[] = $invoice['bilagsnr'];
+
+                               //Bestem belops felt
+                               if ($invoice['splitt']==0)
+                               {
+                                       //Bilaget er ikke splittet
+                                       if ($invoice['godkjentbelop'] <> 
$invoice['belop'])
+                                       {
+                                               $BelopFelt = 'godkjentbelop';
+                                               //Logg til avviks tabell
+                                               if ($download=='on' && 
!$pre_transfer)
+                                               {
+//                                                     
$this->soXport->log_to_deviation_table($invoice);
+                                               }
+                                       }
+                                       else
+                                       {
+                                               $BelopFelt = 'belop';
+                                       }
+                               }
+
+                               //Bilaget er splittet
+                               if ($invoice['godkjentbelop'] == 
$invoice['belop'])
+                               {
+                                       $BelopFelt = 'godkjentbelop';
+                               }
+                               else
+                               {
+                                        //Ikke lovlig
+                                       $message = lang('Avvik mellom 
fakturabelop og godkjent belop pa splittet faktura!');
+                                       $this->errorhandler($batchid,$message);
+                                       return $message;
+                               }
+
+                               $Belop_motpost =$invoice[$BelopFelt] *100; 
+
+                               //Skriv hovedbilag
+
+                               $Buntnr         = 
sprintf("%-12s",basename($Filnavn,".TXT"));// verdi: MMDDFL, type: c12, plass: 
1 - 12
+                               $Forsystem      = 'BI';// verdi: BI, type: c2, 
plass: 13 - 14
+
+                               $Transtype      = 'GL';// verdi: GL, type: c2, 
plass: 17 - 18
+                               $Firmakode      = sprintf("%-2s",'BB');// 
verdi: Firmakode, type: c2, plass: 19 - 20
+
+                               $Valuteringsdato= 
date(Ymd,strtotime($invoice['fakturadato']));// verdi: Dato, type: date, plass: 
251 - 258
+                               $Bilagsdato     = 
date(Ymd,strtotime($invoice['fakturadato'])) ;// verdi: Dato, type: date, 
plass: 259 - 266
+                               $Bilagsnr       = 
sprintf("%-9s",substr($invoice['bilagsnr'],-8));// verdi: Bilagsnummer, type: 
i4, plass: 267 - 275
+               //              $_periode       = 
sprintf("%06s",date(Y,strtotime($invoice['fakturadato'])) . 
sprintf("%02d",$periode));// verdi: Periode, type: i4, plass: 276 - 281
+                               $ESL            = sprintf("%1s",'');// verdi: 
Blank, type: i+C481, plass: 282 - 282
+
+                               if($pre_transfer)
+                               {
+                                       if(abs(date('m',time()) - $periode) >1)
+                                       {
+                                               $temp_period = date('m',time()) 
-1;
+
+                                               if($temp_period == 0)
+                                               {
+                                                       $temp_period =1;
+                                               }
+
+                                               $temp_year = date('Y',time());
+                                       }
+                                       else
+                                       {
+                                               $temp_period = $periode;
+                                               $temp_year = 
date('Y',strtotime($invoice['fakturadato']));
+                                       }
+
+                                       $_periode       = 
sprintf("%06s",$temp_year . sprintf("%02d",$temp_period));// verdi: Periode, 
type: i4, plass: 276 - 281
+                                       $Bilagsart      = 
sprintf("%2s",'FF');// verdi: , type: c2, plass: 15 - 16
+                                       $Forfall        = '20991231';// verdi: 
Forfallsdato , type: date, plass: 298 - 305
+                               }
+                               else
+                               {
+                                       $_periode       = $periode;
+
+                                       $Bilagsart      = 
sprintf("%2s",'HK');// verdi: , type: c2, plass: 15 - 16
+                                       $Forfall        = 
date(Ymd,strtotime($invoice['forfallsdato']));// verdi: Forfallsdato , type: 
date, plass: 298 - 305
+                               }
+
+                               $Rab_forf       = sprintf("%-8s",'');// verdi: 
Blank, type: date, plass: 306 - 313
+                               $Rabatt         = sprintf("%020s",'');// verdi: 
Blank, type: money, plass: 314 - 333
+                               $Avt_Kon        = sprintf("%-8s",'');// verdi: 
Blank, type: c8, plass: 334 - 341
+
+                               $Kid            = 
sprintf("%-27s",$invoice['kidnr']);// verdi: Kid, type: c27, plass: 351 - 377
+                               $Bet_overforing = sprintf("%-2s",'');// verdi: 
Blank, type: c2, plass: 378 - 379
+                               $Status         = 'N';// verdi: N, type: c1, 
plass: 380 - 380
+                               $Resk_type      = 'P';// verdi: Blank, type: 
c1, plass: 381 - 381
+                               $Resk_nr        = 
sprintf("%-9s",$invoice['spvend_code']);// verdi: Blank., type: i4, plass: 382 
- 390
+                               $Forskudd       = '0';// verdi: 0, type: i1, 
plass: 391 - 391
+                               $Fakturaref     = '000000000';// verdi: 0, 
type: i4, plass: 392 - 400
+                               $Fakturaref     = '000000000';// verdi: 0, 
type: i4, plass: 401 - 409
+                               $Inkassokode    = sprintf("%-6s",'');// verdi: 
Blank, type: c6, plass: 410 - 415
+                               $Bet_mottager   = sprintf("%-8s",'');// verdi: 
Blank, type: c8, plass: 416 - 423
+                               $Att_ansvarlig  = 
sprintf("%-6s",utf8_decode($invoice['saksbehandler']));// verdi: Blank, type: 
c6, plass: 424 - 429
+
+                               $vendor_info = 
$this->get_vendor_info($invoice['spvend_code']);
+
+                               if(!$vendor_info['org_nr'])
+                               {
+                                       $message = 'mangler org_nr for 
reskontronr: ' . $invoice['spvend_code'];
+                                       $this->errorhandler($batchid,$message);
+                                       return $message;
+                               }
+
+                               if(!$vendor_info['konto_nr'])
+                               {
+                                       $message = 'mangler konto for 
reskontronr: ' . $invoice['spvend_code'];
+                                       $this->errorhandler($batchid,$message);
+                                       return $message;
+                               }
+
+                               $Resk_navn      = 
sprintf("%-50s",$vendor_info['org_nr']);// verdi: Fødselsnr, type: c50, plass: 
430 - 479
+                               $Postadresse    = sprintf("%-160s",'');// 
verdi: Blank, type: c160, plass: 480 - 639
+                               $Stat_Provins   = sprintf("%-50s",'');// verdi: 
Blank, type: c50, plass: 640 - 689
+                               $Sted           = sprintf("%-50s",'');// verdi: 
Blank, type: c50, plass: 690 - 739
+                               $Bank_Postgiro_kontonr = 
sprintf("%-35s",str_replace(" ","",$vendor_info['konto_nr']));// verdi: 
konto_nr, type: c35, plass: 740 - 774
+                               $Betalingsmate  = sprintf("%-2s",'');// verdi: 
Blank, type: c2, plass: 775 - 776
+                               $Mva_reg_nr     = sprintf("%-25s",'');// verdi: 
Blank, type: c25, plass: 777 - 801
+                               $Postnummer     = sprintf("%-15s",'');// verdi: 
Blank, type: c15, plass: 802 - 816
+                               $Val_dok        = sprintf("%-3s",'');// verdi: 
Blank, type: c3, plass: 817 - 819
+
+
+                               $underbilag_count= 
count($invoice['invoice_line']);
+                               $last_record = $underbilag_count - 1;
+
+                               //Velg ut alle underbilag
+                               foreach($invoice['invoice_line'] as $_key => 
$invoice_line)
+                               {
+
+                                       $BilagId = $invoice_line['id'];
+
+                                       $Belop = $invoice_line[$BelopFelt]*100;
+                                       $Belop_ = $Belop;
+
+                                       if($Belop < 0)
+                                       {
+                                               $Belop = abs($Belop);
+                                               $Belop = 
sprintf("%019s",$Belop);
+                                               $Belop = '-' . $Belop;
+                                       }
+                                       else
+                                       {
+                                               $Belop = 
sprintf("%019s",$Belop);
+                                               $Belop = '+' . $Belop;
+                                       }
+
+
+                                       if($invoice_line['pmwrkord_code'])
+                                       {
+
+                                               
$orders_affected[$BilagOverf[$i]['pmwrkord_code']] = true;
+
+                                               //Oppdater beløp på arbeidsordre
+                                               if ($download=='on' && 
!$pre_transfer)
+                                               {
+                                                       if 
($invoice_line['dimd'] % 2 == 0)
+                                                       {
+                                                               
$actual_cost_field='act_mtrl_cost';
+                                                       }
+                                                       else
+                                                       {
+                                                               
$actual_cost_field='act_vendor_cost';
+                                                       }
+                                                       $operator='+';
+
+                                                       if(!$this->debug)
+                                                       {
+                                                               
$this->soXport->correct_actual_cost($invoice_line['pmwrkord_code'],$Belop_,$actual_cost_field,$operator);
+                                                       }
+                                               }
+                                       }
+
+                                       //Overfør til fm_ecobilagoverf
+                                       $invoice_line['filnavn']= 
basename($Filnavn);
+                                       
$invoice_line['ordrebelop']=$invoice_line[$BelopFelt];
+
+                                       //dersom det mangler budsjett konto - 
kun aktuelt for ikke godkjent - sett konto til 2899999
+
+                                       if(!$invoice_line['spbudact_code'] && 
$pre_transfer)
+                                       {
+                                               $invoice_line['spbudact_code'] 
= 12304361;
+                                       }
+
+
+                                       //dersom ikke gyldig objekt - kun 
aktuelt for ikke godkjent - sett objekt til 9999
+
+                                       if(!($invoice_line['kostra_id']>0) && 
$pre_transfer)
+                                       {
+                                               $invoice_line['kostra_id'] = 
26550;
+                                               $invoice_line['mvakode'] = 0;
+                                               $invoice_line['dima'] = 9999;
+                                       }
+
+                                       $Konto          = 
sprintf("%08s",$invoice_line['spbudact_code']);// verdi: Art, type: c8, plass: 
21 - 28
+                                       $Dim_1          = 
sprintf("%08s",$invoice_line['dimb']);// 64040 verdi: Ansvarssted, type: c8, 
plass: 29 - 36
+                                       $Dim_2          = 
sprintf("%-8s",$invoice_line['kostra_id']);// verdi: Tjeneste, type: c8, plass: 
37 - 44
+
+                                       if($pre_transfer)
+                                       {
+                                               $Dim_3          = 
sprintf("%-8s",substr($invoice_line['dima'],0,4));// verdi: Objekt, type: c8, 
plass: 45 - 52
+                                       }
+                                       else
+                                       {
+                                               $Dim_3          = 
sprintf("%-8s",substr($invoice_line['dima'],0,6));// verdi: Objekt-bygg, type: 
c8, plass: 45 - 52
+                                       }
+
+
+                                       $Dim_4          = sprintf("%-8s",'');// 
verdi: Ressurs, type: c8, plass: 53 - 60
+                                       $Dim_5          = 
sprintf("%-12s",$invoice_line['project_id']);// verdi: Prosjekt, type: c12, 
plass: 61 - 72
+
+//FIXME 'dime' må legges inn...
+                                       $Dim_6          = 
sprintf("%-4s",$invoice_line['dime']);// Kategori, type: c4, plass: 73 - 76
+
+                                       $Dim_7          = sprintf("%-4s",'');// 
verdi: Blank, type: c4, plass: 77 - 80
+
+                                       
$Avgiftskode=sprintf("%-2s",$invoice_line['mvakode']);// verdi: Avgiftskode, 
type: c2, plass: 81 - 82
+
+                                       $Avgiftssystem  = sprintf("%2s",'');// 
verdi: Blank, type: c2, plass: 83 - 84
+                                       $Valutakode     ='NOK';// verdi: NOK, 
type: c3, plass: 85 - 87
+                                       $Debet_Kredit   = sprintf("%2s",'');// 
verdi: Blank, type: i2, plass: 88 - 89
+                                       $Valutabelop    = $Belop;// verdi: 
Beløp, type: money, plass: 90 - 109
+                                       $Belop_i_firmavaluta=$Belop;// verdi: 
Beløp, type: money, plass: 110 - 129
+                                       $Antall         = sprintf("%11s",'');// 
verdi: Blank, type: i4, plass: 130 - 140
+                                       $Belop2         = sprintf("%20s",'');// 
verdi: Blank, type: f8, plass: 141 - 160
+                                       $Belop3         = sprintf("%20s",'');// 
verdi: Blank, type: money, plass: 161 - 180
+
+                               //      $Belop4 (også kalt "money3" )blir brukt 
for identifisere overføring på tvers av filer.
+                                       $Belop4         = 
sprintf("%20s",$batchid);// verdi: Blank, type: money, plass: 181 - 200 - 
batch_id høyre justert
+
+/*
+                                       if($invoice_line['pmwrkord_code'])
+                                       {
+                                               $Tekst  = 
sprintf("%-50s",substr(utf8_decode($this->get_order_title($invoice_line['pmwrkord_code'])),0,50));//sprintf("%-50s",substr($invoice_line['merknad'],0,50));//
 verdi: Tekst, type: text (50), plass: 201 - 250
+                                       }
+                                       else
+                                       {
+                                               $Tekst  = 
sprintf("%-50s",'');//sprintf("%-50s",substr($invoice_line['merknad'],0,50));// 
verdi: Tekst, type: text (50), plass: 201 - 250
+                                       }
+*/
+                                       $Tekst  = 
sprintf("%-50s",substr($invoice_line['fakturanr'],0,50));
+
+                                       $Fakturanr      = 
sprintf("%-15s",substr(utf8_decode($invoice_line['fakturanr']), 0, 15));// 
verdi: Fakturanr, type: c15, plass: 283 - 297
+
+                                       $Ordrenummer    = 
sprintf("%-9s",$invoice_line['pmwrkord_code']);// verdi: Infodoc ordrenr, type: 
i4, plass: 342 - 350
+
+
+                                       //Kopier verdier
+                                       if ($download=='on' && !$pre_transfer 
&& !$this->debug)
+                                       {
+                                               
$this->soXport->add_OverfBilag($invoice_line);
+                                       }
+
+                                       //Skriv til fil
+
+                                       $buffer .= $Buntnr . $Forsystem . 
$Bilagsart . $Transtype . $Firmakode . $Konto . $Dim_1 . $Dim_2 . $Dim_3 . 
$Dim_4 . 
+                                       $Dim_5 . $Dim_6 . $Dim_7 . $Avgiftskode 
. $Avgiftssystem . $Valutakode . $Debet_Kredit . $Valutabelop . 
+                                       $Belop_i_firmavaluta . $Antall . 
$Belop2 . $Belop3 . $Belop4 . $Tekst . $Valuteringsdato . $Bilagsdato . 
+                                       $Bilagsnr . $_periode . $ESL . 
$Fakturanr . $Forfall . $Rab_forf . $Rabatt . $Avt_Kon . $Ordrenummer . 
+                                       $Kid . $Bet_overforing . $Status . 
$Resk_type . $Resk_nr . $Forskudd . $Fakturaref . $Fakturaref . 
+                                       $Inkassokode . $Bet_mottager . 
$Att_ansvarlig . $Resk_navn . $Postadresse . $Stat_Provins . $Sted . 
+                                       $Bank_Postgiro_kontonr . $Betalingsmate 
. $Mva_reg_nr . $Postnummer . $Val_dok ."\r\n";
+
+                                       if($_key==$last_record)
+                                       {
+                                               $Konto          = 
sprintf("%-8s",'2139915');// verdi: Art, type: c8, plass: 21 - 28
+                                               $Dim_1          = 
sprintf("%08s",$invoice_line['dimb']);//sprintf("%-8s",'');// verdi: 
Ansvarssted, type: c8, plass: 29 - 36
+                                               $Dim_2          = 
sprintf("%-8s",'');// verdi: Tjeneste, type: c8, plass: 37 - 44
+                                               $Dim_3          = 
sprintf("%-8s",'');// verdi: Objekt, type: c8, plass: 45 - 52
+                                               $Dim_4          = 
sprintf("%-8s",'');// verdi: Ressurs, type: c8, plass: 53 - 60
+                                               $Dim_5          = 
sprintf("%-12s",'');// verdi: Prosjekt, type: c12, plass: 61 - 72
+                                               $Dim_6          = 
sprintf("%-4s",'');// verdi: Blank, type: c4, plass: 73 - 76
+                                               $Dim_7          = 
sprintf("%-4s",'');// verdi: Blank, type: c4, plass: 77 - 80
+                                               $Fakturanr      = 
sprintf("%-15s",'');// verdi: Fakturanr, type: c15, plass: 283 - 297
+                                               $Ordrenummer    = 
sprintf("%-9s",'');// verdi: Infodoc ordrenr, type: i4, plass: 342 - 350
+                                       //      $Tekst          = 
sprintf("%-50s",'');//sprintf("%-50s",substr($invoice_line['merknad'],0,50));// 
verdi: Tekst, type: text (50), plass: 201 - 250
+                                               $Tekst          = 
sprintf("%-50s",substr($invoice_line['fakturanr'],0,50));// verdi: Tekst, type: 
text (50), plass: 201 - 250
+
+                                               //Ikke fortegnskifte for 
kostfordeling (GL)
+                                               if($Belop_motpost < 0)
+                                               {
+                                                       $Belop_motpost = 
sprintf("%019s",abs($Belop_motpost));
+                                                       $Belop_motpost = '-' . 
$Belop_motpost;
+                                               }
+                                               else
+                                               {
+                                                       $Belop_motpost = 
sprintf("%019s",$Belop_motpost);
+                                                       $Belop_motpost = '+' . 
$Belop_motpost;
+
+                                               }
+
+                                               $Transtype      = 'GL';// 
verdi: GL, type: c2, plass: 17 - 18
+                                               $Valutabelop    = 
$Belop_motpost;// verdi: Beløp, type: money, plass: 90 - 109
+                                               
$Belop_i_firmavaluta=$Belop_motpost;// verdi: Beløp, type: money, plass: 110 - 
129
+
+                                               $buffer .= $Buntnr . $Forsystem 
. $Bilagsart . $Transtype . $Firmakode . $Konto . $Dim_1 . $Dim_2 . $Dim_3 . 
$Dim_4 . 
+                                               $Dim_5 . $Dim_6 . $Dim_7 . 
$Avgiftskode . $Avgiftssystem . $Valutakode . $Debet_Kredit . $Valutabelop . 
+                                               $Belop_i_firmavaluta . $Antall 
. $Belop2 . $Belop3 . $Belop4 . $Tekst . $Valuteringsdato . $Bilagsdato . 
+                                               $Bilagsnr . $_periode . $ESL . 
$Fakturanr . $Forfall . $Rab_forf . $Rabatt . $Avt_Kon . $Ordrenummer . 
+                                               $Kid . $Bet_overforing . 
$Status . $Resk_type . $Resk_nr . $Forskudd . $Fakturaref . $Fakturaref . 
+                                               $Inkassokode . $Bet_mottager . 
$Att_ansvarlig . $Resk_navn . $Postadresse . $Stat_Provins . $Sted . 
+                                               $Bank_Postgiro_kontonr . 
$Betalingsmate . $Mva_reg_nr . $Postnummer . $Val_dok ."\r\n";
+                                       }
+
+                                       //Slett post i fm_ecobilag
+                                       if ($download=='on' && !$pre_transfer 
&& !$this->debug)
+                                       {
+                                               
$this->soXport->delete_from_fm_ecobilag($invoice_line['id']);
+                                               //Logg transaksjon
+                                               
$this->soXport->log_transaction($batchid,$BilagId,lang('Invoice transferred'));
+                                       }
+
+                                       $BilagId = 'NULL';
+
+                                       $antall = $antall + 1;
+                               }
+                       }
+
+                       //Fullfør transaksjon
+
+                       if ($download=='on' && !$pre_transfer && !$this->debug):
+                       {
+                               $fp = fopen($Filnavn, "wb");
+                               fwrite($fp,$buffer);
+
+                               if(fclose($fp))
+                               {
+                                       $file_written=True;
+                               }
+
+                               if($file_written && 
$this->config->config_data['common']['method']!='ftp'):
+                               {
+                                       $transfer_ok = True;
+                               }
+                               elseif($file_written):
+                               {
+                                       $transfer_ok = 
$this->transfer($buffer,$Filnavn,$batchid,$tranfser_bilag);
+                               }
+                               endif;
+
+                               if($transfer_ok)
+                               {
+                                       $this->db->transaction_commit();
+                                       $message = 'Godkjent: periode: 
'.$_periode.' antall bilag/underbilag overfort:'.$antall . ' , fil: ' . 
$Filnavn;
+                                       phpgwapi_cache::message_set($message, 
'message'); 
+                               }
+                               else
+                               {
+                                       $this->db->transaction_abort();
+                                       $message = 'Noe gikk galt med 
overforing av godkjendte fakturaer!';
+                                       phpgwapi_cache::message_set($message, 
'error'); 
+                               }
+                       }
+                       elseif($download=='on' && $pre_transfer && 
!$this->debug):
+                       {
+
+                               $fp = fopen($Filnavn, "wb");
+                               fwrite($fp,$buffer);
+
+                               if(fclose($fp))
+                               {
+                                       $file_written=True;
+                               }
+
+                               if($file_written && 
$this->config->config_data['common']['method']!='ftp'):
+                               {
+                                       $transfer_ok = True;
+                               }
+                               elseif($file_written):
+                               {
+                                       $transfer_ok = 
$this->transfer($buffer,$Filnavn,$batchid,$tranfser_bilag);
+                               }
+                               endif;
+
+                               if($transfer_ok)
+                               {
+                                       
$this->soXport->update_actual_cost_from_archive($this->orders_affected);
+
+                                       $this->db->transaction_commit();
+                                       $message = 'Ankomstregistrering: 
periode: '.$periode.' antall bilag/underbilag overfort:'.$antall . ' , fil: ' . 
$Filnavn;
+                                       phpgwapi_cache::message_set($message, 
'message'); 
+                               }
+                               else
+                               {
+                                       $this->db->transaction_abort();
+                                       $message = 'Noe gikk galt med 
ankomstregistrering!';
+                                       phpgwapi_cache::message_set($message, 
'error'); 
+                               }
+                       }
+                       else:
+                       {
+                               $this->db->transaction_abort();
+
+                               _debug_array($Filnavn);
+                               $fp = fopen($Filnavn, "wb");
+                               fwrite($fp,$buffer);
+
+                               if(fclose($fp))
+                               {
+                                       $file_written=True;
+                               }
+
+                               echo "<pre>{$buffer}</pre>";
+                       }
+                       endif;
+               }
+
+               function transfer($buffer,$Filnavn,$batchid,$tranfser_bilag)
+               {
+
+                       
if($this->config->config_data['common']['method']=='ftp')
+                       {
+                               $ftp    = $this->phpftp_connect();
+
+                               $basedir = 
$this->config->config_data['common']['remote_basedir'];
+                               if($basedir)
+                               {
+                                       $newfile = $basedir . '/' . 
basename($Filnavn);
+                               }
+                               else
+                               {
+                                       $newfile = basename($Filnavn);
+                               }
+
+                               if (ftp_put($ftp,$newfile, $Filnavn, 
FTP_BINARY))
+                               {
+                                       for 
($i=0;$i<count($tranfser_bilag);$i++)
+                                       {
+                                               
$this->soXport->log_transaction($batchid,$tranfser_bilag[$i],lang('Invoice 
pre_transferred %1',basename($Filnavn)));
+                                       }
+                                       $transfer_ok = True;
+                               }
+                               else
+                               {
+                                       for 
($i=0;$i<count($tranfser_bilag);$i++)
+                                       {
+                                               
$this->soXport->log_transaction($batchid,$tranfser_bilag[$i],lang('Failed to 
pre_transfere %1 to agresso',basename($Filnavn)));
+                                       }
+                                       $transfer_ok = False;
+                               }
+                               if(!$transfer_ok)
+                               {
+                                       unlink($Filnavn);
+                               }
+
+                               ftp_quit($ftp);
+                       }
+                       return  $transfer_ok;
+               }
+
+               function phpftp_connect() 
+               {
+                       $host                           = 
$this->config->config_data['common']['host'];
+                       $user                           = 
$this->config->config_data['common']['user'];
+                       $password                       = 
$this->config->config_data['common']['password'];
+
+//                     echo "connecting to $host with $user and $pass\n <br>";
+                       $ftp = ftp_connect($host);
+                       if($ftp) 
+                       {
+                               if (ftp_login($ftp,$user,$password)) 
+                               {
+                                       return $ftp;
+                               }
+                       }
+               }
+       }

Modified: 
branches/Version-1_0-branch/property/inc/import/default/Import_fra_Service
===================================================================
--- branches/Version-1_0-branch/property/inc/import/default/Import_fra_Service  
2013-12-19 18:47:00 UTC (rev 11546)
+++ branches/Version-1_0-branch/property/inc/import/default/Import_fra_Service  
2013-12-19 18:50:32 UTC (rev 11547)
@@ -167,7 +167,9 @@
                                        }
                                        else
                                        {
-                                               
$buffer[$this->id]['project_id'] = $this->soXport->get_project(intval($value)); 
+                                               $workorder = 
execMethod('property.soworkorder.read_single', (int)$value);
+                                               
$buffer[$this->id]['project_id'] = $workorder['project_id'];
+                                               $buffer[$this->id]['dime']      
= $workorder['cat_id'];
                                        }
                                }
                                if($name=='spbudact_code')

Modified: branches/Version-1_0-branch/property/js/portico/ajax_invoice.js
===================================================================
--- branches/Version-1_0-branch/property/js/portico/ajax_invoice.js     
2013-12-19 18:47:00 UTC (rev 11546)
+++ branches/Version-1_0-branch/property/js/portico/ajax_invoice.js     
2013-12-19 18:50:32 UTC (rev 11547)
@@ -86,7 +86,26 @@
                update_form_values(line_id, voucher_id_orig);
     });
 
+       $("#dim_e").change(function(){
+               var oArgs = {menuaction:'property.boworkorder.get_category', 
cat_id:$(this).val()};
+               var requestUrl = phpGWLink('index.php', oArgs, true);
 
+               $.ajax({
+                       type: 'POST',
+                       dataType: 'json',
+                       url: requestUrl,
+                       success: function(data) {
+                               if( data != null)
+                               {
+                                       if(data.active !=1)
+                                       {
+                                               alert('Denne kan ikke velges');
+                                       }
+                               }
+                       }
+               });
+       });
+
        $("#voucher_form").live("submit", function(e){
                e.preventDefault();
                var line_id = $("#line_id").val();
@@ -97,12 +116,36 @@
                        return;
                }
 
-               if($("#periodization").val() && ! 
$("#periodization_start").val())
+               var periodization = 
document.getElementById("periodization").value;
+               var periodization_start = 
document.getElementById("periodization_start").value;
+               var dim_e = document.getElementById("dim_e").value;
+               var dim_b = document.getElementById("dim_b").value;
+               var dim_a = document.getElementById("dim_a").value;
+
+               if(periodization && ! periodization_start)
                {
                        alert('Du må velge startperiode');
                        return;
                }
 
+               if(!dim_e)
+               {
+                       alert('Du må velge Kategori');
+                       return;
+               }
+
+               if(!dim_b)
+               {
+                       alert('Du må velge Ansvarssted');
+                       return;
+               }
+
+               if(!dim_a)
+               {
+                       alert('Du må angi Dim A');
+                       return;
+               }
+
                var thisForm = $(this);
                var submitBnt = $(thisForm).find("input[type='submit']");
                var requestUrl = $(thisForm).attr("action");

Modified: branches/Version-1_0-branch/property/js/yahoo/budget.obligations.js
===================================================================
--- branches/Version-1_0-branch/property/js/yahoo/budget.obligations.js 
2013-12-19 18:47:00 UTC (rev 11546)
+++ branches/Version-1_0-branch/property/js/yahoo/budget.obligations.js 
2013-12-19 18:50:32 UTC (rev 11547)
@@ -3,12 +3,11 @@
 //--------------------------------------------------------
 
                //define SelectButton
-               var oMenuButton_0, oMenuButton_1;//, oMenuButton_2, 
oMenuButton_3, oMenuButton_4;
+               var oMenuButton_0, oMenuButton_1, oMenuButton_2;//, 
oMenuButton_3, oMenuButton_4;
                var selectsButtons = [
                {order:0, var_URL:'year',               name:'btn_year',        
        style:'',dependiente:[]},
-               {order:1, var_URL:'district_id',name:'btn_district_id', 
style:'',dependiente:[]}
-//             {order:2, var_URL:'cat_id',             name:'btn_cat_id',      
        style:'',dependiente:[]},
-//             {order:3, var_URL:'grouping',   name:'btn_grouping',    
style:'',dependiente:[]},
+               {order:1, var_URL:'district_id',name:'btn_district_id', 
style:'',dependiente:[]},
+               {order:2, var_URL:'grouping',   name:'btn_grouping',    
style:'',dependiente:[]}
 //             {order:4, var_URL:'dimb_id',    name:'btn_dimb_id',             
style:'',dependiente:[]}
                ]
 
@@ -59,15 +58,15 @@
                        if(details)
                        {
                                //look for  "grouping" column
-               //              oMenuButton_3.set("label", ("<em>" + param + 
"</em>"));
-               //              oMenuButton_3.set("value", param);
+                               oMenuButton_2.set("label", ("<em>" + param + 
"</em>"));
+                               oMenuButton_2.set("value", param);
                                path_values.grouping = param;
                        }
                        else
                        {
                                //reset GROUPING filter
-               //              oMenuButton_3.set("label", ("<em>" + 
array_options[3][0][1] + "</em>"));
-               //              path_values.grouping =  array_options[3][0][0];
+                               oMenuButton_2.set("label", ("<em>" + 
array_options[2][0][1] + "</em>"));
+                               path_values.grouping =  array_options[2][0][0];
                                path_values.b_account = param;
                        }
 
@@ -88,6 +87,7 @@
                var myformatLinkPGW = function(elCell, oRecord, oColumn, oData)
                {
                        var details;
+                       var district_id = 0;
                        if(oRecord._oData.grouping != "")
                        {
                                details = 1;
@@ -98,8 +98,13 @@
                                details = 0;
                                text = oRecord._oData.b_account;
                        }
-                       
-                       elCell.innerHTML = "<a 
onclick=\"javascript:filter_grouping("+path_values.year+","+oRecord._oData.district_id+","+
 text +","+details+");\" href=\"#\">" + text + "</a>";
+
+                       if (typeof (oRecord._oData.district_id) != 'undefined')
+                       {
+                               district_id = oRecord._oData.district_id;
+                       }
+
+                       elCell.innerHTML = "<a 
onclick=\"javascript:filter_grouping("+path_values.year+","+district_id+","+ 
text +","+details+");\" href=\"#\">" + text + "</a>";
                }       
        
/********************************************************************************/
                var myFormatLink_Count = function(elCell, oRecord, oColumn, 
oData)
@@ -164,7 +169,7 @@
                        tmp_sum_diff = 
YAHOO.util.Number.format(values_ds.sum_diff, {decimalPlaces:0, 
decimalSeparator:",", thousandsSeparator:" "});
                        tmp_sum_hits = 
YAHOO.util.Number.format(values_ds.sum_hits, {decimalPlaces:0, 
decimalSeparator:",", thousandsSeparator:" "});
                        
-                       td_empty(5);
+                       td_empty(4);
                        td_sum(tmp_sum_hits);
                        td_empty(1);
                        td_sum(tmp_sum_budget);




reply via email to

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