<link href="../../stylesheet.css" rel="stylesheet" type="text/css">
<table border="0" width="100%" cellspacing="0" cellpadding="<?php echo CELLPADDING_SUB;?>">
<?php
	$ecCat_path="";

	if ($ecPath!="") $ecCat_path.="&ecPath=" . $ecPath;
	
	echo tep_draw_form("frmView",tep_href_link(FILENAME_EVENTS_MONTH_VIEW,$ecCat_path));
	// get initial parameters
	$category_id=(isset($HTTP_POST_VARS['category_id'])?(int)$HTTP_POST_VARS['category_id']:0);
	$post_action=(isset($HTTP_POST_VARS['post_action'])?$HTTP_POST_VARS['post_action']:"change_cat");
	$server_date=getServerDate();
	
	//check for the selected category

	
	if ($category_id<=0) $category_id=(int)$current_events_category_id;
	
	// if category id is not found try to get the first row category id
	if ($category_id<=0) {
		$first_cat_query=tep_db_query("SELECT events_categories_id from " . TABLE_EVENTS_CATEGORIES_DESCRIPTION . " order by events_categories_name limit 1");
		$first_cat_result=tep_db_fetch_array($first_cat_query);
		$category_id=(int)$first_cat_result["events_categories_id"];
	}

	
	// creation an filter if category_id is present
	if ($category_id>0) $cat_option=" and ec.events_categories_id='" . $category_id . "'";
	$cur_date_time=getServerDate(false);
	
	
	
	// BOF: Lango Added for template MOD
	if (MAIN_TABLE_BORDER == 'yes'){
	table_image_border_top(false, false, TEXT_HEADING_BROWSE);
	}
	
	// select event category details
	$cat_array=array();
	$cat_list_query=tep_db_query("SELECT ecd.events_categories_name,ecd.events_categories_id from " . TABLE_EVENTS_CATEGORIES . " ec, " . 
								TABLE_EVENTS_CATEGORIES_DESCRIPTION . " ecd where ecd.events_categories_id=ec.events_categories_id and ecd.language_id='" . 
								$languages_id . "' order by events_categories_name ");
	
	//$cat_array[]=array('id'=>0,'text'=>"All Categories");
	while($cat_list_result=tep_db_fetch_array($cat_list_query)){
		$cat_array[]=array('id'=>$cat_list_result["events_categories_id"],'text'=>$cat_list_result["events_categories_name"]);
	}

	// fetch all the necessary events
	  								
	$cur_templ_path=DIR_WS_TEMPLATES . TEMPLATE_NAME . "/images/";
?>
	<script language="JavaScript">
		function ChangeResult(mode){
			if(mode==3)
			{
				document.frmView.post_action.value="change_cat";
				document.frmView.action="<?php echo tep_href_link(FILENAME_EVENTS_VIEW5);?>";
				}
						document.frmView.submit();			
		}
		
		function ViewPrevious(){
			document.frmPrevious.submit();
		}
	</script>
<!-- 1st table-->			
<table width='100%' border="0" cellspacing="0" cellpadding="0" align="left">
	<tr height="20">
	<td class="main" valign="top">
	   <!--- 2nd table-->
		<table width='100%' border="0" cellspacing="0" cellpadding="0" align="left">
				<tr class="eventTitleRow">		
				<td valign="middle" align="right" width="120" class="eventTitle"><?php echo TEXT_EVENT_CATEGORY;?>
				</td>
				<td valign="middle" class="eventTitle">
					<?php 
						echo tep_draw_pull_down_menu("category_id",$cat_array,$category_id) . '&nbsp;';
						echo '<a href="javascript:ChangeResult(3);">' . tep_template_image_button("button_quick_find.gif",IMAGE_VIEW_DATE,'align=absmiddle') . '</a>';
					?>
				</td>
				<td valign="middle" align="right" width="300" class="eventTitle">
					<?php 
						echo '<a href="javascript:ChangeView(1)">' . tep_template_image_button("button_day_view.gif",IMAGE_DAY_VIEW,'align=absmiddle') . '</a>&nbsp;';
						echo '<a href="javascript:ChangeView(2)">' . tep_template_image_button("button_week_view.gif",IMAGE_WEEK_VIEW,'align=absmiddle') . '</a>&nbsp;';
						echo tep_template_image_button("button_month_view_selected.gif",IMAGE_MONTH_VIEW,'align=absmiddle') .'&nbsp;';
					?>
				</td>		
				</tr>
		</table>
		<!-- 2nd table end-->
	</td>
	</tr>
<tr>
<td><?php echo tep_draw_separator('pixel_trans.gif','1','10');?></td>	
</tr>
		<tr>
		<td>
		 <!-- 3rd table-->
				<table border="0" cellpadding="10" cellspacing="0" width="100%">
				<tr>
				<td>
				  <!-- 4 the table-->
					<table border="0" cellpadding="0" cellspacing="0" width="100%">
						<tr>
						<td class="contentBackCol1" width="5"></td>	
						<td class="contentBackCol2">
					 <!-- 5 the table-->	
					<table border="0" cellpadding="0" cellspacing="0" width="100%">
						<tr>
						<td><?php echo tep_draw_separator('pixel_trans.gif','1','10');?></td>	
						</tr>
	
						<?php if ($category_id>0) {
							// select the category details
							$cat_query=tep_db_query("SELECT ecd.events_categories_name,ec.events_categories_image,if(CHAR_LENGTH(ecd.events_categories_description)>250,concat(left(ecd.events_categories_description,250),'...'),ecd.events_categories_description) as events_categories_description from " . 
													TABLE_EVENTS_CATEGORIES . " ec, " . TABLE_EVENTS_CATEGORIES_DESCRIPTION . " ecd " .
													" where ecd.events_categories_id='" . $category_id . "' and ecd.language_id='" . $languages_id . "' and ecd.events_categories_id=ec.events_categories_id");
							$cat_info=tep_db_fetch_array($cat_query);
						?>
						
							<tr height="100">
							<td valign="top">
							 <!-- 6 the table-->
									<table border="0" cellpadding="2" cellspacing="3" valign="top" width="100%">
									<tr>
										<td valign="top" class="headerBrowse" ><?php echo $cat_info['events_categories_name'];?></td>
										</tr>
										<tr>
										<td valign="top" class="smalltext" >
											<?php 
											echo ($cat_info['events_categories_image']==''?'':tep_image(DIR_WS_IMAGES . $cat_info['events_categories_image'] , $cat_info['events_categories_name'],SMALL_IMAGE_WIDTH,SMALL_IMAGE_HEIGHT,'align=right'));
											echo $cat_info['events_categories_description'];
										?>
										</td>
									</tr>
									</table>
									 <!-- 6 th table ended-->						
							</td>
							</tr>
							<?php }
							?>
							<tr>
								<td><?php echo tep_draw_separator('pixel_trans.gif',1,20);?></td>
							</tr>
							<tr>
								<td valign="top">
															
										
								 <!-- 7 the table-->			
								<table  border="0" cellpadding="0" cellspacing="4" width="100%" >
									<tr>
											
											 <!-- 8 the table-->		
									<table cellpadding="0" cellspacing="" border=0 height="100%" width="100%">
										<tr> 
										<td width="9"><?php echo tep_image($cur_templ_path ."view_col_tl.gif");?></td>
										<td class="viewColTop"></td>
										<td width="9"><?php echo tep_image($cur_templ_path ."view_col_tr.gif");?></td>
										</tr>
																
										<tr>
										<td class="viewColLeft"></td>
										<td class="viewcontent">
										 <!-- 9 the table-->								
											<table cellpadding="2" cellspacing="" border=0 height="100%" width="100%">
													<tr>
															
																
																 <!-- 10 the table-->
															<!--	<table cellpadding="2" cellspacing="" border=0 height="100%" width="100%" class="viewContent">
																	<tr align="left">
																		<td class="eventTitleMedium"  align="left">
																			<?php // echo '<a href="' . $detail_link . '" class="eventTitleMediumLink">' . $event_info['events_name'] . '</a>'; ?>
																		</td>
																	</tr>
																	
																</table>-->
																 <!-- 10 th table ended-->
																
															<!--<td class="viewColRight"></td>-->
														<td class="smallText" valign="middle" height="75%"><?php //echo $event_info['events_description']; ?></td></tr>
																			
																			<tr><td class="smallText" valign="middle" >
																			 <!-- 11 the table -->
																			
																				<table border="0" cellpadding=5 cellspacing="0" width="100%">
																					<tr>
																					
																							<td class="main" align="right"><b> <?php  echo TEXT_COST;?> </b></td>
																					
																					
																					<?php
																	$month=date("n",strtotime($server_date));
																	$year=date("Y",strtotime($server_date));
																	$month_number=$month;
																	for($icnt=1;$icnt<=5;$icnt++)
																	{
																	 if($month_number>12)
																		 {
																			 $month_number=1;
																			 $year=$year+1;
																			 }
																	 else
																		 {
																		 echo '<td class="viewDate" align="left" width="100"><b>' . constant("TEXT_MONTH" . $month_number) . '</b></td>';
																		 $month_number=$month_number+1;
																		}
																			}
																			'</tr>';
																			
																			
																			// iterate with the events
																			$event_info_query = tep_db_query("select ed.events_name, e.events_id, e.events_fees, e.events_image, if(CHAR_LENGTH(ed.events_description)>100,concat(left(ed.events_description,100),'...'),ed.events_description) as events_description,ed.events_name, e.events_date_available, e.events_date_added" .
										" from " . TABLE_EVENTS . " e , " . TABLE_EVENTS_DESCRIPTION . " ed, " . TABLE_EVENTS_TO_EVENTS_CATEGORIES . " ec2 where ed.events_id = e.events_id " .
										" and ed.events_id=ec2.events_id and ec2.events_categories_id='" . $category_id . "' " . EVENTS_CONDITION_STATUS . " and ed.language_id = '" . (int)$languages_id . "'");
										
									//	echo "select e.events_id, ed.events_name, e.events_fees, e.events_image, if(CHAR_LENGTH(ed.events_description)>100,concat(left(ed.events_description,100),'...'),ed.events_description) as events_description,ed.events_name, e.events_date_available, e.events_date_added" .
									//	" from " . TABLE_EVENTS . " e , " . TABLE_EVENTS_DESCRIPTION . " ed, " . TABLE_EVENTS_TO_EVENTS_CATEGORIES . " ec2 where ed.events_id = e.events_id " .
									//	" and ed.events_id=ec2.events_id and ec2.events_categories_id='" . $category_id . "' " . EVENTS_CONDITION_STATUS . " and ed.language_id = '" . (int)$languages_id . "'";
										
													while($event_info=tep_db_fetch_array($event_info_query)){
													$events_id=$event_info["events_id"];
												
													$events_info_result=array("events_name"=>$events_info["events_name"],
										                   "events_date_available"=>$events_info["events_date_available"],
										                   "events_fees"=>$events_info["events_fees"]); 
														   echo $events_info_result["events_name"];
													$find_sessions_query=tep_db_query("SELECT s.events_id,s.start_date,s.sessions_id from " . TABLE_EVENTS_SESSIONS . " s ".
																	" where "." s.start_date>'" .  $server_date . "' " ." and s.events_id=".$events_id." and s.sessions_type in('R','S') order by s.start_date ");
										//	echo "SELECT s.events_id,s.start_date,s.sessions_id from " . TABLE_EVENTS_SESSIONS . " s ".
										//							" where "." s.start_date>'" .  $server_date . "' " ." and s.events_id=".$events_id." and s.sessions_type in('R','S') order by s.start_date"; 	
										//						// check for some session exists in the event
														$rows_count=tep_db_num_rows($find_sessions_query);
														
													if ($rows_count>0){
													$detail_link=tep_href_link(FILENAME_SESSION_DETAILS,'events_id=' . $events_id . '&ecPath=' . $ecPath); 
													
													
														   
														  
														   
													 $end_month=$month_number;									  
													$maketime=mktime(0,0,0,$end_month,0,$year);
													$last_day=strftime("%Y-%m-%d",$maketime);
																	
																			
																			?>	
													
													<tr>
													<td class="eventTitleMedium"  align="left">
																			<?php echo '<a href="' . $detail_link . '" class="eventTitleMediumLink">' . $events_info_result["events_name"] . '</a>';
																		
																			 ?>
																		</td>
																		
																		<td>
																		<?php 
																		echo $events_info_result["events_fees"];
																		?>
																		
																		
																		</td>
																		
																		
																		</tr>
																			 <?php
										} // found session
									}?>
													
													</table>
													 <!-- 11 the table ended-->
												
								
																			
														</table>
													 <!-- 9 the table- ended -->
																		
														<td class="viewColRight"></td>
														</tr>
																	<tr>
																		<td width="9"><?php echo tep_image($cur_templ_path ."view_col_bl.gif");?></td>
																		<td class="viewColBottom"></td>
																		<td width="9"><?php echo tep_image($cur_templ_path ."view_col_br.gif");?></td>
																	</tr>
																</table>
																 <!-- 8 the table ended-->
											</table>
											 <!-- 7 the table ended-->
										
						<tr>
						<input type="hidden" name="post_action" value="change_cat">
						</form>
					</table>
					 <!-- 5 the table ended-->
					<td width="5" class="contentBackCol3"></td>
			   </tr>
			   </table>
			    <!-- 4 the table ended-->
		</table>
		 <!-- 3 the table ended-->
	</tr>
	</table>
	 <!-- 1 the table ended-->
</tr>
<?php // BOF: Lango Added for template MOD
if (MAIN_TABLE_BORDER == 'yes'){
	table_image_border_bottom();
	}
	// EOF: Lango Added for template MOD
	?>		
			
</table>



