[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] bookkeeping/inc class.uibilling.inc.php, 1.3 class.ui
From: |
uid65887 |
Subject: |
[Phpgroupware-cvs] bookkeeping/inc class.uibilling.inc.php, 1.3 class.uibookkeeping.inc.php, 1.3 class.sodeliveries.inc.php, 1.2 class.bodeliveries.inc.php, 1.2 class.uideliveries.inc.php, 1.3 class.bobookkeeping.inc.php, 1.3 class.sobilling.inc.php, 1.2 class.bobilling.inc.php, 1.2 |
Date: |
Wed, 27 Apr 2005 06:41:49 -0000 |
Update of bookkeeping/inc
Modified Files:
Branch: MAIN
class.uibilling.inc.php lines: +67 -55
class.uibookkeeping.inc.php lines: +2 -2
class.sodeliveries.inc.php lines: +43 -18
class.bodeliveries.inc.php lines: +32 -43
class.uideliveries.inc.php lines: +65 -62
class.bobookkeeping.inc.php lines: +42 -941
class.sobilling.inc.php lines: +49 -18
class.bobilling.inc.php lines: +19 -22
Log Message:
update
====================================================
Index: bookkeeping/inc/class.uibilling.inc.php
diff -u bookkeeping/inc/class.uibilling.inc.php:1.2
bookkeeping/inc/class.uibilling.inc.php:1.3
--- bookkeeping/inc/class.uibilling.inc.php:1.2 Wed Dec 3 13:20:47 2003
+++ bookkeeping/inc/class.uibilling.inc.php Tue Dec 23 16:34:45 2003
@@ -49,9 +49,9 @@
{
$action = get_var('action',array('POST','GET'));
- $this->boprojects =
CreateObject('projects.boprojects',True, $action);
$this->bobilling =
CreateObject('bookkeeping.bobilling');
- $this->bodeliveries =
CreateObject('bookkeeping.bodeliveries');
+ $this->boprojects =
$this->bobilling->boprojects;
+ $this->bobookkeeping =
CreateObject('bookkeeping.bobookkeeping',True,$action);
$this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
$this->sbox
= CreateObject('phpgwapi.sbox');
$this->cats
= CreateObject('phpgwapi.categories');
@@ -59,12 +59,12 @@
$this->grants =
$GLOBALS['phpgw']->acl->get_grants('projects');
$this->grants[$this->account] = PHPGW_ACL_READ +
PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
- $this->start =
$this->boprojects->start;
- $this->query =
$this->boprojects->query;
- $this->filter =
$this->boprojects->filter;
- $this->order =
$this->boprojects->order;
- $this->sort
= $this->boprojects->sort;
- $this->cat_id =
$this->boprojects->cat_id;
+ $this->start =
$this->bobookkeeping->start;
+ $this->query =
$this->bobookkeeping->query;
+ $this->filter =
$this->bobookkeeping->filter;
+ $this->order =
$this->bobookkeeping->order;
+ $this->sort
= $this->bobookkeeping->sort;
+ $this->cat_id =
$this->bobookkeeping->cat_id;
}
function save_sessiondata($action)
@@ -78,7 +78,7 @@
'sort' => $this->sort,
'cat_id' => $this->cat_id
);
- $this->boprojects->save_sessiondata($data, $action);
+ $this->bobookkeeping->save_sessiondata($data, $action);
}
function set_app_langs()
@@ -153,12 +153,36 @@
return $newtax;
}
+ function status_format($status = '', $showarchive = True)
+ {
+ if (!$status)
+ {
+ $status = $this->status = 'active';
+ }
+
+ switch ($status)
+ {
+ case 'active': $stat_sel[0]='
selected'; break;
+ case 'nonactive': $stat_sel[1]='
selected'; break;
+ case 'archive': $stat_sel[2]='
selected'; break;
+ }
+
+ $status_list = '<option value="active"' . $stat_sel[0]
. '>' . lang('Active') . '</option>' . "\n"
+ . '<option value="nonactive"' .
$stat_sel[1] . '>' . lang('Nonactive') . '</option>' . "\n";
+
+ if ($showarchive)
+ {
+ $status_list .= '<option value="archive"' .
$stat_sel[2] . '>' . lang('Archive') . '</option>' . "\n";
+ }
+ return $status_list;
+ }
+
function list_projects()
{
$action = get_var('action',array('POST','GET'));
- $pro_parent =
get_var('pro_parent',array('POST','GET'));
+ $pro_main =
get_var('pro_main',array('POST','GET'));
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('projects') . ': ' . ($pro_parent?lang('list jobs'):lang('list projects'));
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('bookkeeping') . ' - ' . lang('projects') . ': ' . ($pro_parent?lang('list
jobs'):lang('list projects'));
$this->display_app_header();
$GLOBALS['phpgw']->template->set_file(array('projects_list_t' =>
'bill_list.tpl'));
@@ -172,26 +196,16 @@
$link_data = array
(
'menuaction' =>
'bookkeeping.uibilling.list_projects',
- 'pro_parent' => $pro_parent,
+ 'pro_main' => $pro_main,
'action' => $action
);
- if (!$this->start)
- {
- $this->start = 0;
- }
-
if (!$action)
{
$action = 'mains';
}
- if (!$pro_parent)
- {
- $pro_parent = 0;
- }
-
- $pro =
$this->boprojects->list_projects($this->start,True,$this->query,$this->filter,$this->sort,$this->order,'active',$this->cat_id,$action,$pro_parent);
+ $pro = $this->boprojects->list_projects(array('type' =>
$action,'parent' => $pro_main));
// --------------------- nextmatch variable template-declarations
------------------------
@@ -213,22 +227,19 @@
else
{
$action_list= '<form method="POST" action="' .
$GLOBALS['phpgw']->link('/index.php',$link_data) .'" name="form">' . "\n"
- . '<select
name="pro_parent" onChange="this.form.submit();"><option value="">' .
lang('Select main project') . '</option>' . "\n"
- .
$this->boprojects->select_project_list('mains', $status, $pro_parent) .
'</select>';
+ . '<select
name="pro_main" onChange="this.form.submit();"><option value="">' .
lang('Select main project') . '</option>' . "\n"
+ .
$this->boprojects->select_project_list('mains', $this->status, $pro_main) .
'</select>';
}
- $GLOBALS['filter'] = $this->filter;
- $GLOBALS['query'] = $this->query;
-
$GLOBALS['phpgw']->template->set_var('action_list',$action_list);
-
$GLOBALS['phpgw']->template->set_var('filter_action',$GLOBALS['phpgw']->link('/index.php',$link_data));
+
$GLOBALS['phpgw']->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('filter_list',$this->nextmatchs->new_filter($this->filter));
-
$GLOBALS['phpgw']->template->set_var('search_action',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('search_list',$this->nextmatchs->search(array('query'
=> $this->query)));
+
$GLOBALS['phpgw']->template->set_var('status_list',$this->status_format($this->status));
// ---------------- list header variable template-declarations
--------------------------
-
$GLOBALS['phpgw']->template->set_var(sort_number,$this->nextmatchs->show_sort_order($this->sort,'num',$this->order,'/index.php',lang('Project
ID'),$link_data));
+
$GLOBALS['phpgw']->template->set_var('sort_number',$this->nextmatchs->show_sort_order($this->sort,'num',$this->order,'/index.php',lang('Project
ID'),$link_data));
if ($action == 'mains')
{
@@ -298,14 +309,13 @@
$GLOBALS['phpgw']->template->set_var('part',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('lang_part',lang('Invoice'));
- $link_data['menuaction'] =
'bookkeeping.uibilling.list_invoices';
- $link_data['action'] = 'bill';
+ $link_data['menuaction'] =
'bookkeeping.uibilling.list_invoices';
$GLOBALS['phpgw']->template->set_var('partlist',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('lang_partlist',lang('Invoice list'));
if ($action == 'mains')
{
- $action_entry = '<td align="center"><a
href="' .
$GLOBALS['phpgw']->link('/index.php','menuaction=bookkeeping.uibilling.list_projects&pro_parent='
+ $action_entry = '<td align="center"><a
href="' .
$GLOBALS['phpgw']->link('/index.php','menuaction=bookkeeping.uibilling.list_projects&pro_main='
. $pro[$i]['project_id'] .
'&action=subs') . '">' . lang('Jobs')
. '</a></td>' . "\n";
$GLOBALS['phpgw']->template->set_var('action_entry',$action_entry);
@@ -321,8 +331,10 @@
// ------------------------- end record declaration ------------------------
$GLOBALS['phpgw']->template->set_var('lang_all_partlist',lang('All invoices'));
-
$GLOBALS['phpgw']->template->set_var('all_partlist',$GLOBALS['phpgw']->link('/index.php','menuaction=bookkeeping.uibilling.list_invoices&action=bill'
-
. '&project_id='));
+
+ $link_data['project_id'] = '';
+ $link_data['menuaction'] =
'bookkeeping.uibilling.list_invoices';
+
$GLOBALS['phpgw']->template->set_var('all_partlist',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('lang_all_part2list','');
$GLOBALS['phpgw']->template->set_var('all_part2list','');
@@ -334,7 +346,9 @@
{
$action = get_var('action',array('POST','GET'));
$project_id =
get_var('project_id',array('POST','GET'));
+ $pro_main =
get_var('pro_main',array('POST','GET'));
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('bookkeeping') . ' - ' . lang('projects') . ': ' . lang('list invoices');
$this->display_app_header();
$GLOBALS['phpgw']->template->set_file(array('projects_list_t' =>
'bill_listinvoice.tpl'));
@@ -343,17 +357,18 @@
$link_data = array
(
'menuaction' =>
'projects.uibilling.list_invoices',
- 'action' => $action
+ 'action' => $action,
+ 'pro_main' => $pro_main
);
- $nopref = $this->boprojects->check_prefs();
+ $nopref = $this->bobookkeeping->check_prefs();
if (is_array($nopref))
{
$GLOBALS['phpgw']->template->set_var('pref_message',$GLOBALS['phpgw']->common->error_list($nopref));
}
else
{
- $prefs = $this->boprojects->get_prefs();
+ $prefs = $this->bobookkeeping->get_prefs();
}
if (!$this->start)
@@ -361,8 +376,6 @@
$this->start = 0;
}
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('projects') . ': ' . lang('list invoices');
-
$GLOBALS['phpgw']->template->set_var('search_action',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('search_list',$this->nextmatchs->search(array('query'
=> $this->query)));
@@ -470,19 +483,20 @@
Header('Location: ' . $referer);
}
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('bookkeeping') . ' - ' . lang('projects') . ': ' . lang('create invoice');
$this->display_app_header();
$GLOBALS['phpgw']->template->set_file(array('hours_list_t' =>
'bill_listhours.tpl'));
$GLOBALS['phpgw']->template->set_block('hours_list_t','hours_list','list');
- $nopref = $this->boprojects->check_prefs();
+ $nopref = $this->bobookkeeping->check_prefs();
if (is_array($nopref))
{
$GLOBALS['phpgw']->template->set_var('pref_message',$GLOBALS['phpgw']->common->error_list($nopref));
}
else
{
- $prefs = $this->boprojects->get_prefs();
+ $prefs = $this->bobookkeeping->get_prefs();
}
if ($Invoice)
@@ -521,8 +535,6 @@
'invoice_id' => $invoice_id
);
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('projects') . ': ' . lang('create invoice');
-
$GLOBALS['phpgw']->template->set_var('actionurl',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('currency',$prefs['currency']);
@@ -537,7 +549,7 @@
if (!$pro['customer'])
{
-
$GLOBALS['phpgw']->template->set_var('customer',lang('You have no customer
selected !'));
+
$GLOBALS['phpgw']->template->set_var('customer',lang('You have no customer
selected'));
}
else
{
@@ -550,11 +562,11 @@
if (!$invoice_id)
{
-
$GLOBALS['phpgw']->template->set_var('lang_choose',lang('Generate Invoice ID
?'));
+
$GLOBALS['phpgw']->template->set_var('lang_choose',lang('Generate Invoice ID'));
$GLOBALS['phpgw']->template->set_var('choose','<input type="checkbox"
name="values[choose]" value="True">');
$GLOBALS['phpgw']->template->set_var('print_invoice',$GLOBALS['phpgw']->link('/index.php','menuaction=bookkeeping.uibilling.fail'));
$GLOBALS['phpgw']->template->set_var('invoice_num',$values['invoice_num']);
- $hours =
$this->bobilling->read_hours($project_id, $action);
+ $hours =
$this->bobilling->read_hours($project_id, $action,
$this->bobookkeeping->status);
}
else
{
@@ -564,7 +576,7 @@
.
'&invoice_id=' . $invoice_id));
$bill =
$this->bobilling->read_single_invoice($invoice_id);
$GLOBALS['phpgw']->template->set_var('invoice_num',$bill['invoice_num']);
- $hours =
$this->bobilling->read_invoice_hours($project_id, $invoice_id, $action);
+ $hours =
$this->bobilling->read_invoice_hours($project_id, $invoice_id, $action,
$this->bobookkeeping->status);
}
if ($bill['date'])
@@ -764,7 +776,7 @@
function fail()
{
- echo '<p><center>' . lang('You have to CREATE a
delivery or invoice first !');
+ echo '<p><center>' . lang('You have to CREATE a
delivery or invoice first');
echo '</center>';
$GLOBALS['phpgw']->common->phpgw_exit();
}
@@ -787,8 +799,8 @@
{
$prefs = $this->boprojects->get_prefs();
$GLOBALS['phpgw']->template->set_var('currency',$prefs['currency']);
-
$GLOBALS['phpgw']->template->set_var('myaddress',$this->bodeliveries->get_address_data('line',$prefs['abid'],$prefs['ifont'],$prefs['mysize']));
-
$GLOBALS['phpgw']->template->set_var('fulladdress',$this->bodeliveries->get_address_data('full',$prefs['abid'],$prefs['ifont'],$prefs['mysize']));
+
$GLOBALS['phpgw']->template->set_var('myaddress',$this->bobookkeeping->get_address_data('line',$prefs['abid'],$prefs['ifont'],$prefs['mysize']));
+
$GLOBALS['phpgw']->template->set_var('fulladdress',$this->bobookkeeping->get_address_data('full',$prefs['abid'],$prefs['ifont'],$prefs['mysize']));
}
$GLOBALS['phpgw']->template->set_var('site_title',$GLOBALS['phpgw_info']['site_title']);
@@ -803,7 +815,7 @@
if ($prefs)
{
-
$GLOBALS['phpgw']->template->set_var('customer',$this->bodeliveries->get_address_data('address',$bill['customer'],$prefs['ifont'],$prefs['allsize']));
+
$GLOBALS['phpgw']->template->set_var('customer',$this->bobookkeeping->get_address_data('address',$bill['customer'],$prefs['ifont'],$prefs['allsize']));
}
$bill['date'] = $bill['date'] + (60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'];
====================================================
====================================================
Index: bookkeeping/inc/class.sodeliveries.inc.php
diff -u bookkeeping/inc/class.sodeliveries.inc.php:1.1
bookkeeping/inc/class.sodeliveries.inc.php:1.2
--- bookkeeping/inc/class.sodeliveries.inc.php:1.1 Mon Dec 1 16:31:33 2003
+++ bookkeeping/inc/class.sodeliveries.inc.php Tue Dec 23 16:34:45 2003
@@ -1,10 +1,10 @@
<?php
/*******************************************************************\
- * phpGroupWare - Projects *
+ * phpGroupWare - Bookkeeping *
* http://www.phpgroupware.org *
* This program is part of the GNU project, see http://www.gnu.org/
*
* *
- * Project Manager *
+ * Accounting application for the Project Manager *
* Written by Bettina Gille address@hidden *
* ----------------------------------------------- *
* Copyright 2000 - 2003 Free Software Foundation, Inc *
@@ -35,6 +35,7 @@
$this->db = $GLOBALS['phpgw']->db;
$this->db2 = $this->db;
$this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->soprojects =
CreateObject('projects.soprojects');
}
function return_join()
@@ -89,21 +90,44 @@
}
}
- function read_hours($project_id, $action)
+ function parent_search($values)
{
- $project_id = intval($project_id);
+ $project_id = intval($values['project_id']);
+ $action =
isset($values['action'])?$values['action']:'mains';
+ $table =
isset($values['table'])?$values['table']:'hours';
+ $status =
isset($values['status'])?$values['status']:'active';
- $ordermethod = ' order by end_date asc';
+ switch($action)
+ {
+ case 'mains': $type = 'mainandsubs'; break;
+ case 'subs': $type = 'subs'; break;
+ }
+ $pro_array =
$this->soprojects->read_projects(array('type' => $type,'limit' => False,'main'
=> $project_id,'parent' => $project_id,'column' => 'id', 'status' => $status));
- if ($action == 'mains')
+ if(is_array($pro_array))
{
- $parent_hours = ' OR
phpgw_p_hours.pro_parent=' . $project_id;
+ switch($table)
+ {
+ case 'del': $parent_search = ' OR
phpgw_p_delivery.project_id in(' . implode(',',$pro_array) . ')'; break;
+ default: $parent_search = ' OR
phpgw_p_hours.project_id in(' . implode(',',$pro_array) . ')'; break;
+ }
+ return $parent_search;
}
+ return False;
+ }
+
+ function read_hours($project_id, $action, $status)
+ {
+ $project_id = intval($project_id);
+
+ $ordermethod = ' order by end_date asc';
+
+ $parent_search =
$this->parent_search(array('project_id' => $project_id,'action' =>
$action,'status' => $status));
$this->db->query('SELECT phpgw_p_hours.id as
id,phpgw_p_hours.hours_descr,phpgw_p_activities.descr,phpgw_p_hours.status,'
.
'phpgw_p_hours.start_date,phpgw_p_hours.minutes,phpgw_p_hours.minperae FROM
phpgw_p_hours' . $this->return_join()
. "phpgw_p_activities
ON phpgw_p_hours.activity_id=phpgw_p_activities.id WHERE
(phpgw_p_hours.dstatus='o' "
- . "AND
phpgw_p_hours.status != 'open') AND (phpgw_p_hours.project_id=" . $project_id .
$parent_hours
+ . "AND
phpgw_p_hours.status != 'open') AND (phpgw_p_hours.project_id=" . $project_id .
$parent_search
. ')' .
$ordermethod,__LINE__,__FILE__);
while ($this->db->next_record())
@@ -123,17 +147,14 @@
return $hours;
}
- function read_delivery_hours($project_id, $delivery_id, $action)
+ function read_delivery_hours($project_id, $delivery_id,
$action, $status)
{
$project_id = intval($project_id);
$delivery_id = intval($delivery_id);
$ordermethod = ' order by end_date asc';
- if ($action == 'mains' || $action == 'amains')
- {
- $parent_search = ' OR
phpgw_p_hours.pro_parent=' . $project_id;
- }
+ $parent_search =
$this->parent_search(array('project_id' => $project_id,'action' => $action,
'status' => $status));
$this->db->query('SELECT phpgw_p_hours.id as
id,phpgw_p_hours.hours_descr,phpgw_p_activities.descr,phpgw_p_hours.status,'
.
'phpgw_p_hours.start_date,phpgw_p_hours.minutes,phpgw_p_hours.minperae FROM
phpgw_p_hours' . $this->return_join()
@@ -168,6 +189,8 @@
$owner = ($values['owner'] ==
'yes'?True:False);
$limit =
(isset($values['limit'])?$values['limit']:True);
$start = intval($values['start']);
+ $status =
isset($values['status'])?$values['status']:'active';
+ $action =
isset($values['action'])?$values['action']:'mains';
if ($order)
{
@@ -188,11 +211,13 @@
$acl_select = ' AND phpgw_p_delivery.owner=' .
$this->account;
}
- if ($project_id)
+ if ($project_id > 0)
{
+ $parent_search =
$this->parent_search(array('project_id' => $project_id,'action' => $action,
'status' => $status,'table' => 'del'));
+
$sql = 'SELECT phpgw_p_delivery.id as
id,d_number,title,d_date,phpgw_p_delivery.project_id,phpgw_p_delivery.customer '
- . 'FROM
phpgw_p_delivery,phpgw_p_projects WHERE phpgw_p_delivery.project_id=' .
$project_id
- . ' AND
phpgw_p_delivery.project_id=phpgw_p_projects.id';
+ . 'FROM
phpgw_p_delivery,phpgw_p_projects WHERE (phpgw_p_delivery.project_id=' .
$project_id . $parent_search
+ . ') AND
phpgw_p_delivery.project_id=phpgw_p_projects.id';
}
else
{
====================================================
Index: bookkeeping/inc/class.bodeliveries.inc.php
diff -u bookkeeping/inc/class.bodeliveries.inc.php:1.1
bookkeeping/inc/class.bodeliveries.inc.php:1.2
--- bookkeeping/inc/class.bodeliveries.inc.php:1.1 Mon Dec 1 16:31:33 2003
+++ bookkeeping/inc/class.bodeliveries.inc.php Tue Dec 23 16:34:45 2003
@@ -1,10 +1,10 @@
<?php
/*******************************************************************\
- * phpGroupWare - Projects *
+ * phpGroupWare - Bookkeeping *
* http://www.phpgroupware.org *
* This program is part of the GNU project, see http://www.gnu.org/
*
* *
- * Project Manager *
+ * Accounting application for the Project Manager *
* Written by Bettina Gille address@hidden *
* ----------------------------------------------- *
* Copyright 2000 - 2003 Free Software Foundation, Inc *
@@ -37,27 +37,28 @@
'delivery' => True,
'update_delivery' => True,
'read_deliveries' => True,
- 'get_address_data' => True,
'read_delivery_pos' => True
);
function bodeliveries()
{
- $this->sodeliveries =
CreateObject('projects.sodeliveries');
- $this->soprojects =
CreateObject('projects.soprojects');
- $this->contacts =
CreateObject('phpgwapi.contacts');
- $this->boprojects =
CreateObject('projects.boprojects');
+ $action = get_var('action',array('POST','GET'));
+
+ $this->sodeliveries =
CreateObject('bookkeeping.sodeliveries');
+ $this->soprojects =
$this->sodeliveries->soprojects;
+ $this->boprojects =
CreateObject('projects.boprojects');
+ $this->bobookkeeping =
CreateObject('bookkeeping.bobookkeeping',True,$action);
}
- function read_hours($project_id, $action)
+ function read_hours($project_id, $action, $status)
{
- $hours = $this->sodeliveries->read_hours($project_id,
$action);
+ $hours = $this->sodeliveries->read_hours($project_id,
$action, $status);
return $hours;
}
- function read_delivery_hours($project_id, $delivery_id, $action)
+ function read_delivery_hours($project_id, $delivery_id,
$action, $status)
{
- $hours =
$this->sodeliveries->read_delivery_hours($project_id, $delivery_id, $action);
+ $hours =
$this->sodeliveries->read_delivery_hours($project_id, $delivery_id, $action,
$status);
return $hours;
}
@@ -67,16 +68,21 @@
return $hours;
}
- function get_site_config()
+ function read_deliveries($values)
{
- return $this->boprojects->get_site_config();
- }
+ if(substr($values['action'],-5) == 'mains')
+ {
+ $action = 'mains';
+ }
+ elseif(substr($values['action'],-4) == 'subs')
+ {
+ $action = 'subs';
+ }
- function read_deliveries($start, $query, $sort, $order, $limit,
$project_id)
- {
- $co = $this->get_site_config();
- $del =
$this->sodeliveries->read_deliveries(array('start' => $start,'query' =>
$query,'sort' => $sort,'order' => $order,'limit' => $limit,
-
'project_id' => $project_id,'owner' =>
$co['invoice_acl']));
+ $co = $this->bobookkeeping->get_site_config();
+ $del =
$this->sodeliveries->read_deliveries(array('start' => $values['start'],'query'
=> $values['query'],'sort' => $values['sort'],
+
'order' =>
$values['order'],'project_id' => $values['project_id'],'owner' =>
$co['invoice_acl'],
+
'status' => $values['status'],'action'
=> $action));
$this->total_records =
$this->sodeliveries->total_records;
return $del;
}
@@ -87,54 +93,37 @@
return $del;
}
- function get_address_data($format, $abid, $afont, $asize)
- {
- if ($format == 'address')
- {
- $address =
$this->contacts->formatted_address($abid,True,$afont,$asize);
- }
- elseif ($format == 'line')
- {
- $address =
$this->contacts->formatted_address_line($abid,True,$afont,$asize);
- }
- else
- {
- $address =
$this->contacts->formatted_address_full($abid,True,$afont,$asize);
- }
- return $address;
- }
-
function check_values($values,$select)
{
if (!$values['choose'])
{
if (!$values['delivery_num'])
{
- $error[] = lang('Please enter an ID !');
+ $error[] = lang('Please enter an ID');
}
else
{
$num =
$this->sodeliveries->exists($values);
if ($num)
{
- $error[] = lang('That ID has
been used already !');
+ $error[] = lang('That ID has
been used already');
}
}
}
if (! is_array($select))
{
- $error[] = lang('The delivery note contains no
items !');
+ $error[] = lang('The delivery note contains no
items');
}
if (! $values['customer'])
{
- $error[] = lang('You have no customer selected
!');
+ $error[] = lang('You have no customer
selected');
}
if (!
checkdate($values['month'],$values['day'],$values['year']))
{
- $error[] = lang('You have entered an invalid
date !');
+ $error[] = lang('You have entered an invalid
date');
}
if (is_array($error))
====================================================
Index: bookkeeping/inc/class.uideliveries.inc.php
diff -u bookkeeping/inc/class.uideliveries.inc.php:1.2
bookkeeping/inc/class.uideliveries.inc.php:1.3
--- bookkeeping/inc/class.uideliveries.inc.php:1.2 Wed Dec 3 13:20:47 2003
+++ bookkeeping/inc/class.uideliveries.inc.php Tue Dec 23 16:34:45 2003
@@ -49,9 +49,9 @@
{
$action = get_var('action',array('POST','GET'));
- $this->boprojects =
CreateObject('projects.boprojects',True, $action);
$this->bodeliveries =
CreateObject('bookkeeping.bodeliveries');
- $this->bobookkeeping =
CreateObject('bookkeeping.bobookkeeping');
+ $this->boprojects =
$this->bodeliveries->boprojects;
+ $this->bobookkeeping =
CreateObject('bookkeeping.bobookkeeping',True,$action);
$this->nextmatchs =
CreateObject('phpgwapi.nextmatchs');
$this->sbox
= CreateObject('phpgwapi.sbox');
$this->cats
= CreateObject('phpgwapi.categories');
@@ -59,13 +59,13 @@
$this->grants =
$GLOBALS['phpgw']->acl->get_grants('projects');
$this->grants[$this->account] = PHPGW_ACL_READ +
PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
- $this->start =
$this->boprojects->start;
- $this->query =
$this->boprojects->query;
- $this->filter =
$this->boprojects->filter;
- $this->order =
$this->boprojects->order;
- $this->sort
= $this->boprojects->sort;
- $this->cat_id =
$this->boprojects->cat_id;
- $this->status =
$this->boprojects->status;
+ $this->start =
$this->bobookkeeping->start;
+ $this->query =
$this->bobookkeeping->query;
+ $this->filter =
$this->bobookkeeping->filter;
+ $this->order =
$this->bobookkeeping->order;
+ $this->sort
= $this->bobookkeeping->sort;
+ $this->cat_id =
$this->bobookkeeping->cat_id;
+ $this->status =
$this->bobookkeeping->status;
}
function save_sessiondata($action)
@@ -80,7 +80,7 @@
'cat_id' => $this->cat_id,
'status' => $this->status
);
- $this->boprojects->save_sessiondata($data, $action);
+ $this->bobookkeeping->save_sessiondata($data, $action);
}
function set_app_langs()
@@ -168,9 +168,9 @@
function list_projects()
{
$action = get_var('action',array('POST','GET'));
- $pro_parent =
get_var('pro_parent',array('POST','GET'));
+ $pro_main =
get_var('pro_main',array('POST','GET'));
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('projects') . ': ' . ($pro_parent?lang('list jobs'):lang('list projects'));
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('bookkeeping') . ' - ' . lang('projects') . ': ' . ($pro_main?lang('list
jobs'):lang('list projects'));
$this->display_app_header();
$GLOBALS['phpgw']->template->set_file(array('projects_list_t' =>
'bill_list.tpl'));
@@ -184,7 +184,7 @@
$link_data = array
(
'menuaction' =>
'bookkeeping.uideliveries.list_projects',
- 'pro_parent' => $pro_parent,
+ 'pro_main' => $pro_main,
'action' => $action,
'cat_id' => $this->cat_id
);
@@ -194,12 +194,7 @@
$this->start = 0;
}
- if (!$pro_parent)
- {
- $pro_parent = 0;
- }
-
- $pro = $this->boprojects->list_projects(array('type' =>
$action,'parent' => $pro_parent));
+ $pro = $this->boprojects->list_projects(array('type' =>
$action,'parent' => $pro_main));
// --------------------- nextmatch variable template-declarations
------------------------
@@ -216,18 +211,15 @@
{
$action_list = '<select name="cat_id"
onChange="this.form.submit();"><option value="">' . lang('Select category') .
'</option>' . "\n"
.
$this->cats->formatted_list('select','all',$this->cat_id,True) . '</select>';
-
$GLOBALS['phpgw']->template->set_var(lang_header,lang('Project list'));
+
$GLOBALS['phpgw']->template->set_var('lang_header',lang('Project list'));
}
else
{
- $action_list = '<select name="pro_parent"
onChange="this.form.submit();"><option value="">' . lang('Select main project')
. '</option>' . "\n"
- .
$this->boprojects->select_project_list(array('status' => $status,'selected' =>
$pro_parent)) . '</select>';
+ $action_list = '<select name="pro_main"
onChange="this.form.submit();"><option value="">' . lang('Select main project')
. '</option>' . "\n"
+ .
$this->boprojects->select_project_list(array('status' =>
$this->status,'selected' => $pro_main)) . '</select>';
$GLOBALS['phpgw']->template->set_var('lang_header',lang('Job list'));
}
- $GLOBALS['filter'] = $this->filter;
- $GLOBALS['query'] = $this->query;
-
$GLOBALS['phpgw']->template->set_var('action_list',$action_list);
$GLOBALS['phpgw']->template->set_var('action_url',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('filter_list',$this->nextmatchs->new_filter($this->filter));
@@ -236,17 +228,17 @@
// ---------------- list header variable template-declarations
--------------------------
-
$GLOBALS['phpgw']->template->set_var(sort_number,$this->nextmatchs->show_sort_order($this->sort,'num',$this->order,'/index.php',lang('Project
ID'),$link_data));
+
$GLOBALS['phpgw']->template->set_var('sort_number',$this->nextmatchs->show_sort_order($this->sort,'num',$this->order,'/index.php',lang('Project
ID'),$link_data));
if ($action == 'mains')
{
-
$GLOBALS['phpgw']->template->set_var(sort_action,$this->nextmatchs->show_sort_order($this->sort,'customer',$this->order,'/index.php',lang('Customer'),$link_data));
+
$GLOBALS['phpgw']->template->set_var('sort_action',$this->nextmatchs->show_sort_order($this->sort,'customer',$this->order,'/index.php',lang('Customer'),$link_data));
$lang_action = '<td width="5%" align="center">'
. lang('Jobs') . '</td>' . "\n";
$GLOBALS['phpgw']->template->set_var('lang_action',$lang_action);
}
else
{
-
$GLOBALS['phpgw']->template->set_var(sort_action,$this->nextmatchs->show_sort_order($this->sort,'start_date',$this->order,'/index.php',lang('Start
date'),$link_data));
+
$GLOBALS['phpgw']->template->set_var('sort_action',$this->nextmatchs->show_sort_order($this->sort,'start_date',$this->order,'/index.php',lang('Start
date'),$link_data));
$GLOBALS['phpgw']->template->set_var('lang_action','');
}
@@ -301,20 +293,20 @@
));
$link_data['project_id'] =
$pro[$i]['project_id'];
- $link_data['menuaction'] =
'projects.uideliveries.delivery';
+ $link_data['menuaction'] =
'bookkeeping.uideliveries.delivery';
$GLOBALS['phpgw']->template->set_var('part',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('lang_part',lang('Delivery'));
- $link_data['menuaction'] =
'projects.uideliveries.list_deliveries';
- $link_data['action'] = 'del';
+ $link_data['menuaction'] =
'bookkeeping.uideliveries.list_deliveries';
+
$GLOBALS['phpgw']->template->set_var('partlist',$GLOBALS['phpgw']->link('/index.php',$link_data));
$GLOBALS['phpgw']->template->set_var('lang_partlist',lang('Delivery list'));
-
+
if ($action == 'mains')
{
$action_entry = '<td align="center"><a
href="' .
$GLOBALS['phpgw']->link('/index.php','menuaction=bookkeeping.uideliveries.list_projects'
-
. '&pro_parent=' .
$pro[$i]['project_id'] . '&action=subs') . '">' . lang('Jobs')
+
. '&pro_main=' .
$pro[$i]['project_id'] . '&action=subs') . '">' . lang('Jobs')
. '</a></td>' . "\n";
$GLOBALS['phpgw']->template->set_var('action_entry',$action_entry);
}
@@ -328,10 +320,13 @@
// ------------------------- end record declaration ------------------------
-
$GLOBALS['phpgw']->template->set_var('lang_all_partlist',lang('All delivery
notes'));
-
$GLOBALS['phpgw']->template->set_var('all_partlist',$GLOBALS['phpgw']->link('/index.php','menuaction=bookkeeping.uideliveries.list_deliveries&action=del'
-
. '&project_id='));
-
+ if($action == 'mains')
+ {
+ $link_data['project_id'] = '';
+ $link_data['menuaction'] =
'bookkeeping.uideliveries.list_deliveries';
+
$GLOBALS['phpgw']->template->set_var('all_partlist',$GLOBALS['phpgw']->link('/index.php',$link_data));
+
$GLOBALS['phpgw']->template->set_var('lang_all_partlist',lang('All delivery
notes'));
+ }
$GLOBALS['phpgw']->template->set_var('lang_all_part2list','');
$GLOBALS['phpgw']->template->set_var('all_part2list','');
@@ -361,14 +356,14 @@
Header('Location: ' . $referer);
}
- $nopref = $this->boprojects->check_prefs();
+ $nopref = $this->bobookkeeping->check_prefs();
if (is_array($nopref))
{
$GLOBALS['phpgw']->template->set_var('pref_message',$GLOBALS['phpgw']->common->error_list($nopref));
}
else
{
- $prefs = $this->boprojects->get_prefs();
+ $prefs = $this->bobookkeeping->get_prefs();
}
if ($Delivery)
@@ -409,6 +404,8 @@
'delivery_id' => $delivery_id
);
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('bookkeeping') . ' - ' . lang('projects') . ': ' . lang('create delivery');
+
$this->display_app_header();
$GLOBALS['phpgw']->template->set_file(array('hours_list_t' =>
'del_listhours.tpl'));
@@ -429,7 +426,7 @@
if (!$pro['customer'])
{
-
$GLOBALS['phpgw']->template->set_var('customer',lang('You have no customer
selected !'));
+
$GLOBALS['phpgw']->template->set_var('customer',lang('You have no customer
selected'));
}
else
{
@@ -441,11 +438,11 @@
if(!$delivery_id)
{
-
$GLOBALS['phpgw']->template->set_var('lang_choose',lang('Generate Delivery ID
?'));
+
$GLOBALS['phpgw']->template->set_var('lang_choose',lang('Generate Delivery
ID'));
$GLOBALS['phpgw']->template->set_var('choose','<input type="checkbox"
name="values[choose]" value="True">');
$GLOBALS['phpgw']->template->set_var('print_delivery',$GLOBALS['phpgw']->link('/index.php','menuaction=bookkeeping.uideliveries.fail'));
$GLOBALS['phpgw']->template->set_var('delivery_num',$values['delivery_num']);
- $hours =
$this->bodeliveries->read_hours($project_id, $action);
+ $hours =
$this->bodeliveries->read_hours($project_id, $action,
$this->boprojects->status);
}
else
{
@@ -455,7 +452,7 @@
.
'&delivery_id=' . $delivery_id));
$del =
$this->bodeliveries->read_single_delivery($delivery_id);
$GLOBALS['phpgw']->template->set_var('delivery_num',$del['delivery_num']);
- $hours =
$this->bodeliveries->read_delivery_hours($project_id, $delivery_id, $action);
+ $hours =
$this->bodeliveries->read_delivery_hours($project_id, $delivery_id, $action,
$this->boprojects->status);
}
if ($del['date'])
@@ -624,7 +621,7 @@
}
}
- $GLOBALS['phpgw']->template->set_var(sum_aes,$sumaes);
+ $GLOBALS['phpgw']->template->set_var('sum_aes',$sumaes);
if (! $delivery_id)
{
@@ -647,35 +644,41 @@
{
$action = get_var('action',array('POST','GET'));
$project_id =
get_var('project_id',array('POST','GET'));
+ $pro_main =
get_var('pro_main',array('POST','GET'));
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('bookkeeping') . ' - ' . lang('projects') . ': ' . lang('list deliveries');
$this->display_app_header();
$GLOBALS['phpgw']->template->set_file(array('projects_list_t' =>
'bill_listinvoice.tpl'));
$GLOBALS['phpgw']->template->set_block('projects_list_t','projects_list','list');
+ if(substr($action,-5) == 'mains')
+ {
+ $action = 'del_mains';
+ }
+ elseif(substr($action,-4) == 'subs')
+ {
+ $action = 'del_subs';
+ }
+
$link_data = array
(
'menuaction' =>
'bookkeeping.uideliveries.list_deliveries',
'action' => $action,
- 'project_id' => $project_id
+ 'project_id' => $project_id,
+ 'pro_main' => $pro_main
);
- $GLOBALS['phpgw_info']['flags']['app_header'] =
lang('projects') . ': ' . lang('list deliveries');
-
$GLOBALS['phpgw']->template->set_var('search_action',$GLOBALS['phpgw']->link('/index.php',$link_data));
-
$GLOBALS['phpgw']->template->set_var('search_list',$this->nextmatchs->search(array('query'
=> $this->query)));
-
- if (! $this->start)
- {
- $this->start = 0;
- }
+
$GLOBALS['phpgw']->template->set_var('search_list',$this->nextmatchs->search(array('query'
=> $query)));
if (!$project_id)
{
$project_id = '';
}
- $del =
$this->bodeliveries->read_deliveries($this->start, $this->query, $this->sort,
$this->order, True, $project_id);
+ $del =
$this->bodeliveries->read_deliveries(array('start' => $this->start, 'query' =>
$this->query,'sort' => $this->sort,
+
'order' => $this->order,'project_id' =>
$project_id,'status' => $this->status));
// -------------------- nextmatch variable template-declarations
-----------------------------
@@ -745,7 +748,7 @@
}
}
$GLOBALS['phpgw']->template->pfp('out','projects_list_t',True);
- $this->save_sessiondata('del');
+ $this->save_sessiondata($action);
}
function show_delivery()
@@ -757,16 +760,16 @@
$GLOBALS['phpgw']->template->set_file(array('del_list_t' =>
'del_deliveryform.tpl'));
$GLOBALS['phpgw']->template->set_block('del_list_t','del_list','list');
- $error = $this->boprojects->check_prefs();
+ $error = $this->bobookkeeping->check_prefs();
if (is_array($error))
{
$GLOBALS['phpgw']->template->set_var('message',$GLOBALS['phpgw']->common->error_list($error));
}
else
{
- $prefs = $this->boprojects->read_prefs();
-
$GLOBALS['phpgw']->template->set_var('myaddress',$this->bodeliveries->get_address_data('line',$prefs['abid'],$prefs['ifont'],$prefs['mysize']));
-
$GLOBALS['phpgw']->template->set_var('fulladdress',$this->bodeliveries->get_address_data('full',$prefs['abid'],$prefs['ifont'],$prefs['mysize']));
+ $prefs = $this->bobookkeeping->read_prefs();
+
$GLOBALS['phpgw']->template->set_var('myaddress',$this->bobookkeeping->get_address_data('line',$prefs['abid'],$prefs['ifont'],$prefs['mysize']));
+
$GLOBALS['phpgw']->template->set_var('fulladdress',$this->bobookkeeping->get_address_data('full',$prefs['abid'],$prefs['ifont'],$prefs['mysize']));
}
$GLOBALS['phpgw']->template->set_var('site_title',$GLOBALS['phpgw_info']['site_title']);
@@ -781,7 +784,7 @@
if ($prefs)
{
-
$GLOBALS['phpgw']->template->set_var('customer',$this->bodeliveries->get_address_data('address',$del['customer'],$prefs['ifont'],$prefs['allsize']));
+
$GLOBALS['phpgw']->template->set_var('customer',$this->bobookkeeping->get_address_data('address',$del['customer'],$prefs['ifont'],$prefs['allsize']));
}
$del['date'] = $del['date'] + (60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'];
====================================================
Index: bookkeeping/inc/class.bobookkeeping.inc.php
diff -u bookkeeping/inc/class.bobookkeeping.inc.php:1.2
bookkeeping/inc/class.bobookkeeping.inc.php:1.3
--- bookkeeping/inc/class.bobookkeeping.inc.php:1.2 Wed Dec 3 13:20:46 2003
+++ bookkeeping/inc/class.bobookkeeping.inc.php Tue Dec 23 16:34:45 2003
@@ -1,10 +1,10 @@
<?php
/*******************************************************************\
- * phpGroupWare - Projects *
+ * phpGroupWare - Bookkeeping *
* http://www.phpgroupware.org *
* This program is part of the GNU project, see http://www.gnu.org/
*
* *
- * Project Manager *
+ * Accounting application for the Project Manager *
* Written by Bettina Gille address@hidden *
* ----------------------------------------------- *
* Copyright 2000 - 2003 Free Software Foundation, Inc *
@@ -39,39 +39,18 @@
var $public_functions = array
(
- 'cached_accounts' => True,
- 'list_projects' => True,
- 'check_perms' => True,
- 'check_values' => True,
- 'select_project_list' => True,
- 'check_act_values' => True,
- 'save_project' => True,
- 'read_single_project' => True,
- 'delete_pa' => True,
- 'exists' => True,
- 'isprojectadmin' => True,
- 'select_activity_list' => True,
- 'employee_list' => True,
- 'check_prefs' => True,
- 'get_prefs' => True,
- 'list_activities' => True,
- 'read_single_activity' => True,
- 'save_activity' => True,
- 'read_abook' => True,
- 'read_single_contact' => True,
- 'read_prefs' => True,
- 'save_prefs' => True,
- 'return_value' => True,
- 'select_activities_list' => True,
- 'select_pro_activities' => True,
- 'select_hours_activities' => True,
- 'change_owner' => True,
- 'activities_list' => True
+ 'save_sessiondata' => True,
+ 'get_address_data' => True,
+ 'read_prefs' => True,
+ 'save_prefs' => True,
+ 'check_prefs' => True,
+ 'get_site_config' => True
);
function bobookkeeping($session=False, $action = '')
{
$this->debug = False;
+ $this->contacts = CreateObject('phpgwapi.contacts');
if ($session)
{
@@ -138,17 +117,10 @@
{
switch ($action)
{
- case 'mains' : $column = 'projects_mains';
break;
- case 'subs' : $column =
'projects_subs'; break;
- case 'act' : $column =
'projects_act'; break;
- case 'pad' : $column =
'projects_pad'; break;
- case 'pbo' : $column =
'projects_pbo'; break;
- case 'amains' : $column = 'projects_amains';
break;
- case 'asubs' : $column = 'projects_asubs';
break;
- case 'ustat' : $column = 'projects_ustat';
break;
- case 'pstat' : $column = 'projects_pstat';
break;
- case 'bill' : $column =
'projects_bill'; break;
- case 'del' : $column =
'projects_del'; break;
+ case 'mains': $column =
'bookkeeping_mains'; break;
+ case 'subs' : $column =
'bookkeeping_subs'; break;
+ case 'del_mains': $column =
'bookkeeping_de_mains'; break;
+ case 'del_subs': $column =
'bookkeeping_de_subs'; break;
}
return $column;
}
@@ -176,70 +148,21 @@
$this->status = $data['status'];
}
- function check_perms($has, $needed)
+ function get_address_data($format, $abid, $afont, $asize)
{
- return (!!($has & $needed) == True);
- }
-
- function cached_accounts($account_id)
- {
- $this->accounts =
CreateObject('phpgwapi.accounts',$account_id);
-
- $this->accounts->read_repository();
-
-
$cached_data[$this->accounts->data['account_id']]['account_id'] =
$this->accounts->data['account_id'];
-
$cached_data[$this->accounts->data['account_id']]['account_lid'] =
$this->accounts->data['account_lid'];
-
$cached_data[$this->accounts->data['account_id']]['firstname'] =
$this->accounts->data['firstname'];
-
$cached_data[$this->accounts->data['account_id']]['lastname'] =
$this->accounts->data['lastname'];
-
- return $cached_data;
- }
-
- function return_date()
- {
- $date = array
- (
- 'month' =>
$GLOBALS['phpgw']->common->show_date(time(),'n'),
- 'day' =>
$GLOBALS['phpgw']->common->show_date(time(),'d'),
- 'year' =>
$GLOBALS['phpgw']->common->show_date(time(),'Y')
- );
-
- $date['daydate'] =
mktime(2,0,0,$date['month'],$date['day'],$date['year']);
- $date['monthdate'] =
mktime(2,0,0,$date['month']+2,0,$date['year']);
- $date['monthformatted'] =
$GLOBALS['phpgw']->common->show_date($date['monthdate'],'n/Y');
- return $date;
- }
-
- function read_abook($start, $query, $qfilter, $sort, $order)
- {
- $account_id =
$GLOBALS['phpgw_info']['user']['account_id'];
-
- $cols = array('n_given' => 'n_given',
- 'n_family' => 'n_family',
- 'org_name' => 'org_name');
-
- $entries =
$this->contacts->read($start,$GLOBALS['phpgw_info']['user']['preferences']['common']['maxmatchs'],
$cols, $query, $qfilter, $sort, $order, $account_id);
- $this->total_records = $this->contacts->total_records;
- return $entries;
- }
-
- function read_single_contact($abid)
- {
- $cols = array('n_given' => 'n_given',
- 'n_family' => 'n_family',
- 'org_name' => 'org_name');
-
- return $this->contacts->read_single_entry($abid,$cols);
- }
-
- function return_value($action,$item)
- {
- return $this->so->return_value($action,$item);
- }
-
- function list_pcosts($project_id)
- {
- return $this->so->list_pcosts($project_id);
+ if ($format == 'address')
+ {
+ $address =
$this->contacts->formatted_address($abid,True,$afont,$asize);
+ }
+ elseif ($format == 'line')
+ {
+ $address =
$this->contacts->formatted_address_line($abid,True,$afont,$asize);
+ }
+ else
+ {
+ $address =
$this->contacts->formatted_address_full($abid,True,$afont,$asize);
+ }
+ return $address;
}
function read_prefs()
@@ -248,17 +171,10 @@
$prefs = array();
- if
($GLOBALS['phpgw_info']['user']['preferences']['projects'])
+ if
($GLOBALS['phpgw_info']['user']['preferences']['bookkeeping'])
{
- $prefs['tax'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['tax'];
- $prefs['abid'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['abid'];
- $prefs['bill'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['bill'];
- $prefs['ifont'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['ifont'];
- $prefs['mysize'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['mysize'];
- $prefs['allsize'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['allsize'];
- $prefs['notify_mstone'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['notify_mstone'];
- $prefs['notify_pro'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['notify_pro'];
- $prefs['notify_assign'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['notify_assign'];
+ $prefs['tax'] =
$GLOBALS['phpgw_info']['user']['preferences']['bookkeeping']['tax'];
+ $prefs['abid'] =
$GLOBALS['phpgw_info']['user']['preferences']['bookkeeping']['abid'];
}
return $prefs;
}
@@ -269,29 +185,20 @@
if (is_array($prefs))
{
-
$GLOBALS['phpgw']->preferences->change('projects','tax',$prefs['tax']);
-
$GLOBALS['phpgw']->preferences->change('projects','abid',$prefs['abid']);
-
$GLOBALS['phpgw']->preferences->change('projects','bill',$prefs['bill']);
-
$GLOBALS['phpgw']->preferences->change('projects','ifont',$prefs['ifont']);
-
$GLOBALS['phpgw']->preferences->change('projects','mysize',$prefs['mysize']);
-
$GLOBALS['phpgw']->preferences->change('projects','allsize',$prefs['allsize']);
-
$GLOBALS['phpgw']->preferences->change('projects','notify_mstone',(isset($prefs['notify_mstone'])?'yes':''));
-
$GLOBALS['phpgw']->preferences->change('projects','notify_pro',(isset($prefs['notify_pro'])?'yes':''));
-
$GLOBALS['phpgw']->preferences->change('projects','notify_assign',(isset($prefs['notify_assign'])?'yes':''));
+
$GLOBALS['phpgw']->preferences->change('bookkeeping','tax',$prefs['tax']);
+
$GLOBALS['phpgw']->preferences->change('bookkeeping','abid',$prefs['abid']);
$GLOBALS['phpgw']->preferences->save_repository(True);
- // _debug_array($prefs);
- // exit;
}
- if ($prefs['oldbill'] == 'h' && $prefs['bill'] == 'wu')
+ /*if ($prefs['oldbill'] == 'h' && $prefs['bill'] ==
'wu')
{
return True;
}
else
{
return False;
- }
+ }*/
}
function check_prefs()
@@ -303,13 +210,9 @@
$error[] = lang('please specify country and
currency in the global preferences section');
}
- if ($this->isprojectadmin('pad') ||
$this->isprojectadmin('pbo'))
+ if (!isset($prefs['abid']) || !isset($prefs['tax']))
{
- if (! isset($prefs['abid']) || (!
isset($prefs['tax'])) || (! isset($prefs['bill'])) || (!
isset($prefs['ifont'])) || (! isset($prefs['mysize'])) || (!
isset($prefs['allsize'])))
- {
- $error[] = lang('if you are an
administrator, please set the preferences for this application');
- $error[] = lang('if you are not an
administrator, please inform the administrator to set the preferences for this
application');
- }
+ $error[] = lang('please set your preferences
for this application');
}
return $error;
}
@@ -323,819 +226,17 @@
$prefs['currency'] =
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'];
$prefs['country'] =
$GLOBALS['phpgw_info']['user']['preferences']['common']['country'];
- if
($GLOBALS['phpgw_info']['user']['preferences']['projects'])
+ if
($GLOBALS['phpgw_info']['user']['preferences']['bookkeeping'])
{
- if ($this->isprojectadmin('pad') ||
$this->isprojectadmin('pbo'))
- {
- $prefs['abid'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['abid'];
- $prefs['tax'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['tax'];
- $prefs['bill'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['bill'];
- $prefs['ifont'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['ifont'];
- $prefs['mysize'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['mysize'];
- $prefs['allsize'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['allsize'];
- }
- $prefs['notify_mstone'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['notify_mstone'];
- $prefs['notify_pro'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['notify_pro'];
- $prefs['notify_assign'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['notify_assign'];
+ $prefs['abid'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['abid'];
+ $prefs['tax'] =
$GLOBALS['phpgw_info']['user']['preferences']['projects']['tax'];
}
return $prefs;
}
- function employee_list()
- {
- $employees =
$GLOBALS['phpgw']->accounts->get_list('accounts');
- return $employees;
- }
-
- function get_acl_for_project($project_id)
- {
- return
$GLOBALS['phpgw']->acl->get_ids_for_location($project_id, 7);
- }
-
- function selected_employees($project_id)
- {
- $emps = $this->get_acl_for_project($project_id);
-
- if (is_array($emps))
- {
- for($i=0;$i<count($emps);$i++)
- {
- $this->accounts =
CreateObject('phpgwapi.accounts',$emps[$i]);
- $this->accounts->read_repository();
-
- $empl[] = array
- (
- 'account_id' =>
$this->accounts->data['account_id'],
- 'account_lid' =>
$this->accounts->data['account_lid'],
- 'account_firstname' =>
$this->accounts->data['firstname'],
- 'account_lastname' =>
$this->accounts->data['lastname']
- );
- }
- }
- return $empl;
- }
-
- function read_admins($action, $type)
- {
- $admins = $this->so->return_admins($action, $type);
- $this->total_records = $this->so->total_records;
- return $admins;
- }
-
- function list_admins($action, $type, $start, $query, $sort,
$order)
- {
- $admins = $this->read_admins($action, 'all');
- $allaccounts =
$GLOBALS['phpgw']->accounts->get_list($type, $start, $sort, $order, $query);
-
- $j = 0;
- while (is_array($allaccounts) && list($null,$account) =
each($allaccounts))
- {
- for ($i=0;$i<count($admins);$i++)
- {
- if ($account['account_id'] ==
$admins[$i]['account_id'])
- {
- $admin_data[$j]['account_id']
= $account['account_id'];
- $admin_data[$j]['lid']
= $account['account_lid'];
- $admin_data[$j]['firstname']
= $account['account_firstname'];
- $admin_data[$j]['lastname']
= $account['account_lastname'];
- $admin_data[$j]['type']
= $account['account_type'];
- $j++;
- }
- }
- }
- return $admin_data;
- }
-
- function selected_admins($action, $type)
- {
- $is_admin = $this->read_admins($action, $type);
-
- if ($type == 'aa')
- {
- $alladmins =
$GLOBALS['phpgw']->accounts->get_list('accounts');
- }
- else
- {
- $alladmins =
$GLOBALS['phpgw']->accounts->get_list('groups');
- }
-
- while (list($null,$ad_account) = each($alladmins))
- {
- $selected_admins .= '<option value="' .
$ad_account['account_id'] . '"';
- for ($i=0;$i<count($is_admin);$i++)
- {
- if($is_admin[$i]['account_id'] ==
$ad_account['account_id'])
- {
- $selected_admins .= ' selected';
- }
- }
- $selected_admins .= '>'
- . $ad_account['account_firstname'] . ' ' .
$ad_account['account_lastname'] . ' [ ' . $ad_account['account_lid'] . ' ]' .
'</option>';
- }
- return $selected_admins;
- }
-
- function edit_admins($action, $users, $groups)
- {
- $this->so->edit_admins($action, $users, $groups);
- }
-
- function isprojectadmin($action)
- {
- if ($action == 'pad')
- {
- $admin = $this->so->isprojectadmin($action);
- }
- else
- {
- $admin = $this->so->isbookkeeper($action);
- }
- return $admin;
- }
-
- function list_projects($params)
- {
- $pro_list = $this->so->read_projects(array
- (
-
'start' => $this->start,
-
'limit' => $this->limit,
-
'query' => $this->query,
-
'filter' => $this->filter,
-
'sort' => $this->sort,
-
'order' => $this->order,
-
'status' => $this->status,
-
'cat_id' => $this->cat_id,
-
'type' => $params['type'],
-
'parent' => $params['parent'],
-
'main' => $params['main']
- ));
-
- while (is_array($pro_list) &&
list(,$pro)=each($pro_list))
- {
- $cached_data =
$this->cached_accounts($pro['coordinator']);
- $coordinatorout =
$GLOBALS['phpgw']->strip_html($cached_data[$pro['coordinator']]['account_lid']
- . ' [' .
$cached_data[$pro['coordinator']]['firstname'] . ' '
- .
$cached_data[$pro['coordinator']]['lastname'] . ' ]');
- /*if ($pro['customer'])
- {
- $customer =
$this->read_single_contact($pro['customer']);
- if ($customer[0]['org_name'] == '') { $customerout =
$customer[0]['n_given'] . ' ' . $customer[0]['n_family']; }
- else { $customerout = $customer[0]['org_name'] . ' [ '
. $customer[0]['n_given'] . ' ' . $customer[0]['n_family'] . ' ]'; }
- }
-
- $pro['sdate'] = $pro['sdate'] + (60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'];
- $sdateout =
$GLOBALS['phpgw']->common->show_date($pro['sdate'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);*/
-
- $mstones =
$this->get_mstones($pro['project_id']);
-
- if (!isset($params['mstones_stat']))
- {
- $mlist = '';
- if (is_array($mstones))
- {
- $mlist = '<table width="100%"
border="0" cellpadding="0" cellspacing="0">' . "\n";
- for
($i=0;$i<count($mstones);$i++)
- {
- $mlist .= '<tr><td
width="50%">' . $mstones[$i]['title'] . '</td><td width="50%" align="right">' .
$this->formatted_edate($mstones[$i]['edate']) . '</td></tr>' . "\n";
- }
- $mlist .= '</table>';
- }
- }
-
- $projects[] = array
- (
- 'project_id' =>
$pro['project_id'],
- 'parent' =>
$pro['parent'],
- 'coordinator' =>
$pro['coordinator'],
- 'coordinatorout' =>
$coordinatorout,
- 'customerout' => $customerout,
- 'title' =>
$GLOBALS['phpgw']->strip_html($pro['title']),
- 'number' =>
$GLOBALS['phpgw']->strip_html($pro['number']),
- 'investment_nr' =>
$GLOBALS['phpgw']->strip_html($pro['investment_nr']),
- 'descr' =>
$GLOBALS['phpgw']->strip_html($pro['descr']),
- 'sdate' =>
$pro['sdate'],
- 'budget' =>
$pro['budget'],
- 'pcosts' =>
$pro['pcosts'],
- 'edate' =>
$pro['edate'],
- 'status' =>
$pro['status'],
- 'level' =>
$pro['level'],
- 'mstones' =>
(isset($mlist)?$mlist:$mstones)
- );
- }
-
- $this->total_records = $this->so->total_records;
- return $projects;
- }
-
- function read_single_project($project_id)
- {
- $pro = $this->so->read_single_project($project_id);
-
- $project = array
- (
- 'utime' =>
$this->sohours->get_time_used($project_id),
- 'ptime' =>
($pro['ptime']/60),
- 'title' =>
$GLOBALS['phpgw']->strip_html($pro['title']),
- 'number' =>
$GLOBALS['phpgw']->strip_html($pro['number']),
- 'investment_nr' =>
$GLOBALS['phpgw']->strip_html($pro['investment_nr']),
- 'descr' =>
$GLOBALS['phpgw']->strip_html($pro['descr']),
- 'budget' =>
$pro['budget'],
- 'pcosts' =>
$pro['pcosts'],
- 'project_id' => $pro['project_id'],
- 'parent' =>
$pro['parent'],
- 'cat' => $pro['cat'],
- 'access' =>
$pro['access'],
- 'coordinator' => $pro['coordinator'],
- 'customer' =>
$pro['customer'],
- 'status' =>
$pro['status'],
- 'owner' =>
$pro['owner'],
- 'processor' =>
$pro['processor'],
- 'previous' =>
$pro['previous']
- );
-
- if ($project['utime'] > 0)
- {
- $project['uhours'] = ($project['utime']/60);
- }
- else
- {
- $project['uhours'] = 0;
- }
-
- if ($pro['edate'] == 0)
- {
- $project['edate_formatted'] = ' ';
- }
- else
- {
- $project['edate'] = $pro['edate'] + (60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'];
- $project['edate_formatted'] =
$GLOBALS['phpgw']->common->show_date($pro['edate'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
-
- $project['sdate'] = $pro['sdate'] + (60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'];
- $project['sdate_formatted'] =
$GLOBALS['phpgw']->common->show_date($pro['sdate'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-
- $project['udate'] = $pro['udate'] + (60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'];
- $project['udate_formatted'] =
$GLOBALS['phpgw']->common->show_date($pro['udate'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-
- $project['cdate'] = $pro['cdate'] + (60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'];
- $project['cdate_formatted'] =
$GLOBALS['phpgw']->common->show_date($pro['cdate'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
-
- return $project;
- }
-
- function sum_budget($action = 'budget')
- {
- return $this->so->sum_budget($action);
- }
-
- function read_single_activity($activity_id)
- {
- $single_act =
$this->so->read_single_activity($activity_id);
- return $single_act;
- }
-
- function exists($action, $check, $num, $pa_id)
- {
- $exists = $this->so->exists($action, $check , $num,
$pa_id);
- if ($exists)
- {
- return True;
- }
- else
- {
- return False;
- }
- }
-
- function list_activities($start, $limit, $query, $sort, $order,
$cat_id)
- {
- $act_list = $this->so->read_activities($start, $limit,
$query, $sort, $order, $cat_id);
- $this->total_records = $this->so->total_records;
- return $act_list;
- }
-
- function activities_list($project_id, $billable)
- {
- $activities_list =
$this->so->activities_list($project_id, $billable);
- return $activities_list;
- }
-
- function select_activities_list($project_id, $billable)
- {
- $activities_list =
$this->so->select_activities_list($project_id, $billable);
- return $activities_list;
- }
-
- function select_pro_activities($project_id, $pro_parent,
$billable)
- {
- $activities_list =
$this->so->select_pro_activities($project_id, $pro_parent, $billable);
- return $activities_list;
- }
-
- function select_hours_activities($project_id, $act)
- {
- $activities_list =
$this->so->select_hours_activities($project_id, $act);
- return $activities_list;
- }
-
- function check_values($action, $values, $book_activities,
$bill_activities)
- {
- if (strlen($values['descr']) >= 8000)
- {
- $error[] = lang('Description can not exceed
8000 characters in length !');
- }
-
- if (!$values['coordinator'])
- {
- $error[] = lang('please choose a project
coordinator');
- }
-
- if (strlen($values['title']) >= 255)
- {
- $error[] = lang('title can not exceed 255
characters in length');
- }
-
- if (!$values['choose'])
- {
- if (! $values['number'])
- {
- $error[] = lang('Please enter an ID !');
- }
- else
- {
- $exists = $this->exists($action,
'number', $values['number'], $values['project_id']);
-
- if ($exists)
- {
- $error[] = lang('That ID has
been used already !');
- }
-
- if (strlen($values['number']) > 25)
- {
- $error[] = lang('id can not
exceed 25 characters in length');
- }
- }
- }
-
- if ((! $book_activities) && (! $bill_activities))
- {
- $error[] = lang('please choose activities for
the project');
- }
-
- if ($values['smonth'] || $values['sday'] ||
$values['syear'])
- {
- if (!
checkdate($values['smonth'],$values['sday'],$values['syear']))
- {
- $error[] = lang('You have entered an
invalid start date !');
- }
- }
-
- if ($values['emonth'] || $values['eday'] ||
$values['eyear'])
- {
- if (!
checkdate($values['emonth'],$values['eday'],$values['eyear']))
- {
- $error[] = lang('You have entered an
invalid end date !');
- }
- }
-
- if ($values['previous'])
- {
- $edate =
$this->return_value('edate',$values['previous']);
-
- if (intval($edate) == 0)
- {
- $error[] = lang('the choosen previous
project does not have an end date specified');
- }
- }
-
- if ($action == 'mains')
- {
- if ((!$values['budget'] || $values['budget'] ==
0) && $values['pcosts'] > 0)
- {
- $error[] = lang('please specify the
budget');
- }
-
- if (($values['budget'] && $values['budget'] >
0) && ($values['pcosts'] && $values['pcosts'] > 0))
- {
- if ($values['pcosts'] >
$values['budget'])
- {
- $error[] = lang('pcosts can not
be higher than the budget');
- }
- }
- }
-
- if ($action == 'subs')
- {
- $main_edate =
$this->return_value('edate',$values['parent']);
-
- if ($main_edate != 0)
- {
- $checkdate =
mktime(0,0,0,$values['emonth'],$values['eday'],$values['eyear']);
-
- if ($checkdate > $main_edate)
- {
- $error[] = lang('ending date
can not be after main projects ending date');
- }
- }
-
- $main_sdate =
$this->return_value('sdate',$values['parent']);
-
- if ($main_sdate != 0)
- {
- $checkdate =
mktime(0,0,0,$values['smonth'],$values['sday'],$values['syear']);
-
- if ($checkdate < $main_sdate)
- {
- $error[] = lang('start date can
not be before main projects start date');
- }
- }
-
- $ptime_parent =
$this->so->return_value('ptime',$values['parent']);
- $sum_ptime =
$this->so->get_planned_value(array('action' => 'tparent','parent_id' =>
$values['parent']
-
,'project_id' =>
$values['project_id']));
- $pminutes = intval($values['ptime'])*60;
-
- if (($pminutes+$sum_ptime) > $ptime_parent)
- {
- $error[] = lang('planned time sum of
all sub projects is bigger than the planned time of the main project');
- }
-
- $budget_parent =
$this->so->return_value('budget',$values['parent']);
- $sum_budget =
$this->so->get_planned_value(array('action' => 'bparent','parent_id' =>
$values['parent']
-
,'project_id' =>
$values['project_id']));
- if (($values['budget']+$sum_budget) >
$budget_parent)
- {
- $error[] = lang('budget sum of all sub
projects is bigger than the budget of the main project');
- }
- }
-
- if (is_array($error))
- {
- return $error;
- //_debug_array($error);
- }
- }
-
- function check_pa_values($values)
- {
- if (strlen($values['descr']) >= 255)
- {
- $error[] = lang('Description can not exceed 255
characters in length !');
- }
-
- if (! $values['choose'])
- {
- if (! $values['number'])
- {
- $error[] = lang('Please enter an ID !');
- }
- else
- {
- $exists = $this->exists('act',
'number', $values['number'], $values['activity_id']);
-
- if ($exists)
- {
- $error[] = lang('That ID has
been used already !');
- }
-
- if (strlen($values['number']) >= 20)
- {
- $error[] = lang('id can not
exceed 19 characters in length');
- }
- }
- }
-
- if ((! $values['billperae']) || ($values['billperae']
== 0))
- {
- $error[] = lang('please enter the bill');
- }
-
- if
($GLOBALS['phpgw_info']['user']['preferences']['projects']['bill'] == 'wu')
- {
- if ((! $values['minperae']) ||
($values['minperae'] == 0))
- {
- $error[] = lang('please enter the
minutes per workunit');
- }
- }
-
- if (is_array($error))
- {
- return $error;
- }
- }
-
- function save_project($action, $values, $book_activities,
$bill_activities)
- {
- if ($values['choose'])
- {
- if ($action == 'mains')
- {
- $values['number'] =
$this->so->create_projectid();
- }
- else
- {
- $values['number'] =
$this->so->create_jobid($values['parent']);
- }
- }
-
- /*if ($values['access'])
- {
- $values['access'] = 'private';
- }
- else
- {
- $values['access'] = 'public';
- }*/
-
- $month = $this->return_date();
- $values['monthdate'] = $month['monthdate'];
-
- $values['ptime'] = intval($values['ptime'])*60;
-
- if ($values['smonth'] || $values['sday'] ||
$values['syear'])
- {
- $values['sdate'] =
mktime(0,0,0,$values['smonth'], $values['sday'], $values['syear']);
- }
-
- if (!$values['sdate'])
- {
- $values['sdate'] = time();
- }
-
- if ($values['emonth'] || $values['eday'] ||
$values['eyear'])
- {
- $values['edate'] =
mktime(0,0,0,$values['emonth'],$values['eday'],$values['eyear']);
- }
-
- if (!$values['previous'] && $values['parent'])
- {
- $values['previous'] =
$this->return_value('previous',$values['parent']);
- }
-
- if (intval($values['project_id']) > 0)
- {
- $this->so->edit_project($values,
$book_activities, $bill_activities);
-
- if(is_array($values['employees']))
- {
- $this->send_alarm($values,'pro');
- }
- }
- else
- {
- $values['project_id'] =
$this->so->add_project($values, $book_activities, $bill_activities);
-
- if(is_array($values['employees']))
- {
- $this->send_alarm($values);
- }
- }
-
- $values['project_id'] = intval($values['project_id']);
-
- if (is_array($values['employees']))
- {
- $this->so->delete_acl($values['project_id']);
- for($i=0;$i<count($values['employees']);$i++)
- {
-
$GLOBALS['phpgw']->acl->add_repository('projects',$values['project_id'],$values['employees'][$i],7);
- }
- }
- return $values['project_id'];
- }
-
- function save_activity($values)
- {
- if ($values['choose'])
- {
- $values['number'] =
$this->so->create_activityid();
- }
-
- if ($values['activity_id'])
- {
- if ($values['activity_id'] &&
intval($values['activity_id']) > 0)
- {
- $this->so->edit_activity($values);
-
- if ($values['minperae'])
- {
- $this->soprojecthours =
CreateObject('projects.soprojecthours');
-
$this->soprojecthours->update_hours_act($values['activity_id'],$values['minperae']);
- }
- }
- }
- else
- {
- $this->so->add_activity($values);
- }
- }
-
- function select_project_list($values)
- {
- return $this->so->select_project_list($values);
- }
-
- function delete_pa($action, $pa_id, $subs)
- {
- if ($action == 'account')
- {
- $this->so->delete_account_project_data($pa_id);
- }
- else
- {
- $this->so->delete_pa($action, $pa_id, $subs);
- }
- }
-
- function change_owner($old, $new)
- {
- $this->so->change_owner($old, $new);
- }
-
- function get_mstones($project_id)
- {
- $mstones = $this->so->get_mstones($project_id);
-
- while (is_array($mstones) && list(,$ms) =
each($mstones))
- {
- $stones[] = array
- (
- 'title' =>
$GLOBALS['phpgw']->strip_html($ms['title']),
- 'edate' => $ms['edate'],
- 's_id' => $ms['s_id']
- );
- }
- return $stones;
- }
-
- function get_single_mstone($s_id)
- {
- return $this->so->get_single_mstone($s_id);
- }
-
- function save_mstone($values)
- {
- $values['edate'] =
mktime(0,0,0,$values['emonth'],$values['eday'],$values['eyear']);
-
- if (isset($values['old_edate']) &&
intval($values['old_edate']) > 0)
- {
- if ($values['old_edate'] != $values['edate'])
- {
- $values['edateformatted'] =
$this->formatted_edate($values['edate'],False);
- $values['pro_title'] =
$this->return_value('pro',$values['project_id']);
- $values['employees'] =
$this->get_acl_for_project($values['project_id']);
-
- $this->send_alarm($values,'mstone');
-
- unset($values['edateformatted']);
- unset($values['pro_title']);
- unset($values['employees']);
- }
- }
-
- if (intval($values['s_id']) > 0)
- {
- $this->so->edit_mstone($values);
- }
- else
- {
- return $this->so->add_mstone($values);
- }
- }
-
- function delete_mstone($s_id)
- {
- $this->so->delete_mstone($s_id);
- }
-
- function formatted_edate($edate = '',$colored = True)
- {
- $edate = intval($edate);
-
- $month =
$GLOBALS['phpgw']->common->show_date(time(),'n');
- $day =
$GLOBALS['phpgw']->common->show_date(time(),'d');
- $year =
$GLOBALS['phpgw']->common->show_date(time(),'Y');
-
- if ($edate > 0)
- {
- $edate = $edate + (60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'];
- $edateout =
$GLOBALS['phpgw']->common->show_date($edate,$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
- }
-
- if($colored)
- {
- if (mktime(2,0,0,$month,$day,$year) == $edate)
- {
- $edateout = '<b>' . $edateout . '</b>';
- }
- if (mktime(2,0,0,$month,$day,$year) >= $edate)
- {
- $edateout = '<font color="CC0000"><b>'
. $edateout . '</b></font>';
- }
- }
- return $edateout;
- }
-
- function member($project_id = '')
- {
- return $this->so->member($project_id);
- }
-
- function send_alarm($values,$type = 'assign')
- {
- $GLOBALS['phpgw_info']['user']['preferences'] =
$GLOBALS['phpgw']->preferences->create_email_preferences();
- $sender =
$GLOBALS['phpgw_info']['user']['preferences']['email']['address'];
- //$msgtype = '"projects";';
-
- switch($type)
- {
- case 'assign':
- $subject = lang('assignment to project
%1',$values['title']);
- $msg = lang('assignment to project
%1',$values['title']);
- break;
- case 'update':
- $subject = lang('project %1 has been
updated',$values['title']);
- $msg = lang('project %1 has been
updated',$values['title']);
- break;
- case 'mstone':
- $action = lang('date due of milestone
%1 of project %2 has been updated', $values['title'],$values['pro_title']);
- $msg = lang('new date due of milestone
%1: %2', $values['title'], $values['edateformatted']);
- break;
- }
-
- if(!is_object($GLOBALS['phpgw']->send))
- {
- $GLOBALS['phpgw']->send =
CreateObject('phpgwapi.send');
- }
-
- for($i=0;$i<count($values['employees']);$i++)
- {
- //$GLOBALS['phpgw']->preferences->account_id =
$values['employees'][$i];
-
//$GLOBALS['phpgw']->preferences->read_repository();
-
- $prefs =
CreateObject('phpgwapi.preferences',$values['employees'][$i]);
- $prefs->read_repository();
-
- switch($type)
- {
- case 'assign':
- if
($prefs['projects']['notify_assign'] == 'yes')
- {
- $to_notify = True;
- }
- break;
- case 'pro':
-
if($prefs['projects']['notify_pro'] == 'yes')
- {
- $to_notify = True;
- }
- break;
- case 'mstone':
-
if($prefs['projects']['notify_mstone'] == 'yes')
- {
- $to_notify = True;
- }
- break;
- }
-
- if($to_notify)
- {
- /*print_debug('Msg Type',$msg_type);
- print_debug('UserID',$userid);
-
-
$GLOBALS['phpgw']->accounts->get_account_name($userid,$lid,$details['to-firstname'],$details['to-lastname']);
- $details['to-fullname'] =
$GLOBALS['phpgw']->common->display_fullname('',$details['to-firstname'],$details['to-lastname']);*/
-
- $to =
$prefs->email_address($values['employees'][$i]);
- /*if (empty($to) || $to[0] == '@' ||
$to[0] == '$') // we have no valid email-address
- {
- //echo
"<p>boprojects::send_update: Empty email adress for user
'".$details['to-fullname']."' ==> ignored !!!</p>\n";
- continue;
- }
- print_debug('Email being sent
to',$to);*/
-
- $subject =
$GLOBALS['phpgw']->send->encode_subject($subject);
-
- $returncode =
$GLOBALS['phpgw']->send->msg('email',$to,$subject,$msg,''/*$msgtype*/,'','','',$sender);
- //echo "<p>send(to='$to',
sender='$sender'<br>subject='$subject')
returncode=$returncode<br>".nl2br($body)."</p>\n";
-
- if (!$returncode) // not nice,
but better than failing silently
- {
- echo
'<p><b>boprojects::send_alarm</b>: '.lang("Failed sending message to '%1' #%2
subject='%3', sender='%4'
!!!",$to,$values['employees'][$i],htmlspecialchars($subject), $sender)."<br>\n";
- echo
'<i>'.$GLOBALS['phpgw']->send->err['desc']."</i><br>\n";
- echo lang('This is mostly
caused by a not or wrongly configured SMTP server. Notify your
administrator.')."</p>\n";
- echo '<p>'.lang('Click %1here%2
to return to projects.','<a
href="'.$GLOBALS['phpgw']->link('/projects/').'">','</a>')."</p>\n";
- }
- }
- //unset($prefs);
- }
- return $returncode;
- }
-
function get_site_config()
{
- $this->config =
CreateObject('phpgwapi.config','projects');
+ $this->config =
CreateObject('phpgwapi.config','bookkeeping');
$this->config->read_repository();
if ($this->config->config_data)
====================================================
Index: bookkeeping/inc/class.sobilling.inc.php
diff -u bookkeeping/inc/class.sobilling.inc.php:1.1
bookkeeping/inc/class.sobilling.inc.php:1.2
--- bookkeeping/inc/class.sobilling.inc.php:1.1 Mon Dec 1 16:31:33 2003
+++ bookkeeping/inc/class.sobilling.inc.php Tue Dec 23 16:34:45 2003
@@ -33,9 +33,10 @@
function sobilling()
{
- $this->db = $GLOBALS['phpgw']->db;
- $this->db2 = $this->db;
- $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->db = $GLOBALS['phpgw']->db;
+ $this->db2 = $this->db;
+ $this->account =
$GLOBALS['phpgw_info']['user']['account_id'];
+ $this->soprojects =
CreateObject('projects.soprojects');
}
function return_join()
@@ -50,6 +51,32 @@
return $join;
}
+ function parent_search($values)
+ {
+ $project_id = intval($values['project_id']);
+ $action =
isset($values['action'])?$values['action']:'mains';
+ $table =
isset($values['table'])?$values['table']:'hours';
+
+ switch($action)
+ {
+ case 'mains': $type = 'mainandsubs'; break;
+ case 'subs': $type = 'subs'; break;
+ }
+ $pro_array =
$this->soprojects->read_projects(array('type' => $type,'limit' => False,'main'
=> $project_id,'parent' => $project_id,'column' => 'id', 'status' =>
$values['status']));
+
+ if(is_array($pro_array))
+ {
+ switch($table)
+ {
+ case 'billarray': $parent_search
= $pro_array; break;
+ case 'bill': $parent_search = ' OR
phpgw_p_invoice.project_id in(' . implode(',',$pro_array) . ')'; break;
+ default: $parent_search
= ' OR phpgw_p_hours.project_id in(' . implode(',',$pro_array) . ')'; break;
+ }
+ return $parent_search;
+ }
+ return False;
+ }
+
function read_invoices($values)
{
$project_id = intval($values['project_id']);
@@ -79,11 +106,14 @@
$acl_select = ' AND phpgw_p_invoice.owner=' .
$this->account;
}
- if ($project_id)
+ if ($project_id > 0)
{
+ $parent_search =
$this->parent_search(array('project_id' => $project_id,'action' => $action,
'status' => $status,'table' => 'bill'));
+
$sql = 'SELECT phpgw_p_invoice.id as
id,i_number,i_date,phpgw_p_invoice.project_id,phpgw_p_invoice.customer,i_sum,title
'
. 'FROM
phpgw_p_invoice,phpgw_p_projects WHERE
phpgw_p_invoice.project_id=phpgw_p_projects.id '
- . 'AND phpgw_p_projects.id=' .
$project_id . ' AND phpgw_p_invoice.project_id=' . $project_id;
+ //. 'AND phpgw_p_projects.id=' .
$project_id . ' AND phpgw_p_invoice.project_id=' . $project_id;
+ . 'AND (phpgw_p_invoice.project_id=' .
$project_id . $parent_search . ')';
}
else
{
@@ -220,15 +250,18 @@
$this->db2->query('UPDATE phpgw_p_invoice SET
i_sum=round(' . $sum_sum . ',2) WHERE id=' .
$values['invoice_id'],__LINE__,__FILE__);
}
- function read_hours($project_id, $action)
+ function read_hours($project_id, $action, $status)
{
$project_id = intval($project_id);
$ordermethod = ' order by end_date asc';
- if ($action == 'mains')
+ $pro_array = $this->parent_search(array('project_id' =>
$project_id,'action' => $action,'status' => $status,'table' => 'billarray'));
+
+ if(is_array($pro_array))
{
- $parent_hours = ' OR
phpgw_p_hours.pro_parent=' . $project_id;
+ $iparent_search = ' OR
phpgw_p_invoice.project_id in(' . implode(',',$pro_array) . ')';
+ $aparent_search = ' OR
phpgw_p_projectactivities.project_id in(' . implode(',',$pro_array) . ')';
}
$this->db->query('SELECT phpgw_p_hours.id as
id,phpgw_p_hours.hours_descr,phpgw_p_activities.descr,phpgw_p_hours.status,'
@@ -236,9 +269,10 @@
. 'phpgw_p_hours.employee FROM
phpgw_p_hours ' . $this->return_join() . ' phpgw_p_activities ON '
.
'phpgw_p_hours.activity_id=phpgw_p_activities.id ' . $this->return_join() . '
phpgw_p_projectactivities ON '
.
"phpgw_p_hours.activity_id=phpgw_p_projectactivities.activity_id WHERE
(phpgw_p_hours.status='done' OR "
- .
"phpgw_p_hours.status='closed') AND (phpgw_p_hours.project_id=" . $project_id .
$parent_hours . ') AND '
- .
'phpgw_p_projectactivities.project_id=' . $project_id . " AND
phpgw_p_projectactivities.billable='Y' "
- . 'AND
phpgw_p_projectactivities.activity_id=phpgw_p_hours.activity_id' .
$ordermethod,__LINE__,__FILE__);
+ .
"phpgw_p_hours.status='closed') AND (phpgw_p_hours.project_id=" . $project_id .
$iparent_search . ') AND '
+ .
'(phpgw_p_projectactivities.project_id=' . $project_id . $aparent_search
+ . ") AND
phpgw_p_projectactivities.billable='Y' AND
phpgw_p_projectactivities.activity_id=phpgw_p_hours.activity_id"
+ .
$ordermethod,__LINE__,__FILE__);
while ($this->db->next_record())
{
@@ -259,16 +293,13 @@
return $hours;
}
- function read_invoice_hours($project_id, $invoice_id, $action)
+ function read_invoice_hours($project_id, $invoice_id, $action,
$status)
{
$project_id = intval($project_id);
$ordermethod = ' order by end_date asc';
- if ($action == 'mains' || $action == 'amains')
- {
- $parent_search = ' OR
phpgw_p_hours.pro_parent=' . $project_id;
- }
+ $parent_search =
$this->parent_search(array('project_id' => $project_id,'action' => $action,
'status' => $status));
$this->db->query('SELECT phpgw_p_hours.id as
id,phpgw_p_hours.hours_descr,phpgw_p_activities.descr,phpgw_p_hours.status,'
.
'phpgw_p_hours.start_date,phpgw_p_hours.end_date,phpgw_p_hours.minutes,phpgw_p_hours.minperae,phpgw_p_hours.billperae
FROM '
====================================================
Index: bookkeeping/inc/class.bobilling.inc.php
diff -u bookkeeping/inc/class.bobilling.inc.php:1.1
bookkeeping/inc/class.bobilling.inc.php:1.2
--- bookkeeping/inc/class.bobilling.inc.php:1.1 Mon Dec 1 16:31:33 2003
+++ bookkeeping/inc/class.bobilling.inc.php Tue Dec 23 16:34:45 2003
@@ -1,10 +1,10 @@
<?php
/*******************************************************************\
- * phpGroupWare - Projects *
+ * phpGroupWare - Bookkeeping *
* http://www.phpgroupware.org *
* This program is part of the GNU project, see http://www.gnu.org/
*
* *
- * Project Manager *
+ * Accounting application for the Project Manager *
* Written by Bettina Gille address@hidden *
* ----------------------------------------------- *
* Copyright 2000 - 2003 Free Software Foundation, Inc *
@@ -42,20 +42,17 @@
function bobilling()
{
- $this->sobilling =
CreateObject('projects.sobilling');
- $this->soprojects =
CreateObject('projects.soprojects');
- $this->contacts =
CreateObject('phpgwapi.contacts');
- $this->boprojects =
CreateObject('projects.boprojects');
- }
+ $action = get_var('action',array('POST','GET'));
- function get_site_config()
- {
- return $this->boprojects->get_site_config();
+ $this->bobookkeeping =
CreateObject('bookkeeping.bobookkeeping',True,$action);
+ $this->sobilling =
CreateObject('bookkeeping.sobilling');
+ $this->soprojects =
$this->sobilling->soprojects;
+ $this->boprojects =
CreateObject('projects.boprojects');
}
function read_invoices($start, $query, $sort, $order, $limit,
$project_id)
{
- $co = $this->get_site_config();
+ $co = $this->bobookkeeping->get_site_config();
$bill = $this->sobilling->read_invoices(array('start'
=> $start,'query' => $query, 'sort' => $sort,'order' => $order,'limit' =>
$limit,
'project_id' => $project_id,'owner' =>
$co['invoice_acl']));
@@ -75,31 +72,31 @@
{
if (!$values['invoice_num'])
{
- $error[] = lang('Please enter an ID !');
+ $error[] = lang('Please enter an ID');
}
else
{
$num =
$this->sobilling->exists($values);
if ($num)
{
- $error[] = lang('That ID has
been used already !');
+ $error[] = lang('That ID has
been used already');
}
}
}
if (! is_array($select))
{
- $error[] = lang('The invoice contains no items
!');
+ $error[] = lang('The invoice contains no
items');
}
if (! $values['customer'])
{
- $error[] = lang('You have no customer selected
!');
+ $error[] = lang('You have no customer
selected');
}
if (!
checkdate($values['month'],$values['day'],$values['year']))
{
- $error[] = lang('You have entered an invalid
date !');
+ $error[] = lang('You have entered an invalid
date');
}
if (is_array($error))
@@ -128,15 +125,15 @@
$this->sobilling->update_invoice($values,$select);
}
- function read_hours($project_id, $action)
+ function read_hours($project_id, $action, $status)
{
- $hours = $this->sobilling->read_hours($project_id,
$action);
+ $hours = $this->sobilling->read_hours($project_id,
$action, $status);
return $hours;
}
- function read_invoice_hours($project_id, $invoice_id, $action)
+ function read_invoice_hours($project_id, $invoice_id, $action,
$status)
{
- $hours =
$this->sobilling->read_invoice_hours($project_id, $invoice_id, $action);
+ $hours =
$this->sobilling->read_invoice_hours($project_id, $invoice_id, $action,
$status);
return $hours;
}
- [Phpgroupware-cvs] bookkeeping/inc class.uibilling.inc.php, 1.3 class.uibookkeeping.inc.php, 1.3 class.sodeliveries.inc.php, 1.2 class.bodeliveries.inc.php, 1.2 class.uideliveries.inc.php, 1.3 class.bobookkeeping.inc.php, 1.3 class.sobilling.inc.php, 1.2 class.bobilling.inc.php, 1.2,
uid65887 <=
- [Phpgroupware-cvs] bookkeeping/inc class.uibilling.inc.php, 1.3 class.uibookkeeping.inc.php, 1.3 class.sodeliveries.inc.php, 1.2 class.bodeliveries.inc.php, 1.2 class.uideliveries.inc.php, 1.3 class.bobookkeeping.inc.php, 1.3 class.sobilling.inc.php, 1.2 class.bobilling.inc.php, 1.2, uid65887, 2005/04/27
- [Phpgroupware-cvs] bookkeeping/inc class.uibilling.inc.php, 1.3 class.uibookkeeping.inc.php, 1.3 class.sodeliveries.inc.php, 1.2 class.bodeliveries.inc.php, 1.2 class.uideliveries.inc.php, 1.3 class.bobookkeeping.inc.php, 1.3 class.sobilling.inc.php, 1.2 class.bobilling.inc.php, 1.2, uid65887, 2005/04/27
- [Phpgroupware-cvs] bookkeeping/inc class.uibilling.inc.php, 1.3 class.uibookkeeping.inc.php, 1.3 class.sodeliveries.inc.php, 1.2 class.bodeliveries.inc.php, 1.2 class.uideliveries.inc.php, 1.3 class.bobookkeeping.inc.php, 1.3 class.sobilling.inc.php, 1.2 class.bobilling.inc.php, 1.2, uid65887, 2005/04/27
- Prev by Date:
[Phpgroupware-cvs] phpgwapi/templates/idots/css idots.css,1.1.2.3
- Next by Date:
[Phpgroupware-cvs] phpgwapi/inc class.common.inc.php, 1.123.2.9.2.19
- Previous by thread:
[Phpgroupware-cvs] phpgwapi/templates/idots/css idots.css,1.1.2.3
- Next by thread:
[Phpgroupware-cvs] bookkeeping/inc class.uibilling.inc.php, 1.3 class.uibookkeeping.inc.php, 1.3 class.sodeliveries.inc.php, 1.2 class.bodeliveries.inc.php, 1.2 class.uideliveries.inc.php, 1.3 class.bobookkeeping.inc.php, 1.3 class.sobilling.inc.php, 1.2 class.bobilling.inc.php, 1.2
- Index(es):