- remove the download all link.. for now, upload all as well.

- support the new 2 fields downloading awards
- send the download output into a div ont he same screen, rather than on a whole new screen.
This commit is contained in:
dave 2009-09-25 07:11:43 +00:00
parent 0f31f72f07
commit 40789fc92c
2 changed files with 72 additions and 58 deletions

@ -26,15 +26,11 @@
user_auth_required('committee', 'admin');
require_once('curl.inc.php');
send_header("Download Awards",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Awards Main' => 'admin/awards.php' ));
function check_source($source)
{
global $config;
$q=mysql_query("SELECT * FROM fairs WHERE id='$source'");
switch($_GET['action']) {
case 'check':
$fairs_id = intval($_GET['fairs_id']);
$q=mysql_query("SELECT * FROM fairs WHERE id='$fairs_id'");
$fair=mysql_fetch_assoc($q);
if(!($fair['username'] && $fair['password'])) {
echo error(i18n("Username and Password are not set for source '%1'. Please set them in the SFIAB Configuration/External Award Sources editor first",array($r->name)));
@ -73,7 +69,7 @@
}
//get a list of all the existing awards for this external source
$aq=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$source' AND year='{$config['FAIRYEAR']}'");
$aq=mysql_query("SELECT * FROM award_awards WHERE award_source_fairs_id='$fairs_id' AND year='{$config['FAIRYEAR']}'");
$existingawards=array();
while($ar=mysql_fetch_object($aq)) {
$existingawards[$ar->id] = true;
@ -108,7 +104,7 @@
$tq=mysql_query("SELECT * FROM award_awards WHERE
external_identifier='$identifier' AND
award_source_fairs_id='$source' AND
award_source_fairs_id='$fairs_id' AND
year='$year'");
if(mysql_num_rows($tq) == 0) {
/* Award doesn't exist, create it, then update it with the common code below */
@ -117,7 +113,7 @@
award_source_fairs_id)
VALUES (2,'{$year}',
'".mysql_escape_string($identifier)."',
'$source')");
'$fairs_id')");
$award_id=mysql_insert_id();
} else {
echo i18n("Award already exists, updating info")."<br />";
@ -139,11 +135,14 @@
$sponsor_id=mysql_insert_id();
}
mysql_query("UPDATE award_awards SET
sponsors_id='$sponsor_id',
name='".mysql_escape_string($award['name_en'])."',
criteria='".mysql_escape_string($award['criteria_en'])."',
external_postback='".mysql_escape_string($postback)."'
external_postback='".mysql_escape_string($postback)."',
external_register_winners='".(($award['external_register_winners']==1)?1:0)."',
external_additional_materials='".(($award['external_additional_materials']==1)?1:0)."'
WHERE
id='$award_id'
AND external_identifier='".mysql_escape_string($identifier)."'
@ -215,52 +214,66 @@
}
echo "</i>";
exit;
}
send_header("Download Awards",
array('Committee Main' => 'committee_main.php',
'Administration' => 'admin/index.php',
'Awards Main' => 'admin/awards.php' ));
?>
<script type="text/javascript">
function award_download(id)
{
if(id == -1) return false;
$("#award_download_status").load("<?=$_SERVER['PHP_SELF']?>?action=check&fairs_id="+id);
}
</script>
<?
if(!function_exists('curl_init')) {
echo error(i18n("CURL Support Missing"));
echo notice(i18n("Your PHP installation does not support CURL. You will need to have CURL support added by your system administrator before being able to access external award sources"));
$links=false;
} else {
$links=true;
}
?>
<table class="tableview">
<tr><th><?=i18n("Source Name")?></th>
<th><?=i18n("Source Location URL")?></th>
<th><?=i18n("Check")?></th>
</tr>
<?
$q=mysql_query("SELECT * FROM fairs WHERE enable_awards='yes' ORDER BY name");
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo "<td>{$r->name}</td>\n";
echo "<td>{$r->url}</td>";
echo "<td align=\"center\">";
if($links)
echo "<a href=\"#\" onclick=\"award_download({$r->id})\">".i18n("check")."</a>";
else
echo "n/a";
echo "</td>";
echo "</tr>";
// $checkurl.="&check[]={$r->id}";
}
/*
if($links)
echo "<a href=\"award_download.php?action=check$checkurl\">".i18n("Check all sources")."</a>";
*/
?>
</table>
<br />
<div id="award_download_status"></div>
if($_GET['action']=="check") {
if(count($_GET['check'])) {
foreach($_GET['check'] AS $checksource) {
check_source(intval($checksource));
echo "<br />";
}
} else {
echo error(i18n("No sources available to check"));
}
} else {
if(!function_exists('curl_init')) {
echo error(i18n("CURL Support Missing"));
echo notice(i18n("Your PHP installation does not support CURL. You will need to have CURL support added by your system administrator before being able to access external award sources"));
$links=false;
} else {
$links=true;
}
$q=mysql_query("SELECT * FROM fairs WHERE enable_awards='yes' ORDER BY name");
echo "<table class=\"tableview\">";
echo "<tr><th>".i18n("Source Name")."</th>";
echo "<th>".i18n("Source Location URL")."</th>";
echo "<th>".i18n("Check")."</th>";
echo "</tr>";
while($r=mysql_fetch_object($q)) {
echo "<tr>";
echo "<td>{$r->name}</td>\n";
echo "<td>{$r->url}</td>";
echo "<td align=\"center\">";
if($links)
echo "<a href=\"award_download.php?action=check&check[]={$r->id}\">".i18n("check")."</a>";
else
echo "n/a";
echo "</td>";
echo "</tr>";
$checkurl.="&check[]={$r->id}";
}
echo "</table>\n";
echo "<br />";
if($links)
echo "<a href=\"award_download.php?action=check$checkurl\">".i18n("Check all sources")."</a>";
}
<?
send_footer();
?>

@ -505,8 +505,9 @@ while($r=mysql_fetch_object($q)) {
</table>
<br />
<a href="award_upload.php?action=send<?=$sendurl?>"><?=i18n("Send all awards")?></a>
<div id="award_upload_status"></div>
<?
/*<a href="award_upload.php?action=send<?=$sendurl?>"><?=i18n("Send all awards")?></a> */
send_footer();
?>