<?
## File Version -> v6.04
## Email File -> notify user when a bid is placed on an auction on his watch list
## called only from the bid.php page!

if ( !defined('INCLUDED') ) { die("Access Denied"); }

$sql_select_auctions = $db->query("SELECT kw.keyword, a.auction_id, a.name AS item_name,  
	u.name AS user_name, u.username, u.email FROM " . DB_PREFIX . "keywords_watch kw
	INNER JOIN " . DB_PREFIX . "auctions a ON a.auction_id='" . $mail_input_id . "' AND (a.name LIKE kw.keyword OR a.description LIKE kw.keyword)
	INNER JOIN " . DB_PREFIX . "users u ON u.user_id=kw.user_id");

$send = true; ## always send

## send to all the winners of the auction for which the bank details have been set/changed
while ($watch_details = $db->fetch_array($sql_select_auctions))
{
	## text message - editable
	$text_message = 'Hallo %1$s,
	
Eine neue Auktion, die eins Ihrer Schlüsselwörter von Ihrer Schlüsselwortuhrliste zusammenbringt, ist gesetzt worden.
	
Auktion-Titel: %2$s.
	
Um den Gebotsverlauf dieser Auktion anzuzeigen, klicken Sie bitte folgenden Link:
	
%3$s
	
Mit freundlichen Grüßen,
Ihr Team von %4$s ';
	
	## html message - editable
	$html_message = 'Hallo %1$s, <br>
<br>
Eine neue Auktion, die eins Ihrer Schlüsselwörter von Ihrer Schlüsselwortuhrliste zusammenbringt, ist gesetzt worden.<br>
<br>
Auktion-Titel: <b>%2$s</b><br>
<br>
[ <a href="%3$s">Hier klicken</a> ] um nähere Informationen dieser Auktion anzuzeigen. <br>
<br>
Um den Gebotsverlauf dieser Auktion anzuzeigen, bitte [ <a href="%4$s">hier klicken</a> ]. <br>
<br>
Mit freundlichen Grüßen, <br>
Ihr Team von %4$s';
	
	
	$auction_link = process_link('auction_details', array('name' => $watch_details['item_name'], 'auction_id' => $watch_details['auction_id']));
	
	$text_message = sprintf($text_message, $watch_details['user_name'], $watch_details['item_name'], $auction_link, $setts['sitename']);
	$html_message = sprintf($html_message, $watch_details['user_name'], $watch_details['item_name'], $auction_link, $setts['sitename']);
	
	if (!empty($watch_details['email']))
	{
		send_mail($watch_details['email'], 'Keywords Watch - Keyword: ' . $watch_details['keyword'], $text_message, 	
			$setts['admin_email'], $html_message, null, $send);
	}
}
?>