[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] property/inc class.uibudget.inc.php class.sobud...
From: |
Sigurd Nes |
Subject: |
[Phpgroupware-cvs] property/inc class.uibudget.inc.php class.sobud... |
Date: |
Thu, 20 Apr 2006 09:07:43 +0000 |
CVSROOT: /sources/phpgroupware
Module name: property
Branch:
Changes by: Sigurd Nes <address@hidden> 06/04/20 09:07:43
Modified files:
inc : class.uibudget.inc.php class.sobudget.inc.php
Log message:
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.uibudget.inc.php.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/phpgroupware/property/inc/class.sobudget.inc.php.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
Patches:
Index: property/inc/class.sobudget.inc.php
diff -u property/inc/class.sobudget.inc.php:1.9
property/inc/class.sobudget.inc.php:1.10
--- property/inc/class.sobudget.inc.php:1.9 Wed Apr 19 11:27:13 2006
+++ property/inc/class.sobudget.inc.php Thu Apr 20 09:07:43 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.9 2006/04/19 11:27:13
sigurdne Exp $
+ * @version $Id: class.sobudget.inc.php,v 1.10 2006/04/20 09:07:43
sigurdne Exp $
*/
/**
@@ -231,9 +231,10 @@
$budget['district_id'] =
$this->db->f('district_id');
$budget['revision'] =
$this->db->f('revision');
$budget['b_group'] =
$this->db->f('b_group');
- $budget['remark'] =
stripslashes($this->db->f('remark'));
- $budget['budget_cost'] =
$this->db->f('budget_cost');
- $budget['entry_date'] =
$this->db->f('entry_date');
+ $budget['remark'] =
stripslashes($this->db->f('remark'));
+ $budget['budget_cost'] =
$this->db->f('budget_cost');
+ $budget['entry_date'] =
$this->db->f('entry_date');
+ $budget['distribute_year'] =
unserialize($this->db->f('distribute_year'));
}
return $budget;
@@ -247,7 +248,7 @@
$this->db->transaction_begin();
- $sql = "SELECT id FROM fm_budget_basis WHERE year ='" .
$budget['year'] . "' AND b_group ='" . $budget['b_group'] . "' AND revision =
'" . $budget['revision'] . "'AND district_id='" . $budget['district_id'] . "'";
+ $sql = "SELECT id FROM fm_budget_basis WHERE year ='" .
$budget['year'] . "' AND b_group ='" . $budget['b_group'] . "' AND revision =
'" . $budget['revision'] . "' AND district_id='" . $budget['district_id'] . "'";
$this->db->query($sql,__LINE__,__FILE__);
if($this->db->next_record())
@@ -259,8 +260,24 @@
{
$id =
$this->bocommon->next_id('fm_budget_basis');
- $this->db->query("INSERT INTO fm_budget_basis
(id,entry_date,remark,user_id,year,revision,district_id,b_group,budget_cost)"
- . "VALUES ($id,'" . time() . "','" .
$budget['remark'] . "'," . $this->account . "," . $budget['year'] . "," .
$budget['revision'] . "," . $budget['district_id'] . "," . $budget['b_group'] .
"," . $budget['budget_cost'] . ")",__LINE__,__FILE__);
+ $values= array(
+ $id,
+ time(),
+ $budget['remark'],
+ $this->account,
+ $budget['year'],
+ $budget['revision'],
+ $budget['district_id'],
+ $budget['b_group'],
+ $budget['budget_cost'],
+ serialize($budget['distribute_year'])
+ );
+
+ $values =
$this->bocommon->validate_db_insert($values);
+
+
+ $this->db->query("INSERT INTO fm_budget_basis
(id,entry_date,remark,user_id,year,revision,district_id,b_group,budget_cost,distribute_year)"
+ . "VALUES ($values)",__LINE__,__FILE__);
$receipt['budget_id']= $id;
$receipt['message'][] =
array('msg'=>lang('budget %1 has been saved',$receipt['budget_id']));
@@ -273,17 +290,33 @@
function edit_basis($budget)
{
+
$budget['remark'] =
$this->db->db_addslashes($budget['remark']);
- $this->db->query("UPDATE fm_budget set remark='" .
$budget['remark'] . "', entry_date='" . time() . "', budget_cost='" .
$budget['budget_cost'] . "' WHERE id=" .
intval($budget['budget_id']),__LINE__,__FILE__);
+ $value_set=array(
+ 'remark' => $budget['remark'],
+ 'entry_date' => time(),
+ 'budget_cost' => $budget['budget_cost'],
+ 'distribute_year' =>
serialize($budget['distribute_year'])
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
+
+ $this->db->transaction_begin();
+ $this->db->query("UPDATE fm_budget_basis set $value_set
WHERE id=" . intval($budget['budget_id']),__LINE__,__FILE__);
+ $this->db->transaction_commit();
+ if(is_array($budget['distribute_year']))
+ {
+ $budget['distribute'][0] = $budget['budget_id'];
+ $this->distribute($budget);
+ }
+
$receipt['budget_id']= $budget['budget_id'];
$receipt['message'][] = array('msg'=>lang('budget %1
has been edited',$budget['budget_id']));
return $receipt;
}
-
-
function read_single($budget_id)
{
$this->db->query("select * from fm_budget where
id='$budget_id'",__LINE__,__FILE__);
@@ -303,15 +336,13 @@
return $budget;
}
-
-
function add($budget)
{
$budget['remark'] =
$this->db->db_addslashes($budget['remark']);
$this->db->transaction_begin();
- $sql = "SELECT id FROM fm_budget WHERE year ='" .
$budget['year'] . "' AND b_account_id ='" . $budget['b_account_id'] . "' AND
revision = '" . $budget['revision'] . "'AND district_id='" .
$budget['district_id'] . "'";
+ $sql = "SELECT id FROM fm_budget WHERE year ='" .
$budget['year'] . "' AND b_account_id ='" . $budget['b_account_id'] . "' AND
revision = '" . $budget['revision'] . "' AND district_id='" .
$budget['district_id'] . "'";
$this->db->query($sql,__LINE__,__FILE__);
if($this->db->next_record())
@@ -323,8 +354,22 @@
{
$id = $this->bocommon->next_id('fm_budget');
+ $values= array(
+ $id,
+ time(),
+ $budget['remark'],
+ $this->account,
+ $budget['year'],
+ $budget['revision'],
+ $budget['district_id'],
+ $budget['b_account_id'],
+ $budget['budget_cost'],
+ );
+
+ $values =
$this->bocommon->validate_db_insert($values);
+
$this->db->query("INSERT INTO fm_budget
(id,entry_date,remark,user_id,year,revision,district_id,b_account_id,budget_cost)"
- . "VALUES ($id,'" . time() . "','" .
$budget['remark'] . "'," . $this->account . "," . $budget['year'] . "," .
$budget['revision'] . "," . $budget['district_id'] . "," .
$budget['b_account_id'] . "," . $budget['budget_cost'] . ")",__LINE__,__FILE__);
+ . "VALUES ($values)",__LINE__,__FILE__);
$receipt['budget_id']= $id;
$receipt['message'][] =
array('msg'=>lang('budget %1 has been saved',$receipt['budget_id']));
@@ -338,9 +383,21 @@
function edit($budget)
{
$budget['remark'] =
$this->db->db_addslashes($budget['remark']);
+
+ $this->db->transaction_begin();
+
+ $value_set=array(
+ 'remark' => $budget['remark'],
+ 'entry_date' => time(),
+ 'budget_cost' => $budget['budget_cost']
+ );
+
+ $value_set =
$this->bocommon->validate_db_update($value_set);
- $this->db->query("UPDATE fm_budget set remark='" .
$budget['remark'] . "', entry_date='" . time() . "', budget_cost='" .
$budget['budget_cost'] . "' WHERE id=" .
intval($budget['budget_id']),__LINE__,__FILE__);
+ $this->db->query("UPDATE fm_budget set $value_set WHERE
id=" . intval($budget['budget_id']),__LINE__,__FILE__);
+ $this->db->transaction_commit();
+
$receipt['budget_id']= $budget['budget_id'];
$receipt['message'][] = array('msg'=>lang('budget %1
has been edited',$budget['budget_id']));
return $receipt;
@@ -482,9 +539,31 @@
$this->db->query('DELETE FROM fm_budget WHERE id=' .
intval($budget_id),__LINE__,__FILE__);
}
- function delete_basis($budget_id)
+ function delete_basis($basis_id)
{
- $this->db->query('DELETE FROM fm_budget_basis WHERE
id=' . intval($budget_id),__LINE__,__FILE__);
+ $this->db->transaction_begin();
+
+ $this->db->query("SELECT * FROM fm_budget_basis where
id='$basis_id'",__LINE__,__FILE__);
+
+ if ($this->db->next_record())
+ {
+ $basis['year'] =
$this->db->f('year');
+ $basis['district_id'] =
$this->db->f('district_id');
+ $basis['revision'] =
$this->db->f('revision');
+ $basis['b_group'] =
$this->db->f('b_group');
+ $basis['budget_cost'] =
$this->db->f('budget_cost');
+
+ $this->db->query("SELECT id FROM fm_b_account
where category=" . (int)$basis['b_group'],__LINE__,__FILE__);
+ while ($this->db->next_record())
+ {
+ $b_account[] = $this->db->f('id');
+ }
+
+ }
+
+ $this->db->query("DELETE FROM fm_budget WHERE year ='"
. $basis['year'] . "' AND b_account_id in (" . implode(",",$b_account) . ")
AND revision = '" . $basis['revision'] . "' AND district_id='" .
$basis['district_id'] . "'" ,__LINE__,__FILE__);
+ $this->db->query('DELETE FROM fm_budget_basis WHERE
id=' . intval($basis_id),__LINE__,__FILE__);
+ $this->db->transaction_commit();
}
function distribute($values,$receipt='')
Index: property/inc/class.uibudget.inc.php
diff -u property/inc/class.uibudget.inc.php:1.7
property/inc/class.uibudget.inc.php:1.8
--- property/inc/class.uibudget.inc.php:1.7 Wed Apr 19 11:27:13 2006
+++ property/inc/class.uibudget.inc.php Thu Apr 20 09:07:43 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.uibudget.inc.php,v 1.7 2006/04/19 11:27:13
sigurdne Exp $
+ * @version $Id: class.uibudget.inc.php,v 1.8 2006/04/20 09:07:43
sigurdne Exp $
*/
/**
@@ -734,7 +734,6 @@
$GLOBALS['phpgw']->redirect_link('/index.php','menuaction='.$this->currentapp.'.uibudget.basis');
}
- $distribute_year = $values['distribute_year'];
if ($budget_id)
{
$values =
$this->bo->read_single_basis($budget_id);
@@ -758,7 +757,7 @@
'lang_distribute' =>
lang('distribute'),
'lang_distribute_year' =>
lang('distribute year'),
'lang_distribute_year_statustext' =>
lang('of years'),
- 'distribute_year_list' =>
$this->bo->get_distribute_year_list($distribute_year),
+ 'distribute_year_list' =>
$this->bo->get_distribute_year_list($values['distribute_year']),
'lang_revision' =>
lang('revision'),
'lang_revision_statustext' =>
lang('Select revision'),