<?php // This sends emails to the approriate individuals (no keep or remove yet)
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
 $dirsToCheck = array('/hsphere/local/home/apbcweb/artistsofpalmbeachcounty.org/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }

  list($common_informationRecords, $common_informationMetaData) = getRecords(array(
    'tableName'   => 'common_information',
    'allowSearch' => '0',
    'limit'       => '1',
	// 'debugSql' => true, 
  ));
  $common_informationRecord = @$common_informationRecords[0]; // get first record

  ?>
<?php         
list($master_exhibition_listRecords, $master_exhibition_listMetaData) = getRecords(array(
'tableName' => 'master_exhibition_list',

));
?>
<?php   
$numToName = array(); 
foreach ($master_exhibition_listRecords as $record){ 
  $numToName[$record['num']] = $record['title']; 


}
?>

<?php $agree = $CURRENT_USER['allowedFolders'] ?>
<?php 
 $where = ""; 
  ?>
<?php foreach ($master_exhibition_listRecords as $record): ?>
<?php if (strpos($agree, 'exhibition_manager')|| @$CURRENT_USER['isAdmin']): ?>
<?php if (@$CURRENT_USER['for_which_exhibition'] == $record['num']) { $where = $record['title'];}?>
<?php else: ?>
<?php if ($FORM['where'] == $record['num']) { $where = $record['title'];}?>
<?php endif ?>
<?php endforeach; ?>
<?php
 list($exhibition_email_testRecords, $exhibition_email_testMetaData) = getRecords(array(  
    'tableName'   => 'exhibition_email_test',  
    'where'       => " project_title = '$where'",  
	
  ));

?>

<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
  <select name="where">
    <option value=""><span class="body-text-bold">Select</span></option>
    <?php foreach($numToName as $num => $name): ?>
    <option value="<?php echo $num;?>"><?php echo $name;?></option>
    <?php endforeach?>
  </select>
  <input type="submit" name="submit" value="Select An Exhibition And Click To View">
</form>
<br />
<div  align="center">
<?php if(!$where):?>
<span class=" heading-text-red">***</span><span class=" heading-text-yellow">YOU MUST SELECT AN EXHIBITION TO VIEW THE SUBMISSIONS </span><span class=" heading-text-red">***</span>
<?php endif; ?>
 <?php foreach($exhibition_email_testRecords as $record) : ?>
 
<?php $first_name = $record['first_name'] ; ?> 
<?php $last_name = $record['last_name'] ; ?> 
  <?php
  

  $the_to = $record['email'];
   $the_from  = "exhibition-submissions@artistsofpalmbeachcounty.org";
$to = "$the_to";
$from = "$the_from";
$headers  = "From: $from\r\n";
    $headers .= "Content-type: text/html\r\n";  

$subject = "Your submission to the $where Exhibition has been Juried";
$message = <<<EOF
<html>
<style type="text/css">
  .body-text {font-family:Arial; font-size: 1em; }

</style>

  <body bgcolor='#7C7164'>
 <div align='left'> <img src="http://www.artistsofpalmbeachcounty.org/images/APBC-LOGO.png" width="800" height="183" /></div><br /><br />
  <div align='left' class='body-text'>
  Hello $first_name $last_name,
  <br /><br />
  Here is a message about your submission.
  <br /><br />
  Best,
  <br /><br />
 The Exhibition Committee<br />
  Artists of Palm Beach County</div>
  </body>
</html>
EOF;
   //end of message 
mail($to,$subject,$message,$headers);

?> 
 
<?php endforeach ?>