<?php
  /**************************************************************************\
  * phpGroupWare - Brewer delete x                                           *
  * http://www.phpgroupware.org                                              *
  * Written by: Miles Lott <milosch@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: delete.php,v 1.2 2001/09/11 12:38:28 milosch Exp $ */

	if ($confirm || !$id)
	{
		$GLOBALS['phpgw_info']['flags'] = array(
			'noheader' => True,
			'nonavbar' => True
		);
	}

	$GLOBALS['phpgw_info']['flags']['currentapp'] = 'brewer';
	include('../header.inc.php');

	if (!$id)
	{
		Header('Location: ' . $GLOBALS['phpgw']->link('/brewer/index.php',"start=$start&order=$order"));
	}

	if($confirm)
	{
		$accountid = $GLOBALS['phpgw_info']['user']['account_id'];

		$GLOBALS['phpgw']->db->query("DELETE FROM phpgw_brewer_" . $type . "s WHERE id='$id'");
		Header('Location: ' . $GLOBALS['phpgw']->link('/brewer/index.php',"start=$start&order=$order"));
	}
	else
	{
		$hidden_vars = '<input type="hidden" name="sort" value="$sort">' . "\n"
			. '<input type="hidden" name="order" value="' . $order . '">' . "\n"
			. '<input type="hidden" name="start" value="' . $start . '">' . "\n"
			. '<input type="hidden" name="id" value="' . $id . '">' . "\n";

		$GLOBALS['phpgw']->template->set_file(array('delete' => 'delete.tpl'));

		$GLOBALS['phpgw']->template->set_var('deleteheader',lang("Are you sure you want to delete this $type ?"));
		$nolinkf = $GLOBALS['phpgw']->link('/brewer/index.php',"id=$id");
		$nolink = "<a href=\"$nolinkf\">" . lang('No') . "</a>";
		$GLOBALS['phpgw']->template->set_var('nolink',$nolink);
		$GLOBALS['phpgw']->template->set_var('font',$font);

		$yeslinkf = $GLOBALS['phpgw']->link('/brewer/delete.php',"id=$id&type=$type&confirm=True");

		$yeslinkf = "<FORM method=\"POST\" name=yesbutton action=\"".$GLOBALS['phpgw']->link('/brewer/delete.php')."\">"
			. $hidden_vars
			. '<input type=hidden name="id value="' . $id . '">'
			. '<input type=hidden name="type" value="' . $type . '">'
			. '<input type=hidden name="confirm" value="True">'
			. '<input type=submit name="yesbutton" value="Yes">'
			. '</FORM><SCRIPT>document.yesbutton.yesbutton.focus()</SCRIPT>';
		$yeslink = "<a href=\"$yeslinkf\">" . lang('Yes') ."</a>";
		$yeslink = $yeslinkf;

		$GLOBALS['phpgw']->template->set_var('yeslink',$yeslink);
		$GLOBALS['phpgw']->template->pfp('out','delete');
	}

	$GLOBALS['phpgw']->common->phpgw_footer();
?>
