<?
//define("SSL_AUTHORIZATION",2);
define("ADMIN_AUTHORIZATION",1);
include("../../../includes/common.php");


$table = "email_tpl";

$id = $_GET['id']==""?$_POST['id']:$_GET['id'];
$group_ids = $_GET['group_ids']==""?$_POST['group_ids']:$_GET['group_ids'];
$action = trim($_GET['action']=="")?trim($_POST['action']):trim($_GET['action']);

if(is_numeric($id)){
	$group_ids = Array();
	$group_ids[0]=$id;
}

$result_flag = true;

if(sizeof($group_ids)==0||!is_array($group_ids)){
	header("Location: ./mail.php?l_pager");
	exit;
}

switch($action){
	case "delete":
		$flag = true;
		foreach($group_ids as $value){
//			if(!(@ibase_query($DB_LINK,"delete from $table where id=$value"))){
    		if(!(@DeleteRecord($table,$value))){
				$result_flag = false;
				break;
			}
		}
		break;
}
if($result_flag){
	$_SESSION['STATUS_MSG'] = "Шаблон успешно удален!"; 
	header("Location: ./mail.php?l_pager");
}
else{
	$_SESSION['ERROR_MSG'] = "Ошибка при работе с базой данных."; 
	header("Location: ./mail.php?l_pager");
}
exit;
?>