<?php

/**
* @version 2.6.3
* @package Joomla 1.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
*/

    $mosConfig_live_site = JURI::base( true );

    require("../components/com_dtregister/config.dtregister.php");

  	$database = &JFactory::getDBO();

?>

<script language="javascript">

			function saveOrder(n,task)

			{

				for ( var j = 0; j <= n; j++ )

				{

					box = eval( "document.adminForm.cb" + j );

					if ( box ) {

						if ( box.checked == false ) {

							box.checked = true;

						}

					} else {

						alert("You cannot change the order of items, as an item in the list is `Checked Out`");

						return;

					}

				}

				submitform(task);

			}

		</script>

    <form action="index2.php" method="post" name="adminForm">

  <table cellpadding="4" cellspacing="0" border="0" width="100%">

    <tr>

      <td width="50%" align="left">&nbsp;</td>

      <td nowrap><?php echo JText::_( 'DT_DISPLAY_NUM' ); ?> :</td>

      <td nowrap><?php echo $pageNav->getLimitBox(); ?> </td>

      <td><?php echo JText::_( 'DT_FILTER' ); ?>:</td>

	  	<td>

	  		<?php

	  			echo $lists["event_list"];

	  		?>

	  	</td>

       <!-- <td>

         <?php

		echo JText::_( 'DT_SHOW' );

		?>

        </td>-->

         <td>

        <?php

		    $options=array();

        $options[]=JHTML::_('select.option',"-1",JText::_( 'DT_ALL_EVENT' ));

	      $options[]=JHTML::_('select.option',"1",JText::_( 'DT_PUBLISHED' ));

	      $options[]=JHTML::_('select.option',"0",JText::_( 'DT_UNPUBLISHED' ));

        $publish = JRequest::getVar('publish') ;

	      echo JHTML::_('select.genericlist', $options,"publish",' onchange="submit()" ',"value","text",$publish);

			?>

        </td>
        
        <td>

        <?php

		    $options=array();

        $options[]=JHTML::_('select.option',"-1",JText::_( 'DT_HIDE_ARCHIVE' ));

	      $options[]=JHTML::_('select.option',"1",JText::_( 'DT_SHOW_ARCHIVE' ));

	      $options[]=JHTML::_('select.option',"0",JText::_( 'DT_ALL_EVENT' ));

        $archive = JRequest::getVar('archive',-1) ;

	      echo JHTML::_('select.genericlist', $options,"archive",' onchange="submit()" ',"value","text",$archive);

			?>

        </td>

      <td><?php echo JText::_( 'DT_SEARCH' ); ?>:</td>

      <td><input type="text" name="search" value="<?php echo $search;?>" class="inputbox" onChange="document.adminForm.submit();" />

      <input type="hidden" name="act" value="groups"  />

      </td>

      <td width="right"> <?php if(isset($clist)){echo $clist;} ?> </td>

    </tr>

    <tr>

      <td colspan="9">

      <b>NOTE:</b>  To setup registration details for an event, click the NEW button above.<br />

      The Filter on this page will ONLY show events that have already been setup in DT Register.

      </td>

    </tr>

	  <tr>

	  <td colspan="9" align="left"><b>DT Register</b> is a tool that works in conjunction with the JEvents component to enable you to take online registrations for your events, paid or unpaid.

	  You can setup individual and group registration rates, set late fees, etc.  Fees are then paid with a credit card and processed through your Authorize.net payment gateway OR through a PayPal account.<br />

	  </td>
	  
	</tr>

	<tr>

	  <td colspan="9" align="left">

    <p style="background: #d3e8c1; padding:5px;">

    To get JEvents, <a href="http://joomlacode.org/gf/project/jevents/frs" target="_blank">click here</a>.  We recommend using version 1.5.2 or later. The JEvents modules and plugins are completely optional.<br /><br />
    
    <?php
	   $database =& JFactory::getDBO();
      
	   $table_list = $database->getTableList();
		
	   $old_jevent_table_name = $database->getPrefix()."events";
	   
  
     // retrieving a single row as an object
    
	 
	   if(!in_array($old_jevent_table_name,$table_list)) {
	   
	   }else{

	  ?>

    If you have migrated events from JEvents 1.4.x to JEvents 1.5 in addition to upgrading to DT Register 2.5.x, please check and see if your events and records in DT Register are still correct.  

    It is possible that the EventIDs could have changed and may need re-synced.  <b><a href="index.php?option=com_dtregister&task=sync">CLICK HERE</a></b> to check your events.
  <?php }
  
   ?>
    </p>

    </td>

	</tr>

	  <td colspan="9" align="left">For tutorials, support and more information, go to <b><a href="http://www.DTHDevelopment.com" target="_blank">http://www.DTHDevelopment.com</a></b>.<br />

&copy;2006 DTH Development</td>

	</tr>

	  <td colspan="9">&nbsp;</td>

	</tr>

  </table>

    <table cellpadding="4" cellspacing="0" border="0" width="100%" class="adminlist">

      <tr>

        <th width="20">

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

        </th>

        <th class="title" nowrap><?php echo JText::_( 'DT_EVENT_NAME' ); ?>:</th>
        <th class="title" nowrap><?php echo JText::_( 'DT_EVENTID' ); ?>:</th>
        <th class="title" nowrap><?php echo JText::_( 'DT_PUBLISH' ); ?>:</th>

        <th class="title" nowrap><?php echo JText::_( 'DT_CATEGORY_NAME' ); ?>:</th>
        
        <th class="title" nowrap><?php echo JText::_( 'DT_EVENT_TIME' ); ?>:</th>

        <th class="title" nowrap><?php echo JText::_( 'DT_NUMBER_MEMBERS' ); ?>:</th>

        <th class="title" nowrap><?php echo JText::_( 'DT_GROUP_RATE' ); ?>:</th>

        <th class="title" nowrap><?php echo JText::_( 'DT_RATE_PER_PERSON' ); ?>:</th>

	      <th class="title" nowrap><?php echo JText::_( 'DT_ADMIN_EMAIL' ); ?>:</th>
     <?php
     if($eventListOrder==0){
	  ?>
        <th class="title" colspan="2" nowrap><?php echo JText::_( 'DT_REORDER' ); ?>:</th>
	
		    <th class="title" nowrap><?php echo JText::_( 'DT_ORDER' ); ?>:

			   <a href="javascript: saveOrder( <?php echo count( $rows )-1; ?>,'saveorder_event')"><img src="images/filesave.png" border="0" width="16" height="16" alt="<?php echo JText::_( 'DT_SAVE_ORDER' ); ?>" /></a>

		    </th>
       <?php
	 }
	?>
      </tr>

<?php

    $k = 0;

	  $prev_eventid = 0;

	  $n=count( $rows );

    if ($n>0){

    for ($i=0, $n=count( $rows ); $i < $n; $i++ ) {

      $row = &$rows[$i];

      $row->title = tmpl_event_name($event_show_date,$row->summary,get_date_only($row->dtstart,$row->dtend));

     // $row->title=$row->summary." (".get_date($row->dtstart).")";

      // get the name of the category for this event

      $sql = 'SELECT categoryName FROM #__dtregister_categories WHERE categoryId='. $database->Quote( $row->category );

      $database->setQuery($sql);

	    $catRow = $database->loadResult();

	    $j=$i;

	  for($j=$i;isset($rows[$j]) && $row->eventId == $rows[$j]->eventId ;$j++){

	  }

	  $rowspan = $j - $i;

      if (!$catRow){$catRow=JText::_( 'DT_NONE' );}

?>

      <tr class="<?php echo "row$k"; ?>">

        <td width="20">

          <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->slabId; ?>" onclick="isChecked(this.checked);" />

        </td>

        <td align="left">

          <a href="index2.php?option=com_dtregister#edit" onclick="return listItemTask('cb<?php echo $i;?>','edit')">

            <?php echo $row->title; $row->eventId ;?>

          </a>

	  <?php

      if(!isset($rows[$i-1])||$rows[$i-1]->eventId != $rows[$i]->eventId ){

	  ?>

       <?php

         $arr_status = array('Publish','Unpublish');

         $img = $row->publish ? 'publish_g.png' : 'publish_x.png';

		     $alt = $row->publish ? JText::_( 'DT_PUBLISHED' ) : JText::_( 'DT_UNPUBLISHED' );

		?>

	     </td>
        <td rowspan="<?php echo $rowspan; ?>">
           <?php echo (int)$row->eventId;  ?>
        </td>
       <td align="left" rowspan="<?php echo $rowspan; ?>">

         <!--a href="index.php?option=com_dtregister&task=groupPublish&eventId=<?php echo $row->eventId; ?>&status=<?php echo $row->publish?'0':'1'; ?>" --->
         
         <?php $task =  $row->publish?'UngroupPublish':'groupPublish'; ?>
         <a href="index2.php?option=com_dtregister#groupPublish" onclick="return listItemTask('cb<?php echo $i;?>','<?php echo $task; ?>')">
         <img src="images/<?php echo $img;?>" width="12" height="12" border="0" alt="<?php echo $alt; ?>" /></a>

       </td>

    <?php } ?>

        <td align="left"><?php echo $catRow; ?></td>
        
        <td align="left"><?php echo get_time($row->dtstart,$row->dtend);?></td>

        <td align="left"><?php echo $row->memberTotal; ?></td>

        <td align="left"><?php echo numberFormat($row->regGroupRate); ?></td>

        <td align="left"><?php echo numberFormat($row->regGroupPerRate); ?></td>

		    <td align="left"><?php echo $row->email; ?></td>

	  <?php

      if(!isset($rows[$i-1])||$rows[$i-1]->eventId != $rows[$i]->eventId ){

	  ?>
    <?php
     if($eventListOrder==0){
	?>
	  <td align="left" rowspan="<?php echo $rowspan; ?>">

            <span><?php echo $pageNav->orderUpIcon( $i, true,'orderup_event', 'Move Up' ); #echo $pageNav->orderUpIcon( $i, ($row->category == @$rows[$i-1]->category), 'orderup_event', 'Move Up' ); ?></span>

		</td>
 
		<td align="left" rowspan="<?php echo $rowspan; ?>">

			<?php

            if($rowspan > 1 ){

            	$k = $j-1;

            }else{

            	$k = $i;

            }

			?>

			<span><?php echo $pageNav->orderDownIcon( $i, $k, true,'orderdown_event', 'Move Down');# echo $pageNav->orderDownIcon( $k, $n, ($row->category == @$rows[$k+1]->category),'orderdown_event', 'Move Down'); ?></span>

		</td>

		<td align="left" rowspan="<?php echo $rowspan; ?>">

			<input type="text" name="order[<?php echo $row->eventId;?>]" size="5" value="<?php echo $row->ordering; ?>" <?php //echo $disabled ?> class="text_area" style="text-align: center" />

		</td>
      <?php
    }
   ?>
        <?php

      }

	  ?>

      <?php    $k = 1 - $k; echo  "</tr>" ; }

    } else { ?>

		<td align="center" colspan="16"><?php echo '<b>'. JText::_( 'DT_NO_EVENTS' ) . '</b>'; ?></td>

	<?php } ?>

      <tr>

        <th align="center" colspan="16">

          <?php echo $pageNav->getPagesLinks(); ?></th>

      </tr>

      <tr>

        <td align="center" colspan="16">

          <?php # echo $pageNav->writePagesCounter(); ?></td>

      </tr>

    </table>

    <input type="hidden" name="option" value="<?php echo $option;?>" />

    <input type="hidden" name="limitstart" value="<?php echo $pageNav->limitstart; ?>" />

	<input type="hidden" name="boxchecked" value="0" />

	 <input type="hidden" name="task" value="" />

    </form>

<?php

?>