<?/*
Copyright (C) 2003 Media Net Link, Inc. Danville, CA 94526 USA

This file is part of AthenaRMS.

AthenaRMS 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.

AthenaRMS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/?>
<?php
  require_once 'db.php';
  require_once 'ticket.php';
  require_once 'comment.php';
  require_once 'server_functions.php';

  globalize_request_keys('ticket_id', 'person_type', 'person_id',
    'comments', 'query_id', 'internal');

  $ticket_p = new Ticket();
  $comment = new Comment();

  $ticket = $ticket_p->Info_by_Ticket_ID ($ticket_id);

  if ($person_type == 'user_person_id') {
    $pid = $ticket->Get ('user_person_id');
  } else {
    $pid = $person_id;
  }

  if (!$pid) {
    print "Missing person information";
    return;
  }

  if ($comments) {
    $cid = $comment->add (array(
      'ticket_id' => $ticket_id,
      'person_id' => $pid,
      'comments' => $comments,
      'updated_by' => $REMOTE_USER,
      'internal' => $internal,
    ));

    require_once 'server_functions.php';
    redirect ("edit_ticket?ticket_id=$ticket_id&query_id=$query_id", true);
  }
?>
