[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] tts admin.php index.php newticket.php viewticke...
From: |
Dave Hall |
Subject: |
[Phpgroupware-cvs] tts admin.php index.php newticket.php viewticke... |
Date: |
Sat, 14 Oct 2006 05:39:42 +0000 |
CVSROOT: /cvsroot/phpgroupware
Module name: tts
Changes by: Dave Hall <skwashd> 06/10/14 05:39:42
Modified files:
. : admin.php index.php newticket.php
viewticket_details.php
inc : class.attachedFiles.inc.php
class.ipc_tts.inc.php hook_admin.inc.php
setup : default_records.inc.php setup.inc.php
tables_baseline.inc.php tables_current.inc.php
tables_update.inc.php
templates/base : index.tpl newticket.tpl
Added files:
. : mailpipe.php
inc : class.botts.inc.php class.tts_bo_hooks.inc.php
class.uitts.inc.php
js/base : addticket.js field_selector.js index.js view.js
Removed files:
. : test.php
inc : class.bo.inc.php
templates/base : viewticket_details.tpl
templates/base/images: navbar.gif updated.gif
Log message:
no tts, this is still a bit rough, but I want to get it into cvs now :)
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/tts/admin.php?cvsroot=phpgroupware&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/tts/index.php?cvsroot=phpgroupware&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/tts/newticket.php?cvsroot=phpgroupware&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/tts/viewticket_details.php?cvsroot=phpgroupware&r1=1.48&r2=1.49
http://cvs.savannah.gnu.org/viewcvs/tts/mailpipe.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/tts/test.php?cvsroot=phpgroupware&r1=1.3&r2=0
http://cvs.savannah.gnu.org/viewcvs/tts/inc/class.attachedFiles.inc.php?cvsroot=phpgroupware&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/tts/inc/class.ipc_tts.inc.php?cvsroot=phpgroupware&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/tts/inc/hook_admin.inc.php?cvsroot=phpgroupware&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/tts/inc/class.botts.inc.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/tts/inc/class.tts_bo_hooks.inc.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/tts/inc/class.uitts.inc.php?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/tts/inc/class.bo.inc.php?cvsroot=phpgroupware&r1=1.8&r2=0
http://cvs.savannah.gnu.org/viewcvs/tts/js/base/addticket.js?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/tts/js/base/field_selector.js?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/tts/js/base/index.js?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/tts/js/base/view.js?cvsroot=phpgroupware&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/tts/setup/default_records.inc.php?cvsroot=phpgroupware&only_with_tag=Version-0_9_16-branch&r1=1.1.2.3&r2=1.1.2.4
http://cvs.savannah.gnu.org/viewcvs/tts/setup/setup.inc.php?cvsroot=phpgroupware&only_with_tag=Version-0_9_16-branch&r1=1.6.4.2&r2=1.6.4.3
http://cvs.savannah.gnu.org/viewcvs/tts/setup/tables_baseline.inc.php?cvsroot=phpgroupware&only_with_tag=Version-0_9_16-branch&r1=1.1&r2=1.1.4.1
http://cvs.savannah.gnu.org/viewcvs/tts/setup/tables_current.inc.php?cvsroot=phpgroupware&only_with_tag=Version-0_9_16-branch&r1=1.6.4.1&r2=1.6.4.2
http://cvs.savannah.gnu.org/viewcvs/tts/setup/tables_update.inc.php?cvsroot=phpgroupware&only_with_tag=Version-0_9_16-branch&r1=1.1.2.2&r2=1.1.2.3
http://cvs.savannah.gnu.org/viewcvs/tts/templates/base/index.tpl?cvsroot=phpgroupware&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/tts/templates/base/newticket.tpl?cvsroot=phpgroupware&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/tts/templates/base/viewticket_details.tpl?cvsroot=phpgroupware&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/tts/templates/base/images/navbar.gif?cvsroot=phpgroupware&rev=0
http://cvs.savannah.gnu.org/viewcvs/tts/templates/base/images/updated.gif?cvsroot=phpgroupware&rev=0
Patches:
Index: admin.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/admin.php,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- admin.php 10 May 2005 16:12:38 -0000 1.4
+++ admin.php 14 Oct 2006 05:39:41 -0000 1.5
@@ -5,7 +5,7 @@
* @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc.
http://www.fsf.org/
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
* @package tts
- * @version $Id: admin.php,v 1.4 2005/05/10 16:12:38 powerstat Exp $
+ * @version $Id: admin.php,v 1.5 2006/10/14 05:39:41 skwashd Exp $
*/
@@ -77,6 +77,7 @@
$GLOBALS['phpgw']->common->phpgw_header();
echo parse_navbar();
+ $GLOBALS['phpgw']->template->set_root(PHPGW_APP_TPL);
$GLOBALS['phpgw']->template->set_file(array('admin' => 'admin.tpl'));
$GLOBALS['phpgw']->template->set_block('admin',
'tts_select_options','tts_select_options');
Index: index.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/index.php,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- index.php 10 May 2005 16:12:38 -0000 1.53
+++ index.php 14 Oct 2006 05:39:41 -0000 1.54
@@ -5,7 +5,7 @@
* @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc.
http://www.fsf.org/
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
* @package tts
- * @version $Id: index.php,v 1.53 2005/05/10 16:12:38 powerstat Exp $
+ * @version $Id: index.php,v 1.54 2006/10/14 05:39:41 skwashd Exp $
*/
/* Note to self:
@@ -15,377 +15,16 @@
** from phpgw_tts_tickets, phpgw_tts_groups where ticket_id =
group_ticket_id and group_id in (14,15);
*/
- /* ACL levels
- ** 1 - Read ticket within your group only
- ** 2 - Close ticket
- ** 4 - Allow to make changes to priority, billing hours, billing rate,
category, and assigned to
- */
-
- $GLOBALS['phpgw_info']['flags']['currentapp'] = 'tts';
- $GLOBALS['phpgw_info']['flags']['enable_contacts_class'] = True;
- $GLOBALS['phpgw_info']['flags']['enable_categories_class'] = True;
- $GLOBALS['phpgw_info']['flags']['enable_nextmatchs_class'] = True;
+ $GLOBALS['phpgw_info']['flags'] = array
+ (
+ 'currentapp' => 'tts',
+ 'noheader' => true
+ );
/**
* Include phpgroupware header
*/
include('../header.inc.php');
- $GLOBALS['phpgw']->historylog =
createobject('phpgwapi.historylog','tts');
-
- $GLOBALS['phpgw']->template->set_file('index','index.tpl');
- $GLOBALS['phpgw']->template->set_block('index', 'tts_title',
'tts_title');
-// $GLOBALS['phpgw']->template->set_block('index', 'tts_links',
'tts_links');
- $GLOBALS['phpgw']->template->set_block('index', 'tts_search',
'tts_search');
- $GLOBALS['phpgw']->template->set_block('index', 'tts_list', 'tts_list');
- $GLOBALS['phpgw']->template->set_block('index', 'tts_row', 'tts_row');
- $GLOBALS['phpgw']->template->set_block('index', 'tts_col_ifviewall',
'tts_col_ifviewall');
- $GLOBALS['phpgw']->template->set_block('index', 'tts_ticket_id_read',
'tts_ticket_id_read');
- $GLOBALS['phpgw']->template->set_block('index', 'tts_ticket_id_unread',
'tts_ticket_id_unread');
-
- $GLOBALS['phpgw']->template->set_var('lang_appname', lang('Trouble
Ticket System'));
- $GLOBALS['phpgw']->template->set_var('tts_newticket_link',
$GLOBALS['phpgw']->link('/tts/newticket.php'));
- $GLOBALS['phpgw']->template->set_var('tts_search_link',
$GLOBALS['phpgw']->link('/tts/index.php'));
- $GLOBALS['phpgw']->template->set_var('tts_prefs_link',
$GLOBALS['phpgw']->link('/preferences/preferences.php','appname=tts'));
- $GLOBALS['phpgw']->template->set_var('lang_preferences',
lang('Preferences'));
- $GLOBALS['phpgw']->template->set_var('lang_search', lang('search'));
- $GLOBALS['phpgw']->template->set_var('tts_newticket', lang('New
ticket'));
- $GLOBALS['phpgw']->template->set_var('tts_notickets','');
- $GLOBALS['phpgw']->template->set_var('lang_category',lang('Category'));
- $GLOBALS['phpgw']->template->set_var('tts_autofilter_link',
$GLOBALS['phpgw']->link('/tts/index.php'));
- $GLOBALS['phpgw']->template->set_var('lang_filter', lang('filter'));
-
-
- // select what tickets to view
- $start = $_GET['start'];
- $sort = $GLOBALS['phpgw']->db->db_addslashes($_GET['sort']);
- $order = $GLOBALS['phpgw']->db->db_addslashes($_GET['order']);
- $_REQUEST['ticket']['filter_status'] =
!strlen($_REQUEST['ticket']['filter_status']) ? 'open' :
$_REQUEST['ticket']['filter_status'];
-
- $GLOBALS['phpgw']->preferences->read_repository();
- if
($GLOBALS['phpgw_info']['user']['preferences']['tts']['refreshinterval'])
- {
- $GLOBALS['phpgw']->template->set_var('autorefresh','<META
HTTP-EQUIV="Refresh"
CONTENT="'.$GLOBALS['phpgw_info']['user']['preferences']['tts']['refreshinterval'].';
URL='.$GLOBALS['phpgw']->link('/tts/index.php').'">');
- }
- else
- {
- $GLOBALS['phpgw']->template->set_var('autorefresh','');
- }
-
- $filterstring = '';
- if($_REQUEST['ticket']['filter_prio'] != '')
- {
- $filterstring .= 'ticket_priority LIKE
'.$GLOBALS['phpgw']->db->db_addslashes($_POST['ticket']['filter_prio']).' AND
'; //security hole
- }
-
- if($_REQUEST['ticket']['filter_owner'] != '')
- {
- $filterstring .= 'ticket_owner LIKE
"'.$GLOBALS['phpgw']->accounts->name2id($_POST['ticket']['filter_owner']).'"
AND ';
- }
-
- if($_REQUEST['ticket']['filter_assignedto'] != '')
- {
- $filterstring .= 'ticket_assignedto LIKE
"'.$GLOBALS['phpgw']->accounts->name2id($_POST['ticket']['filter_assignedto']).'"
AND ';
- }
-
- if((int) $_REQUEST['fcat_id'])
- {
- $cat_id = (int)$_REQUEST['fcat_id'];
- // not working - probably wrong order in program logic
- $_REQUEST['ticket']['filter_category'] =
$GLOBALS['phpgw']->categories->id2name($cat_id);
- }
- elseif($_REQUEST['ticket']['filter_category'])
- {
- $cat_id =
$GLOBALS['phpgw']->categories->name2id($_REQUEST['ticket']['filter_category']);
- }
-
- if((int)$cat_id)
- {
- $filterstring .= 'ticket_category = "'.$cat_id.'" AND ';
- }
-
- if($_REQUEST['ticket']['filter_status'] != 'none')
- {
- $sqlvalue = $_REQUEST['ticket']['filter_status'] == 'open' ?
'O' : 'X'; // lol, nice value for sql
- $filterstring .= "ticket_status='".$sqlvalue."' AND ";
- }
- if ($_REQUEST['searchfilter'] != '')
- {
- $filterstring .= '(ticket_details LIKE
"%'.addslashes($_REQUEST['searchfilter']).'%" OR '.
- ' ticket_subject LIKE
"%'.addslashes($_REQUEST['searchfilter']).'%") AND ';
- $GLOBALS['phpgw']->template->set_var('tts_searchfilter',
addslashes($_REQUEST['searchfilter'])); //doesn't work
- }
- $filterstring .= '1=1 ';
-
- $sortmethod = $sort ? "order by $order $sort" : 'order by
ticket_priority desc';
-
- $GLOBALS['phpgw']->db->query("select count(*) from
phpgw_tts_tickets",__LINE__,__FILE__);
- $GLOBALS['phpgw']->db->next_record();
- $numtotal = $GLOBALS['phpgw']->db->f('0') ;
-
- $GLOBALS['phpgw']->db->query("select count(*) FROM phpgw_tts_tickets
WHERE ticket_status='O'",__LINE__,__FILE__);
- $GLOBALS['phpgw']->db->next_record();
- $numopen = $GLOBALS['phpgw']->db->f('0') ;
-
- $GLOBALS['phpgw']->template->set_var('tts_numtotal',lang('Tickets total
%1',$numtotal));
- $GLOBALS['phpgw']->template->set_var('tts_numopen', lang('Tickets open
%1',$numopen));
-
- $db2 = $GLOBALS['phpgw']->db;
- $sql = 'SELECT * FROM phpgw_tts_tickets WHERE
'.$filterstring.$sortmethod;
- //echo $sql;
- $GLOBALS['phpgw']->db->query($sql,__LINE__,__FILE__);
- $numfound = $GLOBALS['phpgw']->db->num_rows();
-
-
$GLOBALS['phpgw']->template->set_var('tts_searchfilter',addslashes($_REQUEST['searchfilter']));
- $GLOBALS['phpgw']->template->set_var('tts_numfound',lang('Tickets found
%1',$numfound));
-
- $GLOBALS['phpgw']->template->set_var('tts_ticketstotal', lang('Tickets
total %1',$numtotal));
- $GLOBALS['phpgw']->template->set_var('tts_ticketsopen', lang('Tickets
open %1',$numopen));
-
- // fill header
- $GLOBALS['phpgw']->template->set_var('tts_head_bgcolor',
$GLOBALS['phpgw_info']['theme']['th_bg'] );
- $GLOBALS['phpgw']->template->set_var('th_bg',
$GLOBALS['phpgw_info']['theme']['th_bg'] );
- $GLOBALS['phpgw']->template->set_var('tts_head_ticket',
$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'ticket_id',$order,'/tts/index.php','#'));
- $GLOBALS['phpgw']->template->set_var('tts_head_prio',
$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'ticket_priority',$order,'/tts/index.php',lang('Prio')));
-
$GLOBALS['phpgw']->template->set_var('tts_head_group',$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'ticket_group',$order,'/tts/index.php',lang('Group')));
-
$GLOBALS['phpgw']->template->set_var('tts_head_category',$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'ticket_category',$order,'/tts/index.php',lang('Category')));
- $GLOBALS['phpgw']->template->set_var('tts_head_assignedto',
$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'ticket_assignedto',$order,'/tts/index.php',lang('Assigned
to')));
- $GLOBALS['phpgw']->template->set_var('tts_head_openedby',
$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'ticket_owner',$order,'/tts/index.php',lang('Opened
by')));
-
- // I am not sure how the sorting will work for this, if at all. (jengo)
- $GLOBALS['phpgw']->template->set_var('tts_head_dateopened',lang('Date
opened'));
-// $GLOBALS['phpgw']->template->set_var('tts_head_dateopened',
$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'',$order,'/tts/index.php',lang('Date
opened')));
- //if ($filter != 'viewopen' && $filter != 'search')
- {
- $GLOBALS['phpgw']->template->set_var('tts_head_dateclosed',
$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'ticket_status',$order,'/tts/index.php',lang('Status')));
- }
- $GLOBALS['phpgw']->template->set_var('tts_head_subject',
$GLOBALS['phpgw']->nextmatchs->show_sort_order($sort,'ticket_subject',$order,'/tts/index.php',lang('Subject')));
-
- // read the tickets
- $sql = 'SELECT * FROM phpgw_tts_tickets '.
- 'LEFT JOIN phpgw_tts_views ON (phpgw_tts_tickets.ticket_id =
phpgw_tts_views.view_id AND phpgw_tts_views.view_account_id =
'.$GLOBALS['phpgw_info']['user']['account_id'].') '.
- 'WHERE '.$filterstring.$sortmethod;
- //echo $sql;
- $rs = $GLOBALS['phpgw']->db->adodb->Execute($sql);
- $alltickets = $rs->GetArray();
-
- $GLOBALS['phpgw']->template->set_var('tts_numfound',lang('Tickets found
%1',count($alltickets)));
-
- if (!count($alltickets))
- {
- $GLOBALS['phpgw']->template->set_var('rows',
'<p><center>'.lang('No tickets found').'</center>');
- }
- else
- {
- for($i = 0; $i < count($alltickets); $i++)
- {
- switch ($alltickets[$i]['ticket_priority'])
- {
- case 1: $tr_color =
$GLOBALS['phpgw_info']['theme']['bg01']; $prio = '1'; break;
- case 2: $tr_color =
$GLOBALS['phpgw_info']['theme']['bg02']; $prio = '2'; break;
- case 3: $tr_color =
$GLOBALS['phpgw_info']['theme']['bg03']; $prio = '3'; break;
- case 4: $tr_color =
$GLOBALS['phpgw_info']['theme']['bg04']; $prio = '4'; break;
- case 5: $tr_color =
$GLOBALS['phpgw_info']['theme']['bg05']; $prio = '5'; break;
- case 6: $tr_color =
$GLOBALS['phpgw_info']['theme']['bg06']; $prio = '6'; break;
- case 7: $tr_color =
$GLOBALS['phpgw_info']['theme']['bg07']; $prio = '7'; break;
- case 8: $tr_color =
$GLOBALS['phpgw_info']['theme']['bg08']; $prio = '8'; break;
- case 9: $tr_color =
$GLOBALS['phpgw_info']['theme']['bg09']; $prio = '9'; break;
- case 10: $tr_color =
$GLOBALS['phpgw_info']['theme']['bg10']; $prio = '10'; break;
- default: $tr_color =
$GLOBALS['phpgw_info']['theme']['bg_color']; $prio = '-';
- }
- if ($filter != 'viewopen' &&
$alltickets[$i]['t_timestamp_closed'])
- {
- $tr_color =
$GLOBALS['phpgw_info']['theme']['th_bg']; /*"#CCCCCC";*/
- }
-
- $db2->query("select count(*) from phpgw_tts_views where
view_id='" . $GLOBALS['phpgw']->db->f('ticket_id')
- . "' and view_account_id='" .
$GLOBALS['phpgw_info']['user']['account_id'] . "'",__LINE__,__FILE__);
- $db2->next_record();
-
- if (!$alltickets[$i]['view_time'])
- {
-
$GLOBALS['phpgw']->template->set_var('row_status',' ');
- }
- else
- {
-
$GLOBALS['phpgw']->template->set_var('row_status','<img
src="'.$GLOBALS['phpgw']->common->image('tts','updated').'">');
- }
-
- $GLOBALS['phpgw']->template->set_var('row_ticket_id',
$alltickets[$i]['ticket_id']);
- $GLOBALS['phpgw']->template->set_var('ticket_link',
$GLOBALS['phpgw']->link('/tts/viewticket_details.php','ticket_id=' .
$alltickets[$i]['ticket_id']));
-
- $cat_name =
$GLOBALS['phpgw']->categories->id2name($alltickets[$i]['ticket_category']);
-
$GLOBALS['phpgw']->template->set_var('row_category',$cat_name);
-
- $group_name =
$GLOBALS['phpgw']->accounts->id2name($alltickets[$i]['ticket_group']);
- $group_name = ($group_name ? $group_name : '--');
-
$GLOBALS['phpgw']->template->set_var('row_group',$group_name);
-
-
$GLOBALS['phpgw']->template->set_var('tts_t_assignedto',
$alltickets[$i]['ticket_assignedto'] ?
$GLOBALS['phpgw']->accounts->id2name($alltickets[$i]['ticket_assignedto']) :
lang('None'));
- $GLOBALS['phpgw']->template->set_var('tts_t_user',
$GLOBALS['phpgw']->accounts->id2name($alltickets[$i]['ticket_owner']));
-
- $history_values =
$GLOBALS['phpgw']->historylog->return_array(array(),array('O'),'history_timestamp','ASC',$alltickets[$i]['ticket_id']);
-
$GLOBALS['phpgw']->template->set_var('tts_t_timestampopened',$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime']
- ((60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']),
-
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']
-
));
-
- if ($alltickets[$i]['ticket_status'] == 'X')
- {
- $history_values =
$GLOBALS['phpgw']->historylog->return_array(array(),array('X'),'history_timestamp','DESC',$alltickets[$i]['ticket_id']);
-
$GLOBALS['phpgw']->template->set_var('tts_t_timestampclosed',$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime']
- ((60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']),
-
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']
-
));
- }
- elseif ($filter != 'viewopen' && $filter != 'search')
- {
-
$GLOBALS['phpgw']->template->set_var('tts_t_timestampclosed',lang('Open'));
- }
- $GLOBALS['phpgw']->template->set_var('tts_t_subject',
htmlspecialchars(stripslashes($alltickets[$i]['ticket_subject'])));
- $GLOBALS['phpgw']->template->set_var('tts_t_prio',
$prio);
-
-
$GLOBALS['phpgw']->template->parse('rows','tts_row',True);
- }
- }
-
- // this is a workaround to clear the subblocks autogenerated vars
- $GLOBALS['phpgw']->template->set_var('tts_row','');
- $GLOBALS['phpgw']->template->set_var('tts_col_ifviewall','');
- $GLOBALS['phpgw']->template->set_var('tts_head_ifviewall','');
- $GLOBALS['phpgw']->template->set_var('tts_ticket_id_read','');
- $GLOBALS['phpgw']->template->set_var('tts_ticket_id_unread','');
-
- //Create Autofilters
- $GLOBALS['phpgw']->db->query("select count(*) from phpgw_tts_tickets");
- $GLOBALS['phpgw']->db->next_record();
- $exists = $GLOBALS['phpgw']->db->f('0');
- if ($exists != 0)
- {
- $GLOBALS['phpgw']->db->query("select distinct ticket_priority
from phpgw_tts_tickets order by ticket_priority desc");
- $y=0;
- while ($GLOBALS['phpgw']->db->next_record() != 0)
- {
- $dbvalue[$y] = $GLOBALS['phpgw']->db->f('0') ;
- ++$y;
- }
-
- unset($sel);
- for($y-=1;$y>=0;--$y)
- {
- if($dbvalue[$y] == $_POST['ticket']['filter_prio'])
- {
- $selected = " selected";
- }
- else
- {
- $selected = "";
- }
- $sel .=
'<option'.$selected.'>'.$dbvalue[$y].'</option>' ;
- }
- $GLOBALS['phpgw']->template->set_var('filter_prio','<select
name=ticket[filter_prio] onChange="document.search.submit()"><option>
</option>'.$sel.'</select>');
-
-
- $GLOBALS['phpgw']->db->query("select distinct ticket_owner from
phpgw_tts_tickets order by ticket_owner desc");
- $y=0;
- while ($GLOBALS['phpgw']->db->next_record() != 0)
- {
- $dbvalue[$y] = $GLOBALS['phpgw']->db->f('0') ;
- $db2name[$y] =
$GLOBALS['phpgw']->accounts->id2name($dbvalue[$y]);
- ++$y;
- }
-
- unset($sel);
- natsort($db2name);
- reset($db2name);
- while(list($dummy,$entry) = each($db2name))
- {
- if($entry == $_POST['ticket']['filter_owner'])
- {
- $selected = " selected";
- }
- else
- {
- $selected = "";
- }
- $sel .= '<option'.$selected.'>'.$entry.'</option>' ;
- }
- $GLOBALS['phpgw']->template->set_var('filter_owner','<select
name=ticket[filter_owner] onChange="document.search.submit()"><option>
</option>'.$sel.'</select>');
-
-
- $GLOBALS['phpgw']->db->query("select distinct ticket_assignedto
from phpgw_tts_tickets order by ticket_assignedto desc");
- $y=0;
- while ($GLOBALS['phpgw']->db->next_record() != 0)
- {
- $dbvalue[$y] = $GLOBALS['phpgw']->db->f('0') ;
- $db2name[$y] =
$GLOBALS['phpgw']->accounts->id2name($dbvalue[$y]);
- ++$y;
- }
-
- unset($sel);
- natsort($db2name);
- reset($db2name);
- while(list($dummy,$entry) = each($db2name))
- {
- if($entry == $_POST['ticket']['filter_assignedto'])
- {
- $selected = " selected";
- }
- else
- {
- $selected = "";
- }
- $sel .= '<option'.$selected.'>'.$entry.'</option>' ;
- }
-
-
$GLOBALS['phpgw']->template->set_var('filter_assignedto','<select
name=ticket[filter_assignedto] onChange="document.search.submit()"><option>
</option>'.$sel.'</select>');
-
-
- $GLOBALS['phpgw']->db->query("select distinct ticket_category
from phpgw_tts_tickets order by ticket_category");
- $y=0;
- unset($db2name);
- while ($GLOBALS['phpgw']->db->next_record() != 0)
- {
- $dbvalue[$y] = $GLOBALS['phpgw']->db->f('0');
- $db2name[$y] =
$GLOBALS['phpgw']->categories->id2name($dbvalue[$y]);
- ++$y;
- }
-
- unset($sel);
- natsort($db2name);
- reset($db2name);
- while(list($dummy,$entry) = each($db2name))
- {
- if($entry == $_POST['ticket']['filter_category'])
- {
- $selected = " selected";
- }
- else
- {
- $selected = "";
- }
- $sel .= '<option'.$selected.'>'.$entry.'</option>' ;
- }
-
- $GLOBALS['phpgw']->template->set_var('filter_category','<select
name=ticket[filter_category]
onChange="document.search.submit()"><option></option>'.$sel.'</select>');
-
- $filter_status_options = array('none' => '',
- 'open' => lang('open'),
- 'closed' => lang('closed')
- );
- unset($options);
- foreach($filter_status_options AS $key => $value)
- {
- unset($selected);
- if($_REQUEST['ticket']['filter_status'] == $key)
- {
- $selected = 'selected="seleceted"';
- }
- $options .= '<option value="'.$key.'"
'.$selected.'>'.$value.'</option>';
- }
- $GLOBALS['phpgw']->template->set_var('filter_status_options',
$options);
-
- }
-
- $GLOBALS['phpgw']->template->pfp('out','index');
-
- $GLOBALS['phpgw']->common->phpgw_footer();
+ $GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'tts.uitts.index') );
?>
Index: newticket.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/newticket.php,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- newticket.php 19 May 2005 09:54:04 -0000 1.35
+++ newticket.php 14 Oct 2006 05:39:41 -0000 1.36
@@ -1,48 +1,103 @@
-<?php
+ <?php
/**
* Trouble Ticket System
*
* @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc.
http://www.fsf.org/
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
* @package tts
- * @version $Id: newticket.php,v 1.35 2005/05/19 09:54:04 fipsfuchs Exp $
+ * @version $Id: newticket.php,v 1.36 2006/10/14 05:39:41 skwashd Exp $
*/
- $submit = $_POST['submit'];
- $cancel = $_POST['cancel'];
- if($submit || $cancel)
+ $GLOBALS['phpgw_info']['flags'] = array
+ (
+
'currentapp' => 'tts',
+
'app_section' => 'create new ticket',
+
'enable_send_class' => True,
+
'enable_config_class' => True,
+
'enable_categories_class' => True,
+
'enable_vfs_class' => True,
+
'enable_javascript' => True,
+
'enable_jscalendar_class' => True,
+
'css' => '@import url(css/base.css);',
+
'java_script' => get_js()
+ );
+
+ $submit =& $_POST['submit'];
+ $cancel =& $_POST['cancel'];
+ if ( $submit || $cancel )
{
- $GLOBALS['phpgw_info']['flags'] = array(
+ $GLOBALS['phpgw_info']['flags'] += array
+
(
'noheader' => True,
'nonavbar' => True
);
}
- $GLOBALS['phpgw_info']['flags']['currentapp'] = 'tts';
- $GLOBALS['phpgw_info']['flags']['enable_send_class'] = True;
- $GLOBALS['phpgw_info']['flags']['enable_config_class'] = True;
- $GLOBALS['phpgw_info']['flags']['enable_categories_class'] = True;
- $GLOBALS['phpgw_info']['flags']['enable_vfs_class'] = True;
/**
* Include phpgroupware header
*/
include('../header.inc.php');
- $GLOBALS['phpgw']->config->read_repository();
-
if($cancel)
{
-
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/tts/index.php'));
+ $GLOBALS['phpgw']->redirect_link('/tts/index.php');
}
+ $GLOBALS['phpgw']->config->read_repository();
+
if($submit)
{
+ $deadline =
$GLOBALS['phpgw']->jscalendar->input2date($_POST['ticket']['deadline']);
+ $sql = $GLOBALS['phpgw']->db->adodb->Prepare('INSERT INTO
phpgw_tts_tickets('
+ . ' ticket_group,'
+ . ' ticket_priority,'
+ . ' ticket_owner,'
+ . ' ticket_assignedto,'
+ . ' ticket_subject,'
+ . ' ticket_category,'
+ . ' ticket_billable_hours,'
+ . ' ticket_billable_rate,'
+ . ' ticket_status,'
+ . ' ticket_deadline,'
+ . ' ticket_effort,'
+ . ' ticket_type,'
+ . ' ticket_details,'
+ . ' ticket_lastmod'
+ . ' ticket_lastmod_user)'
+ . ' VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?)');
+
+ $params = array
+ (
+ (int) $_POST['ticket']['group'],
+ (int)
$_POST['ticket']['priority'],
+ (int)
$_POST['ticket']['reported_by'],
+ (int)
$_POST['ticket']['assignedto'],
+ "'" .
$GLOBALS['phpgw']->db->db_addslashes($_POST['ticket']['subject']) . "'",
+ (int)
$_POST['ticket']['category'],
+ (float)
$_POST['ticket']['billable_hour'],
+ (float)
$_POST['ticket']['billable_rate'],
+ 0,
+ $deadline['raw'],
+ "'" .
$GLOBALS['phpgw']->db->db_addslashes($_POST['ticket']['effort']) . "'",
+
(isset($_POST['ticket']['type']) ? (int) $_POST['ticket']['type'] : 0),
+ "'" .
$GLOBALS['phpgw']->db->db_addslashes($_POST['ticket']['details']) . "'",
+ time(),
+ (int)
$GLOBALS['phpgw_info']['user']['account_id']
+ );
+
+ $GLOBALS['phpgw']->db->adodb->Execute($sql, $params);
+ $ticket_id = $GLOBALS['phpgw']->db->adodb->Insert_ID();
+
+ $historylog = createobject('phpgwapi.historylog','tts');
+ $historylog->add('O',$ticket_id,' ','');
+
//File-Upload
- if ($HTTP_POST_FILES['attachment']['name'] != '')
+ if ( isset($_FILES['attachment']['name'])
+ && $_FILES['attachment']['name'] != '')
{
- $basedir = $GLOBALS['basedir'] . "/tts";
- //Check if home/groupdirectory exists. If not, we
create it
+ $basedir = "{$GLOBALS['phpgw']->vfs->basedir}/tts";
+ //Check if tts directory exists. If not, we create it
if (!file_exists($basedir))
{
$GLOBALS['phpgw']->vfs->override_acl = 1;
@@ -52,12 +107,8 @@
$GLOBALS['phpgw']->vfs->override_acl = 0;
}
- $GLOBALS['phpgw']->db->query("SELECT max(ticket_id)
from phpgw_tts_tickets",__LINE__,__FILE__);
- $GLOBALS['phpgw']->db->next_record();
- $tid = ($GLOBALS['phpgw']->db->f('max(ticket_id)')) + 1;
-
- //$tid = $ticket_id =
$phpgw->db->get_last_insert_id('phpgw_tts_tickets','ticket_id');
- $attdir = $basedir . "/" . $tid;
+ $tid = $ticket_id =
$phpgw->db->get_last_insert_id('phpgw_tts_tickets','ticket_id');
+ $attdir = "{$basedir}/{$tid}";
$GLOBALS['phpgw']->vfs->override_acl = 1;
$GLOBALS['phpgw']->vfs->mkdir (array (
@@ -67,48 +118,19 @@
$GLOBALS['phpgw']->vfs->override_acl = 1;
$GLOBALS['phpgw']->vfs->cp(array (
- 'from' =>
$HTTP_POST_FILES['attachment']['tmp_name'],
- 'to' => $attdir . '/' .
$HTTP_POST_FILES['attachment']['name'],
+ 'from' =>
$_FILES['attachment']['tmp_name'],
+ 'to' => $attdir . '/' .
$_FILES['attachment']['name'],
'relatives' => array
(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL)));
$GLOBALS['phpgw']->vfs->override_acl = 0;
- $GLOBALS['phpgw']->db->query("SELECT max(file_id) from
phpgw_vfs",__LINE__,__FILE__);
- $GLOBALS['phpgw']->db->next_record();
- $file_id = $GLOBALS['phpgw']->db->f('max(file_id)');
- }
-
- $GLOBALS['phpgw']->db->query('INSERT INTO phpgw_tts_tickets '
- . '(ticket_group,ticket_priority,ticket_owner,'
- .
'ticket_assignedto,ticket_subject,ticket_category,ticket_billable_hours,'
- .
'ticket_billable_rate,ticket_status,ticket_deadline,ticket_effort,ticket_type, '
- . "ticket_platform, ticket_attachment, ticket_details,
ticket_lastmod) VALUES ('"
- . (int) $_POST['ticket']['group'] . "','"
- . (int) $_POST['ticket']['priority'] . "','"
- . $GLOBALS['phpgw_info']['user']['account_id'] . "','"
- . (int) $_POST['ticket']['assignedto'] . "','"
- .
$GLOBALS['phpgw']->db->db_addslashes($_POST['ticket']['subject']) . "','"
- . (int) $_POST['ticket']['category'] . "','"
- . (float) $_POST['ticket']['billable_hours'] . "','"
- . (float) $_POST['ticket']['billable_rate'] . "','O','"
- . (int) $_POST['ticket']['deadline']['year'] . "-" .
$GLOBALS['phpgw']->db->db_addslashes($_POST['ticket']['deadline']['month']) .
"-" . (int) $_POST['ticket']['deadline']['day'] . "','"
- .
$GLOBALS['phpgw']->db->db_addslashes($_POST['ticket']['effort'])."','"
- . ((int) $_POST['ticket']['type'] ? (int)
$_POST['ticket']['type'] : 0) . "','"
- . ((int) $_POST['ticket']['platform'] ? (int)
$_POST['ticket']['platform'] : 0) . "','"
- . ((int) $file_id ? (int) $file_id : 0). "','"
- .
$GLOBALS['phpgw']->db->db_addslashes($_POST['ticket']['details']) ."',"
- . time() . ")",__LINE__,__FILE__);
-
- $ticket_id =
$GLOBALS['phpgw']->db->get_last_insert_id('phpgw_tts_tickets','ticket_id');
-
- $historylog = createobject('phpgwapi.historylog','tts');
- $historylog->add('O',$ticket_id,' ','');
+ }
if($GLOBALS['phpgw']->config->config_data['mailnotification'])
{
mail_ticket($ticket_id);
}
-
$GLOBALS['phpgw']->redirect($GLOBALS['phpgw']->link('/tts/viewticket_details.php','&ticket_id='
. $ticket_id));
+ $GLOBALS['phpgw']->redirect_link('/tts/viewticket_details.php',
array('ticket_id' => $ticket_id) );
}
$account_selected = array();
@@ -136,59 +158,65 @@
$priority_selected[$GLOBALS['phpgw_info']['user']['preferences']['tts']['prioritydefault']]
= ' selected';
}
*/
- $GLOBALS['phpgw']->template->set_file(array(
- 'newticket' => 'newticket.tpl'
- ));
-
$GLOBALS['phpgw']->template->set_block('newticket','options_select');
- $GLOBALS['phpgw']->template->set_block('newticket','form');
+ $GLOBALS['phpgw']->template->set_file('newticket',
'newticket.tpl');
-
$GLOBALS['phpgw']->template->set_var('lang_create_new_ticket',lang('Create new
ticket'));
+ $GLOBALS['phpgw']->template->set_block('newticket',
'assignedto_option', 'assignedto_options');
+ $GLOBALS['phpgw']->template->set_block('newticket',
'options_select');
+ $GLOBALS['phpgw']->template->set_block('newticket',
'reported_by', 'reported_bys');
+ $GLOBALS['phpgw']->template->set_block('newticket',
'reported_via', 'reported_vias');
+ $GLOBALS['phpgw']->template->set_block('newticket',
'ticket_priority', 'ticket_priorities');
+ $GLOBALS['phpgw']->template->set_block('newticket', 'form');
+
+ $GLOBALS['phpgw']->template->set_var('currency',
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency']);
$GLOBALS['phpgw']->template->set_var('form_action',
$GLOBALS['phpgw']->link('/tts/newticket.php'));
+ $GLOBALS['phpgw']->template->set_var('img_cancel',
$GLOBALS['phpgw']->common->image('tts', 'stock_cancel', '.png', False) );
+ $GLOBALS['phpgw']->template->set_var('img_help',
$GLOBALS['phpgw']->common->image('tts', 'stock_help', '.png', False) );
+ $GLOBALS['phpgw']->template->set_var('img_ok',
$GLOBALS['phpgw']->common->image('tts', 'stock_ok', '.png', False) );
+
+ $GLOBALS['phpgw']->template->set_var('lang_addticket',
lang('Add Ticket'));
+
$GLOBALS['phpgw']->template->set_var('lang_assignedto',lang('Assign to'));
+
$GLOBALS['phpgw']->template->set_var('lang_attachment',lang('Attachment'));
+
$GLOBALS['phpgw']->template->set_var('lang_billable_hours',lang('Billable
hours'));
+
$GLOBALS['phpgw']->template->set_var('lang_billable_hours_rate',lang('Billable
hours rate'));
+
$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('cancel'));
$GLOBALS['phpgw']->template->set_var('lang_category',lang('Category'));
- $GLOBALS['phpgw']->template->set_var('lang_group',
lang('Group'));
- $GLOBALS['phpgw']->template->set_var('lang_subject',
lang('Subject') );
- $GLOBALS['phpgw']->template->set_var('lang_nosubject', lang('No
subject'));
+ $GLOBALS['phpgw']->template->set_var('lang_clearform',
lang('Clear Form'));
+
$GLOBALS['phpgw']->template->set_var('lang_create_new_ticket',lang('Create new
ticket'));
+
$GLOBALS['phpgw']->template->set_var('lang_deadline',lang('Deadline'));
$GLOBALS['phpgw']->template->set_var('lang_details',
lang('Details'));
- $GLOBALS['phpgw']->template->set_var('lang_priority',
lang('Priority'));
+
$GLOBALS['phpgw']->template->set_var('lang_effort',lang('Effort'));
+ $GLOBALS['phpgw']->template->set_var('lang_group',
lang('Group'));
+ $GLOBALS['phpgw']->template->set_var('lang_help', lang('help'));
+ $GLOBALS['phpgw']->template->set_var('lang_highest',
lang('Highest'));
$GLOBALS['phpgw']->template->set_var('lang_lowest',
lang('Lowest'));
$GLOBALS['phpgw']->template->set_var('lang_medium',
lang('Medium'));
- $GLOBALS['phpgw']->template->set_var('lang_highest',
lang('Highest'));
- $GLOBALS['phpgw']->template->set_var('lang_addticket',
lang('Add Ticket'));
- $GLOBALS['phpgw']->template->set_var('lang_clearform',
lang('Clear Form'));
-
$GLOBALS['phpgw']->template->set_var('lang_assignedto',lang('Assign to'));
+ $GLOBALS['phpgw']->template->set_var('lang_nosubject', lang('No
subject'));
+ $GLOBALS['phpgw']->template->set_var('lang_ok', lang('ok') );
+
$GLOBALS['phpgw']->template->set_var('lang_platform',lang('Platform'));
+ $GLOBALS['phpgw']->template->set_var('lang_priority',
lang('Priority'));
+ $GLOBALS['phpgw']->template->set_var('lang_reported_by',
lang('reported by'));
+ $GLOBALS['phpgw']->template->set_var('lang_reported_note',
lang('reported note'));
+ $GLOBALS['phpgw']->template->set_var('lang_reported_via',
lang('reported via'));
+ $GLOBALS['phpgw']->template->set_var('lang_subject',
lang('Subject') );
$GLOBALS['phpgw']->template->set_var('lang_submit',lang('Submit'));
-
$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel'));
-
-
$GLOBALS['phpgw']->template->set_var('lang_billable_hours',lang('Billable
hours'));
-
$GLOBALS['phpgw']->template->set_var('lang_billable_hours_rate',lang('Billable
hours rate'));
-
- $GLOBALS['phpgw']->template->set_var('row_off',
$GLOBALS['phpgw_info']['theme']['row_off']);
- $GLOBALS['phpgw']->template->set_var('row_on',
$GLOBALS['phpgw_info']['theme']['row_on']);
- $GLOBALS['phpgw']->template->set_var('th_bg',
$GLOBALS['phpgw_info']['theme']['th_bg']);
+ $GLOBALS['phpgw']->template->set_var('lang_type',lang('Type'));
+
$GLOBALS['phpgw']->template->set_var('value_billable_hours_rate',($ticket['billable_rate']?$ticket['billable_rate']:'0.00'));
+
$GLOBALS['phpgw']->template->set_var('value_billable_hours',($ticket['billable_hours']?$ticket['billable_hours']:'0.00'));
$GLOBALS['phpgw']->template->set_var('value_details',
$ticket['details']); // check this line
$GLOBALS['phpgw']->template->set_var('value_subject',
$ticket['details']); // check this line
-
$GLOBALS['phpgw']->template->set_var('value_billable_hours',($ticket['billable_hours']?$ticket['billable_hours']:'0.00'));
-
$GLOBALS['phpgw']->template->set_var('value_billable_hours_rate',($ticket['billable_rate']?$ticket['billable_rate']:'0.00'));
-
$GLOBALS['phpgw']->template->set_var('currency',$GLOBALS['phpgw_info']['user']['preferences']['common']['currency']);
-
- $GLOBALS['phpgw']->template->set_var('lang_type',lang('Type'));
-
$GLOBALS['phpgw']->template->set_var('lang_deadline',lang('Deadline'));
-
$GLOBALS['phpgw']->template->set_var('lang_effort',lang('Effort'));
-
$GLOBALS['phpgw']->template->set_var('lang_platform',lang('Platform'));
-
$GLOBALS['phpgw']->template->set_var('lang_attachment',lang('Attachment'));
unset($s);
$groups = CreateObject('phpgwapi.accounts');
$group_list = array();
$group_list =
$GLOBALS['phpgw']->accounts->membership($GLOBALS['phpgw_info']['user']['account_id']);
- while(list($key,$entry) = each($group_list))
+ foreach ( $group_list as $key => $entry )
{
if($GLOBALS['phpgw_info']['user']['preferences']['tts']['groupdefault'] ==
$entry['account_id'])
{
- $selected = 'selected';
+ $selected = 'selected="selected"';
}
else
{
@@ -197,37 +225,57 @@
$s .= '<option value="' . $entry['account_id'] . '" ' .
$selected
. '>' . $entry['account_name'] . '</option>';
}
- $GLOBALS['phpgw']->template->set_var('options_group',$s);
-
- $s = '<select name="ticket[category]">' .
$GLOBALS['phpgw']->categories->formated_list('select','',$group,False) .
'</select>';
- $GLOBALS['phpgw']->template->set_var('value_category',$s);
+ $GLOBALS['phpgw']->template->set_var('options_group', $s);
- unset($s);
- for($i=1; $i<=31; $i++)
+ foreach (
ExecMethod('phpgwapi.contacts.get_contact_comm_descr') as $comm_descr )
{
- $i < 10 ? $y = '0' . $i : $y = $i;
- $s .= '<option>' . $y . '</option>';
+ $GLOBALS['phpgw']->template->set_var(
+
array
+
(
+
'via_id' => $comm_descr['comm_descr_id'],
+
'via_text' => $comm_descr['comm_description'],
+
));
+
$GLOBALS['phpgw']->template->parse('reported_vias', 'reported_via', true);
}
- $GLOBALS['phpgw']->template->set_var('option_day','<select
name="ticket[deadline][day]"><option selected></option>' . $s . '</select>');
- unset($s);
- for($i=1; $i<=12; $i++)
- {
- $i < 10 ? $y = '0' . $i : $y = $i;
- $s .= '<option>' . $y . '</option>';
- }
- $GLOBALS['phpgw']->template->set_var('option_month','<select
name="ticket[deadline][month]"><option selected></option>' . $s . '</select>');
+ $GLOBALS['phpgw']->template->set_var('ticket_deadline',
$GLOBALS['phpgw']->jscalendar->input('ticket_deadline', $ticket['deadline']));
+
+ $GLOBALS['phpgw']->template->set_var('value_cat_top',
$GLOBALS['phpgw']->categories->formated_list('select', 'mains', $group, False));
unset($s);
$accounts = $groups;
$accounts->account_id = $group_id;
- $account_list = $accounts->get_list('accounts');
- while(list($key,$entry) = each($account_list))
+ $tts_users =
$GLOBALS['phpgw']->acl->get_ids_for_location('run', 1, 'tts');
+
+
+ $GLOBALS['phpgw']->template->set_var(array
+
(
+
'acct_id' => 0,
+
'acct_name' => lang('please select')
+
)
+
);
+ $GLOBALS['phpgw']->template->parse('reported_bys',
'reported_by', true);
+
+ $account_list = $accounts->get_list('accounts', -1,
'account_firstname');
+ foreach ( $account_list as $key => $entry )
{
$GLOBALS['phpgw']->accounts->get_account_name($entry['account_id'],$lid,$fname,$lname);
if(!$fname && !$lname)
+ {
continue;
+ }
+
+ $GLOBALS['phpgw']->template->set_var(array
+
(
+
'acct_id' => $entry['account_id'],
+
'acct_name' =>
$GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname)
+
)
+
);
+ $GLOBALS['phpgw']->template->parse('reported_bys',
'reported_by', true);
+
+ if( in_array($entry['account_id'], $tts_users) )
+ {
$employees_list[$entry['account_id']] =
$GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname);
if(count($employees_list))
@@ -236,56 +284,32 @@
reset($employees_list);
}
}
-
- $select_employee_list = "<select name=\"ticket[assignedto]\"
size=\"1\">\n";
- while (list($account_id,$account_name) = each($employees_list))
- {
- $select_employee_list .= '<option value="' .
$account_id . '"';
- if
($GLOBALS['phpgw_info']['user']['preferences']['tts']['assigntodefault'] ==
$account_id)
- {
- $select_employee_list .= ' selected';
}
- $select_employee_list .=
'>'.$account_name."</option>\n";
- }
- $select_employee_list .= '</select>';
-
-
$GLOBALS['phpgw']->template->set_var('value_assignedto',$select_employee_list);
-
- //auswahlfelder type und platform
-
-
- $platform =
CreateObject('tts.subcategories',$GLOBALS['phpgw_info']['user']['account_id'],'tts');
- unset($s);
- $s = '<select name="ticket[platform]">' .
$platform->formated_list('select','appandplatform','',False) . '</select>';
- $GLOBALS['phpgw']->template->set_var('value_platform',$s);
-
-
- $type =
CreateObject('tts.subcategories',$GLOBALS['phpgw_info']['user']['account_id'],'tts');
- unset($s);
- $s = '<select name="ticket[type]">' .
$type->formated_list('select','appandtype','',False) . '</select>';
- $GLOBALS['phpgw']->template->set_var('value_type',$s);
-
- //$GLOBALS['phpgw']->template->set_var('tts_account_lid','0');
-
//$GLOBALS['phpgw']->template->set_var('tts_account_name',lang('None'));
// Choose the correct priority to display
$prority_selected[$ticket['priority']] = ' selected';
- $priority_comment[1] = ' - '.lang('Lowest');
- $priority_comment[5] = ' - '.lang('Medium');
- $priority_comment[10] = ' - '.lang('Highest');
- for($i=1; $i<=10; $i++)
+ $priority_comment[1] = ' - ' . lang('Lowest');
+ $priority_comment[5] = ' - ' . lang('Medium');
+ $priority_comment[10] = ' - ' . lang('Highest');
+ for($i = 1; $i <= 10; ++$i)
{
if($GLOBALS['phpgw_info']['user']['preferences']['tts']['prioritydefault'] ==
$i)
{
- $prio_selected = 'selected';
+
$GLOBALS['phpgw']->template->set_var('priority_selected',
'selected="selected"');
}
else
{
- $prio_selected = '';
+
$GLOBALS['phpgw']->template->set_var('priority_selected', '');
}
- $priority_select .= '<option value="' . $i . '" ' .
$prio_selected . '>' . $i . $priority_comment[$i] . '</option>';
+
+ $GLOBALS['phpgw']->template->set_var(array
+
(
+
'priority_val' => $i,
+
'priority_text' => strval($i) . (
isset($priority_comment[$i]) ? $priority_comment[$i] : '')
+
)
+
);
+ $GLOBALS['phpgw']->template->parse('ticket_priorities',
'ticket_priority', true);
}
- $GLOBALS['phpgw']->template->set_var('value_priority','<select
name="ticket[priority]">' . $priority_select . '</select>');
$GLOBALS['phpgw']->template->set_var('tts_select_options','');
$GLOBALS['phpgw']->template->set_var('tts_new_lstcategory','');
@@ -294,7 +318,9 @@
$GLOBALS['phpgw']->template->pfp('out','form');
$GLOBALS['phpgw']->common->phpgw_footer();
}
- else
+
+ function get_js()
{
+ return '\{\};';
}
?>
Index: viewticket_details.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/viewticket_details.php,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -b -r1.48 -r1.49
--- viewticket_details.php 10 May 2005 16:12:38 -0000 1.48
+++ viewticket_details.php 14 Oct 2006 05:39:41 -0000 1.49
@@ -5,7 +5,7 @@
* @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc.
http://www.fsf.org/
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
* @package tts
- * @version $Id: viewticket_details.php,v 1.48 2005/05/10 16:12:38
powerstat Exp $
+ * @version $Id: viewticket_details.php,v 1.49 2006/10/14 05:39:41
skwashd Exp $
*/
$GLOBALS['phpgw_info']['flags'] = array('enable_nextmatchs_class' =>
true,
@@ -479,28 +479,6 @@
$GLOBALS['phpgw']->db->transaction_begin();
- /*
- ** phpgw_tts_append.append_type - Defs
- ** R - Reopen ticket
- ** X - Ticket closed
- ** O - Ticket opened
- ** C - Comment appended
- ** A - Ticket assignment
- ** P - Priority change
- ** T - Category change
- ** S - Subject change
- ** B - Billing rate
- ** H - Billing hours
- ** G - Group
- ** Y - Type
- ** D - Deadline
- ** E - Effort
- ** L - Platform
- ** M - Attachment
- */
-
-
-
if($old_group != $ticket['group'])
{
$fields_updated = True;
Index: inc/class.attachedFiles.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/inc/class.attachedFiles.inc.php,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- inc/class.attachedFiles.inc.php 10 May 2005 16:12:38 -0000 1.3
+++ inc/class.attachedFiles.inc.php 14 Oct 2006 05:39:41 -0000 1.4
@@ -6,7 +6,12 @@
* @copyright Copyright (C) 2003-2005 Free Software Foundation, Inc.
http://www.fsf.org/
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
* @package tts
- * @version $Id: class.attachedFiles.inc.php,v 1.3 2005/05/10 16:12:38
powerstat Exp $
+ * @version $Id: class.attachedFiles.inc.php,v 1.4 2006/10/14 05:39:41
skwashd Exp $
+ */
+
+
+ /*
+ * FIXME This is crap and should be removed. phpgwapi.browser handles
a lot of it and the rest should be in botts
*/
Index: inc/class.ipc_tts.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/inc/class.ipc_tts.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- inc/class.ipc_tts.inc.php 10 May 2005 16:12:38 -0000 1.2
+++ inc/class.ipc_tts.inc.php 14 Oct 2006 05:39:41 -0000 1.3
@@ -6,7 +6,7 @@
* @copyright Copyright (C) 2003-2004 Free Software Foundation, Inc.
http://www.fsf.org/
* @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General
Public License
* @package tts
- * @version $Id: class.ipc_tts.inc.php,v 1.2 2005/05/10 16:12:38
powerstat Exp $
+ * @version $Id: class.ipc_tts.inc.php,v 1.3 2006/10/14 05:39:41 skwashd
Exp $
*/
/**
@@ -29,7 +29,7 @@
* Constructor
*/
function ipc_tts() {
- $this->bo =& CreateObject('tts.bo');
+ $this->bo =& CreateObject('tts.botts');
}
/**
Index: inc/hook_admin.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/inc/hook_admin.inc.php,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- inc/hook_admin.inc.php 9 Sep 2006 09:04:51 -0000 1.7
+++ inc/hook_admin.inc.php 14 Oct 2006 05:39:41 -0000 1.8
@@ -7,7 +7,7 @@
* @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
* @package tts
* @subpackage hooks
- * @version $Id: hook_admin.inc.php,v 1.7 2006/09/09 09:04:51 skwashd
Exp $
+ * @version $Id: hook_admin.inc.php,v 1.8 2006/10/14 05:39:41 skwashd
Exp $
*/
$values = array
@@ -21,7 +21,7 @@
if (! $GLOBALS['phpgw']->acl->check('custom_fields_access', 1, 'admin'))
{
- $values['custom fields'] =
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'admin.ui_custom_fields2.list_attribute', 'appname' => 'tts') );
+ $values['custom fields'] =
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'admin.ui_custom.list_attribute', 'appname' => 'tts') );
}
$GLOBALS['phpgw']->common->display_mainscreen('tts', $values);
Index: setup/default_records.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/setup/default_records.inc.php,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -b -r1.1.2.3 -r1.1.2.4
--- setup/default_records.inc.php 29 Feb 2004 22:01:50 -0000 1.1.2.3
+++ setup/default_records.inc.php 14 Oct 2006 05:39:41 -0000 1.1.2.4
@@ -1,51 +1,12 @@
<?php
-
/**************************************************************************\
- * phpGroupWare - Setup
*
- * http://www.phpgroupware.org
*
- * --------------------------------------------
*
- * This program is free software; you can redistribute it and/or modify
it *
- * under the terms of the GNU General Public License as published by
the *
- * Free Software Foundation; either version 2 of the License, or (at
your *
- * option) any later version.
*
-
\**************************************************************************/
- /* $Id: default_records.inc.php,v 1.1.2.3 2004/02/29 22:01:50 ceb Exp $
*/
+ /**
+ * Trouble Ticket System - Setup
+ *
+ * @copyright Copyright (C) 2001-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @package tts
+ * @subpackage setup
+ * @version $Id: default_records.inc.php,v 1.1.2.4 2006/10/14 05:39:41
skwashd Exp $
+ */
- $GLOBALS['phpgw_setup']->oProc->query('INSERT into phpgw_categories
(cat_main,cat_parent,cat_level,cat_owner,cat_access,cat_appname,cat_name,cat_description,cat_data)'
-
. " values(0,0,0,-1,'public','tts','Platform','Global category for
tts','platform')",__LINE__,__FILE__);
- $GLOBALS['phpgw_setup']->oProc->query("SELECT cat_id from
phpgw_categories where cat_name='Platform' and cat_owner=-1 and
cat_appname='tts'",__LINE__,__FILE__);
- if($GLOBALS['phpgw_setup']->oProc->next_record())
- {
- $main = $GLOBALS['phpgw_setup']->oProc->f('cat_id');
- }
- $main = intval($main);
-
- $GLOBALS['phpgw_setup']->oProc->query('UPDATE phpgw_categories set
cat_main=' . $main . ' where cat_id=' . $main,__LINE__,__FILE__);
-
- $GLOBALS['phpgw_setup']->oProc->query('INSERT into phpgw_categories
(cat_main,cat_parent,cat_level,cat_owner,cat_access,cat_appname,cat_name,cat_description,cat_data)'
-
. ' values('. $main . ',' . $main . ",1,-1,'public','tts','Linux','Global
category for tts','platform')",__LINE__,__FILE__);
-
- $GLOBALS['phpgw_setup']->oProc->query('INSERT into phpgw_categories
(cat_main,cat_parent,cat_level,cat_owner,cat_access,cat_appname,cat_name,cat_description,cat_data)'
-
. ' values('. $main . ',' . $main . ",1,-1,'public','tts','Windows','Global
category for tts','platform')",__LINE__,__FILE__);
-
- $GLOBALS['phpgw_setup']->oProc->query('INSERT into phpgw_categories
(cat_main,cat_parent,cat_level,cat_owner,cat_access,cat_appname,cat_name,cat_description,cat_data)'
-
. ' values('. $main . ',' . $main . ",1,-1,'public','tts','MacOS','Global
category for tts','platform')",__LINE__,__FILE__);
-
-
- $GLOBALS['phpgw_setup']->oProc->query('INSERT into phpgw_categories
(cat_main,cat_parent,cat_level,cat_owner,cat_access,cat_appname,cat_name,cat_description,cat_data)'
-
. " values(0,0,0,-1,'public','tts','Type','Global category for
tts','type')",__LINE__,__FILE__);
-
- $GLOBALS['phpgw_setup']->oProc->query("SELECT cat_id from
phpgw_categories where cat_name='Type' and cat_owner=-1 and
cat_appname='tts'",__LINE__,__FILE__);
- if($GLOBALS['phpgw_setup']->oProc->next_record())
- {
- $main = $GLOBALS['phpgw_setup']->oProc->f('cat_id');
- }
- $main = intval($main);
-
- $GLOBALS['phpgw_setup']->oProc->query('UPDATE phpgw_categories set
cat_main=' . $main . ' where cat_id=' . $main,__LINE__,__FILE__);
-
- $GLOBALS['phpgw_setup']->oProc->query('INSERT into phpgw_categories
(cat_main,cat_parent,cat_level,cat_owner,cat_access,cat_appname,cat_name,cat_description,cat_data)'
-
. ' values('. $main . ',' . $main . ",1,-1,'public','tts','Bug','Global
category for tts','type')",__LINE__,__FILE__);
-
- $GLOBALS['phpgw_setup']->oProc->query('INSERT into phpgw_categories
(cat_main,cat_parent,cat_level,cat_owner,cat_access,cat_appname,cat_name,cat_description,cat_data)'
-
. ' values('. $main . ',' . $main . ",1,-1,'public','tts','Feature
Request','Global category for tts','type')",__LINE__,__FILE__);
Index: setup/setup.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/setup/setup.inc.php,v
retrieving revision 1.6.4.2
retrieving revision 1.6.4.3
diff -u -b -r1.6.4.2 -r1.6.4.3
--- setup/setup.inc.php 16 Apr 2004 11:30:05 -0000 1.6.4.2
+++ setup/setup.inc.php 14 Oct 2006 05:39:41 -0000 1.6.4.3
@@ -1,29 +1,25 @@
<?php
-
/**************************************************************************\
- * phpGroupWare - Addressbook
*
- * http://www.phpgroupware.org
*
- * --------------------------------------------
*
- * This program is free software; you can redistribute it and/or modify
it *
- * under the terms of the GNU General Public License as published by
the *
- * Free Software Foundation; either version 2 of the License, or (at
your *
- * option) any later version.
*
-
\**************************************************************************/
-
- /* $Id: setup.inc.php,v 1.6.4.2 2004/04/16 11:30:05 lpiepho Exp $ */
+ /**
+ * Trouble Ticket System - Setup
+ *
+ * @copyright Copyright (C) 2001-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @package tts
+ * @subpackage setup
+ * @version $Id: setup.inc.php,v 1.6.4.3 2006/10/14 05:39:41 skwashd Exp
$
+ */
/* Basic information about this app */
$setup_info['tts']['name'] = 'tts';
$setup_info['tts']['title'] = 'Trouble Ticket System';
- $setup_info['tts']['version'] = '0.9.16.001';
+ $setup_info['tts']['version'] = '0.9.17.500';
$setup_info['tts']['app_order'] = 99;
$setup_info['tts']['enable'] = 1;
- $setup_info['todo']['globals_checked'] = True;
+ $setup_info['tts']['globals_checked'] = True;
+ $setup_info['tts']['app_group'] = 'development';
/* The tables this app creates */
- $setup_info['tts']['tables'] = array(
- 'phpgw_tts_tickets',
- 'phpgw_tts_views'
- );
+ $setup_info['tts']['tables'] =
array('phpgw_tts_tickets','phpgw_tts_views');
/* The hooks this app includes, needed for hooks registration */
$setup_info['tts']['hooks'][] = 'admin';
@@ -31,10 +27,14 @@
$setup_info['tts']['hooks'][] = 'manual';
$setup_info['tts']['hooks'][] = 'preferences';
$setup_info['tts']['hooks'][] = 'settings';
+ $setup_info['tts']['hooks'][] = 'deleteaccount';
+ $setup_info['tts']['hooks']['cat_add'] = 'tts.tts_bo_hooks.cat_add';
+ $setup_info['tts']['hooks']['cat_delete'] =
'tts.tts_bo_hooks.cat_delete';
+ $setup_info['tts']['hooks']['cat_edit'] = 'tts.tts_bo_hooks.cat_edit';
/* Dependencies for this app to work */
$setup_info['tts']['depends'][] = array(
'appname' => 'phpgwapi',
- 'versions' => Array('0.9.13','0.9.14', '0.9.16')
+ 'versions' => Array('0.9.17', '0.9.18')
);
?>
Index: setup/tables_baseline.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/setup/tables_baseline.inc.php,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -b -r1.1 -r1.1.4.1
--- setup/tables_baseline.inc.php 29 Sep 2001 03:43:33 -0000 1.1
+++ setup/tables_baseline.inc.php 14 Oct 2006 05:39:41 -0000 1.1.4.1
@@ -1,15 +1,13 @@
<?php
- /**************************************************************************\
- * phpGroupWare - Setup *
- * http://www.phpgroupware.org *
- * -------------------------------------------- *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU General Public License as published by the *
- * Free Software Foundation; either version 2 of the License, or (at your *
- * option) any later version. *
- \**************************************************************************/
-
- /* $Id: tables_baseline.inc.php,v 1.1 2001/09/29 03:43:33 jengo Exp $ */
+ /**
+ * Trouble Ticket System - Setup
+ *
+ * @copyright Copyright (C) 2001,2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @package tts
+ * @subpackage setup
+ * @version $Id: tables_baseline.inc.php,v 1.1.4.1 2006/10/14 05:39:41
skwashd Exp $
+ */
$phpgw_baseline = array(
'ticket' => array(
Index: setup/tables_current.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/setup/tables_current.inc.php,v
retrieving revision 1.6.4.1
retrieving revision 1.6.4.2
diff -u -b -r1.6.4.1 -r1.6.4.2
--- setup/tables_current.inc.php 20 Jan 2004 05:03:42 -0000 1.6.4.1
+++ setup/tables_current.inc.php 14 Oct 2006 05:39:41 -0000 1.6.4.2
@@ -1,46 +1,45 @@
<?php
- /**************************************************************************\
- * phpGroupWare - Setup *
- * http://www.phpgroupware.org *
- * -------------------------------------------- *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU General Public License as published by the *
- * Free Software Foundation; either version 2 of the License, or (at your *
- * option) any later version. *
- \**************************************************************************/
-
- /* $Id: tables_current.inc.php,v 1.6.4.1 2004/01/20 05:03:42 jengo Exp $ */
+ /**
+ * Trouble Ticket System - Setup
+ *
+ * @copyright Copyright (C) 2001-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @package tts
+ * @subpackage setup
+ * @version $Id: tables_current.inc.php,v 1.6.4.2 2006/10/14 05:39:41
skwashd Exp $
+ */
$phpgw_baseline = array(
'phpgw_tts_tickets' => array(
'fd' => array(
- 'ticket_id' => array('type' =>
'auto', 'nullable' => False),
- 'ticket_group' => array('type' =>
'varchar', 'precision' => 40, 'nullable' => True),
- 'ticket_priority' => array('type' =>
'int', 'precision' => 2, 'nullable' => False),
- 'ticket_owner' => array('type' =>
'varchar', 'precision' => 10, 'nullable' => True),
- 'ticket_assignedto' => array('type' =>
'varchar', 'precision' => 10, 'nullable' => True),
- 'ticket_subject' => array('type' =>
'varchar', 'precision' => 255, 'nullable' => True),
- 'ticket_category' => array('type' =>
'varchar', 'precision' => 25, 'nullable' => True),
- 'ticket_billable_hours' => array('type' =>
'decimal', 'precision' => 8, 'scale' => 2, 'nullable' => False),
- 'ticket_billable_rate' => array('type' =>
'decimal', 'precision' => 8, 'scale' => 2, 'nullable' => False),
- 'ticket_status' => array('type' =>
'char','precision' => 1, 'nullable' => False),
+ 'ticket_id' => array('type' =>
'auto','nullable' => False),
+ 'ticket_group' => array('type' =>
'int','precision' => '8','nullable' => True),
+ 'ticket_priority' => array('type' =>
'int','precision' => '2','nullable' => False),
+ 'ticket_owner' => array('type' =>
'int','precision' => '8','nullable' => True),
+ 'ticket_assignedto' => array('type' =>
'int','precision' => '4','nullable' => True),
+ 'ticket_subject' => array('type' =>
'varchar','precision' => '255','nullable' => True),
+ 'ticket_category' => array('type' =>
'int','precision' => '8','nullable' => True),
+ 'ticket_billable_hours' => array('type' =>
'decimal','precision' => '8','scale' => '2','nullable' => False),
+ 'ticket_billable_rate' => array('type' =>
'decimal','precision' => '8','scale' => '2','nullable' => False),
+ 'ticket_status' => array('type' =>
'char','precision' => '1','nullable' => False),
'ticket_details' => array('type' =>
'text','nullable' => False),
- 'ticket_type' => array('type' =>
'int', 'precision' => 2, 'nullable' => False),
- 'ticket_deadline' => array('type' =>
'varchar', 'precision' => 10, 'nullable' => False),
- 'ticket_effort' => array('type' =>
'varchar', 'precision' => 4, 'nullable' => False),
- 'ticket_platform' => array('type' =>
'int', 'precision' => 2, 'nullable' => False),
- 'ticket_attachment' => array('type' =>
'int', 'precision' => 2, 'nullable' => False)
+ 'ticket_type' => array('type' =>
'int','precision' => '2','nullable' => False),
+ 'ticket_deadline' => array('type' =>
'int','precision' => '8','nullable' => False),
+ 'ticket_effort' => array('type' =>
'varchar','precision' => '4','nullable' => False),
+ 'ticket_lastmod' => array('type' =>
'int','precision' => '8','nullable' => False),
+ 'ticket_lastmod_user' => array('type' =>
'int','precision' => '8','nullable' => False),
+ 'ticket_request_note' => array('type' =>
'varchar','precision' => '255','nullable' => True)
),
'pk' => array('ticket_id'),
- 'ix' => array(),
'fk' => array(),
+ 'ix' =>
array('ticket_group','ticket_owner','ticket_assignedto','ticket_subject','ticket_category','ticket_status','ticket_deadline'),
'uc' => array()
),
'phpgw_tts_views' => array(
'fd' => array(
- 'view_id' => array('type' => 'int',
'precision' => 4, 'nullable' => False),
- 'view_account_id' => array('type' =>
'varchar', 'precision' => 40, 'nullable' => True),
- 'view_time' => array('type' => 'int',
'precision' => 4, 'nullable' => False)
+ 'view_id' => array('type' => 'int','precision'
=> '4','nullable' => False),
+ 'view_account_id' => array('type' =>
'varchar','precision' => '40','nullable' => True),
+ 'view_time' => array('type' =>
'int','precision' => '4','nullable' => False)
),
'pk' => array(),
'ix' => array(),
Index: setup/tables_update.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/tts/setup/tables_update.inc.php,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -b -r1.1.2.2 -r1.1.2.3
--- setup/tables_update.inc.php 20 Jan 2004 05:03:42 -0000 1.1.2.2
+++ setup/tables_update.inc.php 14 Oct 2006 05:39:41 -0000 1.1.2.3
@@ -1,55 +1,163 @@
<?php
-
/**************************************************************************\
- * phpGroupWare - Setup
*
- * http://www.phpgroupware.org
*
- * --------------------------------------------
*
- * This program is free software; you can redistribute it and/or modify
it *
- * under the terms of the GNU General Public License as published by
the *
- * Free Software Foundation; either version 2 of the License, or (at
your *
- * option) any later version.
*
-
\**************************************************************************/
-
- // $Id: tables_update.inc.php,v 1.1.2.2 2004/01/20 05:03:42 jengo Exp $
- // $Source: /cvsroot/phpgroupware/tts/setup/tables_update.inc.php,v $
+ /**
+ * Trouble Ticket System - Setup
+ *
+ * @copyright Copyright (C) 2001-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @package tts
+ * @subpackage setup
+ * @version $Id: tables_update.inc.php,v 1.1.2.3 2006/10/14 05:39:41
skwashd Exp $
+ */
/* This is since the last release */
$test[] = '0.9.16';
- function phpgwapi_upgrade0_9_16()
+
+ /**
+ * Upgrade from 0.9.16 to 0.9.16.001
+ *
+ * @return string New version
+ */
+ function tts_upgrade0_9_16()
{
global $setup_info,$phpgw_setup;
-
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_tts_tickets','type',array(
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_tts_tickets','ticket_type',array(
'type' => 'int',
- 'precision' => '',
- 'nullable' => True
+ 'precision' => 2,
+ 'nullable' => true
));
-
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_tts_tickets','deadline',array(
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_tts_tickets','ticket_deadline',array(
'type' => 'varchar',
- 'precision' => '10',
- 'nullable' => True
+ 'precision' => 10,
+ 'nullable' => true
));
-
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_tts_tickets','effort',array(
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_tts_tickets','ticket_effort',array(
'type' => 'varchar',
- 'precision' => '4',
- 'nullable' => True
+ 'precision' => 4,
+ 'nullable' => true
));
-
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_tts_tickets','platform',array(
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_tts_tickets','ticket_platform',array(
'type' => 'int',
- 'precision' => '',
- 'nullable' => True
+ 'precision' => 2,
+ 'nullable' => true
));
-
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_tts_tickets','attachment',array(
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_tts_tickets','ticket_attachment',array(
'type' => 'int',
- 'precision' => '',
- 'nullable' => True
+ 'precision' => 2,
+ 'nullable' => false
+ ));
+
+ $setup_info['tts']['currentver'] = '0.9.16.001';
+ return $setup_info['tts']['currentver'];
+ }
+
+ $test[] = '0.9.16.001';
+ function tts_upgrade0_9_16_001() {
+ global $setup_info,$phpgw_setup;
+
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_tts_tickets','ticket_lastmod',array(
+ 'type' => 'int',
+ 'precision' => 4,
+ 'nullable' => false
));
- $setup_info['phpgwapi']['currentver'] = '0.9.16.001';
- return $setup_info['phpgwapi']['currentver'];
+ $setup_info['tts']['currentver'] = '0.9.16.002';
+ return $setup_info['tts']['currentver'];
}
+
+
+ $test[] = '0.9.16.002';
+ function tts_upgrade0_9_16_002()
+ {
+
$GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_tts_tickets',array(
+ 'fd' => array(
+ 'ticket_id' => array('type' =>
'auto','nullable' => False),
+ 'ticket_group' => array('type' =>
'varchar','precision' => '40','nullable' => True),
+ 'ticket_priority' => array('type' =>
'int','precision' => '2','nullable' => False),
+ 'ticket_owner' => array('type' =>
'varchar','precision' => '10','nullable' => True),
+ 'ticket_assignedto' => array('type' =>
'varchar','precision' => '10','nullable' => True),
+ 'ticket_subject' => array('type' =>
'varchar','precision' => '255','nullable' => True),
+ 'ticket_category' => array('type' =>
'varchar','precision' => '25','nullable' => True),
+ 'ticket_billable_hours' => array('type' =>
'decimal','precision' => '8','scale' => '2','nullable' => False),
+ 'ticket_billable_rate' => array('type' =>
'decimal','precision' => '8','scale' => '2','nullable' => False),
+ 'ticket_status' => array('type' =>
'char','precision' => '1','nullable' => False),
+ 'ticket_details' => array('type' =>
'text','nullable' => False),
+ 'ticket_type' => array('type' =>
'int','precision' => '2','nullable' => False),
+ 'ticket_deadline' => array('type' =>
'varchar','precision' => '10','nullable' => False),
+ 'ticket_effort' => array('type' =>
'varchar','precision' => '4','nullable' => False),
+ 'ticket_attachment' => array('type' =>
'int','precision' => '2','nullable' => False),
+ 'ticket_lastmod' => array('type' =>
'int','precision' => '4','nullable' => False)
+ ),
+ 'pk' => array('ticket_id'),
+ 'ix' => array(),
+ 'fk' => array(),
+ 'uc' => array()
+ ),'ticket_platform');
+
$GLOBALS['phpgw_setup']->oProc->DropColumn('phpgw_tts_tickets',array(
+ 'fd' => array(
+ 'ticket_id' => array('type' =>
'auto','nullable' => False),
+ 'ticket_group' => array('type' =>
'varchar','precision' => '40','nullable' => True),
+ 'ticket_priority' => array('type' =>
'int','precision' => '2','nullable' => False),
+ 'ticket_owner' => array('type' =>
'varchar','precision' => '10','nullable' => True),
+ 'ticket_assignedto' => array('type' =>
'varchar','precision' => '10','nullable' => True),
+ 'ticket_subject' => array('type' =>
'varchar','precision' => '255','nullable' => True),
+ 'ticket_category' => array('type' =>
'varchar','precision' => '25','nullable' => True),
+ 'ticket_billable_hours' => array('type' =>
'decimal','precision' => '8','scale' => '2','nullable' => False),
+ 'ticket_billable_rate' => array('type' =>
'decimal','precision' => '8','scale' => '2','nullable' => False),
+ 'ticket_status' => array('type' =>
'char','precision' => '1','nullable' => False),
+ 'ticket_details' => array('type' =>
'text','nullable' => False),
+ 'ticket_type' => array('type' =>
'int','precision' => '2','nullable' => False),
+ 'ticket_deadline' => array('type' =>
'varchar','precision' => '10','nullable' => False),
+ 'ticket_effort' => array('type' =>
'varchar','precision' => '4','nullable' => False),
+ 'ticket_lastmod' => array('type' =>
'int','precision' => '4','nullable' => False)
+ ),
+ 'pk' => array('ticket_id'),
+ 'ix' => array(),
+ 'fk' => array(),
+ 'uc' => array()
+ ),'ticket_attachment');
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_tts_tickets','ticket_group',array(
+ 'type' => 'int',
+ 'precision' => '8',
+ 'nullable' => True
+ ));
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_tts_tickets','ticket_owner',array(
+ 'type' => 'int',
+ 'precision' => '8',
+ 'nullable' => True
+ ));
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_tts_tickets','ticket_assignedto',array(
+ 'type' => 'int',
+ 'precision' => '8',
+ 'nullable' => True
+ ));
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_tts_tickets','ticket_category',array(
+ 'type' => 'int',
+ 'precision' => '8',
+ 'nullable' => True
+ ));
+
$GLOBALS['phpgw_setup']->oProc->AlterColumn('phpgw_tts_tickets','ticket_deadline',array(
+ 'type' => 'int',
+ 'precision' => '8',
+ 'nullable' => False
+ ));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_tts_tickets','ticket_lastmod_user',array(
+ 'type' => 'int',
+ 'precision' => '4',
+ 'nullable' => False
+ ));
+
$GLOBALS['phpgw_setup']->oProc->AddColumn('phpgw_tts_tickets','ticket_request_note',array(
+ 'type' => 'varchar',
+ 'precision' => '255',
+ 'nullable' => True
+ ));
+
+ $GLOBALS['setup_info']['tts']['currentver'] = '0.9.17.500';
+ return $GLOBALS['setup_info']['tts']['currentver'];
+ }
?>
Index: templates/base/index.tpl
===================================================================
RCS file: /cvsroot/phpgroupware/tts/templates/base/index.tpl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- templates/base/index.tpl 11 Jan 2005 15:00:19 -0000 1.1
+++ templates/base/index.tpl 14 Oct 2006 05:39:42 -0000 1.2
@@ -1,94 +1,56 @@
<!-- BEGIN index.tpl -->
-{autorefresh}
-
-<!-- BEGIN tts_title -->
-<!-- <div align="center">{tts_appname}</div><p></p> -->
-<!-- END tts_title -->
-
+<script type="text/javascript">
+ //<![CDATA[
+ var lang =
+ {
+ invalid : '{lang_invalid}',
+ ticket_no : '{lang_ticket_no}'
+ };
+ //]]>
+</script>
<!-- BEGIN tts_search -->
-<form action="{tts_search_link}" method="post" name="search">
- <table style="margin-left: 20px">
- <tr>
- <td style="text-align: left">
- <a
href="{tts_newticket_link}">{tts_newticket}</a> |
- <a
href="{tts_prefs_link}">{lang_preferences}</a>
- </td>
- </tr>
- </table>
+<ul class="app_buttons">
+ <li onclick="window.location='{url_new_ticket}';">
+ <img src="{img_new}" alt="{lang_new}" /><br />
+ <a href="{url_new_ticket}">{lang_new}</a>
+ </li>
+ <li onclick="window.location='{url_search}';">
+ <img src="{img_search}" alt="{lang_search}" /><br />
+ <a href="{url_search}">{lang_search}</a>
+ </li>
+ <li onclick="window.location='{url_prefs}';">
+ <img src="{img_prefs}" alt="{lang_preferences"}" /><br />
+ <a href="{url_prefs}">{lang_preferences}</a>
+ </li>
+ <li onclick="goToPopup()">
+ <img src="{img_goto}" alt="{lang_goto"}" /><br />
+ <a href="#" onclick="goToPopup();">{lang_goto}</a>
+ </li>
+</ul>
<!-- END tts_search -->
-<!-- BEGIN tts_list -->
-
-<!--
- <div align="center">{tts_numtotal}<br />{tts_numopen}</div><p></p>
- <div align="center">{tts_notickets}</div>
--->
- <table style="width: 100%">
- <tr>
- <td style="width: 25%">
- </td>
- <td style="font-weight: bold; width: 50%;
text-align: center">
- {tts_numfound}
- </td>
- <td style="width: 25%"
style="white-space:nowrap; text-align:center; width:230px">
- <input type="hidden" name="filter"
value="search" />
- <input type="text" name="searchfilter"
value="{tts_searchfilter}" />
- <input type="submit"
value="{lang_search}" />
- </td>
- </tr>
- <tr>
- <td colspan="3" style="padding-top: 20px">
- <table class="fancy"
style="table-layout: fixed; width:99%;">
- <thead>
- <tr>
- <td
style="width: 20px"> </td>
- <td
style="width: 30px">{tts_head_ticket}</td>
-
<td>{tts_head_subject}</td>
- <td
style="width: 100px">{tts_head_dateopened}</td>
- <td
style="width: 170px">{tts_head_category}</td>
- <td
style="width: 120px">{tts_head_assignedto}</td>
- <td
style="width: 120px">{tts_head_openedby}</td>
- <td
style="width: 45px">{tts_head_prio}</td>
- <td
style="width: 110px">{tts_head_dateclosed}</td>
- </tr>
- <tr>
- <td></td>
- <td></td>
- <td></td>
- <td></td>
-
<td>{filter_category}</td>
-
<td>{filter_assignedto}</td>
-
<td>{filter_owner}</td>
-
<td>{filter_prio}</td>
- <td>
- <select
name="ticket[filter_status]" onChange="document.search.submit()">
-
{filter_status_options}
-
</select>
- </td>
- </tr>
- </thead>
- <tbody>
- {rows}
- </tbody>
- </table>
- </td>
- </tr>
- </table>
-</form>
-<!-- END tts_list -->
-
+<div class="tabsholder">
+ <ul class="tabs">
+ <li id="tab1"><a href="#"
onclick="oTabs.display(1);"><span>{lang_overdue}</span></a></li>
+ <li id="tab2"><a href="#"
onclick="oTabs.display(2);"><span>{lang_open}</span></a></li>
+ </ul><br />
+</div>
+<div id="tabcontent1">
+ {overdue_list}
+</div>
+<div id="tabcontent2">
+ {open_list}
+</div>
+
+<div id="tts_goto_dialog" class="panel">
+ <div class="hd"><div class="lt"></div><span>{lang_goto}</span><div
class="rt"></div></div>
+ <div class="bd">
+ <form method="post" action="{goto_action}" id="tts_goto_form"
name="tts_goto_form">
+ <div> <!-- STFU validator -->
+ <label for="ticket_id">{lang_ticket_no}</label>
+ <input type="text" name="ticket_id"
id="ticket_id"><br>
+ </div>
+ </form>
+ </div>
+</div>
<!-- END index.tpl -->
-
-<!-- BEGIN tts_row -->
- <tr bgcolor="{tts_row_color}">
- <td>{row_status}</td>
- <td style="overflow: hidden; white-space: nowrap;
text-align:center"><a href="{ticket_link}">{row_ticket_id}</a></td>
- <td style="overflow: hidden; white-space: nowrap"><a
href="{ticket_link}">{tts_t_subject}</a></td>
- <td style="overflow: hidden; white-space: nowrap;
text-align:center">{tts_t_timestampopened}</td>
- <td style="overflow: hidden; white-space: nowrap">{row_category}</td>
- <td style="overflow: hidden; white-space:
nowrap">{tts_t_assignedto}</td>
- <td style="overflow: hidden; white-space: nowrap">{tts_t_user}</td>
- <td style="text-align:center">{tts_t_prio}</td>
- <td>{tts_t_timestampclosed}</td>
- </tr>
-<!-- END tts_row -->
Index: templates/base/newticket.tpl
===================================================================
RCS file: /cvsroot/phpgroupware/tts/templates/base/newticket.tpl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- templates/base/newticket.tpl 11 Jan 2005 15:00:19 -0000 1.1
+++ templates/base/newticket.tpl 14 Oct 2006 05:39:42 -0000 1.2
@@ -3,64 +3,89 @@
<!-- END options_select -->
<!-- BEGIN form -->
-<b>{lang_create_new_ticket}</b>
-<hr />
-<p></p>
-{messages}
<form method="post" action="{form_action}" enctype="multipart/form-data">
- <table border="0" width="80%" cellspacing="0" align="center">
- <tr bgcolor="{th_bg}"><td colspan="4"> </td></tr>
- <tr bgcolor="{row_off}">
- <td align="left">{lang_assignedto}:</td>
- <td align="left">{value_assignedto}</td>
- <td align="left">{lang_category}:</td> <!-- <td
class="left">{lang_billable_hours}:</td> -->
- <td align="left">{value_category}</td> <!-- <td
class="left"><input name="ticket[billable_hours]"
value="{value_billable_hours}" /></td> -->
- </tr>
- <tr bgcolor="{row_on}">
- <td align="left">{lang_priority}:</td>
- <td align="left">{value_priority}</td>
- <td align="left">{lang_effort}:</td> <!-- <td
class="left">{lang_billable_hours_rate} {currency}:</td> -->
- <td align="left"><input type="text" name="ticket[effort]"
/></td> <!-- <td class="left"><input name="ticket[billable_rate]"
value="{value_billable_hours_rate}" /></td> -->
- </tr>
- <tr bgcolor="{row_off}">
- <td align="left">{lang_group}:</td>
- <td align="left"><select
name="ticket[group]">{options_group}</select></b></td>
- <td align="left">{lang_billable_hours}: {currency}</td>
- <td align="left"><input name="ticket[billable_hours]"
value="{value_billable_hours}" /></td>
- </tr>
- <tr bgcolor="{row_on}">
- <td align="left" colspan="2"></td>
- <td align="left" colspan="2"></td>
-<!-- <td align="left"> {lang_type}: </td> -->
-<!-- <td align="left">{value_type}</td> -->
- </tr>
- <tr bgcolor="{row_on}">
- <td align="left">{lang_deadline}:</td>
- <td align="left"><input type="text"
name="ticket[deadline][year]" size="4" /> . {option_month} . {option_day}</td>
- <td align="left">{lang_billable_hours_rate}: {currency}</td>
- <td align="left"><input name="ticket[billable_rate]"
value="{value_billable_hours_rate}" /></td>
- </tr>
- <tr bgcolor="{row_off}"
- <td align="left"> </td>
- <td align="left"> </td>
- <td align="left"> {lang_attachment} </td>
- <td align="left"> <input type="file" name="attachment" /> </td>
- </tr>
- <tr><td bgcolor="{row_on}" colspan="4"
align="center"> </td></tr>
- <tr bgcolor="{row_off}"><td colspan="4">{lang_subject}:</td></tr>
- <tr bgcolor="{row_on}"><td colspan="4"><input
name="ticket[subject]" value="{value_subject}" size="65" /></td></tr>
- <tr bgcolor="{row_off}"><td colspan="4"> </td></tr>
- <tr bgcolor="{row_on}">
- <td colspan="4">
- {lang_details}:<br />
- <textarea rows="10" name="ticket[details]" cols="65"
wrap="hard">{value_details}</textarea>
- </td>
- </tr>
- <tr>
- <td align="left"><input type="submit" name="submit"
value="{lang_submit}" /></td>
- <td colspan="2"> </td>
- <td align="right"><input type="submit" name="cancel"
value="{lang_cancel}" /></td>
- </tr>
- </table>
+
+ <label for="ticket_reported_by">{lang_reported_by}:</label>
+ <select name="ticket[reported_by]" id="ticket_reported_by">
+ <option value="0">{lang_please_select}</option>
+ <!-- BEGIN reported_by -->
+ <option value="{acct_id}">{acct_name}</option>
+ <!-- END reported_by -->
+ </select><br />
+
+ <label for="ticket_reported_note">{lang_reported_note}:</label>
+ <input type="text" name="ticket[reported_note]"
id="ticket_reported_note" /><br />
+
+ <label for="ticket_reported_via">{lang_reported_via}</label>
+ <select name="ticket[reported_via]" id="ticket_reported_via">
+ <option value="0">{lang_please_select}</option>
+ <!-- BEGIN reported_via -->
+ <option value="{via_id}">{via_text}</option>
+ <!-- END reported_via -->
+ </select><br />
+
+ <label for="ticket_cat_top">{lang_category}:</label>
+ <select name="ticket[cat_top]" id="ticket_cat_top">
+ <option value="0">{lang_please_select}</option>
+ {value_cat_top}
+ </select>
+
+ <select name="ticket[category]" id="ticket_category"
disabled="disabled">
+ <option></option>
+ </select><br />
+
+ <label for="ticket_priority">{lang_priority}:</label>
+ <select name="ticket[priority]" id="ticket_priority">
+ <!-- BEGIN ticket_priority -->
+ <option value="{priority_val}"
{priority_selected}>{priority_text}</option>
+ <!-- END ticket_priority -->
+ </select><br />
+
+ <label for="ticket_group">{lang_assignedto}:</label>
+ <select name="ticket[group]" id="ticket_group">
+ <option value="0">{lang_please_select}</option>
+ <!-- BEGIN ticket_group -->
+ <option value="{group_id}"
{group_selected}>{group_name}</option>
+ <!-- END ticket_group -->
+ </select>
+
+ <select name="ticket[assignedto]" id="ticket_assignedto"
disabled="disabled">
+ <option></option>
+ </select><br />
+
+ <label for="ticket_effort">{lang_effort}:</label>
+ <input type="text" name="ticket[effort]" id="ticket_effort" /><br />
+
+ <label for="ticket_billable_hours">{lang_billable_hours}:</label>
+ <input name="ticket[billable_hours]" id="ticket_billable_hours"
value="{value_billable_hours}" /><br />
+
+ <label for="ticket_billable_rate">{lang_billable_hours_rate}:</label>
+ <input name="ticket[billable_rate]" id="ticket_billable_rate"
value="{value_billable_hours}" /><br />
+
+ <label for="ticket_deadline">{lang_deadline}:</label>
+ {ticket_deadline}<br />
+
+ <label for="attachment">{lang_attachment}:</label>
+ <input type="file" name="attachment" id="attachment" /><br />
+
+ <label for="ticket_subject">{lang_subject}:</label>
+ <input name="ticket[subject]" id="ticket_subject"
value="{value_subject}" /><br />
+
+ <label for="ticket_details">{lang_details}:</label>
+ <textarea name="ticket[details]" id="ticket_details" rows="4"
cols="50">{value_details}</textarea>
+
+ <div class="btngrp">
+ <button type="button" name="help" id="help" value="0"
onclick="showHelp();" class="help">
+ <img src="{img_help}" alt="{lang_help}" /><span
class="btnlabel">{lang_help}</span>
+ </button>
+
+ <button type="submit" name="cancel" id="cancel" value="0"
onclick="this.value=1; return true;">
+ <img src="{img_cancel}" alt="{lang_cancel}" /><span
class="btnlabel">{lang_cancel}</span>
+ </button>
+
+ <button type="submit" name="submit" id="submit" value="0"
onclick="this.value=1; return true;">
+ <img src="{img_ok}" alt="{lang_ok}" /><span
class="btnlabel">{lang_ok}</span>
+ </button><br />
+ </div>
</form>
<!-- END form -->
Index: mailpipe.php
===================================================================
RCS file: mailpipe.php
diff -N mailpipe.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ mailpipe.php 14 Oct 2006 05:39:41 -0000 1.1
@@ -0,0 +1,157 @@
+#!/usr/bin/php
+<?php
+/**
+ * phpGroupWare TTS mail pipe interface
+ *
+ * This script allows you to add tickets via email
+ * @internal all attachments are dropped/ignored
+ * @author Dave Hall skwashd at phpgroupware org
+ * @copyright (c) 2006 Free Software Foundation Inc
+ */
+
+ if ( $_SERVER['argc'] != 3
+ || !isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] !=
'--email'
+ || !isset($_SERVER['argv'][2]) || !strlen($_SERVER['argv'][2]) )
+ {
+ fwrite(STDERR, "ERROR: TTS mailpipe called improperly!\n");
+ fwrite(STDERR, "Usage: mailpipe.php --email address@hidden");
+ fwrite(STDERR, "Exiting.\n");
+ fwrite(STDERR, print_r($_SERVER['argv']) . "\nExiting.\n");
+ return 1;
+ }
+ $email = $_SERVER['argv']['email'];
+
+ $user = 'demo';
+ $pass = 'guest';
+
+ $GLOBALS['phpgw_info']['flags'] = array
+
(
+
'disable_Template_class' => true,
+
'login' => true,
+
'currentapp' => 'login',
+
'noheader' => true
+
);
+ $phpgw_root = dirname($_SERVER['PHP_SELF']);
+ include($phpgw_root . '/../header.inc.php');
+
+ $sessionid = $GLOBALS['phpgw']->session->create($login,$passwd,'text');
+
+ $raw_msg = file_get_contents('php://stdin');
+
+ $decoder = createObject('phpgwapi.Mail_mimeDecode', $raw_msg, "\r\n");
+
+ $msg = $decoder->decode(array('include_bodies' => true));
+
+ unset($decoder);
+ unset($raw_msg);
+
+ $id_info = process_ticket_id($msg->headers['subject']);
+
+ $ticket = array
+ (
+ 'acct_id' =>
process_from($msg->headers['from']),
+ 'sender' =>
$msg->headers['from'],
+ 'subject' =>
$msg->headers['subject'],
+ 'target' => $id_info['queue'],
+ 'ticket_id' => $id_info['id']
+ );
+
+ $body_found = false;
+ if ( preg_match('/^text\/plain/',
$msg->parts[0]->headers['content-type']) )
+ {
+ $ticket['description'] =& $msg->parts[0]->body;
+ $body_found = true;
+ }
+ elseif ( preg_match('/^multipart\/alternative/',
$msg->parts[0]->headers['content-type']) )
+ {
+ foreach ( $msg->parts[0]->parts as $part_no => $part )
+ {
+ if ( preg_match('/^text\/plain/',
$part->headers['content-type']) )
+ {
+ $ticket['description'] =&
$msg->parts[0]->parts[$part_no]->body;
+ $body_found = true;
+ break;
+ }
+ }
+ }
+ unset($msg);
+
+ $ticket_created = false;
+ if ( $body_found )
+ {
+ ExecMethod('tts.botts.process_mail', $ticket);
+ terminate_session($sessionid);
+ exit;
+ }
+ else
+ {
+ $errors[] = 'no valid body of message found';
+ }
+
+ if ( count($errors) )
+ {
+ fwrite(STDERR, "ERROR: TTS mailpipe could not find message
body!\n");
+ fwrite(STDERR, "Exiting.\n");
+ return 1;
+ }
+ terminate_session($sessionid);
+
+ function process_from($from)
+ {
+ if ( ($pos = strpos($from, '<') ) !== false )
+ {
+ $from = substr($from, $pos + 1, -1);
+ }
+
+ $contacts = createObject('phpgwapi.contacts');
+ $contact_id = $contacts->search(array('comm_data'), $from);
+ unset($contacts);
+ if ( is_array($contact_id) && count($contact_id) )
+ {
+ return ExecMethod('phpgwapi.accounts.search_person',
$contact_id);
+ }
+ return 0;
+ }
+
+ function process_received($str)
+ {
+ if ( ($start = strpos($str, '<') ) !== false )
+ {
+ $end = strpos($str, '>') - $start;
+ return substr($str, $start + 1, $end -1);
+ }
+ return '';
+ }
+
+ /**
+ * Get the ID and queue information for a ticket
+ *
+ *
+ */
+ function process_ticket_id($str)
+ {
+ $id_info = array
+ (
+ 'id' => 0,
+ 'queue' => ''
+ );
+ if ( strpos($str, '[') === 0 )
+ {
+ $end = strpos($str, ']');
+ if ( $start = strpos($str, '#') < $end )
+ {
+ $id_info = array
+ (
+ 'id' => substr($str, $start + 1,
$end - $start -1),
+ 'queue' => substr($str, 1, $start -2)
+ );
+ }
+ }
+ return $id_info;
+ }
+
+ function terminate_session($sid)
+ {
+ $GLOBALS['phpgw']->session->destroy($sid,
$GLOBALS['phpgw']->session->kp3);
+ }
+?>
\ No newline at end of file
Index: inc/class.botts.inc.php
===================================================================
RCS file: inc/class.botts.inc.php
diff -N inc/class.botts.inc.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ inc/class.botts.inc.php 14 Oct 2006 05:39:41 -0000 1.1
@@ -0,0 +1,1101 @@
+<?php
+ /**
+ * Trouble Ticket System - business object
+ *
+ * @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @package tts
+ * @version $Id: class.botts.inc.php,v 1.1 2006/10/14 05:39:41 skwashd
Exp $
+ */
+
+
+ /**
+ * Business object
+ *
+ * @package tts
+ */
+ class botts
+ {
+ var $custom;
+ var $db;
+ var $cats;
+ var $so;
+ var $historylog;
+ var $total_records;
+ var $public_methods = array
+ (
+ 'list_methods' => true
+ );
+
+ function botts()
+ {
+ $this->db =& $GLOBALS['phpgw']->db;
+
+ $this->cats = createObject('phpgwapi.categories');
+
+ $this->custom = createObject('phpgwapi.custom_fields');
+
+ $this->historylog =
createobject('phpgwapi.historylog','tts');
+ $this->historylog->types = array
+ (
+ 'A' => 'Re-assigned',
+ 'B' => 'Billing rate',
+ 'C' => 'Commant',
+ 'D' => 'Deadline',
+ 'E' => 'Effort',
+ 'F' => 'Custom field value',
+ 'G' => 'Group ownership changed',
+ 'H' => 'Billing hours',
+ 'L' => 'Platform',
+ 'O' => 'Opened',
+ 'P' => 'Priority changed',
+ 'R' => 'Re-opened',
+ 'S' => 'Subject changed',
+ 'T' => 'Category changed',
+ 'X' => 'Closed',
+ 'Y' => 'Type'
+ );
+ }
+
+ function list_methods($_type)
+ {
+ if (is_array($_type))
+ {
+ $_type = $_type['type'];
+ }
+
+ switch($_type)
+ {
+ case 'xmlrpc':
+ $xml_functions = array(
+ 'list_methods' => array(
+ 'function' =>
'list_methods',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
+ 'docstring' =>
lang('Read this list of methods.')
+ ),
+ 'save' => array(
+ 'function' => 'save',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
+ 'docstring' =>
lang('Creates a new ticket, returns ticket_id')
+ ),
+ 'list' => array(
+ 'function' => '_list',
+ 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
+ 'docstring' =>
lang('Creates a struct of tickets')
+ ),
+ 'read' => array(
+ 'function' => '_read',
+ 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
+ 'docstring' =>
lang('Returns a struct of values of a single ticket')
+ ),
+ 'read_notes' => array(
+ 'function' =>
'read_notes',
+ 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
+ 'docstring' =>
lang('Returns the additional notes attached to a ticket')
+ ),
+ 'history' => array(
+ 'function' =>
'history',
+ 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
+ 'docstring' =>
lang('Returns a struct of a tickets history')
+ ),
+ 'update' => array(
+ 'function' => 'update',
+ 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
+ 'docstring' =>
lang('Updates ticket')
+ ),
+ 'test' => array(
+ 'function' => 'test',
+ 'signature' =>
array(array(xmlrpcString)),
+ 'docstring' =>
lang('TEST')
+ )
+
+ );
+ return $xml_functions;
+
+ case 'soap':
+ return $this->soap_functions;
+
+ default:
+ return array();
+ }
+ }
+
+ function test()
+ {
+ return 'This is a string';
+ }
+
+ function cached_accounts($account_id)
+ {
+ $this->accounts = CreateObject('phpgwapi.accounts',
$account_id);
+ $this->accounts->read_repository();
+
+
$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 delete($id)
+ {
+ $id = (int)$id;
+ $ret = true;
+ $ret &= (! is_null($this->db->query(
+ "DELETE FROM phpgw_tts_tickets WHERE
ticket_id=$id",
+ __LINE__,
+ __FILE__
+ )));
+ $ret &= (! is_null($this->db->query(
+ "DELETE FROM phpgw_tts_views WHERE view_id=$id",
+ __LINE__,
+ __FILE__
+ )));
+ return $ret;
+ }
+
+ /**
+ * Read a ticket from the database
+ *
+ * @param int $id the database id for the ticket
+ * @return array the ticket values, count(0) == invalid ticket
+ */
+ function get_ticket($id)
+ {
+ $id = (int)$id;
+ if ( $id === 0 )
+ {
+ return array();
+ }
+
+ $this->_record_view($id);
+
+ $ttype = (int)$this->db->adodb->getOne('SELECT
ticket_type FROM phpgw_tts_tickets WHERE ticket_id = ' . $id);
+
+ $cats = $this->get_user_cat_list(PHPGW_ACL_READ);
+
+ if ( $ttype === 0 || !isset($cats[$ttype]) ) //not
found, invalid type or no rights
+ {
+ return array();
+ }
+
+ $ticket = $this->db->adodb->getAssoc("SELECT * FROM
phpgw_tts_tickets, phpgw_tts_c{$ttype}" .
+ " WHERE phpgw_tts_tickets.ticket_id =
$id" .
+ " AND phpgw_tts_c{$ttype}.ticket_id =
phpgw_tts_tickets.ticket_id");
+
+ if ( !is_array($ticket) || !count($ticket) )
+ {
+ return array();
+ }
+ $ticket = $ticket[$id];//it keys the array with the
primary key
+
+ $ticket['type'] = $this->cats->id2name($ttype);
+
+ $ticket['deadline'] = $this->db->f('ticket_deadline');
+ if ($this->db->f('ticket_deadline') == '0000-00-00')
+ {
+ $ticket['deadline'] = '';
+ }
+
+ $ticket['attachment'] = array();
+
+ $ticket['history'] = $this->get_history($id);
+ $ticket['notes'] = $this->get_notes($id);
+
+ $cached_data =
$this->cached_accounts($ticket['ticket_group']);
+ $ticket['ticket_group_name'] =
isset($cached_data[$ticket['ticket_group']]) ? lang('%1 group',
$cached_data[$ticket['ticket_group']]['firstname']) : lang('unknown');
+
+ $cached_data =
$this->cached_accounts($ticket['ticket_owner']);
+ $ticket['ticket_owner_name'] =
isset($cached_data[$ticket['ticket_owner']]) ?
$GLOBALS['phpgw']->common->display_fullname($cached_data[$ticket['ticket_owner']]['account_lid'],
+
$cached_data[$ticket['ticket_owner']]['firstname'],
$cached_data[$ticket['ticket_owner']]['lastname']) : lang('unkown');
+
+ $cached_data =
$this->cached_accounts($ticket['ticket_assignedto']);
+ $ticket['ticket_assignedto_name'] =
isset($cached_data[$ticket['ticket_assignedto']]) ?
$GLOBALS['phpgw']->common->display_fullname($cached_data[$ticket['ticket_assignedto']]['account_lid'],
+
$cached_data[$ticket['ticket_assignedto']]['firstname'],$cached_data[$ticket['ticket_assignedto']]['lastname'])
: lang('unassigned');
+
+ return $ticket;
+ }
+
+ function list_tickets($params)
+ {
+ $order = isset($param['order']) ?
$this->db->db_addslashes($params['order']) : '';
+ $sort = ( isset($param['sort']) &&
strtolower($params['sort']) == 'asc') ? 'ASC' : 'DESC';
+ $sortmethod = strlen($order) > 0 ? "ORDER BY $order
$sort" : 'ORDER BY ticket_priority DESC';
+
+ $filter = array();
+ if( isset($params['filter_prio']) &&
$params['filter_prio'] != '')
+ {
+ $filter[] = 'ticket_priority = ' .
$this->db->db_addslashes($_POST['ticket']['filter_prio']);
+ }
+
+ if( isset($params['filter_owner']) &&
$params['filter_owner'] != '')
+ {
+ $filter[] = 'ticket_owner =
'.(int)$params['filter_owner'];
+ }
+
+ if( isset($params['filter_assignedto']) &&
$params['filter_assignedto'] != '')
+ {
+ $filter[] = 'ticket_assignedto = ' .
(int)$params['filter_assignedto'];
+ }
+
+ if( isset($params['filter_category']) &&
$params['filter_category'] > 0 )
+ {
+ $filter[] = 'ticket_category = ' .
(int)$params['filter_category'];
+ }
+
+ if( isset($params['filter_status']) &&
$params['filter_status'] != 'none')
+ {
+ if ( $params['filter_status'] == 'open' )
+ {
+ $filter[] = "ticket_status='O'";
+ }
+ else
+ {
+ $filter[] = "ticket_status='X'";
+ }
+ }
+ if ( isset($params['searchfilter']) &&
$params['searchfilter'] != '')
+ {
+ $filter[] .= "(ticket_details LIKE '%" .
$this->db->db_addslashes($params['searchfilter']) ."%' OR " .
+ " ticket_subject LIKE '%" .
$this->db->db_addslashes($params['searchfilter']) . "'%)";
+
+ }
+
+ if ( isset($params['filter_due_before']) &&
$params['filter_due_before'] > 0 )
+ {
+ $filter[] = 'ticket_deadline <= ' .
(int)$params['filter_due_before'];
+ }
+
+ $cats = $this->get_user_cat_list(PHPGW_ACL_READ);
+ $filter[] = ' ticket_category IN (0' . ( count($cats) ?
', ' . implode(', ', $cats) : '') . ')';
+
+ $filter[] = '1 = 1';
+
+ $filterstring = implode(' AND ', $filter);
+ unset($filter);
+
+ $sql = 'SELECT * FROM phpgw_tts_tickets'
+ . " WHERE {$filterstring} {$sortmethod}";
+
+ $rs = $this->db->adodb->Execute($sql);
+ $tickets = $rs->getAssoc(true);
+
+ $this->total_records = count($tickets);
+
+ foreach ( $tickets as $tid => $ticket )
+ {
+
+ $history_values =
$this->historylog->return_array(array(), array('O'), '', '', $tid);
+
+ $cached_data =
$this->cached_accounts($ticket['ticket_group']);
+ $tickets[$tid]['ticket_group_name'] =
isset($cached_data[$ticket['ticket_group']]) ? lang('%1 group',
$cached_data[$ticket['ticket_group']]) : lang('unkown');
+
+ $cached_data =
$this->cached_accounts($ticket['ticket_owner']);
+ $tickets[$tid]['ticket_owner_name'] =
isset($cached_data[$ticket['ticket_owner']]) ?
$GLOBALS['phpgw']->common->display_fullname($cached_data[$ticket['ticket_owner']]['account_lid'],
+
$cached_data[$ticket['ticket_owner']]['firstname'],
$cached_data[$ticket['ticket_owner']]['lastname']) : lang('unkown');
+
+ $cached_data =
$this->cached_accounts($ticket['ticket_assignedto']);
+ $tickets[$tid]['ticket_assignedto_name'] =
isset($cached_data[$ticket['ticket_assignedto']]) ?
$GLOBALS['phpgw']->common->display_fullname($cached_data[$ticket['ticket_assignedto']]['account_lid'],
+
$cached_data[$ticket['ticket_assignedto']]['firstname'],$cached_data[$ticket['ticket_assignedto']]['lastname'])
: lang('unassigned');
+
+ //$tickets[$tid]['odate'] =
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']);
+ //$tickets[$tid]['odate_epoch'] =
(int)$history_values[0]['datetime'];
+ $tickets[$tid]['status_name'] =
$ticket['ticket_status'] == 0 ? lang('open') : lang('closed');
+ }
+ return $tickets;
+ }
+
+ function exists($id)
+ {
+ $myid = (int)$id;
+ $this->db->query(
+ "SELECT ticket_id FROM phpgw_tts_tickets WHERE
ticket_id=$myid",
+ __LINE__,
+ __FILE__
+ );
+ return $this->db->next_record();
+ }
+
+ /**
+ * Get a list of category IDs for the current user
+ *
+ * @param int $level the requited security level
+ * @return array the categories available to the user
+ */
+ function get_user_cat_list($level)
+ {
+ $ret_cats = array();
+ $cat_list = $this->cats->return_array('all', 0, false,
'', 'ASC', 'cat_name', false);
+ foreach ( $cat_list as $cat )
+ {
+ if ( $GLOBALS['phpgw']->acl->check('C' .
$cat['id'], $level, 'tts') )
+ {
+ $ret_cats[$cat['id']] = $cat['id']; //
this way we can use $val[$key] lookups as well as using implode :)`
+ }
+ }
+ return $ret_cats;
+ }
+
+ function getIDList($lastmod = -1) {
+ $sel = "SELECT ticket_id FROM phpgw_tts_tickets";
+ $mylastmod = (int) $lastmod;
+ if ($mylastmod >= 0) {
+ $sel .= " WHERE ticket_lastmod>='" . $mylastmod
. "'";
+ }
+ $this->db->query($sel, __LINE__, __FILE__);
+ $ret = array();
+ while ($this->db->next_record()) {
+ $ret[] = $this->db->f("ticket_id");
+ }
+ error_log("bo_tts:getIDList: ".print_r($ret, true));
+ return $ret;
+ }
+
+ function get_fields($cat_id, $custom_only = false)
+ {
+ $fields = array();
+
+ if ( !$custom_only )
+ {
+ $fields[] = array
+ (
+ 'id' => 'ticket_id',
+ 'type' => 'hidden'
+ );
+
+ $fields[] = array
+ (
+ 'id' => 'ticket_type',
+ 'type' => 'hidden',
+ 'change_key'=> 'T'
+ );
+
+ $fields[] = array
+ (
+ 'id' => 'ticket_group',
+ 'label' => lang('user group'),
+ 'options' => $this->_get_groups(),
+ 'type' => 'select'
+ );
+
+ $fields[] = array
+ (
+ 'id' => 'ticket_priority',
+ 'label' => lang('priority'),
+ 'options' =>
$this->_get_priorities(),
+ 'type' => 'select',
+ 'change_key'=> 'P'
+ );
+
+ $fields[] = array
+ (
+ 'id' => 'ticket_owner',
+ 'label' => lang('ticket owner'),
+ 'type' => 'hidden'
+ );
+
+ $fields[] = array
+ (
+ 'id' => 'ticket_assignedto',
+ 'label' => lang('assigned to'),
+ 'options' =>
$this->_get_users($cat_id),
+ 'type' => 'select',
+ 'change_key'=> 'A'
+ );
+
+ $fields[] = array
+ (
+ 'id' => 'ticket_subject',
+ 'label' => lang('subject'),
+ 'type' => 'textbox',
+ 'change_key'=> 'S'
+ );
+
+ $fields[] = array
+ (
+ 'id' =>
'ticket_billable_hours',
+ 'label' => lang('billable
hours'),
+ 'type' => 'textbox',
+ 'change_key'=> 'H'
+ );
+
+ $fields[] = array
+ (
+ 'id' =>
'ticket_billable_rate',
+ 'label' => lang('hourly rate'),
+ 'type' => 'textbox',
+ 'change_key'=> 'B'
+ );
+
+ $fields[] = array
+ (
+ 'id' => 'ticket_status',
+ 'label' => lang('status'),
+ 'options' => $this->_get_stati(),
+ 'type' => 'select'
+ );
+
+ $fields[] = array
+ (
+ 'id' => 'ticket_deadline',
+ 'label' => lang('deadline'),
+ 'type' => 'date',
+ 'change_key'=> 'D'
+ );
+
+ $fields[] = array
+ (
+ 'id' => 'ticket_effort',
+ 'label' => lang('effort'),
+ 'type' => 'textbox',
+ 'change_key'=> 'E'
+ );
+
+ $fields[] = array
+ (
+ 'id' => 'ticket_details',
+ 'label' => lang('details'),
+ 'type' => 'memo',
+ 'change_key'=> 'C'
+ );
+ }
+
+ $cust_fields = $this->custom->get_attribs('tts',
"C{$cat_id}", 0, '', 'ASC', 'attrib_sort', true, true);
+ if ( is_array($cust_fields) && count($cust_fields) )
+ {
+ $i = count($fields);
+ foreach ( $cust_fields as $cust_field )
+ {
+ $fields[$i] = array
+ (
+ 'id' =>
$cust_field['column_name'],
+ //'help' =>
lang($cust_field['status_text']),
+ 'label' =>
lang($cust_field['name']),
+ 'type' =>
$this->_translate_cust_type($cust_field['datatype']),
+ 'change_key'=> 'F'
+ );
+ if ( isset($cust_field['choice']) )
+ {
+ $fields[$i]['options'] =
$cust_field['choice'];
+ }
+ ++$i;
+ }
+ }
+ return $fields;
+ }
+
+ // created getter without view-creation or reading it
+ function retrieve($id) {
+ $myid = (int) $id;
+ $this->db->query("select * from phpgw_tts_tickets where
ticket_id='" . $myid . "'",__LINE__,__FILE__);
+ if (! $this->db->next_record()) {
+ return false;
+ }
+ $ret = array(
+ 'id' => (int) $id,
+ 'group' =>
$this->db->f('ticket_group'),
+ 'priority' =>
$this->db->f('ticket_priority'),
+ 'owner' =>
$this->db->f('ticket_owner'),
+ 'assignedto' =>
$this->db->f('ticket_assignedto'),
+ 'subject' =>
$this->db->f('ticket_subject'),
+ 'category' =>
$this->db->f('ticket_category'),
+ 'billable_hours' =>
$this->db->f('ticket_billable_hours'),
+ 'billable_rate' =>
$this->db->f('ticket_billable_rate'),
+ 'status' =>
$this->db->f('ticket_status'),
+ 'details' =>
$this->db->f('ticket_details')
+ );
+ return $ret;
+ }
+
+ /**
+ * Validate a ticket before it is submitted
+ *
+ * @param string $ttype the ticket type to be validated
+ * @param array $values the ticket values as an associative array
+ * @return array any errors, count(0) == valid
+ */
+ function validate($ttype, $values)
+ {
+ $errors = array();
+ return $errors;
+ }
+
+ function _read($params = '')
+ {
+ $cat = createobject('phpgwapi.categories');
+
+ // Have they viewed this ticket before ?
+ $this->db->query("select count(*) from phpgw_tts_views
where view_id='" . $params['id']
+ . "' and view_account_id='" .
$GLOBALS['phpgw_info']['user']['account_id'] . "'",__LINE__,__FILE__);
+ $this->db->next_record();
+
+ if (! $this->db->f(0))
+ {
+ $this->db->query("insert into phpgw_tts_views
values ('" . $params['id'] . "','"
+ .
$GLOBALS['phpgw_info']['user']['account_id'] . "','" . time() .
"')",__LINE__,__FILE__);
+ }
+
+ $this->db->query("select * from phpgw_tts_tickets where
ticket_id='" . $params['id'] . "'",__LINE__,__FILE__);
+ $this->db->next_record();
+
+ $cached_data =
$this->cached_accounts($this->db->f('ticket_owner'));
+ $owner =
$GLOBALS['phpgw']->common->display_fullname($cached_data[$this->db->f('ticket_owner')]['account_lid'],
+
$cached_data[$this->db->f('ticket_owner')]['firstname'],$cached_data[$this->db->f('ticket_owner')]['lastname']);
+
+ $cached_data =
$this->cached_accounts($this->db->f('ticket_assignedto'));
+ $assignedto =
$GLOBALS['phpgw']->common->display_fullname($cached_data[$this->db->f('ticket_assignedto')]['account_lid'],
+
$cached_data[$this->db->f('ticket_assignedto')]['firstname'],$cached_data[$this->db->f('ticket_assignedto')]['lastname']);
+
+ $r = array
+ (
+ 'id' =>
(int)$this->db->f('ticket_id'),
+ 'group' =>
$this->db->f('ticket_group'),
+ 'priority' =>
$this->db->f('ticket_priority'),
+ 'owner' => $owner,
+ 'assignedto' => $assignedto,
+ 'subject' =>
$this->db->f('ticket_subject'),
+ 'category' =>
$cat->id2name($this->db->f('ticket_category')),
+ 'billable_hours' =>
$this->db->f('ticket_billable_hours'),
+ 'billable_rate' =>
$this->db->f('ticket_billable_rate'),
+ 'status' =>
$this->db->f('ticket_status'),
+ 'details' =>
$this->db->f('ticket_details'),
+ 'odate' =>
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
+ 'odate_epoch' =>
(int)$history_values[0]['datetime'],
+ 'view' => $this->db->f('ticket_view'),
+ 'history_size' =>
count($this->historylog->return_array(array('C','O'),array(),'','',$params['id']))
+ );
+ return $r;
+ }
+
+ function get_notes($ticket_id)
+ {
+ $r = array();
+ $history_array =
$this->historylog->return_array(array(),array('C'),'','',$ticket_id);
+ foreach ( $history_array as $value )
+ {
+ $r[] = array
+ (
+ 'note_date' =>
$GLOBALS['phpgw']->common->show_date($value['datetime']),
+ 'note_user' =>
$value['owner'],
+ 'note_contents' =>
nl2br($value['new_value'])//i know this really belongs in the UI layer but I am
doing it here
+ );
+ }
+ return $r;
+ }
+
+ function get_history($ticket_id)
+ {
+ $r = array();
+ // This function needs to make use of the alternate
handle option (jengo)
+ $history_array =
$this->historylog->return_array(array('C'), array(), '', '', $ticket_id);
+ foreach ( $history_array as $value )
+ {
+ $datetime =
$GLOBALS['phpgw']->common->show_date($value['datetime']);
+ $owner = $value['owner'];
+
+ $action = lang('unknown');
+ if (
isset($this->historylog->types[$value['status']]) )
+ {
+ $action =
$this->historylog->types[$value['status']];
+ }
+
+ $new_value = '';
+ if ($value['status'] == 'A')
+ {
+ if (! $value['new_value'])
+ {
+ $new_value = lang('None');
+ }
+ else
+ {
+ $new_value =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+ }
+ }
+ else if ( $value['status'] == 'X' ||
$value['status'] == 'O' )
+ {
+ $value['old_value'] =
$GLOBALS['phpgw']->common->show_date($value['old_value']);
+ if ( (int) $value['new_value'] > 0 )
+ {
+ $new_value =
$GLOBALS['phpgw']->common->show_date($value['new_value']);
+ }
+ }
+ else if ($value['status'] == 'T')
+ {
+ $new_value =
$cat->id2name($value['new_value']);
+ }
+ else if ($value['status'] != 'O' &&
$value['new_value'])
+ {
+ $new_value = $value['new_value'];
+ }
+
+ $r[] = array
+ (
+ 'owner' => $owner,
+ 'action' => $action,
+ 'new_value' => $new_value,
+ 'old_value' => $value['old_value'],
+ 'datetime' => $datetime
+ );
+ }
+
+ return $r;
+ }
+
+ /**
+ * Process the data provided by the mailpipe script
+ *
+ * @param array $ticket the ticket data
+ * @return int the new ticket id, 0 = failure
+ */
+ function process_mail($ticket)
+ {
+ //we are dealing with a comment
+ if ( isset($ticket['ticket_id']) )
+ {
+ $this->historylog->add('C',
$ticket['ticket_id'], $ticket['body'],'');
+ return $ticket['ticket_id'];
+ }
+
+ if ( count($this->validate($ticket) ) ) // we don't
really care what is invalid
+ {
+ if ( $id = $this->save($ticket) )
+ {
+ return $id;
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * Save a ticket to the database
+ */
+ function save($ticket, $dohistorylog = true)
+ {
+ $ticket_id = 0;
+ $lastmod = isset($ticket['ticket_lastmod']) ? (int)
$ticket['ticket_lastmod'] : time();
+ $sql = $this->db->adodb->Prepare('INSERT INTO
phpgw_tts_tickets('
+ . ' ticket_group,'
+ . ' ticket_priority,'
+ . ' ticket_owner,'
+ . ' ticket_assignedto,'
+ . ' ticket_subject,'
+ . ' ticket_category,'
+ . ' ticket_billable_hours,'
+ . ' ticket_billable_rate,'
+ . ' ticket_status,'
+ . ' ticket_deadline,'
+ . ' ticket_effort,'
+ . ' ticket_type,'
+ . ' ticket_details,'
+ . ' ticket_lastmod,'
+ . ' ticket_lastmod_user)'
+ . ' VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
?, ?, ?)');
+
+ $params = array
+ (
+ (int) $ticket['ticket_group'],
+ (int) $ticket['ticket_priority'],
+ 0, //(int) $ticket['ticket_reported_by'],
+ (int) $ticket['ticket_assignedto'],
+
$this->db->db_addslashes($ticket['ticket_subject']),
+ 0,//(int) $ticket['ticket_category'],
+ (float) $ticket['ticket_billable_hours'],
+ (float) $ticket['ticket_billable_rate'],
+ 'O',
+ (int) $ticket['ticket_deadline'],
+
$this->db->db_addslashes($ticket['ticket_effort']),
+ (isset($ticket['ticket_type']) ? (int)
$ticket['ticket_type'] : 0),
+
$this->db->db_addslashes($ticket['ticket_details']),
+ $lastmod,
+ (int)
$GLOBALS['phpgw_info']['user']['account_id']
+ );
+
+ if ( $GLOBALS['phpgw']->db->adodb->Execute($sql,
$params) !== false )
+ {
+ $ticket_id =
$GLOBALS['phpgw']->db->adodb->Insert_ID();
+ $ticket['ticket_id'] = $ticket_id;
+
+ $this->_save_custom($ticket['ticket_type'],
$ticket);
+
+ error_log("bo_tts:save: saved -> $ticket_id");
+ //added optional parameter to avoid
historylog-entries due sync-addition
+ if ($dohistorylog)
+ {
+ $this->historylog->add('O', $ticket_id,
'', time());
+ }
+ }
+ else
+ {
+ echo "ERROR: sql == $sql<br />\nmessage: " .
$GLOBALS['phpgw']->db->adodb->ErrorMsg();
+ }
+
+ return $ticket_id;
+ }
+
+ function search()
+ {
+
+ }
+
+ /**
+ * Update an existing ticket
+ *
+ * @param int $ticket_id the ticket id
+ * @param array $params the values of the ticket
+ * @return int the ticket number, 0 == failure
+ */
+ function update($ticket_id, $params)
+ {
+ $ticket_id = (int) $ticket_id;
+ if ( $ticket_id <= 0 )
+ {
+ return 0; //invalid ticket
+ }
+
+ $ticket = $this->get_ticket($ticket_id);
+
+ if ( !count($ticket) )
+ {
+ return 0;//ticket not found/available
+ }
+
+ $ticket_fields =
$this->get_fields($ticket['ticket_type']);
+ if ( !count($ticket_fields) )
+ {
+ return 0; //no fields - invalid type
+ }
+
+ //die('<pre>fields:' . print_r($ticket_fields, true) .
'</pre>current values<pre>' . print_r($ticket, true) . '</pre>new values<pre>'
. print_r($params, true) . '</pre>');
+
+ // Make sure it is a single transaction
+ $this->historylog->db = &$this->db;
+ $this->db->transaction_begin();
+
+ //stop empty notes being added
+ if ( trim($params['ticket_details']) == '' )
+ {
+ unset($params['ticket_details']);
+ }
+
+ $vals = array();
+ foreach ( $ticket_fields as $field )
+ {
+ if ( isset($params[$field['id']])
+ && $ticket[$field['id']] !=
$params[$field['id']]
+ && $field['id'] != 'ticket_status' )
+ {
+
$this->historylog->add($field['change_key'], $ticket_id, $params[$field['id']],
$ticket[$field['id']]);
+ $vals[$field['id']] =
$params[$field['id']];
+ }
+ }
+
+ if ( isset($_FILES['attachment']) &&
$_FILES['attachment']['name'] != '')
+ {
+ $fields_updated = true;
+ $attdir = "/tts/$ticket_id";
+ $basedir = $GLOBALS['basedir'] . "/tts";
+
+ if (!file_exists($basedir . "/" . $attdir))
+ {
+ $GLOBALS['phpgw']->vfs->override_acl =
1;
+ $GLOBALS['phpgw']->vfs->mkdir (array (
+ 'string' => $attdir,
+ 'relatives' => array
(RELATIVE_ALL)));
+ $GLOBALS['phpgw']->vfs->override_acl =
0;
+ }
+ //FIXME do this properly
+ $vfs->override_acl = 1;
+ $vfs->cp(array
+ (
+ 'from' =>
$_FILES['attachment']['tmp_name'],
+ 'to' => $attdir . '/' .
$_FILES['attachment']['name'],
+ 'relatives' => array
(RELATIVE_NONE|VFS_REAL, RELATIVE_ALL))
+ );
+ $vfs->override_acl = 0;
+
+
$this->historylog->add('M',$ticket_id,$_FILES['attachment']['name'],'');
+ }
+
+ if($params['ticket_status'] != $ticket['ticket_status'])
+ {
+ //only allow assigned-to or admin members to
close tickets
+ if (
$GLOBALS['phpgw_info']['user']['account_id'] == $ticket['ticket_assignedto']
+ ||
isset($GLOBALS['phpgw_info']['user']['apps']['admin']) )
+ {
+
$GLOBALS['phpgw']->historylog->add($param['ticket_status'], $ticket_id,
$ticket['ticket_status'], $param['ticket_status']);
+ $vals['ticket_status'] =
$param['ticket_status'];
+ }
+ else
+ {
+ $messages .= '<br>You can only close a
ticket if it is assigned to you.';
+
$GLOBALS['phpgw']->session->appsession('messages','tts',lang($messages));
+ }
+ }
+
+
+ if ( count($vals) )
+ {
+ $vals['lastmod'] = time();
+ $vals['lastmod_user'] =
$GLOBALS['phpgw_info']['user']['account_id'];
+
+
$this->db->adodb->AutoExecute('phpgw_tts_tickets', $vals, 'UPDATE', 'ticket_id
= ' . (int)$ticket_id, true, get_magic_quotes_gpc());
+ $this->_save_custom($ticket['ticket_type'],
$params);
+
+ // Do this before we go into mail_ticket()
+ $GLOBALS['phpgw']->db->transaction_commit();
+
+
$GLOBALS['phpgw']->session->appsession('messages','tts',lang('Ticket has been
updated'));
+
+ $GLOBALS['phpgw']->config =
createObject('phpgwapi.config', 'tts');
+
if($GLOBALS['phpgw']->config->config_data['mailnotification'])
+ {
+ mail_ticket($ticket_id);
+ }
+ }
+
+ }
+
+ /**
+ * Get a list of groups
+ *
+ * @return array list of groups
+ */
+ function _get_groups()
+ {
+ $groups = array();
+ $accts = createObject('phpgwapi.accounts');
+ foreach ( $accts->get_list('groups') as $group )
+ {
+ $groups[] = array
+ (
+ 'id' => $group['account_id'],
+ 'value' =>
$GLOBALS['phpgw']->common->display_fullname($group['account_id'],
$group['account_firstname'], $group['account_lastname'])
+ );
+ }
+ return $groups;
+ }
+
+ /**
+ * Get a list of available priorities
+ *
+ * @return array the priorities
+ */
+ function _get_priorities()
+ {
+ return array
+ (
+ array('id' => '0', 'value' => lang('none')),
+ array('id' => '1', 'value' => '1 - ' .
lang('lowest')),
+ array('id' => '2', 'value' => '2'),
+ array('id' => '3', 'value' => '3'),
+ array('id' => '4', 'value' => '4'),
+ array('id' => '5', 'value' => '5 - ' .
lang('medium')),
+ array('id' => '6', 'value' => '6'),
+ array('id' => '7', 'value' => '7'),
+ array('id' => '8', 'value' => '8'),
+ array('id' => '9', 'value' => '9'),
+ array('id' => '10', 'value' => '10 - ' .
lang('highest'))
+ );
+ }
+
+ /**
+ * Get a list of available stati
+ *
+ * @return array the stati
+ */
+ function _get_stati()
+ {
+ return array
+ (
+ array('id' => 'O', 'value' => lang('open')),
+ array('id' => 'X', 'value' => lang('closed')),
+ );
+ }
+
+ /**
+ * Get a list of users who have edit access to a ticket type
+ *
+ * @param int $cat_id the category to check
+ * @return array list of users
+ */
+ function _get_users($cat_id)
+ {
+ $users = array();
+ $grants =
$GLOBALS['phpgw']->acl->get_ids_for_location("C{$cat_id}", PHPGW_ACL_EDIT,
'tts');
+ if ( is_array($grants ) && count($grants) )
+ {
+ foreach ( $grants as $uid )
+ {
+ if (
$GLOBALS['phpgw']->accounts->get_type($uid) == 'g' )
+ {
+
$GLOBALS['phpgw']->accounts->account_id = $uid;
+ $accts =
$GLOBALS['phpgw']->accounts->get_members();
+ foreach ( $accts as $acct )
+ {
+ $users[] = array('id'
=> $acct, 'value' => $GLOBALS['phpgw']->accounts->id2name($acct));
+ }
+ }
+ else
+ {
+ $users[] = array('id' => $uid,
'value' => $GLOBALS['phpgw']->accounts->id2name($uid));
+ }
+ }
+ }
+ return $users;
+ }
+
+ //FIXME make this work again and use phpmailer
+ function _mail_ticket($ticket_id)
+ {
+ return ;
+ // $GLOBALS['phpgw']->preferences->read_repository();
+ //
$GLOBALS['phpgw_info']['user']['preferences']['tts']['mailnotification']
+
+ $GLOBALS['phpgw']->config->read_repository();
+
+ if
($GLOBALS['phpgw']->config->config_data['mailnotification'])
+ {
+ $GLOBALS['phpgw']->send =
CreateObject('phpgwapi.send');
+
+ $this->db->query('select
t_id,t_category,t_detail,t_priority,t_user,t_assignedto,'
+ . "t_timestamp_opened,
t_timestamp_closed, t_subject from phpgw_tts_tickets where
t_id='".$ticket_id."'",__LINE__,__FILE__);
+ $this->db->next_record();
+
+ $group = $this->db->f('t_category');
+
+ // build subject
+ $subject = "[TTS {$group} #{$ticket_id}] "
+ .
(!$this->db->f('t_timestamp_closed')? lang('updated') : lang('closed') )
+ . ': ' .
$this->db->f('t_subject', true);
+
+ // build body
+ $body = '';
+ $body .= 'TTS #'.$ticket_id."\n\n";
+ $body .= 'Subject:
'.$this->db->f('t_subject')."\n\n";
+ $body .= 'Assigned To:
'.$this->db->f('t_assignedto')."\n\n";
+ $body .= 'Priority: ' .
$this->db->f('t_priority') . "\n\n";
+ $body .= 'Group: ' . $group."\n\n";
+ $body .= 'Opened By: ' .
$this->db->f('t_user')."\n";
+ $body .= 'Date Opened:
'.$GLOBALS['phpgw']->common->show_date($this->db->f('t_timestamp_opened'))."\n\n";
+ if($this->db->f('t_timestamp_closed'))
+ {
+ $body .= 'Date Closed:
'.$GLOBALS['phpgw']->common->show_date($this->db->f('t_timestamp_closed'))."\n\n";
+ }
+ $body .=
stripslashes(strip_tags($this->db->f('t_detail')))."\n\n.";
+
+ $members = array();
+ if
($GLOBALS['phpgw']->config->config_data['groupnotification'])
+ {
+ // select group recipients
+ $group_id =
$GLOBALS['phpgw']->accounts->name2id($group);
+ $members =
$GLOBALS['phpgw']->accounts->members($group_id);
+ }
+
+ if
($GLOBALS['phpgw']->config->config_data['ownernotification'])
+ {
+ // add owner to recipients
+ $members[] = array('account_id' =>
$GLOBALS['phpgw']->accounts->name2id($this->db->f('t_user')), 'account_name' =>
$this->db->f('t_user'));
+ }
+
+ if
($GLOBALS['phpgw']->config->config_data['assignednotification'])
+ {
+ // add assigned to recipients
+ $members[] = array('account_id' =>
$GLOBALS['phpgw']->accounts->name2id($this->db->f('t_assignedto')),
'account_name' => $this->db->f('t_assignedto'));
+ }
+
+ $toarray = Array();
+ $i=0;
+ for ($i=0;$i<count($members);$i++)
+ {
+ if ($members[$i]['account_id'])
+ {
+ $prefs =
$GLOBALS['phpgw']->preferences->create_email_preferences($members[$i]['account_id']);
+
$toarray[$prefs['email']['address']] = $prefs['email']['address'];
+ }
+ }
+ if(count($toarray) > 1)
+ {
+ @reset($toarray);
+ $to = implode(',',$toarray);
+ }
+ else
+ {
+ $to = current($toarray);
+ }
+
+ $rc = $GLOBALS['phpgw']->send->msg('email',
$to, $subject, stripslashes($body), '', $cc, $bcc);
+ if (!$rc)
+ {
+ echo 'Your message could <B>not</B> be
sent!<BR>'."\n"
+ . 'The mail server
returned:<BR>'
+ . "err_code:
'".$GLOBALS['phpgw']->send->err['code']."';<BR>"
+ . "err_msg:
'".htmlspecialchars($GLOBALS['phpgw']->send->err['msg'])."';<BR>\n"
+ . "err_desc:
'".$GLOBALS['phpgw']->err['desc']."'.<P>\n"
+ . 'To go back to the msg list,
click <a href="'.$GLOBALS['phpgw']->link('/tts/index.php','cd=13').'">here</a>';
+ $GLOBALS['phpgw']->common->phpgw_exit();
+ }
+ }
+ }
+
+ function _record_view($id)
+ {
+ // Have they viewed this ticket before ?
+ $this->db->query('SELECT COUNT(view_id) AS cnt_views
FROM phpgw_tts_views'
+ . " WHERE view_id=$id"
+ . " AND
view_account_id={$GLOBALS['phpgw_info']['user']['account_id']}", __LINE__,
__FILE__);
+ $this->db->next_record();
+
+ if(!$this->db->f('cnt_views'))
+ {
+ $this->db->query('INSERT INTO phpgw_tts_views'
+ . " VALUES ({$id},
{$GLOBALS['phpgw_info']['user']['account_id']}, " . time() . ')', __LINE__,
__FILE__);
+ }
+ }
+
+ /**
+ * Save the custom field values for a ticket
+ */
+ function _save_custom($ttype, $values)
+ {
+ $tbl_name = 'phpgw_tts_c' . $ttype;
+ if ( $this->db->adodb->getOne("SELECT COUNT(ticket_id)
FROM $tbl_name WHERE ticket_id = {$values['ticket_id']}") > 0 )
+ {
+ $this->db->adodb->autoExecute($tbl_name,
$values, 'UPDATE', 'ticket_id = ' . (int)$values['ticket_id'], false,
get_magic_quotes_gpc() );
+ }
+ else //is new
+ {
+
$this->db->adodb->Execute($this->db->adodb->GetInsertSQL($tbl_name, $values,
get_magic_quotes_gpc() ) );
+ // auto execute is broken :(
+ //$this->db->adodb->autoExecute('phpgw_tts_c' .
$ttype, $values, 'INSERT', null, true, get_magic_quotes_gpc() );
+ }
+ }
+
+ /**
+ * Translates custom field types into html form element types
+ */
+ function _translate_cust_type($dt)
+ {
+ switch (strtolower($dt) )
+ {
+ case 'lb':
+ case 'r':
+ return 'select';
+
+ case 'd':
+ return 'date';
+
+ case 't':
+ return 'memo';
+
+ case 'v':
+ case 'i':
+ case 'c':
+ case 'f':
+ case 'email':
+ case 'link':
+ default:
+ return 'textbox';
+ }
+ }
+ }
+?>
Index: inc/class.tts_bo_hooks.inc.php
===================================================================
RCS file: inc/class.tts_bo_hooks.inc.php
diff -N inc/class.tts_bo_hooks.inc.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ inc/class.tts_bo_hooks.inc.php 14 Oct 2006 05:39:41 -0000 1.1
@@ -0,0 +1,79 @@
+<?php
+ /**
+ * TTS Hooks Manager
+ * @author Dave Hall - skwashd at phpgroupware.org
+ * @copyright Copyright (C) 2006 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @package tts
+ * @version $Id: class.tts_bo_hooks.inc.php,v 1.1 2006/10/14 05:39:41
skwashd Exp $
+ */
+
+ /**
+ * Centralise hook management to make life a little easier
+ *
+ * @package tts
+ */
+ class tts_bo_hooks
+ {
+
+ /**
+ * Handle a new category being added, namely to create the
required location
+ * and db table for custom fields
+ */
+ function cat_add($cat_data)
+ {
+ if ( isset($cat_data['cat_owner']) &&
$cat_data['cat_owner'] != -1 )
+ {
+ return false; //nothing needed to be done, we
only care about global cats
+ }
+
$GLOBALS['phpgw']->acl->add_location("C{$cat_data['cat_id']}", lang('ticket
type: %1', $cat_data['cat_name']), 'tts', true,
"phpgw_tts_c{$cat_data['cat_id']}");
+
+ // we interupt your normal programming for this special
annoucement
+ $hon = $GLOBALS['phpgw']->db->Halt_On_Error;
+ $GLOBALS['phpgw']->db->Halt_On_Error = 'report';
+
+ $oProc =
CreateObject('phpgwapi.schema_proc',$GLOBALS['phpgw_info']['server']['db_type']);
+ $oProc->m_odb =& $GLOBALS['phpgw']->db;
+
+ $oProc->CreateTable("phpgw_tts_c{$cat_data['cat_id']}",
array
+ (
+ 'fd' => array
+ (
+ 'ticket_id' => array('type' =>
'int', 'precision' => 4, 'nullable' => false)
+ ),
+ 'pk' => array('ticket_id'),
+ 'fk' => array(),
+ 'ix' => array(),
+ 'uc' => array()
+ ));
+
+ // we now return you to your normal prograaming
+ $GLOBALS['phpgw']->db->Halt_On_Error = $hon;
+ }
+
+ /**
+ * Handle a category being deleted, namely to remove the
location
+ * and table for custom fields
+ */
+ function cat_delete($cat_data)
+ {
+ if ( isset($cat_data['cat_owner']) &&
$cat_data['cat_owner'] != -1 )
+ {
+ return false; //nothing needed to be done, we
only care about global cats
+ }
+ //TODO add code here to delete the ticket types and to
clean up the ACL table
+ }
+
+ /**
+ * Handle a category being editted, namely to update the
location info
+ */
+ function cat_edit($cat_data)
+ {
+ if ( isset($cat_data['cat_owner']) &&
$cat_data['cat_owner'] != -1 )
+ {
+ return false; //nothing needed to be done, we
only care about global cats
+ }
+
$GLOBALS['phpgw']->acl->update_location_description("C{$cat_data['cat_id']}",
lang('ticket type: %1', $cat_data['cat_name']), 'tts');
+ }
+ }
+?>
Index: inc/class.uitts.inc.php
===================================================================
RCS file: inc/class.uitts.inc.php
diff -N inc/class.uitts.inc.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ inc/class.uitts.inc.php 14 Oct 2006 05:39:41 -0000 1.1
@@ -0,0 +1,1150 @@
+<?php
+ /**
+ * Trouble Ticket System
+ *
+ * @copyright Copyright (C) 2000-2006 Free Software Foundation, Inc.
http://www.fsf.org/
+ * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
+ * @package tts
+ * @version $Id: class.uitts.inc.php,v 1.1 2006/10/14 05:39:41 skwashd
Exp $
+ */
+
+ class uitts
+ {
+ /**
+ * @var object $bo reference to the tts business logic class
+ */
+ var $bo;
+
+ /**
+ * var object $historylog reference the history log obejct
+ */
+ var $historylog;
+
+ /**
+ * @var array $public_functions the publicly accessible methods
of the class
+ */
+ var $public_functions = array
+ (
+ 'add_ticket' => true,
+ 'edit_ticket' => true,
+ 'get_cats' => true,
+ 'get_users' => true,
+ 'index' => true,
+ 'view' => true
+ );
+
+ /**
+ * @var object $t refernce to global template object
+ */
+ var $t;
+
+ /**
+ * @constructor
+ */
+ function uitts()
+ {
+ $this->bo = createObject('tts.botts');
+
+ $this->historylog =& $this->bo->historylog;
+
+ $this->t =& $GLOBALS['phpgw']->template;
+ $this->t->set_root(PHPGW_APP_TPL);
+ }
+
+ /**
+ * Add a new trouble ticket
+ */
+ function add_ticket()
+ {
+ if ( $_SERVER['REQUEST_METHOD'] == 'GET' )
+ {
+ //FIXME switch to XSLT here
+ $this->t->set_file('type_select',
'type_select.tpl');
+ $this->t->set_block('type_select',
'type_options', 'options');
+
+ $cats = createObject('phpgwapi.categories',
$GLOBALS['phpgw_info']['user']['account_id'], 'tts');
+ $cat_list = $cats->return_array('all', 0,
false, '', 'ASC', 'cat_name', false);
+ foreach ( $cat_list as $cat )
+ {
+ if ( $GLOBALS['phpgw']->acl->check('C'
. $cat['id'], PHPGW_ACL_ADD, 'tts') )
+ {
+ $this->t->set_var($cat);
+ $this->t->parse('options',
'type_options', true);
+ }
+ }
+ $GLOBALS['phpgw']->common->phpgw_header(true);
+
+ $this->t->set_var(array
+ (
+ 'lang_cancel' =>
lang('cancel'),
+ 'lang_next' =>
htmlspecialchars(lang('next >')),
+ 'lang_ticket_type' => lang('ticket
type'),
+ 'url_form_action' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'tts.uitts.add_ticket', 'id' => 0))
+ ));
+
+ $this->t->pfp('out','type_select');
+
+ $GLOBALS['phpgw']->common->phpgw_exit(true);
+ }
+ elseif ( $_SERVER['REQUEST_METHOD'] == 'POST' )
+ {
+ if ( !isset($_POST['ticket_type'])
+ || !$GLOBALS['phpgw']->acl->check('C' .
(int) $_POST['ticket_type'], PHPGW_ACL_ADD, 'tts') )
+ {
+ $this->_access_denied();
+ }
+
+ if ( isset($_POST['next']) && $_POST['next'] )
+ {
+ $ticket = array
+ (
+ 'ticket_id' => 0,
+ 'ticket_type' => (int)
$_REQUEST['ticket_type']
+ );
+
+ $this->_render_add_form($ticket);
+
$GLOBALS['phpgw']->common->phpgw_footer();
+ exit;
+ }
+ elseif ( isset($_POST['submit']) &&
$_POST['submit'] )
+ {
+ $id = $this->bo->save($_POST);
+ if ($id > 0)
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'tts.uitts.view', 'ticket_id' => $id));
+ }
+ die('oh shit!');
+ }
+ elseif ( isset($_POST['cancel']) &&
$_POST['cancel'] )
+ {
+
$GLOBALS['phpgw']->redirect_link('/tts/index.php');
+ }
+ }
+ die('invalid request');
+ }
+
+ function edit_ticket()
+ {
+ }
+
+
+ function get_users()
+ {
+ Header('Content-Type: text/javascript; charset=utf-8');
+ $group_id = (int) $_GET['group_id'];
+ $accounts = createObject('phpgwapi.accounts');
+ $members = $accounts->member($group_id);
+ $json = createObject('phpgwapi.Services_JSON');
+ echo $json->encode($members);
+ exit;
+ }
+
+ /**
+ * Display the index listing
+ */
+ function index()
+ {
+ if ( !isset($GLOBALS['phpgw']->js) ||
!is_object($GLOBALS['phpgw']->js) )
+ {
+ $GLOBALS['phpgw']->js =
createObject('phpgwapi.javascript');
+ }
+ $js =& $GLOBALS['phpgw']->js;
+ $js->validate_file('core', 'base');
+ $js->validate_file('sortabletable', 'sortabletable');
+ $js->validate_file('tabs', 'tabs');
+ $js->validate_file('yahoo', 'yahoo');
+ $js->validate_file('yahoo', 'dom');
+ $js->validate_file('yahoo', 'event');
+ $js->validate_file('yahoo', 'dragdrop');
+ $js->validate_file('yahoo', 'connection');
+ $js->validate_file('yahoo', 'container');
+ $js->validate_file('base', 'index', 'tts');
+
+ $js->add_event('load', 'ttsIndexOnLoad()');
+
+ if ( !isset($GLBOALS['phpgw_info']['flags']['css']) )
+ {
+ $GLOBALS['phpgw_info']['flags']['css'] = '';
+ }
+ $GLOBALS['phpgw_info']['flags']['css'] = "@import
url('rostering/templates/base/css/base.css');\n";
+
+ $this->t->set_file('index','index.tpl');
+ $this->t->set_block('index', 'tts_search',
'tts_search');
+ //$this->t->set_block('index', 'tts_col_ifviewall',
'tts_col_ifviewall');
+ //$this->t->set_block('index', 'tts_ticket_id_read',
'tts_ticket_id_read');
+ //$this->t->set_block('index', 'tts_ticket_id_unread',
'tts_ticket_id_unread');
+
+ $this->t->set_file('list', 'list.tpl');
+ $this->t->set_block('list', 'tts_row', 'tts_rows');
+
+ $this->t->set_var(
+ array
+ (
+ 'img_goto' =>
$GLOBALS['phpgw']->common->image('phpgwapi', 'stock_jump_to', '.png', false),
+ 'img_new' =>
$GLOBALS['phpgw']->common->image('phpgwapi', 'stock_new', '.png', false),
+ 'img_prefs' =>
$GLOBALS['phpgw']->common->image('phpgwapi', 'settings', '.png', false),
+ 'img_search' =>
$GLOBALS['phpgw']->common->image('phpgwapi', 'stock_search', '.png', false),
+ 'lang_clear' => lang('clear'),
+ 'lang_close_ticket' => lang('close
ticket'),
+ 'lang_filter' => lang('filter'),
+ 'lang_find' => lang('find'),
+ 'lang_goto' => lang('go
to'),
+ 'lang_invalid' => lang('invalid ticket
id, please try again'),
+ 'lang_new' => lang('new'),
+ 'lang_open' => lang('open'),
+ 'lang_overdue' => lang('overdue'),
+ 'lang_preferences' =>
lang('preferences'),
+ 'lang_search' => lang('search'),
+ 'lang_ticket_no'=> lang('ticket
number'),
+ 'url_new_ticket'=>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'tts.uitts.add_ticket')),
+ 'url_prefs' =>
$GLOBALS['phpgw']->link('/preferences/preferences.php', array('appname' =>
'tts')),
+ 'url_search' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'tts.uitts.search')),
+ 'url_view' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'tts.uitts.view') ),
+ 'goto_action' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'tts.uitts.view') )
+ ));
+
+
+ $this->t->set_var('tts_searchfilter',
isset($_REQUEST['searchfilter']) ? $_REQUEST['searchfilter'] : '');
+
//$this->t->set_var('tts_numfound',lang('Tickets found %1',$numfound));
+
+ //$this->t->set_var('tts_ticketstotal',
lang('Tickets total %1',$numtotal));
+ //$this->t->set_var('tts_ticketsopen',
lang('Tickets open %1',$numopen));
+
+ $tickets =
$this->bo->list_tickets(array('filter_due_before' => time(), 'filter_status' =>
'open'));
+ $this->_render_list($tickets,
'tickets_overdue', 'overdue', 'overdue', 'overdue_list');
+
+ $tickets =
$this->bo->list_tickets(array('filter_status' => 'open'));
+ $this->_render_list($tickets, 'tickets_open',
'status', 'ticket', 'open_list');
+
+ $GLOBALS['phpgw']->common->phpgw_header(true);
+
+ $this->t->pfp('out','index');
+
+ $GLOBALS['phpgw']->common->phpgw_footer();
+ }
+
+ function view()
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] =
true;
+ if ( !isset($_REQUEST['ticket_id'])
+ || (isset($_POST['cancel']) &&
$_POST['cancel']) )
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'tts.uitts.index'));
+ }
+
+ if ( isset($_POST['submit']) &&
$_POST['submit'] )
+ {
+ $this->bo->update($_POST['ticket_id'],
$_POST);
+ }
+
+ if ( !isset($GLOBALS['phpgw']->js) ||
!is_object($GLOBALS['phpgw']->js) )
+ {
+ $GLOBALS['phpgw']->js =
createObject('phpgwapi.javascript');
+ }
+ $js =& $GLOBALS['phpgw']->js;
+ $js->validate_file('tabs', 'tabs');
+ $js->validate_file('base', 'view', 'tts');
+
+ $values = array
+ (
+ 'edit' => false,
+ 'history' => array(),
+ 'notes' => array(),
+ 'ticket' =>
$this->bo->get_ticket($_REQUEST['ticket_id']),
+ 'view' => array()
+ );
+
+ if ( count($values['ticket']['history']) )
+ {
+ $values['history'] =
$values['ticket']['history'];
+ }
+ unset($values['ticket']['history']);
+
+ if ( count($values['ticket']['notes']) )
+ {
+ $values['notes'] =
$values['ticket']['notes'];
+ }
+ unset($values['ticket']['notes']);
+
+ //echo '<pre>' . print_r($values['ticket'],
true) . '</pre>';
+
+ if ( !$GLOBALS['phpgw']->acl->check('C' . (int)
$values['ticket']['ticket_type'], PHPGW_ACL_READ, 'tts') )
+ {
+
$GLOBALS['phpgw']->redirect_link('/index.php', array('menuaction' =>
'tts.uitts.index'));
+ }
+
+ if ( $GLOBALS['phpgw']->acl->check('C' . (int)
$values['ticket']['ticket_type'], PHPGW_ACL_EDIT, 'tts') )
+ {
+ $values['edit'] = true;
+ }
+
+ $fields =
$this->bo->get_fields($values['ticket']['ticket_type']);
+ foreach ( $fields as $key => $field )
+ {
+ switch ( $field['type'] )
+ {
+ case 'hidden':
+ $fields[$key]['value']
= $values['ticket'][$field['id']];
+ continue; //ignore it
+ case 'select':
+ $values['view'][] =
array
+ (
+ 'label' =>
$field['label'],
+ 'value' =>
$this->_get_selection($values['ticket'][$field['id']], $field['options'])
+ );
+
$fields[$key]['selected'] = $values['ticket'][$field['id']];
+ break;
+ default:
+ $values['view'][] =
array
+ (
+ 'label' =>
$field['label'],
+ 'value' =>
$values['ticket'][$field['id']]
+ );
+ $fields[$key]['value']
= $values['ticket'][$field['id']];
+ }
+ }
+
+ if ( $values['edit'] )
+ {
+ $values['form_elements'] =
array('form_elm' => $fields);
+ }
+ unset($fields);
+
+
$GLOBALS['phpgw']->xslttpl->add_file('viewticket_details');
+ $ui = createObject('phpgwapi.ui_tools');
+
+
+ $values['form_action'] =
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'tts.uitts.view'));
+ $values['lang'] = array
+ (
+ 'action' => lang('action'),
+ 'close' => lang('close'),
+ 'date' => lang('date'),
+ 'history' => lang('history'),
+ 'new_value' => lang('new value'),
+ 'no_history'=> lang('no history
available'),
+ 'no_rights' => lang('you do not
have the required rights to edit this ticket'),
+ 'notes' => lang('notes'),
+ 'old_value' => lang('old value'),
+ 'save' => lang('save'),
+ 'status' => lang('status'),
+ 'summary' => lang('summary'),
+ 'update' => lang('update'),
+ 'user' => lang('user')
+ );
+
+ unset($values['ticket']);
+
+ $GLOBALS['phpgw']->xslttpl->set_var('phpgw',
array('view_ticket' => $values));
+ $GLOBALS['phpgw']->common->phpgw_exit(true);
+
+
$this->t->set_file('viewticket','viewticket_details.tpl');
+
$this->t->set_block('viewticket','options_select');
+
$this->t->set_block('viewticket','additional_notes_row');
+
$this->t->set_block('viewticket','additional_notes_row_empty');
+ $this->t->set_block('viewticket','row_history');
+
$this->t->set_block('viewticket','row_history_empty');
+ $this->t->set_block('viewticket','form');
+
+ $messages =
$GLOBALS['phpgw']->session->appsession('messages','tts');
+ if ( strlen($messages) )
+ {
+ $this->t->set_var('messages',$messages);
+
$GLOBALS['phpgw']->session->appsession('messages','tts','');
+ }
+
+ if ( $ticket['ticket_status'] == 'C')
+ {
+ $this->t->set_var('t_status','FIX ME!
time closed ' . __LINE__);
+ }
+ else
+ {
+ $this->t->set_var('t_status', lang('In
progress'));
+ }
+
+ // Choose the correct priority to display
+ $priority_selected[$ticket['ticket_priority']]
= '';
+ $priority_comment = array
+ (
+ '',
+ ' - ' . lang('Lowest'),
+ '',
+ '',
+ '',
+ ' - '.lang('Medium'),
+ '',
+ '',
+ '',
+ '',
+ ' - '.lang('Highest')
+ );
+
+ for ( $i = 1; $i <= 10; ++$i )
+ {
+ $this->t->set_var('optionname',
"{$i}{$priority_comment[$i]}");
+ $this->t->set_var('optionvalue', $i);
+ $this->t->set_var('optionselected',
isset($priority_selected[$i]) ? ' selected' : '');
+
$this->t->parse('options_priority','options_select',true);
+ }
+
+ // assigned to
+ $accounts = CreateObject('phpgwapi.accounts');
+ $account_list = $accounts->get_list('accounts');
+ $this->t->set_var('optionname',lang('None'));
+ $this->t->set_var('optionvalue','0');
+ $this->t->set_var('optionselected','');
+
$this->t->parse('options_assignedto','options_select',true);
+
+ while(list($key,$entry) = each($account_list))
+ {
+ $lid = $fname = $lname = '';
+
$GLOBALS['phpgw']->accounts->get_account_name($entry['account_id'], $lid,
$fname, $lname);
+
+ if(!$fname && !$lname)
+ {
+ continue;
+ }
+
+ $employees_list[$entry['account_id']] =
$GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname);
+
+ if(count($employees_list))
+ {
+ asort($employees_list);
+ reset($employees_list);
+ }
+ }
+
+ while (list($account_id,$account_name) =
each($employees_list))
+ {
+ $selected = '';
+ if ($account_id ==
$ticket['ticket_assignedto'])
+ {
+ $selected = 'selected';
+ }
+ $this->t->set_var('optionname',
$account_name);
+ $this->t->set_var('optionvalue',
$account_id);
+ $this->t->set_var('optionselected',
$selected);
+
$this->t->parse('options_assignedto','options_select',True);
+ }
+
+
+ // Figure out when it was opened and last closed
+ $history_array =
$this->bo->historylog->return_array(array(),array('X','O'),'','',$_REQUEST['ticket_id']);
+
+ while(is_array($history_array) && list(,$value)
= each($history_array))
+ {
+ if($value['status'] == 'O')
+ {
+ $ticket['opened'] =
$GLOBALS['phpgw']->common->show_date($value['datetime'] - ((60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']));
+ }
+
+ if($value['status'] == 'X')
+ {
+ $ticket['closed'] =
$GLOBALS['phpgw']->common->show_date($value['datetime'] - ((60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']));
+ }
+ }
+
+ // group
+
+ $group_list = array();
+ $group_list =
$GLOBALS['phpgw']->accounts->membership($GLOBALS['phpgw_info']['user']['account_id']);
+
+ while(list($key,$entry) = each($group_list))
+ {
+ $tag = '';
+ if($entry['account_id'] ==
$ticket['ticket_group'])
+ {
+ $tag = 'selected';
+ }
+ $this->t->set_var('optionname',
$entry['account_name']);
+ $this->t->set_var('optionvalue',
$entry['account_id']);
+ $this->t->set_var('optionselected',
$tag);
+
$this->t->parse('options_group','options_select',true);
+ }
+
+ $this->t->set_var('options_category',
$this->bo->cats->formated_list('select','',$ticket['category'],False));
+
+ $ticket_status[$ticket['status']] = ' selected';
+ $s = '<option value="O"' . $ticket_status['O']
. '>' . lang('Open') . '</option>';
+ $s .= '<option value="X"' . $ticket_status['X']
. '>' . lang('Closed') . '</option>';
+
+ $this->t->set_var('options_status',$s);
+ $this->t->set_var('lang_status',lang('Status'));
+
+
/**************************************************************\
+ * Display additional notes
*
+
\**************************************************************/
+ $history_array =
$this->bo->historylog->return_array(array(),array('C'),'','',$ticket_id);
+ while(is_array($history_array) && list(,$value)
= each($history_array))
+ {
+
$this->t->set_var('lang_date',lang('Date'));
+
$this->t->set_var('lang_user',lang('User'));
+
+
$this->t->set_var('value_date',$GLOBALS['phpgw']->common->show_date($value['datetime']
- ((60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'])));
+
$this->t->set_var('value_user',$value['owner']);
+
+
$this->t->set_var('value_note',nl2br(htmlspecialchars($value['new_value'])));
+
$this->t->fp('rows_notes','additional_notes_row',True);
+ }
+
+ if(!count($history_array))
+ {
+
$this->t->set_var('lang_no_additional_notes',lang('No additional notes'));
+
$this->t->fp('rows_notes','additional_notes_row_empty',True);
+ }
+
+
/**************************************************************\
+ * Display record history
*
+
\**************************************************************/
+ $this->t->set_var('lang_user',lang('User'));
+ $this->t->set_var('lang_date',lang('Date'));
+ $this->t->set_var('lang_action',lang('Action'));
+ $this->t->set_var('lang_new_value',lang('New
Value'));
+ $this->t->set_var('lang_old_value',lang('Old
Value'));
+
+ $history_array =
$this->historylog->return_array(array('C'),array(),'','',$ticket_id);
+ while(is_array($history_array) && list(,$value)
= each($history_array))
+ {
+
$GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($GLOBALS['phpgw']->template);
+
+
$this->t->set_var('value_date',$GLOBALS['phpgw']->common->show_date($value['datetime']
- ((60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'])));
+
$this->t->set_var('value_user',$value['owner']);
+ $this->t->set_var('value_action',
$this->historylog->types[$value['status']]);
+
+ if($value['status'] == 'A')
+ {
+ if(!$value['new_value'])
+ {
+
$this->t->set_var('value_new_value',lang('None'));
+ }
+ else
+ {
+
$this->t->set_var('value_new_value',$GLOBALS['phpgw']->accounts->id2name($value['new_value']));
+ }
+
+ if(!$value['old_value'])
+ {
+
$this->t->set_var('value_old_value',lang('None'));
+ }
+ else
+ {
+
$this->t->set_var('value_old_value',$GLOBALS['phpgw']->accounts->id2name($value['old_value']));
+ }
+ }
+ elseif($value['status'] == 'T')
+ {
+
$this->t->set_var('value_new_value',$GLOBALS['phpgw']->categories->id2name($value['new_value']));
+
$this->t->set_var('value_old_value',$GLOBALS['phpgw']->categories->id2name($value['old_value']));
+ }
+ elseif($value['status'] == 'L')
+ {
+
$this->t->set_var('value_new_value',$GLOBALS['phpgw']->categories->id2name($value['new_value']));
+
$this->t->set_var('value_old_value',$GLOBALS['phpgw']->categories->id2name($value['old_value']));
+ }
+ elseif($value['status'] == 'G')
+ {
+ $s =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+ $s = ($s ? $s : '--');
+
$this->t->set_var('value_new_value',$s);
+
+ $s =
$GLOBALS['phpgw']->accounts->id2name($value['old_value']);
+ $s = ($s ? $s : '--');
+
$this->t->set_var('value_old_value',$s);
+ }
+ elseif($value['status'] != 'O' &&
$value['new_value'])
+ {
+
$this->t->set_var('value_new_value',$value['new_value']);
+
$this->t->set_var('value_old_value',$value['old_value']);
+ }
+ else
+ {
+
$this->t->set_var('value_new_value',' ');
+
$this->t->set_var('value_old_value',' ');
+ }
+
+
$this->t->fp('rows_history','row_history',True);
+ }
+
+ if(!count($history_array))
+ {
+
$this->t->set_var('lang_no_history',lang('No history for this record'));
+
$this->t->fp('rows_history','row_history_empty',True);
+ }
+
+ for($i=0; $i <= $x-1; $i++)
+ {
+ $file =
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'tts.attachedFiles.show_file',
+
'file' =>
$ticket['attachment'][$i]
+
));
+ $attLink .= "<a href=\"" . $file . "\"
target=\"_NEW\">" . basename($ticket['attachment'][$i]) . " </a><br>";
+ }
+
$this->t->set_var('lang_attachment',lang('Attachment'));
+ $this->t->set_var('value_attachment',$attLink);
+
+
$this->t->set_var('lang_billable_hours_total',lang('Total billable'));
+
$this->t->set_var('value_billable_hours_total',sprintf('%01.2f',($ticket['billable_hours']
* $ticket['billable_rate'])));
+
+
$this->t->set_var('lang_assignedto',lang('Assigned to'));
+ if($ticket['ticket_assignedto'])
+ {
+ $assignedto =
$GLOBALS['phpgw']->accounts->id2name($ticket['assignedto']);
+ }
+ else
+ {
+ $assignedto = lang('None');
+ }
+
$this->t->set_var('value_assignedto',$assignedto);
+
+ $s =
$GLOBALS['phpgw']->accounts->id2name($ticket['group']);
+ $s = ($s ? $s : '--');
+ $this->t->set_var('value_group',$s);
+
+ $this->t->set_var(array
+ (
+ 'currency' =>
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
+ 'lang_additional_notes' =>
lang('additional notes'),
+ 'lang_assignedfrom' =>
lang('assigned from'),
+ 'lang_billable_hours'=> lang('billable
hours'),
+ 'lang_billable_hours_rate' =>
lang('billable rate'),
+ 'lang_category' =>
lang('category'),
+ 'lang_close' =>
lang('close'),
+ 'lang_deadline' =>
lang('deadline'),
+ 'lang_details' =>
lang('details'),
+ 'lang_effort' =>
lang('effort'),
+ 'lang_group' =>
lang('group'),
+ 'lang_history' =>
lang('history'),
+ 'lang_notes' =>
lang('notes'),
+ 'lang_opendate' => lang('open
date'),
+ 'lang_priority' =>
lang('priority'),
+ 'lang_type' =>
lang('type'),
+ 'lang_save' =>
lang('save'),
+ 'lang_subject' =>
lang('subject'),
+ 'lang_summary' =>
lang('summary'),
+ 'lang_update' =>
lang('update'),
+ 'ticket_id' =>
$ticket['ticket_id'],
+ 'url_close' =>
$GLOBALS['phpgw']->link('/tts/index.php'),
+ 'url_viewdetails' =>
$GLOBALS['phpgw']->link('/tts/viewticket_details.php'),
+ 'value_category' =>
$this->bo->cats->id2name($ticket['category']),
+ 'value_details' =>
nl2br(htmlspecialchars($ticket['details'])),
+ 'value_billable_hours_rate' =>
$ticket['billable_rate'],
+ 'value_billable_hours' =>
$ticket['billable_hours'],
+ 'value_deadline' =>
$ticket['deadline'],
+ 'value_effort' =>
$ticket['effort'],
+ 'value_opendate' =>
$ticket['opened'],
+ 'value_owner' =>
$GLOBALS['phpgw']->accounts->id2name($ticket['owner']),
+ 'value_platform' =>
$ticket['platform'],
+ 'value_priority' =>
$ticket['priority'],
+ 'value_subject' =>
htmlspecialchars($ticket['subject']),
+ 'value_type' =>
$ticket['type']
+ ));
+
+ $this->t->set_var('options_select','');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
" #{$ticket['ticket_id']} {$ticket['subject']}";
+
+ $GLOBALS['phpgw']->common->phpgw_header(true);
+
+ $this->t->pfp('out','form');
+ $GLOBALS['phpgw']->common->phpgw_footer();
+ }
+
+ function old_view()
+ {
+ if ( !isset($_REQUEST['ticket_id'])
+ || (isset($_POST['cancel']) &&
$_POST['cancel']) )
+ {
+ $GLOBALS['phpgw']->redirect_link('/index.php',
array('menuaction' => 'tts.uitts.index'));
+ }
+
+ $config = createObject('phpgwapi.config');
+ $config->read_repository();
+ if ( !( isset($_POST['submit']) && $_POST['submit']) )
+ {
+ if ( !isset($GLOBALS['phpgw']->js) ||
!is_object($GLOBALS['phpgw']->js) )
+ {
+ $GLOBALS['phpgw']->js =
createObject('phpgwapi.javascript');
+ }
+ $js =& $GLOBALS['phpgw']->js;
+ $js->validate_file('tabs', 'tabs');
+ $js->validate_file('base', 'view', 'tts');
+
+ $ticket =
$this->bo->get_ticket($_REQUEST['ticket_id']);
+
+ $edit = false;
+ if ( !$GLOBALS['phpgw']->acl->check('C' . (int)
$ticket['ticket_type'], PHPGW_ACL_EDIT, 'tts') )
+ {
+ $edit = true;
+ }
+
+ $fields =
$this->bo->get_fields($ticket['ticket_type']);
+
+
$this->t->set_file('viewticket','viewticket_details.tpl');
+
$this->t->set_block('viewticket','options_select');
+
$this->t->set_block('viewticket','additional_notes_row');
+
$this->t->set_block('viewticket','additional_notes_row_empty');
+ $this->t->set_block('viewticket','row_history');
+
$this->t->set_block('viewticket','row_history_empty');
+ $this->t->set_block('viewticket','form');
+
+ $messages =
$GLOBALS['phpgw']->session->appsession('messages','tts');
+ if ( strlen($messages) )
+ {
+ $this->t->set_var('messages',$messages);
+
$GLOBALS['phpgw']->session->appsession('messages','tts','');
+ }
+
+ if ( $ticket['ticket_status'] == 'C')
+ {
+ $this->t->set_var('t_status','FIX ME!
time closed ' . __LINE__);
+ }
+ else
+ {
+ $this->t->set_var('t_status', lang('In
progress'));
+ }
+
+ // Choose the correct priority to display
+ $priority_selected[$ticket['ticket_priority']]
= '';
+ $priority_comment = array
+ (
+ '',
+ ' - ' . lang('Lowest'),
+ '',
+ '',
+ '',
+ ' - '.lang('Medium'),
+ '',
+ '',
+ '',
+ '',
+ ' - '.lang('Highest')
+ );
+
+ for ( $i = 1; $i <= 10; ++$i )
+ {
+ $this->t->set_var('optionname',
"{$i}{$priority_comment[$i]}");
+ $this->t->set_var('optionvalue', $i);
+ $this->t->set_var('optionselected',
isset($priority_selected[$i]) ? ' selected' : '');
+
$this->t->parse('options_priority','options_select',true);
+ }
+
+ // assigned to
+ $accounts = CreateObject('phpgwapi.accounts');
+ $account_list = $accounts->get_list('accounts');
+ $this->t->set_var('optionname',lang('None'));
+ $this->t->set_var('optionvalue','0');
+ $this->t->set_var('optionselected','');
+
$this->t->parse('options_assignedto','options_select',true);
+
+ while(list($key,$entry) = each($account_list))
+ {
+ $lid = $fname = $lname = '';
+
$GLOBALS['phpgw']->accounts->get_account_name($entry['account_id'], $lid,
$fname, $lname);
+
+ if(!$fname && !$lname)
+ {
+ continue;
+ }
+
+ $employees_list[$entry['account_id']] =
$GLOBALS['phpgw']->common->display_fullname($lid,$fname,$lname);
+
+ if(count($employees_list))
+ {
+ asort($employees_list);
+ reset($employees_list);
+ }
+ }
+
+ while (list($account_id,$account_name) =
each($employees_list))
+ {
+ $selected = '';
+ if ($account_id ==
$ticket['ticket_assignedto'])
+ {
+ $selected = 'selected';
+ }
+ $this->t->set_var('optionname',
$account_name);
+ $this->t->set_var('optionvalue',
$account_id);
+ $this->t->set_var('optionselected',
$selected);
+
$this->t->parse('options_assignedto','options_select',True);
+ }
+
+
+ // Figure out when it was opened and last closed
+ $history_array =
$this->bo->historylog->return_array(array(),array('X','O'),'','',$_REQUEST['ticket_id']);
+
+ while(is_array($history_array) && list(,$value)
= each($history_array))
+ {
+ if($value['status'] == 'O')
+ {
+ $ticket['opened'] =
$GLOBALS['phpgw']->common->show_date($value['datetime'] - ((60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']));
+ }
+
+ if($value['status'] == 'X')
+ {
+ $ticket['closed'] =
$GLOBALS['phpgw']->common->show_date($value['datetime'] - ((60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']));
+ }
+ }
+
+ // group
+
+ $group_list = array();
+ $group_list =
$GLOBALS['phpgw']->accounts->membership($GLOBALS['phpgw_info']['user']['account_id']);
+
+ while(list($key,$entry) = each($group_list))
+ {
+ $tag = '';
+ if($entry['account_id'] ==
$ticket['ticket_group'])
+ {
+ $tag = 'selected';
+ }
+ $this->t->set_var('optionname',
$entry['account_name']);
+ $this->t->set_var('optionvalue',
$entry['account_id']);
+ $this->t->set_var('optionselected',
$tag);
+
$this->t->parse('options_group','options_select',true);
+ }
+
+ $this->t->set_var('options_category',
$this->bo->cats->formated_list('select','',$ticket['category'],False));
+
+ $ticket_status[$ticket['status']] = ' selected';
+ $s = '<option value="O"' . $ticket_status['O']
. '>' . lang('Open') . '</option>';
+ $s .= '<option value="X"' . $ticket_status['X']
. '>' . lang('Closed') . '</option>';
+
+ $this->t->set_var('options_status',$s);
+ $this->t->set_var('lang_status',lang('Status'));
+
+
/**************************************************************\
+ * Display additional notes
*
+
\**************************************************************/
+ $history_array =
$this->bo->historylog->return_array(array(),array('C'),'','',$ticket_id);
+ while(is_array($history_array) && list(,$value)
= each($history_array))
+ {
+
$this->t->set_var('lang_date',lang('Date'));
+
$this->t->set_var('lang_user',lang('User'));
+
+
$this->t->set_var('value_date',$GLOBALS['phpgw']->common->show_date($value['datetime']
- ((60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'])));
+
$this->t->set_var('value_user',$value['owner']);
+
+
$this->t->set_var('value_note',nl2br(htmlspecialchars($value['new_value'])));
+
$this->t->fp('rows_notes','additional_notes_row',True);
+ }
+
+ if(!count($history_array))
+ {
+
$this->t->set_var('lang_no_additional_notes',lang('No additional notes'));
+
$this->t->fp('rows_notes','additional_notes_row_empty',True);
+ }
+
+
/**************************************************************\
+ * Display record history
*
+
\**************************************************************/
+ $this->t->set_var('lang_user',lang('User'));
+ $this->t->set_var('lang_date',lang('Date'));
+ $this->t->set_var('lang_action',lang('Action'));
+ $this->t->set_var('lang_new_value',lang('New
Value'));
+ $this->t->set_var('lang_old_value',lang('Old
Value'));
+
+ $history_array =
$this->historylog->return_array(array('C'),array(),'','',$ticket_id);
+ while(is_array($history_array) && list(,$value)
= each($history_array))
+ {
+
$GLOBALS['phpgw']->nextmatchs->template_alternate_row_color($GLOBALS['phpgw']->template);
+
+
$this->t->set_var('value_date',$GLOBALS['phpgw']->common->show_date($value['datetime']
- ((60*60) *
$GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset'])));
+
$this->t->set_var('value_user',$value['owner']);
+ $this->t->set_var('value_action',
$this->historylog->types[$value['status']]);
+
+ if($value['status'] == 'A')
+ {
+ if(!$value['new_value'])
+ {
+
$this->t->set_var('value_new_value',lang('None'));
+ }
+ else
+ {
+
$this->t->set_var('value_new_value',$GLOBALS['phpgw']->accounts->id2name($value['new_value']));
+ }
+
+ if(!$value['old_value'])
+ {
+
$this->t->set_var('value_old_value',lang('None'));
+ }
+ else
+ {
+
$this->t->set_var('value_old_value',$GLOBALS['phpgw']->accounts->id2name($value['old_value']));
+ }
+ }
+ elseif($value['status'] == 'T')
+ {
+
$this->t->set_var('value_new_value',$GLOBALS['phpgw']->categories->id2name($value['new_value']));
+
$this->t->set_var('value_old_value',$GLOBALS['phpgw']->categories->id2name($value['old_value']));
+ }
+ elseif($value['status'] == 'L')
+ {
+
$this->t->set_var('value_new_value',$GLOBALS['phpgw']->categories->id2name($value['new_value']));
+
$this->t->set_var('value_old_value',$GLOBALS['phpgw']->categories->id2name($value['old_value']));
+ }
+ elseif($value['status'] == 'G')
+ {
+ $s =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
+ $s = ($s ? $s : '--');
+
$this->t->set_var('value_new_value',$s);
+
+ $s =
$GLOBALS['phpgw']->accounts->id2name($value['old_value']);
+ $s = ($s ? $s : '--');
+
$this->t->set_var('value_old_value',$s);
+ }
+ elseif($value['status'] != 'O' &&
$value['new_value'])
+ {
+
$this->t->set_var('value_new_value',$value['new_value']);
+
$this->t->set_var('value_old_value',$value['old_value']);
+ }
+ else
+ {
+
$this->t->set_var('value_new_value',' ');
+
$this->t->set_var('value_old_value',' ');
+ }
+
+
$this->t->fp('rows_history','row_history',True);
+ }
+
+ if(!count($history_array))
+ {
+
$this->t->set_var('lang_no_history',lang('No history for this record'));
+
$this->t->fp('rows_history','row_history_empty',True);
+ }
+
+ for($i=0; $i <= $x-1; $i++)
+ {
+ $file =
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'tts.attachedFiles.show_file',
+
'file' =>
$ticket['attachment'][$i]
+
));
+ $attLink .= "<a href=\"" . $file . "\"
target=\"_NEW\">" . basename($ticket['attachment'][$i]) . " </a><br>";
+ }
+
$this->t->set_var('lang_attachment',lang('Attachment'));
+ $this->t->set_var('value_attachment',$attLink);
+
+
$this->t->set_var('lang_billable_hours_total',lang('Total billable'));
+
$this->t->set_var('value_billable_hours_total',sprintf('%01.2f',($ticket['billable_hours']
* $ticket['billable_rate'])));
+
+
$this->t->set_var('lang_assignedto',lang('Assigned to'));
+ if($ticket['ticket_assignedto'])
+ {
+ $assignedto =
$GLOBALS['phpgw']->accounts->id2name($ticket['assignedto']);
+ }
+ else
+ {
+ $assignedto = lang('None');
+ }
+
$this->t->set_var('value_assignedto',$assignedto);
+
+ $s =
$GLOBALS['phpgw']->accounts->id2name($ticket['group']);
+ $s = ($s ? $s : '--');
+ $this->t->set_var('value_group',$s);
+
+ $this->t->set_var(array
+ (
+ 'currency' =>
$GLOBALS['phpgw_info']['user']['preferences']['common']['currency'],
+ 'lang_additional_notes' =>
lang('additional notes'),
+ 'lang_assignedfrom' =>
lang('assigned from'),
+ 'lang_billable_hours'=> lang('billable
hours'),
+ 'lang_billable_hours_rate' =>
lang('billable rate'),
+ 'lang_category' =>
lang('category'),
+ 'lang_close' =>
lang('close'),
+ 'lang_deadline' =>
lang('deadline'),
+ 'lang_details' =>
lang('details'),
+ 'lang_effort' =>
lang('effort'),
+ 'lang_group' =>
lang('group'),
+ 'lang_history' =>
lang('history'),
+ 'lang_notes' =>
lang('notes'),
+ 'lang_opendate' => lang('open
date'),
+ 'lang_priority' =>
lang('priority'),
+ 'lang_type' =>
lang('type'),
+ 'lang_save' =>
lang('save'),
+ 'lang_subject' =>
lang('subject'),
+ 'lang_summary' =>
lang('summary'),
+ 'lang_update' =>
lang('update'),
+ 'ticket_id' =>
$ticket['ticket_id'],
+ 'url_close' =>
$GLOBALS['phpgw']->link('/tts/index.php'),
+ 'url_viewdetails' =>
$GLOBALS['phpgw']->link('/tts/viewticket_details.php'),
+ 'value_category' =>
$this->bo->cats->id2name($ticket['category']),
+ 'value_details' =>
nl2br(htmlspecialchars($ticket['details'])),
+ 'value_billable_hours_rate' =>
$ticket['billable_rate'],
+ 'value_billable_hours' =>
$ticket['billable_hours'],
+ 'value_deadline' =>
$ticket['deadline'],
+ 'value_effort' =>
$ticket['effort'],
+ 'value_opendate' =>
$ticket['opened'],
+ 'value_owner' =>
$GLOBALS['phpgw']->accounts->id2name($ticket['owner']),
+ 'value_platform' =>
$ticket['platform'],
+ 'value_priority' =>
$ticket['priority'],
+ 'value_subject' =>
htmlspecialchars($ticket['subject']),
+ 'value_type' =>
$ticket['type']
+ ));
+
+ $this->t->set_var('options_select','');
+
+ $GLOBALS['phpgw_info']['flags']['app_header'] =
" #{$ticket['ticket_id']} {$ticket['subject']}";
+
+ $GLOBALS['phpgw']->common->phpgw_header(true);
+
+ $this->t->pfp('out','form');
+ $GLOBALS['phpgw']->common->phpgw_footer();
+ }
+ else
+ {
+ $ticket['billable_hours'] =
$_POST['ticket']['billable_hours'];
+ $ticket['billable_rate'] =
$_POST['ticket']['billable_rate'];
+ $ticket['assignedto'] =
$_POST['ticket']['assignedto'];
+ $ticket['category'] =
$_POST['ticket']['category'];
+ $ticket['note'] =
$_POST['ticket']['note'];
+ $ticket['priority'] =
$_POST['ticket']['priority'];
+ $ticket['group'] =
$_POST['ticket']['group'];
+ $ticket['status'] =
$_POST['ticket']['status'];
+ $ticket['type'] =
$_POST['ticket']['type'];
+ $ticket['deadline'] =
$_POST['ticket']['deadline'];
+ $ticket['effort'] =
$_POST['ticket']['effort'];
+ $ticket['platform'] =
$_POST['ticket']['platform'];
+ $ticket['attachment'] =
$_POST['ticket']['attachment'];
+
+ $this->bo->update_ticket($_POST['ticket_id'],
$ticket);
+
+
$GLOBALS['phpgw']->redirect_link('/tts/viewticket_details.php',
array('ticket_id' => $_POST['ticket_id']));
+ }
+ }
+
+ /**
+ * Inform users that they have been denied access
+ */
+ function _access_denied()
+ {
+ trigger_error(lang('You do not have access to that
record type! This attempted access has been reported'), E_USER_ERROR);
+ }
+
+ function _edit_fields($fields, $values)
+ {
+ foreach ( $fields as $key => $val )
+ {
+ if ( isset($values[$val['id']]) )
+ {
+ $fields[$key]['value'] =
$values[$val['id']];
+ }
+ }
+
+ $fields[] = array
+ (
+ 'id' => 'cancel',
+ 'type' => 'button',
+ 'value' => lang('cancel')
+ );
+
+ $fields[] = array
+ (
+ 'id' => 'submit',
+ 'type' => 'button',
+ 'value' => lang('save')
+ );
+
+ return array('form_elm' => $fields);
+ }
+
+ function _get_selection($selected, $options)
+ {
+ if ( !is_array($options) || !count($options) )
+ {
+ return '';
+ }
+
+ foreach ( $options as $option )
+ {
+ if ( $option['id'] == $selected )
+ {
+ return $option['value'];
+ }
+ }
+
+ return '';
+ }
+
+ function _invalid_request()
+ {
+ die('<pre>' . print_r($_REQUEST, true) . '</pre>');
+ }
+
+
+ function _render_add_form($ticket, $invalids = array() )
+ {
+ $GLOBALS['phpgw_info']['flags']['xslt_app'] = true;
+ $ui = createObject('phpgwapi.ui_tools');
+
+ if ( isset($_REQUEST['ticket_type']) &&
$_REQUEST['ticket_type'] > 0 )
+ {
+ $ticket['cat_id'] = (int)
$_REQUEST['ticket_type'];
+ }
+ else
+ {
+ $this->_invalid_request();
+ }
+
+ $fields = $this->bo->get_fields($ticket['cat_id']);
+ $form = array
+ (
+ 'form_action' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' =>
'tts.uitts.add_ticket')),
+ 'form_elements' => $this->_edit_fields($fields,
$ticket)
+ );
+
+ $GLOBALS['phpgw']->xslttpl->set_var('phpgw',
array('edit' => $form));
+ }
+
+ function _render_list($records, $tbl_id, $status_prefix,
$col_prefix, $target)
+ {
+ $cats = createObject('phpgwapi.categories');
+ $this->t->set_var(
+ array
+ (
+ 'col_prefix'
=> $col_prefix,
+ 'img_close'
=> $GLOBALS['phpgw']->common->image('phpgwapi', 'stock_close',
'.png', false),
+ 'lang_id'
=> lang('ID'),
+ 'lang_subject'
=> lang('subject'),
+ 'lang_opened'
=> lang('opened'),
+ 'lang_category'
=> lang('category'),
+
'lang_assignedto' => lang('assigned to'),
+ 'lang_openedby'
=> lang('opened by'),
+ 'lang_status'
=> lang('status'),
+ 'status_prefix'
=> $status_prefix,
+ 'table_id'
=> $tbl_id
+ ));
+
+ if ( !count($records) )
+ {
+ $this->t->set_var($target, '', true);
+ return false;
+ }
+
+ $first_pass = true;
+ foreach ( $records as $record )
+ {
+ $status_class =
"{$status_prefix}_{$record['ticket_priority']}";
+ $this->t->set_var(
+ array
+ (
+ 'assignedto_name' =>
$record['ticket_assignedto_name'],
+ 'cat_name' =>
$cats->id2name($record['ticket_category']),
+ 'group_name' =>
$record['ticket_group_name'],
+ 'owner_name' =>
$record['ticket_owner_name'],
+ 'subject' =>
htmlspecialchars($record['ticket_subject']),
+ 'status' =>
$record['status_name'],
+ 'status_id' =>
$record['ticket_status'],
+ 'ticket_id' =>
$record['ticket_id'],
+ 'url_ticket' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'tts.uitts.view',
'ticket_id' => $record['ticket_id']) ),
+ 'url_close' =>
$GLOBALS['phpgw']->link('/index.php', array('menuaction' => 'tts.uitts.view',
'ticket_id' => $record['ticket_id'], 'status' => 'X') )
+ ));
+
+ $history_values =
$this->historylog->return_array(array(), array('O'), 'history_timestamp',
'ASC', $record['ticket_id']);
+ $this->t->set_var('opened',
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'] - ((60*60)
* $GLOBALS['phpgw_info']['user']['preferences']['common']['tz_offset']),
+
$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']
+
));
+ $this->t->parse('tts_rows', 'tts_row',
!$first_pass);
+ $first_pass = false;
+ }
+ $this->t->parse($target, 'list', true);
+ return true;
+ }
+ }
+?>
Index: js/base/addticket.js
===================================================================
RCS file: js/base/addticket.js
diff -N js/base/addticket.js
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ js/base/addticket.js 14 Oct 2006 05:39:41 -0000 1.1
@@ -0,0 +1,118 @@
+/*
+* Add Ticket JavaScript functions
+* @author Dave Hall skwashd at phpgroupware org
+* @copyright Copyright (c) 2006 Free Software Foundation Inc
+*/
+
+function updateGroup()
+{
+ var tGroup = document.getElementById('ticket_group');
+ var tAssigned = document.getElementById('ticket_assignedto');
+
+ tAssigned.disbaled = true; // until it is updated and valid again
+
+ if ( tGroup.selectedIndex != 0 )
+ {
+ oParams = {
+ menuaction : 'tts.uitts.get_users',
+ group_id :
tGroup.options[tGroup.selectedIndex].value
+ };
+
+ req = new XMLHttpRequest();
+ req.open('GET', phpGWLink('/index.php', oParams), true);
+ req.onreadystatechange = function()
+ {
+ if ( req.readyState == 4 )
+ {
+ tAssigned.innerHTML = ''; //hack to clear the
list
+ var option;
+ var users = eval(req.responseText);
+ if ( users.length )
+ {
+ for ( var user_key in users )
+ {
+ option =
document.createElement('option');
+ option.value =
users[user_key].account_id;
+
option.appendChild(document.createTextNode(users[user_key].account_name) );
+ tAssigned.appendChild(option);
+ }
+ tAssigned.disabled = false;
+ }
+ }
+ }
+ req.send(null);
+ }
+ else
+ {
+ tAssigned.disabled = true;
+ }
+}
+
+function updateCats()
+{
+ var tCatTop = document.getElementById('ticket_cat_top');
+ var tCategory = document.getElementById('ticket_category');
+
+ tCategory.disbaled = true; // until it is updated and valid again
+
+ if ( tCatTop.selectedIndex != 0 )
+ {
+ oParams = {
+ menuaction : 'tts.uitts.get_cats',
+ cat_id :
tCatTop.options[tCatTop.selectedIndex].value
+ };
+
+ req = new XMLHttpRequest();
+ req.open('GET', phpGWLink('/index.php', oParams), true);
+ req.onreadystatechange = function()
+ {
+ if ( req.readyState == 4 )
+ {
+ tCategory.innerHTML = ''; //hack to clear the
list
+ var option;
+ var cats = eval(req.responseText);
+ if ( cats.length )
+ {
+ for ( var cat_key in cats )
+ {
+ option =
document.createElement('option');
+ option.value =
cats[cat_key].cat_id;
+
option.appendChild(document.createTextNode(cats[cat_key].name) );
+ tCategory.appendChild(option);
+ }
+ tCategory.disabled = false;
+ }
+ }
+ }
+ req.send(null);
+ }
+ else
+ {
+ tAssigned.disabled = true;
+ }
+}
+
+function attachAllEvents()
+{
+ var tGroup = document.getElementById('ticket_group');
+ if ( tGroup.selectedIndex != 0 )
+ {
+ updateGroup();
+ }
+ else
+ {
+ Evnt.addEventListener(tGroup, 'change', updateGroup, false);
+ }
+
+ var tCatTop = document.getElementById('ticket_cat_top');
+ if ( tCatTop.selectedIndex != 0 )
+ {
+ updateCats();
+ }
+ else
+ {
+ Evnt.addEventListener(tCatTop, 'change', updateCats, false);
+ }
+}
+
+Evnt.addEventListener(window, 'load', attachAllEvents, false);
Index: js/base/field_selector.js
===================================================================
RCS file: js/base/field_selector.js
diff -N js/base/field_selector.js
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ js/base/field_selector.js 14 Oct 2006 05:39:41 -0000 1.1
@@ -0,0 +1,268 @@
+ //make this method actually do something
+ ygDDList.prototype.endDrag = function(e)
+ {
+ reStripe();
+ }
+
+
+ /**
+ * Alternate the css class for an array of html elements
+ *
+ * @internal TODO Move to API base
+ * @param array elms the elements to stripe
+ * @param string on the css class name for the "on" elements
+ * @param string off the css class name for the "off" elements
+ */
+ function stripe(elms, on, off)
+ {
+ var regexOn = new RegExp(on);
+ var regexOff = new RegExp(off);
+ var regex = regexOn;
+
+ var row = '';
+ var rowDud = '';
+
+ for ( var i = 0; i < elms.length; ++i )
+ {
+ row = ( i%2 ) ? on : off;
+ rowDud = ( i%2 ) ? off : on;
+ regex = ( i%2 ) ? regexOn : regexOff;
+
+ if ( !elms[i].className.match(regex) )
+ {
+ removeClassName(elms[i], rowDud);
+ addClassName(elms[i], row);
+ }
+ }
+ }
+
+ function reStripe()
+ {
+
stripe(document.getElementById('fields_list').getElementsByTagName('li'),
'row_on', 'row_off');
+ }
+
+ function moveBottom()
+ {
+ var parentNode = document.getElementById('fields_list');
+ var elms = parentNode.getElementsByTagName('li');
+ var lastElm = elms[elms.length - 1 ]; //footer is the
last li, so we want to to be above it
+
+ selectedElms = findSelected(elms, 'highlight');
+ elms = [];
+
+ var elm;
+ while ( selectedElms.length )
+ {
+ elm = selectedElms.pop();
+ parentNode.insertBefore(elm, lastElm);
+ lastElm = elm;
+ }
+ reStripe();
+ return false;
+ }
+
+ function moveDown()
+ {
+ var parentNode = document.getElementById('fields_list');
+ var elms = parentNode.getElementsByTagName('li');
+
+ selectedElms = findSelected(elms, 'highlight');
+ var lastElm = selectedElms[selectedElms.length - 1];
+ elms = [];
+
+ if ( lastElm.nextSibling )//make sure we don't fall off
the edge
+ {
+ lastElm = lastElm.nextSibling;
+ }
+ if ( lastElm.nextSibling )//make sure we don't fall off
the edge
+ {
+ lastElm = lastElm.nextSibling;
+ }
+
+ var elm;
+ while ( selectedElms.length )
+ {
+ elm = selectedElms.pop();
+ parentNode.insertBefore(elm, lastElm);
+ lastElm = elm;
+ }
+ reStripe();
+ return false;
+ }
+
+ function moveTop()
+ {
+ var parentNode = document.getElementById('fields_list');
+ var elms = parentNode.getElementsByTagName('li');
+ var firstElm = elms[1]; //header is the first li, so we
want to skip it
+
+ selectedElms = findSelected(elms, 'highlight');
+ elms = [];
+
+ var elm;
+ while ( selectedElms.length )
+ {
+ elm = selectedElms.pop();
+ parentNode.insertBefore(elm, firstElm);
+ firstElm = elm;
+ }
+ reStripe();
+ return false;
+ }
+
+ function moveUp()
+ {
+ var parentNode = document.getElementById('fields_list');
+ var elms = parentNode.getElementsByTagName('li');
+ var firstElm = elms[1];
+
+ selectedElms = findSelected(elms, 'highlight');
+
+ if ( selectedElms[0] != elms[1] ) //not already at top
+ {
+ firstElm = selectedElms[0].previousSibling;
+ }
+
+ elms = [];
+
+ var elm;
+ while ( selectedElms.length )
+ {
+ elm = selectedElms.pop();
+ parentNode.insertBefore(elm, firstElm);
+ firstElm = elm;
+ }
+ reStripe();
+ return false;
+ }
+
+
+ function findSelected(elms, strSearch)
+ {
+ selectedItems = [];
+ if ( !elms.length )
+ {
+ return selectedItems;
+ }
+
+ var regex = new RegExp(strSearch);
+
+ for ( var i = 0; i < elms.length; ++i )
+ {
+ if ( elms[i].className.match(regex) )
+ {
+ selectedItems[selectedItems.length] =
elms[i];
+ }
+ }
+ return selectedItems;
+ }
+
+ function highlight(evnt)
+ {
+ var elm = YAHOO.util.Event.getTarget(evnt, true);
+
+ if ( elm.tagName.toLowerCase() == 'input'
+ || elm.tagName.toLowerCase() == 'img'
+ || elm.tagName.toLowerCase() == 'a' ) //don't
let checkboxes or styled checkboxes fire it
+ {
+ return false;
+ }
+
+ if ( elm.tagName.toLowerCase() != 'li' )
+ {
+ while ( elm.tagName.toLowerCase() != 'li' )
+ {
+ elm = elm.parentNode;
+ }
+ }
+
+ if ( evnt.ctrlKey )
+ {
+ addClassName(elm, 'highlight');
+ }
+ else if( evnt.shiftKey )
+ {
+ var hilite = false;
+ var regex = new RegExp('highlight');
+ var parent = elm.parentNode;
+ for ( var i = 0; i < parent.childNodes.length;
++i)
+ {
+ if ( parent.childNodes[i].nodeType == 1
) //only want HTML elements
+ {
+ if ( parent.childNodes[i].id ==
elm.id
+ ||
parent.childNodes[i].className.match(regex) )
+ {
+ if ( !hilite )
+ {
+
addClassName(parent.childNodes[i], 'highlight');
+ hilite = true;
+ continue;
+ }
+ else if ( hilite )
+ {
+
addClassName(parent.childNodes[i], 'highlight');
+ break;
+ }
+ }
+
+ if ( hilite )
+ {
+
addClassName(parent.childNodes[i], ' highlight');
+ }
+ }
+
+ }
+ }
+ else //normal click
+ {
+ var parent = elm.parentNode;
+ for ( var i = 0; i < parent.childNodes.length;
++i)
+ {
+ if ( parent.childNodes[i].nodeType == 1
) //only want HTML elements
+ {
+ if ( parent.childNodes[i].id ==
elm.id )
+ {
+
addClassName(parent.childNodes[i], 'highlight')
+ }
+ else
+ {
+
removeClassName(parent.childNodes[i], 'highlight')
+ }
+ }
+ }
+ }
+ }
+
+ var dd = [];
+ function dragDropInit()
+ {
+ var i = 0;
+
+ var fields =
document.getElementById('fields_list').childNodes;
+ for ( var j = 0; j < fields.length; ++j)
+ {
+ if ( fields[j].nodeType != 1
+ || fields[j].tagName.toLowerCase() !=
'li'
+ || fields[j].id.substr(0, 7) ==
'header_'
+ || fields[j].id.substr(0, 7) ==
'footer_' )
+ {
+ continue;
+ }
+
+ dd[i++] = new ygDDList(fields[j].id);
+ YAHOO.util.Event.addListener(fields[j],
'click', highlight);
+ }
+
+ dd[i++] = new ygDDListBoundary('header_fields');
+ dd[i++] = new ygDDListBoundary('footer_fields');
+
+ YAHOO.util.DDM.mode = YAHOO.util.DDM.INTERSECT;
+ }
+
+ function initPage()
+ {
+ InitialiseCheckboxes();
+ InitialiseRadioboxes();
+ dragDropInit();
+ }
+ YAHOO.util.Event.addListener(window, 'load', initPage);
\ No newline at end of file
Index: js/base/index.js
===================================================================
RCS file: js/base/index.js
diff -N js/base/index.js
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ js/base/index.js 14 Oct 2006 05:39:41 -0000 1.1
@@ -0,0 +1,70 @@
+/**
+* TTS index page functions
+*
+* Written by and Copyright 2006 Dave Hall
+*/
+
+var oTabs;
+var sortOpen;
+var sortOverdue;
+
+YAHOO.namespace('example.container');
+// What to do once the page has loaded
+function ttsIndexOnLoad()
+{
+ oTabs = new Tabs(2,'activetab','inactivetab','tab','tabcontent');
+ oTabs.display(1);
+
+ sortOpen = new SortableTable(document.getElementById('tickets_open'),
+ ['None', 'Number', 'CaseInsensitiveString', 'Date',
'CaseInsensitiveString', 'CaseInsensitiveString', 'CaseInsensitiveString',
'CaseInsensitiveString']);
+
+ sortOverdue = new
SortableTable(document.getElementById('tickets_overdue'),
+ ['None', 'Number', 'CaseInsensitiveString', 'Date',
'CaseInsensitiveString', 'CaseInsensitiveString', 'CaseInsensitiveString',
'CaseInsensitiveString']);
+
+ var handleCancel = function()
+ {
+ dlg.cancel();
+ }
+
+ var handleSubmit = function()
+ {
+ dlg.submit();
+ }
+
+ dlg = new
YAHOO.widget.Dialog(document.getElementById('tts_goto_dialog'), { modal:true,
visible:false, width:"350px", fixedcenter:true, constraintoviewport:true,
draggable:true });
+
+ var listeners = new YAHOO.util.KeyListener(document, { keys : 27 },
{fn:handleCancel,scope:YAHOO.example.container.dlg,correctScope:true} );
+
+ dlg.cfg.queueProperty('postmethod','form');
+
+ dlg.cfg.queueProperty("keylisteners", listeners);
+
+ dlg.cfg.queueProperty("buttons", [ { text : 'Cancel', handler :
handleCancel },
+
{ text: 'Go', handler : handleSubmit, isDefault : true } ]);
+
+
+ dlg.render();
+}
+
+
+function goToPopup()
+{
+ dlg.show();
+ /*
+ var ticketID = prompt(lang['ticket_no'] + ' :');
+ if ( ticketID == parseInt(ticketID) )
+ {
+ window.location = phpGWLink('/index.php', { menuaction :
'tts.uitts.view', id : ticketID } );
+ return false;
+ }
+ else if ( ticketID != null && ticketID != '' && ticketID != false )
+ {
+ alert(lang['invalid']);
+ goToPopup();
+ }
+ else
+ {
+ return false;
+ }
+ */
+}
Index: js/base/view.js
===================================================================
RCS file: js/base/view.js
diff -N js/base/view.js
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ js/base/view.js 14 Oct 2006 05:39:41 -0000 1.1
@@ -0,0 +1,13 @@
+/**
+* TTS view screen functions
+*
+* Written by and Copyright 2006 Dave Hall
+*/
+
+var oTabs;
+// What to do once the page has loaded
+window.onload = function()
+{
+ oTabs = new Tabs(4,'activetab','inactivetab','tab','tabcontent');
+ oTabs.display(1);
+};
Index: test.php
===================================================================
RCS file: test.php
diff -N test.php
--- test.php 10 May 2005 16:12:38 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,28 +0,0 @@
-<?php
- /**
- * Trouble Ticket System
- *
- * @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @package tts
- * @version $Id: test.php,v 1.3 2005/05/10 16:12:38 powerstat Exp $
- */
-
-$GLOBALS['phpgw_info']['flags'] = array
-(
- 'currentapp' => 'tts',
- 'noheader' => True,
- 'nofooter' => True,
- 'enable_vfs_class' => True,
- 'enable_browser_class' => True
-);
-
-/**
- * Include phpgroupware header
- */
-include ('../header.inc.php');
-
-echo ($GLOBALS['phpgw_info']['user']['preferences']['common']['currency']);
-
-$GLOBALS['phpgw']->common->phpgw_footer();
-?>
\ No newline at end of file
Index: inc/class.bo.inc.php
===================================================================
RCS file: inc/class.bo.inc.php
diff -N inc/class.bo.inc.php
--- inc/class.bo.inc.php 10 May 2005 16:12:38 -0000 1.8
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,580 +0,0 @@
-<?php
- /**
- * Trouble Ticket System - business object
- *
- * @copyright Copyright (C) 2000-2005 Free Software Foundation, Inc.
http://www.fsf.org/
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public
License
- * @package tts
- * @version $Id: class.bo.inc.php,v 1.8 2005/05/10 16:12:38 powerstat
Exp $
- */
-
-
- /**
- * Business object
- *
- * @package tts
- */
- class bo
- {
- var $db;
- var $so;
- var $historylog;
- var $total_records;
- var $public_methods = array(
- 'list_methods' => True,
- 'add_ticket' => True
- );
-
- function bo()
- {
- $this->db = $GLOBALS['phpgw']->db;
-// $this->so = createobject('tts.so');
- $this->historylog =
createobject('phpgwapi.historylog','tts');
- $this->historylog->types = array(
- 'R' => 'Re-opened',
- 'X' => 'Closed',
- 'O' => 'Opened',
- 'A' => 'Re-assigned',
- 'P' => 'Priority changed',
- 'T' => 'Category changed',
- 'S' => 'Subject changed',
- 'B' => 'Billing rate',
- 'H' => 'Billing hours'
- );
- }
-
- function list_methods($_type)
- {
- if (is_array($_type))
- {
- $_type = $_type['type'];
- }
-
- switch($_type)
- {
- case 'xmlrpc':
- $xml_functions = array(
- 'list_methods' => array(
- 'function' =>
'list_methods',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Read this list of methods.')
- ),
- 'save' => array(
- 'function' => 'save',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Creates a new ticket, returns ticket_id')
- ),
- 'list' => array(
- 'function' => '_list',
- 'signature' =>
array(array(xmlrpcStruct,xmlrpcStruct)),
- 'docstring' =>
lang('Creates a struct of tickets')
- ),
- 'read' => array(
- 'function' => '_read',
- 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
- 'docstring' =>
lang('Returns a struct of values of a single ticket')
- ),
- 'read_notes' => array(
- 'function' =>
'read_notes',
- 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
- 'docstring' =>
lang('Returns the additional notes attached to a ticket')
- ),
- 'history' => array(
- 'function' =>
'history',
- 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
- 'docstring' =>
lang('Returns a struct of a tickets history')
- ),
- 'update' => array(
- 'function' => 'update',
- 'signature' =>
array(array(xmlrpcInt,xmlrpcStruct)),
- 'docstring' =>
lang('Updates ticket')
- ),
- 'test' => array(
- 'function' => 'test',
- 'signature' =>
array(array(xmlrpcString)),
- 'docstring' =>
lang('TEST')
- )
-
- );
- return $xml_functions;
- break;
-
- case 'soap':
- return $this->soap_functions;
- break;
-
- default:
- return array();
- break;
- }
- }
-
- function test()
- {
- return 'This is a string';
- }
-
- function cached_accounts($account_id)
- {
- global $phpgw;
-
- $this->accounts =
CreateObject('phpgwapi.accounts',$account_id);
- $this->accounts->read_repository();
-
-
$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 _list($params)
- {
- $db2 = $this->db;
- $this->db->query("select * from phpgw_tts_tickets
$filtermethod $sortmethod",__LINE__,__FILE__);
- $this->total_records = $this->db->num_rows();
-
- while ($this->db->next_record())
- {
- $db2->query("select count(*) from
phpgw_tts_views where view_id='" . $this->db->f('ticket_id')
- . "' and view_account_id='" .
$GLOBALS['phpgw_info']['user']['account_id'] . "'",__LINE__,__FILE__);
- $db2->next_record();
-
- if ($db2->f(0))
- {
- $ticket_read = 'old';
- }
- else
- {
- $ticket_read = 'new';
- }
-
- $history_values =
$this->historylog->return_array(array(),array('O'),'','',$this->db->f('ticket_id'));
-
- $cached_data =
$this->cached_accounts($this->db->f('ticket_owner'));
- $owner =
$GLOBALS['phpgw']->common->display_fullname($cached_data[$this->db->f('ticket_owner')]['account_lid'],
-
$cached_data[$this->db->f('ticket_owner')]['firstname'],$cached_data[$this->db->f('ticket_owner')]['lastname']);
-
- $cached_data =
$this->cached_accounts($this->db->f('ticket_assignedto'));
- $assignedto =
$GLOBALS['phpgw']->common->display_fullname($cached_data[$this->db->f('ticket_assignedto')]['account_lid'],
-
$cached_data[$this->db->f('ticket_assignedto')]['firstname'],$cached_data[$this->db->f('ticket_assignedto')]['lastname']);
-
- $r[] = array(
- 'id' =>
(int)$this->db->f('ticket_id'),
- 'group' =>
$this->db->f('ticket_group'),
- 'priority' =>
$this->db->f('ticket_priority'),
- 'owner' => $owner,
- 'assignedto' => $assignedto,
- 'subject' =>
$this->db->f('ticket_subject'),
- 'category' =>
$this->db->f('ticket_category'),
- 'billable_hours' =>
$this->db->f('ticket_billable_hours'),
- 'billable_rate' =>
$this->db->f('ticket_billable_rate'),
- 'status' =>
$this->db->f('ticket_status'),
- 'details' =>
$this->db->f('ticket_details'),
- 'odate' =>
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
- 'odate_epoch' =>
(int)$history_values[0]['datetime'],
- 'view' => $ticket_read
- );
- }
- return $r;
- }
-
- function exists($id) {
- $myid = (int) $id;
- $this->db->query(
- "select 1 from phpgw_tts_tickets where
ticket_id='". $myid . "'",
- __LINE__,
- __FILE__
- );
- return $this->db->next_record();
- }
-
- function delete($id) {
- $ret = true;
- $ret &= (! is_null($this->db->query(
- "DELETE from phpgw_tts_tickets where
ticket_id='". $myid . "'",
- __LINE__,
- __FILE__
- )));
- $ret &= (! is_null($this->db->query(
- "DELETE from phpgw_tts_views where view_id='".
$myid . "'",
- __LINE__,
- __FILE__
- )));
- return $ret;
- }
-
- function getIDList($lastmod = -1) {
- $sel = "SELECT ticket_id FROM phpgw_tts_tickets";
- $mylastmod = (int) $lastmod;
- if ($mylastmod >= 0) {
- $sel .= " WHERE ticket_lastmod>='" . $mylastmod
. "'";
- }
- $this->db->query($sel, __LINE__, __FILE__);
- $ret = array();
- while ($this->db->next_record()) {
- $ret[] = $this->db->f("ticket_id");
- }
- error_log("bo_tts:getIDList: ".print_r($ret, true));
- return $ret;
- }
-
- // created getter without view-creation or reading it
- function retrieve($id) {
- $myid = (int) $id;
- $this->db->query("select * from phpgw_tts_tickets where
ticket_id='" . $myid . "'",__LINE__,__FILE__);
- if (! $this->db->next_record()) {
- return false;
- }
- $ret = array(
- 'id' => (int) $id,
- 'group' =>
$this->db->f('ticket_group'),
- 'priority' =>
$this->db->f('ticket_priority'),
- 'owner' =>
$this->db->f('ticket_owner'),
- 'assignedto' =>
$this->db->f('ticket_assignedto'),
- 'subject' =>
$this->db->f('ticket_subject'),
- 'category' =>
$this->db->f('ticket_category'),
- 'billable_hours' =>
$this->db->f('ticket_billable_hours'),
- 'billable_rate' =>
$this->db->f('ticket_billable_rate'),
- 'status' =>
$this->db->f('ticket_status'),
- 'details' =>
$this->db->f('ticket_details')
- );
- return $ret;
- }
-
- function _read($params = '')
- {
- $cat = createobject('phpgwapi.categories');
-
- // Have they viewed this ticket before ?
- $this->db->query("select count(*) from phpgw_tts_views
where view_id='" . $params['id']
- . "' and view_account_id='" .
$GLOBALS['phpgw_info']['user']['account_id'] . "'",__LINE__,__FILE__);
- $this->db->next_record();
-
- if (! $this->db->f(0))
- {
- $this->db->query("insert into phpgw_tts_views
values ('" . $params['id'] . "','"
- .
$GLOBALS['phpgw_info']['user']['account_id'] . "','" . time() .
"')",__LINE__,__FILE__);
- }
-
- $this->db->query("select * from phpgw_tts_tickets where
ticket_id='" . $params['id'] . "'",__LINE__,__FILE__);
- $this->db->next_record();
-
- $cached_data =
$this->cached_accounts($this->db->f('ticket_owner'));
- $owner =
$GLOBALS['phpgw']->common->display_fullname($cached_data[$this->db->f('ticket_owner')]['account_lid'],
-
$cached_data[$this->db->f('ticket_owner')]['firstname'],$cached_data[$this->db->f('ticket_owner')]['lastname']);
-
- $cached_data =
$this->cached_accounts($this->db->f('ticket_assignedto'));
- $assignedto =
$GLOBALS['phpgw']->common->display_fullname($cached_data[$this->db->f('ticket_assignedto')]['account_lid'],
-
$cached_data[$this->db->f('ticket_assignedto')]['firstname'],$cached_data[$this->db->f('ticket_assignedto')]['lastname']);
-
- $r = array(
- 'id' =>
(int)$this->db->f('ticket_id'),
- 'group' =>
$this->db->f('ticket_group'),
- 'priority' =>
$this->db->f('ticket_priority'),
- 'owner' => $owner,
- 'assignedto' => $assignedto,
- 'subject' =>
$this->db->f('ticket_subject'),
- 'category' =>
$cat->id2name($this->db->f('ticket_category')),
- 'billable_hours' =>
$this->db->f('ticket_billable_hours'),
- 'billable_rate' =>
$this->db->f('ticket_billable_rate'),
- 'status' =>
$this->db->f('ticket_status'),
- 'details' =>
$this->db->f('ticket_details'),
- 'odate' =>
$GLOBALS['phpgw']->common->show_date($history_values[0]['datetime'],$GLOBALS['phpgw_info']['user']['preferences']['common']['dateformat']),
- 'odate_epoch' =>
(int)$history_values[0]['datetime'],
- 'view' => $this->db->f('ticket_view'),
- 'history_size' =>
count($this->historylog->return_array(array('C','O'),array(),'','',$params['id']))
- );
- return $r;
- }
-
- function read_notes($params)
- {
- $history_array =
$this->historylog->return_array(array(),array('C'),'','',$params[0]);
-
- return $history_array;
- }
-
- function history($params)
- {
- $cat = createobject('phpgwapi.categories');
- // This function needs to make use of the alternate
handle option (jengo)
- $history_array =
$this->historylog->return_array(array('C','O'),array(),'','',$params[0]);
- while (is_array($history_array) && list(,$value) =
each($history_array))
- {
- $datetime =
$GLOBALS['phpgw']->common->show_date($value['datetime']);
- $owner = $value['owner'];
-
- switch ($value['status'])
- {
- case 'R': $type = lang('Re-opened');
break;
- case 'X': $type = lang('Closed');
break;
- case 'O': $type = lang('Opened');
break;
- case 'A': $type = lang('Re-assigned');
break;
- case 'P': $type = lang('Priority
changed'); break;
- case 'T': $type = lang('Category
changed'); break;
- case 'S': $type = lang('Subject
changed'); break;
- case 'H': $type = lang('Billable hours
changed'); break;
- case 'B': $type = lang('Billable rate
changed'); break;
- default: break;
- }
-
- $action = ($type?$type:'');
- unset($type);
-
- if ($value['status'] == 'A')
- {
- if (! $value['new_value'])
- {
- $new_value = lang('None');
- }
- else
- {
- $new_value =
$GLOBALS['phpgw']->accounts->id2name($value['new_value']);
- }
- }
- else if ($value['status'] == 'T')
- {
- $new_value =
$cat->id2name($value['new_value']);
- }
- else if ($value['status'] != 'O' &&
$value['new_value'])
- {
- $new_value = $value['new_value'];
- }
- else
- {
- $new_value = '';
- }
-
- $r[] = array(
- 'owner' => $owner,
- 'action' => $action,
- 'new_value' => $new_value,
- 'old_value' => '' . $old_value,
- 'datetime' => $datetime
- );
- }
-
- return $r;
- }
-
- //added optional parameter to avoid historylog-entries due
sync-addition
- function save($params, $dohistorylog = true)
- {
- //added lastmod-support for ipc-layer
- $lastmod = array_key_exists('lastmod', $params) ? (int)
$params['lastmod'] : time();
- $statement = "insert into phpgw_tts_tickets
(ticket_group,ticket_priority,ticket_owner,"
- .
"ticket_assignedto,ticket_subject,ticket_category,ticket_billable_hours,"
- .
"ticket_billable_rate,ticket_status,ticket_details,ticket_lastmod) values
('0','"
- . $params['priority'] . "','"
- . $GLOBALS['phpgw_info']['user']['account_id']
. "','"
- . $params['assignedto'] . "','"
- . $params['subject'] . "','"
- . $params['category'] . "','"
- . $params['billable_hours'] . "','"
- . $params['billable_rate'] . "','O','"
- . addslashes($params['details']) . "','"
- . $lastmod . "')";
- error_log("bo_tts:save: statement='" . $statement .
"'");
- $this->db->query($statement,__LINE__,__FILE__);
- $ticket_id =
$this->db->get_last_insert_id('phpgw_tts_tickets','ticket_id');
- error_log("bo_tts:save: saved -> $ticket_id");
- //added optional parameter to avoid historylog-entries
due sync-addition
- if ($dohistorylog) {
- $this->historylog->add('O',$ticket_id,'');
- }
- return $ticket_id;
- }
-
- function update($params)
- {
- // So where on the same page with our transactions
- $this->historylog->db = &$this->db;
-
- $ticket = $params;
- $ticket_id = $params['id'];
- // DB Content is fresher is always more up to date
- $this->db->query("select * from phpgw_tts_tickets where
ticket_id='"
- . $params['id'] . "'",__LINE__,__FILE__);
- $this->db->next_record();
-
- $oldassigned = $this->db->f('ticket_assignedto');
- $oldpriority = $this->db->f('ticket_priority');
- $oldcategory = $this->db->f('ticket_category');
- $old_status = $this->db->f('ticket_status');
-
- $this->db->transaction_begin();
-
- /*
- ** phpgw_tts_append.append_type - Defs
- ** R - Reopen ticket
- ** X - Ticket closed
- ** O - Ticket opened
- ** C - Comment appended
- ** A - Ticket assignment
- ** P - Priority change
- ** T - Category change
- ** S - Subject change
- ** B - Billing rate
- ** H - Billing hours
- */
-
- if ($old_status != $ticket['status'])
- {
- $fields_updated = True;
-
$this->historylog->add($ticket['status'],$ticket_id,'');
-
- $this->db->query("update phpgw_tts_tickets set
ticket_status='"
- . $ticket['status'] . "' where
ticket_id='$ticket_id'",__LINE__,__FILE__);
- }
-
- if ($oldassigned != $ticket['assignedto'])
- {
- $fields_updated = True;
- $this->db->query("update phpgw_tts_tickets set
ticket_assignedto='" . $ticket['assignedto']
- . "' where
ticket_id='$ticket_id'",__LINE__,__FILE__);
-
$this->historylog->add('A',$ticket_id,$ticket['assignedto']);
- }
-
- if ($oldpriority != $ticket['priority'])
- {
- $fields_updated = True;
- $this->db->query("update phpgw_tts_tickets set
ticket_priority='" . $ticket['priority']
- . "' where
ticket_id='$ticket_id'",__LINE__,__FILE__);
-
$this->historylog->add('P',$ticket_id,$ticket['priority']);
- }
-
- if ($oldcategory != $ticket['category'])
- {
- $fields_updated = True;
- $this->db->query("update phpgw_tts_tickets set
ticket_category='" . $ticket['category']
- . "' where
ticket_id='$ticket_id'",__LINE__,__FILE__);
-
$this->historylog->add('T',$ticket_id,$ticket['category']);
- }
-
- if ($old_billable_hours != $ticket['billable_hours'])
- {
- $fields_updated = True;
- $this->db->query("update phpgw_tts_tickets set
ticket_billable_hours='" . $ticket['billable_hours']
- . "' where
ticket_id='$ticket_id'",__LINE__,__FILE__);
-
$this->historylog->add('H',$ticket_id,$ticket['billable_hours']);
- }
-
- if ($old_billable_rate != $ticket['billable_rate'])
- {
- $fields_updated = True;
- $this->db->query("update phpgw_tts_tickets set
ticket_billable_rate='" . $ticket['billable_rate']
- . "' where
ticket_id='$ticket_id'",__LINE__,__FILE__);
-
$this->historylog->add('B',$ticket_id,$ticket['billable_rate']);
- }
-
- if ($ticket['note'])
- {
- $fields_updated = True;
-
$this->historylog->add('C',$ticket_id,$ticket['note']);
-
- // Do this before we go into mail_ticket()
- $this->db->transaction_commit();
-
- if
($GLOBALS['phpgw_info']['server']['tts_mailticket'])
- {
- //$this->mail_ticket($ticket_id);
- }
- }
- else
- {
- // Only do our commit once
- $this->db->transaction_commit();
- }
- return True;
- }
-
- function mail_ticket($ticket_id)
- {
- // $GLOBALS['phpgw']->preferences->read_repository();
- //
$GLOBALS['phpgw_info']['user']['preferences']['tts']['mailnotification']
-
- $GLOBALS['phpgw']->config->read_repository();
-
- if
($GLOBALS['phpgw']->config->config_data['mailnotification'])
- {
- $GLOBALS['phpgw']->send =
CreateObject('phpgwapi.send');
-
- $this->db->query('select
t_id,t_category,t_detail,t_priority,t_user,t_assignedto,'
- . "t_timestamp_opened,
t_timestamp_closed, t_subject from phpgw_tts_tickets where
t_id='".$ticket_id."'",__LINE__,__FILE__);
- $this->db->next_record();
-
- $group = $this->db->f('t_category');
-
- // build subject
- $subject = '[TTS #'.$ticket_id.' '.$group.']
'.(!$this->db->f('t_timestamp_closed')?'Updated':'Closed').':
'.$this->db->f('t_subject');
-
- // build body
- $body = '';
- $body .= 'TTS #'.$ticket_id."\n\n";
- $body .= 'Subject:
'.$this->db->f('t_subject')."\n\n";
- $body .= 'Assigned To:
'.$this->db->f('t_assignedto')."\n\n";
- $body .= 'Priority: ' .
$this->db->f('t_priority') . "\n\n";
- $body .= 'Group: ' . $group."\n\n";
- $body .= 'Opened By: ' .
$this->db->f('t_user')."\n";
- $body .= 'Date Opened:
'.$GLOBALS['phpgw']->common->show_date($this->db->f('t_timestamp_opened'))."\n\n";
- if($this->db->f('t_timestamp_closed'))
- {
- $body .= 'Date Closed:
'.$GLOBALS['phpgw']->common->show_date($this->db->f('t_timestamp_closed'))."\n\n";
- }
- $body .=
stripslashes(strip_tags($this->db->f('t_detail')))."\n\n.";
-
- $members = array();
- if
($GLOBALS['phpgw']->config->config_data['groupnotification'])
- {
- // select group recipients
- $group_id =
$GLOBALS['phpgw']->accounts->name2id($group);
- $members =
$GLOBALS['phpgw']->accounts->members($group_id);
- }
-
- if
($GLOBALS['phpgw']->config->config_data['ownernotification'])
- {
- // add owner to recipients
- $members[] = array('account_id' =>
$GLOBALS['phpgw']->accounts->name2id($this->db->f('t_user')), 'account_name' =>
$this->db->f('t_user'));
- }
-
- if
($GLOBALS['phpgw']->config->config_data['assignednotification'])
- {
- // add assigned to recipients
- $members[] = array('account_id' =>
$GLOBALS['phpgw']->accounts->name2id($this->db->f('t_assignedto')),
'account_name' => $this->db->f('t_assignedto'));
- }
-
- $toarray = Array();
- $i=0;
- for ($i=0;$i<count($members);$i++)
- {
- if ($members[$i]['account_id'])
- {
- $prefs =
$GLOBALS['phpgw']->preferences->create_email_preferences($members[$i]['account_id']);
-
$toarray[$prefs['email']['address']] = $prefs['email']['address'];
- }
- }
- if(count($toarray) > 1)
- {
- @reset($toarray);
- $to = implode(',',$toarray);
- }
- else
- {
- $to = current($toarray);
- }
-
- $rc = $GLOBALS['phpgw']->send->msg('email',
$to, $subject, stripslashes($body), '', $cc, $bcc);
- if (!$rc)
- {
- echo 'Your message could <B>not</B> be
sent!<BR>'."\n"
- . 'The mail server
returned:<BR>'
- . "err_code:
'".$GLOBALS['phpgw']->send->err['code']."';<BR>"
- . "err_msg:
'".htmlspecialchars($GLOBALS['phpgw']->send->err['msg'])."';<BR>\n"
- . "err_desc:
'".$GLOBALS['phpgw']->err['desc']."'.<P>\n"
- . 'To go back to the msg list,
click <a href="'.$GLOBALS['phpgw']->link('/tts/index.php','cd=13').'">here</a>';
- $GLOBALS['phpgw']->common->phpgw_exit();
- }
- }
- }
- }
Index: templates/base/viewticket_details.tpl
===================================================================
RCS file: templates/base/viewticket_details.tpl
diff -N templates/base/viewticket_details.tpl
--- templates/base/viewticket_details.tpl 11 Jan 2005 15:00:19 -0000
1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,178 +0,0 @@
-<!-- BEGIN options_select -->
- <option value="{optionvalue}" {optionselected}>{optionname}</option>
-<!-- END options_select -->
-
-<!-- BEGIN additional_notes_row -->
- <tr bgcolor="{row_off}">
- <td colspan="4">
- <hr>
- {lang_date}: {value_date}
- <br>{lang_user}: {value_user}
- <br><br>{value_note}
- <p>
- </td>
- </tr>
-<!-- END additional_notes_row -->
-
-<!-- BEGIN additional_notes_row_empty -->
- <tr bgcolor="{row_off}">
- <td colspan="4">{lang_no_additional_notes}</b></td>
- </tr>
-<!-- END additional_notes_row_empty -->
-
-<!-- BEGIN row_history -->
- <tr bgcolor="{tr_color}">
- <td>{value_date}</td>
- <td>{value_user}</td>
- <td>{value_action}</td>
- <td>{value_old_value}</td>
- <td>{value_new_value}</td>
- </tr>
-<!-- END row_history -->
-
-<!-- BEGIN row_history_empty -->
- <tr bgcolor="{row_off}">
- <td colspan="4"
align="center"><b>{lang_no_history}</b></td>
- </tr>
-<!-- END row_history_empty -->
-
-<!-- BEGIN form -->
-<b>{lang_viewjobdetails}</b>
-<hr><p>
-
-<center><font color=red>{messages}</font></center>
-
-<form method="POST" action="{viewticketdetails_link}"
enctype="multipart/form-data">
-<input type="hidden" name="ticket_id" value="{ticket_id}">
-<input type="hidden" name="lstAssignedfrom" value="{ticket_user}">
-
-<table border="0" width="80%" cellspacing="0" align="center">
- <tr bgcolor="{th_bg}">
- <td colspan="4"> <b>[ #{ticket_id} ] -
{value_subject}</b></td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td align="left">{lang_opendate}:</td>
- <td align="left"><b>{value_opendate}</b></td>
- <td align="left">{lang_billable_hours}:</td>
- <td align="left"><b>{currency} {value_billable_hours}</b></td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td align="left">{lang_assignedfrom}:</td>
- <td align="left"><b>{value_owner}</b></td>
- <td align="left">{lang_billable_hours_rate}: </td>
- <td align="left"><b>{currency}
{value_billable_hours_rate}</b></td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td align="left">{lang_assignedto}:</td>
- <td align="left"><b>{value_assignedto}</b></td>
- <td align="left">{lang_billable_hours_total}:</td>
- <td align="left"><b>{currency}
{value_billable_hours_total}</b></td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td align="left">{lang_priority}:</td>
- <td align="left"><b>{value_priority}</b></td>
- <td align="left">{lang_attachment}</td>
- <td align="left">{value_attachment}</td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td align="left">{lang_category}:</td>
- <td align="left"><b>{value_category}</b></td>
- <td align="left"> </td>
- <td align="left"> </td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td align="left">{lang_group}:</td>
- <td align="left"><b>{value_group}</b></td>
- <td align="left"> </td>
- <td align="left"> </td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td colspan="4" align="center"><hr></td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td colspan="4"><b>{lang_details}:</b><br>{value_details}</td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td colspan="4"> </td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td colspan="4"><b>{lang_additional_notes}:</b></td>
- </tr>
-
-{rows_notes}
-
- <tr bgcolor="{row_off}">
- <td colspan="4"> </td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td colspan="4"><b>{lang_update}:</b><hr></td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td align="center"><b>{lang_priority}: </b><select
name="ticket[priority]">{options_priority}</select></td>
- <td align="center"><b>{lang_category}: </b><select size="1"
name="ticket[category]">{options_category}</select></td>
- <td align="center"><b>{lang_assignedto}: </b><select size="1"
name="ticket[assignedto]">{options_assignedto}</select></td>
- <td align="center"><b>{lang_attachment} </b><input type="file"
name="attachment"></td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td align="center"><b>{lang_status}: </b><select
name="ticket[status]">{options_status}</select></td>
- <td align="center"><b>{lang_group}: </b><select
name="ticket[group]">{options_group}</select></td>
- <td align="center"><b>{lang_billable_hours_rate}: <input
name="ticket[billable_rate]" value="{value_billable_hours_rate}"></td>
- <td align="center"><b>{lang_billable_hours}: <input
name="ticket[billable_hours]" value="{value_billable_hours}"></td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td colspan="4"
align="center">{additonal_details_rows}<textarea rows="12" name="ticket[note]"
cols="70" wrap="physical"></textarea></td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td colspan="4"> </td>
- </tr>
-
- <tr bgcolor="{row_off}">
- <td> </td>
- <td align="center"><input type="submit" value="{lang_ok}"
name="submit"></td>
- <td align="center"><input name="done" type="button"
value="{lang_done}" onClick="self.location.href='{done_url}'" /></td>
- <td> </td>
- </tr>
-
- <tr>
- <td colspan="4"> </td>
- </tr>
-
- <tr>
- <td colspan="4">{lang_history}</td>
- </tr>
-
- <tr>
- <td colspan="4">
-
- <table border="0" width="100%">
- <tr bgcolor="{th_bg}">
- <td width="10%">{lang_date}</td>
- <td>{lang_user}</td>
- <td>{lang_action}</td>
- <td>{lang_old_value}</td>
- <td>{lang_new_value}</td>
- </tr>
-{rows_history}
- </table>
-
- </td>
- </tr>
-
- </table>
-</form>
-<!-- END form -->
Index: templates/base/images/navbar.gif
===================================================================
RCS file: templates/base/images/navbar.gif
diff -N templates/base/images/navbar.gif
Binary files /tmp/cvspzo23y and /dev/null differ
Index: templates/base/images/updated.gif
===================================================================
RCS file: templates/base/images/updated.gif
diff -N templates/base/images/updated.gif
Binary files /tmp/cvsGiBImz and /dev/null differ
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] tts admin.php index.php newticket.php viewticke...,
Dave Hall <=