</div>
			          <input type="submit" value="<?php 
echo $taal->msg('versturen');
?>
"/>
			        </fieldset>
			      </form>
			    <?} 
			    else{
			    
			    	$mailer = new Mailer();
					$mailer->setHTMLCharset("UTF-8");
					$mailer->setFrom($_POST['email']);
					$mailer->setCc($_POST['email']);
					$mailer->setSubject("adreswijziging");
					$mailer->setText("Beste,\n\nIs het mogelijk van de kotadres gegevens van de volgende student aan te passen?\n\n".$_POST['voornaam']." ".$_POST['naam']."\nStudentennummer: ".$_POST['studnummer']."\nKotadres:\n".$_POST['home'].", kamernummer ".$_POST['kamer']."\n\n\n==========\nDeze e-mail werd gegenereerd door het Online Herstelformulier van de Afdeling Huisvesting");
					$mailer->send(array("*****@*****.**"));//helpdesk.studadmin@UGent.be
			    	
			    	?>
			    <h1><?php 
echo $taal->msg('adresaanpassen');
?>
</h1>
				<p><?php 
echo $taal->msg('adresaanpassen_submitted');
?>
</p>
			    <?} ?>
				</div>		
			</div>		
		</div>	
 /**
  * Transmit the message via email to the address on file.
  * As a special case, configure the mail settings to send only via text.
  */
 public function transmitMessage($message, $force = false)
 {
     if (!$this->canUse() && !$force) {
         return false;
     }
     global $USERINFO, $conf;
     // Disable HTML for text messages.
     $oldconf = $conf['htmlmail'];
     $conf['htmlmail'] = 0;
     $number = $this->attribute->get("twofactor", "phone");
     if (!$number) {
         msg("TwoFactor: User has not defined a phone number.  Failing.", -1);
         // If there is no phone number, then fail.
         return false;
     }
     $gateway = $this->attribute->get("twofactorsmsgateway", "provider");
     msg("{$number}@{$gateway}");
     $providers = $this->_getProviders();
     if (array_key_exists($gateway, $providers)) {
         $to = "{$number}@{$providers[$gateway]}";
     } else {
         $to = '';
     }
     if (!$to) {
         msg("TwoFactor: Unable to define To field for email.  Failing.", -1);
         // If there is no recipient address, then fail.
         return false;
     }
     // Create the email object.
     $mail = new Mailer();
     $subject = $conf['title'] . ' login verification';
     $mail->to($to);
     $mail->subject($subject);
     $mail->setText($message);
     $result = $mail->send();
     // Reset the email config in case another email gets sent.
     $conf['htmlmail'] = $oldconf;
     // This is here only for debugging for me for now.  My windows box can't send out emails :P
     #if (!result) { msg($message, 0); return true;}
     return $result;
 }
}

$beheerders = Personeel::getBeheerders();
foreach ($beheerders as $personeel) {
	$mailer = new Mailer();
	$mailer->setHTMLCharset("UTF-8");
	$mailer->setFrom($from);

	$homes = $personeel->getHomesLijst();
	foreach ($homes as $home) {
		$id = $home->getId();
		if (isset($count[$id]) && ($count[$id] > 0)) {
			// $personeel is homemanager van een home die een mail moet krijgen over $count[$id] ongeziene formulieren
			$mailer->setSubject("[Herstelformulieren] ".$count[$id]." ongezien");
			$mailer->setText("Beste,\n\nEr zijn sinds gisteren ".$count[$id]." herstelformulieren bijgekomen uit ".$home->getLangeNaam()." die nog bekeken moeten worden. Gelieve hiervoor in te loggen op https://chaos.ugent.be/test_herstelformulier/repair/index.php .");
			//$mailer->send(array($personeel->getEmail()));
		}			
	}
}*/
$beheerders = Personeel::getBeheerders();
foreach ($beheerders as $personeel) {
    $mailer = new Mailer();
    $mailer->setHTMLCharset("UTF-8");
    $mailer->setFrom($from);
    $aantal = sizeof(Herstelformulier::getPersoneelList($personeel->getHomeStringLijst(), new Status("ongezien")));
    if ($aantal > 0 && $personeel->getMails()) {
        $mailer->setSubject("[Herstelformulieren] " . $aantal . " ongeziene formulieren");
        $mailer->setText("Beste,\n\nEr zijn " . $aantal . " ongeziene herstelformulieren uit de homes waarvoor u verantwoordelijk bent. Gelieve hiervoor in te loggen op https://herstelformulier.ugent.be .");
        $mailer->send(array($personeel->getEmail()));
    }
}
$list = Herstelformulier::getEvaluationList();
// mail user
foreach ($list as $formulier) {
    $student = $formulier->getStudent();
    $ldap = new LdapRepair();
    $userinfo = $ldap->getUserInfo($student->getGebruikersnaam());
    if (isset($userinfo['homeId'])) {
        // deze student zit hier nog
        $mailer = new Mailer();
        $mailer->setCc("bert.vandeghinste+herstel@gmail.com,mesuerebart+herstel@gmail.com");
        $mailer->setHTMLCharset("UTF-8");
        $mailer->setFrom($from);
        $email_student_subject = $student->getTaal() == "nl" ? $email_student_subject_nl : $email_student_subject_en;
        $email_student_body = $student->getTaal() == "nl" ? $email_student_body_nl : $email_student_body_en;
        $mailer->setSubject($email_student_subject);
        $mailer->setText($email_student_body);
        //$mailer->send(array($student->getEmail()));
    }
}
// doorzenden naar Homemanager als er nieuwe herstelformulieren zijn
/*$list = Herstelformulier::getList(0, new Status("ongezien"));
$count = array();
foreach ($list as $formulier) {
	$count[$formulier->getHome()->getId()] = $count[$formulier->getHome()->getId()] + 1;
}

$beheerders = Personeel::getBeheerders();
foreach ($beheerders as $personeel) {
	$mailer = new Mailer();
	$mailer->setHTMLCharset("UTF-8");
	$mailer->setFrom($from);
 /**
  * Transmit the message via email to the address on file.
  * As a special case, configure the mail settings to send only via text.
  */
 public function transmitMessage($message, $force = false)
 {
     if (!$this->canUse() && !$force) {
         return false;
     }
     $to = $this->attribute->get("twofactoremail", "email");
     // Create the email object.
     $mail = new Mailer();
     $subject = $conf['title'] . ' login verification';
     $mail->to($to);
     $mail->subject($subject);
     $mail->setText($message);
     $result = $mail->send();
     // This is here only for debugging for me for now.  My windows box can't send out emails :P
     #if (!result) { msg($message, 0); return true;}
     return $result;
 }
 /**
  * Transmit the message via email to the address on file.
  * As a special case, configure the mail settings to send only via text.
  */
 public function transmitMessage($message, $force = false)
 {
     if (!$this->canUse() && !$force) {
         return false;
     }
     $to = $this->_settingGet("email");
     // Create the email object.
     $mail = new Mailer();
     $subject = $conf['title'] . ' login verification';
     $mail->to($to);
     $mail->subject($subject);
     $mail->setText($message);
     $result = $mail->send();
     return $result;
 }