<?
## Email File -> notify seller if an wanted ad has closed
## called only from the main_cron.php page

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

$row_details = $db->get_sql_row("SELECT u.name, u.username, u.email, u.mail_item_closed, 
	w.name AS item_name, w.wanted_ad_id FROM " . DB_PREFIX . "wanted_ads w
	LEFT JOIN " . DB_PREFIX . "users u ON u.user_id=w.owner_id
	WHERE w.wanted_ad_id='" . $mail_input_id . "'");

$send = ($row_details['mail_item_closed']) ? true : false;

## text message - editable
$text_message = 'Hallo %1$s,

Ihr Gesuch, %2$s, ist beendet.

Um Details dieses Gesuchs anzuzeigen, klicken Sie bitte den unten stehenden Link:

%3$s

Mit freundlichen Grüßen,
Ihr Team von %4$s';

## html message - editable
$html_message = 'Hallo %1$s, <br>
<br>
Ihr Gesuch, %2$s, ist beendet. <br>
[ <a href="%3$s">Hier klicken</a> ] um Details dieses Gesuchs anzuzeigen. <br>
<br>
Mit freundlichen Grüßen, <br>
Ihr Team von %4$s';


$auction_link = process_link('wanted_details', array('wanted_ad_id' => $row_details['wanted_ad_id']));

$text_message = sprintf($text_message, $row_details['name'], $row_details['item_name'], $auction_link, $setts['sitename']);
$html_message = sprintf($html_message, $row_details['name'], $row_details['item_name'], $auction_link, $setts['sitename']);

send_mail($row_details['email'], 'Wanted Ad ID: ' . $row_details['wanted_ad_id'] . ' - Beendet', $text_message, 
	$setts['admin_email'], $html_message, null, $send);
?>