[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11593] Merge 11588:11592 from trunk
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11593] Merge 11588:11592 from trunk |
Date: |
Thu, 09 Jan 2014 13:59:35 +0000 |
Revision: 11593
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11593
Author: sigurdne
Date: 2014-01-09 13:59:35 +0000 (Thu, 09 Jan 2014)
Log Message:
-----------
Merge 11588:11592 from trunk
Modified Paths:
--------------
branches/Version-1_0-branch/property/inc/class.bogeneric.inc.php
branches/Version-1_0-branch/property/inc/class.sogeneric.inc.php
branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php
branches/Version-1_0-branch/property/inc/class.uiimport.inc.php
branches/Version-1_0-branch/property/setup/tables_update.inc.php
Removed Paths:
-------------
branches/Version-1_0-branch/property/inc/export/default/Basware_X114
Property Changed:
----------------
branches/Version-1_0-branch/
Property changes on: branches/Version-1_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
-
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352,8354-8368,8370-8396,8398-8430,8432,8434-8440,8442-8445,8447-8453,8455-8456,8458,8460,8462-8464,8466-8473,8475-8479,8481,8483-8501,8503-8523,8525,8527-8531,8533,8535-8536,8538-8550,8552-8554,8556-8557,8559-8579,8581-8587,8589,8591-8592,8594-8595,8597-8601,8603-8610,8612-8613,8615,8617,8619-8645,8647-8650,8652-8661,8663-8666,8668-8669,8671-8683,8685-8691,8693-8730,8732-8737,8739,8741-8767,8769,8771-8772,8774,8776-8797,8799-8812,8814-8819,8821,8823-8833,8835-8837,8839,8841,8843-8849,8852-8858,8860-8867,8869-8870,8872,8874-8877,8879,8881,8883-8888,8890,8892-8901,8903-8911,8913-8917,8920-8923,8925-8933,8935-8938,8940-8943,8945,8947-8948,8950,8952-8953,8955-8962,8964,8966,8968-8970,8972-8975,8977-8983,8985-8993,8995-9001,9003,9005,9007,9009,9011-9019,9021-9023,9025,9027-9028,9030-9044,9046-9047,9049-9050,9052-9056,9058-9059,9061,9063-9064,9066-9068,9071-9092,9094-9112,9114-9117,9119,9121-9160,9162-9166,9169-9207,9209-9211,9213-9215,9217,9219,9221-9253,9255,9257,9259-9260,9262,9264-9269,9271-9273,9275,9277-9278,9280,9282-9283,9285-9289,9291-9299,9301-9310,9312-9313,9315-9320,9322-9324,9326-9338,9340-9342,9344,9346-9348,9350-9358,9360-9362,9364-9366,9368-9374,9376-9382,9384,9386,9388-9390,9392-9396,9398-9402,9404-9410,9412,9414,9416-9417,9419-9425,9427,9429-9430,9432,9434-9463,9465-9502,9504-9506,9508-9521,9523-9526,9528,9530-9537,9539,9541-9551,9553,9555-9556,9558-9578,9580-9581,9583,9585,9587,9589,9591-9624,9626-9655,9657-9700,9702-9726,9728-9729,9731-9749,9751,9753-9754,9756-9832,9834-9836,9838-9839,9841-9846,9848-9850,9852-9858,9860-9863,9865,9867,9869-9871,9873-9893,9895,9897-9912,9914-9919,9921-9928,9930-9952,9954,9956,9958-9963,9965-9993,9995-9997,9999-10001,10003-10004,10006-10007,10009-10012,10014-10031,10033-10073,10075-10107,10109-10165,10167-10210,10222-10226,10228-10311,10313-10378,10380,10382,10384-10393,10395-10478,10480-10482,10484-10494,10496-10503,10505,10507,10509-10521,10523,10525-10528,10530-10540,10542-10543,10545-10568,10570-10584,10586-10590,10592-10594,10596,10598-10599,10601-10611,10613,10615,10617-10626,10628-10636,10638,10640-10654,10656-10658,10660,10662-10672,10674,10676-10682,10684,10686,10688-10690,10692-10694,10696-10697,10699-10701,10703,10705-10706,10708-10724,10726-10731,10734,10736-10748,10750-10796,10798-10939,10941,10943,10945,10947-10953,10955,10957-10961,10963,10965-10966,10968-11001,11003-11030,11032-11034,11036,11038,11040,11042-11053,11055-11059,11061-11062,11064-11068,11070-11073,11075-11077,11079-11083,11085,11087-11088,11090-11093,11095-11108,11110-11111,11113,11115-11116,11118-11120,11122,11124-11129,11131-11132,11134,11136,11138,11140-11151,11153-11161,11163-11185,11187-11189,11191-11229,11231,11233,11235-11264,11266-11267,11269-11278,11280-11282,11284-11291,11293-11295,11297,11299-11302,11304,11306,11309,11311,11313-11316,11318-11323,11325-11332,11334,11336-11344,11346,11348-11354,11356,11358-11360,11363-11386,11388-11389,11391-11392,11394,11396-11403,11405-11406,11408,11410,11412,11415,11417,11419-11420,11422,11424-11429,11431-11442,11444-11445,11447-11460,11462-11464,11466-11470,11472-11475,11477-11478,11480-11487,11489-11492,11494,11496,11498,11500-11502,11504-11506,11508,11510-11511,11513,11515,11517-11523,11525-11526,11528-11531,11533,11535-11538,11540-11546,11548-11560,11563-11572,11574,11576,11578,11580-11581,11583,11585,11587
+
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352,8354-8368,8370-8396,8398-8430,8432,8434-8440,8442-8445,8447-8453,8455-8456,8458,8460,8462-8464,8466-8473,8475-8479,8481,8483-8501,8503-8523,8525,8527-8531,8533,8535-8536,8538-8550,8552-8554,8556-8557,8559-8579,8581-8587,8589,8591-8592,8594-8595,8597-8601,8603-8610,8612-8613,8615,8617,8619-8645,8647-8650,8652-8661,8663-8666,8668-8669,8671-8683,8685-8691,8693-8730,8732-8737,8739,8741-8767,8769,8771-8772,8774,8776-8797,8799-8812,8814-8819,8821,8823-8833,8835-8837,8839,8841,8843-8849,8852-8858,8860-8867,8869-8870,8872,8874-8877,8879,8881,8883-8888,8890,8892-8901,8903-8911,8913-8917,8920-8923,8925-8933,8935-8938,8940-8943,8945,8947-8948,8950,8952-8953,8955-8962,8964,8966,8968-8970,8972-8975,8977-8983,8985-8993,8995-9001,9003,9005,9007,9009,9011-9019,9021-9023,9025,9027-9028,9030-9044,9046-9047,9049-9050,9052-9056,9058-9059,9061,9063-9064,9066-9068,9071-9092,9094-9112,9114-9117,9119,9121-9160,9162-9166,9169-9207,9209-9211,9213-9215,9217,9219,9221-9253,9255,9257,9259-9260,9262,9264-9269,9271-9273,9275,9277-9278,9280,9282-9283,9285-9289,9291-9299,9301-9310,9312-9313,9315-9320,9322-9324,9326-9338,9340-9342,9344,9346-9348,9350-9358,9360-9362,9364-9366,9368-9374,9376-9382,9384,9386,9388-9390,9392-9396,9398-9402,9404-9410,9412,9414,9416-9417,9419-9425,9427,9429-9430,9432,9434-9463,9465-9502,9504-9506,9508-9521,9523-9526,9528,9530-9537,9539,9541-9551,9553,9555-9556,9558-9578,9580-9581,9583,9585,9587,9589,9591-9624,9626-9655,9657-9700,9702-9726,9728-9729,9731-9749,9751,9753-9754,9756-9832,9834-9836,9838-9839,9841-9846,9848-9850,9852-9858,9860-9863,9865,9867,9869-9871,9873-9893,9895,9897-9912,9914-9919,9921-9928,9930-9952,9954,9956,9958-9963,9965-9993,9995-9997,9999-10001,10003-10004,10006-10007,10009-10012,10014-10031,10033-10073,10075-10107,10109-10165,10167-10210,10222-10226,10228-10311,10313-10378,10380,10382,10384-10393,10395-10478,10480-10482,10484-10494,10496-10503,10505,10507,10509-10521,10523,10525-10528,10530-10540,10542-10543,10545-10568,10570-10584,10586-10590,10592-10594,10596,10598-10599,10601-10611,10613,10615,10617-10626,10628-10636,10638,10640-10654,10656-10658,10660,10662-10672,10674,10676-10682,10684,10686,10688-10690,10692-10694,10696-10697,10699-10701,10703,10705-10706,10708-10724,10726-10731,10734,10736-10748,10750-10796,10798-10939,10941,10943,10945,10947-10953,10955,10957-10961,10963,10965-10966,10968-11001,11003-11030,11032-11034,11036,11038,11040,11042-11053,11055-11059,11061-11062,11064-11068,11070-11073,11075-11077,11079-11083,11085,11087-11088,11090-11093,11095-11108,11110-11111,11113,11115-11116,11118-11120,11122,11124-11129,11131-11132,11134,11136,11138,11140-11151,11153-11161,11163-11185,11187-11189,11191-11229,11231,11233,11235-11264,11266-11267,11269-11278,11280-11282,11284-11291,11293-11295,11297,11299-11302,11304,11306,11309,11311,11313-11316,11318-11323,11325-11332,11334,11336-11344,11346,11348-11354,11356,11358-11360,11363-11386,11388-11389,11391-11392,11394,11396-11403,11405-11406,11408,11410,11412,11415,11417,11419-11420,11422,11424-11429,11431-11442,11444-11445,11447-11460,11462-11464,11466-11470,11472-11475,11477-11478,11480-11487,11489-11492,11494,11496,11498,11500-11502,11504-11506,11508,11510-11511,11513,11515,11517-11523,11525-11526,11528-11531,11533,11535-11538,11540-11546,11548-11560,11563-11572,11574,11576,11578,11580-11581,11583,11585,11587,11589-11592
Modified: branches/Version-1_0-branch/property/inc/class.bogeneric.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.bogeneric.inc.php
2014-01-09 13:56:06 UTC (rev 11592)
+++ branches/Version-1_0-branch/property/inc/class.bogeneric.inc.php
2014-01-09 13:59:35 UTC (rev 11593)
@@ -148,6 +148,23 @@
$values = $this->so->read(array('start' =>
$this->start,'query' => $this->query,'sort' => $this->sort,'order' =>
$this->order,
'allrows'=>$this->allrows),$filter);
+
+ foreach ( $this->location_info['fields'] as $field )
+ {
+ if (isset($field['role']) && $field['role'] ==
'parent')
+ {
+ foreach($values as &$entry)
+ {
+
if(isset($entry[$field['name']]) && $entry[$field['name']])
+ {
+ $path =
$this->so->get_path(array('type' => $this->type, 'id' =>
$entry[$field['name']]));
+ $entry[$field['name']]
= implode(' > ', $path);
+ }
+ }
+ }
+
+ }
+
$this->total_records = $this->so->total_records;
$this->uicols = $this->so->uicols;
@@ -222,7 +239,7 @@
{
array_unshift($values,array('id'=> '', 'name'=>
lang('select')));
}
-
+
if(isset($data['selected']) &&
is_array($data['selected']))
{
foreach ($values as &$entry)
Modified: branches/Version-1_0-branch/property/inc/class.sogeneric.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.sogeneric.inc.php
2014-01-09 13:56:06 UTC (rev 11592)
+++ branches/Version-1_0-branch/property/inc/class.sogeneric.inc.php
2014-01-09 13:59:35 UTC (rev 11593)
@@ -3295,6 +3295,7 @@
public function get_children2($data, $parent, $level, $reset =
false)
{
+ $parent = (int)$parent;
$mapping = array();
if(isset($data['mapping']) && $data['mapping'])
{
@@ -3315,6 +3316,7 @@
return $this->tree;
}
$sql = "SELECT * FROM {$table} WHERE parent_id =
{$parent}";
+
$db->query($sql,__LINE__,__FILE__);
while ($db->next_record())
@@ -3324,9 +3326,9 @@
(
'id' => $id,
'name' =>
str_repeat('..',$level) . $db->f($mapping['name'],true),
- 'parent_id' => $db->f('parent_id')
+ 'parent_id' => $parent
);
- $this->get_children2($id, $level+1);
+ $this->get_children2($data, $id, $level+1);
}
return $this->tree;
}
Modified: branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php
2014-01-09 13:56:06 UTC (rev 11592)
+++ branches/Version-1_0-branch/property/inc/class.soinvoice.inc.php
2014-01-09 13:59:35 UTC (rev 11593)
@@ -1363,7 +1363,9 @@
if(isset($this->config->config_data['invoice_acl']) &&
$this->config->config_data['invoice_acl'] == 'dimb')
{
$sql = "SELECT DISTINCT fm_ecodimb.* FROM
fm_ecodimb {$this->db->join} fm_ecodimb_role_user ON fm_ecodimb.id =
fm_ecodimb_role_user.ecodimb"
- . ' WHERE fm_ecodimb_role_user.user_id = ' .
(int) $this->account_id . ' ORDER BY descr ASC';
+ . ' WHERE fm_ecodimb_role_user.user_id = ' .
(int) $this->account_id
+ . ' AND expired_on IS NULL'
+ . ' ORDER BY descr ASC';
$include_selected = true;
}
else
Modified: branches/Version-1_0-branch/property/inc/class.uiimport.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiimport.inc.php
2014-01-09 13:56:06 UTC (rev 11592)
+++ branches/Version-1_0-branch/property/inc/class.uiimport.inc.php
2014-01-09 13:59:35 UTC (rev 11593)
@@ -57,6 +57,7 @@
'fm_condition_survey' => 'fm_condition_survey
(' . lang('condition survey') . ')',
'fm_ecodimb' => 'fm_ecodimb
(' . lang('dimb') . ')',
'fm_budget' =>
'fm_budget (' . lang('budget') . ')',
+ 'fm_department' =>
'fm_department (' . lang('department') . ')',
);
$location_types =
execMethod('property.soadmin_location.select_location_type');
Deleted: branches/Version-1_0-branch/property/inc/export/default/Basware_X114
===================================================================
--- branches/Version-1_0-branch/property/inc/export/default/Basware_X114
2014-01-09 13:56:06 UTC (rev 11592)
+++ branches/Version-1_0-branch/property/inc/export/default/Basware_X114
2014-01-09 13:59:35 UTC (rev 11593)
@@ -1,1156 +0,0 @@
-<?php
- /**
- * phpGroupWare - property: a Facilities Management System.
- *
- * @author Sigurd Nes <address@hidden>
- * @copyright Copyright (C) 2003,2004,2005,2006,2007 Free Software
Foundation, Inc. http://www.fsf.org/
- * This file is part of phpGroupWare.
- *
- * phpGroupWare is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * phpGroupWare is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with phpGroupWare; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
- *
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
- * @package property
- * @subpackage export
- * @version $Id$
- */
-
- /**
- * Description
- * @package property
- */
-
- phpgw::import_class('phpgwapi.datetime');
-
- class export_conv
- {
- //var $fil_katalog='c:/temp'; //On windows use
"//computername/share/filename" or "\\\\computername\share\filename" to check
files on network shares.
-
- var $debug;
- var $client_code = 14;
- protected $connection = false;
- protected $global_lock = false;
- protected $orders_affected = array();
- protected $min_period;
-
- function __construct()
- {
- $GLOBALS['phpgw_info']['flags']['currentapp'] =
'property';
- $this->currentapp =
$GLOBALS['phpgw_info']['flags']['currentapp'];
- $this->db = &
$GLOBALS['phpgw']->db;
- $this->join = &
$this->db->join;
-
- $this->soXport =
CreateObject('property.soXport');
- $this->config =
CreateObject('admin.soconfig',$GLOBALS['phpgw']->locations->get_id('property',
'.invoice'));
- $this->cats =
CreateObject('phpgwapi.categories', -1, 'property', '.project');
- $this->cats->supress_info = true;
-
-
if(!isset($this->config->config_data['common']['method']))
- {
- $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'admin.uiconfig2.index', 'location_id' =>
$GLOBALS['phpgw']->locations->get_id('property', '.invoice')) );
- }
-
- if
(isset($this->config->config_data['export']['cleanup_old']) &&
$this->config->config_data['export']['cleanup_old'])
- {
- $this->cleanup_old();
- }
-
- $sogeneric =
CreateObject('property.sogeneric','period_transition');
- $period_config =
$sogeneric->read(array('allrows' => true));
-
- $period_transition = array();
- foreach($period_config as $entry)
- {
- $period_transition[$entry['month']] = $entry;
- }
-
- $current_month = date('n');
-
- if(isset($period_transition[$current_month]))
- {
- $_lag_day =
(int)$period_transition[$current_month]['day'];
- $_lag_hour =
(int)$period_transition[$current_month]['hour'];
- $_lag_seconds = ($_lag_day * 24 * 3600) +
($_lag_hour * 3600);
- }
- else if(isset($period_transition[13]))
- {
- $_lag_day = (int)$period_transition[13]['day'];
- $_lag_hour =
(int)$period_transition[13]['hour'];
- $_lag_seconds = ($_lag_day * 24 * 3600) +
($_lag_hour * 3600);
- }
- else
- {
- $_lag = date('n') == 1 ? 17 :
7;//6 days into next month, 16 days into next year
- $_lag_seconds = $_lag * 24 * 3600;
- }
-
- $_lag_seconds -= phpgwapi_datetime::user_timezone();
-
-//_debug_array($period_transition);
- $time = time();
- $timestamp_at_start_month = mktime( $hour = 0, $minute
= 0, $second = 0, $month = date("n"), $day = 0, $year = date("Y") );
-
- if(($time - $timestamp_at_start_month) < $_lag_seconds)
- {
- $time = $time - $_lag_seconds;
- }
-
- $month = date('n', $time);
- $year = date('Y',$time);
-
- $this->min_period = sprintf("%s%02d",$year,$month);
-
- }
-
- protected function cleanup_old()
- {
- $this->db->transaction_begin();
- $date = date($this->db->datetime_format(),time());
- $sql= "UPDATE fm_ecobilag SET saksigndato = '{$date}',
saksbehandlerid = 'admin' WHERE external_ref IS NULL AND saksigndato IS NULL";
-//_debug_array($sql);
- $this->db->query($sql,__LINE__,__FILE__);
- $sql= "UPDATE fm_ecobilag SET budsjettsigndato =
'{$date}', budsjettansvarligid = 'admin' WHERE external_ref IS NULL AND
budsjettsigndato IS NULL";
-//_debug_array($sql);
- $this->db->query($sql,__LINE__,__FILE__);
- $sql= "UPDATE fm_ecobilag SET utbetalingsigndato =
'{$date}', utbetalingid = 'admin' WHERE external_ref IS NULL AND
utbetalingsigndato IS NULL";
-//_debug_array($sql);
- $this->db->query($sql,__LINE__,__FILE__);
- $this->overfor('on');
-
- $sql= "SELECT min(bilagsnr) as bilagsnr FROM
fm_ecobilagoverf";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $bilagsnr = (int)$this->db->f('bilagsnr');
- if($bilagsnr)
- {
- $correction = $bilagsnr -1;
- $sql= "UPDATE fm_ecobilagoverf SET bilagsnr =
bilagsnr - {$correction}";
-//_debug_array($sql);
- $this->db->query($sql,__LINE__,__FILE__);
- }
- $this->db->transaction_commit();
- }
-
- protected function select_vouchers_to_transfer()
- {
-
if(isset($this->config->config_data['common']['invoice_approval']) &&
$this->config->config_data['common']['invoice_approval']== 1)
- {
- $sql= "SELECT DISTINCT fm_ecobilag.bilagsnr
FROM fm_ecobilag {$this->join} fm_ecobilag_sum_view ON fm_ecobilag.bilagsnr =
fm_ecobilag_sum_view.bilagsnr WHERE approved_amount = '0.00' OR
budsjettsigndato IS NOT NULL ORDER BY bilagsnr ASC";
- }
- else
- {
- $sql= "SELECT DISTINCT fm_ecobilag.bilagsnr
FROM fm_ecobilag {$this->join} fm_ecobilag_sum_view ON fm_ecobilag.bilagsnr =
fm_ecobilag_sum_view.bilagsnr WHERE approved_amount = '0.00' OR (
budsjettsigndato IS NOT NULL AND (saksigndato IS NOT NULL OR oppsynsigndato IS
NOT NULL) ) ORDER BY bilagsnr ASC";
- }
- $this->db->query($sql,__LINE__,__FILE__);
- $vouchers_step1 = array();
- while ($this->db->next_record())
- {
- $vouchers_step1[] =
$this->db->f('bilagsnr');
- }
-
- //Filter out partially approved
- $vouchers = array();
- foreach($vouchers_step1 as $bilagsnr)
- {
- $sql = "SELECT bilagsnr FROM fm_ecobilag WHERE
bilagsnr = {$bilagsnr} AND budsjettsigndato IS NULL";
- $this->db->query($sql,__LINE__,__FILE__);
- if( !$this->db->next_record() )
- {
- $vouchers[] = $bilagsnr;
- }
- }
-
-
- //Add vouchers with split-line and approved amount =
0.00
- $extra_candidates = array();
- $sql = "SELECT DISTINCT bilagsnr FROM fm_ecobilag WHERE
(godkjentbelop = '0' OR godkjentbelop = '0.00') AND budsjettsigndato IS NULL";
- $this->db->query($sql,__LINE__,__FILE__);
- while( $this->db->next_record() )
- {
- $extra_candidates[] =
$this->db->f('bilagsnr');
- }
-
- foreach($extra_candidates as $extra_candidate)
- {
- if(in_array($extra_candidate, $vouchers))
- {
- continue;
- }
-
- $sql = "SELECT
bilagsnr,oppsynsigndato,saksigndato,budsjettsigndato FROM fm_ecobilag WHERE
bilagsnr = {$extra_candidate} AND (godkjentbelop > 0 OR godkjentbelop < 0)";
-
- $this->db->query($sql,__LINE__,__FILE__);
- $transfer_extra = true;
- while( $this->db->next_record() )
- {
- $oppsynsigndato =
$this->db->f('oppsynsigndato');
- $saksigndato =
$this->db->f('saksigndato');
- $budsjettsigndato =
$this->db->f('budsjettsigndato');
-
-
if(isset($this->config->config_data['common']['invoice_approval']) &&
$this->config->config_data['common']['invoice_approval']== 1)
- {
- if(!$budsjettsigndato)
- {
- $transfer_extra = false;
- }
- }
- else
- {
- if (!$budsjettsigndato)
- {
- $transfer_extra = false;
- }
- else if ($budsjettsigndato &&
!$saksigndato && !$oppsynsigndato)
- {
- $transfer_extra = false;
- }
- }
- }
-
- if($transfer_extra)
- {
- $vouchers[] = $extra_candidate;
- }
- }
-
- return $vouchers;
- }
-
- protected 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__);
- }
-
- protected 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__);
- }
-
- protected 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();
- $batchid = $this->db->f('value');
- return $batchid;
- }
-
- protected 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
- protected function log_start($batchid)
- {
- $tid = date($this->db->datetime_format());
- $sql= "INSERT INTO fm_ecologg (batchid,melding,tid)
VALUES ('$batchid','Start transfer','$tid')";
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
- protected 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;
- }
-
- protected function get_order_info($order_id='')
- {
- $order_info = array();
- $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, category FROM
fm_workorder WHERE id='$order_id'";
-
$this->db->query($sql2,__LINE__,__FILE__);
- $this->db->next_record();
- $order_info['title'] =
$this->db->f('title');
- $cat_id = (int)$this->db->f('category');
- $category =
$this->cats->return_single($cat_id);
- $category_arr =
explode('-',$category[0]['name']);
- $order_info['category'] =
(int)trim($category_arr[0]);
- 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_info['title'] =
$this->db->f('title');
- break;
- }
-
- return $order_info;
- }
-
-
- protected function select_invoice_rollback($date,
$Filnavn,$rollback_voucher,$rollback_internal_voucher)
- {
- $date_array = phpgwapi_datetime::date_array($date);
- $day = $date_array['day'];
- $month = $date_array['month'];
- $year = $date_array['year'];
-
- 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':
- $datepart_year =
"date_part('year',overftid)";
- $datepart_month =
"date_part('month',overftid)";
- $datepart_day =
"date_part('day',overftid)";
- break;
- case 'postgres':
- $datepart_year =
"date_part('year',overftid)";
- $datepart_month =
"date_part('month',overftid)";
- $datepart_day =
"date_part('day',overftid)";
- break;
- }
-
- if($rollback_voucher)
- {
- $rollback_voucher = (int)$rollback_voucher;
- $sql="SELECT * FROM fm_ecobilagoverf WHERE
bilagsnr_ut = {$rollback_voucher} AND manual_record IS NULL";
- }
- else if($rollback_internal_voucher)
- {
- $rollback_internal_voucher =
(int)$rollback_internal_voucher;
- $sql="SELECT * FROM fm_ecobilagoverf WHERE
bilagsnr = {$rollback_internal_voucher} AND manual_record IS NULL";
- }
- else
- {
- $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__);
-
- $invoice_rollback = array();
- while ($this->db->next_record())
- {
- $invoice_rollback[] = array
- (
- 'id'
=> $this->db->f('id'),
- 'bilagsnr'
=> $this->db->f('bilagsnr'),
- 'bilagsnr_ut' =>
$this->db->f('bilagsnr_ut'),
- 'kidnr'
=> $this->db->f('kidnr'),
- 'typeid'
=> $this->db->f('typeid'),
- 'kildeid'
=> $this->db->f('kildeid'),
- 'pmwrkord_code' =>
$this->db->f('pmwrkord_code'),
- 'belop'
=> $this->db->f('belop'),
- 'fakturadato' =>
$this->db->f('fakturadato'),
- 'periode'
=> $this->db->f('periode'),
- 'periodization' =>
$this->db->f('periodization'),
- 'periodization_start' =>
$this->db->f('periodization_start'),
- 'forfallsdato' =>
$this->db->f('forfallsdato'),
- 'fakturanr'
=> $this->db->f('fakturanr'),
- 'spbudact_code' =>
$this->db->f('spbudact_code'),
- 'regtid'
=> $this->db->f('regtid'),
- 'artid'
=> $this->db->f('artid'),
- 'godkjentbelop' =>
(int) $this->db->f('godkjentbelop') == 0 ? $this->db->f('belop') :
$this->db->f('godkjentbelop'),//restore original amount
- 'spvend_code' =>
$this->db->f('spvend_code'),
- 'dima'
=> $this->db->f('dima'),
- 'loc1'
=> $this->db->f('loc1'),
- 'dimb'
=> $this->db->f('dimb'),
- 'mvakode'
=> $this->db->f('mvakode'),
- 'dimd'
=> $this->db->f('dimd'),
- 'dime'
=> $this->db->f('dime'),
- 'project_id' =>
$this->db->f('project_id'),
- 'kostra_id'
=> $this->db->f('kostra_id'),
- 'item_type'
=> $this->db->f('item_type'),
- 'item_id'
=> $this->db->f('item_id'),
- 'oppsynsmannid' =>
$this->db->f('oppsynsmannid'),
- 'saksbehandlerid' =>
$this->db->f('saksbehandlerid'),
- 'budsjettansvarligid' =>
$this->db->f('budsjettansvarligid'),
- 'oppsynsigndato' =>
$this->db->f('oppsynsigndato'),
- 'saksigndato' =>
$this->db->f('saksigndato'),
- // 'budsjettsigndato' =>
$this->db->f('budsjettsigndato'), // må anvises på nytt etter tilbakerulling
- 'merknad'
=> $this->db->f('merknad',true),
- 'line_text'
=> $this->db->f('line_text',true),
- 'splitt'
=> $this->db->f('splitt'),
- 'ordrebelop' =>
$this->db->f('ordrebelop'),
- // 'utbetalingid' =>
$this->db->f('utbetalingid'),
- // 'utbetalingsigndato' =>
$this->db->f('utbetalingsigndato'),
- 'external_ref' =>
$this->db->f('external_ref'),
- 'currency'
=> $this->db->f('currency'),
- 'process_log' =>
$this->db->f('process_log',true),
- 'process_code' =>
$this->db->f('process_code'),
-
- );
- }
-
- return $invoice_rollback;
- }
-
- //rollback function
- protected function bilag_update_overf($BilagOverf)
- {
- $values= array
- (
- $BilagOverf['project_id'],
- $BilagOverf['kostra_id'],
- $BilagOverf['pmwrkord_code'],
- $BilagOverf['bilagsnr'],
- $BilagOverf['bilagsnr_ut'],
- $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['dime'],
- $BilagOverf['mvakode'],
- $BilagOverf['periode'],
- $BilagOverf['periodization'],
- $BilagOverf['periodization_start'],
-
$this->db->db_addslashes($BilagOverf['merknad']),
-
$this->db->db_addslashes($BilagOverf['line_text']),
- $BilagOverf['utbetalingid'],
- $BilagOverf['oppsynsigndato'],
- $BilagOverf['saksigndato'],
- $BilagOverf['budsjettsigndato'],
- $BilagOverf['utbetalingsigndato'],
- $BilagOverf['item_type'],
- $BilagOverf['item_id'],
- $BilagOverf['external_ref'],
- $BilagOverf['belop'],
- $BilagOverf['godkjentbelop'],
- $BilagOverf['currency'],
-
$this->db->db_addslashes($BilagOverf['process_log']),
- $BilagOverf['process_code'],
- );
-
- $values = $this->db->validate_insert($values);
-
- $sql= "INSERT INTO fm_ecobilag
(project_id,kostra_id,pmwrkord_code,bilagsnr,bilagsnr_ut,splitt,kildeid,kidnr,typeid,"
- . "
fakturadato,forfallsdato,regtid,artid,spvend_code,dimb,oppsynsmannid,"
- . "
saksbehandlerid,budsjettansvarligid,fakturanr,spbudact_code,dima,loc1,dimd,dime,mvakode,"
- . "
periode,periodization,periodization_start,merknad,line_text,utbetalingid,oppsynsigndato,saksigndato,budsjettsigndato,utbetalingsigndato,"
- . "
item_type,item_id,external_ref,belop,godkjentbelop,currency,process_log,process_code)"
- . " VALUES ({$values})";
-
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
- public function overfor($download,$force_period_year='')
- {
-// $download = 'on';
-// $download = False;
-// $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 hoved bilag som skal overføres
- $vouchers = $this->select_vouchers_to_transfer();
-
- foreach ($vouchers as $voucher_id)
- {
- $receipt['message'][]= array('msg' =>
$this->transfer_voucher($batchid, $voucher_id, $download, $force_period_year));
- }
-
- if($this->connection)
- {
- switch
($this->config->config_data['common']['method'])
- {
- case 'ftp';
- ftp_quit($this->connection);
- break;
- case 'ssh';
- ssh2_exec($this->connection,
'exit');
- break;
- }
- }
- //Lagre melding
- if ($download=='on')
- {
- $this->log_end($batchid); //Lagre melding
- }
-
- return $receipt;
- }
-
- protected function errorhandler($batchid,$error_desr)
- {
- if($this->db->get_transaction())
- {
- $this->db->transaction_abort();
- }
-
- $meld = $error_desr;
-
- //Vis feilmelding
- echo $meld;
-
- //Lagre feilmelding
- $this->log_error($batchid,$error_desr);
- }
-
- public function RullTilbake($Filnavn,
$date,$rollback_voucher,$rollback_internal_voucher)
- {
- $voucher = $this->select_invoice_rollback($date,
$Filnavn,$rollback_voucher,$rollback_internal_voucher);
-
- if ( $this->db->get_transaction() )
- {
- $this->global_lock = true;
- }
- else
- {
- $this->global_lock = false;
- $this->db->transaction_begin();
- }
-
- foreach ($voucher as $line)
- {
- $this->bilag_update_overf($line);
-
- if($line['pmwrkord_code'])
- {
-
$orders_affected[$line['pmwrkord_code']] = true;
-
- $Belop = sprintf("%01.2f",
$line['ordrebelop'])*100;
-
- if ($line['dimd'] % 2 == 0)
- {
-
$actual_cost_field='act_mtrl_cost';
- }
- else
- {
-
$actual_cost_field='act_vendor_cost';
- }
-
- $operator='-';
-
-
$this->soXport->correct_actual_cost($line['pmwrkord_code'],$Belop,$actual_cost_field,$operator);
- }
-
- //Slett fra avviks tabell
- // $this->soXport->delete_avvik($line['bilagsnr']);
-
- //Slett fra arkiv
-
$this->soXport->delete_invoice($line['bilagsnr']);
- }
-
- $antall = count($voucher);
- if($antall > 0)
- {
- $fil_katalog =
$this->config->config_data['export']['path'];
-
- if($rollback_voucher ||
$rollback_internal_voucher)
- {
- if ( !$this->global_lock )
- {
- $this->db->transaction_commit();
- }
-
- $receipt['message'][]= array('msg' =>
$antall . ' ' . lang('bilag/underbilag rullet tilbake'));
- }
- else if(unlink ($fil_katalog. '/' . $Filnavn))
- {
- if ( !$this->global_lock )
- {
- $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['error'][]= array('msg' =>
'Noe gikk galt!');
- }
- }
- else
- {
- if ( !$this->global_lock )
- {
- $this->db->transaction_commit();
- }
-
- $receipt['error'][]= array('msg' => lang('Sorry
- No hits'));
- }
- return $receipt;
- }
-
- protected function LagFilnavn ($external_ref = '')
- {
- if(!$external_ref)
- {
- $external_ref = mt_rand();
- }
- $fil_katalog =
$this->config->config_data['export']['path'];
- $continue = True;
- $Filnavn = $fil_katalog .
"/x114_14_{$external_ref}.xml";
-
- //Sjekk om filen eksisterer
- if (file_exists($Filnavn))
- {
- unlink($Filnavn);
- }
-
- return $Filnavn;
- }
-
- protected function transfer_voucher($batchid, $voucher_id,
$download, $force_period_year = '')
- {
- $oRsBilag = $this->soXport->get_voucher($voucher_id);
-
- $skip_basware = false;
- if(!isset($oRsBilag[0]['external_ref']) ||
!$oRsBilag[0]['external_ref'])
- {
- $skip_basware = true;
- }
-
- //Bestem filnavn
- $Filnavn =
$this->LagFilnavn($oRsBilag[0]['external_ref']);
-
- if (!$Filnavn)
- {
- $message='LagFilnavn: Filnavn er i bruk';
- $this->errorhandler($batchid,$message);
- return $message;
- }
-
- //Test om filen kan opprettes og skrives til
- if(!$skip_basware)
- {
- if (@fopen($Filnavn, "wb"))
- {
- unlink($Filnavn);
- }
- else
- {
- $message='kan ikke lagre til fil: '.
$Filnavn .'<br>';
- if($this->debug)
- {
- echo $message;
- }
- else
- {
- return $message;
- }
- }
- }
-
- $antall = count($oRsBilag);
-
- if ( $this->db->get_transaction() )
- {
- $this->global_lock = true;
- }
- else
- {
- $this->db->transaction_begin();
- }
-
- $bilagsnr_ut = $oRsBilag[0]['bilagsnr_ut'];
- if(!$bilagsnr_ut)
- {
- $get_bilagsnr_ut = false;
- foreach ($oRsBilag as $line)
- {
- if(abs($line['godkjentbelop']) > 0)
- {
- $get_bilagsnr_ut = true;
- }
- }
-
- if($get_bilagsnr_ut)
- {
- $bilagsnr_ut =
$this->increment_voucher_id();
- }
- }
-
- $tranfser_bilag = $bilagsnr_ut ? array($bilagsnr_ut) :
array($voucher_id);
-
- $localtime = phpgwapi_datetime::user_localtime();
-
- $transactioninformation = array
- (
- 0 => array
- (
- 'TRANSACTIONTYPE' => 'X114',
- 'TRANSFER' => array
- (
- 0 => array
- (
- 'TRANSFERDATE' =>
date('d.m.Y', $localtime),//28.05.2009
- 'TRANSFERTIME' =>
date('H:i:s', $localtime)//14:29:52
- )
- )
- )
- );
-
- $invoiceheader = array
- (
- 0 => array
- (
- 'TRANSACTIONTYPE'
=> 'X114',
- 'KEY'
=> '', //dummy
- 'VOUCHERID'
=> $bilagsnr_ut,
- 'SCANNINGNO'
=> $oRsBilag[0]['external_ref'], // 11E28NJINL3VR6
- 'PROFILE'
=> 'TRAINVPOMA',
- 'CLIENT.CODE'
=> $this->client_code, //14,
- 'POATTRIB1'
=> '', //dummy
- 'POATTRIB2'
=> '', //dummy
- 'POPURCHASER'
=> '', //dummy
- 'PREVOUCHERID'
=> '', //dummy
- 'PURCHASEORDERNO'
=> $oRsBilag[0]['order_id'], // 1409220008
- 'PURCHASEORDEROWNER.CODE' =>
$oRsBilag[0]['spvend_code'], // 100644
- 'PURCHASEORDERSTATUS.CODE' => 'OK',
- 'GENERALCOMMENT'
=> $comment, // Denne er fakturert i 3 deler OBS OBS!
- )
- );
-
- $accountline = array();
-
- if ( $oRsBilag[0]['periode'] )
- {
- if((int)$this->min_period <
(int)$oRsBilag[0]['periode'])
- {
- $periode = $this->min_period;
- }
- else
- {
- $periode = $oRsBilag[0]['periode'];
- }
- }
- else if
(isset($this->config->config_data['export']['dato_aarsavslutning']) && time() <
$this->config->config_data['export']['dato_aarsavslutning'] )
- {
- if(date('Y',time()) == date('Y',
$this->config->config_data['export']['dato_aarsavslutning']))
- {
- $periode = date('Y',time()) - 1 . '12';
- }
- else
- {
- $periode = date('Ym',time());
- }
- }
- else
- {
- $time = time();
-
- if ( date('j',$time) < 7 ) //Day of the month
without leading zeros
- {
- $time = $time - (7 * 24 * 3600);
- }
-
- $periode = date('Ym',$time);
- }
-
- $comment = array();
- foreach ($oRsBilag as $line)
- {
- $comment[] =
"{$line['belop']}::{$line['process_log']}";
-
- $BelopFelt = 'godkjentbelop';
-
-/*
- //Bestem belops felt
- if ($line['splitt'] == 0)
- {
- //Bilaget er ikke splittet
- if ($line['godkjentbelop'] <>
$line['belop'])
- {
- $BelopFelt = 'godkjentbelop';
- //Logg til avviks tabell
- if ($download=='on')
- {
-//
$this->soXport->log_to_deviation_table($line);
- }
- }
- else
- {
- $BelopFelt = 'belop';
- }
- }
-
-*/
- //Bilaget er splittet
-/*
- if ($line['godkjentbelop'] == $line['belop'])
- {
- $BelopFelt = 'godkjentbelop';
- }
- else
- {
- //Ikke lovlig
- $message = lang('Avvik mellom
fakturabelop og godkjent belop pa splittet faktura!');
- $this->errorhandler($batchid,$message);
- return $message;
- }
-*/
- $amount = $line[$BelopFelt] * 100;
- $amount = number_format($amount,0,'','');
-
- if($line['order_id'])
- {
- $orders_affected[$line['order_id']] =
true;
-
- //Oppdater beløp på arbeidsordre
- if ($download=='on')
- {
- if ($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($line['order_id'],$amount,
$actual_cost_field,$operator);
- }
- }
- }
-
- $oRsOverfBilag
= $line;
- $oRsOverfBilag['filnavn'] =
$Filnavn? basename($Filnavn) : date('d.m.Y-H:i:s',
phpgwapi_datetime::user_localtime());
- $oRsOverfBilag['ordrebelop'] =
$line[$BelopFelt];
- $oRsOverfBilag['pmwrkord_code'] =
$line['order_id'];
- $oRsOverfBilag['bilagsnr_ut'] = $bilagsnr_ut;
- $oRsOverfBilag['periode'] =
$periode;
-
- if($line['dime'])
- {
- $category =
$this->cats->return_single($line['dime']);
- $category_arr =
explode('-',$category[0]['name']);
- $dim6 =
(int)trim($category_arr[0]);
- }
- else
- {
- $dim6 = '';
- }
-
- //Kopier verdier til fm_ecobilagoverf
- if ($download=='on' && !$this->debug)
- {
-
$this->soXport->add_OverfBilag($oRsOverfBilag);
- }
-
- if ($line['order_id'])
- {
- $order_info =
$this->get_order_info($line['order_id']);
- if(!$dim6)
- {
- $dim6 =
isset($order_info['category']) && $order_info['category'] ?
$order_info['category'] : '';
- }
- }
-
- $descr = '';
- if($line['line_text'])
- {
- $descr =
substr($line['line_text'],0,60);
- }
- else if ($line['order_id'])
- {
- $descr =
substr($order_info['title'],0,60);
- }
-
- $accountline[] = array
- (
- 'TRANSACTIONTYPE' =>
'R114',
- 'ACCOUNTLINK.CODE' =>
$line['spbudact_code'], // 4180
- 'AMOUNT'
=> $amount, // 312500
- 'APPROVER.FULLNAME' =>
$line['budsjettansvarligid'], //Batch 04 - 14
- 'DIMENSION.D1.CODE' =>
$line['dimb'], // 1111
- 'DIMENSION.D2.CODE' =>
'',//$line['dima'], // 62000
- 'DIMENSION.D3.CODE' => '',
- 'DIMENSION.D4.CODE' =>
$line['project_id'], // dummy
- 'DIMENSION.D5.CODE' =>
$dim5, // dummy
- 'DIMENSION.D6.CODE' =>
$dim6, // dummy
- 'DIMENSION.D7.CODE' =>
$dim7, // dummy
- 'DIMENSION.D8.CODE' =>
$dim8, // dummy
- 'POITEMDESCRIPTION' =>
$descr, // Sugerør,plast,fleksibelt,20cm
- 'POITEMNUMBER' =>
$itemnumber, //200200
- 'POITEMTYPE' => 'C',
// A = Item, B = Special Product (SP), C = Text based (Misc.)
- 'POLINENUMBER' =>
$linenumber, // 10
- 'RECEIVER.FULLNAME' =>
$line['budsjettansvarligid'], // Batch 04 - 14
- 'STATUS'
=> 5,
- 'SUBACCOUNT' =>
$periode, //200905 Accounting period YYYYMM
- 'ALLOCATION.KEY' =>
$line['periodization'],//0
- 'ALLOCATION.PERIOD' =>
$line['periodization_start'] //dummy
- );
-
- }
-
- $invoiceheader[0]['GENERALCOMMENT'] =
implode("\n",$comment);
- $invoices = array
- (
- 0 => array
- (
- 'INVOICE' => array
- (
- 0 => array
- (
- 'INVOICEHEADER' =>
$invoiceheader,
- 'ACCOUNTLINES' => array
- (
- 0 => array
- (
-
'ACCOUNTLINE' => $accountline
- )
- )
- )
- )
- )
- );
-
- $export_data = array
- (
- 'TRANSACTIONINFORMATION' =>
$transactioninformation,
- 'INVOICES'
=> $invoices
- );
-
- $xmltool = CreateObject('phpgwapi.xmltool');
-
- $buffer = $xmltool->import_var('INVOICEIMPORT',
$export_data,true, true);
- $buffer = str_replace('<INVOICEIMPORT>',
'<INVOICEIMPORT TYPE="INVOICE">', $buffer);
-
- //Slett bilaget i fm_ecobilag
- if ($download=='on' && !$this->debug)
- {
- $this->_delete_from_fm_ecobilag($voucher_id);
- //Logg transaksjon
-
$this->soXport->log_transaction($batchid,$voucher_id,lang('Invoice
transferred'));
- }
-
- //Fullfør transaksjon
- if ($download=='on' && !$this->debug)
- {
- // $file_written = true;
-
- // -- Start
-
- if($skip_basware)
- {
- if ( !$this->global_lock )
- {
- $this->db->transaction_commit();
- }
- $message = "Antall bilag/underbilag
overført til historikk (ikke til Basware): {$antall}";
- return $message;
- }
-
- $file_written = false;
- $fp = fopen($Filnavn, "wb");
- fwrite($fp,$buffer);
-
- if(fclose($fp))
- {
- $file_written=true;
- }
-
- // -- END
- if( $file_written &&
($this->config->config_data['common']['method'] != 'ftp' &&
$this->config->config_data['common']['method'] != 'ssh'))
- {
- $transfer_ok = true;
- }
- else if($file_written)
- {
- $transfer_ok =
$this->transfer($buffer,$Filnavn,$batchid,$tranfser_bilag);
- }
-
- if($transfer_ok)
- {
-
$this->soXport->update_actual_cost_from_archive($this->orders_affected);
-
- if ( !$this->global_lock )
- {
- $this->db->transaction_commit();
- }
-
- $message = "Antall bilag/underbilag
overfort: {$antall}, fil: {$Filnavn}";
- }
- else
- {
- $this->db->transaction_abort();
- $message = 'Noe gikk galt med
overforing av godkjendte fakturaer!';
- }
- }
- else
- {
- $message = $buffer;
- $this->db->transaction_abort();
-
- }
-
- return $message;
- }
-
- protected function increment_voucher_id()
- {
- $name = 'bilagsnr_ut';
- $now = time();
- $this->db->query("SELECT value, start_date FROM
fm_idgenerator WHERE name='{$name}' AND start_date < {$now} ORDER BY start_date
DESC");
- $this->db->next_record();
- $next_id = $this->db->f('value') +1;
- $start_date = (int)$this->db->f('start_date');
- $this->db->query("UPDATE fm_idgenerator SET value =
$next_id WHERE name = '{$name}' AND start_date = {$start_date}");
-
- return $next_id;
- }
-
- protected function _delete_from_fm_ecobilag($bilagsnr)
- {
- $bilagsnr = (int) $bilagsnr;
- $sql="DELETE FROM fm_ecobilag WHERE bilagsnr =
$bilagsnr";
- $this->db->query($sql,__LINE__,__FILE__);
- }
-
- protected function
transfer($buffer,$Filnavn,$batchid,$tranfser_bilag)
- {
- $transfer_ok = false;
-
if($this->config->config_data['common']['method']=='ftp' ||
$this->config->config_data['common']['method']=='ssh')
- {
- if(!$connection = $this->connection)
- {
- $connection =
$this->phpftp_connect();
- }
-
- $basedir =
$this->config->config_data['export']['remote_basedir'];
- if($basedir)
- {
- $remote_file = $basedir . '/' .
basename($Filnavn);
- }
- else
- {
- $remote_file = basename($Filnavn);
- }
-
- switch
($this->config->config_data['common']['method'])
- {
- case 'ftp';
- $transfer_ok =
ftp_put($connection,$remote_file, $Filnavn, FTP_BINARY);
- break;
- case 'ssh';
- $sftp = ssh2_sftp($connection);
- $stream =
@fopen("ssh2.sftp://$sftp$remote_file", 'w');
- $data_to_send =
@file_get_contents($Filnavn);
- fwrite($stream, $data_to_send);
- $transfer_ok = @fclose($stream);
- break;
- default:
- $transfer_ok = false;
- }
- if ($transfer_ok)
- {
- for
($i=0;$i<count($tranfser_bilag);$i++)
- {
-
$this->soXport->log_transaction($batchid,$tranfser_bilag[$i],lang('Invoice
transferred %1 to Basware',basename($Filnavn)));
- }
- }
- else
- {
- for
($i=0;$i<count($tranfser_bilag);$i++)
- {
-
$this->soXport->log_transaction($batchid,$tranfser_bilag[$i],lang('Failed to
transfere %1 to Basware',basename($Filnavn)));
- }
- }
- if(!$transfer_ok)
- {
- unlink($Filnavn);
- }
- }
- return $transfer_ok;
- }
-
- protected function phpftp_connect()
- {
- $server =
$this->config->config_data['common']['host'];
- $user =
$this->config->config_data['common']['user'];
- $password =
$this->config->config_data['common']['password'];
- $port = 22;
-
- switch ($this->config->config_data['common']['method'])
- {
- case 'ftp';
- if($connection = ftp_connect($server))
- {
-
ftp_login($connection,$user,$password);
- }
- break;
- case 'ssh';
- if (!function_exists("ssh2_connect"))
- {
- die("function ssh2_connect
doesn't exist");
- }
- if(!($connection =
ssh2_connect("$server", $port)))
- {
- $message = "fail: unable to
establish connection";
- _debug_array($message);
- //$receipt['error'][]=
array('msg' => $message);
- }
- else
- {
- // try to authenticate with
username root, password secretpassword
-
if(!ssh2_auth_password($connection, $user, $password))
- {
- $message = "fail:
unable to authenticate";
- _debug_array($message);
- //$receipt['error'][]=
array('msg' => $message);
- }
- }
- break;
- }
- $this->connection = $connection;
- return $connection;
- }
- }
Modified: branches/Version-1_0-branch/property/setup/tables_update.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/tables_update.inc.php
2014-01-09 13:56:06 UTC (rev 11592)
+++ branches/Version-1_0-branch/property/setup/tables_update.inc.php
2014-01-09 13:59:35 UTC (rev 11593)
@@ -7855,6 +7855,9 @@
$GLOBALS['phpgw_setup']->oProc->query("ALTER TABLE fm_budget
DROP CONSTRAINT fm_budget_year_key");
$GLOBALS['phpgw_setup']->oProc->query("ALTER TABLE fm_budget
ADD CONSTRAINT fm_budget_year_key UNIQUE(year , b_account_id , district_id ,
revision, ecodimb ,category)");
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('fm_department','name',
array('type' => 'varchar','precision' => '200','nullable' => False));
+
+
if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
{
$GLOBALS['setup_info']['property']['currentver'] =
'0.9.17.676';
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11593] Merge 11588:11592 from trunk,
Sigurd Nes <=