<?php 

if($_REQUEST['mass']!=""){
	$ids=$_REQUEST['mass'];

	$accounts = new Account();
	$accounts=$accounts->get_full_list("", "accounts.id in ('".implode("','",$ids)."')");

	foreach ($accounts as $account){
		$account->mark_deleted($account->id);
		$r=$db->query("select * from accounts_contacts where account_id='".$account->id."'");
		while($dane=$db->fetchByAssoc($r)){
			$db->query("delete from contacts where id='".$dane['contact_id']."'");
			$db->query("delete from accounts_contacts where id='".$dane['id']."'"); 
		}
	}
	
	header("Location: index.php?module=Accounts&action=index");
}
?>