<?php
	/***************************************************************************\
	* phpGroupWare - Notepad													*
	* http://www.phpgroupware.org												*
	* Written by: Andy Holman (LoCdOg)											*
	* --------------------------------------------								*
	* 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.21 2001/05/15 01:36:34 bettina Exp $ */

	if (! $id)
	{
		Header('Location: ' . $phpgw->link('/notes/index.php',"cat_id=$cat_id&start=$start&search=$search"));
	}

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

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

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

### SET THE QUERY STRING ###

		$phpgw->db->query("DELETE FROM phpgw_notes WHERE note_id='$id'");
		Header('Location: ' . $phpgw->link('/notes/index.php',"cat_id=$cat_id&start=$start&search=$search"));
	}
	else
	{
		$hidden_vars = '<input type="hidden" name="search" value="' . $search . '">' . "\n"
					. '<input type="hidden" name="start" value="' . $start . '">' . "\n"
					. '<input type="hidden" name="id" value="' . $id . '">' . "\n"
					. '<input type="hidden" name="cat_id" value="' . $cat_id . '">' . "\n";

		$t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
		$t->set_file(array('delete' => 'delete.tpl'));

		if (isset($phpgw_info['user']['preferences']['notes']['notes_font']))
		{
			$font = $phpgw_info['user']['preferences']['notes']['notes_font'];
		}
		else
		{
			$font = set_font();
		}

		$t->set_var('deleteheader',lang('Are you sure you want to delete this note ?'));
		$t->set_var('hidden_vars',$hidden_vars);
		$t->set_var('nolink',$phpgw->link('/notes/index.php',"id=$id&cat_id=$cat_id&search=$searcht&start=$start"));
		$t->set_var('lang_no',lang('No'));
		$t->set_var('font',$font);

		$t->set_var('action_url',$phpgw->link('/notes/delete.php',"id=$id"));
		$t->set_var('lang_yes',lang('Yes'));
		$t->pparse('out','delete');
	}

	$phpgw->common->phpgw_footer();
?>
