<?/*
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
*/?>


<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">


<table cellpadding="0" border="0" cellspacing="0">
<tr><td>
<div class="athenatitleshadow">Delete Tickets<div class="athenatitle">Delete Tickets</div></div>
<br />
</td></tr></table>

<?php
  require_once 'db.php';
  require_once 'ticket.php';
  require_once 'person.php';
  require_once 'comment.php';
  require_once 'server_functions.php';

  globalize_request_keys('ticket_id', 'submit', 'del_person');

  if (!$ticket_id) {
    show_form ();
    return;
  }

  if ($submit == 'Delete') {
    print "<font class=\"errors\">Are you sure you want to delete: <b>$ticket_id?</b></font><br />\n";
    #print 'Delete the person who submitted the ticket? <input type="checkbox" name="del_person" value="1" /> (you probably want this)<br />'."\n";
    print "<input type=\"hidden\" name=\"ticket_id\" value=\"$ticket_id\" />\n";
    print "<input type=\"hidden\" name=\"submit\" value=\"Yes Delete Now\" />\n";
    print "<br /><table cellspacing=\"0\" cellpadding=\"1\" border=\"0\" bgcolor=\"#de0000\"><tr><td><input type=\"submit\" name=\"submit\" value=\"Yes Delete Now\" /></td></tr></table>\n";
    print "</form>\n";
    return;
  }

  if ($submit != 'Yes Delete Now') {
    print "No action?! ($submit)";
    return;
  }

  $ticket_p = new Ticket ($dbi);
  $person = new Person ($dbi);
  $comment = new Comment ($dbi);
  $search_result = new Search_Result ($dbi);

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

  print "<font class=\"errors\"><b>Your ticket deletion was successful.</b></font><br />\n";
  $search_result->Delete_by_Ticket_ID ($ticket_id);

  #print "not deleting comments.<br />\n";
  #$comment->Delete_by_Ticket_ID ($ticket_id);

##
## this assumes the ticket is in no other RMSes.  If it is the action will fail.
##

  print "<br />\n";
  $ticket->Delete ($ticket_id);

  if ($del_person) {
    print "<font class=\"errors\">Not Deleting Person</font><br />\n";
    #$upid = $ticket->Get ('user_person_id');
    #$person->Delete_Types ($upid);
    #$person->Delete ($upid);
  }
?>

If you would like delete another ticket...<br />

<?php

show_form ();

function show_form () { ?>

<br />

<table cellpadding="0" border="0" cellspacing="0">
<tr><td>
Enter your ticket ID:&nbsp;&nbsp;</td>
<td><input type="text" name="ticket_id" size="7" /><input type="hidden" name="submit" value="Submit" />&nbsp;&nbsp;</td>
<td><table cellspacing="0" cellpadding="1" border="0" bgcolor="#de0000">
<tr>
<td><input type="submit" name="submit" value="Delete" /></td>
</tr>
</table></td></tr></table>

</form>
<?php } ?>


