<?php

/**
* @version 2.7.18
* @package Joomla 2.5
* @subpackage DT Register
* @copyright Copyright (C) 2006 DTH Development
* @copyright contact dthdev@dthdevelopment.com
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
*/

global $Itemid,$xhtml,$member_confirmnum;

$mfield = $this->getModel('field');
$tfield = $mfield->table;

$fields = $tfield->memberlistfields();
$fieldtype = $this->getModel('fieldtype');
$mdiscountcode = $this->getModel('discountcode')->table;
$fieldtypes = $fieldtype->getTypes();
?>
<style>
 div.pagetitle.icon-48-dtregister {
    background-image:none;
    background-repeat: no-repeat;
    line-height: 48px;
    padding-left: 0 !important;
    text-transform: uppercase;
}
</style>
<form action="index.php" name="adminForm" method="post" >
<table cellpadding="4" cellspacing="1" border="0" width="100%" class="adminform adminlist">
   <tr>

        <th width="20">

				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->members ); ?>);" />

		</th>
       <?php
       foreach($fields as $field){
		?>
        <th>

				<?php echo $field->label;?>

		</th>
        <?php
	   }
	   ?>
        <?php if($member_confirmnum) { ?>
       <th>
         <?php echo JText::_('DT_CONFIRMATION_NUMBER'); ?>
       </th>
       <?php }?>
       
        <th>

	    <?php echo JText::_( 'DT_DISCOUNT_CODE' ); ?>

	 </th>
       <th>

			<?php echo JText::_( 'DT_ATTENDED' ); ?>

	   </th>
       
    </tr>
<?php
  $k=0;
  $i=0;
 foreach($this->members as $member){
	 $code = "";
	 
	 if(isset($member->discount_code_id) && $member->discount_code_id != "" && $member->discount_code_id != 0){
	    $mdiscountcode->load($member->discount_code_id);
		$code = $mdiscountcode->code;
	 
	 } 
?>
<tr class="<?php echo "row$k"; ?>">
   
    <td>		<?php
                  echo $checked = JHTML::_('grid.id', $i,$member->groupMemberId); ?>

	</td>
    
     <?php
       foreach($fields as $field){
		?>
           <td>

				<?php
				  $classname = "Field_".$fieldtypes[$field->type];
				  $ObjField = new $classname();
				  $ObjField->load($field->id);
				  if(isset($member->fields[$field->id])){
					  $function = 'viewHtml';
					  if(is_callable(array($ObjField,'exportView'))){
						  $function = 'exportView';
					  }
					  echo $ObjField->$function((array)$member);
					  //echo $member['fields'][$field->id]." ".$classname;
				  }else{
					  echo '';
				   }
				 
				 ?>

		</td>
        <?php
	   }
	   ?>
        <?php if($member_confirmnum) { ?>
       <td>
         <?php echo $member->confirmnum; ?>
       </td>
       <?php }?>
       <td>
         <?php echo $code; ?>
       </td>
        <td><?php echo DtHtml::gridTask($member, $i,'attend'); ?></td>
</tr>
<?php	 
 $k = 1 - $k;
 $i++;
  }    
?>
</table>
<input type="hidden" name="option" value="<?php echo DTR_COM_COMPONENT;?>" />
<input type="hidden" name="userId" value="<?php echo $this->userId;?>" />
<input type="hidden" name="controller" value="member" />
<input type="hidden" name="task" value="index" />

<input type="hidden" name="filter_order" value="<?php echo Jrequest::getVar('filter_order');?>" />

<input type="hidden" name="filter_order_Dir" value="<?php echo Jrequest::getVar('filter_order_Dir');?>" />
<input type="hidden" name="tmpl" value="component" />
<input type="hidden" name="showtoolbar" value="1" />
<input type="hidden" name="boxchecked" value="0" />

</form>