[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [10627] Merge 10616:10626 from trunk
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [10627] Merge 10616:10626 from trunk |
Date: |
Tue, 01 Jan 2013 21:43:59 +0000 |
Revision: 10627
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10627
Author: sigurdne
Date: 2013-01-01 21:43:59 +0000 (Tue, 01 Jan 2013)
Log Message:
-----------
Merge 10616:10626 from trunk
Modified Paths:
--------------
branches/Version-1_0-branch/controller/inc/class.socontrol_item_list.inc.php
branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
branches/Version-1_0-branch/controller/inc/class.uicontrol_group.inc.php
branches/Version-1_0-branch/property/inc/class.bobudget.inc.php
branches/Version-1_0-branch/property/inc/class.boproject.inc.php
branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php
branches/Version-1_0-branch/property/inc/class.sobudget.inc.php
branches/Version-1_0-branch/property/inc/class.sogeneric.inc.php
branches/Version-1_0-branch/property/inc/class.soproject.inc.php
branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
branches/Version-1_0-branch/property/inc/class.uibudget.inc.php
branches/Version-1_0-branch/property/inc/class.uiproject.inc.php
branches/Version-1_0-branch/property/js/yahoo/project.edit.js
branches/Version-1_0-branch/property/js/yahoo/property2.js
branches/Version-1_0-branch/property/setup/phpgw_no.lang
branches/Version-1_0-branch/property/setup/setup.inc.php
branches/Version-1_0-branch/property/setup/tables_current.inc.php
branches/Version-1_0-branch/property/setup/tables_update.inc.php
branches/Version-1_0-branch/property/templates/base/project.xsl
Property Changed:
----------------
branches/Version-1_0-branch/
Property changes on: branches/Version-1_0-branch
___________________________________________________________________
Modified: svn:mergeinfo
-
/trunk:6439-6441,6443,6445-6447,6449-6464,6466-6468,6470-6474,6476-6477,6479-6480,6483-6488,6490-6491,6493-6494,6496-6501,6503-6504,6506,6508,6510-6511,6513,6515-6516,6518,6520-6524,6526-6528,6533-6534,6536-6541,6543-6565,6567,6569,6571-6576,6578,6580-6586,6588-6596,6598-6600,6602-6604,6606-6607,6609-6611,6613-6625,6629-6639,6641-6643,6645-6646,6648,6650-6654,6656-6659,6661-6663,6665-6666,6668-6669,6672-6673,6675,6677-6678,6680,6682-6686,6688-6717,6719,6721-6722,6724-6728,6730,6732-6734,6736-6739,6741,6743,6745-6746,6748-6756,6758-6762,6764,6766-6788,6790,6792-6798,6800-6814,6816-6819,6821-6822,6824-6826,6828-6837,6839,6841,6843-6849,6851,6853-6869,6871-6874,6876-6877,6879,6881,6883,6885-6886,6888-6893,6895-6897,6899-6901,6903,6905-6907,6909,6911-6929,6931-6936,6938-6947,6949,6951,6953,6955-6956,6958-6959,6961-6968,6970-6971,6973-6974,6976-6978,6980,6982-7017,7019-7025,7027-7035,7037-7039,7041-7045,7047-7055,7057,7059-7065,7067-7069,7071,7073,7075-7076,7078,7080-7081,7083,7085,7087,7089-7097,7099-7102,7104-7105,7107-7111,7113-7120,7122-7124,7126-7129,7131,7133-7141,7143,7145-7146,7148-7150,7152-7153,7155-7158,7160-7164,7166-7167,7169-7170,7172,7174,7176,7178,7180-7181,7183,7185,7187-7188,7190,7192-7196,7198-7199,7201-7203,7205,7207,7209-7210,7212,7214,7216-7217,7219-7222,7224-7226,7228-7229,7231,7233-7234,7236-7238,7240-7241,7243-7244,7246,7248,7250,7252-7256,7258-7259,7261-7264,7266-7273,7275-7279,7281-7332,7334-7338,7340-7348,7350,7352-7353,7355-7361,7363-7366,7368-7370,7372,7374,7376,7378,7380-7386,7388-7400,7402,7404-7433,7435-7439,7441-7446,7448-7458,7460-7469,7471-7483,7485-7487,7489-7490,7492,7494,7496-7497,7499,7501-7502,7504,7506-7507,7509-7511,7513-7517,7519-7521,7523,7525,7527-7529,7531,7533,7535-7538,7540-7542,7544-7549,7551-7552,7554-7561,7563,7565,7567-7573,7575-7578,7580-7584,7586-7591,7593-7624,7627-7636,7638-7656,7658-7718,7720-7732,7734,7736,7738-7750,7754-7759,7761-7767,7769-7780,7782,7784-7809,7811-7812,7814-7835,7837-7847,7849-7887,7889-7895,7897,7899,7901,7903-7905,7907-7921,7923-7925,7927-7933,7935,7937-7952,7954-7968,7970-7974,7976,7978-7979,7981-7982,7984-7988,7990-7992,7994-8041,8043-8066,8068-8087,8089,8091-8108,8110-8124,8126-8129,8131,8133-8150,8152-8154,8156-8162,8164-8167,8169-8170,8172-8179,8181,8183-8196,8198-8207,8209-8211,8213-8214,8216-8217,8219-8220,8222,8224-8225,8227-8247,8249,8251,8253-8282,8284-8352,8354-8368,8370-8396,8398-8430,8432,8434-8440,8442-8445,8447-8453,8455-8456,8458,8460,8462-8464,8466-8473,8475-8479,8481,8483-8501,8503-8523,8525,8527-8531,8533,8535-8536,8538-8550,8552-8554,8556-8557,8559-8579,8581-8587,8589,8591-8592,8594-8595,8597-8601,8603-8610,8612-8613,8615,8617,8619-8645,8647-8650,8652-8661,8663-8666,8668-8669,8671-8683,8685-8691,8693-8730,8732-8737,8739,8741-8767,8769,8771-8772,8774,8776-8797,8799-8812,8814-8819,8821,8823-8833,8835-8837,8839,8841,8843-8849,8852-8858,8860-8867,8869-8870,8872,8874-8877,8879,8881,8883-8888,8890,8892-8901,8903-8911,8913-8917,8920-8923,8925-8933,8935-8938,8940-8943,8945,8947-8948,8950,8952-8953,8955-8962,8964,8966,8968-8970,8972-8975,8977-8983,8985-8993,8995-9001,9003,9005,9007,9009,9011-9019,9021-9023,9025,9027-9028,9030-9044,9046-9047,9049-9050,9052-9056,9058-9059,9061,9063-9064,9066-9068,9071-9092,9094-9112,9114-9117,9119,9121-9160,9162-9166,9169-9207,9209-9211,9213-9215,9217,9219,9221-9253,9255,9257,9259-9260,9262,9264-9269,9271-9273,9275,9277-9278,9280,9282-9283,9285-9289,9291-9299,9301-9310,9312-9313,9315-9320,9322-9324,9326-9338,9340-9342,9344,9346-9348,9350-9358,9360-9362,9364-9366,9368-9374,9376-9382,9384,9386,9388-9390,9392-9396,9398-9402,9404-9410,9412,9414,9416-9417,9419-9425,9427,9429-9430,9432,9434-9463,9465-9502,9504-9506,9508-9521,9523-9526,9528,9530-9537,9539,9541-9551,9553,9555-9556,9558-9578,9580-9581,9583,9585,9587,9589,9591-9624,9626-9655,9657-9700,9702-9726,9728-9729,9731-9749,9751,9753-9754,9756-9832,9834-9836,9838-9839,9841-9846,9848-9850,9852-9858,9860-9863,9865,9867,9869-9871,9873-9893,9895,9897-9912,9914-9919,9921-9928,9930-9952,9954,9956,9958-9963,9965-9993,9995-9997,9999-10001,10003-10004,10006-10007,10009-10012,10014-10031,10033-10073,10075-10107,10109-10165,10167-10210,10222-10226,10228-10311,10313-10378,10380,10382,10384-10393,10395-10478,10480-10482,10484-10494,10496-10503,10505,10507,10509-10521,10523,10525-10528,10530-10540,10542-10543,10545-10568,10570-10584,10586-10590,10592-10594,10596,10598-10599,10601-10611,10613,10615
+
/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
Modified:
branches/Version-1_0-branch/controller/inc/class.socontrol_item_list.inc.php
===================================================================
---
branches/Version-1_0-branch/controller/inc/class.socontrol_item_list.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++
branches/Version-1_0-branch/controller/inc/class.socontrol_item_list.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -139,14 +139,21 @@
$sql = "SELECT cil.* FROM controller_control_item_list
cil WHERE cil.control_id = " . $control_id . " AND cil.control_item_id = " .
$control_item_id;
$this->db->limit_query($sql, 0, __LINE__, __FILE__, 1);
- $this->db->next_record();
+ $result = $this->db->next_record();
- $control_item_list = new
controller_control_item_list($this->unmarshal($this->db->f('id'), 'int'));
-
$control_item_list->set_control_id($this->unmarshal($this->db->f('control_id'),
'int'));
-
$control_item_list->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
'int'));
-
$control_item_list->set_order_nr($this->unmarshal($this->db->f('order_nr'),
'int'));
-
- return $control_item_list;
+ if( $result )
+ {
+ $control_item_list = new
controller_control_item_list($this->unmarshal($this->db->f('id'), 'int'));
+
$control_item_list->set_control_id($this->unmarshal($this->db->f('control_id'),
'int'));
+
$control_item_list->set_control_item_id($this->unmarshal($this->db->f('control_item_id'),
'int'));
+
$control_item_list->set_order_nr($this->unmarshal($this->db->f('order_nr'),
'int'));
+
+ return $control_item_list;
+ }
+ else
+ {
+ return null;
+ }
}
/**
Modified: branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -262,13 +262,11 @@
}
}
- // Sigurd: START as categories
$cats = CreateObject('phpgwapi.categories', -1,
'controller', '.control');
$cats->supress_info = true;
$control_areas =
$cats->formatted_xslt_list(array('format'=>'filter','globals' => true,'use_acl'
=> $this->_category_acl));
$control_areas_array = $control_areas['cat_list'];
- // END as categories
if($control != null)
$procedures_array =
$this->so_procedure->get_procedures_by_control_area($control->get_control_area_id());
@@ -289,7 +287,7 @@
'tabs'
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 0),
'view'
=> "control_details",
'editable'
=> true,
- 'control'
=> ($control != null) ? $control->toArray() : null,
+ 'control'
=> ($control != null) ? $control : null,
'control_areas_array' =>
$control_areas_array,
'procedures_array' =>
$procedures_array,
'role_array'
=> $role_array,
@@ -404,7 +402,7 @@
'tabs'
=> $GLOBALS['phpgw']->common->create_tabs($tabs, 1),
'view'
=> "control_groups",
'editable' => true,
- 'control'
=> $control->toArray(),
+ 'control'
=> $control,
'control_area' => $control_area,
'control_groups' => $control_groups,
);
@@ -523,7 +521,7 @@
'tabs'
=>
$GLOBALS['phpgw']->common->create_tabs($tabs, 2),
'view'
=> 'control_items',
'control_group_ids'
=> implode($control_group_ids, ","),
- 'control'
=> $control->toArray(),
+ 'control'
=> $control,
'groups_with_control_items' =>
$groups_with_control_items
);
@@ -543,30 +541,57 @@
*/
public function save_control_items(){
$control_id = phpgw::get_var('control_id');
-
+
// Fetching selected control items. Tags are on the
format 1:2 (group:item).
$control_tag_ids = phpgw::get_var('control_tag_ids');
- // Deleting earlier saved control items
-
$this->so_control_item_list->delete_control_items($control_id);
-
+ $saved_control_items =
$this->so_control_item_list->get_control_items_by_control($control_id,
"return_object");
+
+ // Deleting formerly saved control items
+ foreach ($saved_control_items as $saved_control_item)
+ {
+ $exists = false;
+ $saved_control_item_id =
$saved_control_item->get_id();
+
+ foreach ($control_tag_ids as $control_item_tag)
+ {
+ $control_item_id =
substr($control_item_tag, strpos($control_item_tag, ":")+1,
strlen($control_item_tag));
+
+ if($control_item_id ==
$saved_control_item_id)
+ {
+ $exists = true;
+ }
+ }
+
+ if($exists == false)
+ {
+ $exists = false;
+ $status =
$this->so_control_item_list->delete($control_id, $saved_control_item_id);
+ }
+ }
+
$order_nr = 1;
- // Saving control items if submit save control items is
clicked
+ // Saving new control items
foreach ($control_tag_ids as $control_item_tag)
- {
+ {
// Fetch control_item_id from tag string
$control_item_id = substr($control_item_tag,
strpos($control_item_tag, ":")+1, strlen($control_item_tag));
-
- // Saves control item
- $control_item_list = new
controller_control_item_list();
- $control_item_list->set_control_id($control_id);
-
$control_item_list->set_control_item_id($control_item_id);
- $control_item_list->set_order_nr($order_nr);
-
$this->so_control_item_list->add($control_item_list);
- $order_nr++;
- }
-
+ $saved_control_list_item =
$this->so_control_item_list->get_single_2($control_id, $control_item_id);
+
+ if( $saved_control_list_item == null )
+ {
+ // Saves control item
+ $control_item_list = new
controller_control_item_list();
+
$control_item_list->set_control_id($control_id);
+
$control_item_list->set_control_item_id($control_item_id);
+
$control_item_list->set_order_nr($order_nr);
+
$this->so_control_item_list->add($control_item_list);
+
+ $order_nr++;
+ }
+ }
+
$this->redirect(array('menuaction' =>
'controller.uicontrol.view_check_list', 'control_id'=>$control_id ));
}
@@ -601,7 +626,7 @@
(
'tabs'
=>
$GLOBALS['phpgw']->common->create_tabs($tabs, 3),
'view'
=> "sort_check_list",
- 'control'
=> $control->toArray(),
+ 'control'
=> $control,
'saved_groups_with_items_array' =>
$saved_groups_with_items_array
);
@@ -621,7 +646,7 @@
$data = array
(
- 'control' => $control->toArray(),
+ 'control' => $control
);
self::render_template_xsl('control/control_details',
$data);
Modified:
branches/Version-1_0-branch/controller/inc/class.uicontrol_group.inc.php
===================================================================
--- branches/Version-1_0-branch/controller/inc/class.uicontrol_group.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/controller/inc/class.uicontrol_group.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -547,7 +547,7 @@
$item_order_arr = explode(",", $item_order_str);
$db_control_group_list =
$this->so_control_group_list->get_db();
-
+
// Saves order for control groups
foreach($group_order_arr as $group_id_order){
$group_id_order_arr = explode(":",
$group_id_order);
@@ -561,7 +561,6 @@
// Updates group order if control_group_list
object exists
if( $control_group_list != null ){
-
$control_group_list->set_order_nr(
$group_order_nr );
$id =
$this->so_control_group_list->update( $control_group_list );
Modified: branches/Version-1_0-branch/property/inc/class.bobudget.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.bobudget.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/inc/class.bobudget.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -88,9 +88,16 @@
$revision =
phpgw::get_var('revision', 'int');
$allrows =
phpgw::get_var('allrows', 'bool');
$details =
phpgw::get_var('details', 'bool');
+ $direction =
phpgw::get_var('direction');
$this->start = $start;
- $this->query = isset($query) ?
$query : $this->query;
+ $this->query = $query ? $query :
$this->query;
+ $this->direction = $direction ?
$direction : $this->direction;
+ if( !$this->direction )
+ {
+ $this->direction = 'expences';
+ }
+
$this->filter = isset($filter) &&
$filter ? $filter : '';
$this->sort = isset($sort)
&& $sort ? $sort : '';
$this->order = isset($order) &&
$order ? $order : '';
@@ -133,6 +140,7 @@
$this->cat_id =
isset($data['cat_id'])?$data['cat_id']:'';
$this->dimb_id =
isset($data['dimb_id'])?$data['dimb_id']:'';
$this->details =
isset($data['details'])?$data['details']:'';
+ $this->direction =
isset($data['direction'])?$data['direction']:'';
}
function check_perms($has, $needed)
@@ -183,7 +191,8 @@
'sort' => strtoupper($this->sort), 'order' =>
$this->order, 'filter' => $this->filter,
'cat_id' => $this->cat_id,
'allrows'=>$this->allrows, 'district_id' => $this->district_id,
'year' => $this->year, 'grouping' =>
$this->grouping, 'revision' => $this->revision,
- 'details' => $this->details,'dimb_id' =>
$this->dimb_id, 'department' => $this->department));
+ 'details' => $this->details,'dimb_id' =>
$this->dimb_id, 'department' => $this->department,
+ 'direction' => $this->direction));
$this->total_records =
$this->so->total_records;
$this->sum_budget_cost =
$this->so->sum_budget_cost;
Modified: branches/Version-1_0-branch/property/inc/class.boproject.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.boproject.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/inc/class.boproject.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -553,6 +553,7 @@
{
$sum_deviation+=
$workorder_data[$i]['deviation'];
+/*
$_cost = (float)number_format(0, 2, ',', '');
if(abs($workorder_data[$i]['contract_sum']) > 0)
{
@@ -566,24 +567,26 @@
{
$_cost =
(float)number_format($workorder_data[$i]['budget'] * $tax, 2, ',', '');
}
-
- $values['workorder_budget'][$i]['cost'] =
$_cost;
-
+*/
+ $values['workorder_budget'][$i]['cost'] =
$workorder_data[$i]['combined_cost'];
+ $values['workorder_budget'][$i]['actual_cost']
= $workorder_data[$i]['actual_cost'];
+
$values['workorder_budget'][$i]['title']=htmlspecialchars_decode($workorder_data[$i]['title']);
$values['workorder_budget'][$i]['workorder_id']=$workorder_data[$i]['workorder_id'];
//
$values['workorder_budget'][$i]['contract_sum']=(float)number_format($workorder_data[$i]['contract_sum']
* (1+(((int)$workorder_data[$i]['addition_percentage'])/100)), 2, ',', '');
- // $values['workorder_budget'][$i]['budget']=
$workorder_data[$i]['budget'];
+ $values['workorder_budget'][$i]['budget']=
$workorder_data[$i]['budget'];
//
$values['workorder_budget'][$i]['calculation']=(float)number_format($workorder_data[$i]['calculation']*$tax,
2, ',', '');
$values['workorder_budget'][$i]['charge_tenant'] =
$workorder_data[$i]['charge_tenant'];
$values['workorder_budget'][$i]['status'] =
$workorder_data[$i]['status'];
- $values['workorder_budget'][$i]['actual_cost']
= (float)number_format($workorder_data[$i]['actual_cost'] ?
$workorder_data[$i]['actual_cost'] : 0, 2, ',', '');
+ // $values['workorder_budget'][$i]['actual_cost']
= (float)number_format($workorder_data[$i]['actual_cost'] ?
$workorder_data[$i]['actual_cost'] : 0, 2, ',', '');
$values['workorder_budget'][$i]['b_account_id']
= $workorder_data[$i]['b_account_id'];
// $values['workorder_budget'][$i]['paid_percent']
= (int)$workorder_data[$i]['paid_percent'];
$values['workorder_budget'][$i]['addition_percentage'] =
$workorder_data[$i]['addition_percentage'];
+ $values['workorder_budget'][$i]['obligation'] =
$workorder_data[$i]['obligation'];
-
$values['workorder_budget'][$i]['combined_cost'] =
$workorder_data[$i]['closed'] ? 0 : ($_cost -
$workorder_data[$i]['actual_cost']);
- $values['workorder_budget'][$i]['diff'] =
$_cost - $values['workorder_budget'][$i]['combined_cost'] -
$values['workorder_budget'][$i]['actual_cost'];
+//
$values['workorder_budget'][$i]['combined_cost'] =
$workorder_data[$i]['closed'] ? 0 : ($_cost -
$workorder_data[$i]['actual_cost']);
+ $values['workorder_budget'][$i]['diff'] =
$workorder_data[$i]['diff'];
if(isset($workorder_data[$i]['vendor_id']) &&
$workorder_data[$i]['vendor_id'])
{
@@ -874,9 +877,9 @@
$this->so->delete($project_id);
}
- function bulk_update_status($start_date, $end_date,
$status_filter, $status_new, $execute, $type,
$user_id,$ids,$paid,$closed_orders)
+ function bulk_update_status($start_date, $end_date,
$status_filter, $status_new, $execute, $type,
$user_id,$ids,$paid,$closed_orders,$ecodimb)
{
- return $this->so->bulk_update_status($start_date,
$end_date, $status_filter, $status_new, $execute, $type,
$user_id,$ids,$paid,$closed_orders);
+ return $this->so->bulk_update_status($start_date,
$end_date, $status_filter, $status_new, $execute, $type,
$user_id,$ids,$paid,$closed_orders,$ecodimb);
}
public function get_user_list($selected = 0)
@@ -894,6 +897,11 @@
return $this->so->get_budget($project_id);
}
+ public function get_buffer_budget($project_id)
+ {
+ return $this->so->get_buffer_budget($project_id);
+ }
+
public function get_periodizations_with_outline()
{
return $this->so->get_periodizations_with_outline();
Modified: branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/inc/class.boworkorder.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -605,6 +605,13 @@
$historylog =
CreateObject('property.historylog','workorder');
$history_array =
$historylog->return_array(array('O'),array(),'','',$id);
+ $_status_list = $this->so->select_status_list();
+ $status_text = array();
+ foreach ($_status_list as $_status_entry)
+ {
+ $status_text[$_status_entry['id']] =
$_status_entry['name'];
+ }
+
$i=0;
foreach ($history_array as $value)
{
@@ -633,7 +640,7 @@
case 'CO': $type = lang('Initial
Coordinator'); break;
case 'C': $type = lang('Coordinator
changed'); break;
case 'TO': $type = lang('Initial
Category'); break;
- case 'T': $type =
lang('Category changed'); break;
+ case 'T': $type = lang('Category
changed'); break;
case 'SO': $type = lang('Initial
Status'); break;
case 'S': $type = lang('Status
changed'); break;
case 'SC': $type = lang('Status
confirmed'); break;
@@ -647,10 +654,9 @@
}
if($value['new_value']=='O'){$value['new_value']=lang('Opened');}
-
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
+
if($value['new_value']=='X'){$value['new_value']=lang('Closed');}
-
-
$record_history[$i]['value_action'] = $type?$type:'';
+ $record_history[$i]['value_action'] = $type
? $type:'';
unset($type);
if ($value['status'] == 'A')
@@ -694,6 +700,11 @@
$record_history[$i]['value_old_value'] = $category[0]['name'];
}
}
+ else if ($value['status'] == 'S' ||
$value['status'] == 'SO')
+ {
+ $record_history[$i]['value_new_value']
= $status_text[$value['new_value']];
+ $record_history[$i]['value_old_value']
= $status_text[$value['old_value']];
+ }
else if ($value['status'] != 'O' &&
$value['new_value'])
{
$record_history[$i]['value_new_value']
= $value['new_value'];
Modified: branches/Version-1_0-branch/property/inc/class.sobudget.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.sobudget.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/inc/class.sobudget.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -533,22 +533,39 @@
$details = isset($data['details']) ?
$data['details'] : '';
$dimb_id = isset($data['dimb_id']) &&
$data['dimb_id'] ? (int)$data['dimb_id'] : 0;
$department = isset($data['department'])
&& $data['department'] ? (int)$data['department'] : 0;
+ $direction = isset($data['direction']) &&
$data['direction'] ? $data['direction'] : 'expences';
if(!$year)
{
return array();
}
- //_debug_array($allrows);
- $ordermethod = '';
+
+ $filtermethod_direction = '';
+
+ if($direction == 'income')
+ {
+ $filtermethod_direction = "fm_b_account.id
{$this->like} '3%'";
+ }
+ else
+ {
+ $filtermethod_direction = "fm_b_account.id NOT
{$this->like} '3%'";
+ }
+
/* 0 => cancelled, 1 => obligation , 2 => paid */
- //$filtermethod = "WHERE fm_workorder.paid = 1 and
fm_workorder.vendor_id > 0";
-// $filtermethod = "WHERE fm_workorder.vendor_id > 0";
+ $filtermethod = '';
+
$start_date = mktime(1, 1, 1, 1, 1, $year);
$end_date = mktime (23, 59, 59, 12, 31, $year);
- $filtermethod .= " WHERE fm_workorder.start_date >=
$start_date AND fm_workorder.start_date <= $end_date";
-// $filtermethod .= " WHERE fm_workorder_status.closed IS
NULL AND fm_workorder.start_date >= $start_date AND fm_workorder.start_date <=
$end_date";
+ $start_periode = date('Ym',mktime(2,0,0,1,1,$year));
+ $end_periode = date('Ym',mktime(2,0,0,12,31,$year));
+
+
+
+ $filtermethod .= " WHERE (fm_workorder.start_date >=
$start_date AND fm_workorder.start_date <= $end_date";
+ $filtermethod .= " OR fm_workorder_status.closed IS
NULL AND fm_workorder.start_date < $start_date)";
+
$where = 'AND';
$cat_ids = array();
@@ -626,40 +643,94 @@
$b_account_field = 'category';
}
- $sql = "SELECT fm_workorder_status.closed,
sum(combined_cost) as combined_cost, count(fm_workorder.id) as hits,
fm_b_account.{$b_account_field} as {$b_account_field}, district_id,
fm_workorder.ecodimb"
+ $this->db->query('SELECT id, percent FROM
fm_ecomva',__LINE__,__FILE__);
+ $_taxcode = array(0 => 0);
+ while ($this->db->next_record())
+ {
+ $_taxcode[$this->db->f('id')] =
$this->db->f('percent');
+ }
+
+ $sql = "SELECT fm_workorder.id,
fm_workorder_status.closed, fm_workorder.budget,
combined_cost,fm_location1.mva,fm_workorder.start_date,"
+ . "
fm_orders_actual_cost_view.actual_cost,pending_cost,
fm_b_account.{$b_account_field} as {$b_account_field}, district_id,
fm_workorder.ecodimb"
. " FROM fm_workorder"
. " {$this->join} fm_workorder_status ON
fm_workorder.status = fm_workorder_status.id"
. " {$this->join} fm_b_account ON
fm_workorder.account_id = fm_b_account.id"
. " {$this->join} fm_project ON
fm_workorder.project_id = fm_project.id"
+ . " {$this->left_join}
fm_orders_actual_cost_view ON fm_workorder.id =
fm_orders_actual_cost_view.order_id"
+ . " {$this->left_join}
fm_orders_pending_cost_view ON fm_workorder.id =
fm_orders_pending_cost_view.order_id"
. " {$_join_district}"
. " {$this->join} fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id"
- . " {$filtermethod} {$querymethod} GROUP BY
fm_workorder_status.closed,fm_b_account.{$b_account_field},district_id,fm_workorder.ecodimb";
+ . " {$filtermethod} {$querymethod} {$where}
{$filtermethod_direction}";
//_debug_array($sql);
//die();
$this->db->query($sql . $ordermethod,__LINE__,__FILE__);
+ $sum_actual_cost = 0;
+ $actual_cost = array();
$sum_obligation_cost = 0;
$obligations = array();
$sum_hits = 0;
+ $_local_combined_cost = array();
+//$_test=array();
while ($this->db->next_record())
{
- $_combined_cost =
round($this->db->f('combined_cost'));
- $_hits = $this->db->f('hits');
- $sum_hits += $_hits;
+ $_id = $this->db->f('id');
+ if (!isset($_local_combined_cost[$_id]) && !
$_combined_cost = $_local_combined_cost[$_id])
+ {
+ $_local_combined_cost[$_id] =
round($this->db->f('combined_cost'));
+ $_combined_cost =
$_local_combined_cost[$_id];
+ }
+ unset($_id);
+ $_pending_cost =
round($this->db->f('pending_cost'));
- if(!$this->db->f('closed'))
+ $_taxfactor = 1 +
($_taxcode[(int)$this->db->f('mva')]/100);
+ $_actual_cost =
round($this->db->f('actual_cost')/$_taxfactor);
+ // $_actual_cost =
round($this->db->f('actual_cost'));
+ $_obligation = $_combined_cost - $_actual_cost
- $_pending_cost;
+
+
+ // only the current year
+ if($this->db->f('start_date') < $start_date)
{
- $sum_obligation_cost += $_combined_cost;
-
$obligations[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
+= $_combined_cost;
+ $_actual_cost = 0;
}
-
$hits[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
+= $_hits;
+ $sum_hits += 1;
+
+ if(!$this->db->f('closed'))
+ {
+ if((int)$this->db->f('budget') >= 0)
+ {
+ if($_obligation < 0)
+ {
+//$_test[] = $_obligation;
+ $_obligation = 0;
+ }
+ }
+ else
+ {
+ if($_obligation > 0)
+ {
+ $_obligation = 0;
+ }
+ }
+
+ $sum_obligation_cost += $_obligation;
+
$obligations[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
+= $_obligation;
+ }
+//_debug_array($_test);
+
$hits[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
+= 1;
$accout_info[$this->db->f($b_account_field)] =
true;
$district[$this->db->f('district_id')] = true;
$ecodimb[(int)$this->db->f('ecodimb')] = true;
+
+ $sum_actual_cost += $_actual_cost;
+
$actual_cost[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('ecodimb')]
+= $_actual_cost;
+
}
+
// _debug_array($obligations);
//----------- ad hoc order
@@ -707,7 +778,7 @@
. " FROM fm_tts_tickets"
. " $this->join fm_b_account ON
fm_tts_tickets.b_account_id = fm_b_account.id "
. " $this->join fm_location1 ON
fm_tts_tickets.loc1 = fm_location1.loc1 "
- . " $this->join fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id $filtermethod
$filtermethod2 $querymethod GROUP BY
fm_b_account.{$b_account_field},district_id,fm_tts_tickets.ecodimb";
+ . " $this->join fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id $filtermethod
$filtermethod2 $querymethod {$where} {$filtermethod_direction} GROUP BY
fm_b_account.{$b_account_field},district_id,fm_tts_tickets.ecodimb";
//_debug_array($sql);die();
$this->db->query($sql . $ordermethod,__LINE__,__FILE__);
@@ -732,14 +803,12 @@
. " FROM fm_tts_tickets"
. " $this->join fm_b_account ON
fm_tts_tickets.b_account_id = fm_b_account.id "
. " $this->join fm_location1 ON
fm_tts_tickets.loc1 = fm_location1.loc1 "
- . " $this->join fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id $filtermethod
$querymethod GROUP BY
fm_b_account.{$b_account_field},district_id,fm_tts_tickets.ecodimb";
+ . " $this->join fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id $filtermethod
$querymethod {$where} {$filtermethod_direction} GROUP BY
fm_b_account.{$b_account_field},district_id,fm_tts_tickets.ecodimb";
$sql = str_replace('budget', 'actual_cost', $sql);
$this->db->query($sql . $ordermethod,__LINE__,__FILE__);
- $sum_actual_cost = 0;
- $actual_cost = array();
while ($this->db->next_record())
{
$_actual_cost =
round($this->db->f('actual_cost'));
@@ -804,12 +873,14 @@
if( $details )
{
$sql = "SELECT budget_cost,b_account_id as
b_account_field,district_id,ecodimb FROM fm_budget"
- . " {$this->join} fm_b_account ON
fm_budget.b_account_id =fm_b_account.id WHERE year={$year} AND revision =
'$revision' $filtermethod GROUP BY
budget_cost,b_account_id,district_id,ecodimb";
+ . " {$this->join} fm_b_account ON
fm_budget.b_account_id =fm_b_account.id WHERE year={$year} AND revision =
'$revision' $filtermethod {$where} {$filtermethod_direction}"
+ . " GROUP BY
budget_cost,b_account_id,district_id,ecodimb";
}
else
{
$sql = "SELECT sum(budget_cost) as budget_cost
,fm_b_account.category as b_account_field,district_id,ecodimb FROM fm_budget"
- . " $this->join fm_b_account ON
fm_budget.b_account_id =fm_b_account.id WHERE year={$year} AND revision =
'$revision' $filtermethod GROUP BY fm_b_account.category,district_id,ecodimb";
+ . " $this->join fm_b_account ON
fm_budget.b_account_id =fm_b_account.id WHERE year={$year} AND revision =
'$revision' $filtermethod {$where} {$filtermethod_direction}"
+ . " GROUP BY
fm_b_account.category,district_id,ecodimb";
}
//_debug_array($sql);
$this->db->query($sql,__LINE__,__FILE__);
@@ -828,176 +899,8 @@
//_debug_array($budget_cost);die();
- $filtermethod = '';
- $where = 'AND';
- if($cat_ids)
- {
- $filtermethod .= " $where fm_workorder.category
IN (". implode(',', $cat_ids) . ')';
- $where = 'AND';
- }
- if ($grouping > 0)
- {
- $filtermethod .= " $where
fm_b_account.category='$grouping' ";
- $where = 'AND';
- }
-
- if ($district_id > 0)
- {
- $filtermethod .= " $where
district_id='$district_id' ";
- $where = 'AND';
- }
-
- if ($dimb_id > 0)
- {
- $filtermethod .= " $where dimb={$dimb_id}";
- $where = 'AND';
- }
-
- if($_department_dimb)
- {
- $filtermethod .= " $where dimb IN (" .
implode(',', $_department_dimb) . ')';
- $where = 'AND';
- }
-
-
- $start_periode = date('Ym',mktime(2,0,0,1,1,$year));
- $end_periode = date('Ym',mktime(2,0,0,12,31,$year));
-
- $this->db->query('SELECT id, percent FROM
fm_ecomva',__LINE__,__FILE__);
- $_taxcode = array(0 => 0);
- while ($this->db->next_record())
- {
- $_taxcode[$this->db->f('id')] =
$this->db->f('percent');
- }
-
-
-//-------start check paid workorder-----------
- $sql = "SELECT
fm_workorder.id,fm_workorder_status.closed,combined_cost,
fm_b_account.{$b_account_field} as {$b_account_field}, district_id,
sum(godkjentbelop) as actual_cost,dimb,mvakode"
- . " FROM fm_ecobilagoverf"
- . " {$this->join} fm_b_account ON
fm_ecobilagoverf.spbudact_code =fm_b_account.id"
- . " {$this->join} fm_location1 ON
fm_ecobilagoverf.loc1 = fm_location1.loc1"
- . " {$this->join} fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id"
- . " {$this->join} fm_workorder ON
fm_ecobilagoverf.pmwrkord_code = fm_workorder.id"
- . " {$this->join} fm_project ON
fm_workorder.project_id = fm_project.id"
- . " {$this->join} fm_workorder_status ON
fm_workorder.status = fm_workorder_status.id"
- . " WHERE periode >= $start_periode AND periode
<= $end_periode {$filtermethod}"
- . " GROUP BY fm_workorder.id,
fm_workorder_status.closed,combined_cost, fm_b_account.{$b_account_field},
district_id, dimb, mvakode";
-
- $this->db->query($sql,__LINE__,__FILE__);
-//_debug_array($sql);
- while ($this->db->next_record())
- {
-//continue;
- $_taxfactor = 1 +
($_taxcode[(int)$this->db->f('mvakode')]/100);
- $_actual_cost =
round($this->db->f('actual_cost')/$_taxfactor);
-
- $_combined_cost = $this->db->f('combined_cost');
-
- if($this->db->f('closed'))
- {
- $_diff_obligation = 0;
- }
- else if($_combined_cost > 0)
- {
- if(($_combined_cost - $_actual_cost) >
0)
- {
- $_diff_obligation =
$_actual_cost;
- }
- else
- {
- $_diff_obligation =
$_combined_cost;
- }
- }
- else if($_combined_cost < 0)
- {
- if(($_combined_cost - $_actual_cost) <
0)
- {
- $_diff_obligation =
$_actual_cost;
- }
- else
- {
- $_diff_obligation =
$_combined_cost;
- }
- }
- else
- {
- $_diff_obligation = 0;
- }
-
- $sum_obligation_cost -= $_diff_obligation;
- $sum_actual_cost += $_actual_cost;
-
$obligations[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('dimb')]
-= $_diff_obligation;
-
$actual_cost[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('dimb')]
+= $_actual_cost;
- $accout_info[$this->db->f($b_account_field)] =
true;
- $district[(int)$this->db->f('district_id')] =
true;
- $ecodimb[(int)$this->db->f('dimb')] = true;
- }
-
-// _debug_array($obligations);
-//-------end check paid-----------
-
-//-------start check active invoices, workorder-----------
- $sql = "SELECT fm_workorder.id,combined_cost,
fm_b_account.{$b_account_field} as {$b_account_field}, district_id,
sum(godkjentbelop) as actual_cost,dimb,mvakode"
- . " FROM fm_ecobilag"
- . " {$this->join} fm_b_account ON
fm_ecobilag.spbudact_code =fm_b_account.id"
- . " {$this->join} fm_location1 ON
fm_ecobilag.loc1 = fm_location1.loc1"
- . " {$this->join} fm_part_of_town ON
fm_location1.part_of_town_id = fm_part_of_town.part_of_town_id"
- . " {$this->join} fm_workorder ON
fm_ecobilag.pmwrkord_code = fm_workorder.id"
- . " {$this->join} fm_project ON
fm_workorder.project_id = fm_project.id"
- . " WHERE (periode >= 0 AND periode <=
$end_periode OR periode IS NULL) {$filtermethod}"
- . " GROUP BY fm_workorder.id, combined_cost,
fm_b_account.{$b_account_field}, district_id, dimb, mvakode";
-
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
-//continue;
- $_taxfactor = 1 +
($_taxcode[(int)$this->db->f('mvakode')]/100);
- $_actual_cost =
round($this->db->f('actual_cost')/$_taxfactor);
-
- $_combined_cost = $this->db->f('combined_cost');
-
- if($_combined_cost > 0)
- {
- if(($_combined_cost - $_actual_cost) >
0)
- {
- $_diff_obligation =
$_actual_cost;
- }
- else
- {
- $_diff_obligation =
$_combined_cost;
- }
- }
- else if($_combined_cost < 0)
- {
- if(($_combined_cost - $_actual_cost) <
0)
- {
- $_diff_obligation =
$_actual_cost;
- }
- else
- {
- $_diff_obligation =
$_combined_cost;
- }
- }
- else
- {
- $_diff_obligation = 0;
- }
-
- $sum_obligation_cost -= $_diff_obligation;
-
- $sum_actual_cost += $_actual_cost;
-
$obligations[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('dimb')]
-= $_diff_obligation;
-
$actual_cost[$this->db->f($b_account_field)][(int)$this->db->f('district_id')][(int)$this->db->f('dimb')]
+= $_actual_cost;
- $accout_info[$this->db->f($b_account_field)] =
true;
- $district[(int)$this->db->f('district_id')] =
true;
- $ecodimb[(int)$this->db->f('dimb')] = true;
- }
-
-//-------end check active invoices-----------
-
// start service agreements
$filtermethod = " fm_s_agreement_budget.year = $year";
@@ -1031,7 +934,7 @@
. " FROM fm_s_agreement"
. " {$this->join} fm_s_agreement_budget ON
fm_s_agreement.id = fm_s_agreement_budget.agreement_id"
. " $this->join fm_b_account ON
fm_s_agreement_budget.budget_account = fm_b_account.id "
- . " WHERE $filtermethod $querymethod GROUP BY
fm_b_account.{$b_account_field},fm_s_agreement_budget.ecodimb";
+ . " WHERE $filtermethod $querymethod {$where}
{$filtermethod_direction} GROUP BY
fm_b_account.{$b_account_field},fm_s_agreement_budget.ecodimb";
//_debug_array($sql);die();
$this->db->query($sql . $ordermethod,__LINE__,__FILE__);
@@ -1059,7 +962,7 @@
. " {$this->join} fm_b_account ON
fm_ecobilagoverf.spbudact_code =fm_b_account.id"
. " {$this->join} fm_s_agreement ON
fm_ecobilagoverf.pmwrkord_code = fm_s_agreement.id"
. " {$this->join} fm_s_agreement_budget ON
fm_s_agreement.id = fm_s_agreement_budget.agreement_id"
- . " WHERE periode >= $start_periode AND periode
<= $end_periode AND {$filtermethod}"
+ . " WHERE periode >= $start_periode AND periode
<= $end_periode AND {$filtermethod} {$where} {$filtermethod_direction}"
. " GROUP BY fm_b_account.{$b_account_field},
ecodimb";
//_debug_array($sql);
$this->db->query($sql,__LINE__,__FILE__);
@@ -1114,7 +1017,7 @@
. " {$this->join} fm_b_account ON
fm_ecobilag.spbudact_code =fm_b_account.id"
. " {$this->join} fm_s_agreement ON
fm_ecobilag.pmwrkord_code = fm_s_agreement.id"
. " {$this->join} fm_s_agreement_budget ON
fm_s_agreement.id = fm_s_agreement_budget.agreement_id"
- . " {$filtermethod}"
+ . " {$filtermethod} {$where}
{$filtermethod_direction}"
. " GROUP BY fm_b_account.{$b_account_field},
ecodimb";
//_debug_array($sql);
$this->db->query($sql,__LINE__,__FILE__);
Modified: branches/Version-1_0-branch/property/inc/class.sogeneric.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.sogeneric.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/inc/class.sogeneric.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -2412,12 +2412,31 @@
'name'
=> 'value',
'descr'
=> lang('value'),
'type'
=> 'numeric',
- 'nullable'
=> false,
+ 'nullable'
=> true,
'size'
=> 4,
'sortable'
=> true
),
array
(
+ 'name'
=> 'dividend',
+ 'descr'
=> lang('fraction::dividend'),
+ 'type'
=> 'integer',
+ 'nullable'
=> true,
+ 'size'
=> 4,
+ 'sortable'
=> true
+ ),
+ array
+ (
+ 'name'
=> 'divisor',
+ 'descr'
=> lang('fraction::divisor'),
+ 'type'
=> 'integer',
+ 'nullable'
=> true,
+ 'size'
=> 4,
+ 'sortable'
=> true
+ ),
+
+ array
+ (
'name' =>
'remark',
'descr' =>
lang('remark'),
'type' =>
'varchar',
Modified: branches/Version-1_0-branch/property/inc/class.soproject.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soproject.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/inc/class.soproject.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -37,6 +37,7 @@
class property_soproject
{
var $total_records = 0;
+ private $global_lock = false;
function __construct()
{
@@ -53,6 +54,8 @@
$this->acl = &
$GLOBALS['phpgw']->acl;
$this->acl->set_account_id($this->account);
$this->grants =
$this->acl->get_grants('property','.project');
+ $this->config =
CreateObject('phpgwapi.config','property');
+ $this->config->read();
}
function select_status_list()
@@ -645,7 +648,7 @@
}
$this->db->set_fetch_single(false);
-
+//$test=array();
foreach($project_list as &$project)
{
$this->db->query("{$sql} WHERE
fm_project.id = '{$project['project_id']}' {$group_method}");
@@ -671,89 +674,55 @@
$project['actual_cost'] = 0;
$project['billable_hours'] = 0;
- $sql_workder = 'SELECT combined_cost,
actual_cost, billable_hours,closed'//, contract_sum, addition, calculation,
budget'
- . " FROM fm_workorder {$this->join}
fm_workorder_status ON fm_workorder.status = fm_workorder_status.id"
- . " WHERE project_id =
'{$project['project_id']}'";
-//_debug_array($sql_workder);
+ $sql_workder_date_filter = '';
if ($start_date)
{
- $sql_workder .= " AND
fm_workorder.start_date >= $start_date AND fm_workorder.start_date <= $end_date
";
+ $sql_workder_date_filter = "AND
fm_workorder.start_date >= $start_date AND fm_workorder.start_date <= $end_date
";
}
- $this->db->query($sql_workder);
+ $sql_workder = 'SELECT
fm_workorder.id, budget, combined_cost, billable_hours, closed,
sum(fm_orders_paid_or_pending_view.amount) AS actual_cost'//, contract_sum,
addition, calculation, budget'
+ . " FROM fm_workorder"
+ . " {$this->join} fm_workorder_status
ON fm_workorder.status = fm_workorder_status.id"
+ . " {$this->left_join}
fm_orders_paid_or_pending_view ON fm_workorder.id =
fm_orders_paid_or_pending_view.order_id"
+ . " WHERE project_id =
'{$project['project_id']}' {$sql_workder_date_filter}"
+ . " GROUP BY fm_workorder.id, budget,
combined_cost, billable_hours, closed";
+//_debug_array($sql_workder);
+
+
$this->db->query($sql_workder,__LINE__,__FILE__);
+
+ $_obligation = 0;
+ $project['obligation'] = 0;
+
while ($this->db->next_record())
{
- $closed = false;
- if($this->db->f('closed'))
+ $_combined_cost =
$this->db->f('combined_cost');
+ $_actual_cost =
$this->db->f('actual_cost');
+ if(!$this->db->f('closed'))
{
- $_sum = 0;
- $closed = true;
+//$test[] = $this->db->f('id');
+ $_obligation =
$_combined_cost - $_actual_cost;
+
if((int)$this->db->f('budget') >= 0)
+ {
+ if($_obligation
< 0)
+ {
+
$_obligation = 0;
+ }
+ }
+ else
+ {
+ if($_obligation
> 0)
+ {
+
$_obligation = 0;
+ }
+ }
+ $project['obligation']
+= $_obligation;
}
- else
- {
- $_sum =
$this->db->f('combined_cost');
- }
-/*
- else
if(abs($this->db->f('contract_sum')) > 0)
- {
- $_sum =
$this->db->f('contract_sum') * ( 1 + ((int)$this->db->f('addition')/100));
- }
- else
if(abs($this->db->f('calculation')) > 0)
- {
- $_sum =
$this->db->f('calculation');
- }
- else
if(abs($this->db->f('budget')) > 0)
- {
- $_sum =
$this->db->f('budget');
- }
- else
- {
- $_sum = 0;
- }
-*/
- $_actual_cost =
(int)$this->db->f('actual_cost');
- if($closed)
- {
- $__actual_cost = 0;
- }
- else
- {
- $__actual_cost =
$_actual_cost;
- }
-
- $project['combined_cost']
+= ($_sum - $__actual_cost);
- $project['actual_cost']
+= $_actual_cost;
$project['billable_hours']
+= (int)$this->db->f('billable_hours');
- }
-
- $sql_workder = 'SELECT godkjentbelop
AS actual_cost'
- . " FROM fm_ecobilag {$this->join}
fm_workorder ON fm_ecobilag.pmwrkord_code = fm_workorder.id"
- . " WHERE fm_workorder.project_id =
'{$project['project_id']}'";
-
- $this->db->query($sql_workder);
- while ($this->db->next_record())
- {
- $_actual_cost =
(int)$this->db->f('actual_cost');
- $project['combined_cost']
-= $_actual_cost;
$project['actual_cost']
+= $_actual_cost;
}
- if($project['budget'] >= 0)
- {
- if($project['combined_cost'] <
0)
- {
-
$project['combined_cost'] = 0;
- }
- }
- else
- {
- if($project['combined_cost'] >
0)
- {
-
$project['combined_cost'] = 0;
- }
- }
-
+ $project['combined_cost'] =
$project['obligation'];
$project['diff'] = $project['budget']
- $project['combined_cost'] - $project['actual_cost'];
}
@@ -783,7 +752,7 @@
}
$values =
$this->custom->translate_value($dataset, $location_id);
-
+//_debug_array($test);
return $values;
}
@@ -884,22 +853,26 @@
function project_workorder_data($project_id = 0)
{
$project_id = (int) $project_id;
- $budget = array();
- $this->db->query("SELECT fm_workorder.title,
fm_workorder.actual_cost, fm_workorder.budget, fm_workorder.id as
workorder_id,fm_workorder.contract_sum,"
+ $values = array();
+ $this->db->query("SELECT
fm_workorder.title,combined_cost, fm_workorder.actual_cost,
fm_workorder.budget, fm_workorder.id as workorder_id,fm_workorder.contract_sum,"
. " fm_workorder.vendor_id,
fm_workorder.calculation,fm_workorder.rig_addition,fm_workorder.addition,fm_workorder.deviation,fm_workorder.charge_tenant,"
. " fm_workorder_status.descr as status,
fm_workorder_status.closed, fm_workorder.account_id as b_account_id"
. " FROM fm_workorder {$this->join}
fm_workorder_status ON fm_workorder.status = fm_workorder_status.id"
- . " WHERE project_id={$project_id}");
+ . " WHERE
project_id={$project_id}",__LINE__,__FILE__);
+ $_orders = array();
+
while ($this->db->next_record())
{
- $budget[] = array(
+ $values[] = array(
'workorder_id' =>
$this->db->f('workorder_id'),
'title' =>
$this->db->f('title',true),
'budget' =>
(int)$this->db->f('budget'),
'deviation' =>
$this->db->f('deviation'),
'calculation' =>
$this->db->f('calculation'),
- 'actual_cost' =>
$this->db->f('actual_cost'),
+ 'combined_cost' =>
(int)$this->db->f('combined_cost'),
+ 'actual_cost' => 0,
+ 'obligation' => 0,
'vendor_id' =>
$this->db->f('vendor_id'),
'charge_tenant' =>
$this->db->f('charge_tenant'),
'status' =>
$this->db->f('status'),
@@ -908,16 +881,63 @@
'contract_sum' =>
(int)$this->db->f('contract_sum'),
'addition_percentage' =>
(int)$this->db->f('addition')
);
+ $_orders[] = $this->db->f('workorder_id');
}
- foreach ($budget as &$entry)
+
+ if($_orders)
{
- $this->db->query("SELECT sum(godkjentbelop) AS
actual_cost FROM fm_ecobilag WHERE pmwrkord_code = '{$entry['workorder_id']}'
GROUP BY pmwrkord_code");
- $this->db->next_record();
- $entry['actual_cost']
+=$this->db->f('actual_cost');
+ $_actual_cost_arr = array();
+
+ $sql_cost = "SELECT order_id, sum(amount) AS
actual_cost"
+ . " FROM fm_workorder {$this->join}
fm_orders_paid_or_pending_view ON fm_workorder.id =
fm_orders_paid_or_pending_view.order_id"
+ . ' WHERE order_id IN (' . implode(',',
$_orders ) .') GROUP BY order_id';
+ $this->db->query($sql_cost,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+
$_actual_cost_arr[$this->db->f('order_id')] = $this->db->f('actual_cost');
+ }
}
- return $budget;
+ foreach ($values as &$entry)
+ {
+ $_combined_cost =
round($entry['combined_cost']);
+
+ $_actual_cost =
isset($_actual_cost_arr[$entry['workorder_id']]) &&
$_actual_cost_arr[$entry['workorder_id']] ?
$_actual_cost_arr[$entry['workorder_id']] : 0;
+
+ // FIXME
+ // $_taxfactor = 1 +
($_taxcode[(int)$this->db->f('mvakode')]/100);
+ // $_actual_cost = round($actual_cost/$_taxfactor);
+
+ $entry['actual_cost'] = $_actual_cost;
+
+ $_obligation = 0;
+ if(!$entry['closed'])
+ {
+ $_obligation = $_combined_cost -
$_actual_cost;
+ if($entry['budget'] >= 0)
+ {
+ if($_obligation < 0)
+ {
+ $_obligation = 0;
+ }
+ }
+ else
+ {
+ if($_obligation > 0)
+ {
+ $_obligation = 0;
+ }
+ }
+ $entry['obligation'] = $_obligation;
+ }
+
+ $_diff_start = abs($entry['budget']) > 0 ?
$entry['budget'] : $_combined_cost;
+ $entry['diff'] = $_diff_start -
$entry['obligation'] - $entry['actual_cost'];
+// $entry['diff'] = $entry['budget'] -
$entry['obligation'] - $entry['actual_cost'];
+ }
+
+ return $values;
}
function branch_p_list($project_id = '')
@@ -1049,7 +1069,7 @@
if($project['budget'])
{
- $this->updat_budget($id,
$project['budget_year'], $project['budget_periodization'], $project['budget']);
+ $this->update_budget($id,
$project['budget_year'], $project['budget_periodization'], $project['budget']);
}
if($project['extra']['contact_phone'] &&
$project['extra']['tenant_id'])
@@ -1274,15 +1294,151 @@
$this->delete_period_from_budget($project['id'], $project['delete_b_period']);
}
- if($project['budget'])
+ $workorders = array();
+
+ if($project['project_type_id']==3)//buffer
{
- $this->updat_budget($project['id'],
$project['budget_year'], $project['budget_periodization'], $project['budget']);
+ if($project['budget'])
+ {
+
$this->_update_buffer_budget($project['id'], $project['budget_year'],
$project['budget'], null,null);
+ }
+
}
+ else // investment or operation
+ {
+ if($project['budget'])
+ {
+ $this->update_budget($project['id'],
$project['budget_year'], $project['budget_periodization'], $project['budget']);
+ }
- $this->db->query("SELECT sum(budget) AS sum_budget FROM
fm_project_budget WHERE project_id = " . (int)$project['id'],__LINE__,__FILE__);
- $this->db->next_record();
- $new_budget =(int)$this->db->f('sum_budget');
+ $this->db->query("SELECT sum(budget) AS
sum_budget FROM fm_project_budget WHERE project_id = " .
(int)$project['id'],__LINE__,__FILE__);
+ $this->db->next_record();
+ $new_budget =(int)$this->db->f('sum_budget');
+ if ($old_budget != $new_budget)
+ {
+ $this->db->query("UPDATE fm_project SET
budget = {$new_budget} WHERE id = " . (int)$project['id'],__LINE__,__FILE__);
+
$historylog->add('B',$project['id'],$project['budget'], $old_budget);
+ }
+
+ $this->db->query("SELECT id FROM fm_workorder
WHERE project_id=" . (int)$project['id'] ,__LINE__,__FILE__);
+
+ while ($this->db->next_record())
+ {
+ $workorders[] = $this->db->f('id');
+ }
+
+ if ($workorders)
+ {
+ $historylog_workorder =
CreateObject('property.historylog','workorder');
+ }
+
+ if (isset($project['new_project_id']) &&
$project['new_project_id'] && ($project['new_project_id'] != $project['id']))
+ {
+ $new_project_id = (int)
$project['new_project_id'];
+ reset($workorders);
+ foreach($workorders as $workorder_id)
+ {
+
$historylog_workorder->add('NP',$workorder_id,$new_project_id, $project['id']);
+ }
+
+ $sql = "SELECT sum(budget) AS
sum_budget FROM fm_project_budget WHERE project_id = {$new_project_id}";
+
$this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $old_budget_new_project =
(int)$this->db->f('sum_budget');
+
+ $sql = "SELECT * FROM fm_project_budget
WHERE project_id = " . (int)$project['id'];
+
$this->db->query($sql,__LINE__,__FILE__);
+
+ $budget = array();
+ while ($this->db->next_record())
+ {
+ $budget[] = array
+ (
+ 'project_id'
=> (int)$project['id'],
+ 'year'
=> $this->db->f('year'),
+ 'month'
=> $this->db->f('month'),
+ 'budget'
=> (int)$this->db->f('budget'),
+ 'user_id'
=> $this->db->f('user_id'),
+ 'entry_date'
=> $this->db->f('entry_date'),
+ 'modified_date'
=> $this->db->f('modified_date'),
+ 'closed'
=> $this->db->f('closed'),
+ 'active'
=> $this->db->f('active')
+ );
+ }
+
+ foreach($budget as $entry)
+ {
+ $sql = "SELECT * FROM
fm_project_budget WHERE project_id = {$new_project_id} AND year =
{$entry['year']} AND month = {$entry['month']}";
+
$this->db->query($sql,__LINE__,__FILE__);
+ if($this->db->next_record())
+ {
+ $sql = "UPDATE
fm_project_budget SET budget = budget + {$entry['budget']} WHERE project_id =
{$new_project_id} AND year = {$entry['year']} AND month = {$entry['month']}";
+
$this->db->query($sql,__LINE__,__FILE__);
+ }
+ else
+ {
+ $value_set = array
+ (
+ 'project_id'
=> $new_project_id,
+ 'year'
=> $entry['year'],
+ 'month'
=> $entry['month'],
+ 'budget'
=> $entry['budget'],
+ 'user_id'
=> $entry['user_id'],
+ 'entry_date'
=> $entry['entry_date'],
+ 'modified_date'
=> $entry['modified_date'],
+ 'closed'
=> $entry['closed'],
+ 'active'
=> $entry['active']
+
+ );
+ $cols = implode(',',
array_keys($value_set));
+ $values =
$this->db->validate_insert(array_values($value_set));
+
$this->db->query("INSERT INTO fm_project_budget ({$cols}) VALUES
({$values})",__LINE__,__FILE__);
+ }
+ }
+
+ if ($old_budget)
+ {
+
$historylog->add('B',$project['id'],0, $old_budget);
+ }
+
+ $sql = "SELECT sum(budget) AS
sum_budget FROM fm_project_budget WHERE project_id = {$new_project_id}";
+
$this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $new_budget_new_project =
(int)$this->db->f('sum_budget');
+
+ $sql = "SELECT ecodimb FROM fm_project
WHERE id = {$new_project_id}";
+
$this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $ecodimb_new_project =
(int)$this->db->f('ecodimb');
+
+ $sql = "SELECT reserve FROM fm_project
WHERE id = " . (int)$project['id'];
+
$this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $reserve_old_project =
(int)$this->db->f('reserve');
+
+ if ($new_budget_new_project !=
$old_budget_new_project)
+ {
+
$historylog->add('B',$new_project_id, $new_budget_new_project,
$old_budget_new_project);
+ }
+
+ $this->db->query("UPDATE fm_workorder
SET project_id = {$new_project_id}, ecodimb = {$ecodimb_new_project} WHERE
project_id = {$project['id']}",__LINE__,__FILE__);
+ $this->db->query("UPDATE fm_project SET
reserve = 0 WHERE reserve IS NULL AND id = {$new_project_id}"
,__LINE__,__FILE__);
+ $this->db->query("UPDATE fm_project SET
budget = {$new_budget_new_project}, reserve = reserve + {$reserve_old_project}
WHERE id = {$new_project_id}" ,__LINE__,__FILE__);
+ $this->db->query("UPDATE fm_project SET
budget = 0, reserve = 0 WHERE id = " . (int)$project['id'] ,__LINE__,__FILE__);
+ $this->db->query("DELETE FROM
fm_project_budget WHERE project_id = " . (int)$project['id']
,__LINE__,__FILE__);
+
$historylog->add('RM',(int)$project['id'],"Budsjett og alle bestillinger er
overført fra prosjekt {$project['id']} til prosjekt {$new_project_id}");
+
$historylog->add('RM',$new_project_id,"Budsjett og alle bestillinger er
overført fra prosjekt {$project['id']} til prosjekt {$new_project_id}");
+
+ reset($workorders);
+ foreach($workorders as $workorder_id)
+ {
+
execMethod('property.soworkorder.update_order_budget',$workorder_id);
+ }
+ }
+
+ }
+
if($project['extra']['contact_phone'] &&
$project['extra']['tenant_id'])
{
$this->db->query("UPDATE fm_tenant SET
contact_phone='". $project['extra']['contact_phone']. "' WHERE id='".
$project['extra']['tenant_id']. "'",__LINE__,__FILE__);
@@ -1310,17 +1466,7 @@
}
$this->update_request_status($project['id'],$project['status'],$project['cat_id'],$project['coordinator']);
- $this->db->query("SELECT id FROM fm_workorder WHERE
project_id=" . (int)$project['id'] ,__LINE__,__FILE__);
- $workorders = array();
- while ($this->db->next_record())
- {
- $workorders[] = $this->db->f('id');
- }
- if ($workorders)
- {
- $historylog_workorder =
CreateObject('property.historylog','workorder');
- }
if (($old_status != $project['status']) ||
$project['confirm_status'])
{
@@ -1354,6 +1500,7 @@
unset($action_params);
}
+ $workorder_closed_status =
isset($this->config->config_data['workorder_closed_status']) &&
$this->config->config_data['workorder_closed_status'] ?
$this->config->config_data['workorder_closed_status'] : 'closed';
if($old_status != $project['status'])
{
@@ -1364,11 +1511,11 @@
{
$historylog->add('S',$project['id'],$project['status'], $old_status);
- $this->db->query("UPDATE fm_workorder
SET status='closed' WHERE project_id = {$project['id']}",__LINE__,__FILE__);
-
+ // $this->db->query("UPDATE fm_workorder
SET status='{$workorder_closed_status}' WHERE project_id =
{$project['id']}",__LINE__,__FILE__);
+ $this->_update_status_workorder(true,
$workorder_closed_status, $workorders);
foreach($workorders as $workorder_id)
{
-
$historylog_workorder->add('S',$workorder_id,'closed');
+ //
$historylog_workorder->add('S',$workorder_id,'closed');
}
$receipt['notice_owner'][]=lang('Status
changed') . ': ' . $project['status'];
@@ -1379,14 +1526,19 @@
if ($close_workorders)
{
+ // $this->db->query("UPDATE
fm_workorder SET status='{$workorder_closed_status}' WHERE project_id =
{$project['id']}",__LINE__,__FILE__);
+
+
$this->_update_status_workorder(true, $workorder_closed_status, $workorders);
foreach($workorders as
$workorder_id)
{
-
$historylog_workorder->add('SC',$workorder_id,'closed');
+ //
$historylog_workorder->add('SC',$workorder_id,'closed');
}
}
$receipt['notice_owner'][]=lang('Status
confirmed') . ': ' . $project['status'];
}
+/*
+ // Handled in _update_status_workorder();
if($close_pending_action)
{
$action_params = array
@@ -1409,6 +1561,7 @@
}
unset($action_params);
}
+*/
}
if(isset($project['project_group']) &&
$project['project_group'])
@@ -1430,13 +1583,7 @@
$receipt['notice_owner'][]=lang('Coordinator
changed') . ': ' .
$GLOBALS['phpgw']->accounts->id2name($project['coordinator']);
}
- if ($old_budget != $new_budget)
- {
- $this->db->query("UPDATE fm_project SET budget
= {$new_budget} WHERE id = " . (int)$project['id'],__LINE__,__FILE__);
-
$historylog->add('B',$project['id'],$project['budget'], $old_budget);
- }
-
if ($old_reserve != (int)$project['reserve'])
{
$historylog->add('BR',$project['id'],$project['reserve'], $old_reserve);
@@ -1447,101 +1594,8 @@
$historylog->add('RM',$project['id'],$project['remark']);
}
-// execMethod('property.soworkorder.update_planned_cost',
$project['id']);
- if (isset($project['new_project_id']) &&
$project['new_project_id'] && ($project['new_project_id'] != $project['id']))
- {
- $new_project_id = (int)
$project['new_project_id'];
- reset($workorders);
- foreach($workorders as $workorder_id)
- {
-
$historylog_workorder->add('NP',$workorder_id,$new_project_id, $project['id']);
- }
- $sql = "SELECT sum(budget) AS sum_budget FROM
fm_project_budget WHERE project_id = {$new_project_id}";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $old_budget_new_project =
(int)$this->db->f('sum_budget');
-
- $sql = "SELECT * FROM fm_project_budget WHERE
project_id = " . (int)$project['id'];
- $this->db->query($sql,__LINE__,__FILE__);
-
- $budget = array();
- while ($this->db->next_record())
- {
- $budget[] = array
- (
- 'project_id' =>
(int)$project['id'],
- 'year'
=> $this->db->f('year'),
- 'month'
=> $this->db->f('month'),
- 'budget'
=> (int)$this->db->f('budget'),
- 'user_id'
=> $this->db->f('user_id'),
- 'entry_date' =>
$this->db->f('entry_date'),
- 'modified_date' =>
$this->db->f('modified_date'),
- 'closed'
=> $this->db->f('closed'),
- 'active'
=> $this->db->f('active')
- );
- }
-
- foreach($budget as $entry)
- {
- $sql = "SELECT * FROM fm_project_budget
WHERE project_id = {$new_project_id} AND year = {$entry['year']} AND month =
{$entry['month']}";
-
$this->db->query($sql,__LINE__,__FILE__);
- if($this->db->next_record())
- {
- $sql = "UPDATE
fm_project_budget SET budget = budget + {$entry['budget']} WHERE project_id =
{$new_project_id} AND year = {$entry['year']} AND month = {$entry['month']}";
-
$this->db->query($sql,__LINE__,__FILE__);
- }
- else
- {
- $value_set = array
- (
- 'project_id'
=> $new_project_id,
- 'year'
=> $entry['year'],
- 'month'
=> $entry['month'],
- 'budget'
=> $entry['budget'],
- 'user_id'
=> $entry['user_id'],
- 'entry_date'
=> $entry['entry_date'],
- 'modified_date'
=> $entry['modified_date'],
- 'closed'
=> $entry['closed'],
- 'active'
=> $entry['active']
-
- );
- $cols = implode(',',
array_keys($value_set));
- $values =
$this->db->validate_insert(array_values($value_set));
- $this->db->query("INSERT INTO
fm_project_budget ({$cols}) VALUES ({$values})",__LINE__,__FILE__);
- }
- }
-
- if ($old_budget)
- {
- $historylog->add('B',$project['id'],0,
$old_budget);
- }
-
- $sql = "SELECT sum(budget) AS sum_budget FROM
fm_project_budget WHERE project_id = {$new_project_id}";
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $new_budget_new_project =
(int)$this->db->f('sum_budget');
-
- $sql = "SELECT reserve FROM fm_project WHERE id
= " . (int)$project['id'];
- $this->db->query($sql,__LINE__,__FILE__);
- $this->db->next_record();
- $reserve_old_project =
(int)$this->db->f('reserve');
-
- if ($new_budget_new_project !=
$old_budget_new_project)
- {
- $historylog->add('B',$new_project_id,
$new_budget_new_project, $old_budget_new_project);
- }
-
- $this->db->query("UPDATE fm_workorder SET
project_id = {$new_project_id} WHERE project_id =
{$project['id']}",__LINE__,__FILE__);
- $this->db->query("UPDATE fm_project SET reserve
= 0 WHERE reserve IS NULL AND id = {$new_project_id}" ,__LINE__,__FILE__);
- $this->db->query("UPDATE fm_project SET budget
= {$new_budget_new_project}, reserve = reserve + {$reserve_old_project} WHERE
id = {$new_project_id}" ,__LINE__,__FILE__);
- $this->db->query("UPDATE fm_project SET budget
= 0, reserve = 0 WHERE id = " . (int)$project['id'] ,__LINE__,__FILE__);
- $this->db->query("DELETE FROM fm_project_budget
WHERE project_id = " . (int)$project['id'] ,__LINE__,__FILE__);
-
$historylog->add('RM',(int)$project['id'],"Budsjett og alle bestillinger er
overført fra prosjekt {$project['id']} til prosjekt {$new_project_id}");
- $historylog->add('RM',$new_project_id,"Budsjett
og alle bestillinger er overført fra prosjekt {$project['id']} til prosjekt
{$new_project_id}");
- }
-
$receipt['id'] = $project['id'];
$receipt['message'][] = array('msg'=>lang('project %1
has been edited', $project['id']));
@@ -1562,7 +1616,7 @@
}
- function updat_budget($project_id, $year, $periodization_id,
$budget)
+ function update_budget($project_id, $year, $periodization_id,
$budget)
{
$project_id = (int) $project_id;
$year = $year ? (int) $year : date('Y');
@@ -1572,13 +1626,15 @@
if($periodization_id)
{
- $this->db->query("SELECT month, value FROM
fm_eco_periodization_outline WHERE periodization_id = {$periodization_id} ORDER
BY month ASC",__LINE__,__FILE__);
+ $this->db->query("SELECT month,
value,dividend,divisor 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'),
+ 'dividend' =>
$this->db->f('dividend'),
+ 'divisor' =>
$this->db->f('divisor')
);
}
}
@@ -1588,14 +1644,25 @@
(
'month' => 0,
'value' => 100,
+ 'dividend' => 1,
+ 'divisor' => 1,
+
);
}
foreach ($periodization_outline as $outline)
{
- $partial_budget = $budget * $outline['value'] /
100;
- $this->_updat_budget($project_id, $year,
$outline['month'], $partial_budget);
+ if ($outline['dividend'] && $outline['divisor'])
+ {
+ $partial_budget = $budget *
$outline['dividend'] / $outline['divisor'];
+ }
+ else
+ {
+ $partial_budget = $budget *
$outline['value'] / 100;
+ }
+
+ $this->_update_budget($project_id, $year,
$outline['month'], $partial_budget);
}
$sql = "SELECT sum(budget) as sum_budget FROM
fm_project_budget WHERE project_id = {$project_id}";
@@ -1607,9 +1674,75 @@
return $sum_budget;
}
+ public function get_buffer_budget($project_id)
+ {
+ $sql = "SELECT * FROM fm_project_buffer_budget WHERE
buffer_project_id = {$project_id}";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $values = array();
+ while ($this->db->next_record())
+ {
+ $values[] = array
+ (
+ 'buffer_project_id' =>
$this->db->f('buffer_project_id'),
+ 'year' =>
$this->db->f('year'),
+ 'amount_in' =>
$this->db->f('amount_in'),
+ 'amount_out' =>
$this->db->f('amount_out'),
+ 'from_project' =>
$this->db->f('from_project'),
+ 'to_project' =>
$this->db->f('to_project'),
+ 'user_id' =>
$this->db->f('this->account'),
+ 'entry_date' =>
$this->db->f('entry_date'),
+ 'active' =>
!!$this->db->f('active'),
+ 'remark' =>
$this->db->f('remark',true)
+ );
+ }
+ return $values;
+ }
- private function _updat_budget($project_id, $year, $month,
$budget)
+ private function _update_buffer_budget($project_id, $year,
$amount, $from_project, $to_project)
{
+ $year = (int) $year;
+ $amount = (int) $amount;
+
+ if(!$year)
+ {
+ $year = date('Y');
+ }
+
+ if($from_project || (!$from_project && !$to_project))
+ {
+ $amount_in = $amount;
+ $amount_out = null;
+ }
+ else if ($to_project && !$from_project)
+ {
+ $amount_in = null;
+ $amount_out = $amount;
+ }
+ else
+ {
+ throw new
Exception('property_soproject::update_buffer_budget() - wrong input');
+ }
+
+ $value_set = array
+ (
+ 'buffer_project_id' => $project_id,
+ 'year' => $year,
+ 'amount_in' => $amount_in,
+ 'amount_out' => $amount_out,
+ 'from_project' => $from_project,
+ 'to_project' => $to_project,
+ 'user_id' =>
$this->account,
+ 'entry_date' => time(),
+ 'active' => 1
+ );
+
+ $cols = implode(',', array_keys($value_set));
+ $values =
$this->db->validate_insert(array_values($value_set));
+ $this->db->query("INSERT INTO fm_project_buffer_budget
({$cols}) VALUES ({$values})",__LINE__,__FILE__);
+ }
+
+ private function _update_budget($project_id, $year, $month,
$budget)
+ {
$month = (int) $month;
$budget = (int) $budget;
$now = time();
@@ -1633,7 +1766,7 @@
'user_id' =>
$this->account,
'entry_date' => $now,
'modified_date' => $now,
- 'active' => 1
+// 'active' => 1
);
$cols = implode(',', array_keys($value_set));
@@ -1650,86 +1783,70 @@
$closed_period = array();
$active_period = array();
$project_budget = array();
- $project_order_amount = array();
+ $project_total_budget = 0;
- $sql = "SELECT * FROM fm_project_budget WHERE
project_id = {$project_id}";
+ $sql = "SELECT fm_project_budget.year,
fm_project_budget.month, fm_project_budget.budget, fm_project_budget.closed,
fm_project_budget.active, sum(combined_cost) AS order_amount, start_date"
+ . " FROM fm_project_budget {$this->left_join}
fm_workorder ON fm_project_budget.project_id = fm_workorder.project_id WHERE
fm_project_budget.project_id = {$project_id}"
+ . " GROUP BY fm_project_budget.year,
fm_project_budget.month, fm_project_budget.budget, fm_project_budget.closed,
fm_project_budget.active,start_date";
$this->db->query($sql,__LINE__,__FILE__);
-
+// _debug_array($sql);
while ($this->db->next_record())
{
$period = $this->db->f('year') .
sprintf("%02s", $this->db->f('month'));
$project_budget[$period] =
(int)$this->db->f('budget');
- $project_order_amount[$period] =
$this->db->f('order_amount');
$closed_period[$period] =
!!$this->db->f('closed');
$active_period[$period] =
!!$this->db->f('active');
}
+ $project_total_budget = array_sum($project_budget);
- $sql = "SELECT id AS order_id FROM fm_workorder WHERE
project_id = {$project_id}";
+ $sql = "SELECT fm_workorder.id AS order_id,
fm_workorder_budget.combined_cost, fm_workorder_budget.budget,
fm_workorder_budget.year, fm_workorder_budget.month, fm_workorder_status.closed"
+ . " FROM fm_workorder"
+ . " {$this->join} fm_workorder_status ON
fm_workorder.status = fm_workorder_status.id"
+ . " {$this->join} fm_workorder_budget ON
fm_workorder.id = fm_workorder_budget.order_id"
+ . " WHERE project_id = {$project_id}";
+// _debug_array($sql);
$this->db->query($sql,__LINE__,__FILE__);
+ $_order_list = array();
$_orders = array();
while ($this->db->next_record())
{
- $_orders[] = $this->db->f('order_id');
+ $period = $this->db->f('year') .
sprintf("%02s", $this->db->f('month'));
+ $_order_list[] = $this->db->f('order_id');
+ $_orders[$period][$this->db->f('order_id')] =
array
+ (
+ 'combined_cost' =>
$this->db->f('combined_cost'),
+ 'budget' =>
$this->db->f('budget'),
+ 'actual_cost' => 0, //for now..
+ 'closed' =>
!!$this->db->f('closed')
+ );
}
-
- $orders = array();
- if($_orders)
+//_debug_array($_orders);
+$test = 0;
+ if ( $_order_list )
{
- $_order_filter = implode(',', $_orders);
- $sql = "SELECT sum(godkjentbelop) AS
actual_cost, pmwrkord_code AS order, periode FROM fm_ecobilagoverf WHERE
pmwrkord_code IN ({$_order_filter}) GROUP BY pmwrkord_code, periode ORDER BY
periode ASC ";
-
+ $sql = "SELECT order_id, periode, amount AS
actual_cost"
+ . " FROM fm_workorder {$this->join}
fm_orders_paid_or_pending_view ON fm_workorder.id =
fm_orders_paid_or_pending_view.order_id"
+ . ' WHERE order_id IN (' . implode(',',
$_order_list ) .') ORDER BY periode ASC';
+//_debug_array($sql);
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
+ $_order_id = $this->db->f('order_id');
$periode = $this->db->f('periode');
-
- $year = substr( $periode, 0, 4 );
-
- $_found = false;
- if(isset($project_budget[$periode]))
- {
-
$orders[$periode][$this->db->f('order')]['actual_cost'] +=
$this->db->f('actual_cost');
- $_found = true;
- }
- else
- {
- for ($i=0;$i<13;$i++)
- {
- $_period = $year .
sprintf("%02s", $i);
-
if(isset($project_budget[$_period]))
- {
-
$orders[$_period][$this->db->f('order')]['actual_cost'] +=
$this->db->f('actual_cost');
- $_found = true;
- break;
- }
- }
- }
-
- if(!$_found)
- {
-
$orders[$periode][$this->db->f('order')]['actual_cost'] +=
$this->db->f('actual_cost');
- }
- }
-//_debug_array($orders);die();
- $sql = "SELECT sum(godkjentbelop) AS
actual_cost, pmwrkord_code AS order, periode FROM fm_ecobilag WHERE
pmwrkord_code IN ({$_order_filter}) GROUP BY pmwrkord_code, periode ORDER BY
pmwrkord_code, periode ASC ";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $periode = $this->db->f('periode');
- $year = substr( $periode, 0, 4 );
if(!$periode)
{
- $year = date('Y');
$periode = date('Ym');
}
+ $year = substr( $periode, 0, 4 );
+
$_found = false;
if(isset($project_budget[$periode]))
{
-
$orders[$periode][$this->db->f('order')]['actual_cost'] +=
$this->db->f('actual_cost');
+
$_orders[$periode][$_order_id]['actual_cost'] += $this->db->f('actual_cost');
$_found = true;
}
else
@@ -1739,7 +1856,8 @@
$_period = $year .
sprintf("%02s", $i);
if(isset($project_budget[$_period]))
{
-
$orders[$_period][$this->db->f('order')]['actual_cost'] +=
$this->db->f('actual_cost');
+
$_orders[$_period][$_order_id]['actual_cost'] += $this->db->f('actual_cost');
+//_debug_array($test+=$this->db->f('actual_cost'));
$_found = true;
break;
}
@@ -1748,206 +1866,139 @@
if(!$_found)
{
-
$orders[$periode][$this->db->f('order')]['actual_cost'] +=
$this->db->f('actual_cost');
+
$_orders[$periode][$_order_id]['actual_cost'] += $this->db->f('actual_cost');
}
}
}
- $this->db->query("SELECT periodization_id FROM
fm_project WHERE id = {$project_id}",__LINE__,__FILE__);
- $this->db->next_record();
- if($this->db->f('periodization_id'))
- {
- $_use_periodization = true;
- }
- else
- {
- $_use_periodization = false;
- }
+//_debug_array($_orders);die();
- if(!$_use_periodization)
- {
- $config =
CreateObject('phpgwapi.config','property');
- $config->read();
- $tax = 1+(($config->config_data['fm_tax'])/100);
-
- $sql = "SELECT fm_workorder.id,
sum(calculation) as calculation, sum(budget) as budget, sum(contract_sum) as
contract_sum, fm_workorder.addition, start_date"
- . " FROM fm_workorder"
- . " {$this->join} fm_workorder_status ON
fm_workorder.status = fm_workorder_status.id"
- . " WHERE project_id = {$project_id} AND
(fm_workorder_status.closed IS NULL OR fm_workorder_status.closed != 1)"
- . " GROUP BY fm_workorder.id,
fm_workorder.start_date,fm_workorder.addition ORDER BY start_date ASC";
- $this->db->query($sql,__LINE__,__FILE__);
-
- while ($this->db->next_record())
- {
- $_found = false;
- $_start_date =
$this->db->f('start_date');
- $_order_period = date('Ym',
$_start_date);
-
- $year = date('Y');
-
- if($_use_periodization)
- {
- $periode = $_order_period;
-
if(isset($project_budget[$periode]))
- {
- $_found = true;
- }
- }
-
- if(!$_found) //move to current
- {
- $check_months = array(0,
date('m'));
- foreach ($check_months as $i)
- {
- $periode = $year .
sprintf("%02s", $i);
-
if(isset($project_budget[$periode]))
- {
- $_found = true;
- break;
- }
- }
- }
-
- if(!$_found)
- {
- $periode = date('Ym');
- }
-
- if(abs($this->db->f('contract_sum')) >
0)
- {
- $_amount =
$this->db->f('contract_sum') * ( 1 + ((int)$this->db->f('addition')/100));
- }
- else
if(abs($this->db->f('calculation')) > 0)
- {
- $_amount =
$this->db->f('calculation') * $tax;
- }
- else if(abs($this->db->f('budget')) > 0)
- {
- $_amount =
$this->db->f('budget');
- }
- else
- {
- $_amount = 0;
- }
-
-
$orders[$periode][$this->db->f('id')]['amount'] = $_amount;
- }
- unset($periode);
- }
- else
- {
-
- //FIXME
- foreach ($project_order_amount as $periode =>
$_amount)
- {
- $orders[$periode][] = array('amount' =>
$_amount);
- }
-
- }
-
$sort_period = array();
$values = array();
-
+//_debug_array($project_budget);die();
+//$test = 0;
+ $_delay_period = 0;
foreach ($project_budget as $period => $_budget)
{
- $_sum_orders = 0;
+ $_sum_orders = array();
+ $_sum_oblications = array();
$_actual_cost = 0;
- if(isset($orders[$period]))
+ if(isset($_orders[$period]))
{
- foreach ($orders[$period] as $order_id
=> $order)
+//_debug_array($_orders[$period]);die();
+
+ foreach ($_orders[$period] as $order_id
=> $order)
{
- $_sum_orders +=
$order['amount'];
- // $_sum_orders -=
$order['actual_cost'];
+ $_actual_cost +=
$order['actual_cost'];
+//_debug_array( $test+= $order['actual_cost']);
+ $_sum_orders[$order_id] +=
$order['combined_cost'];
- if($_budget >= 0)
+ if(!$order['closed'])
{
-
if($order['actual_cost'] >= 0)
+
$_sum_oblications[$order_id] += $order['combined_cost'];
+
$_sum_oblications[$order_id] -= $order['actual_cost'];
+
+
if($project_total_budget >= 0)
{
- $_sum_orders -=
$order['actual_cost'];
- }
- else
- {
- $_sum_orders +=
$order['actual_cost'];
- }
- $_sum_orders =
$_sum_orders > 0 ? $_sum_orders : 0;
- }
- else // income
- {
-
if($order['actual_cost'] >= 0)
- {
- $_sum_orders +=
$order['actual_cost'];
+
if($_sum_oblications[$order_id] < 0)
+ {
+
$_sum_oblications[$order_id] = 0;
+ }
}
- else
+ else // income
{
- $_sum_orders -=
$order['actual_cost'];
+
if($_sum_oblications[$order_id] > 0)
+ {
+
$_sum_oblications[$order_id] = 0;
+ }
}
-
- $_sum_orders =
$_sum_orders < 0 ? $_sum_orders : 0;
}
-
- $_actual_cost +=
$order['actual_cost'];
//override if periode is closed
+
if(!isset($active_period[$period]) || !$active_period[$period])
+ {
+ $_delay_period +=
$_sum_oblications[$order_id];
+
$_sum_oblications[$order_id] = 0;
+ }
+ //override if periode is closed
if(isset($closed_period[$period]) && $closed_period[$period])
{
- $_sum_orders = 0;
+
$_sum_oblications[$order_id] = 0;
}
}
- unset($orders[$period]);
+ unset($_orders[$period]);
}
+ if(isset($active_period[$period]) &&
$active_period[$period] && $_delay_period)
+ {
+ $_sum_oblications[] += $_delay_period;
+ $_delay_period =0;
+ }
+
+//die();
$values[] = array
(
'project_id' =>
$project_id,
'period'
=> $period,
'budget'
=> $_budget,
- 'sum_orders' =>
$_sum_orders,
+ 'sum_orders' =>
array_sum($_sum_orders),
+ 'sum_oblications' =>
array_sum($_sum_oblications),
'actual_cost' =>
$_actual_cost,
);
$sort_period[] = $period;
}
-//_debug_array($values);die();
+
unset($order);
unset($order_id);
unset($period);
- reset($orders);
+ reset($_orders);
//remaining
-//_debug_array($orders);
- foreach ($orders as $period => $_orders)
+
+ foreach ($_orders as $period => $orders)
{
- $_sum_orders = 0;
+ $_sum_orders = array();
+ $_sum_oblications = array();
$_actual_cost = 0;
- foreach ($_orders as $order_id => $order)
+ foreach ($orders as $order_id => $order)
{
- $_sum_orders += $order['amount'];
-
- if($order['actual_cost'] > 0 &&
($order['amount'] - $order['actual_cost']) > 0)
+ $_actual_cost += $order['actual_cost'];
+
+ $_sum_orders[$order_id] +=
$order['combined_cost'];
+
+ if(!$order['closed'])
{
- $_sum_orders -=
$order['actual_cost'];
- $_sum_orders = $_sum_orders > 0
? $_sum_orders : 0;
+ $_sum_oblications[$order_id] -=
$order['actual_cost'];
+ $_sum_oblications[$order_id] +=
$order['combined_cost'];
+
+ if($project_total_budget >= 0)
+ {
+
if($_sum_oblications[$order_id] < 0)
+ {
+
$_sum_oblications[$order_id] = 0;
+ }
+ }
+ else // income
+ {
+
if($_sum_oblications[$order_id] > 0)
+ {
+
$_sum_oblications[$order_id] = 0;
+ }
+ }
}
- else if($order['actual_cost'] < 0 &&
($order['amount'] - $order['actual_cost']) < 0)//income
- {
- $_sum_orders -=
$order['actual_cost'];
- $_sum_orders = $_sum_orders < 0
? $_sum_orders : 0;
- }
- $_actual_cost += $order['actual_cost'];
-
//override if periode is closed
if(isset($closed_period[$period]) &&
$closed_period[$period])
{
- $_sum_orders = 0;
+ $_sum_oblications[$order_id] =
0;
}
-
}
$values[] = array
@@ -1955,7 +2006,8 @@
'project_id' =>
$project_id,
'period'
=> $period,
'budget'
=> 0,
- 'sum_orders' =>
$_sum_orders,
+ 'sum_orders' =>
array_sum($_sum_orders),
+ 'sum_oblications' =>
array_sum($_sum_oblications),
'actual_cost' =>
$_actual_cost,
);
@@ -1975,16 +2027,19 @@
$entry['month'] = $month == '00' ? '' : $month;
if($active_period[$entry['period']])
{
- $entry['diff'] = $entry['budget'] -
$entry['sum_orders'] - $entry['actual_cost'];
+ $_diff_start = abs($entry['budget']) >
0 ? $entry['budget'] : $entry['sum_orders'];
+ $entry['diff'] = $_diff_start -
$entry['sum_oblications'] - $entry['actual_cost'];
}
else
{
$entry['diff'] = 0;
}
-
- $deviation = $entry['budget'] -
$entry['actual_cost'];
- $entry['deviation'] = $deviation;
- $entry['deviation_percent'] =
$deviation/$entry['budget'] * 100;
+ $_deviation = $entry['budget'] -
$entry['actual_cost'];
+ $deviation = abs($entry['actual_cost']) > 0 ?
$_deviation : 0;
+ $entry['deviation_period'] = $deviation;
+ $entry['deviation_acc'] += $deviation;
+ $entry['deviation_percent_period'] =
$deviation/$entry['budget'] * 100;
+ $entry['deviation_percent_acc'] =
$entry['deviation_acc']/$entry['budget'] * 100;
$entry['closed'] =
$closed_period[$entry['period']];
$entry['active'] =
$active_period[$entry['period']];
}
@@ -2202,22 +2257,36 @@
}
- function bulk_update_status($start_date, $end_date,
$status_filter, $status_new, $execute, $type, $user_id = 0,$ids,$paid = false,
$closed_orders = false)
+ function bulk_update_status($start_date, $end_date,
$status_filter, $status_new, $execute, $type, $user_id = 0,$ids,$paid = false,
$closed_orders = false, $ecodimb = 0)
{
$start_date = $start_date ?
phpgwapi_datetime::date_to_timestamp($start_date) : time();
+ $start_date -= 3600*24;
$end_date = $end_date ?
phpgwapi_datetime::date_to_timestamp($end_date) : time();
$filter = '';
if($user_id)
{
$user_id = (int) $user_id;
- $filter = "AND fm_{$type}.user_id = $user_id";
+ $filter .= "AND fm_{$type}.user_id = $user_id";
}
+ if($ecodimb)
+ {
+ $ecodimb = (int) $ecodimb;
+ $filter .= "AND fm_{$type}.ecodimb = $ecodimb";
+ }
+
if($status_filter)
{
- $user_id = (int) $user_id;
- $filter .= "AND fm_{$type}.status =
'{$status_filter}'";
+ if($status_filter == 'open')
+ {
+ $filter .= " AND
fm_{$type}_status.closed IS NULL";
+
+ }
+ else
+ {
+ $filter .= " AND
fm_{$type}.status='{$status_filter}' ";
+ }
}
switch($type)
@@ -2255,7 +2324,7 @@
}
$this->_update_status_workorder($execute, $status_new, $ids);
- $sql = "SELECT {$table}.id,
$status_table.descr as status ,{$title_field},start_date {$actual_cost} FROM
{$table}"
+ $sql = "SELECT {$table}.id, project_id,
$status_table.descr as status ,{$title_field},start_date {$actual_cost} FROM
{$table}"
. " {$join_method}"
. " WHERE ({$table}.start_date >
{$start_date} AND {$table}.start_date < {$end_date} {$filter}) OR start_date is
NULL"
. " ORDER BY {$table}.id DESC";
@@ -2273,6 +2342,7 @@
$values[] = array
(
'id' =>
$this->db->f('id'),
+ 'project_id' =>
$this->db->f('project_id'),
'title' =>
htmlspecialchars_decode($this->db->f('title',true)),
'status' =>
$this->db->f('status',true),
'actual_cost' =>
(float)$this->db->f('actual_cost'),
@@ -2294,6 +2364,7 @@
}
$historylog =
CreateObject('property.historylog','project');
+ $workorder_closed_status =
isset($this->config->config_data['workorder_closed_status']) &&
$this->config->config_data['workorder_closed_status'] ?
$this->config->config_data['workorder_closed_status'] : false;
$this->db->transaction_begin();
foreach ($ids as $id)
@@ -2328,10 +2399,28 @@
$this->db->query("SELECT * FROM
fm_project_status WHERE id = '{$status_new}'");
$this->db->next_record();
- if ($this->db->f('approved') ||
$this->db->f('closed'))
+ $approved = $this->db->f('approved');
+ $closed = $this->db->f('closed');
+
+ if ($approved || $closed)
{
execMethod('property.sopending_action.close_pending_action',
$action_params_approved);
}
+
+ if($closed && $workorder_closed_status)
+ {
+ $sql = "SELECT fm_workorder.id FROM
fm_workorder"
+ . " {$this->join} fm_workorder_status
ON fm_workorder.status = fm_workorder_status.id"
+ . " WHERE project_id = '{$id}' AND
closed IS NULL";
+
+ $this->db->query($sql);
+ $orders[] = array();
+ while($this->db->next_record())
+ {
+ $orders[] = $this->db->f('id');
+ }
+
$this->_update_status_workorder($execute, $workorder_closed_status, $orders);
+ }
}
$this->db->transaction_commit();
@@ -2346,7 +2435,15 @@
}
$historylog =
CreateObject('property.historylog','workorder');
- $this->db->transaction_begin();
+ if ( $this->db->get_transaction() )
+ {
+ $this->global_lock = true;
+ }
+ else
+ {
+ $this->db->transaction_begin();
+ }
+
foreach ($ids as $id)
{
if(!$id)
@@ -2363,7 +2460,7 @@
{
$this->db->query("UPDATE fm_workorder
SET status = '{$status_new}' WHERE id = '{$id}'",__LINE__,__FILE__);
$historylog->add('S', $id, $status_new,
$old_status);
- $historylog->add('RM', $id,'Status
endret via masseoppdatering');
+ $historylog->add('RM', $id,'Status
endret via masseoppdatering eller prosjekt');
}
$action_params_approved = array
@@ -2407,7 +2504,10 @@
}
}
- $this->db->transaction_commit();
+ if ( !$this->global_lock )
+ {
+ $this->db->transaction_commit();
+ }
}
public function get_user_list()
Modified: branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/inc/class.soworkorder.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -276,6 +276,7 @@
$joinmethod .= " {$this->join}
fm_workorder_status ON (fm_workorder.status = fm_workorder_status.id))";
$paranthesis .='(';
+ $cols .= ',fm_workorder_status.closed';
$cols .= ',fm_vendor.org_name';
$cols_return[] = 'org_name';
$uicols['input_type'][] = 'hidden';
@@ -305,7 +306,7 @@
$cols .= ',fm_workorder.combined_cost';
$cols_return[] = 'combined_cost';
$uicols['input_type'][] = 'text';
- $uicols['name'][] =
'combined_cost';
+ $uicols['name'][] =
'obligation';
$uicols['descr'][] =
lang('sum orders');
$uicols['statustext'][] = lang('Cost -
either budget or calculation');
$uicols['exchange'][] = false;
@@ -716,13 +717,36 @@
$count_cols_return=count($cols_return);
+ $_order_list = array();
while ($this->db->next_record())
{
$workorder_list[] = array('workorder_id' =>
$this->db->f('id'));
+ $_order_list[] = $this->db->f('id');
}
$this->db->set_fetch_single(false);
+ $_actual_cost_arr = array();
+ if($workorder_list)
+ {
+ $sql_cost = "SELECT fm_workorder.id as
order_id,closed, sum(amount) AS actual_cost"
+ . " FROM fm_workorder {$this->left_join}
fm_orders_paid_or_pending_view ON fm_workorder.id =
fm_orders_paid_or_pending_view.order_id"
+ . " {$this->join} fm_workorder_status ON
fm_workorder.status = fm_workorder_status.id"
+ . ' WHERE fm_workorder.id IN (' . implode(',',
$_order_list ) .') GROUP BY fm_workorder.id, closed';
+
+ unset($_order_list);
+ $this->db->query($sql_cost,__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+
$_actual_cost_arr[$this->db->f('order_id')] = array
+ (
+ 'actual_cost' =>
$this->db->f('actual_cost'),
+ 'closed' =>
!!$this->db->f('closed')
+ );
+ }
+
+ }
+
foreach($workorder_list as &$workorder)
{
$this->db->query("{$sql} WHERE fm_workorder.id
= '{$workorder['workorder_id']}'");
@@ -732,8 +756,41 @@
{
$workorder[$cols_return[$i]] =
$this->db->f($cols_return[$i]);
}
- $workorder['budget'] =
$workorder['combined_cost'];
- $workorder['combined_cost'] =
$workorder['combined_cost'] - $workorder['actual_cost'];
+ $workorder['actual_cost'] = 0;
+ $workorder['obligation'] = 0;
+
+ if
(isset($_actual_cost_arr[$workorder['workorder_id']]))
+ {
+ $_combined_cost =
$workorder['combined_cost'];
+ // $_pending_cost =
round($this->db2->f('pending_cost'));
+
+ // $_taxfactor = 1 +
($_taxcode[(int)$this->db2->f('mvakode')]/100);
+ // $_actual_cost =
round($this->db2->f('actual_cost')/$_taxfactor);
+ // $_actual_cost =
round($this->db2->f('actual_cost'));
+ $workorder['actual_cost'] =
$_actual_cost_arr[$workorder['workorder_id']]['actual_cost'];
+
+
if(!$_actual_cost_arr[$workorder['workorder_id']]['closed'])
+ {
+ $_obligation = $_combined_cost
- $workorder['actual_cost'];
+ if((int)$workorder['budget'] >=
0)
+ {
+ if($_obligation < 0)
+ {
+ $_obligation =
0;
+ }
+ }
+ else
+ {
+ if($_obligation > 0)
+ {
+ $_obligation =
0;
+ }
+ }
+ $workorder['obligation'] =
$_obligation;
+ }
+ }
+
+//---------
$workorder['grants'] =
(int)$this->grants[$this->db->f('project_owner')];
$location_code= $this->db->f('location_code');
@@ -746,35 +803,8 @@
$workorder['query_location']['loc' .
($m+1)]=implode("-", array_slice($location, 0, ($m+1)));
}
- $sql_workder = 'SELECT godkjentbelop AS
actual_cost'
- . " FROM fm_ecobilag WHERE pmwrkord_code =
'{$workorder['workorder_id']}'";
- $this->db->query($sql_workder);
- while ($this->db->next_record())
- {
- $_actual_cost =
(int)$this->db->f('actual_cost');
- $workorder['combined_cost'] -=
$_actual_cost;
- $workorder['actual_cost'] +=
$_actual_cost;
- }
-
-
-
- if($workorder['budget'] > 0)
- {
- if($workorder['combined_cost'] < 0)
- {
- $workorder['combined_cost'] = 0;
- }
- }
- else
- {
- if($workorder['combined_cost'] > 0)
- {
- $workorder['combined_cost'] = 0;
- }
- }
-
- $workorder['diff'] = $workorder['budget'] -
$workorder['combined_cost'] - $workorder['actual_cost'];
+ $workorder['diff'] = $workorder['budget'] -
$workorder['obligation'] - $workorder['actual_cost'];
}
return $workorder_list;
@@ -1131,9 +1161,10 @@
$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');
-
- $this->_update_project_budget($workorder['project_id'],
date('Y', $workorder['start_date']), $periodization_id, $combined_cost);
+// $this->_update_project_budget($workorder['project_id'],
date('Y', $workorder['start_date']), $periodization_id, $combined_cost);
+ $this->_update_order_budget($id, date('Y',
$workorder['start_date']), $periodization_id,
$workorder['budget'],$combined_cost);
+
/*
if($workorder['charge_tenant'])
{
@@ -1310,9 +1341,11 @@
$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');
-
- $this->_update_project_budget($workorder['project_id'],
date('Y', $workorder['start_date']), $periodization_id,
$combined_cost,$old_combined_cost);
+// $this->_update_project_budget($workorder['project_id'],
date('Y', $workorder['start_date']), $periodization_id,
$combined_cost,$old_combined_cost);
+ $this->_update_order_budget($workorder['id'], date('Y',
$workorder['start_date']), $periodization_id,
$workorder['budget'],$combined_cost);
+
+
/* if($workorder['charge_tenant'])
{
$this->db->query("UPDATE fm_project set
charge_tenant = 1 WHERE id =" . $workorder['project_id']);
@@ -1585,11 +1618,11 @@
$config->read_repository();
$tax = 1+(($config->config_data['fm_tax'])/100);
- $this->db->query("UPDATE fm_project_budget SET
order_amount = 0",__LINE__,__FILE__);
+// $this->db->query("UPDATE fm_project_budget SET
order_amount = 0",__LINE__,__FILE__);
foreach ($orders as $id => $dummy)
{
- $this->db->query("SELECT project_id,
start_date, combined_cost, budget,calculation,contract_sum,addition FROM
fm_workorder WHERE id = {$id}",__LINE__,__FILE__);
+ $this->db->query("SELECT project_id,
start_date, combined_cost, budget,calculation,contract_sum,addition,ecodimb
FROM fm_workorder WHERE id = {$id}",__LINE__,__FILE__);
$this->db->next_record();
$old_combined_cost =
$this->db->f('combined_cost');
@@ -1599,6 +1632,7 @@
$addition =
$this->db->f('addition');
$project_id =
$this->db->f('project_id');
$start_date =
$this->db->f('start_date');
+ $old_ecodimb =
(int)$this->db->f('ecodimb');
if ( abs((int)$contract_sum) > 0)
{
@@ -1620,11 +1654,18 @@
$this->db->query("UPDATE fm_workorder
SET combined_cost = '{$combined_cost}' WHERE id = {$id}",__LINE__,__FILE__);
}
- $this->db->query("SELECT periodization_id FROM
fm_project WHERE id = {$project_id}",__LINE__,__FILE__);
+ $this->db->query("SELECT
periodization_id,ecodimb FROM fm_project WHERE id =
{$project_id}",__LINE__,__FILE__);
$this->db->next_record();
- $periodization_id =
$this->db->f('periodization_id');
+ $periodization_id =
$this->db->f('periodization_id');
+ $ecodimb =
(int)$this->db->f('ecodimb');
- $this->_update_project_budget($project_id,
date('Y', $start_date), $periodization_id, $combined_cost);
+ if($old_ecodimb != $ecodimb)
+ {
+ $this->db->query("UPDATE fm_workorder
SET ecodimb = {$ecodimb} WHERE id = {$id}",__LINE__,__FILE__);
+ }
+
+ // $this->_update_project_budget($project_id,
date('Y', $start_date), $periodization_id, $combined_cost);
+ $this->_update_order_budget($id, date('Y',
$start_date), $periodization_id, $budget, $combined_cost);
}
$config = CreateObject('phpgwapi.config','property');
@@ -1682,9 +1723,11 @@
'month' => 0,
'value' => 100,
);
-
+
}
+//FIXME : condsider removed
+/*
foreach ($periodization_outline as $outline)
{
$partial_amount = $combined_cost *
$outline['value'] / 100;
@@ -1692,5 +1735,112 @@
$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__);
}
+*/
}
+
+ /**
+ * Maintain correct periodizing in relation to current project
(in case the order is moved)
+ *
+ **/
+ public function update_order_budget($order_id)
+ {
+ $this->db->query("SELECT fm_workorder.start_date,
periodization_id, fm_workorder.budget, combined_cost"
+ . " FROM fm_workorder {$this->join} fm_project ON
fm_workorder.project_id = fm_project.id"
+ . " WHERE fm_workorder.id =
'{$order_id}'",__LINE__,__FILE__);
+ $this->db->next_record();
+ $start_date =
$this->db->f('start_date');
+ $periodization_id =
(int)$this->db->f('periodization_id');
+ $budget =
$this->db->f('budget');
+ $combined_cost = $this->db->f('combined_cost');
+
+ $this->_update_order_budget($order_id, date('Y',
$start_date), $periodization_id, $budget,$combined_cost);
+ }
+
+ private function _update_order_budget($order_id, $year,
$periodization_id, $budget, $combined_cost = 0)
+ {
+ $order_id = $order_id;//might be bigint
+ $year = $year ? (int) $year : date('Y');
+
+ $periodization_id = (int) $periodization_id;
+ $periodization_outline = array();
+
+ if($periodization_id)
+ {
+ $this->db->query("SELECT month,
value,dividend,divisor 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'),
+ 'dividend' =>
$this->db->f('dividend'),
+ 'divisor' =>
$this->db->f('divisor')
+ );
+ }
+ }
+ else
+ {
+ $periodization_outline[] = array
+ (
+ 'month' => 0,
+ 'value' => 100,
+ 'dividend' => 1,
+ 'divisor' => 1,
+
+ );
+
+ }
+ $sql = "DELETE FROM fm_workorder_budget WHERE order_id
= '{$order_id}'";
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ foreach ($periodization_outline as $outline)
+ {
+ if ($outline['dividend'] && $outline['divisor'])
+ {
+ $partial_budget = $budget *
$outline['dividend'] / $outline['divisor'];
+ $partial_cost = $combined_cost *
$outline['dividend'] / $outline['divisor'];
+ }
+ else
+ {
+ $partial_budget = $budget *
$outline['value'] / 100;
+ $partial_cost = $combined_cost *
$outline['value'] / 100;
+ }
+
+ $this->_update_budget($order_id, $year,
$outline['month'], $partial_budget, $partial_cost);
+ }
+ }
+
+ private function _update_budget($order_id, $year, $month,
$budget,$combined_cost)
+ {
+ $month = (int) $month;
+ $budget = (int) $budget;
+ $now = time();
+
+ $sql = "SELECT order_id FROM fm_workorder_budget WHERE
order_id = {$order_id} AND year = {$year} AND month = {$month}";
+
+ $this->db->query($sql,__LINE__,__FILE__);
+ if ($this->db->next_record())
+ {
+ $sql = "UPDATE fm_workorder_budget SET budget =
'{$budget}', combined_cost = '{$combined_cost}', modified_date = {$now} WHERE
order_id = '{$order_id}' AND year = {$year} AND month = {$month}";
+ $this->db->query($sql,__LINE__,__FILE__);
+ }
+ else
+ {
+ $value_set = array
+ (
+ 'order_id' =>
$order_id,
+ 'year' =>
$year,
+ 'month' =>
$month,
+ 'budget' =>
$budget,
+ 'combined_cost' =>
$combined_cost,
+ 'user_id' =>
$this->account,
+ 'entry_date' => $now,
+ 'modified_date' => $now
+ );
+
+ $cols = implode(',', array_keys($value_set));
+ $values =
$this->db->validate_insert(array_values($value_set));
+ $this->db->query("INSERT INTO
fm_workorder_budget ({$cols}) VALUES ({$values})",__LINE__,__FILE__);
+ }
+ }
}
Modified: branches/Version-1_0-branch/property/inc/class.uibudget.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uibudget.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/inc/class.uibudget.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -78,6 +78,7 @@
$this->grouping = $this->bo->grouping;
$this->revision = $this->bo->revision;
$this->details = $this->bo->details;
+ $this->direction = $this->bo->direction;
$this->acl = &
$GLOBALS['phpgw']->acl;
@@ -94,7 +95,8 @@
'filter' =>
$this->filter,
'cat_id' =>
$this->cat_id,
'dimb_id' =>
$this->dimb_id,
- 'allrows' =>
$this->allrows
+ 'allrows' =>
$this->allrows,
+ 'direction' =>
$this->direction
);
$this->bo->save_sessiondata($data);
}
@@ -994,21 +996,22 @@
$datatable = array();
$values_combo_box = array();
$dry_run = false;
-
+ $this->save_sessiondata();
if( phpgw::get_var('phpgw_return_as') != 'json' )
{
$datatable['config']['base_url'] =
$GLOBALS['phpgw']->link('/index.php', array
(
- 'menuaction'
=>'property.uibudget.obligations',
- 'cat_id'
=>$this->cat_id,
- 'filter'
=>$this->filter,
- 'query'
=>$this->query,
- 'district_id'
=>$this->district_id,
- 'grouping'
=>$this->grouping,
- 'year'
=>$this->year,
+ 'menuaction' =>
'property.uibudget.obligations',
+ 'cat_id' =>
$this->cat_id,
+ 'filter' =>
$this->filter,
+ 'query' =>
$this->query,
+ 'district_id' =>
$this->district_id,
+ 'grouping' =>
$this->grouping,
+ 'year' =>
$this->year,
'details' =>
$this->details,
'allrows' =>
$this->allrows,
- 'dimb_id'
=>$this->dimb_id
+ 'dimb_id' =>
$this->dimb_id,
+ 'direction' =>
$this->direction
));
$datatable['config']['allow_allrows'] = true;
@@ -1021,6 +1024,7 @@
."year:'{$this->year}',"
."details:'{$this->details}',"
."dimb_id:'{$this->dimb_id}',"
+ ."direction:'{$this->direction}',"
."allrows:'{$this->allrows}',"
."download:'obligations'";
@@ -1062,6 +1066,23 @@
$default_value = array
('id'=>'','name'=>lang('no dimb'));
array_unshift
($values_combo_box[5],$default_value);
+
+ $values_combo_box[6] = array
+ (
+ array
+ (
+ 'id' => 'expences',
+ 'name' => lang('expences'),
+ 'selected' =>
$this->direction == 'expences' ? 1 : 0
+ ),
+ array
+ (
+ 'id' => 'income',
+ 'name' => lang('income'),
+ 'selected' =>
$this->direction == 'income' ? 1 : 0
+ )
+ );
+
$datatable['actions']['form'] = array
(
array
@@ -1167,15 +1188,27 @@
'style'
=> 'filter',
'values' => $values_combo_box[5],
'onchange'=> 'onChangeSelect("dimb_id");',
-
'tab_index' => 5
+
'tab_index' => 6
),
+ array
+ ( //boton
USER
+ //
'id' => 'btn_user_id',
+ 'id' =>
'sel_direction',
+ 'name'
=> 'direction',
+ 'value'
=> lang('direction'),
+ 'type'
=> 'select',
+ 'style'
=> 'filter',
+
'values' => $values_combo_box[6],
+
'onchange'=> 'onChangeSelect("direction");',
+
'tab_index' => 7
+ ),
array
(
'type'
=> 'button',
'id'
=> 'btn_export',
'value'
=> lang('download'),
-
'tab_index' => 8
+
'tab_index' => 10
),
array
( //boton
SEARCH
@@ -1183,7 +1216,7 @@
'name'
=> 'search',
'value'
=> lang('search'),
'type'
=> 'button',
-
'tab_index' => 7
+
'tab_index' => 9
),
array
( // TEXT IMPUT
@@ -1193,7 +1226,7 @@
'type'
=> 'text',
'size'
=> 28,
'onkeypress'=> 'return pulsar(event)',
-
'tab_index' => 6
+
'tab_index' => 8
)
),
'hidden_value' => array
Modified: branches/Version-1_0-branch/property/inc/class.uiproject.inc.php
===================================================================
--- branches/Version-1_0-branch/property/inc/class.uiproject.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/inc/class.uiproject.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -54,6 +54,7 @@
var $district_id;
var $criteria_id;
var $project_type_id;
+ var $ecodimb;
var $public_functions = array
(
@@ -1188,6 +1189,12 @@
$error_id=true;
}
+ if(!isset($values['project_type_id'])
|| !$values['project_type_id'])
+ {
+
$receipt['error'][]=array('msg'=>lang('Please select a project type!'));
+ $error_id=true;
+ }
+
if(!$values['name'])
{
$receipt['error'][]=array('msg'=>lang('Please enter a project NAME !'));
@@ -1628,6 +1635,8 @@
{
$prefs2 =
$this->bocommon->create_preferences('property', $prefs['approval_from']);
+
+
if(isset($prefs2['email']))
{
$supervisor_email[] = array
@@ -1719,6 +1728,7 @@
$value_remainder -=
$b_entry['sum_orders'];
$value_remainder -=
$b_entry['actual_cost'];
}
+ unset($b_entry);
}
$values['sum'] = number_format($values['sum'], 0, ',',
' ');
@@ -1726,29 +1736,51 @@
//_debug_array($content_budget);die();
- $datavalues[0] = array
+
+
+
+ if( isset($values['project_type_id']) &&
$values['project_type_id']==3)
+ {
+
+ $myColumnDefs[0] = array
(
- 'name'
=> "0",
- 'values'
=> json_encode($content_budget),
- 'total_records' =>
count($content_budget),
- 'edit_action' => "''",
- 'permission' => "''",
- 'is_paginator' => 1,
- 'footer'
=> 0
+ 'name' => "0",
+ 'values' =>
json_encode(array
+
(
+
array('key' =>
'year','label'=>lang('year'),'sortable'=>false,'resizeable'=>true),
+
array('key' => 'entry_date','label'=>lang('entry
date'),'sortable'=>true,'resizeable'=>true),
+
array('key' => 'amount_in','label'=>lang('amount
in'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' => 'from_project','label'=>lang('from
project'),'sortable'=>true,'resizeable'=>true),
+
array('key' => 'amount_out','label'=>lang('amount
out'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' => 'to_project','label'=>lang('to
project'),'sortable'=>true,'resizeable'=>true),
+
array('key' =>
'user_name','label'=>lang('user'),'sortable'=>true,'resizeable'=>true)
+
)
+
)
);
-
- $myColumnDefs[0] = array
+ $content_budget =
$this->bo->get_buffer_budget($id);
+ foreach($content_budget as & $b_entry)
+ {
+ $b_entry['entry_date'] =
$GLOBALS['phpgw']->common->show_date($b_entry['entry_date'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ }
+ unset($b_entry);
+ }
+ else
+ {
+ $myColumnDefs[0] = array
(
'name' => "0",
'values' =>
json_encode(array( array('key' =>
'year','label'=>lang('year'),'sortable'=>false,'resizeable'=>true),
array('key' =>
'month','label'=>lang('month'),'sortable'=>false,'resizeable'=>true),
array('key' =>
'budget','label'=>lang('budget'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
-
array('key' => 'sum_orders','label'=>lang('sum
orders'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
// array('key' => 'sum_orders','label'=>
lang('order'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' =>
'sum_oblications','label'=>lang('sum
orders'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
array('key' =>
'actual_cost','label'=>lang('actual
cost'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
array('key' =>
'diff','label'=>lang('difference'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
-
array('key' =>
'deviation','label'=>lang('deviation'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
-
array('key' =>
'deviation_percent','label'=>lang('deviation') . '::' .
lang('percent'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
+
array('key' =>
'deviation_period','label'=>lang('deviation'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' =>
'deviation_acc','label'=>lang('deviation'). '::' .
lang('accumulated'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' =>
'deviation_percent_period','label'=>lang('deviation') . '::' .
lang('percent'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
+
array('key' =>
'deviation_percent_acc','label'=>lang('percent'). '::' .
lang('accumulated'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
array('key' =>
'closed','label'=>lang('closed'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter'),
array('key' => 'closed_orig','hidden' => true),
array('key' =>
'active','label'=>lang('active'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter'),
@@ -1756,13 +1788,19 @@
array('key' => 'flag_active','hidden' => true),
array('key' =>
'delete_year','label'=>lang('Delete'),'sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterCenter')))
);
+ }
-/*
-
array('key' => 'subtract_sum_orders','hidden'
=> true),
-
array('key' => 'subtract_actual_cost','hidden'
=> true),
-
array('key' => 'subtract_budget','hidden' =>
true),
+ $datavalues[0] = array
+ (
+ 'name'
=> "0",
+ 'values'
=> json_encode($content_budget),
+ 'total_records' =>
count($content_budget),
+ 'edit_action' => "''",
+ 'permission' => "''",
+ 'is_paginator' => 1,
+ 'footer'
=> 0
+ );
-*/
//_debug_array($values['workorder_budget']);die();
$datavalues[1] = array
@@ -1781,10 +1819,11 @@
'values' =>
json_encode(array( array('key' =>
'workorder_id','label'=>lang('Workorder'),'sortable'=>true,'resizeable'=>true,'formatter'=>'YAHOO.widget.DataTable.formatLink'),
array('key' =>
'title','label'=>lang('title'),'sortable'=>true,'resizeable'=>true),
array('key' =>
'b_account_id','label'=>lang('Budget
account'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterRight'),
-
array('key' =>
'cost','label'=>lang('cost'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
+
array('key' =>
'budget','label'=>lang('budget'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' =>
'cost','label'=>lang('cost'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
array('key' => 'addition_percentage','label'=>
'%','sortable'=>false,'resizeable'=>true,'formatter'=>'FormatterRight'),
-
array('key' =>
'combined_cost','label'=>lang('sum
orders'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
-
array('key' =>
'actual_cost','label'=>lang('actual
cost'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount2'),
+
array('key' => 'obligation','label'=>lang('sum
orders'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
+
array('key' =>
'actual_cost','label'=>lang('actual
cost'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
array('key' =>
'diff','label'=>lang('difference'),'sortable'=>true,'resizeable'=>true,'formatter'=>'FormatterAmount0'),
array('key' =>
'vendor_name','label'=>lang('Vendor'),'sortable'=>true,'resizeable'=>true),
array('key' =>
'status','label'=>lang('Status'),'sortable'=>true,'resizeable'=>true)))
@@ -1922,6 +1961,11 @@
$periodization_list =
$this->bo->get_periodizations_with_outline();
$sub_entry_action_data = array();
+ $sub_entry_action_data = array
+ (
+ 'menuaction' =>
'property.uiworkorder.edit',
+ 'project_id' => $id
+ );
if($id && !$values['project_type_id']==3)
{
@@ -1946,6 +1990,7 @@
$data = array
(
'project_types'
=> array('options' =>
$this->bo->get_project_types($values['project_type_id'])),
+ 'project_type_id'
=> $values['project_type_id'],
'inherit_location'
=> $id ? $values['inherit_location'] : 1,
'mode'
=> $mode,
'suppressmeter'
=> isset($config->config_data['project_suppressmeter']) &&
$config->config_data['project_suppressmeter'] ? 1 : '',
@@ -2114,6 +2159,7 @@
phpgwapi_yui::load_widget('dragdrop');
phpgwapi_yui::load_widget('datatable');
+
phpgwapi_yui::load_widget('menu');
phpgwapi_yui::load_widget('connection');
phpgwapi_yui::load_widget('loader');
@@ -2172,7 +2218,8 @@
$execute = phpgw::get_var('execute',
'bool', 'POST');
$status_filter = phpgw::get_var('status_filter');
$status_new = phpgw::get_var('status_new');
- $type = phpgw::get_var('type');
+ $type =
phpgw::get_var('type','string', 'REQUEST' , 'project');
+ $ecodimb = phpgw::get_var('ecodimb');
$id_to_update = phpgw::get_var('id_to_update');
$paid = phpgw::get_var('paid',
'bool', 'POST');
$closed_orders = phpgw::get_var('closed_orders',
'bool', 'POST');
@@ -2206,7 +2253,7 @@
if(($execute || $get_list) && $type)
{
- $list =
$this->bo->bulk_update_status($start_date, $end_date, $status_filter,
$status_new, $execute, $type, $user_id,$ids,$paid,$closed_orders);
+ $list =
$this->bo->bulk_update_status($start_date, $end_date, $status_filter,
$status_new, $execute, $type, $user_id,$ids,$paid,$closed_orders,$ecodimb);
}
$total_records = count($list);
@@ -2224,30 +2271,37 @@
switch($type)
{
case 'project':
- $_key = 'num_open';
- $_label = lang('open');
+ $myColumnDefs[0] = array
+ (
+ 'name' => "0",
+ 'values' =>
json_encode(array( array('key' =>
'id','label'=>lang('id'),'sortable'=>true,'resizeable'=>true,'formatter'=>'YAHOO.widget.DataTable.formatLink'),
+
array('key' =>
'start_date','label'=>lang('date'),'sortable'=>false,'resizeable'=>true),
+
array('key' =>
'title','label'=>lang('title'),'sortable'=>true,'resizeable'=>true),
+
array('key' =>
'status','label'=>lang('status'),'sortable'=>true,'resizeable'=>true),
+
array('key' =>
'num_open','label'=>lang('open'),'sortable'=>true,'resizeable'=>true
,'formatter'=>'FormatterRight'),
+
array('key' => 'select','label'=>
lang('select'),
'sortable'=>false,'resizeable'=>false,'formatter'=>'myFormatterCheck','width'=>30)
+
))
+ );
break;
case 'workorder':
- $_key = 'actual_cost';
- $_label = lang('actual cost');
- break;
- default:
- $_key = 'num_open';
- $_label = lang('open');
- }
-
- $myColumnDefs[0] = array
- (
- 'name' => "0",
- 'values' =>
json_encode(array( array('key' =>
'id','label'=>lang('id'),'sortable'=>true,'resizeable'=>true,'formatter'=>'YAHOO.widget.DataTable.formatLink'),
+ $myColumnDefs[0] = array
+ (
+ 'name' => "0",
+ 'values' =>
json_encode(array(
+
array('key' =>
'project_id','label'=>lang('project'),'sortable'=>true,'resizeable'=>true),
+
array('key' =>
'id','label'=>lang('id'),'sortable'=>true,'resizeable'=>true,'formatter'=>'YAHOO.widget.DataTable.formatLink'),
array('key' =>
'start_date','label'=>lang('date'),'sortable'=>false,'resizeable'=>true),
array('key' =>
'title','label'=>lang('title'),'sortable'=>true,'resizeable'=>true),
array('key' =>
'status','label'=>lang('status'),'sortable'=>true,'resizeable'=>true),
-
array('key' =>
$_key,'label'=>$_label,'sortable'=>true,'resizeable'=>true
,'formatter'=>'FormatterRight'),
+
array('key' =>
'actual_cost','label'=>lang('actual cost'),'sortable'=>true,'resizeable'=>true
,'formatter'=>'FormatterRight'),
array('key' => 'select','label'=>
lang('select'),
'sortable'=>false,'resizeable'=>false,'formatter'=>'myFormatterCheck','width'=>30)
))
- );
+ );
+ break;
+ }
+
+
$user_list =
$this->bocommon->get_user_list('select', $user_id, $extra=false, $default =
$user_id, $start=-1, $sort='ASC',
$order='account_lastname',$query='',$offset=-1);
foreach ($user_list as &$entry)
{
@@ -2258,17 +2312,24 @@
switch($type)
{
case 'project':
- $status_list_filter =
execMethod('property.bogeneric.get_list', array('type' => 'project_status',
'selected' => $status_filter));
+ $status_list_filter =
execMethod('property.bogeneric.get_list', array('type' => 'project_status'));
$status_list_new =
execMethod('property.bogeneric.get_list', array('type' => 'project_status',
'selected' => $status_new));
break;
case 'workorder':
- $status_list_filter =
execMethod('property.bogeneric.get_list', array('type' => 'workorder_status',
'selected' => $status_filter));
+ $status_list_filter =
execMethod('property.bogeneric.get_list', array('type' => 'workorder_status'));
$status_list_new =
execMethod('property.bogeneric.get_list', array('type' => 'workorder_status',
'selected' => $status_new));
break;
default:
$status_list_filter = array();
}
+ if($status_list_filter)
+ {
+ array_unshift ($status_list_filter,array
('id'=>'open','name'=> lang('open')));
+ }
+
+ $status_list_filter =
$this->bocommon->select_list($status_filter,$status_list_filter);
+
$type_array = array
(
array
@@ -2304,6 +2365,7 @@
'status_list_new' =>
array('options' => $status_list_new),
'type_list' =>
array('options' => $type_array),
'user_list' =>
array('options' => $user_list),
+ 'ecodimb_list' =>
array('options' =>
$this->bocommon->select_category_list(array('type'=>'dimb','selected' =>
$ecodimb))),
'start_date' => $start_date,
'end_date' =>
$end_date,
'total_records' =>
$total_records,
@@ -2345,6 +2407,7 @@
function view()
{
+
if(!$this->acl_read)
{
$this->bocommon->no_access();
@@ -2446,6 +2509,7 @@
}
$datavalues[2] = array
+
(
'name'
=> "2",
'values'
=> json_encode($content_invoice),
Modified: branches/Version-1_0-branch/property/js/yahoo/project.edit.js
===================================================================
--- branches/Version-1_0-branch/property/js/yahoo/project.edit.js
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/js/yahoo/project.edit.js
2013-01-01 21:43:59 UTC (rev 10627)
@@ -84,7 +84,16 @@
/********************************************************************************/
this.myParticularRenderEvent = function()
{
- this.addFooterDatatable0(myPaginator_0,myDataTable_0);
+
+ if(project_type_id == 3)
+ {
+
this.addFooterDatatable_buffer(myPaginator_0,myDataTable_0);
+ }
+ else
+ {
+ this.addFooterDatatable0(myPaginator_0,myDataTable_0);
+ }
+
this.addFooterDatatable1(myPaginator_1,myDataTable_1);
this.addFooterDatatable2(myPaginator_2,myDataTable_2);
}
@@ -113,14 +122,48 @@
}
+ this.addFooterDatatable_buffer = function(paginator,datatable)
+ {
+ //call getTotalSum(name of column) in property.js
+ tmp_sum1 = getTotalSum('amount_in',0,paginator,datatable);
+ tmp_sum2 = getTotalSum('amount_out',0,paginator,datatable);
+ tmp_sum3 = tmp_sum1 + tmp_sum2;
+
+ if(typeof(tableYUI0)=='undefined')
+ {
+ tableYUI0 =
YAHOO.util.Dom.getElementsByClassName("yui-dt-data","tbody")[0].parentNode;
+ tableYUI0.setAttribute("id","tableYUI0");
+ }
+ else
+ {
+ tableYUI0.deleteTFoot();
+ }
+
+ //Create ROW
+ newTR = document.createElement('tr');
+
+ td_sum('Sum');
+ td_empty(1);
+ td_sum(tmp_sum1);
+ td_empty(1);
+ td_sum(tmp_sum2);
+ td_empty(1);
+ td_sum(tmp_sum3);
+
+ myfoot = tableYUI0.createTFoot();
+ myfoot.setAttribute("id","myfoot");
+ myfoot.appendChild(newTR);
+ }
+
this.addFooterDatatable0 = function(paginator,datatable)
{
//call getTotalSum(name of column) in property.js
tmp_sum1 = getTotalSum_active('budget',0,paginator,datatable);
- tmp_sum2 =
getTotalSum_active('sum_orders',0,paginator,datatable);
- tmp_sum3 =
getTotalSum_active('actual_cost',0,paginator,datatable);
- tmp_sum4 = getTotalSum_active('diff',0,paginator,datatable);
- tmp_sum5 =
getTotalSum_active('deviation',0,paginator,datatable);
+ // tmp_sum2 =
getTotalSum_active('sum_orders',0,paginator,datatable);
+ tmp_sum3 =
getTotalSum_active('sum_oblications',0,paginator,datatable);
+ tmp_sum4 =
getTotalSum_active('actual_cost',0,paginator,datatable);
+ tmp_sum5 = getTotalSum_active('diff',0,paginator,datatable);
+ tmp_sum6 =
getTotalSum_active('deviation',0,paginator,datatable);
if(typeof(tableYUI0)=='undefined')
{
@@ -138,11 +181,12 @@
td_sum('Sum');
td_empty(1);
td_sum(tmp_sum1);
- td_sum(tmp_sum2);
+// td_sum(tmp_sum2);
td_sum(tmp_sum3);
td_sum(tmp_sum4);
td_sum(tmp_sum5);
- td_empty(7);
+ td_sum(tmp_sum6);
+ td_empty(9);
myfoot = tableYUI0.createTFoot();
myfoot.setAttribute("id","myfoot");
@@ -152,15 +196,15 @@
this.addFooterDatatable1 = function(paginator,datatable)
{
//call getTotalSum(name of column) in property.js
- tmp_sum0 = getTotalSum('cost',2,paginator,datatable);
+ tmp_sum0 = getTotalSum('budget',0,paginator,datatable);
+ tmp_sum1 = getTotalSum('cost',0,paginator,datatable);
/*
- tmp_sum1 = getTotalSum('budget',0,paginator,datatable);
tmp_sum2 = getTotalSum('calculation',2,paginator,datatable);
tmp_sum3 = getTotalSum('contract_sum',2,paginator,datatable);
*/
- tmp_sum4 = getTotalSum('combined_cost',2,paginator,datatable);
- tmp_sum5 = getTotalSum('actual_cost',2,paginator,datatable);
- tmp_sum6 = getTotalSum('diff',2,paginator,datatable);
+ tmp_sum4 = getTotalSum('obligation',0,paginator,datatable);
+ tmp_sum5 = getTotalSum('actual_cost',0,paginator,datatable);
+ tmp_sum6 = getTotalSum('diff',0,paginator,datatable);
if(typeof(tableYUI1)=='undefined')
@@ -179,7 +223,7 @@
td_sum('Sum');
td_empty(2);
td_sum(tmp_sum0);
-// td_sum(tmp_sum1);
+ td_sum(tmp_sum1);
// td_sum(tmp_sum2);
// td_sum(tmp_sum3);
td_empty(1);
Modified: branches/Version-1_0-branch/property/js/yahoo/property2.js
===================================================================
--- branches/Version-1_0-branch/property/js/yahoo/property2.js 2013-01-01
20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/js/yahoo/property2.js 2013-01-01
21:43:59 UTC (rev 10627)
@@ -43,7 +43,11 @@
tmp_sum = 0;
for(i = begin; i < end; i++)
{
- tmp_sum = tmp_sum +
parseFloat(datatable.getRecordSet().getRecords(0)[i].getData(name_column));
+ if(tmp_record =
parseFloat(datatable.getRecordSet().getRecords(0)[i].getData(name_column)))
+ {
+ tmp_sum += tmp_record;
+ }
+ //tmp_sum = tmp_sum +
parseFloat(datatable.getRecordSet().getRecords(0)[i].getData(name_column));
}
return tmp_sum = YAHOO.util.Number.format(tmp_sum,
{decimalPlaces:round, decimalSeparator:",", thousandsSeparator:" "});
Modified: branches/Version-1_0-branch/property/setup/phpgw_no.lang
===================================================================
--- branches/Version-1_0-branch/property/setup/phpgw_no.lang 2013-01-01
20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/setup/phpgw_no.lang 2013-01-01
21:43:59 UTC (rev 10627)
@@ -5,6 +5,8 @@
%1 group property no %1 gruppe
%1 is notified property no Melding sendt til %1
%1 properties has been updated to not active of %2 already not active
property no %1 Eiendommer er oppdatert til IKKE AKTIVE av %2 som
var IKKE AKTIVE fra før
+expences property no Utgifter
+income property no Inntekter
about common no Om
access error property no Manglende tilgang
accounting property no Regnskap
@@ -14,6 +16,7 @@
accounting tax property no Regnskap mva-kode
accounting voucher category property no Regnskap kategorier
faktura
accounting voucher type property no Regnskap type faktura
+accumulated property no Akkumulert
acl_locastion is missing property no ACL-lokalisering mangler
acquisition date property no Anskaffelses dato
action property no Handling
@@ -823,6 +826,8 @@
formats property no Formater
forward property no Videresend
fraction property no Fraksjon
+fraction::dividend property no Brøk::teller
+fraction::divisor property no Brøk::nevner
from property no Fra
from date property no Fra dato
funding property no Finansiering
Modified: branches/Version-1_0-branch/property/setup/setup.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/setup.inc.php 2013-01-01
20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/setup/setup.inc.php 2013-01-01
21:43:59 UTC (rev 10627)
@@ -12,7 +12,7 @@
*/
$setup_info['property']['name'] = 'property';
- $setup_info['property']['version'] = '0.9.17.658';
+ $setup_info['property']['version'] = '0.9.17.661';
$setup_info['property']['app_order'] = 8;
$setup_info['property']['enable'] = 1;
$setup_info['property']['app_group'] = 'office';
@@ -99,6 +99,7 @@
'fm_b_account',
'fm_b_account_category',
'fm_workorder',
+ 'fm_workorder_budget',
'fm_workorder_history',
'fm_workorder_status',
'fm_activities',
@@ -128,6 +129,7 @@
'fm_ns3420',
'fm_project_status',
'fm_project',
+ 'fm_project_buffer_budget',
'fm_projectbranch',
'fm_project_group',
'fm_project_history',
Modified: branches/Version-1_0-branch/property/setup/tables_current.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/tables_current.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/setup/tables_current.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -550,6 +550,22 @@
'ix' => array(),
'uc' => array()
),
+ 'fm_workorder_budget' => array(
+ 'fd' => array(
+ 'order_id' => array('type' => 'int','precision'
=> 8,'nullable' => False),
+ 'year' => array('type' => 'int','precision' =>
4,'nullable' => False),
+ 'month' => array('type' => 'int','precision' =>
2,'nullable' => False,'default' => 0),
+ 'budget' => array('type' =>
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' =>
'0.00'),
+ 'combined_cost' => array('type' =>
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' =>
'0.00'),
+ 'user_id' => array('type' => 'int','precision'
=> 4,'nullable' => True),
+ 'entry_date' => array('type' =>
'int','precision' => 4,'nullable' => True),
+ 'modified_date' => array('type' =>
'int','precision' => 4,'nullable' => True)
+ ),
+ 'pk' => array('order_id','year','month'),
+ 'fk' => array('fm_workorder' => array('order_id' =>
'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ ),
'fm_activities' => array(
'fd' => array(
'id' => array('type' => 'int','precision' =>
'4','nullable' => False),
@@ -1309,6 +1325,8 @@
'periodization_id' => array('type' =>
'int','precision' => '4','nullable' => False),
'month' => array('type' => 'int','precision' =>
'4','nullable' => true),
'value' => array('type' =>
'decimal','precision' => '20','scale' => '6','nullable' => false,'default' =>
'0.000000'),
+ 'dividend' => array('type' => 'int','precision'
=> '4','nullable' => true),
+ 'divisor' => array('type' => 'int','precision'
=> '4','nullable' => true),
'remark' => array('type' =>
'varchar','precision' => '60','nullable' => False),
),
'pk' => array('id'),
@@ -1545,12 +1563,15 @@
'fm_project_buffer_budget' => array(
'fd' => array(
'id' => array('type' => 'auto','precision' =>
'4','nullable' => False),
+ 'year' => array('type' => 'int','precision' =>
4,'nullable' => False),
+ 'month' => array('type' => 'int','precision' =>
2,'nullable' => False,'default' => 0),
'buffer_project_id' => array('type' =>
'int','precision' => '4','nullable' => False),
'entry_date' => array('type' =>
'int','precision' => '4','nullable' => False),
'amount_in' => array('type' =>
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' =>
'0.00'),
'from_project' => array('type' =>
'int','precision' => '4','nullable' => true),
'amount_out' => array('type' =>
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' =>
'0.00'),
'to_project' => array('type' =>
'int','precision' => '4','nullable' => true),
+ 'active' => array('type' => 'int','precision'
=> 2,'nullable' => True),
'user_id' => array('type' => 'int','precision'
=> '4','nullable' => False),
'remark' => array('type' => 'text','nullable'
=> true),
),
Modified: branches/Version-1_0-branch/property/setup/tables_update.inc.php
===================================================================
--- branches/Version-1_0-branch/property/setup/tables_update.inc.php
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/setup/tables_update.inc.php
2013-01-01 21:43:59 UTC (rev 10627)
@@ -7069,3 +7069,148 @@
return $GLOBALS['setup_info']['property']['currentver'];
}
}
+
+ /**
+ * Update property version from 0.9.17.658 to 0.9.17.659
+ * Add view on fm_ecobilag
+ */
+ $test[] = '0.9.17.658';
+ function property_upgrade0_9_17_658()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+ $GLOBALS['phpgw_setup']->oProc->query("DELETE FROM fm_cache");
+
+ $sql = 'UPDATE fm_project SET project_type_id = 1 WHERE
project_type_id IS NULL';
+
+ $GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+
+ $sql = 'CREATE OR REPLACE VIEW fm_orders_pending_cost_view AS'
+ . ' SELECT fm_ecobilag.pmwrkord_code AS order_id,
sum(fm_ecobilag.godkjentbelop) AS pending_cost FROM fm_ecobilag GROUP BY
fm_ecobilag.pmwrkord_code';
+
+ $GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+
+ $sql = 'CREATE OR REPLACE VIEW fm_orders_actual_cost_view AS'
+ . ' SELECT fm_ecobilagoverf.pmwrkord_code AS order_id,
sum(fm_ecobilagoverf.godkjentbelop) AS actual_cost FROM fm_ecobilagoverf GROUP
BY fm_ecobilagoverf.pmwrkord_code';
+
+ $GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+
+
+ $sql = 'CREATE OR REPLACE VIEW fm_orders_paid_or_pending_view AS
+ SELECT orders_paid_or_pending.order_id,
orders_paid_or_pending.periode, orders_paid_or_pending.amount
+ FROM ( SELECT fm_ecobilagoverf.pmwrkord_code AS
order_id, fm_ecobilagoverf.periode, sum(fm_ecobilagoverf.godkjentbelop) AS
amount
+ FROM fm_ecobilagoverf
+ GROUP BY fm_ecobilagoverf.pmwrkord_code,
fm_ecobilagoverf.periode
+ UNION ALL
+ SELECT fm_ecobilag.pmwrkord_code AS order_id,
fm_ecobilag.periode, sum(fm_ecobilag.godkjentbelop) AS amount
+ FROM fm_ecobilag
+ GROUP BY fm_ecobilag.pmwrkord_code, fm_ecobilag.periode)
orders_paid_or_pending';
+
+ $GLOBALS['phpgw_setup']->oProc->query($sql,__LINE__,__FILE__);
+
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['property']['currentver'] =
'0.9.17.659';
+ return $GLOBALS['setup_info']['property']['currentver'];
+ }
+ }
+
+ /**
+ * Update property version from 0.9.17.659 to 0.9.17.660
+ * Add fraction to periodization outline as an alternative
+ */
+ $test[] = '0.9.17.659';
+ function property_upgrade0_9_17_659()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_eco_periodization_outline','dividend',array(
+ 'type' => 'int',
+ 'precision' => 4,
+ 'nullable' => true
+ )
+ );
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_eco_periodization_outline','divisor',array(
+ 'type' => 'int',
+ 'precision' => 4,
+ 'nullable' => true
+ )
+ );
+
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('fm_eco_periodization_outline','value',array(
+ 'type' => 'decimal',
+ 'precision' => '20',
+ 'scale' => '6',
+ 'nullable' => true
+ )
+ );
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['property']['currentver'] =
'0.9.17.660';
+ return $GLOBALS['setup_info']['property']['currentver'];
+ }
+ }
+
+ /**
+ * Update property version from 0.9.17.660 to 0.9.17.661
+ * Add year and active-flag to project_buffer_budget
+ */
+ $test[] = '0.9.17.660';
+ function property_upgrade0_9_17_660()
+ {
+ $GLOBALS['phpgw_setup']->oProc->m_odb->transaction_begin();
+
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_project_buffer_budget','year',array(
+ 'type' => 'int',
+ 'precision' => 4,
+ 'nullable' => false
+ )
+ );
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_project_buffer_budget','month',array(
+ 'type' => 'int',
+ 'precision' => 4,
+ 'nullable' => false,
+ 'default' => 0
+ )
+ );
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('fm_project_buffer_budget','active',array(
+ 'type' => 'int',
+ 'precision' => 2,
+ 'nullable' => true
+ )
+ );
+
+
+ $GLOBALS['phpgw_setup']->oProc->query('UPDATE fm_project_budget
SET active = 1',__LINE__,__FILE__);
+
+ $GLOBALS['phpgw_setup']->oProc->CreateTable(
+ 'fm_workorder_budget', array(
+ 'fd' => array(
+ 'order_id' => array('type' =>
'int','precision' => 8,'nullable' => False),
+ 'year' => array('type' =>
'int','precision' => 4,'nullable' => False),
+ 'month' => array('type' =>
'int','precision' => 2,'nullable' => False,'default' => 0),
+ 'budget' => array('type' =>
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' =>
'0.00'),
+ 'combined_cost' => array('type' =>
'decimal','precision' => '20','scale' => '2','nullable' => True,'default' =>
'0.00'),
+ 'user_id' => array('type' =>
'int','precision' => 4,'nullable' => True),
+ 'entry_date' => array('type' =>
'int','precision' => 4,'nullable' => True),
+ 'modified_date' => array('type' =>
'int','precision' => 4,'nullable' => True)
+ ),
+ 'pk' => array('order_id','year','month'),
+ 'fk' => array('fm_workorder' =>
array('order_id' => 'id')),
+ 'ix' => array(),
+ 'uc' => array()
+ )
+ );
+
+ if($GLOBALS['phpgw_setup']->oProc->m_odb->transaction_commit())
+ {
+ $GLOBALS['setup_info']['property']['currentver'] =
'0.9.17.661';
+ return $GLOBALS['setup_info']['property']['currentver'];
+ }
+ }
Modified: branches/Version-1_0-branch/property/templates/base/project.xsl
===================================================================
--- branches/Version-1_0-branch/property/templates/base/project.xsl
2013-01-01 20:21:50 UTC (rev 10626)
+++ branches/Version-1_0-branch/property/templates/base/project.xsl
2013-01-01 21:43:59 UTC (rev 10627)
@@ -40,6 +40,7 @@
{
document.add_sub_entry_form.submit();
}
+ var project_type_id = '<xsl:value-of
select="project_type_id"/>';
</script>
<table cellpadding="2" cellspacing="2" align="center">
<xsl:choose>
@@ -453,6 +454,9 @@
<div
id="datatable-container_0"/>
</td>
</tr>
+ <xsl:choose>
+ <xsl:when test="project_type_id !='3'">
+
<tr>
<td
valign="top">
<xsl:value-of select="lang_reserve"/>
@@ -484,17 +488,11 @@
<xsl:text> % )</xsl:text>
</td>
</tr>
-<!--
+ </xsl:when>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
<tr>
- <td
valign="top">
-
<xsl:value-of select="lang_planned_cost"/>
- </td>
- <td>
-
<xsl:value-of select="value_planned_cost"/><xsl:text> </xsl:text> [
<xsl:value-of select="currency"/> ]
- </td>
- </tr>
--->
- <tr>
<td
class="th_text" valign="top">
<xsl:value-of select="lang_workorder_id"/>
</td>
@@ -522,6 +520,7 @@
<div
id="datatable-container_2"/>
</td>
</tr>
+
</table>
<!-- DATATABLE DEFINITIONS-->
<script type="text/javascript">
@@ -845,6 +844,22 @@
</tr>
<tr>
<td>
+ <xsl:value-of
select="php:function('lang', 'dimb')"/>
+ </td>
+ <td>
+ <select name="ecodimb">
+ <xsl:attribute
name="title">
+
<xsl:value-of select="php:function('lang', 'select')"/>
+ </xsl:attribute>
+ <option
value="0">
+
<xsl:value-of select="php:function('lang', 'select')"/>
+ </option>
+
<xsl:apply-templates select="ecodimb_list/options"/>
+ </select>
+ </td>
+ </tr>
+ <tr>
+ <td>
<xsl:value-of
select="php:function('lang', 'user')"/>
</td>
<td>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [10627] Merge 10616:10626 from trunk,
Sigurd Nes <=