fmsystem-commits
[Top][All Lists]
Advanced

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

[Fmsystem-commits] [11758] Merge 11740:11757 from trunk


From: Sigurd Nes
Subject: [Fmsystem-commits] [11758] Merge 11740:11757 from trunk
Date: Wed, 26 Feb 2014 13:42:16 +0000

Revision: 11758
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11758
Author:   sigurdne
Date:     2014-02-26 13:42:16 +0000 (Wed, 26 Feb 2014)
Log Message:
-----------
Merge 11740:11757 from trunk

Modified Paths:
--------------
    branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php
    branches/Version-1_0-branch/property/inc/class.soXport.inc.php
    branches/Version-1_0-branch/property/inc/class.soproject.inc.php
    branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
    branches/Version-1_0-branch/property/inc/class.uitts.inc.php
    branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php

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


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

Modified: branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php  
2014-02-26 13:37:14 UTC (rev 11757)
+++ branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php  
2014-02-26 13:42:16 UTC (rev 11758)
@@ -822,7 +822,12 @@
                                        $receipt['message'] = 
array_merge($receipt['message'] , $receipt_claim['message']);
                                }
                        }
-
+                       if ($workorder['id'])
+                       {
+                               //temporary
+                               
execMethod('property.soXport.update_actual_cost_from_archive',array($workorder['id']
 => true));
+                               
$this->notify_coordinator_on_consumption($workorder['id']);
+                       }
                        return $receipt;
                }
 
@@ -855,4 +860,132 @@
                {
                        $this->so->recalculate();
                }
+
+               /**
+                * Check the consumption  on an order - and notify the 
coordinator
+                * @param integer $order_id
+                */
+               function notify_coordinator_on_consumption($order_id)
+               {
+                       $notify_coordinator = true;
+                       if(!$notify_coordinator)
+                       {
+                               return false;
+                       }
+                       $toarray = array();
+                       $workorder      = $this->so->read_single($order_id);
+
+                       if(!$workorder['continuous'])
+                       {
+                               return false;
+                       }
+
+                       $project        = 
ExecMethod('property.boproject.read_single_mini',$workorder['project_id']);
+                       $coordinator = $project['coordinator'];
+                       $prefs_coordinator = 
$this->bocommon->create_preferences('property',$coordinator);
+                       if(isset($prefs_coordinator['email']) && 
$prefs_coordinator['email'])
+                       {
+                               $toarray[] = $prefs_coordinator['email'];
+                       }
+
+                       if ($toarray)
+                       {
+                               $budget_info = 
$this->so->get_order_budget_percent($order_id);
+
+                               if($budget_info['percent'] < 90)
+                               {
+                                       return false;
+                               }
+
+                               
if(isset($GLOBALS['phpgw_info']['user']['preferences']['property']['email']) && 
$GLOBALS['phpgw_info']['user']['preferences']['property']['email'])
+                               {
+                                       
$from_name=$GLOBALS['phpgw_info']['user']['fullname'];
+                                       
$from_email=$GLOBALS['phpgw_info']['user']['preferences']['property']['email'];
+                               }
+                               else
+                               {
+                                       $from_name       = 'noreply';
+                                       $from_email      = 
"{$from_name}<address@hidden>";
+                               }
+
+                               $subject         = "Bestilling # {$order_id} 
har disponert {$budget_info['percent']} prosent av budsjettet";
+
+                               $lang_budget = lang('budget');
+                               $lang_actual_cost = lang('actual cost');
+                               $lang_percent = lang('percent');
+                               $lang_obligation = lang('obligation');
+
+                               $_budget = 
number_format($budget_info['budget'], 0, ',', ' ');
+                               $_actual_cost = 
number_format($budget_info['actual_cost'], 0, ',', ' ');
+                               $_budget = 
number_format($budget_info['budget'], 0, ',', ' ');
+                               $_obligation = 
number_format($budget_info['obligation'], 0, ',', ' ');
+
+                               $to = implode(';',$toarray);
+                               $cc = false;
+                               $bcc = 'address@hidden';//test phase
+                               $body = '<a href ="' . 
$GLOBALS['phpgw']->link('/index.php',array('menuaction'=> 
'property.uiworkorder.edit','id'=> $order_id),false,true).'">' . 
lang('workorder %1 has been edited',$order_id) .'</a>' . "\n";
+                               $body .= <<<HTML
+                               </br>
+                               <h2>{$workorder['title']}</h2>
+                               </br>
+                               </br>
+                               <table>
+                                       <tr>
+                                               <td>
+                                                       {$lang_budget}
+                                               </td>
+                                               <td align = 'right'>
+                                                       {$_budget}
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td>
+                                                       {$lang_actual_cost}
+                                               </td>
+                                               <td align = 'right'>
+                                                       {$_actual_cost}
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td>
+                                                       {$lang_percent}
+                                               </td>
+                                               <td align = 'right'>
+                                                       
{$budget_info['percent']}
+                                               </td>
+                                       </tr>
+                                       <tr>
+                                               <td>
+                                                       {$lang_obligation}
+                                               </td>
+                                               <td align = 'right'>
+                                                       {$_obligation}
+                                               </td>
+                                       </tr>
+                               </table>
+HTML;
+
+                               if (!is_object($GLOBALS['phpgw']->send))
+                               {
+                                       $GLOBALS['phpgw']->send = 
CreateObject('phpgwapi.send');
+                               }
+
+                               try
+                               {
+                                       $ok = 
$GLOBALS['phpgw']->send->msg('email',$to,$subject,$body, false,$cc,$bcc, 
$from_email, $from_name, 'html');
+                               }
+                               catch (phpmailerException $e)
+                               {
+                                       phpgwapi_cache::message_set( 
$e->getMessage(), 'error' );
+                               }
+
+                               if($ok)
+                               {
+                                       $historylog     = 
CreateObject('property.historylog','workorder');
+                                       $historylog->add('ON', $order_id, 
lang('%1 is notified',$to));
+                                       $historylog->add('RM', $order_id, 
$subject);
+                                       return true;
+                               }
+                       }
+               }
        }

Modified: branches/Version-1_0-branch/property/inc/class.soXport.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soXport.inc.php      
2014-02-26 13:37:14 UTC (rev 11757)
+++ branches/Version-1_0-branch/property/inc/class.soXport.inc.php      
2014-02-26 13:42:16 UTC (rev 11758)
@@ -42,6 +42,7 @@
                var $bilagsnr;
                var $voucher_id;
                protected $global_lock = false;
+               var $debug = false;
 
                function __construct()
                {
@@ -238,7 +239,7 @@
                                                $fields['pmwrkord_code'],
                                                $fields['bilagsnr'],
                                                $fields['bilagsnr_ut'],
-                                               $fields['splitt'],
+                                               isset($fields['splitt']) && 
$fields['splitt'] ? $fields['splitt'] : false,
                                                $fields['kildeid'],
                                                $fields['kidnr'],
                                                $fields['typeid'],
@@ -255,20 +256,20 @@
                                                $fields['spbudact_code'],
                                                $fields['loc1'],
                                                $fields['dima'],
-                                               $fields['dimd'],
-                                               $fields['dime'],
+                                               isset($fields['dimd']) && 
$fields['dimd'] ? $fields['dimd'] : false,
+                                               isset($fields['dime']) && 
$fields['dime'] ? $fields['dime'] : false,
                                                $fields['mvakode'],
                                                $fields['periode'],
                                                
$this->db->db_addslashes($fields['merknad']),
-                                               
$this->db->db_addslashes($fields['line_text']),
+                                               isset($fields['line_text']) && 
$fields['line_text'] ? $this->db->db_addslashes($fields['line_text']) : false,
                                                false,
                                                false,
                                                false,
                                                false,
-                                               $fields['item_type'],
-                                               $fields['item_id'],
-                                               $fields['external_ref'],
-                                               $fields['external_voucher_id'],
+                                               isset($fields['item_type']) && 
$fields['item_type'] ? $fields['item_type'] : false,
+                                               isset($fields['item_id']) && 
$fields['item_id'] ? $fields['item_id'] : false,
+                                               isset($fields['external_ref']) 
&& $fields['external_ref'] ? $fields['external_ref'] : false,
+                                               
isset($fields['external_voucher_id']) && $fields['external_voucher_id'] ? 
$fields['external_voucher_id'] : false,
                                                isset($fields['currency']) && 
$fields['currency'] ? $fields['currency'] : 'NOK'
                                        );
 
@@ -281,7 +282,7 @@
                                                . " 
fakturanr,spbudact_code,loc1,dima,dimd,dime,mvakode,periode,merknad,line_text,oppsynsigndato,saksigndato,"
                                                . " 
budsjettsigndato,utbetalingsigndato,item_type,item_id,external_ref,external_voucher_id,currency,belop,godkjentbelop)"
                                                . " VALUES ({$values}," . 
$this->db->money_format($fields['belop']) . ',' . 
$this->db->money_format($fields['godkjentbelop']) .')';
-
+//                                             _debug_array($sql);die();
                                        
$this->db->query($sql,__LINE__,__FILE__);
 
                                        $num++;
@@ -346,13 +347,13 @@
                                $data['utbetalingsigndato'],
                                $data['filnavn'],
                                isset($data['overftid']) && $data['overftid'] ? 
$data['overftid'] : date($this->db->datetime_format()),
-                               $data['item_type'],
-                               $data['item_id'],
-                               $data['external_ref'],
-                               $data['external_voucher_id'],
+                               isset($data['item_type']) && $data['item_type'] 
? $data['item_type'] : false,
+                               isset($data['item_id']) && $data['item_id'] ? 
$data['item_id'] : false,
+                               isset($data['external_ref']) && 
$data['external_ref'] ? $data['external_ref'] : false,
+                               isset($data['external_voucher_id']) && 
$data['external_voucher_id'] ? $data['external_voucher_id'] : false,
                                $data['currency'],
-                               $data['manual_record'],
-                               $data['process_code'],
+                               isset($data['manual_record']) && 
$data['manual_record'] ? $data['manual_record'] : false,
+                               isset($data['process_code']) && 
$data['process_code'] ? $data['process_code'] : false,
                                $this->db->db_addslashes($data['process_log']),
                        );
 
@@ -724,17 +725,10 @@
                        $orders_affected = array();
                        $_dateformat = $this->db->date_format();
 
-                       if ( $this->db->get_transaction() )
-                       {
-                               $this->global_lock = true;
-                       }
-                       else
-                       {
-                               $this->db->transaction_begin();
-                       }
+                       $this->db->transaction_begin();
 
-
                        $this->add($values, $skip_update_voucher_id);
+                       $this->voucher_id = $values[0]['bilagsnr'];
 
                        $voucher = $this->get_voucher($values[0]['bilagsnr']);
                        foreach ($voucher as &$line)
@@ -750,12 +744,16 @@
                                $line['manual_record']                  = 1;
 
                                $this->add_OverfBilag($line);
+                       }
+                       
$this->delete_voucher_from_fm_ecobilag($values[0]['bilagsnr']);
 
-                               $amount =  $line['godkjentbelop'] * 100; 
+                       reset($voucher);
 
+                       foreach ($voucher as &$line)
+                       {
                                if($line['order_id'])
                                {
-                                       $orders_affected[$line['order_id']] = 
true;
+                                       $amount =  $line['godkjentbelop'] * 
100; 
                                        //Oppdater beløp på bestilling
                                        if ($line['dimd'] % 2 == 0)
                                        {
@@ -773,15 +771,12 @@
                                }
                        }
 
-                       
$this->delete_voucher_from_fm_ecobilag($values[0]['bilagsnr']);
+
                        
$this->update_actual_cost_from_archive($orders_affected);
 
-                       if ( !$this->global_lock )
-                       {
-                               $this->db->transaction_commit();
-                       }
+                       return $this->db->transaction_commit();
 
-                       return true;
+
                }
 
 
@@ -916,6 +911,8 @@
                        {
                                $sql="UPDATE {$table} SET 
{$actual_cost_field}={$actual_cost_field} {$operator} {$amount} {$update_paid} 
WHERE id='{$order_id}'";
                                $this->db->query($sql,__LINE__,__FILE__);
+
+                               
execMethod('property.boworkorder.notify_coordinator_on_consumption', $order_id);
                        }
                }
 

Modified: branches/Version-1_0-branch/property/inc/class.soproject.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soproject.inc.php    
2014-02-26 13:37:14 UTC (rev 11757)
+++ branches/Version-1_0-branch/property/inc/class.soproject.inc.php    
2014-02-26 13:42:16 UTC (rev 11758)
@@ -2547,9 +2547,9 @@
                        {
                //              if($budget['budget_amount'])
                                {
+                                       $this->db->query("UPDATE 
fm_project_budget SET active = 0 WHERE project_id = {$id}",__LINE__,__FILE__); 
// previous
                                        $this->update_budget($id, $year, 
$periodization_id, (int)$budget['budget_amount'], true, 'update', true);
                                }
-                               $this->db->query("UPDATE fm_project_budget SET 
active = 0 WHERE project_id = {$id}",__LINE__,__FILE__);
                        }
 
                        $this->db->transaction_commit();

Modified: branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php  
2014-02-26 13:37:14 UTC (rev 11757)
+++ branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php  
2014-02-26 13:42:16 UTC (rev 11758)
@@ -1195,22 +1195,14 @@
 
                        $this->db->query("INSERT INTO fm_orders (id,type) 
VALUES ({$id},'workorder')");
 
-
-/*
-                       $this->db->query("SELECT periodization_id FROM 
fm_project WHERE id = {$workorder['project_id']}",__LINE__,__FILE__);
-                       $this->db->next_record();
-                       $periodization_id = $this->db->f('periodization_id');
-*/
                        $periodization_id = 
isset($workorder['budget_periodization']) && $workorder['budget_periodization'] 
? (int) $workorder['budget_periodization'] : 0;
-//                     $this->_update_project_budget($workorder['project_id'], 
date('Y', $workorder['start_date']), $periodization_id, $combined_cost);
                        if($combined_cost)
                        {
                                $this->_update_order_budget($id, 
$workorder['budget_year'], $periodization_id, $workorder['budget'], 
$workorder['contract_sum'], $combined_cost);
                        }
 
+                       $this->_update_project_budget($workorder['project_id'], 
date('Y', $workorder['start_date']));
 
-
-
 /*
                        if($workorder['charge_tenant'])
                        {
@@ -1419,13 +1411,7 @@
 
                        }
 
-/*
-                       $this->db->query("SELECT periodization_id FROM 
fm_project WHERE id = {$workorder['project_id']}",__LINE__,__FILE__);
-                       $this->db->next_record();
-                       $periodization_id = $this->db->f('periodization_id');
-*/
                        $periodization_id = 
isset($workorder['budget_periodization']) && $workorder['budget_periodization'] 
? (int) $workorder['budget_periodization'] : 0;
-//                     $this->_update_project_budget($workorder['project_id'], 
date('Y', $workorder['start_date']), $periodization_id, 
$combined_cost,$old_combined_cost);
                        if($combined_cost)
                        {
                                $this->db->query("SELECT sum(budget) AS budget 
FROM fm_workorder_budget WHERE order_id = 
'{$workorder['id']}'",__LINE__,__FILE__);
@@ -1441,6 +1427,7 @@
                                $historylog->add('B', $workorder['id'], 
$new_budget, $old_budget);
                        }
 
+                       $this->_update_project_budget($workorder['project_id'], 
date('Y', $workorder['start_date']));
 
 /*                     if($workorder['charge_tenant'])
                        {
@@ -1755,7 +1742,41 @@
                        }
                }
 
+               /**
+                * Get the percent of used funding
+                * @param integer $order_id
+                * @return float percent
+               */
+               function get_order_budget_percent($order_id)
+               {
+                       $_sub_budget = 0;
+                       $sum_actual_cost = 0;
+                       $sum_oblications = 0;
 
+                       $budget = $this->get_budget($order_id);
+                       foreach($budget as $entry)
+                       {
+                               if ($entry['active'] == 1)
+                               {
+                                       $_sub_budget += $entry['budget'];
+                                       $sum_actual_cost += 
$entry['actual_cost'];
+                                       $sum_oblications += 
$entry['sum_oblications'];
+                               }
+                       }
+                       $sum_budget = $_sub_budget == 0 ? 1 : $_sub_budget; // 
avoid zero-division
+                       $percent = round(($sum_actual_cost/$sum_budget)*100, 1);
+
+                       $budget_info = array
+                       (
+                               'percent'               => $percent,
+                               'budget'                => $sum_budget,
+                               'actual_cost'   => $sum_actual_cost,
+                               'obligation'    => $sum_oblications
+
+                       );
+                       return $budget_info;
+               }
+
                /**
                * Get periodized budget for an order
                * @param integer $order_id
@@ -2392,50 +2413,53 @@
                        $this->db->transaction_commit();
                }
 
-               protected function _update_project_budget($project_id, $year, 
$periodization_id, $combined_cost, $old_combined_cost = 0)
+               /**
+                * Add budget to project if missing.
+                * @param integer $project_id
+                * @param integer $year
+                */
+               protected function _update_project_budget($project_id, $year)
                {
                        $project_id = (int) $project_id;
                        $year = $year ? (int) $year : date('Y');
 
-                       $periodization_id = (int) $periodization_id;
-                       $periodization_outline = array();
+                       $ids = array();
+                       $this->db->query("SELECT id FROM fm_workorder WHERE 
project_id = {$project_id}",__LINE__,__FILE__);
+                       while ($this->db->next_record())
+                       {
+                               $ids[] = $this->db->f('id');
+                       }
+                       $this->db->query("SELECT sum(budget) AS budget FROM 
fm_workorder_budget WHERE year = {$year} AND order_id IN (" . implode(',', 
$ids) . ')',__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $workorder_budget       = $this->db->f('budget');
+                       
+                       $this->db->query("SELECT sum(budget) AS budget FROM 
fm_project_budget WHERE project_id = {$project_id} AND year = 
{$year}",__LINE__,__FILE__);
+                       $this->db->next_record();
+                       $project_budget = $this->db->f('budget');
+                       
+                       $update = false;
 
-                       if($periodization_id)
+                       if($project_budget < 0 && $workorder_budget < 
$project_budget)
                        {
-                               $this->db->query("SELECT month, value FROM 
fm_eco_periodization_outline WHERE periodization_id = {$periodization_id} ORDER 
BY month ASC",__LINE__,__FILE__);
-                               while ($this->db->next_record())
-                               {
-                                       $periodization_outline[] = array
-                                       (
-                                               'month' => 
$this->db->f('month'),
-                                               'value' => 
$this->db->f('value'),
-                                       );
-                               }
+                               $update = true;
                        }
-                       else
+                       else if ($workorder_budget > $project_budget)
                        {
-                               $periodization_outline[] = array
-                               (
-                                       'month' => 0,
-                                       'value' => 100,
-                               );
-
+                               $update = true;
                        }
 
-//FIXME : condsider removed
-/*
-                       foreach ($periodization_outline as $outline)
+                       if ($update)
                        {
-                               $partial_amount = $combined_cost * 
$outline['value'] / 100;
-                               $old_partial_amount = $old_combined_cost * 
$outline['value'] / 100;
-                               $sql = "UPDATE fm_project_budget SET 
order_amount = order_amount + {$partial_amount} - {$old_combined_cost} WHERE 
project_id = {$project_id} AND year = {$year} AND month =" . 
(int)$outline['month'];
-                               $this->db->query($sql,__LINE__,__FILE__);
+                               $this->db->query("SELECT periodization_id FROM 
fm_project WHERE id = {$project_id}",__LINE__,__FILE__);
+                               $this->db->next_record();
+                               $periodization_id       = 
(int)$this->db->f('periodization_id');
+
+                               $soproject      = 
CreateObject('property.soproject');
+
+                               $soproject->update_budget($project_id, $year, 
$periodization_id, (int)$workorder_budget, true, 'update', true);
                        }
-*/
                }
 
-
-
                /**
                * Transfer budget and cost from one year to the next
                *

Modified: branches/Version-1_0-branch/property/inc/class.uitts.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uitts.inc.php        
2014-02-26 13:37:14 UTC (rev 11757)
+++ branches/Version-1_0-branch/property/inc/class.uitts.inc.php        
2014-02-26 13:42:16 UTC (rev 11758)
@@ -2892,7 +2892,11 @@
                                                '</b>'
                                        ),$order_email_template));
 
-                                       $html = 
"<html><head><title>{$subject}</title></head>";
+                                       $html = "<html><head><meta 
http-equiv=\"Content-Type\" content=\"text/html; 
charset=utf-8\"><title>{$subject}</title></head>";
+
+                                       $body .='</br>';
+                                       $body .='</br>';
+                                       $body .= '<a href ="' . 
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 
'property.uitts.view', 'id' => $id),false,true).'">' . lang('Ticket').' #' .$id 
.'</a>';
                                        $html .= "<body>{$body}</body></html>";
 
 

Modified: branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php  
2014-02-26 13:37:14 UTC (rev 11757)
+++ branches/Version-1_0-branch/property/inc/class.uiworkorder.inc.php  
2014-02-26 13:42:16 UTC (rev 11758)
@@ -1135,13 +1135,13 @@
                                                $action='add';
                                        }
                                        $receipt = 
$this->bo->save($values,$action);
-                                       $historylog     = 
CreateObject('property.historylog','workorder');
+
                                        if (! $receipt['error'])
                                        {
                                                $id = $receipt['id'];
-                                               //temporary
-                                               
execMethod('property.soXport.update_actual_cost_from_archive',array($id => 
true));
                                        }
+
+                                       $historylog     = 
CreateObject('property.historylog','workorder');
                                        $function_msg = lang('Edit Workorder');
                                        //----------files
                                        $bofiles        = 
CreateObject('property.bofiles');
@@ -2453,7 +2453,7 @@
                                        $_receipt = array();//local errors
                                        $receipt = 
$boinvoice->add_manual_invoice($values);
 
-                                       if(!$receipt['error']) // all ok
+                                       if(!isset($receipt['error'])) // all ok
                                        {
                                                
execMethod('property.soXport.update_actual_cost_from_archive',array($values['order_id']
 => true));
                                                $redirect = true;




reply via email to

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