<?php

$table_name = $_SESSION['db_prefix']."_alerts";
	$alert_query = "SELECT user_name, send_alert, send_email FROM $table_name WHERE alert_name = 'Min stock' ";
	$alert_result = mySQL_query($alert_query);
	$alert_num = mysql_num_rows($alert_result);
			
	$i=0;
	$email_address = '';
	while ($i<$alert_num) {
		$user_name = mysql_result($alert_result, $i, "user_name");
		$send_alert = mysql_result($alert_result, $i, "send_alert");
		
		
		if ($send_alert=='yes') {
			$table_name = $_SESSION['db_prefix']."_alerts_store";
			$message_query = "INSERT INTO $table_name (user_name, department, generated, alert, detail_1, detail_2, detail_3 ) VALUES ('".$user_name."', 'store', '".$entry_date."', '32', '".$store_item_id."', '', '".$total_quantity."' ) ";
			execsql($message_query);
		}
$i++;		
}
	
?>

