<?php

/**
 * @file
 * Customize the e-mails sent by Webform after successful submission.
 *
 * This file may be renamed "webform-mail-[nid].tpl.php" to target a
 * specific webform e-mail on your site. Or you can leave it
 * "webform-mail.tpl.php" to affect all webform e-mails on your site.
 *
 * Available variables:
 * - $node: The node object for this webform.
 * - $submission: The webform submission.
 * - $email: The entire e-mail configuration settings.
 * - $user: The current user submitting the form.
 * - $ip_address: The IP address of the user submitting the form.
 *
 * The $email['email'] variable can be used to send different e-mails to different users
 * when using the "default" e-mail template.
 */


$subData=$submission->data;
$comp=$node->webform['components'];



$iter=0;
foreach($comp as $cName=>$cId)
{

if($cName!=139 && $cName!= 20 && $cName!=31 && $cName!=45 && $cName!=135 && $cName!=102 && $cName!=118 && $cName!=120 && $cName!=121 && $cName!= 119)
{
$cData=$subData[$cName]['value'][0];
$cname=$comp[$cName]['name'];
$filterCname=rtrim($cname,":");

if($iter % 2 == 0) 
{
$leftArrN[]= $filterCname;
$leftArrD[]= $cData;
}
else
{
$rightArrN[]=$filterCname;
$rightArrD[]=$cData;

}


$iter++;


}


}

echo "<table>
<tr>
<th><p style='font-size: 12px;'>Submitted on %date</p>
<p style='font-size: 12px;'>Submitted by user: %username</p>
<p style='font-size: 12px;'>Submitted values are:</p></th>
</tr>";

$cmpNo=count($leftArrN);
for($i=0;$i<$cmpNo;$i++)
{

$lData=empty($leftArrD[$i])?"N/A":$leftArrD[$i];

$rData=empty($rightArrD[$i])?"N/A":$rightArrD[$i];

echo "<tr>
      <td style='width: 211px; font-weight: bold; font-size: 12px; vertical-align: top;'>".$leftArrN[$i]."</td>
      <td></td>
      <td style='width: 211px; font-size: 14px; vertical-align: top;'>".$lData."</td>
      <td></td>
      <td style='width: 211px; font-weight: bold; font-size: 12px; vertical-align: top;'>".$rightArrN[$i]."</td>
      <td style='width: 211px; font-size: 14px; vertical-align: top;'>".$rData."</td>
      </tr><tr></tr><tr></tr><tr></tr>";
}

echo "</table>";

 
?>

