<?php

/**
* @version 2.8.14
* @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
*/

$jevent = $this->getModel('event')->tableJevt;

$category = $this->getModel('category')->table;

$location = $this->getModel('location')->table;

$section = $this->getModel('section')->table;

$row = $this->row;

$article = $row->get_article();

$jusertable = $this->getModel('user')->table->TableJUser;

global $default_group;

?>
<style type="text/css">

	#sortable { list-style-type: none; margin: 0; padding: 0; width: 60%; }

	#sortable li { margin: 0 3px 3px 3px; padding: 0.4em; padding-left: 1.5em; font-size: 1.4em; height: 18px; }

	#sortable li span { position: absolute; margin-left: -1.3em; }

	</style>

<table cellpadding="4" cellspacing="1" border="1" width="100%" class="adminform">

    <tr><td align="left"><?php echo JText::_( 'DT_EVENT_OWNER' ); ?>:</td>
	
	    <td><?php
		$joomla_users = $jusertable->optionslist() ;
		 echo JHTML::_('select.genericlist', DtHtml::options($joomla_users,JText::_("DT_SELECT_USER")),'data[event][user_id][]','multiple ','value','text',$row->user_id)?>
        <input type="hidden" name="data[moderator_order]" id="moderator_order" value="" />
        <span>
       <ul id="moderator_sortable">
       <?php
	   
	  
	   if(is_array($row->user_id)) {
		    $row->user_id = array_filter($row->user_id);
       foreach($row->user_id as $user_id){
	      echo '<li class="ui-state-default" id="userorder_'.$user_id.'"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>'.$joomla_users[$user_id].'</li>' ;
		  
	   }
	   }
	   ?>
       </ul>
</span>
   
        </td>
	
	    <td colspan="2" align="left">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_EVENT_OWNER_HELP' )), '', 'tooltip.png', '', ''); ?></td>
	
	</tr>  
    <?php 
	
	  if($row->slabId == ""){
		  echo $this->loadTemplate('event_type');
	 ?>
    <tr id="jeventrow">

        <td align="left"><?php echo JText::_( 'DT_SELECT_JEVENT' ); ?>:</td>

        <td width="400" id="jeventrow">

 			  <?php 

			   $events=DtHtml::options($jevent->optionslist(),JText::_('DT_SELECT_EVENT'));

			   echo JHTML::_('select.genericlist', $events,"data[event][eventId]","","value","text",$row->eventId); ?></td>

        <td colspan="2" align="left">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_EVENT_SELECTION_HELP' )), '', 'tooltip.png', '', ''); ?></td>

      </tr>
     <?php
     }else{
	    
		if($row->eventId){
		?>
         <script type="text/javascript">
		 
		   DTjQuery(function(){
			  DTjQuery('tr[id="timerow"]').find('input').attr('disabled',true);
			  DTjQuery("#dtstarttime").timeEntry('destroy');
              DTjQuery("#dtendtime").timeEntry('destroy');
		   })
		 </script>
        <?php
		}	 
	 
	 }
	  
	  ?>
       <tr id="timerow">

      	<td align="left"><?php echo JText::_( 'DT_EVENT_TITLE' ); ?>:</td>

      	<td>

            <input type="text" class="inputbox" id="summary" size="46" name="data[event][title]" value="<?php echo $row->title; ?>"  />

      	</td>

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

      		&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_EVENT_TITLE_HELP' )), '', 'tooltip.png', '', ''); ?>

      	</td>

   </tr>

   <tr>

	 <td align="left"><?php echo JText::_( 'DT_EVENT_CATEGORY' ); ?>:</td>

    <td><?php  
        
        $options=DtHtml::options($category->optionslist(),JText::_('DT_NONE'));



		echo JHTML::_('select.genericlist', $options,"data[category][]",'multiple="multiple" size="5"',"value","text",$row->category); ?></td>


    <td colspan="2">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_EVENT_CATEGORY_HELP' )), '', 'tooltip.png', '', ''); ?></td>

    </tr>

      <tr>

        <td align="left"><?php echo JText::_( 'DT_EVENT_LOCATION' ); ?>:</td>

        <td>

 			  <?php 

              $locationsOpts = DtHtml::options($location->optionslist(),JText::_('DT_SELECT_LOCATION'));

			  echo JHTML::_('select.genericlist', $locationsOpts,"data[event][location_id]","","value","text",$row->location_id); ?></td>

        <td colspan="2" align="left">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_SELECT_LOCATION_HELP' )), '', 'tooltip.png', '', ''); ?></td>

   </tr>
 <?php
  if($this->checkpermission()) {
  ?>
    <tr>

      	<td align="left"><?php echo JText::_( 'DT_EVENT_PUBLISH' ); ?>:</td>

      	<td>

			<?php

			$options=array();

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

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

            echo JHTML::_('select.radiolist', $options, 'data[event][publish]','','value','text',$row->publish);

			?>

      	</td>

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

      		&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_EVENT_PUBLISH_HELP' )), '', 'tooltip.png', '', ''); ?>

      	</td>

      </tr>
<?php
  } else{
 ?>
    <input type="hidden" class="inputbox" name="data[event][publish]" value="<?php echo $row->publish; ?>" />
 <?php
  }
?>

   <tr align="center" valign="middle">
	
	  <td align="left" valign="top"><?php echo JText::_( 'DT_TIME_FORMAT' );?>:</td>

		<td align="left" valign="top">

			<?php

			$options = array();

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

            $options[]=JHTML::_('select.option', '2', JText::_( 'DT_24_FORMAT' ));

			echo JHTML::_('select.genericlist', $options,'data[event][timeformat]','','value','text',$row->timeformat);

			?>

		</td>

		<td>&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_TIME_FORMAT_HELP' )), '', 'tooltip.png', '', ''); ?> </td>

		</tr>
       <tr id="timerow">

      	<td align="left"><?php echo JText::_( 'DT_EVENT_START' ); ?>:</td>

      	<td>
        <input type="text" class="error" id="dtstart" size="14" name="data[event][dtstart]" value="<?php echo $row->dtstart; ?>" readonly="readonly">
         <?php //echo JHTML::_("calendar",$row->dtstart,"data[event][dtstart]","dtstart",'%Y-%m-%d','class="checkdate"');?>

           <input type="button" class="button jeventdisable" value="..."

onclick="return DTshowCalendar('dtstart','%Y-%m-%d');" />

		   <input type="text" class="timeEntry checkdate" id="dtstarttime" size="10" name="data[event][dtstarttime]" value="<?php echo $row->dtstarttime; ?>" readonly="readonly" />&nbsp;
           <label for="dtstart" generated="true" class="error" style="display:none"></label>
           
      	</td>

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

      		&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_EVENT_START_HELP' )), '', 'tooltip.png', '', ''); ?>

      	</td>

      </tr>

       <tr id="timerow">

      	<td align="left"><?php echo JText::_( 'DT_EVENT_END' ); ?>:</td>

      	<td>
            <input type="text" class="" id="dtend" size="14" name="data[event][dtend]" value="<?php echo $row->dtend; ?>" readonly="readonly">

            <input type="button" class="button jeventdisable" value="..."

onclick="return DTshowCalendar('dtend','%Y-%m-%d');" />

            <input type="text" readonly="readonly" class="timeEntry checkdate" id="dtendtime" size="10" name="data[event][dtendtime]" value="<?php echo $row->dtendtime; ?>" />

      	</td>

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

      		&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_EVENT_END_HELP' )), '', 'tooltip.png', '', ''); ?>

      	</td>

    </tr>
    <tr align="center" valign="middle">

							   	<td align="left" valign="top"><?php echo JText::_( 'DT_EVENT_TIMEZONE' );?>:</td>

							      <td align="left" valign="top">

								   <?php
                                 $value = $row->timezone;
								 if (class_exists("DateTimeZone")){
									$zones = DateTimeZone::listIdentifiers();
									static $options;
									if (!isset($options)){
										$options = array();
										$options[] = JHTML::_('select.option', '', '- '.JText::_('DT_SELECT_TIMEZONE').' -');
										foreach ($zones as $zone) {
											if (strpos($zone,"/")===false) continue;
											if (strpos($zone,"Etc")===0) continue;
											$options[] = JHTML::_('select.option', $zone, $zone);
										}
									}
									echo JHTML::_('select.genericlist', $options, 'data[event][timezone]', 'class="inputbox"', 'value', 'text', $value);
								}
								else {
								    
									/*
									* Required to avoid a cycle of encoding &
									* html_entity_decode was used in place of htmlspecialchars_decode because
									* htmlspecialchars_decode is not compatible with PHP 4
									*/
									$value = htmlspecialchars(html_entity_decode($value, ENT_QUOTES), ENT_QUOTES);
						
									echo '<input type="text" name="data[event][timezone]" id="configtimezone" value="'.$value.'" class="inputbox" />';
								}
								   ?>

							   </td>

							   		<td align="left" colspan="2"><?php echo JHTML::tooltip((JText::_( 'DT_EVENT_TIMEZONE_TIP' )), '', 'tooltip.png', '', ''); ?> </td>

							   </tr>
      <tr>

	  	 <td align="left"><?php echo JText::_( 'DT_SEND_NOTIFICATION_TO' ); ?>:</td>

         <td align="left"><input class="inputbox required" type="text" name="data[event][email]" id="email" size="46" value="<?php echo $row->email; ?>" /></td>

	  <td colspan="2" align="left">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_SEND_NOTIFICATION_TO_HELP' )), '', 'tooltip.png', '', ''); ?></td>

   </tr>

       <?php
	    
	     if($row->slabId =="" ){

             echo $this->loadTemplate('repeat');

		 }elseif($row->parent_id == 0 && $row->repetition_id > 0){

			 echo $this->loadTemplate('editrepeat');

		 }elseif($row->parent_id == 0){

		     echo $this->loadTemplate('repeat');	 

		 }

	   ?>

      <tr>

        <td align="left"><?php echo JText::_( 'DT_REGISTRATION_TYPE' ); ?>:</td>

        <td>

 		    <?php 

			 $options=array();

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

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

             $options[]=JHTML::_('select.option',"both",JText::_('DT_BOTH'));
			 
			 // $options[]=JHTML::_('select.option',"no",JText::_('DT_NO_REGISTRATION'));

			echo JHTML::_('select.genericlist', $options,'data[event][registration_type]','','value','text',$row->registration_type); 

			?></td>

        <td colspan="2" align="left">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_REGISTRATION_TYPE_HELP' )), '', 'tooltip.png', '', ''); ?></td>

      </tr>

      <tr id="grouptype">

        <td align="left"><?php echo JText::_( 'DT_GROUP_REG_TYPE' ); ?>:</td>

        <td>

 		    <?php 

			 $options=array();

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

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

			 echo JHTML::_('select.genericlist', $options,'data[event][group_registration_type]','','value','text',$row->group_registration_type); 

			?></td>

        <td colspan="2" align="left">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_GROUP_REG_TYPE_HELP' )), '', 'tooltip.png', '', ''); ?></td>

      </tr>

      <tr>

      <td align="left"><?php echo JText::_( 'DT_PUBLIC_LIST' ); ?>:</td>

      <td align="left" valign="top">

	    <?php

	    $options=array();

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

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

	    echo JHTML::_('select.genericlist', $options,"data[event][public]","","value","text",$row->public);

	    ?>

	    </td>

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

      		&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_PUBLIC_LIST_HELP' )), '', 'tooltip.png', '', ''); ?>

      </td>

      </tr>

      <tr>

        <td align="left"><?php echo JText::_( 'DT_EVENT_MAX_REGISTRATION' ); ?>:</td>

        <td>

                   	<input type="text" class="inputbox" name="data[event][max_registrations]" size="5" value="<?php echo $row->max_registrations; ?>" />

		    </td>

        <td colspan="2" align="left">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_EVENT_MAX_REGISTRATION_HELP' )), '', 'tooltip.png', '', ''); ?></td>

    </tr>
    <tr align="center" valign="middle">
	
	    <td align="left" valign="top"><?php echo JText::_( 'DT_MIN_GROUP_SIZE' ); ?>:</td>

   		<td align="left" valign="top">
	
		<input id="min_group_size" class="inputbox" type="text" name="data[event][min_group_size]" size="5" value="<?php echo $row->min_group_size; ?>" /></td>

		<td colspan="2">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_MIN_GROUP_SIZE_DESC' )), '', 'tooltip.png', '', ''); ?></td>

	 </tr>
    <tr align="center" valign="middle">
	
	    <td align="left" valign="top"><?php echo JText::_( 'DT_MAX_GROUP_SIZE' ); ?>:</td>

   		<td align="left" valign="top">
	
		<input type="text" class="inputbox" id="max_group_size" name="data[event][max_group_size]" size="5" value="<?php echo $row->max_group_size; ?>" /></td>

		<td colspan="2">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_MAX_GROUP_SIZE_DESC' )), '', 'tooltip.png', '', ''); ?></td>

	 </tr>
	
	    <tr>

		<td align="left" valign="top"><?php echo JText::_( 'DT_CUSTOM_CONFIRM_NUMBER_PREFIX' );?>:</td>

        <td>

                 <input type="text" id="confirm_number_prefix" name="data[event][confirm_number_prefix]" size="5" value="<?php echo $row->confirm_number_prefix; ?>" />

		</td>

		<td colspan="2">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_CUSTOM_CONFIRM_NUMBER_PREFIX_HELP' )), '', 'tooltip.png', '', ''); ?> </td>

	</tr>

     <tr>

        <td align="left"><?php echo JText::_( 'DT_REGISTRATION_OPEN_DATE' ); ?>:</td>

        <td>

        	<?php

				if(defined('_JEXEC'))

        		{

        			echo JHTML::_("calendar",$row->startdate,"data[event][startdate]","startdate");

        		}

        		else

        		{

        		?>

        		<input class="inputbox" type="text" name="data[event][startdate]" id="startdate" size="14" maxlength="12" value="<?php echo $row->startdate; ?>" />

            	<input type="reset" class="button" value="..." onclick="return showCalendar('startdate', 'y-mm-dd');" />

        		<?php

        		}

        	?>

             <input type="text" class="timeEntry" id="starttime" size="10" name="data[event][starttime]" value="<?php echo $row->starttime; ?>" />

		    </td>

        <td colspan="2" align="left">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_REGISTRATION_OPEN_DATE_HELP' )), '', 'tooltip.png', '', ''); ?></td>

      </tr>  

      <tr>

        <td align="left"><?php echo JText::_( 'DT_CUT_OFF_DATE' ); ?>:</td>

        <td>

        	<?php

           	if(defined('_JEXEC'))

        		{

        			echo JHTML::_("calendar",$row->cut_off_date,"data[event][cut_off_date]","cut_off_date");

        		}

        		else

        		{

        		?>

        	    <input class="inputbox" type="text" name="data[event][cut_off_date]" id="cut_off_date" size="14" maxlength="12" value="<?php echo $row->cut_off_date; ?>" />

            	<input type="reset" class="button" value="..." onclick="return showCalendar('cut_off_date', 'y-mm-dd');" />

        		<?php

        		}

        	?>

            <input type="text" class="timeEntry" id="cut_off_time" size="10" name="data[event][cut_off_time]" value="<?php echo $row->cut_off_time; ?>" />

		    </td>

        <td colspan="2" align="left">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_CUT_OFF_DATE_HELP' )), '', 'tooltip.png', '', ''); ?></td>

      </tr>

      <tr>

      <td align="left"><?php echo JText::_( 'DT_WAITING_LIST' ); ?>:</td>

      <td align="left" valign="top">

	    <?php

	    $options=array();

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

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

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

	    echo JHTML::_('select.genericlist', $options,"data[event][waiting_list]","","value","text",$row->waiting_list);

	    ?>

	    </td>

      <td colspan="2" align="left">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_WAITING_LIST_HELP' )), '', 'tooltip.png', '', ''); ?></td>

      </tr>

    <tr>

    <td valign="top" align="left"><?php echo JText::_( 'DT_EVENT_CATEGORY_PREREQUISITE' ); ?>:</td>

    <td><?php 

	   $options=DtHtml::options($category->optionslist());

	   echo JHTML::_('select.genericlist', $options,"data[prerequisite_category][]", 'multiple="multiple" size="5"',"value","text",$row->prerequisitecategory); ?></td>

    <td colspan="2">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_EVENT_CATEGORY_PREREQUISITE_HELP' )), '', 'tooltip.png', '', ''); ?></td>

   </tr>

      <tr>

        <td valign="top" align="left"><?php echo JText::_( 'DT_PREREQUISITE' ); ?>:</td>

        <td>

 			 <?php 

			  $options=DtHtml::options($row->optionslist(),JText::_('DT_SELECT_EVENT'));

              echo JHTML::_( 'select.genericlist', $options, 'data[prerequisite][]', 'multiple="multiple" size="5"',"value","text",$row->prerequisite);

              $options = array();	  

        ?></td>

        <td colspan="2" align="left">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_PREREQUISITE_HELP' )), '', 'tooltip.png', '', ''); ?></td>

      </tr>

      <tr>

        <td align="left"><?php echo JText::_( 'DT_ARTICLE' ); ?>:</td>

        <td>

			<?php
			    $database = &JFactory::getDBO();
				$options=array();
				$user = JFactory::getUser();
				$options[]=JHTML::_('select.option',"",JText::_('DT_SELECT_CATEGORY'));
				$con = "";
                if(!$user->authorise('core.admin')) {
					$groups	= implode(',', $user->getAuthorisedViewLevels());
			         
				  $con = " and ".'c.access IN ('.$groups.')';
				}
				$query = "Select c.* from #__categories c where published <> 0 and parent_id > 0   ".$con." order by lft asc ";

				$database->setQuery($query);

				$categories = $database->loadObjectList();

				if (is_array($categories)) 
				foreach($categories as $category){
					
                    if($user->authorise('core.edit',  'com_content.category.' . $category->id) != true) {
					 
					} else {
						 $repeat = ($category->level - 1 >= 0) ? $category->level - 1 : 0;
				         $category->title = str_repeat('- ', $repeat) . $category->title;
						 $options[]=JHTML::_('select.option',$category->id,$category->title);
					}

				}
				
                
				$category_html = JHTML::_('select.genericlist', $options,"articlecategory","","value","text");

				$options=array();

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

				$article_html = JHTML::_('select.genericlist', $options,"data[event][article_id]","","value","text",$row->article_id);

			?>

	    <span id="category_id"><?php echo $category_html; ?></span>

        <span id="article_id"><?php echo $article_html; ?></span>

 		</td>

        <td colspan="2" align="left">&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_ARTICLE_TYPE_HELP' )), '', 'tooltip.png', '', ''); ?></td>

      </tr>

	   <tr>
 
       <tr>

      	<td align="left"><?php echo JText::_( 'DT_DETAILS_ITEMID' ); ?>:</td>

      	<td> 

            <input type="text" class="inputbox" id="" name="data[event][detail_itemid]" size="5" value="<?php echo $row->detail_itemid; ?>" />

      	</td>

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

      		&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_DETAILS_ITEMID_HELP' )), '', 'tooltip.png', '', ''); ?>

      	</td>

      </tr>
     
     <tr>
      	<td align="left"><?php echo JText::_( 'DT_EVENT_DETAIL_LINK_DISPLAY' ); ?>:</td>

      	<td>

			<?php

				 		$options=array();

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

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

            echo JHTML::_('select.radiolist', $options, 'data[event][detail_link_show]','','value','text',$row->detail_link_show);

			?>

      	</td>

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

      		&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_EVENT_DETAIL_LINK_DISPLAY_HELP' )), '', 'tooltip.png', '', ''); ?>

      	</td>

      </tr>

	  <tr>

      	<td align="left"><?php echo JText::_( 'DT_EVENT_SHOW_REGISTRANT' ); ?>:</td>

      	<td>

			<?php

				 	$options=array();

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

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

            echo JHTML::_('select.radiolist', $options, 'data[event][show_registrant]','','value','text',$row->show_registrant );

			?>

      	</td>

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

      		&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_EVENT_SHOW_REGISTRANT_HELP' )), '', 'tooltip.png', '', ''); ?>

      	</td>

      </tr>

      <tr>

				<td align="left" valign="top"><?php echo JText::_( 'DT_DUPLICATION_OVERRIDE' );?>:</td>

        <td>

                   <?php

						    $options=array();

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

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

                  			echo JHTML::_('select.radiolist', $options,'data[event][prevent_duplication]','','value','text',isset($row->prevent_duplication)?$row->prevent_duplication:1);

					?>

		</td>

		<td>&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_DUPLICATION_OVERRIDE_HELP' )), '', 'tooltip.png', '', ''); ?> </td>

	  </tr>
                             
       <tr>

		<td align="left" valign="top"><?php echo JText::_( 'DT_OVERRIDE_OVERLAP' );?>:</td>

          <td>

                   <?php

							$options=array();

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

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

                  			echo JHTML::_('select.radiolist', $options,'data[event][usetimecheck]','','value','text',isset($row->usetimecheck)?$row->usetimecheck:0);

								   ?>

					</td>

					<td>&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_OVERRIDE_OVERLAP_HELP' )), '', 'tooltip.png', '', ''); ?></td>

	</tr>

    <tr>

		<td align="left" valign="top"><?php echo JText::_( 'DT_EXCLUDE_OVERLAP' );?>:</td>

          <td>

                   <?php

							$options=array();

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

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

							echo JHTML::_('select.radiolist', $options,'data[event][excludeoverlap]','','value','text',isset($row->excludeoverlap)?$row->excludeoverlap:0);

								   ?>

					</td>

					<td>&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_EXCLUDE_OVERLAP_HELP' )), '', 'tooltip.png', '', ''); ?></td>

	</tr>

    <tr>

	    <td valign="top" align="left">&nbsp;</td>

	    <td>&nbsp;</td>

	    <td colspan="2" align="left">&nbsp;</td>

     </tr>

   <tr>

		<td align="left" valign="top"><?php echo JText::_( 'DT_USER_CREATION' );?>:</td>

        <td>

                        <?php

							$options=array();

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

							$options[]=JHTML::_('select.option', '1', JText::_( 'DT_YES_REQUIRED' ));
							$options[]=JHTML::_('select.option', '2', JText::_( 'DT_YES_OPTIONAL' ));

							echo JHTML::_('select.genericlist', $options,'data[event][usercreation]','','value','text',$row->usercreation);

						?>

		</td>

		<td>&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_USER_CREATION_HELP' )), '', 'tooltip.png', '', ''); ?> </td>

	</tr>

     <tr class="usergroup">

		<td align="left" valign="top"><?php echo JText::_( 'DT_USER_GROUP' );?>:</td>

        <td>

                        <?php
                    
					$options= TableJUser::getUserGroupOptions();
					global $default_group ;
					echo JHTML::_('select.genericlist', $options,'data[event][usergroup][]',"class = 'inputbox' multiple",'value','text',$row->usergroup==""?$default_group:$row->usergroup);

			?>

		</td>

		<td>&nbsp;&nbsp;<?php echo JHTML::tooltip((JText::_( 'DT_USER_GROUP_HELP' )), '', 'tooltip.png', '', ''); ?> </td>

	</tr>


<?php echo $this->loadTemplate('image'); ;?>
</table>


<script type="text/javascript">
 
  DTjQuery(function(){
	    DTjQuery.validator.messages.required;
		
	    DTjQuery(document.adminForm).validate({
                        success: function(label) {
                            label.addClass("success");
                        },
						debug :false,
						ignore :".dtuploadfield",
						invalidHandler:function(event, validator) {
							                 DTjQuery("#tabs").find(".dt_tab_error").removeClass("dt_tab_error")
						                     // console.log(validator.numberOfInvalids());
											  //console.log(validator.invalidElements());
											  DTjQuery.each(validator.invalidElements() , function(k,v){
												  
												 var tabpanel = DTjQuery(v).closest(".ui-tabs-panel");
												 //console.log(tabpanel[0]);
												 var index = DTjQuery(".ui-tabs-panel").index(tabpanel[0]) ;
												// console.log(index);
										         var tab = DTjQuery("li.ui-state-default").get(index).addClass('dt_tab_error');
												 //console.log(tab);
												 //DTjQery(tab).addClass('dt_tab_error');
												 
												 
												  
											  });
											
											}
              
                });
		DTjQuery("#min_group_size").rules('add',{min:1,messages:{min:" "}});
		 DTjQuery('#dtstart').rules('add',{datelessthen: "#dtend", required:true,
		                   messages :{datelessthen:""}
                  });
		 /* DTjQuery('#dtend').rules('add',{datelessthen: "#dtend",  required:true,
		                   messages :{datelessthen:""}
                  });*/
	    DTjQuery(".checkdate").change(function(){
		    
			if(DTjQuery(document.adminForm).validate().element("#dtstart" )){
				DTjQuery('label[for="dtstart"]').show();
				DTjQuery('label[for="dtstart"]').addClass('success');
		
			}else{
			   DTjQuery('label[for="dtstart"]').show();
				DTjQuery('label[for="dtstart"]').removeClass('success');
			
			}
				
		});
		
		DTjQuery("#dataeventregistration_type").change(function(){
		     
			 var value = DTjQuery(this).val();
			 if(navigator.appName.indexOf("Micro") >=0){
				 display = 'block';
			 }else{
				 display = 'table-row';
			 }
			 if(value != 'individual'){
			    DTjQuery('#grouptype').css({display:display});
				
			 }else{
				DTjQuery('#grouptype').hide();
			     
			 }
			 	
		})
		DTjQuery("#dataeventregistration_type").trigger('change');	
		
		DTjQuery("#dataeventusercreation").change(function(){
		     
			 var value = DTjQuery(this).val();
			 if(navigator.appName.indexOf("Micro") >=0){
				 display = 'block';
			 }else{
				 display = 'table-row';
			 }
			 if(value != '0'){
			    DTjQuery('.usergroup').css({display:display});
				
			 }else{
				DTjQuery('.usergroup').hide();
			     
			 }
			 
			  DTjQuery('.usergroup').css({display:display});
			 	
		})
		DTjQuery("#dataeventusercreation").trigger('change');	
		
	});
   
   var article = <?php echo json_encode($article);?>;

   if(article ==  null){
	   article = {};
   }

			DTjQuery('#articlecategory').change(function(){

                article['catid'] = DTjQuery(this).val();

	DTjQuery('#article_id').load("index.php?option=com_dtregister&controller=event&no_html=1&categoryId="+DTjQuery(this).val()+"&task=getarticle",article,function(){

				});

		});

   DTjQuery(function(){

	    DTjQuery("#dataeventarticle_id").change(function(){

			 article['id'] = DTjQuery(this).val();	 	

		});

	   	<?php

		if($article !== false){

		?>

			      DTjQuery('#articlecategory').val(article['catid']);
				  DTjQuery('#article_id').load("index.php?option=com_dtregister&controller=event&no_html=1&categoryId="+article['catid']+"&task=getarticle",article,function(){

				   DTjQuery('#dataeventarticle_id').val(article['id']);

				});
				
		<?php	

		}

		?>
       
   });
      var moderator_sort ;
      DTjQuery(function(){
	      
		moderator_sort =   DTjQuery('#moderator_sortable').sortable({axis:'y',placeholder: "ui-state-highlight"});
		
		DTjQuery("#dataeventuser_id").live('change',function(){
		    var  html_li = "";
			DTjQuery("#dataeventuser_id option:selected").each(function(){
			  
			   html_li += '<li class="ui-state-default" id="userorder_'+DTjQuery(this).val()+'"><span class="ui-icon ui-icon-arrowthick-2-n-s"></span>'+DTjQuery(this).text()+'</li>';
			})
			DTjQuery('#moderator_sortable').html(html_li);
			DTjQuery('#moderator_sortable').sortable('refresh')
		})
		  
	  })
  
    Joomla.submitbutton = function(pressbutton) {
            
			var str = moderator_sort.sortable("serialize") ;
			DTjQuery("#moderator_order").val(str);
			if(pressbutton == "cancel"){
				submitform(pressbutton);
				return;
			}
			
			if(DTjQuery(document.adminForm).valid()){
				DTjQuery('input').removeAttr('disabled');
				submitform(pressbutton);
			}
			if(DTjQuery(document.adminForm).validate().element("#dtstart" )){
				DTjQuery('label[for="dtstart"]').show();
				DTjQuery('label[for="dtstart"]').addClass('success');
		
			}else{
			   DTjQuery('label[for="dtstart"]').show();
				DTjQuery('label[for="dtstart"]').removeClass('success');
			
			}
			  
			return false;
		
		}
		
		 function DTselected(cal, date) {

			cal.sel.value = date; // just update the value of the input field
			
			if(DTjQuery(document.adminForm).validate().element("#dtstart" )){
				DTjQuery('label[for="dtstart"]').show();
				DTjQuery('label[for="dtstart"]').addClass('success');
		
			}else{
			   DTjQuery('label[for="dtstart"]').show();
				DTjQuery('label[for="dtstart"]').removeClass('success');
			
			}
		
		   return false;
			
		}
  
</script>