<?
/* 
   This file is part of the 'Science Fair In A Box' project
   SFIAB Website: http://www.sfiab.ca

   Copyright (C) 2005 Sci-Tech Ontario Inc <info@scitechontario.org>
   Copyright (C) 2005 James Grant <james@lightbox.org>

   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public
   License as published by the Free Software Foundation, version 2.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; see the file COPYING.  If not, write to
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
   Boston, MA 02111-1307, USA.
*/
?>
<?
 require("../common.inc.php");
 require_once("../user.inc.php");
 user_auth_required('committee', 'admin');

 send_header("Communication Sending Status",
 		array('Committee Main' => 'committee_main.php',
			'Administration' => 'admin/index.php',
			'Communication' => 'admin/communication.php')
			);
 echo "<br />";

echo "<h3>".i18n("Communication Sending Status")."</h3>\n";
echo "<div style=\"margin-left: 20px\">";

if(file_exists("../data/communication.lock"))
{
	$lines=file("../data/communication.lock");
	echo "<b>Email ID:</b> ".$lines[0]." <br>";
	echo "<b>Started:</b> ".$lines[1]." <br>";
	echo "<b>Subject:</b> ".$lines[2]." <br>";
	echo "<b>Total Recipients:</b> ".$lines[3]." <br>";
	echo "<b>To:</b> ".$lines[4]." <br>";
	echo "</div>";

	$id=trim($lines[0]);
	$total=trim($lines[3]);

	echo "<h3>".i18n("Progress")."</h3>";
	echo "<div style=\"margin-left: 20px\">";
	if(file_exists("../data/communication.lock.$id"))
	{
		$progresslines=file("../data/communication.lock.$id");
		$num=$progresslines[0];
		$percent=round($num/$total*100,1);
		echo i18n("%1 of %2 (%3%)",array($num,$total,$percent));

	}
	else
	{
		echo "Queued to start (should start within the next minute)";
	}
	echo "</div>";

	echo "<br><br>Press your browsers 'Refresh' Button to see updated status";
}
else
{
	echo notice("No Email Communications are currently being sent out");
	echo "</div>";
}


send_footer();
?>
