<!-- This is a sample email template.
It will tell the user if the record is a new one or an updated one
It contains a link to the record in question
It shows in the table a list of the updated fields.
 -->

<?php
//the original data
$orig = JArrayHelper::fromObject($this->formModel->_origData[0]);
if (empty($orig)) {
	$action = 'toegevoegd';//new
} else {
	$action = 'aangepast';//existing
}
$formid = JRequest::getInt('fabrik');
$tableid = JRequest::getInt('tableid');
$rowid = JRequest::getInt('rowid');

//get the updated record from the database
$this->formModel->set('_origData', null);
$this->formModel->setOrigData();
$data = JArrayHelper::fromObject($this->formModel->_origData[0]);

$config =& JFactory::getConfig();
$live_site = $config->getValue('config.live_site');
$uri =& JURI::getInstance($live_site);
$url = 'http://'.$uri->getHost().JRoute::_("index.php?option=com_fabrik&view=form&fabrik=$formid&tableid=$tableid&rowid=$rowid");
?>
<p>Dag Administrator,</p>
<p>
Er is een record <?php echo $action ?> op de website <a href="http://www.duurzaamaanhetwerk.nl">http://www.duurzaamaanhetwerk.nl</a>.
Om het record online te bekijken klik op onderstaande link :
</p>
<a href="<?php echo $url?>"><?php echo $url?></a>
<p>(Wanneer u informatie van het record wilt aanpassen zorg dan eerst dat u ingelogd bent op de website.)</p>
<table>
<?php
foreach ($data as $key => $val) {
	if (substr($key, -4) == '_raw') {
		continue;
	}
	if(!array_key_exists($key, $orig) || $orig[$key] !== $val) {
	  echo "<tr><td>$key</td><td>";
	  if (is_array($val)) {
	  	foreach ($val as $v) {
	  		if (is_array($v)) {
	  			echo implode("<br>", $v);
		  	} else {
		  		echo implode("<br>", $val);
		  	}
	  	}
	  } else {
	  	echo $val;
	  }
	  echo "</td></tr>";
	}
}
?>
</table>