$GLOBALS['phpgw']->db->query("update phpgw_tts_tickets set ticket_billable_hours='" . $ticket['billable_hours'] . "' where ticket_id='{$ticket_id}'", __LINE__, __FILE__);
     $GLOBALS['phpgw']->historylog->add('H', $ticket_id, $ticket['billable_hours'], $old_billable_hours);
 }
 if ($old_billable_rate != $ticket['billable_rate']) {
     $fields_updated = True;
     $GLOBALS['phpgw']->db->query("update phpgw_tts_tickets set ticket_billable_rate='" . $ticket['billable_rate'] . "' where ticket_id='{$ticket_id}'", __LINE__, __FILE__);
     $GLOBALS['phpgw']->historylog->add('B', $ticket_id, $ticket['billable_rate'], $old_billable_rate);
 }
 if ($ticket['state'] && $old_state != $ticket['state']) {
     $fields_updated = True;
     $GLOBALS['phpgw']->db->query("update phpgw_tts_tickets set ticket_state='" . $ticket['state'] . "' where ticket_id='{$ticket_id}'", __LINE__, __FILE__);
     $GLOBALS['phpgw']->historylog->add('N', $ticket_id, $ticket['state'], $old_state);
 }
 if ($ticket['note']) {
     $fields_updated = True;
     $ticket['note'] = html_activate_urls($ticket['note']);
     $GLOBALS['phpgw']->historylog->add('C', $ticket_id, $ticket['note'], '');
     // Do this before we go into mail_ticket()
     $GLOBALS['phpgw']->db->transaction_commit();
 } else {
     // Only do our commit once
     $GLOBALS['phpgw']->db->transaction_commit();
 }
 if ($fields_updated) {
     $GLOBALS['phpgw']->session->appsession('messages', 'tts', lang('Ticket has been updated') . '<br/>' . $messages);
     if ($GLOBALS['phpgw']->config->config_data['mailnotification']) {
         mail_ticket($ticket_id);
     }
 }
 if ($_POST['save'] && $no_error) {
     $GLOBALS['phpgw']->redirect_link('/tts/index.php', array('filter' => $filter, 'order' => $order, 'sort' => $sort));
  \**************************************************************************/
// $Id: newticket.php,v 1.40.2.1 2004/07/22 20:12:11 shrykedude Exp $
// $Source: /cvsroot/egroupware/tts/newticket.php,v $
$GLOBALS['phpgw_info']['flags'] = array('noheader' => True, 'nonavbar' => True, 'currentapp' => 'tts', 'enable_send_class' => True, 'enable_config_class' => True, 'enable_categories_class' => True);
include '../header.inc.php';
$GLOBALS['phpgw']->config->read_repository();
if ($_POST['cancel']) {
    $GLOBALS['phpgw']->redirect_link('/tts/index.php');
}
if ($_POST['submit'] && !empty($_POST['ticket_subject'])) {
    if (get_magic_quotes_gpc()) {
        foreach (array('subject', 'details') as $name) {
            $_POST['ticket_' . $name] = stripslashes($_POST['ticket_' . $name]);
        }
    }
    $_POST['ticket_details'] = html_activate_urls($_POST['ticket_details']);
    $ticket_billable_hours = str_replace(',', '.', $_POST['ticket_billable_hours']);
    $ticket_billable_rate = str_replace(',', '.', $_POST['ticket_billable_rate']);
    $GLOBALS['phpgw']->db->query("insert into phpgw_tts_tickets (ticket_state,ticket_group,ticket_priority,ticket_owner," . "ticket_assignedto,ticket_subject,ticket_category,ticket_billable_hours," . "ticket_billable_rate,ticket_status,ticket_details) values ('" . intval($_POST['ticket_state']) . "','" . intval($_POST['ticket_group']) . "','" . intval($_POST['ticket_priority']) . "','" . $GLOBALS['phpgw_info']['user']['account_id'] . "','" . intval($_POST['ticket_assignedto']) . "','" . $GLOBALS['phpgw']->db->db_addslashes($_POST['ticket_subject']) . "','" . intval($_POST['ticket_category']) . "','" . $GLOBALS['phpgw']->db->db_addslashes($ticket_billable_hours) . "','" . $GLOBALS['phpgw']->db->db_addslashes($ticket_billable_rate) . "','O','" . $GLOBALS['phpgw']->db->db_addslashes($_POST['ticket_details']) . "')", __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_link('/tts/viewticket_details.php', '&ticket_id=' . $ticket_id);
} else {
    if ($_POST['submit']) {
        //there is an error:
        $GLOBALS['phpgw']->template->set_var('messages', lang('ERROR: The subject of the ticket is not specified.'));
    } else {