<?php
  /**************************************************************************\
  * phpGroupWare - phpgw_dj                                                  *
  * 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.3 2001/05/11 15:01:03 milosch Exp $ */

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

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

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

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

		$phpgw->db->query("DELETE FROM phpgw_dj_songlist WHERE song_id='$song_id'");
		Header('Location: ' . $phpgw->link('/dj/index.php',"cat_id=$cat_id&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=\"song_id\" value=\"$song_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'));

		$t->set_var('deleteheader',lang('Are you sure you want to delete this song ?'));
		$nolinkf = $phpgw->link('/dj/index.php',"song_id=$song_id");
		$nolink = "<a href=\"$nolinkf\">" . lang('No') . "</a>";
		$t->set_var('nolink',$nolink);
		$t->set_var('font',$font);

		$yeslinkf = $phpgw->link('/dj/delete.php',"song_id=$song_id&confirm=True");

		$yeslinkf = "<FORM method=\"POST\" name=yesbutton action=\"".$phpgw->link('/dj/delete.php')."\">"
			. $hidden_vars
			. "<input type=hidden name=song_id value=$song_id>"
			. "<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;

		$t->set_var('yeslink',$yeslink);
		$t->pparse('out','delete');
	}

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