<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
require_once( "includes/HTML_toolbar.php" );
?>
<script>
function deEnrolConfirm(OPTION,EVENTID,ITEMID,PAID) {
	var URL = '?option=' + OPTION + '&task=deenrol&eventid=' + EVENTID + '&Itemid=' + ITEMID;
	if(PAID == 1) {
		var varRet = confirm('<?php echo $l->m("msg_cancel_confirm","general"); ?>');
		if(varRet == true) {
			document.location = URL;
		}
	} else {
		document.location = URL;
	}
}
</script>
<!-- end of CSS and JavaScript -->

<?php
class HTML_MLS_events {
	function listEvents(&$rows, $paid, $option, $Itemid) {
		global $database,$my,$l;
		$l->setBlock("events");
		?>
		
		<table cellpadding="5" cellspacing="0" border="0" width="100%">
			<tr>
				<td><div class="componentheading"><?php echo $l->m("lanparty_events"); ?></div></td>
			</tr>
		</table>
		
		<table cellpadding="3" cellspacing="1" border="0" width="100%">
			<tr>
				<td class="sectiontableheader"><?php echo $l->m("name"); ?>:</td>
				<td class="sectiontableheader"><?php echo $l->m("start"); ?>:</td>
				<td class="sectiontableheader"><?php echo $l->m("city"); ?>:</td>
				<td class="sectiontableheader"><?php echo $l->m("registrations"); ?>:</td>
				<td class="sectiontableheader"></td>
				<td class="sectiontableheader"></td>
				<td class="sectiontableheader"></td>
			</tr>
		<?php
		$k = 0;
		for($i = 0, $n = count($rows); $i < $n; $i++) {
			$row = $rows[$i];
			$row->paid = array_search($row->id,$paid) ? 1 : NULL;
			$img = $row->paid ? "tick.png" : "publish_x.png";
			$pre = $row->paid ? "" : "<a href=\"?option=".$option."&task=pay&eventid=".$row->id."&Itemid=".$Itemid."\">";
			$post = $row->paid ? "" : "</a>";
			$y = $k + 1;
			$class = "sectiontableentry" . $y;
			SefRelToAbs("?option=".$option."&task=details&eventid=".$row->id."&Itemid=".$Itemid);
			?>
			<tr>
				<td class="<?php echo $class;?>"><a href="?option=<?php echo $option?>&task=details&eventid=<?php echo $row->id?>&Itemid=<?php echo $Itemid?>"><?php echo $row->name; ?></a></td>
				<td class="<?php echo $class;?>"><?php echo date("D, d.m.Y H:i", strtotime($row->start)); ?></td>
				<td class="<?php echo $class;?>"><?php echo $row->loc_zip; ?> <?php echo $row->loc_city; ?></td>
				<td class="<?php echo $class;?>"><?php echo $row->usercount; ?>/<?php echo $row->participants_number; ?></td>
				<td class="<?php echo $class;?>">
					<?php if($row->enrol AND !$row->enrolled) { ?>
						<a href="?option=<?php echo $option?>&task=enrol&eventid=<?php echo $row->id?>&Itemid=<?php echo $Itemid?>"><?php echo $l->m("enrol"); ?></a>
					<?php } elseif($row->enrol AND $row->enrolled) { ?>
						<a href="#" onclick="javascript:deEnrolConfirm('<?php echo $option?>','<?php echo $row->id?>','<?php echo $Itemid?>','<?php echo $row->paid?>');"><?php echo $l->m("de_enrol"); ?></a>
					<?php } else { ?>
						&nbsp;
					<?php } ?>
				</td>
				<td class="<?php echo $class;?>">
					<?php if($row->enrol) { ?>
						<a href="?option=<?php echo $option?>&task=show_participants&eventid=<?php echo $row->id?>&Itemid=<?php echo $Itemid?>"><?php echo $l->m("participants"); ?></a>
					<?php } else { ?>
						&nbsp;
					<?php } ?>
				</td>
				<td class="<?php echo $class;?>">
					<?php if($row->enrolled) {?>
						<?php echo $pre;?><img src="administrator/images/<?php echo $img?>" width="12" height="12" alt="" border="0" /><?php echo $post;?>
					<?php } else { ?>
						&nbsp;
					<?php } ?>
				</td>
			</tr>
			<?php
			$k = 1 - $k;
		}
		?>
		<tr>
			<td class="sectiontablefooter" colspan="7" align="center" valign="middle">
			<img src="administrator/images/publish_x.png" width="12" height="12" alt="" /> <?php echo $l->m("awaiting_payment"); ?> | 
			<img src="administrator/images/tick.png" width="12" height="12" alt="" /> <?php echo $l->m("payment_received"); ?>
			</td>
		</table>
		<?php
		HTML_MLS_events::printFooter();
	}
	
	function showEvent(&$row, $option, $Itemid) {
		global $database,$my,$l;
		$l->setBlock("events");
		?>
		<div align="center">
		<nobr><a href="?option=<?php echo $option?>&Itemid=<?php echo $Itemid?>"><?php echo $l->m("back_to_list"); ?></a></nobr> |
		<?php if($row->enrol) { ?>
			<?php if(!$row->enrolled) { ?>
				<nobr><a href="?option=<?php echo $option?>&task=enrol&eventid=<?php echo $row->id?>&Itemid=<?php echo $Itemid?>"><?php echo $l->m("enrol"); ?></a></nobr> |
			<?php } else { ?>
				<nobr><a href="#" onclick="javascript:deEnrolConfirm('<?php echo $option?>','<?php echo $row->id?>','<?php echo $Itemid?>','<?php echo $row->paid?>');"><?php echo $l->m("cancel_enrolment"); ?></a></nobr> |
				<?php if(!$row->paid) { ?>
					<nobr><a href="?option=<?php echo $option?>&task=pay&eventid=<?php echo $row->id?>&Itemid=<?php echo $Itemid?>"><?php echo $l->m("pay"); ?></a></nobr> |
				<?php } ?>
			<?php } ?>
			<nobr><a href="?option=<?php echo $option?>&task=show_participants&eventid=<?php echo $row->id?>&Itemid=<?php echo $Itemid?>"><?php echo $l->m("participants"); ?> (<?php echo $row->usercount ?> [<span style="color: #00FF00;"><?php echo $row->usercount_paid ?></span>/<span style="color: #FF0000;"><?php echo $row->usercount_unpaid ?></span>])</a></nobr> |
		<?php } ?>
		<nobr><a href="?option=<?php echo $option?>&task=list_comments&eventid=<?php echo $row->id?>&Itemid=<?php echo $Itemid?>"><?php echo $l->m("comments"); ?> (<?php echo $row->commentcount ?>)</a></nobr> |
		<nobr><a href="?option=<?php echo $option?>&task=list_reviews&eventid=<?php echo $row->id?>&Itemid=<?php echo $Itemid?>"><?php echo $l->m("reviews"); ?> (<?php echo $row->reviewcount ?>)</a></nobr>
		</div>
		
		<table cellpadding="5" cellspacing="0" border="0" width="100%">
			<tr>
				<td colspan="5"><div class="componentheading"><?php echo $l->m("event_details"); ?></div></td>
			</tr>
		</table>
		
		<table cellpadding="3" cellspacing="1" border="0" width="100%">
			<tr>
				<td colspan="2" class="sectiontableheader"><?php echo $l->m("general_information"); ?></td>
			</tr>
			<tr> 
				<td class="sectiontableheader" valign="top" width="130"><?php echo $l->m("name"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->name; ?></td>
			</tr>
			
			<?php if($row->wwcl_pid) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("wwcl_pid"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->wwcl_pid; ?></td>
			</tr>
			<?php } ?>
			<?php if($row->ngl_pid) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("ngl_pid"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->ngl_pid; ?></td>
			</tr>
			<?php } ?>
			<?php if($row->start) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("start"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo date("l, d. F Y H:i", strtotime($row->start)); ?></td>
			</tr>
			<?php } ?>
			<?php if($row->end) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("end"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo date("l, d. F Y H:i", strtotime($row->end)); ?></td>
			</tr>
			<?php } ?>
			<?php if($row->infos) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("information"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo nl2br($row->infos); ?></td>
			</tr>
			<?php } ?>
			
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="2" class="sectiontableheader"><?php echo $l->m("location"); ?></td>
			</tr>
			<?php if($row->loc_journey_desc) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("journey_description"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo nl2br($row->loc_journey_desc); ?></td>
			</tr>
			<?php } ?>
			<?php if($row->loc_location_name) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("location_name"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->loc_location_name; ?></td>
			</tr>
			<?php } ?>
			<?php if($row->loc_street) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("street_name"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->loc_street; ?></td>
			</tr>
			<?php } ?>
			<?php if($row->loc_street_no) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("street_number"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->loc_street_no; ?></td>
			</tr>
			<?php } ?>
			<?php if($row->loc_zip) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("zip"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->loc_zip; ?></td>
			</tr>
			<?php } ?>
			<?php if($row->loc_city) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("city"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->loc_city; ?></td>
			</tr>
			<?php } ?>
			<?php if($row->loc_country) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("country"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->loc_country; ?></td>
			</tr>
			<?php } ?>
			<?php if($row->loc_parking_space) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("parking_space"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->loc_parking_space; ?></td>
			</tr>
			<?php } ?>
			
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="2" class="sectiontableheader"><?php echo $l->m("financial"); ?><a name="financial">&nbsp;</a></td>
			</tr>
			<?php if($row->price_advance_sale > 0) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("price_advance"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->price_advance_sale; ?></td>
			</tr>
			<?php } ?>
			<?php if($row->price_direct_sale > 0) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("price_direct"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->price_direct_sale; ?></td>
			</tr>
			<?php } ?>
			<?php if($row->price_payment_instructions) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("payment_instructions"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->price_payment_instructions; ?></td>
			</tr>
			<?php } ?>
			
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="2" class="sectiontableheader"><?php echo $l->m("participants_title"); ?></td>
			</tr>
			<?php if($row->participants_number) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("number_of_participants"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->participants_number; ?></td>
			</tr>
			<?php } ?>
			<?php if($row->participants_visitors) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("visitors_info"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->participants_visitors; ?></td>
			</tr>
			<?php } ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("minimum_age"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->participants_min_age ? $row->participants_min_age.' '.$l->m("years") : $l->m("not_defined"); ?></td>
			</tr>
			
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="2" class="sectiontableheader"><?php echo $l->m("features"); ?></td>
			</tr>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("smokers_section"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->features_smokers_section ? $l->m("yes","general") : $l->m("no","general"); ?></td>
			</tr>
			
			<?php if($row->features_network) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("network_description"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo nl2br($row->features_network); ?></td>
			</tr>
			<?php } ?>
			<?php if($row->features_internet) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("internet_connection"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo nl2br($row->features_internet); ?></td>
			</tr>
			<?php } ?>
			
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="2" class="sectiontableheader"><?php echo $l->m("contact"); ?></td>
			</tr>
			<?php if($row->contact_icq) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("contact_icq"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->contact_icq; ?></td>
			</tr>
			<?php } ?>
			<?php if($row->contact_irc) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("contact_irc"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->contact_irc; ?></td>
			<tr>
			<?php } ?>
			<?php if($row->contact_mail) { ?>
			<tr> 
				<td class="sectiontableheader" valign="top"><?php echo $l->m("contact_email"); ?>:</td>
				<td valign="top" class="sectiontableentry2"><?php echo $row->contact_mail; ?></td>
			<tr>
			<?php } ?>
		</table>
		<?php
		HTML_MLS_events::printFooter();
	}
	
	function listReviews(&$rows,$event,$unpub, $option,$Itemid) {
		global $database,$my,$mainframe,$l, $acl;
		$l->setBlock("reviews");
		?>
		<div align="center">
		<a href="?option=<?php echo $option?>&Itemid=<?php echo $Itemid?>&task=details&eventid=<?php echo $event->id?>"><?php echo $l->m("back_to_details"); ?></a> |
		<a href="?option=<?php echo $option?>&Itemid=<?php echo $Itemid?>&task=write_review&eventid=<?php echo $event->id?>"><?php echo $l->m("write_review"); ?></a>
		</div>
		<table cellpadding="5" cellspacing="0" border="0" width="100%">
			<tr>
				<td><div class="componentheading"><?php echo $l->m("event_reviews"); ?>' '<?php echo $event->name?>'</div></td>
			</tr>
			<tr>
				<td><?php echo $l->m("num_unpublished_reviews"); ?>: <?php echo $unpub; ?></td>
			</tr>
		</table>
		
		
		<table cellpadding="3" cellspacing="1" border="0" width="100%">
			<tr>
				<td class="sectiontableheader"><?php echo $l->m("author"); ?>:</td>
				<td class="sectiontableheader"><?php echo $l->m("title"); ?>:</td>
				<td class="sectiontableheader" width="15%"><?php echo $l->m("written"); ?>:</td>
			</tr>
			<?php
			$k = 0;
			for($i = 0, $n = count($rows); $i < $n; $i++) {
				$row = $rows[$i];
				$grp =  $acl->getAroGroup( $my->id );
				$backend = $acl->is_group_child_of(intval($grp->group_id),"Public Backend");
				$pub = $grp->name == "Publisher" ? 1 : 0;
				if($row->published || (!$row->published && ($backend || $pub) )) {
					if(!$row->published) {
						$row->title .= " (".$l->m("unpublished","general").")";
					}
					$y = $k + 1;
					$class = "sectiontableentry" . $y;
					?>
					<tr>
						<td class="<?php echo $class;?>"><?php echo $row->username; ?></td>
						<td class="<?php echo $class;?>"><a href="<?php echo "?option=".$option."&task=read_review&id=".$row->id."&Itemid=".$Itemid; ?>"><?php echo $row->title; ?></a></td>
						<td class="<?php echo $class;?>" width="15%" nowrap="nowrap"><?php echo mosFormatDate( $row->time,"%a, %d.%m.%Y %H:%M" ); ?></td>
					</tr>
					<?php
					$k = 1 - $k;
				}
			}
			?>
		</table>
		<?php
		HTML_MLS_events::printFooter();
	}
	
	function editReview(&$row, $event, $option, $Itemid) {
		global $database, $my, $mainframe, $l, $gid;
		
		$l->setBlock("reviews");
		?>
		<div align="center">
		<a href="?option=<?php echo $option?>&Itemid=<?php echo $Itemid?>&task=list_reviews&eventid=<?php echo $event->id;?>"><?php echo $l->m("back","general"); ?></a>
		</div>
		
		<form action="index.php" method="POST" name="adminForm" id="adminForm">
		<table cellpadding="4" cellspacing="0" border="0" width="100%">
			<tr>
				<td><div class="componentheading"><?php echo $row->id ? $l->m("edit_event_review") : $l->m("add_event_review");?>: '<?php echo $event->name?>'</div></td>
			</tr>
			<tr>
				<td align="right">
				<div style="float: right;">
				<?php
				mosToolBar::startTable();
				mosToolBar::spacer();
				mosToolBar::save('save_review');
				mosToolBar::cancel('list_reviews');
				mosToolBar::endtable();
				?>
				</div>
				</td>
			</tr>
		</table>
		
		<table cellpadding="3" cellspacing="1" border="0">
			<tr>
				<td class="sectiontableentry2" valign="top"><?php echo $l->m("title"); ?>:<br>
				<input type="text" class="inputbox" name="title" value="<?php echo $row->title; ?>" size="70" maxlength="255" /></td>
			</tr>
			<tr>
				<td class="sectiontableentry2" valign="top"><?php echo $l->m("text_html_allowed"); ?>:<br>
				<?php // parameters : areaname, content, hidden field, width, height, rows, cols
				editorArea( 'editor2',  $row->text , 'text', '100%;', '350', '75', '20' ) ; ?></td>
			</tr>
		</table>
		<input type="hidden" name="option" value="<?php echo $option; ?>" />
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="Itemid" value="<?php echo $Itemid;?>" />
		<input type="hidden" name="userid" value="<?php echo $row->userid; ?>" />
		<input type="hidden" name="eventid" value="<?php echo $row->eventid; ?>" />
		<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
		<input type="hidden" name="time" value="<?php echo $row->time; ?>" />
		<input type="hidden" name="published" value="<?php echo $row->published; ?>" />
		</form>
		
		<?php
		HTML_MLS_events::printFooter();
	}
	
	function showParticipants(&$rows,$fields, $event,$link,$pageNav,$search,$option,$Itemid) {
		global $database,$my,$mainframe,$l;
		$l->setBlock("participants");
		?>
		<div align="center">
		<a href="?option=<?php echo $option?>&Itemid=<?php echo $Itemid?>"><?php echo $l->m("back_to_list"); ?></a> |
		<a href="?option=<?php echo $option?>&Itemid=<?php echo $Itemid?>&task=details&eventid=<?php echo $event->id?>"><?php echo $l->m("back_to_details"); ?></a>
		</div>
		<form method="POST" action="<?php echo $link?>">
		<table cellpadding="5" cellspacing="0" border="0" width="100%">
			<tr>
				<td colspan="5"><div class="componentheading"><?php echo $l->m("event_participants"); ?> '<?php echo $event->name?>'</div></td>
			</tr>
			
			<tr> 
				<td align="left" width="90%">&nbsp;</td>
				<td align="right" width="50"><nobr><?php echo $l->m("num_display","general"); ?></nobr></td>
				<td align="right" width="40"> <?php echo $pageNav->writeLimitBox($link); ?> </td>
				<td align="right" width="60" nowrap="nowrap"><?php echo $l->m("search","general"); ?>:</td>
				<td align="right" width="150"><input type="text" size="20" name="search" value="<?php echo $search;?>" class="inputbox" /></td>
			</tr>
		</table>
		</form>
		
		<table cellpadding="3" cellspacing="1" border="0" width="100%">
		<!--
			<tr>
				<td class="sectiontableheader" width="20" align="center">#</td>
				<td class="sectiontableheader"><?php echo $l->m("name"); ?>:</td>
				<td class="sectiontableheader" width="125"><?php echo $l->m("subscribed"); ?>:</td>
				<td class="sectiontableheader" width="50" style="text-align: center"><?php echo $l->m("paid"); ?>:</td>
				<td class="sectiontableheader" width="60" style="text-align: center"><?php echo $l->m("checkin"); ?>:</td>
				<td class="sectiontableheader" width="60" style="text-align: center"><?php echo $l->m("checkout"); ?>:</td>
			</tr> -->
			<tr>
				<td class="sectiontableheader" width="20" align="center">#</td>
				<?php
				foreach($fields["fields"] AS $fieldname) {
					?>
					<td class="sectiontableheader" style="white-space: nowrap;"><?php echo $fields["titles"][$fieldname]; ?>:</td>
					<?php
				}
				?>
			</tr>
		<?php
		$k = 0;
		for($i = 0, $n = count($rows); $i < $n; $i++) {
			$row = $rows[$i];
			$img_mylansite_paid = $row->paid ? 'tick.png' : 'publish_x.png';
			$img_mylansite_checked_in = $row->mylansite_checked_in ? 'tick.png' : 'publish_x.png';
			$img_mylansite_checked_out = $row->mylansite_checked_out ? 'tick.png' : 'publish_x.png';
			$y = $k + 1;
			$class = "sectiontableentry" . $y;
			?>
			<!-- <tr>
				<td class="<?php echo $class;?>" width="20" align="center"><?php echo $i + $pageNav->limitstart + 1; ?></td>
				<td class="<?php echo $class;?>"><?php echo $row->joomla_username; ?></td>
				<td class="<?php echo $class;?>" width="125"><nobr><?php echo date("D, d.m.Y H:i", strtotime($row->subscribed_time)); ?></nobr></td>
				<td class="<?php echo $class;?>" width="50" style="text-align: center"><img src="administrator/images/<?php echo $img_paid;?>" width="12" height="12" border="0" alt="" /></td>
				<td class="<?php echo $class;?>" width="60" style="text-align: center"><img src="administrator/images/<?php echo $img_in;?>" width="12" height="12" border="0" alt="" /></td>
				<td class="<?php echo $class;?>" width="60" style="text-align: center"><img src="administrator/images/<?php echo $img_out;?>" width="12" height="12" border="0" alt="" /></td>
			</tr> -->
			<tr>
				<td class="<?php echo $class;?>" width="20" align="center"><?php echo $i + $pageNav->limitstart + 1; ?></td>
				<?php
				foreach($fields["fields"] AS $fieldname) {
					if(eregi("checked_in",$fieldname) || eregi("checked_out",$fieldname) || eregi("paid",$fieldname)) {
						$imgname = "img_".$fieldname;
						?>
						<td class="<?php echo $class;?>" width="60" style="text-align: center"><img src="administrator/images/<?php echo $$imgname;?>" width="12" height="12" border="0" alt="" /></td>
						<?php
					} else {
						?>
						<td class="<?php echo $class;?>"><?php echo $row->$fieldname; ?></td>
						<?php
					}
				}
				?>
			</tr>
			<?php
			$k = 1 - $k;
		}
		?>
			<tr>
				<td colspan="6">&nbsp;</td>
			</tr>
			<tr> 
				<td align="center" colspan="6" class="sectiontablefooter"><?php echo $pageNav->writePagesLinks($link); ?></td>
			</tr>
			<tr> 
				<td align="center" colspan="6" class="sectiontablefooter"><?php echo $pageNav->writePagesCounter(); ?></td>
			</tr>
		</table>
		<?php
		HTML_MLS_events::printFooter();
	}
	
	function readReview(&$row, $event, $option, $Itemid) {
		global $database, $my, $l, $acl;
		$l->setBlock("reviews");
		$grp =  $acl->getAroGroup( $my->id );
		$backend = $acl->is_group_child_of(intval($grp->group_id),"Public Backend");
		$pub = $grp->name == "Publisher" ? 1 : 0;
		if($row->published || (!$row->published && ($backend || $pub) )) {
		?>
		<div align="center">
			<a href="?option=<?php echo $option?>&Itemid=<?php echo $Itemid?>&task=list_reviews&eventid=<?php echo $event->id?>"><?php echo $l->m("back","general"); ?></a>
		</div>
		<table cellpadding="0" cellspacing="1" border="0" width="100%">
			<tr>
				<td><div class="componentheading"><?php echo $l->m("event_reviews"); ?> '<?php echo $event->name?>': <?php echo $row->title;?></div></td>
			</tr>
		</table>
		<table cellpadding="3" cellspacing="1" border="0" width="100%">
			<tr>
				<td width="70%" align="left" valign="top">
				<span class="small"><?php echo $l->m("written_by"); ?> <?php echo $row->username?> (<?php echo $row->realname?>)</span>
				</td>
			</tr>
			<tr>
				<td valign="top" colspan="2">
				<span class="createdate"><?php echo date("l, d. F Y H:i", strtotime($row->time)); ?></span><br>
				</td>
			</tr>
		</table>
		<span style="text-align: left"><?php echo $row->text; ?></span>
		<?php
		}
		HTML_MLS_events::printFooter();
	}
	
	function listComments(&$rows, $e, $option, $Itemid) {
		global $database, $my, $l, $task;
		$l->setBlock("comments");
		?>
		<div align="center">
			<a href="?option=<?php echo $option?>&Itemid=<?php echo $Itemid?>&task=details&eventid=<?php echo $e->id?>"><?php echo $l->m("back_to_details"); ?></a>
		</div>
		<table cellpadding="5" cellspacing="0" border="0" width="100%">
			<tr>
				<td><div class="componentheading"><?php echo $l->m("event_comments"); ?>: <?php echo $e->name; ?></div></td>
			</tr>
		</table>
		<form method="POST" action="index.php">
		<table cellpadding="3" cellspacing="1" width="100%" border="0">
		<?php
		$num = count($rows);
		for($i = 0, $n = count($rows); $i < $n; $i++) {
			$row = $rows[$i];
			?>
			<tr>
				<td class="sectiontableheader" colspan="2"><?php echo date("l, d. F Y H:i", strtotime($row->time)); ?></td>
			</tr>
			<tr>
				<td width="20" align="center" class="sectiontableheader">#<?php echo $num;?></td>
				<td class="sectiontableheader"><?php echo $row->username;?></td>
			</tr>
			<tr>
				<td class="sectiontableentry2" colspan="2"><?php echo nl2br(htmlspecialchars($row->text)); ?></td>
			</tr>
			<tr>
				<td colspan="2">&nbsp;</td>
			</tr>
			<?php
			$num--;
		}
		
		if($my->id) {
			?>
			<tr>
				<td class="sectiontableheader" colspan="2"><?php echo $l->m("add_event_comment"); ?></td>
			</tr>
			<tr>
				<td class="sectiontableentry2" colspan="2"><textarea class="inputbox" name="text" rows="5" cols="60"></textarea><br>
				<input type="submit" class="button" name="save_comment" value="<?php echo $l->m("save","general"); ?>" />
				</td>
			</tr>
			<?php
		}
		?>
		</table>
		<input type="hidden" name="userid" value="<?php echo $my->id;?>" />
		<input type="hidden" name="option" value="<?php echo $option;?>" />
		<input type="hidden" name="Itemid" value="<?php echo $Itemid;?>" />
		<input type="hidden" name="task" value="<?php echo $task;?>" />
		<input type="hidden" name="eventid" value="<?php echo $e->id;?>" />
		</form>
		<?php
		HTML_MLS_events::printFooter();
	}
	
	function payEvent($event, $packages_event, $packages_general, $option, $Itemid) {
		global $option, $l, $my, $cnf_mls_pp;
		$l->setBlock("pay");
		?>
		<div align="center">
			<a href="?option=<?php echo $option?>&Itemid=<?php echo $Itemid?>"><?php echo $l->m("back_to_list"); ?></a> |
			<a href="?option=<?php echo $option?>&Itemid=<?php echo $Itemid?>&task=details&eventid=<?php echo $event->id?>"><?php echo $l->m("back_to_details"); ?></a>
		</div>
		<table cellpadding="5" cellspacing="0" border="0" width="100%">
			<tr>
				<td><div class="componentheading"><?php echo $l->m("pay_for_event"); ?>: <?php echo $event->name; ?></div></td>
			</tr>
		</table>
		<table cellpadding="3" cellspacing="1" width="100%" border="0">
			<?php if($event->price_payment_instructions) { ?>
				<tr>
					<td colspan="4"><h3><?php echo $l->m("payment_instructions","events"); ?></h3></h4>
				</tr>
				<tr>
					<td colspan="4" class="sectiontableentry1" width="160" colspan="2"><?php echo nl2br($event->price_payment_instructions) ;?></td>
				</tr>
				<tr>
					<td colspan="4">&nbsp;</td>
				</tr>
			<?php } ?>
			<tr>
				<td class="sectiontableentry1" width="160" colspan="2"><strong><?php echo $l->m("price_advance","events"); ?></strong><br />event_<?php echo $event->id;?>_<?php echo $my->id;?></td>
				<td class="sectiontableentry1" style="text-align: right;"><nobr><?php echo $event->price_advance_sale; ?> <?php echo $event->price_currency; ?></nobr></td>
				<td class="sectiontableentry1" width="50" style="text-align: center;"><?php if($cnf_mls_pp["enabled"] && $cnf_mls_pp["enabled_events"] && $my->id) HTML_MLS_events::showPayPalButton($event->name, 'event_'.$event->id.'_'.$my->id, $event->price_advance_sale, $event->price_currency, $event->loc_country); ?></td>
			</tr>
			<tr>
				<td colspan="4">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="4"><h3><?php echo $l->m("packages_for_this_event"); ?></h3></h4>
			</tr>
			<?php
			$k = 0;
			for($i = 0; $i < count($packages_event); $i ++) {
				$row = $packages_event[$i];
				$class = $k ? "sectiontableentry2" : "sectiontableentry1";
				?>
				<tr>
					<td class="<?php echo $class;?>" width="160"><strong><?php echo $row->name; ?></strong><br /><?php echo $row->code;?></td>
					<td class="<?php echo $class;?>"><?php echo nl2br($row->description); ?></td>
					<td class="<?php echo $class;?>" style="text-align: right;"><nobr><?php echo $row->price; ?> <?php echo $row->currency; ?></nobr></td>
					<td class="<?php echo $class;?>" width="50" style="text-align: center;"><?php if($cnf_mls_pp["enabled"] && $cnf_mls_pp["enabled_packages"] && $my->id) HTML_MLS_events::showPayPalButton($row->name, 'package_'.$row->id.'_'.$my->id, $row->price, $row->currency, $event->loc_country); ?></td>
				</tr>
				<?php if($row->timeid) { ?>
					<tr>
						<td class="<?php echo $class;?>">&nbsp;</td>
						<td class="<?php echo $class;?>"><strong><?php echo $l->m("arrival"); ?></strong>: <?php echo  date("D d. M H:i",strtotime($row->start)); ?><br />
						<strong><?php echo $l->m("departure"); ?></strong>: <?php echo  date("D d. M H:i",strtotime($row->end)); ?></td>
						<td class="<?php echo $class;?>">&nbsp;</td>
						<td class="<?php echo $class;?>">&nbsp;</td>
					</tr>
					<?php
				}
				$k = 1 - $k;
			}
			?>
			<tr>
				<td colspan="4">&nbsp;</td>
			</tr>
			<tr>
				<td colspan="4"><h3><?php echo $l->m("general_packages"); ?></h3></h4>
			</tr>
			<?php
			$k = 0;
			for($i = 0; $i < count($packages_general); $i ++) {
				$row = $packages_general[$i];
				$class = $k ? "sectiontableentry2" : "sectiontableentry1";
				?>
				<tr>
					<td class="<?php echo $class;?>" width="160"><strong><?php echo $row->name; ?></strong><br /><?php echo $row->code;?></td>
					<td class="<?php echo $class;?>"><?php echo  nl2br($row->description); ?></td>
					<td class="<?php echo $class;?>" style="text-align: right;"><nobr><?php echo $row->price; ?> <?php echo $row->currency; ?></nobr></td>
					<td class="<?php echo $class;?>" width="50" style="text-align: center;"><?php if($cnf_mls_pp["enabled"] && $cnf_mls_pp["enabled_packages"] && $my->id) HTML_MLS_events::showPayPalButton($row->name, 'package_'.$row->id.'_'.$my->id, $row->price, $row->currency, $event->loc_country); ?></td>
				</tr>
				<tr>
					<td class="<?php echo $class;?>">&nbsp;</td>
					<td class="<?php echo $class;?>">
					<?php if($row->type == 1) { ?>
						<?php echo $row->eventamount; ?> <?php echo $l->m("upcoming_events"); ?>
					<?php } elseif($row->type == 2) { ?>
						<?php echo $l->m("membership_for"); ?> <?php echo $row->timeamount; ?> <?php echo $l->m($row->timetype); ?>
					<?php } ?>
					</td>
					<td class="<?php echo $class;?>">&nbsp;</td>
					<td class="<?php echo $class;?>">&nbsp;</td>
				</tr>
				<?php
				$k = 1 - $k;
			}
			?>
		</table>
		<?php
		HTML_MLS_events::printFooter();
	}
	
	function showCouponForm( $event, $option, $Itemid ) {
		global $l;
		$l->setBlock("coupons");
		?>
		<div align="center">
			<a href="?option=<?php echo $option?>&Itemid=<?php echo $Itemid?>"><?php echo $l->m("back_to_list"); ?></a> |
			<a href="?option=<?php echo $option?>&Itemid=<?php echo $Itemid?>&task=details&eventid=<?php echo $event->id?>"><?php echo $l->m("back_to_details"); ?></a>
		</div>
		<table cellpadding="5" cellspacing="0" border="0" width="100%">
			<tr>
				<td><div class="componentheading"><?php echo $l->m("enter_coupon"); ?>: <?php echo $event->name; ?></div></td>
			</tr>
		</table>
		
		<form action="index.php" method="POST" name="couponForm">
		<table cellpadding="3" cellspacing="1" width="100%" border="0">
			<tr>
				<td class="sectiontableheader" colspan="2"><?php echo $l->m("coupon_info"); ?></h4>
			</tr>
			<tr> 
				<td class="sectiontableheader" valign="top" width="130"><?php echo $l->m("code"); ?>:</td>
				<td valign="top" class="sectiontableentry2">
					<input type="text" class="text_area" name="couponcode" size="20" maxlength="50" />
				</td>
			</tr>
			<tr> 
				<td>&nbsp;</td>
				<td>
					<input type="submit" class="button" name="submit" value="<?php echo $l->m("enrol","events"); ?>" />
				</td>
			</tr>
		</table>
		<input type="hidden" name="eventid" value="<?php echo $event->id; ?>" />
		<input type="hidden" name="option" value="<?php echo $option; ?>" />
		<input type="hidden" name="Itemid" value="<?php echo $Itemid; ?>" />
		<input type="hidden" name="task" value="enrol_coupon" />
		</form>
		<?php
		HTML_MLS_events::printFooter();
	}
	
	function showPayPalButton($item_name, $item_number, $amount, $currency_code, $lc) {
		global $cnf_mls_pp;
		$ret = "<form action=\"https://".$cnf_mls_pp["validation_url"]."/cgi-bin/webscr\" method=\"POST\">\n";
		$ret .= "<input type=\"hidden\" name=\"cmd\" value=\"_xclick\">\n";
		$ret .= "<input type=\"hidden\" name=\"business\" value=\"".$cnf_mls_pp["recipient_email"]."\">\n";
		$ret .= "<input type=\"hidden\" name=\"item_name\" value=\"".$item_name."\">\n";
		$ret .= "<input type=\"hidden\" name=\"item_number\" value=\"".$item_number."\">\n";
		$ret .= "<input type=\"hidden\" name=\"amount\" value=\"".$amount."\">\n";
		$ret .= "<input type=\"hidden\" name=\"no_note\" value=\"1\">\n";
		$ret .= "<input type=\"hidden\" name=\"currency_code\" value=\"".$currency_code."\">\n";
		$ret .= "<input type=\"hidden\" name=\"lc\" value=\"".$lc."\">\n";
		$ret .= "<input type=\"image\" src=\"".$cnf_mls_pp["button_url"]."\" border=\"0\" name=\"submit\" alt=\"Make payments with PayPal - it's fast, free and secure!\">\n";
		$ret .= "</form>\n";
		
		echo $ret;
	}
	
	function printFooter() {
		global $option, $mosConfig_absolute_path, $database;
		$versionTable = "#__" . substr($option,4) . "_version";
		$database->setQuery( "SELECT `version`,`date` FROM `".$versionTable."` LIMIT 1" );
		$database->loadObject($currentVersion);
		?>
		<table width="100%" border="0" align="center">
			<tr>
				<td height="20">&nbsp;</td>
			</tr>
			<tr>
				<td style="text-align: center; color: #ABABAB;">
				<a href="http://www.mylansite.org/" target="_top">myLANsite Events Component for Joomla <?php echo $currentVersion->version;?></a> (com_mls_events)<br>
				&copy; 2005 - 2007 Samuel Suter &lt;<a href="mailto:samuel.suter@mylansite.org">samuel.suter@mylansite.org</a>&gt;<br>
				This is Free Software released under the GNU/GPL License.
 				</td>
 			</tr>
 		</table>
 		<?php
 	}
};
?>