<?php 

// Check to ensure this file is included in Freeway!
defined('_FEXEC') or die();
?>
<link href="../../stylesheet.css" rel="stylesheet" type="text/css" />
<link href="../../print.css" rel="stylesheet" type="text/css" />
<link href="../Original/stylesheet.css" rel="stylesheet" type="text/css" />
<div id="spiffycalendar" class="text"></div>
<table border="0" width="100%" height="100%" cellspacing="0" cellpadding="<?php echo CELLPADDING_SUB;?>">
<?php

	$seCat_path="";

	if ($secPath!="") $seCat_path.="&secPath=" . $secPath;

	echo tep_draw_form("frmView",tep_href_link(FILENAME_SERVICES_WEEK_VIEW,$seCat_path));

	$category_id=(isset($HTTP_POST_VARS['category_id'])?(int)$HTTP_POST_VARS['category_id']:0);
	$start_date=(isset($HTTP_POST_VARS['start_date'])?tep_db_prepare_input($HTTP_POST_VARS['start_date']):getServerDate());
	$end_date=(isset($HTTP_POST_VARS['end_date'])?tep_db_prepare_input($HTTP_POST_VARS['end_date']):getServerDate());
	$post_action=(isset($HTTP_POST_VARS['post_action'])?tep_db_prepare_input($HTTP_POST_VARS['post_action']):"change_cat");
	$server_date=getServerDate();

	// determine category id from post data or current services category or from the first data
	if ($category_id<=0) $category_id=(int)$current_services_category_id;
	if ($category_id<=0) {
		$first_cat_query=tep_db_query("SELECT services_categories_id from " . TABLE_SERVICES_CATEGORIES_DESCRIPTION . " order by services_categories_name limit 1");
		$first_cat_result=tep_db_fetch_array($first_cat_query);
		$category_id=(int)$first_cat_result["services_categories_id"];
	}
	
	if ($category_id>0) $cat_option=" and ec.services_categories_id='" . $category_id . "'";
	
	//determine action to nav_left or nav_right or view_date
	if ($post_action=="view_date") {
		$current_date=tep_db_prepare_input($HTTP_POST_VARS['select_date']);
	}else if ($post_action=="nav_left"){

		$end_date=date('Y-m-d',tep_datesub(strtotime($start_date),"day",1));
		$start_date=date('Y-m-d',tep_datesub(strtotime($start_date),"day",7));
	} else if ($post_action=="nav_right"){
		$start_date=date('Y-m-d',tep_dateadd(strtotime($end_date),"day",1));
		$end_date=date('Y-m-d',tep_dateadd(strtotime($end_date),"day",7));
	} else if ($start_date==$end_date){
		// find week start date and week end date
		$week_day=date("w",strtotime($start_date))-1;
		if ($week_day<0) $week_day=6;
		if ($week_day>0) $start_date=date("Y-m-d",tep_datesub(strtotime($start_date),"day",$week_day));
		$week_day=6-$week_day;
		if ($week_day>0) $end_date=date("Y-m-d",tep_dateadd(strtotime($end_date),"day",$week_day));
		
	}
	$navigate_left=true;
	$navigate_right=true;
	
	
	if ($start_date<=$server_date) $navigate_left=false;

	$month=date("m",strtotime($start_date));
	$year=date("Y",strtotime($start_date));

	// prepare for weeks
	$cur_week_date=$start_date . "|" . $end_date;
	
	$week_array=array();

	// get the first day of the month
	$temp_time_stamp=strtotime($start_date);
	$temp_time_stamp=tep_datesub($temp_time_stamp,"day",14);
	for ($icnt=0;$icnt<5;$icnt++){
		$end_time_stamp=tep_dateadd($temp_time_stamp,"day",6);
		$week_array[]=array("id"=>date("Y-m-d",$temp_time_stamp) . "|" . date("Y-m-d",$end_time_stamp),'text'=>date("M d",$temp_time_stamp). " - " . date("M d",$end_time_stamp));
		$temp_time_stamp=tep_dateadd($temp_time_stamp,"day",7);
		
	}
  
  
	$dates_array=tep_get_service_dates_array($start_date,7,"simple");
	$find_services_query1="SELECT se.service_id,se.service_start_time,se.service_end_time,se.no_booking_until,se.no_booking_until_date,date_format(se.no_booking_start,'%Y-%m-%d') as no_booking_sdate,date_format(se.no_booking_end,'%Y-%m-%d') as no_booking_edate,time_format(se.no_booking_start,'%H:%i') as no_booking_stime,time_format(se.no_booking_end,'%H:%i') as no_booking_end_time,".
							" se.service_end_time,se.booking_granular from " . TABLE_SERVICES . " se, " . TABLE_SERVICES_DESCRIPTION . " sed, " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " se2c " .
						  	" where  se2c.service_id=se.service_id and se.service_id=sed.service_id   and se2c.services_categories_id='".$category_id."' " . SERVICES_CONDITION_STATUS . " and sed.language_id = '" . (int)$languages_id . "' group by se.service_id ";

	$find_services_query=tep_db_query($find_services_query);
	$times_array=array();
	while($find_services_result=tep_db_fetch_array($find_services_query)){
		$select_id=$find_services_result["service_id"];
		
		$granular=$find_services_result["booking_granular"];
		$interval_min=60/$granular;
		
		
		$er=$er+1;
		while($start_hour<=$end_hour){
		if ($start_hour==$end_hour && $start_min>=$end_min) break;
		$time=sprintf("%02s:%02s",$start_hour,$start_min);
				
		if ($start_hour>=13){
			$time_text=sprintf("%02d:%02d:PM",$start_hour-12,$start_min);
		} else  {
			$time_text=sprintf("%02d:%02d:AM",$start_hour,$start_min);
		}
		//if (!($time>=$no_booking_stime && $time<=$no_booking_etime)){
			$service_details[$time_text][]=array("service_id"=>$find_services_result["service_id"],"name"=>$find_services_result["service_name"],"start_time"=>$find_services_result["service_start_hour"],"end_time"=>$find_services_result["service_end_hour"],"service_date_available"=>$find_services_result["service_dateavail"],
				"no_booking_start_date" =>$find_services_result["no_booking_start_date"],"no_booking_end_date" =>$find_services_result["no_booking_end_date"],
				"no_booking_start" =>$find_services_result["no_booking_start"],"no_booking_end" =>$find_services_result["no_booking_end"],
				"no_booking_until"=>$find_services_result["no_booking_until"],"no_booking_until_date"=>$find_services_result["no_booking_until_date"]);
	//	}
		$start_min+=$interval_min;
		// create time text AM or PM 
		if ($start_min>=60){
			$start_min=$start_min-60;
			$start_hour++;
		}
		//print_r($service_details[$time_text]);
		}
		/*while($start_hour<=$end_hour){
		if (strlen($start_hour)>1?$start_hour=$start_hour:$start_hour="0".$start_hour)
				if($start_hour>= 12 )
			{
			 	 $meridian="PM";}
			else{
			  $meridian="AM" ;}
			  
			   if($start_hour>12)
			   $hour=$start_hour-12;
			   else
			    $hour=$start_hour;
			$time=sprintf("%02d",$hour) . ":" .sprintf("%02d",$start_min). ":" .$meridian;
			
			$service_details[$time][]=array("service_id"=>$find_services_result["service_id"],"name"=>$find_services_result["service_name"],"start_time"=>$find_services_result["service_start_hour"],"end_time"=>$find_services_result["service_end_hour"],"service_date_available"=>$find_services_result["service_dateavail"],
											"no_booking_start_date" =>$find_services_result["no_booking_start_date"],"no_booking_end_date" =>$find_services_result["no_booking_end_date"]);
			$start_min=$start_min+$interval_min;
			if ($start_hour==$end_hour && $start_min>$end_min){
				break;
			} 
			else if ($start_min>=60){
			    $start_min=0; if (strlen($start_min)>1?$start_min=$start_min:$start_min=$start_min ."0")
				$start_hour=$start_hour+1;
			}	
 		 }*/
    }
	set_time_limit(10);
	//no booking dates
$book_details=array();
$nobooking_query1="select v.service_id,vd.service_name,vnb.no_booking_days from  " . TABLE_SERVICES . " v, " . TABLE_SERVICES_TO_SERVICES_CATEGORIES  . " v2c ,"  . TABLE_SERVICES_DESCRIPTION  . " vd ," . TABLE_SERVICES_NO_BOOKING_DAYS  . " vnb " .
	              " where   v2c.service_id=v.service_id and v.service_id=vd.service_id and v.service_id=vnb.service_id and v2c.services_categories_id= '".$category_id."' and date_format(v.service_date_available,'%Y-%m-%d')>date_format(curdate(),'%Y-%m-%d')and vd.language_id = '" . (int)$languages_id . "' ";
	//echo $nobooking_query1;			
$nobooking_query=tep_db_query($nobooking_query1);
	while($nobooking_result=tep_db_fetch_array($nobooking_query)){
		$nobookdays=$nobooking_result["no_booking_days"];
		$book_details[]=array("service_id"=>$nobooking_result["service_id"],"no_booking_days"=>$nobooking_result["no_booking_days"]);
		}
		
	//order edit services	
	
	$order_details=array();
	$order_details_query1="select o.products_id,o.start_time,o.start_date,vd.service_name,time_format(o.start_time,'%H') as ostart_hour,time_format(o.end_time,'%H ') as oend_hour,time_format(o.start_time,'%i') as ostart_min from  " . TABLE_ORDERS_SERVICES . " o, ".TABLE_SERVICES." s, " . TABLE_SERVICES_TO_SERVICES_CATEGORIES  . " v2c ,"  . TABLE_SERVICES_DESCRIPTION  . " vd " . 
                          " where date_format(s.service_date_available,'%Y-%m-%d')>curdate() and vd.service_id=o.products_id and s.service_id=o.products_id and v2c.service_id=o.products_id and v2c.services_categories_id= '".$category_id."' and vd.language_id = '1' group by o.products_id";
		
	//	echo $order_details_query1;
	$order_details_query=tep_db_query($order_details_query1);
	   while($order_details_result=tep_db_fetch_array($order_details_query))
	   {
		   $ostart_hour=$order_details_result["ostart_hour"];
		   $oend_hour=$order_details_result["oend_hour"];
		   $ostart_min=$order_details_result["ostart_min"];
		   
				if($ostart_hour>= 12 )
					{
			 	 		$omeridian="PM";
					}
				else
					{
					  $omeridian="AM" ;
					}
			 if($ostart_hour>12)
			   	$ohour=$ostart_hour-12;
			   else
			    $ohour=$ostart_hour;
				$otime=sprintf("%02d",$ohour) . ":" .sprintf("%02d",$ostart_min). ":" .$omeridian;
		
		      
			  

	   $order_details[]=array("service_id"=>$order_details_result["service_id"],"service_name"=>$order_details_result["service_name"],
	   						  "start_time"=>$otime,"start_date"=>$order_details_result["start_date"]);
							 
							   
		}
						   
	   
	   
		
	if (sizeof($time_array)>0) $services_found=true;
	// BOF: Lango Added for template MOD
	if (MAIN_TABLE_BORDER == 'yes'){
	table_image_border_top(false, false, TEXT_HEADING_BROWSE);
	}
	// select category details
	
	$cat_array=array();
	$cat_list_query=tep_db_query("SELECT ecd.services_categories_name,ecd.services_categories_id from " . TABLE_SERVICES_CATEGORIES . " ec, " . 
								TABLE_SERVICES_CATEGORIES_DESCRIPTION . " ecd where ecd.services_categories_id=ec.services_categories_id and ecd.language_id='" . 
								$languages_id . "' order by services_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["services_categories_id"],'text'=>$cat_list_result["services_categories_name"]);
	}
	
	//print_r($service_details);
	
//	print_r($order_details);
?>
	<script language="JavaScript">
		function ChangeResult(mode){
			if (mode==1){
				document.frmView.post_action.value="nav_left";
			} else if (mode==2){
				document.frmView.post_action.value="nav_right";
			}else if (mode==3){
				document.frmView.post_action.value="view_date";
			} else if (mode==5){
				var element=document.frmView.selWeek;
				var spltDetail;
				var content;
				if (element.selectedIndex<0) return;
				content=element.options[element.selectedIndex].value;
				spltDetail=content.split("|");
				document.frmView.start_date.value=spltDetail[0];
				document.frmView.end_date.value=spltDetail[1];
			} else {
				document.frmView.action="<?php echo tep_href_link(FILENAME_SERVICES_WEEK_VIEW);?>";
				document.frmView.post_action.value="change_cat";
			}
			document.frmView.submit();			
		}
		function OpenDayView(id){
			var element=document.frmView.elements["date_"+id];
			if (!element) return;
			document.frmView.current_date.value=element.value;
			document.frmView.action="<?php echo tep_href_link(FILENAME_SERVICES_DAY_VIEW,$seCat_path);?>";
			document.frmView.submit();
		}
		function ChangeView(mode){
			switch(mode){
				case 1:
					document.frmView.action="<?php echo tep_href_link(FILENAME_SERVICES_DAY_VIEW,$seCat_path);?>";
					break;
				case 2:
					document.frmView.action="<?php echo tep_href_link(FILENAME_SERVICES_WEEK_VIEW,$seCat_path);?>";
					break;
				case 3:
					document.frmView.action="<?php echo tep_href_link(FILENAME_SERVICES_MONTH_VIEW,$seCat_path);?>";
					break;
			}
			document.frmView.submit();
		}
		function ViewPrevious(){
			document.frmPrevious.submit();
		}
	</script>
	
<table  width='100%' border="0" cellspacing="0" cellpadding="0" align="left">
	<tr>
	
		<td class="main">
		<table width='100%' border="0" cellspacing="0" cellpadding="0" align="left">
			<tr class="servicesTitleRow">
				<td valign="middle" width="130" class="eventTitle">&nbsp;&nbsp;<?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(4);">' . tep_template_image_button("button_quick_find.gif",IMAGE_VIEW_DATE,'align=absmiddle') . '</a>';
					?>
				</td>
				<td valign="middle" align="right" width="350" class="servicesTitle">
					<?php 
						echo '<a href="javascript:ChangeView(1)">' . tep_template_image_button("button_day_view.gif",IMAGE_DAY_VIEW,'align=absmiddle') . '</a>&nbsp;';
						echo tep_template_image_button("button_week_view_selected.gif",IMAGE_WEEK_VIEW,'align=absmiddle') . '&nbsp;';
						echo '<a href="javascript:ChangeView(3)">' . tep_template_image_button("button_month_view.gif",IMAGE_MONTH_VIEW,'align=absmiddle') . '</a>&nbsp;';
					?>
				</td>
			</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif','1','10');?></td>
	</tr>
	<tr>
		<td>
		<!--<table border="0" cellpadding="0" cellspacing="0" width="100%">
		<tr>
			<td>!-->
			<table border="0" cellpadding="0" cellspacing="0" width="100%">
				<tr>
					<td class="contentBackCol1" width="6"></td>	
					<td class="contentBackCol2">
					<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 current services category
						
						$cat_query=tep_db_query("SELECT ecd.services_categories_name,ec.services_categories_image,if(CHAR_LENGTH(ecd.services_categories_description)>250,concat(left(ecd.services_categories_description,250),'...'),ecd.services_categories_description) as services_categories_description from " . 
												TABLE_SERVICES_CATEGORIES . " ec, " . TABLE_SERVICES_CATEGORIES_DESCRIPTION . " ecd " .
												" where ecd.services_categories_id='" . $category_id . "' and ecd.language_id='" . $languages_id . "' and ecd.services_categories_id=ec.services_categories_id");
						$cat_info=tep_db_fetch_array($cat_query);
					?>
					<tr>
						<td>
						<table border="0" cellpadding="0" cellspacing="0" valign="top" width="100%">
							<tr>
								<td valign="top" class="headerBrowse"><?php echo $cat_info['services_categories_name'];?></td>
							</tr>
							<tr>
								<td valign="top" class="smallText">
									<?php 
										echo ($cat_info['services_categories_image']==''?'':tep_image(DIR_WS_IMAGES . $cat_info['services_categories_image'] , $cat_info['services_categories_name'],SMALL_IMAGE_WIDTH,SMALL_IMAGE_WIDTH,'align="right"'));
										echo $cat_info['services_categories_description'];
									?>
								</td>
							</tr>
						</table>
						</td>
					</tr>
					<?php }
					?>
					<tr>
						<td><?php echo tep_draw_separator('pixel_trans.gif',1,20);?></td>
					</tr>
					<tr>
						<td>
						<table border="0" cellspacing="0" cellpadding="0" valign="top" width="100%">
							<tr class='servicesListing-data'>
								<td valign="top" width="20"><?php if ($navigate_left) echo '<a href="javascript:ChangeResult(1);">' . tep_template_image_button("navigate_left.gif",IMAGE_PREVIOUS_DAY) . '</a>';?></td>
								<td valign="middle" align="center" class="headerSubBrowse">
									Week: <?php echo tep_draw_pull_down_menu("selWeek",$week_array,$cur_week_date,'OnChange="ChangeResult(5)"'); 
								?>
								</td>
								<td valign="top" width="20"><?php if ($navigate_right) echo '<a href="javascript:ChangeResult(2);">' . tep_template_image_button("navigate_right.gif",IMAGE_NEXT_DAY) . '</a>';?></td>
							</tr>
						</table>
						
						</td>
					</tr>
					<tr>
						<td><?php echo tep_draw_separator('pixel_trans.gif',1,15);?></td>
					</tr>
					<tr>
						<td valign="top">
						
						
						<table border="1"  cellspacing="0" cellpadding="0" valign="top" width="100%" class="formArea" bordercolordark="#c3d1e3">
						
							<tr   >
							<td  class="headerCalendar"  align="center">Time </td>
								<?php 
									set_time_limit(5);
									// display the week name header
									for ($icnt=1;$icnt<=7;$icnt++){
										if ($icnt==7)
											$class="headerCalendarSunday";
										else
											$class="headerCalendar";
										echo '<td class="' . $class . '" align="center" onClick="javascript:OpenDayView(' . $icnt . ');">' . constant("TEXT_DAY" . $icnt) . '</td>';
									}
								?>
							</tr>
							
							<tr><td class="dataCalendarSunday">&nbsp;<b>Time</b> <br /><br /></td>
							<?php
						
							$temp_date=$start_date;
							$cur_date=$server_date;
							
											
									// display the selected week days and services details
								
								for ($icnt=1;$icnt<=7;$icnt++) {
										echo '<input type="hidden" name="date_' . $icnt . '" value="' . $temp_date . '">';
										if ($icnt==7){
									$class="dataCalendarSunday";
								} else if ($icnt%2==0){
									
									$class="dataCalendarEven";
								} else {
								
									$class="dataCalendarOdd";
								}
								?>
						
								
								<?php 
								if ($temp_date<$cur_date) { ?>
									<Td class="tdSubCalendarGray" valign="top"><span class="headerSubCalendarGray" onClick="javascript:OpenDayView(<?php echo $icnt;?>);"><?php echo date("d",strtotime($temp_date)); ?></span>
									
									</Td>
								<?php } else { ?>
									<Td valign="top"><span class="headerSubCalendar" onClick="javascript:OpenDayView(<?php echo $icnt;?>);"><?php echo date("d",strtotime($temp_date)); ?></span></Td>
								<?php
								 }
									$temp_date=date("Y-m-d",tep_dateadd(strtotime($temp_date),"day",1));
								 
							}
									 ?>
							</tr>
						<!--	<tr><td colspan="8"><table cellpadding="0" cellspacing="0" border="1" bordercolor="#993333">-->
							
							<!-- Time scheduling   --> <?php
							
							if (sizeof($service_details)>0){
								reset($service_details);
								 $tarr = array();	
								 $rt=0;				
								while( list($key,)=each($service_details)){
								if (!in_array($key,$tarr)){
								$rt=$rt+1;
									$tarr[]=$key;
								}
							}	
						
						for ($kcnt=0;$kcnt<sizeof($tarr);$kcnt++) {
							$sr=substr($tarr[$kcnt],6);
							if($sr=="AM")
								$morning_session_array[]=$tarr[$kcnt];
							else
								$evening_session_array[]=$tarr[$kcnt]	;
							}
							sort($morning_session_array);
							sort($evening_session_array);
							$time_session_array=array_merge($morning_session_array,$evening_session_array);
						
							}	
						?>
						
							<?php 
							//print_r($service_details);
							reset($service_details);
							if (sizeof($service_details)>0){
								$temp_date=$start_date;
									for($ic=0;$ic<sizeof($time_session_array);$ic++){
							?>
									<tr>
										<td  class="calEventTime"  >
							<?php
											echo $time_session_array[$ic];
							?>
									
										</td>
							<?php
									$tempd=date("Y-m-d",strtotime($temp_date));
									$startd =date("d",strtotime($start_date));
									$endd=date("d",strtotime($end_date));	
									
									for($dcnt=1;$dcnt<=7;$dcnt++){
									
										if ($tempd<$cur_date){
									$class="headerSubCalendarGray";
								} else {
								   $class="calEventName";
								   }
								   echo '<td class="' . $class . '" align="center">';
									
							?>
							
							
							<!--<td   class="calEventName" >-->
							
							
								<?php // echo $final_time_session_array[$time_session_array[$ic]][2];
										//echo $server_Date;
//										echo $tempd;
//print_r(
//print_r($service_details[$time_session_array[$ic]]);
										if ( sizeof($service_details[$time_session_array[$ic]])>0 ){
								for($t=0;$t<sizeof($service_details[$time_session_array[$ic]]);$t++){
									if (strtotime( $service_details[$time_session_array[$ic]][$t]["service_date_available"])<=strtotime($tempd)) 
									// to display under current date
										{
										
										// to display the no booking days from the date list
										for($bc=0;$bc<(sizeof($book_details));$bc++)
										  {
										 if ((strtotime($book_details[$bc]["no_booking_days"]) == strtotime($tempd)) && ($service_details[$time_session_array[$ic]][$t]["service_id"]==$book_details[$bc]["service_id"]))
											{
											echo '&nbsp;';
											break;
											}
											} 
											if($bc>=(sizeof($book_details))){
												for($od=0;$od<sizeof($order_details);$od++)
												{
													if($time_session_array[$ic]==$order_details[$od]["start_time"]){
														echo   '<font style="font-family: Verdana, Arial, sans-serif;
  font-size: 10px;" >'.$order_details[$od]["service_name"].'</font>';
														break;
														}
													}
														if($od>=sizeof($order_details)){
															/*if($service_details[$time_session_array[$ic]][$t]["no_booking_until"]=="Y"){
																if(strtotime($service_details[$time_session_array[$ic]][$t]["service_date_available"])<= strtotime($service_details[$time_session_array[$ic]][$t]["no_booking_until_date"]))
																echo '&nbsp;';
																else
																{
																if(!((strtotime($tempd)>=strtotime($service_details[$time_session_array[$ic]][$t]["no_booking_start_date"]) && strtotime($tempd)<=strtotime($service_details[$time_session_array[$ic]][$t]["no_booking_end_date"])) && get_diff_time($time_session_array[$ic],$service_details[$time_session_array[$ic]][$t]["no_booking_start"],"m")<=0 && get_diff_time($time_session_array[$ic],$service_details[$time_session_array[$ic]][$t]["no_booking_end"],"m")>=0 ))
														echo ' <a href="' . tep_href_link(FILENAME_SERVICES_INFO,'service_id=' . $service_details[$time_session_array[$ic]][$t]["service_id"] . $secCat_path) . '">' .  '<font style="font-family: Verdana, Arial, sans-serif;
  font-size: 10px;" >'.$service_details[$time_session_array[$ic]][$t]["name"] .'</font>'. "</a>".'<br>';
  														else
															
															echo '&nbsp;';
																}
															}*/
																
														//else if($service_details[$time_session_array[$ic]][$t]["no_booking_until"]=="N"){	
															
														if(!((strtotime($tempd)>=strtotime($service_details[$time_session_array[$ic]][$t]["no_booking_start_date"]) && strtotime($tempd)<=strtotime($service_details[$time_session_array[$ic]][$t]["no_booking_end_date"])) && get_diff_time($time_session_array[$ic],$service_details[$time_session_array[$ic]][$t]["no_booking_start"],"m")<=0 && get_diff_time($time_session_array[$ic],$service_details[$time_session_array[$ic]][$t]["no_booking_end"],"m")>=0 ))
														echo ' <a href="' . tep_href_link(FILENAME_SERVICES_INFO,'service_id=' . $service_details[$time_session_array[$ic]][$t]["service_id"] . $secCat_path) . '">' .  '<font style="font-family: Verdana, Arial, sans-serif;
  font-size: 10px;" >'.$service_details[$time_session_array[$ic]][$t]["name"] .'</font>'. "</a>".'<br>';
  														else
															
															echo '&nbsp;';
  														}
														//}
										}
										}
										else
										echo "&nbsp;";
										//echo '</td>';
										}
										
										}
										else
										echo "&nbsp;";
										echo '</td>';
								?>
							<!--</td>-->
							<?php
										// increment the date value
										$tempd=date("Y-m-d",tep_dateadd(strtotime($tempd),"day",1));

									
									}
							}}?></tr><!--</table></td></tr>-->
					<tr>
						<td class="main">
						
						<table width='100%' border="0" cellspacing="0" cellpadding="0" align="left">
							<tr>
								<td>
								<?php
								
									echo '<a href="javascript:ViewPrevious();">' . tep_template_image_button("button_back.gif",IMAGE_BACK) . '</a>';
								?>
								</td>
							</tr>
						</table>
						</td>
					</tr>
				</table>
				
				<td class="contentBackCol3" width="6"></td>
			</tr>
		</table>	
		</td>
		</tr>
		</table>
		</td>
	</tr>
	<tr>
		<td><?php echo tep_draw_separator('pixel_trans.gif',1,10);?></td>
	</tr>
<input type="hidden" name="start_date" value="<?php echo $start_date;?>">
<input type="hidden" name="end_date" value="<?php echo $end_date;?>">
<input type="hidden" name="current_date" value="<?php echo $start_date;?>">
<input type="hidden" name="post_action" value="">
</form>
</table>
</td>
</tr>
<?php


	// display the post details as hidden values for back action
	$page_param=(isset($HTTP_SESSION_VARS["calendar_style"])?$HTTP_SESSION_VARS["calendar_style"]:"day");
	if ($page_param=="month") {
		$page_name=FILENAME_SERVICES_MONTH_VIEW;
	} else if ($page_param=="week"){
		$page_name=FILENAME_SERVICES_WEEK_VIEW;
	} else if ($page_param=="day"){
		$page_name=FILENAME_SERVICES_DAY_VIEW;
	} else {
		$page_name=basename($GLOBALS["PHP_SELF"]);
	}
	echo tep_draw_form("frmPrevious",tep_href_link($page_name,$seCat_path));
	echo '<input type="hidden" name="temp" value="1">';
		$view_state=(isset($HTTP_SESSION_VARS["VIEW_STATE"])?$HTTP_SESSION_VARS["VIEW_STATE"]:array());
	if (sizeof($view_state)){
	
	  reset($view_state);
	  while (list($key, $value) = each($view_state)) {
		if (!is_array($view_state[$key])) {
		  echo tep_draw_hidden_field($key, htmlspecialchars(stripslashes($value)));
		}
	  }
	}
	echo '</form>';
	tep_set_session_value("VIEW_STATE",$HTTP_POST_VARS);
	tep_set_session_value("calendar_style","week");
	if (MAIN_TABLE_BORDER == 'yes'){

	table_image_border_bottom();
	}
?>
</table>