[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property inc/class.bobudget.inc.php inc/class.s...
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-cvs] property inc/class.bobudget.inc.php inc/class.s... |
Date: |
Tue, 11 Apr 2006 11:39:05 +0000 |
CVSROOT: /sources/phpgroupware
Module name: property
Branch:
Changes by: Sigurd Nes <address@hidden> 06/04/11 11:39:05
Modified files:
inc : class.bobudget.inc.php class.sobudget.inc.php
setup : tables_current.inc.php tables_update.inc.php
Log message:
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.bobudget.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sobudget.inc.php.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/setup/tables_current.inc.php.diff?tr1=1.54&tr2=1.55&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/setup/tables_update.inc.php.diff?tr1=1.39&tr2=1.40&r1=text&r2=text
Patches:
Index: property/inc/class.bobudget.inc.php
diff -u property/inc/class.bobudget.inc.php:1.5
property/inc/class.bobudget.inc.php:1.6
--- property/inc/class.bobudget.inc.php:1.5 Mon Apr 10 19:22:30 2006
+++ property/inc/class.bobudget.inc.php Tue Apr 11 11:39:04 2006
@@ -8,7 +8,7 @@
* @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
* @package property
* @subpackage budget
- * @version $Id: class.bobudget.inc.php,v 1.5 2006/04/10 19:22:30
sigurdne Exp $
+ * @version $Id: class.bobudget.inc.php,v 1.6 2006/04/11 11:39:04
sigurdne Exp $
*/
/**
@@ -227,7 +227,7 @@
$receipt = $this->so->add_basis($values);
}
- if($values['distribute'] &&
is_array($values['distribute']))
+ if(is_array($values['distribute']) &&
is_array($values['distribute_year']))
{
$this->distribute($values,$receipt);
}
Index: property/inc/class.sobudget.inc.php
diff -u property/inc/class.sobudget.inc.php:1.5
property/inc/class.sobudget.inc.php:1.6
--- property/inc/class.sobudget.inc.php:1.5 Mon Apr 10 19:22:31 2006
+++ property/inc/class.sobudget.inc.php Tue Apr 11 11:39:04 2006
@@ -8,7 +8,7 @@
* @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
* @package property
* @subpackage budget
- * @version $Id: class.sobudget.inc.php,v 1.5 2006/04/10 19:22:31
sigurdne Exp $
+ * @version $Id: class.sobudget.inc.php,v 1.6 2006/04/11 11:39:04
sigurdne Exp $
*/
/**
@@ -468,9 +468,11 @@
function distribute($values,$receipt='')
{
+ $year_condition = 'year in (' .
implode(",",$values['distribute_year']). ')';
+
foreach ($values['distribute'] as $basis_id)
{
- $this->db->query("select * from fm_budget_basis
where id='$basis_id'",__LINE__,__FILE__);
+ $this->db->query("SELECT * FROM fm_budget_basis
where id='$basis_id'",__LINE__,__FILE__);
if ($this->db->next_record())
{
@@ -480,13 +482,73 @@
$basis['b_group'] =
$this->db->f('b_group');
$basis['budget_cost'] =
$this->db->f('budget_cost');
}
+
+ $sql = "SELECT SUM(amount) as group_sum FROM
fm_budget_cost $this->join fm_b_account ON fm_budget_cost.b_account_id =
fm_b_account.id WHERE fm_b_account.grouping = '" . $basis['b_group'] . "' AND
$year_condition";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $group_sum = $this->db->f('group_sum');
+
+ $sql = "SELECT SUM(amount) as account_sum,
b_account_id FROM fm_budget_cost $this->join fm_b_account ON
fm_budget_cost.b_account_id = fm_b_account.id WHERE fm_b_account.grouping = '"
. $basis['b_group'] . "' AND $year_condition group by b_account_id";
+ $this->db->query($sql,__LINE__,__FILE__);
-
-
+ while ($this->db->next_record())
+ {
+ $budget[] = array(
+ 'b_account_id' =>
$this->db->f('b_account_id'),
+ 'account_sum' =>
round(($this->db->f('account_sum')/$group_sum) * $basis['budget_cost'],-3),
+ );
+
+ $test_sum = $test_sum +
round(($this->db->f('account_sum')/$group_sum) * $basis['budget_cost'],-3);
+ }
+
+
+ $sql = "DELETE FROM fm_budget WHERE year = " .
(int)$basis['year']
+ . " AND district_id = " .
(int)$basis['district_id']
+ . " AND revision = " .
(int)$basis['revision'];
+ $this->db->query($sql,__LINE__,__FILE__);
+
+ if(is_array($budget))
+ {
+ foreach ($budget as $entry)
+ {
+ if(abs($entry['account_sum'])>0)
+ {
+
+
$this->db->query("INSERT INTO fm_budget (id, year, b_account_id,
district_id,revision,user_id,entry_date,budget_cost) VALUES ("
+ .
$this->bocommon->next_id('fm_budget') . ","
+ . $basis['year'] . ",'"
+ .
$entry['b_account_id']. "',"
+ . $basis['district_id']
. ","
+ . $basis['revision'] .
","
+ . $this->account . ","
+ . time() . ","
+ . $entry['account_sum']
. ")",__LINE__,__FILE__);
+ }
+ }
+
+ if($test_sum != $basis['budget_cost'])
+ {
+ $diff_sum =
$basis['budget_cost'] - $test_sum;
+ $sql = "SELECT max(budget_cost)
as budget_cost FROM fm_budget WHERE year = " . (int)$basis['year']
+ . " AND district_id = " .
(int)$basis['district_id']
+ . " AND revision = " .
(int)$basis['revision'];
+
+
$this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+ $max_budget_cost =
$this->db->f('budget_cost');
+
+ $sql = "SELECT id FROM
fm_budget WHERE year = " . (int)$basis['year']
+ . " AND district_id = " .
(int)$basis['district_id']
+ . " AND revision = " .
(int)$basis['revision']
+ . " AND budget_cost =
$max_budget_cost";
+
+
$this->db->query($sql,__LINE__,__FILE__);
+ $this->db->next_record();
+
+ $this->db->query("UPDATE
fm_budget set budget_cost = budget_cost + $diff_sum WHERE id = " .
(int)$this->db->f('id') ,__LINE__,__FILE__);
+ }
+ }
}
-
}
-
-
}
?>
Index: property/setup/tables_current.inc.php
diff -u property/setup/tables_current.inc.php:1.54
property/setup/tables_current.inc.php:1.55
--- property/setup/tables_current.inc.php:1.54 Mon Apr 10 14:36:42 2006
+++ property/setup/tables_current.inc.php Tue Apr 11 11:39:04 2006
@@ -8,7 +8,7 @@
* @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
* @package property
* @subpackage setup
- * @version $Id: tables_current.inc.php,v 1.54 2006/04/10 14:36:42
sigurdne Exp $
+ * @version $Id: tables_current.inc.php,v 1.55 2006/04/11 11:39:04
sigurdne Exp $
*/
$phpgw_baseline = array(
@@ -2166,7 +2166,7 @@
'access' => array('type' =>
'varchar','precision' => '7','nullable' => True),
'user_id' => array('type' => 'int', 'precision'
=> 4,'nullable' => True),
'entry_date' => array('type' => 'int',
'precision' => 4,'nullable' => True),
- 'budget_cost' => array('type' => 'int',
'precision' => 4,'nullable' => True),
+ 'budget_cost' => array('type' => 'int',
'precision' => 4,'default' => '0','nullable' => True),
'remark' => array('type' => 'text','nullable'
=> True)
),
'pk' => array('id'),
@@ -2185,7 +2185,7 @@
'access' => array('type' =>
'varchar','precision' => '7','nullable' => True),
'user_id' => array('type' => 'int', 'precision'
=> 4,'nullable' => True),
'entry_date' => array('type' => 'int',
'precision' => 4,'nullable' => True),
- 'budget_cost' => array('type' => 'int',
'precision' => 4,'nullable' => True),
+ 'budget_cost' => array('type' => 'int',
'precision' => 4,'default' => '0','nullable' => True),
'remark' => array('type' => 'text','nullable'
=> True)
),
'pk' => array('id'),
@@ -2197,8 +2197,8 @@
'fd' => array(
'year' => array('type' => 'int', 'precision' =>
4,'nullable' => False),
'month' => array('type' => 'int', 'precision'
=> 4,'nullable' => False),
- 'b_account_id' => array('type' =>
'varchar','precision' => '4','nullable' => False),
- 'percent' => array('type' => 'int','precision'
=> '4','nullable' => True),
+ 'b_account_id' => array('type' =>
'varchar','precision' => 4,'nullable' => False),
+ 'percent' => array('type' => 'int','precision'
=> 4,'default' => '0','nullable' => True),
'user_id' => array('type' => 'int', 'precision'
=> 4,'nullable' => True),
'entry_date' => array('type' => 'int',
'precision' => 4,'nullable' => True),
'remark' => array('type' => 'text','nullable'
=> True)
@@ -2214,7 +2214,7 @@
'year' => array('type' => 'int', 'precision' =>
4,'nullable' => False),
'month' => array('type' => 'int', 'precision'
=> 4,'nullable' => False),
'b_account_id' => array('type' =>
'varchar','precision' => '20','nullable' => False),
- 'amount' => array('type' => 'int','precision'
=> '4','nullable' => True)
+ 'amount' => array('type' =>
'decimal','precision' => '20','scale' => '2','default' => '0','nullable' =>
True)
),
'pk' => array('id'),
'fk' => array(),
Index: property/setup/tables_update.inc.php
diff -u property/setup/tables_update.inc.php:1.39
property/setup/tables_update.inc.php:1.40
--- property/setup/tables_update.inc.php:1.39 Mon Apr 10 14:36:42 2006
+++ property/setup/tables_update.inc.php Tue Apr 11 11:39:05 2006
@@ -8,7 +8,7 @@
* @internal Development of this application was funded by
http://www.bergen.kommune.no/bbb_/ekstern/
* @package property
* @subpackage setup
- * @version $Id: tables_update.inc.php,v 1.39 2006/04/10 14:36:42
sigurdne Exp $
+ * @version $Id: tables_update.inc.php,v 1.40 2006/04/11 11:39:05
sigurdne Exp $
*/
/**
@@ -1109,7 +1109,7 @@
'access' => array('type' =>
'varchar','precision' => '7','nullable' => True),
'user_id' => array('type' => 'int',
'precision' => 4,'nullable' => True),
'entry_date' => array('type' => 'int',
'precision' => 4,'nullable' => True),
- 'budget_cost' => array('type' => 'int',
'precision' => 4,'nullable' => True),
+ 'budget_cost' => array('type' => 'int',
'precision' => 4,'default' => '0','nullable' => True),
'remark' => array('type' =>
'text','nullable' => True)
),
'pk' => array('id'),
@@ -1129,7 +1129,7 @@
'access' => array('type' =>
'varchar','precision' => '7','nullable' => True),
'user_id' => array('type' => 'int',
'precision' => 4,'nullable' => True),
'entry_date' => array('type' => 'int',
'precision' => 4,'nullable' => True),
- 'budget_cost' => array('type' => 'int',
'precision' => 4,'nullable' => True),
+ 'budget_cost' => array('type' => 'int',
'precision' => 4,'default' => '0','nullable' => True),
'remark' => array('type' =>
'text','nullable' => True)
),
'pk' => array('id'),
@@ -1145,7 +1145,7 @@
'year' => array('type' => 'int',
'precision' => 4,'nullable' => False),
'month' => array('type' => 'int',
'precision' => 4,'nullable' => False),
'b_account_id' => array('type' =>
'varchar','precision' => '20','nullable' => False),
- 'percent' => array('type' =>
'int','precision' => '4','nullable' => True),
+ 'percent' => array('type' =>
'int','precision' => 4,'default' => '0','nullable' => True),
'user_id' => array('type' => 'int',
'precision' => 4,'nullable' => True),
'entry_date' => array('type' => 'int',
'precision' => 4,'nullable' => True),
'remark' => array('type' =>
'text','nullable' => True)
@@ -1165,7 +1165,7 @@
'year' => array('type' => 'int',
'precision' => 4,'nullable' => False),
'month' => array('type' => 'int',
'precision' => 4,'nullable' => False),
'b_account_id' => array('type' =>
'varchar','precision' => '20','nullable' => False),
- 'amount' => array('type' =>
'int','precision' => '4','nullable' => True)
+ 'amount' => array('type' =>
'decimal','precision' => '20','scale' => '2','default' => '0','nullable' =>
True)
),
'pk' => array('id'),
'fk' => array(),