<?php
// Set flag that this is a parent file
	defined('_FEXEC') or die();
 $server_date = getServerDate(true);
 $current_date = getServerDate();
 $cID = (isset ($HTTP_GET_VARS['cID']) ? $HTTP_GET_VARS['cID'] : 0);
 $pID = (isset ($HTTP_GET_VARS['pID']) ? $HTTP_GET_VARS['pID'] : 0);
 $check_ID = (isset ($HTTP_GET_VARS['chk_ID']) ? $HTTP_GET_VARS['chk_ID'] : 0);
 $service_id = ($HTTP_GET_VARS['pID']) ? $HTTP_GET_VARS['pID'] : $HTTP_POST_VARS['product_id'];
 $HTTP_POST_VARS['product_id'] = $service_id;
 $action = (isset ($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
 $formname='new_product';
 //End Categories Description 1.5	  	
 if ($action != "") {
	$languages = tep_get_languages();
	$categories = array ();
	if ($HTTP_GET_VARS['cID'] > 0) {
		$categories_query = tep_db_query("select c.parent_id,c.services_categories_id, cd.services_categories_name, c.services_categories_image, c.sort_order, c.date_added, c.last_modified from  " . TABLE_SERVICES_CATEGORIES . "  c,  " . TABLE_SERVICES_CATEGORIES_DESCRIPTION . "  cd where c.services_categories_id = cd.services_categories_id and cd.language_id = '" . $languages_id . "' and c.services_categories_id='" . (int) $cID . "' order by c.sort_order, cd.services_categories_name");
		if (tep_db_num_rows($categories_query) > 0) $categories = tep_db_fetch_array($categories_query);
	}
	$cInfo = new objectInfo($categories);
	$service_query = tep_db_query("select su.service_id,sd.service_name, sd.service_description, su.quantity,date_format(su.service_date_added,'%Y-%m-%d') as service_date_added, date_format(su.service_last_modified,'%Y-%m-%d') as service_last_modified,su.service_status,su.service_image,su.include_resource,su.service_tax_class_id,su.service_costs from " . TABLE_SERVICES . " su, " . TABLE_SERVICES_DESCRIPTION . " sd where su.service_id = '" . (int) $service_id . "' and su.service_id = sd.service_id and sd.language_id = '" . (int) $languages_id . "'");
	if (tep_db_num_rows($service_query) > 0) {
		$service = tep_db_fetch_array($service_query);
		$suInfo = new objectInfo($service);
	}
	$cPath = isset ($HTTP_POST_VARS['cPath']) ? $HTTP_POST_VARS['cPath'] : '0';
	$current_service_category_id = $cPath;
	if ($action == 'file_upload') {
		$sql_data_array = array ();
		$upload_fs_dir = DIR_FS_CATALOG_IMAGES;
		$upload_error=false;
		if ($HTTP_POST_VARS['action_type'] == "new_category" || $HTTP_POST_VARS['action_type'] == "edit_category") {
		  $categories = new upload('services_categories_image');
		  if(!is_writable($upload_fs_dir) || !is_writable($upload_fs_dir)){
			 echo 'upload_error^';
			 if(!is_writable($upload_fs_dir)) echo sprintf(WARNING_IMAGE_DIRECTORY_WRITEABLE,$upload_fs_dir);    		 
		  }else {
			$categories->set_destination($upload_fs_dir);
			if ($categories->parse() && $categories->save())
				$categories_image_filename = $categories->filename;
				$upload_error=false;				
			if(strlen($categories->filename)>64) {
			  $upload_error=true;
			  echo 'upload_error^'.ERR_SERVICE_CATEGORIES_IMAGE_LENGTH;	
			}else if($categories_image_filename!="" && $HTTP_POST_FILES['services_categories_image']['size']<=0){
				$upload_error=true;
			    echo 'upload_error^'.ERR_SERVICE_CATEGORIES_IMAGE_DOESNT_EXISTS;
			}			
			if ($HTTP_POST_VARS['action_type'] == 'new_category' && !$upload_error) {
				$sql_data_array = array (
					'services_categories_image' => $categories_image_filename,
					'date_added' => $server_date,
					'parent_id' => ($HTTP_POST_VARS['main_category'] == 'Y'
				) ? 0 : $HTTP_POST_VARS['cPath']);
				tep_db_perform(TABLE_SERVICES_CATEGORIES, $sql_data_array);
				$insert_id = tep_db_insert_id();
				echo $insert_id;
				for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
					$insert_sql_data = array (
						'services_categories_id' => $insert_id,
						'language_id' => $languages[$i]['id']
					);
					tep_db_perform(TABLE_SERVICES_CATEGORIES_DESCRIPTION, $insert_sql_data);
				}
			} else if ($HTTP_POST_VARS['action_type'] == 'edit_category' && !$upload_error ) 
			   tep_db_query("update " . TABLE_SERVICES_CATEGORIES . " set services_categories_image = '" . $categories_image_filename . "' where services_categories_id = '" . tep_db_input($HTTP_POST_VARS['cPath']) . "'");
		}
	  	} else if ($HTTP_POST_VARS['action_type'] == "new" || $HTTP_POST_VARS['action_type'] == "edit") {
			for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
				$language_id = $languages[$i]['id'];
				$products_image = new upload("service_image_".$language_id);
				$products_image->set_destination(DIR_FS_CATALOG_IMAGES);
				$upload_error=false;
				if(!is_writable($upload_fs_dir) || !is_writable($upload_fs_dir)){
			 		echo 'upload_error^';
			 		if(!is_writable($upload_fs_dir)) echo sprintf(WARNING_IMAGE_DIRECTORY_WRITEABLE,$upload_fs_dir);
				}else if ($products_image->parse() && $products_image->save()){
					if(strlen($products_image->filename)>64) {
			  			$upload_error=true;
			  			echo 'upload_error^'.ERR_SERVICE_IMAGE_LENGTH;	
					}else if($products_image->filename!="" && $HTTP_POST_FILES['service_image_'.$language_id]['size']<=0){
						$upload_error=true;
			    		echo 'upload_error^'.ERR_SERVICE_CATEGORIES_IMAGE_DOESNT_EXISTS;
					}
					if ($HTTP_POST_VARS['action_type'] == "new" && !$upload_error) {
						$sql_data_array = array (
							'service_image' => $products_image->filename,
							'service_date_added' => $server_date
						);
						tep_db_perform(TABLE_SERVICES, $sql_data_array);
						$products_id = tep_db_insert_id();
						echo $products_id;
						$insert_sql_data = array (
								'service_id' => $products_id,
								'language_id' => $language_id);
						tep_db_perform(TABLE_SERVICES_DESCRIPTION, $insert_sql_data);
					} else if ($HTTP_POST_VARS['action_type'] == 'edit' && !$upload_error) tep_db_query("update " .TABLE_SERVICES . " set service_image='" . $products_image->filename . "' where service_id='" . (int) $HTTP_POST_VARS['product_id'] . "'");
		  	  }
     	}
	 }
	} else
		if ($action == 'get_category_details') {
			$product_categories = tep_db_query("select date_format(c.date_added,'%Y-%m-%d') as date_added,date_format(c.last_modified,'%Y-%m-%d') as last_modified,cd.services_categories_id,cd.services_categories_name,c.sort_order,c.services_categories_image from " . TABLE_SERVICES_CATEGORIES . "  c, " . TABLE_SERVICES_CATEGORIES_DESCRIPTION . " cd where c.services_categories_id=cd.services_categories_id and cd.language_id='" . (int) $languages_id . "' and c.services_categories_id='" . (int) $cID . "'");
			if (tep_db_num_rows($product_categories) > 0)
				$product = tep_db_fetch_array($product_categories);
			echo get_category_details($product);
		} else
			if ($action == 'edit_category')
				tep_create_new_product_category();
			else
				if ($action == 'update_category') {
					$categories_id = $cID;
					$current_category_id = (int) $HTTP_POST_VARS['cPath'];
					// for edit get the update id
					$services_categories_id = (int) $current_category_id;
					$sort_order = (int)$HTTP_POST_VARS['sort_order'];
					if ($HTTP_POST_VARS['action_type'] == 'new_category' && $HTTP_POST_VARS['main_category'] == 'Y') {
						echo 'new_main_category^';
						$current_category_id = 0;
						$sort_query = tep_db_query("select max(sort_order) as sort_order from " . TABLE_SERVICES_CATEGORIES);
						if (tep_db_num_rows($sort_query) > 0) {
							$sort = tep_db_fetch_array($sort_query);
							$sort_order = $sort['sort_order'] + 1;
						}
					} else  echo $HTTP_POST_VARS['action_type'] . '^';								
					$sql_data_array = array ('sort_order' => $sort_order);
					// insert the category
					if (!$HTTP_GET_VARS['cID']) {
						$insert_sql_data = array (
							'parent_id' => $current_category_id,
							'date_added' => $server_date
						);
						$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
						tep_db_perform(TABLE_SERVICES_CATEGORIES, $sql_data_array);
						$insert_id = tep_db_insert_id();
					}
					elseif ($HTTP_GET_VARS['cID']) {
						$update_sql_data = array ('last_modified' => $server_date);
						$sql_data_array = array_merge($sql_data_array, $update_sql_data);
						tep_db_perform(TABLE_SERVICES_CATEGORIES, $sql_data_array, 'update', "services_categories_id = '" . (int) $services_categories_id . "'");
					}
					// update the service category description
					for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
						$services_categories_name_array = str_replace("|||","&",$HTTP_POST_VARS['services_categories_name']);
						$language_id = $languages[$i]['id'];
						$sql_data_array = array (
							'services_categories_name' => tep_db_prepare_input($services_categories_name_array[$language_id]
						));
						if (ALLOW_CATEGORY_DESCRIPTIONS == 'true') {
							$sql_data_array = array (
								'services_categories_name' => tep_db_prepare_input($HTTP_POST_VARS['services_categories_name'][$language_id]
							), 'services_categories_heading_title' => tep_db_prepare_input($HTTP_POST_VARS['services_categories_heading_title'][$language_id]), 'services_categories_description' => tep_db_prepare_input($HTTP_POST_VARS['services_categories_description'][$language_id]), 'services_categories_notes' => tep_db_prepare_input($HTTP_POST_VARS['services_categories_notes'][$language_id]));
						}
						// insert the category
						if (!$HTTP_GET_VARS['cID']) {
							$insert_sql_data = array (
								'services_categories_id' => $insert_id,
								'language_id' => $languages[$i]['id']
							);
							$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
							tep_db_perform(TABLE_SERVICES_CATEGORIES_DESCRIPTION, $sql_data_array);
						}
						elseif ($HTTP_GET_VARS['cID']) { //update the category
							tep_db_perform(TABLE_SERVICES_CATEGORIES_DESCRIPTION, $sql_data_array, 'update', "services_categories_id = '" . (int) $HTTP_GET_VARS['cID'] . "' and language_id = '" . (int) $languages[$i]['id'] . "'");
							$insert_id = $HTTP_GET_VARS['cID'];
						}
					}
					// update the services categories image
					if ($HTTP_POST_VARS['action_type'] == 'new_category')
						echo $insert_id . '{}' . $services_categories_name_array[$languages_id] . '{}' . $current_category_id;
					else
						if ($HTTP_POST_VARS['action_type'] == 'edit_category') {
							echo $current_category_id . '{}' . $services_categories_name_array[$languages_id] . '{}';
							echo get_category_details($categories);
						}
				tep_reset_seo_cache('services');
				} else
					if ($action == 'delete_category') {
						$contents = '<table width="100%" class="openContent" border="0" cellspacing="2" cellpadding="2"><tr><td width="10" align="right">' . tep_image('images/template/img_trash.gif') . '</td><td class="main" colspan="4"><b>' . TEXT_DELETE_CATEGORY_INTRO . '</b></td></tr><tr>';
						$contents .= '<tr><td></td><td class="main">' . $cInfo->services_categories_name . '</td></tr>';
						$category_childs = tep_childs_in_service_category_count($cInfo->services_categories_id);
						$category_products = tep_service_in_service_category_count($cInfo->services_categories_id);
						if ($category_childs > 0) $contents .= '<tr><td></td><td class="main">' . sprintf(TEXT_DELETE_WARNING_CHILDS, $category_childs) . '</td></tr>';
						if ($category_products > 0) $contents .= '<tr><td></td><td class="main">' . sprintf(TEXT_DELETE_WARNING_SERVICES, $category_products) . '</td></tr>';
						$contents .= '<tr><td colspan="2">' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td></tr></table>';
						echo $contents;
					} else if ($action == 'delete_category_confirm') {
							if ($HTTP_GET_VARS['cID']) {
								$services_categories_id = (int) $HTTP_GET_VARS['cID'];
								$services_categories = tep_get_services_category_tree($services_categories_id, '', '0', '', true);
								$service = array ();
								$service_delete = array ();

								//get the service details belong to the deleted category
								for ($i = 0, $n = sizeof($services_categories); $i < $n; $i++) {
									$service_ids_query = tep_db_query("SELECT service_id from " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " where services_categories_id = '" . (int) $services_categories[$i]['id'] . "'");
									while ($service_ids = tep_db_fetch_array($service_ids_query)) {
										$service[$service_ids['service_id']]['services_categories'][] = $services_categories[$i]['id'];
									}
								}
								reset($service);
								while (list ($key, $value) = each($service)) {
									$service_category_ids = '';

									for ($i = 0, $n = sizeof($value['services_categories']); $i < $n; $i++) {
										$service_category_ids .= "'" . (int) $service['services_categories'][$i] . "', ";
									}
									$service_category_ids = substr($service_category_ids, 0, -2);
									$check_query = tep_db_query("SELECT count(*) as total from " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " where service_id = '" . (int) $key . "' and services_categories_id not in (" . $service_category_ids . ")");
									$check = tep_db_fetch_array($check_query);
									if ($check['total'] < '1') {
										$service_delete[$key] = $key;
									}
								}
								tep_set_time_limit(0);

								for ($i = 0, $n = sizeof($services_categories); $i < $n; $i++) {
									tep_remove_service_category($services_categories[$i]['id']);
								}

								reset($service_delete);
								while (list ($key) = each($service_delete)) {
									tep_remove_service($key);
								}
								if ($services_categories_id != $cInfo->parent_id)
									$parent_id = $cInfo->parent_id;
								echo 'delete_category_success^' . $services_categories_id;
							}
						tep_reset_seo_cache('services');
						} else if ($action == 'move_category') {
								$contents = '<table width="100%"  border="0" cellspacing="5" cellpadding="5" class="openContent"><tr><td width="10" class="main">' . tep_image('images/template/img_move.gif') . '</td><td class="main" colspan="4"><b>' . sprintf(TEXT_MOVE_SERVICES_CATEGORIES_INTRO, $cInfo->services_categories_name) . '</b></td></tr><tr>';
								$contents .= '<tr><td></td><td class="main" align="left">' . sprintf(TEXT_MOVE, $cInfo->services_categories_name) . '&nbsp;' . tep_draw_pull_down_menu('move_to_service_category_id', tep_get_services_category_tree('0', '', $cInfo->services_categories_id), $cID) . '</td></tr>';
								$contents .= '<tr><td colspan="2">' . tep_draw_separator('pixel_trans.gif', '1', '10') . '</td></tr></table>';
								echo $contents;
						} else if ($action == 'move_category_confirm') {
									if ($cID && ($cID != $HTTP_POST_VARS['move_to_service_category_id'])) {
										$cID = tep_db_prepare_input($cID);
										$new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_service_category_id']);
										
										$path = explode('_', tep_get_generated_service_category_path_ids($new_parent_id));
										// check if the directory to move is a child category
										if (in_array($cID, $path)) {
											 echo 'move_category_failure^'.$cID;
										} else {
										tep_db_query("update " . TABLE_SERVICES_CATEGORIES . " set parent_id = '" . (int) $new_parent_id . "', last_modified ='" . $server_date . "' where services_categories_id = '" . (int) $cID . "'");
										echo 'move_category_success^' . $new_parent_id;
									   }	
									}
						}else if ($action == 'get_details')									
							echo_get_details();
					else if ($action == 'setflag' && $HTTP_GET_VARS['flag'] != "" && $HTTP_GET_VARS['pID'] > 0)
							tep_set_service_status($HTTP_GET_VARS['pID'], $HTTP_GET_VARS['flag']);
					else  if ($action == 'update_product') {
						$span_days=($HTTP_POST_VARS['span_days']!="" && $HTTP_POST_VARS['booking_type']!='D')?$HTTP_POST_VARS['span_days']:'N';
						if ($HTTP_POST_VARS['action_type'] == 'new') echo $HTTP_POST_VARS['action_type'] . '_product^';												
						$include_resource = ($HTTP_POST_VARS['include_resource'])?$HTTP_POST_VARS['include_resource']:'N';
						$include_resource_arr = tep_db_prepare_input($HTTP_POST_VARS['include_resource_arr']);
						$resource_price=isset($HTTP_POST_VARS['resource_price'])?$HTTP_POST_VARS['resource_price']:'N';
						$selected_rid = $HTTP_POST_VARS['include_resource_arr'];
						if ($include_resource == 'N') {
							$quantity = tep_db_prepare_input($HTTP_POST_VARS['quantity']);
						} else if ($include_resource == 'Y')  $quantity = 0;												
						if ($resource_price == 'N') {
							$service_tax_class_id = tep_db_prepare_input($HTTP_POST_VARS['service_tax_class_id']);
							$service_costs = tep_db_prepare_input($HTTP_POST_VARS['service_costs_net']);
						}
						$no_booking_stime = tep_prepare_time("no_booking_stime");
						$no_booking_etime = tep_prepare_time("no_booking_etime");
						$loading_stime = tep_prepare_time("loading_stime");
						$loading_etime = tep_prepare_time("loading_etime");
						if (isset ($HTTP_GET_VARS['pID'])) $service_id = tep_db_prepare_input($HTTP_GET_VARS['pID']);
						$service_date_available = tep_prepare_date($HTTP_POST_VARS['service_date_available']);
						$booking_type = (isset ($HTTP_POST_VARS['booking_type']) ? $HTTP_POST_VARS['booking_type'] : 'H');
						$no_booking_start = $no_booking_end = "";
						$no_booking_time = tep_db_prepare_input($HTTP_POST_VARS['no_booking_time']);

						if ($no_booking_time != 'Y')
							$no_booking_time = 'N';
						$booking_buffer = 'N';

						if (defined("SERVICES_BUFFER_BOOKING") && (SERVICES_BUFFER_BOOKING == 'true' || SERVICES_BUFFER_BOOKING == 1)) {
							$no_booking_sdate = tep_prepare_date($HTTP_POST_VARS['no_booking_sdate']);
							$no_booking_edate = tep_prepare_date($HTTP_POST_VARS['no_booking_edate']);
							$recurring_type = $HTTP_POST_VARS['recurring_type'];
							if ($HTTP_POST_VARS['sel_book_buffer'] == 'Y')
								$booking_buffer = 'Y,' . $HTTP_POST_VARS['book_minute'];
						}
						$include_loadings = tep_db_prepare_input($HTTP_POST_VARS['include_loadings']);
						$include_loadings='Y';
						if ($include_loadings != 'Y')
							$include_loadings = 'N';
						if ($include_loadings == 'Y') {
							$loading_sdate = tep_prepare_date($HTTP_POST_VARS['loading_sdate']);
							$loading_edate = tep_prepare_date($HTTP_POST_VARS['loading_edate']);
							$loading_recurring_type = $HTTP_POST_VARS['loading_recurring_type'];
						}
						$multiple_purchase = $HTTP_POST_VARS['multiple_purchase'];
						if ($multiple_purchase != 'Y')
							$multiple_purchase = 'N';
						$provider_id = $rate = $base_rate = $backup_provider = 0;
						$provider = tep_db_prepare_input($HTTP_POST_VARS['provider']);
						$rate_type = 'GP';
						if ($service_costs == '')
							$service_costs = '0';
						if ($service_tax_class_id == '')
							$service_tax_class_id = '0';
						$booking_granular = (isset($HTTP_POST_VARS['booking_granular']) ? $HTTP_POST_VARS['booking_granular'] : 1);
						$sql_data_array = array (
							'service_date_available' => $service_date_available,
							'service_location' => tep_db_prepare_input($HTTP_POST_VARS['service_location']),
							'span_days' => $span_days, 'include_resource' => $include_resource, 'include_loadings' => $include_loadings, 'include_resource_price' => $resource_price, 'service_total_time' => tep_db_prepare_input($HTTP_POST_VARS['service_total_time']), 'max_bookings' => tep_db_prepare_input($HTTP_POST_VARS['max_bookings']), 
							'quantity' => $quantity, 'booking_granular' => $booking_granular, 'service_status' => tep_db_prepare_input($HTTP_POST_VARS['service_status']), 
							'conditions' => tep_db_prepare_input($HTTP_POST_VARS['service_conditions']), 'service_costs' => $service_costs, 'pending_period' => tep_db_prepare_input($HTTP_POST_VARS['pending_period']), 
							'service_renewal_start' => tep_db_prepare_input($HTTP_POST_VARS['service_renewal_start']), 'service_renewal_end' => tep_db_prepare_input($HTTP_POST_VARS['service_renewal_end']), 
							'multiple_purchase' => $multiple_purchase, 'no_booking_time' => $no_booking_time, 'service_tax_class_id' => $service_tax_class_id,
							 'booking_type' => $booking_type, 'booking_buffer' => $booking_buffer);

						if (!$HTTP_GET_VARS['pID']) {
							$insert_sql_data = array (
								'service_date_added' => $server_date
							);
							$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
							tep_db_perform(TABLE_SERVICES, $sql_data_array);
							$service_id = tep_db_insert_id();
						} else
							if ($HTTP_GET_VARS['pID']) {
								$update_sql_data = array (
									'service_last_modified' => $server_date
								);
								$sql_data_array = array_merge($sql_data_array, $update_sql_data);
								tep_db_perform(TABLE_SERVICES, $sql_data_array, 'update', "service_id = '" . (int) $service_id . "'");
								tep_db_query("delete from " . TABLE_SERVICES_NO_BOOKING_DAYS . " where service_id = '" . (int) $service_id . "'"); //print_r($sql_no_booking_array);
								tep_db_query("delete from " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " where service_id = '" . (int) $service_id . "'");
								tep_db_query("delete from " . TABLE_SERVICES_LOADINGS . " where service_id='" . $service_id . "'");
							}
						# create loop here to insert rows for multiple categories
						$differ_category_found = true;
						$selected_service_catids = $HTTP_POST_VARS['service_categories_ids'];
						if ($selected_service_catids) {
							foreach ($selected_service_catids as $current_service_category_id) {
								if ($cPath == $current_service_category_id)
									$differ_category_found = false;
								if ($cPath != $current_service_category_id)
									$differ_category = $current_service_category_id;
								tep_db_query("insert into " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " (service_id, services_categories_id) values ('" . $service_id . "', '" . $current_service_category_id . "')");
								$cPath = $current_service_category_id;
							}
						}
						# create loop here to insert rows for multiple resources					
						if ($selected_rid) {
							if ($service_id)
								tep_db_query("delete from " . TABLE_SERVICES_TO_SERVICES_RESOURCES . " where service_id = '" . (int) $service_id . "'");
							if ($include_resource == 'Y' && sizeof($selected_rid) > 0) {
								foreach ($selected_rid as $current_service_resource_id) {
									if ($current_service_resource_id != '')
										tep_db_query("insert into " . TABLE_SERVICES_TO_SERVICES_RESOURCES . " (service_id, service_resource_id) values ('" . $service_id . "', '" . $current_service_resource_id . "')");
									$cPath = $current_service_category_id;
								}
							}
						}
						$nb_dates_string=isset($HTTP_POST_VARS['nb_dates'])?$HTTP_POST_VARS['nb_dates']:'';
						$nb_dates_array=split('{}',$nb_dates_string);
						if(count($nb_dates_array)>0){
						  for($i=0;$i<sizeof($nb_dates_array);$i++){
							$block_recurring_array=split('#',$nb_dates_array[$i]);
							if(sizeof($block_recurring_array)>0){
								$no_booking_sdate = $block_recurring_array[0];
								$no_booking_edate = $block_recurring_array[1];
								$no_booking_stime = ($block_recurring_array[2]!="")?$block_recurring_array[2]:'00:00:00';
								$no_booking_etime = ($block_recurring_array[3]!="")?$block_recurring_array[3]:'00:00:00';
								$recurring_type = $block_recurring_array[4];
								$recurring_details = $block_recurring_array[5];
									if($no_booking_sdate!="") 												
									tep_db_query("insert into " . TABLE_SERVICES_NO_BOOKING_DAYS . " (service_id,no_booking_start_date,no_booking_end_date,no_booking_start_time,no_booking_end_time,recurring_type,recurring_details) values('" . $service_id . "','" . tep_convert_date_raw($no_booking_sdate) . "','" . tep_convert_date_raw($no_booking_edate) . "','" . $no_booking_stime . "','" . $no_booking_etime . "','" . $recurring_type . "','" . $recurring_details . "')");
							}
						  }
						}
						if ($include_loadings == 'Y') {
							$loading_dates = (isset ($HTTP_POST_VARS['loading_dates']) ? $HTTP_POST_VARS['loading_dates'] : '');
							if ($loading_dates != '')
								$loading_dates_array = split('/', $loading_dates);
							for ($bcnt = 0; $bcnt < count($loading_dates_array) - 1; $bcnt++) {
								$loading_recurring_array = split('#', $loading_dates_array[$bcnt]);
								if (sizeof($loading_recurring_array) > 0) {
									$loading_sdate = $loading_recurring_array[0];
									$loading_edate = $loading_recurring_array[1];
									$loading_stime = ($loading_recurring_array[2]!="")?$loading_recurring_array[2]:'00:00:00';
									$loading_etime = ($loading_recurring_array[3]!="")?$loading_recurring_array[3]:'00:00:00';
									$recurring_type = $loading_recurring_array[4];
									$recurring_details = $loading_recurring_array[5];
									$loading_price = $loading_recurring_array[6];
									$loading_type = $loading_recurring_array[7];
									tep_db_query("insert into " . TABLE_SERVICES_LOADINGS . " (service_id,loadings_start_date,loadings_end_date,loadings_start_time,loadings_end_time,recurring_type,recurring_details,loadings_price,loadings_type) values('" . $service_id . "','" . tep_convert_date_raw($loading_sdate) . "','" . tep_convert_date_raw($loading_edate) . "','" . $loading_stime . "','" . $loading_etime . "','" . $recurring_type . "','" . $recurring_details . "','" .
												  tep_db_input($loading_price) . "','" . tep_db_input($loading_type) . "')");
								}
							}
						}
						for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
							$language_id = $languages[$i]['id'];
							$sql_data_array = array (
								'service_name' => tep_db_prepare_input($HTTP_POST_VARS['service_name'][$language_id]
							), 'service_description' => tep_db_prepare_input($HTTP_POST_VARS['service_description'][$language_id]), 'service_url' => tep_db_prepare_input($HTTP_POST_VARS['service_url'][$language_id]));
							if (!$HTTP_GET_VARS['pID']) {
								$insert_sql_data = array (
									'service_id' => $service_id,
									'language_id' => $language_id
								);
								$sql_data_array = array_merge($sql_data_array, $insert_sql_data);
								tep_db_perform(TABLE_SERVICES_DESCRIPTION, $sql_data_array);
							}
							elseif ($HTTP_GET_VARS['pID']) tep_db_perform(TABLE_SERVICES_DESCRIPTION, $sql_data_array, 'update', "service_id = '" . (int) $service_id . "' and language_id = '" . (int) $language_id . "'");
						}
						if ($differ_category_found)
							echo 'diff_category^' . $differ_category . '#';
						echo_get_details();
					tep_reset_seo_cache('services');
			} else
				if ($action == 'delete_confirm') {
					$HTTP_POST_VARS['product_id'] = $HTTP_GET_VARS['pID'];
					tep_set_time_limit(100);
					if (isset ($HTTP_POST_VARS['services_categories']) && is_array($HTTP_POST_VARS['services_categories'])) {
						$product_id = tep_db_prepare_input($HTTP_POST_VARS['product_id']);
						$product_categories = $HTTP_POST_VARS['services_categories'];
						for ($i = 0, $n = sizeof($product_categories); $i < $n; $i++)
							tep_db_query("delete from " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " where service_id = '" . (int) $pID . "' and services_categories_id = '" . (int) $product_categories[$i] . "'");
						$product_categories_query = tep_db_query("select count(*) as total from " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " where service_id= '" . (int) $pID . "'");
						$product_categories = tep_db_fetch_array($product_categories_query);
						if ($product_categories['total'] == '0')
							tep_remove_service($pID);
						echo 'delete_success^' . $HTTP_GET_VARS['cID'];
					tep_reset_seo_cache('services');
					}
				} else
					if ($action == 'delete_product') {
						$err_delete = false;
						if ($suInfo->attribute_count > 0)
							$err_delete = true;
						$service_categories_string .= "<table border='0' cellspacing='2' cellpadding='2' width='100%'><tr><td width='17' align='center'>" . tep_image('images/template/delete_blue.gif') . '</td>';
						$service_categories_string .= '<td width="500" align="left" class="inner_title">' . TEXT_INFO_HEADING_DELETE_SERVICES . '</td></tr>';
						$service_categories_string .= '<tr><td></td><td width="500" align="left" class="main">' . TEXT_DELETE_SERVICES_INTRO . '</td></tr>';
						$service_categories_string .= '<tr><td></td><td width="500" align="left" class="main"><b>' . $suInfo->service_name . '</b></td></tr>';
						if ($suInfo->attribute_count > 0)
							$service_categories_string .= '<tr><td></td><td width="500" align="left" class="main"><b>' . sprintf(TEXT_DELETE_WARNING_SERVICES, $suInfo->attribute_count) . '</td></tr>';
						$service_categories_string .= '<tr><td></td><td width="500" valign="top" class="main"><b>';
						if ($err_delete == false) {
							$services_categories = tep_generate_service_category_path($suInfo->service_id, 'service');
							for ($i = 0, $n = sizeof($services_categories); $i < $n; $i++) {
								$service_category_path = '';
								for ($j = 0, $k = sizeof($services_categories[$i]); $j < $k; $j++) {
									$service_category_path .= $services_categories[$i][$j]['text'] . '&nbsp;&gt;&nbsp;';
								}
								$service_category_path = substr($service_category_path, 0, -16);
								$service_categories_string .= tep_draw_checkbox_field('services_categories[]', $services_categories[$i][sizeof($services_categories[$i]) - 1]['id'], true) . '&nbsp;' . $service_category_path . '<br>';
							}
							$service_categories_string = substr($service_categories_string, 0, -4);
						}
						$service_categories_string .= '</b></td></tr>';
						$service_categories_string .= '<tr><td colspan="2">' . tep_draw_separator('pixel_trans.gif', 50, 10) . '</td></tr></table>';
						echo $service_categories_string;
					} else
						if ($action == 'delete_confirm') {
							$HTTP_POST_VARS['product_id'] = $service_id;
							if (isset ($HTTP_POST_VARS['product_id']) && isset ($HTTP_POST_VARS['services_categories']) && is_array($HTTP_POST_VARS['services_categories'])) {
								$service_id = tep_db_prepare_input($HTTP_POST_VARS['product_id']);
								$services_categories = $HTTP_POST_VARS['services_categories'];
								for ($i = 0, $n = sizeof($services_categories); $i < $n; $i++) {
									tep_db_query("delete from " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " where service_id = '" . (int) $service_id . "' and services_categories_id = '" . (int) $services_categories[$i] . "'");
								}
								$services_categories_query = tep_db_query("SELECT count(*) as total from " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " where service_id = '" . (int) $service_id . "'");
								$services_categories = tep_db_fetch_array($services_categories_query);
								if ($services_categories['total'] == '0') {
									tep_remove_service($service_id);
								}
								echo 'delete_success^';
							tep_reset_seo_cache('services');
							}
						} else
							if ($action == 'copy_product') {
								$copy_to .= '<table  border="0" cellpadding="2" cellspacing="2" width="100%"><tr><td width="35" align="center">' . tep_image('images/template/copy_blue.gif') . '</td>';
								$copy_to .= '<td width="500" align="left" class="inner_title">' . TEXT_COPY_SERVICES . '</td><td></td></tr>';
								$copy_to .= '<tr><td></td><td width="500" align="left" class="main">' . TEXT_INFO_CURRENT_SERVICES_CATEGORIES . '&nbsp;&nbsp;' . '<b>' . tep_output_generated_service_category_path($suInfo->service_id, 'service') . '</b></td><td></td></tr>';
								$copy_to .= '<tr><td></td><td  width="500" colspan="2" align="left" class="main">' . TEXT_INFO_COPY_TO_INTRO . '<br>' . '</td><td></td></tr>';
								$copy_to .= '<tr><td></td><td  width="500" colspan="2" align="left" class="main">' . TEXT_INFO_HEADING_COPY_TO . '&nbsp;&nbsp;&nbsp;' . tep_draw_pull_down_menu('services_categories_id', tep_get_services_category_tree('','',0), $current_service_category_id) . '</td><td></td></tr>';
								$copy_to .= '<tr><td></td><td width="500" align="left" class="main" colspan="2">' . TEXT_HOW_TO_COPY . tep_draw_separator('pixel_trans.gif', 47, 10) . tep_draw_radio_field('copy_as', 'link', true, '', 'onclick="javascript:show_duplicate(\'link\');"') . ' ' . TEXT_COPY_AS_LINK . '<br>' . tep_draw_separator('pixel_trans.gif', '85', '10') . '&nbsp;&nbsp;' . tep_draw_radio_field('copy_as', 'duplicate', '', '', 'onclick="javascript:show_duplicate(\'dup\');"') . ' ' . TEXT_COPY_AS_DUPLICATE . tep_draw_separator('pixel_trans.gif', 60, 10). '&nbsp;<span class="main" style="display:none" id="dub_prd">' . TEXT_COPY_ATTRIBUTES . '&nbsp;' . tep_draw_radio_field('copy_attributes', 'copy_attributes_yes', true) . ' ' . TEXT_COPY_ATTRIBUTES_YES . '&nbsp;' . tep_draw_radio_field('copy_attributes', 'copy_attributes_no') . ' ' . TEXT_COPY_ATTRIBUTES_NO . '</span></td></tr>';
								$copy_to .= '<tr><td colspan="2">' . tep_draw_separator('pixel_trans.gif', 50, 10) . '</td></tr></table>';
								echo $copy_to;
					} else
						if ($action == 'copy_confirm') {
							$error = "";
							if (isset ($HTTP_POST_VARS['services_categories_id'])) {
								$service_id = tep_db_prepare_input($HTTP_POST_VARS['product_id']);
								$services_categories_id = tep_db_prepare_input($HTTP_POST_VARS['services_categories_id']);
								// copying is as a link
								if ($HTTP_POST_VARS['copy_as'] == 'link') {
									if ($services_categories_id != $current_service_category_id) {
										$check_query = tep_db_query("SELECT count(*) as total from " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " where service_id = '" . (int) $service_id . "' and services_categories_id = '" . (int) $services_categories_id . "'");
										$check = tep_db_fetch_array($check_query);
										// check if service already does not exist
										if ($check['total'] < '1') {
											tep_db_query("insert into " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " (service_id, services_categories_id) values ('" . (int) $service_id . "', '" . (int) $services_categories_id . "')");
										}
									} else {
										$error = ERROR_CANNOT_LINK_TO_SAME_SERVICES_CATEGORY;
									}
								}
								elseif ($HTTP_POST_VARS['copy_as'] == 'duplicate') {
									// copying it is as a new one 
									$service_query = tep_db_query("SELECT su.service_image, su.service_date_added,su.service_location, su.service_last_modified, date_format(su.service_date_available, '%Y-%m-%d') " .
									"as service_date_available, su.span_days,su.include_resource,su.include_loadings,su.service_status,su.no_booking_time,su.max_bookings,su.quantity,su.service_total_time,su.booking_granular," .
									" su.pending_period, " .
									"su.service_renewal_start,su.service_renewal_end,su.conditions ,su.multiple_purchase," .
									"su.service_tax_class_id, su.service_costs,su.include_resource_price,su.booking_type  " .
									" from " . TABLE_SERVICES . " su where su.service_id = '" . (int) $service_id . "' ");
									$service = tep_db_fetch_array($service_query);
									$service["service_date_added"] = $server_date;
									tep_db_perform(TABLE_SERVICES, $service);
									$dup_service_id = tep_db_insert_id();
									
									//Attribute copy
									$attribute_query = tep_db_query("SELECT * from " . TABLE_SERVICES_ATTRIBUTES . " where service_id = '" . (int) $service_id . "'");
									while ($attribute = tep_db_fetch_array($attribute_query)) {
										tep_db_query("insert into " . TABLE_SERVICES_ATTRIBUTES . " (service_id, options_id, options_values_id, options_values_price, price_prefix, services_options_sort_order, services_attributes_one_time, services_attributes_weight, services_attributes_weight_prefix, services_attributes_units, services_attributes_units_price) values ('" .
										(int) $dup_service_id . "', '" . (int)$attribute['options_id'] . "', '" . (int)($attribute['options_values_id']) . "', '" . (float)($attribute['options_values_price']) . "', '" .
										tep_db_input($attribute['price_prefix']) . "', '" . (int)($attribute['services_options_sort_order']) . "', '" . (int)($attribute['services_attributes_one_time']) . "', '" . (float)($attribute['services_attributes_weight']) . "', '" . tep_db_input($attribute['services_attributes_weight_prefix']) . "', '" . (int)($attribute['services_attributes_units']) . "', '" . (float)($attribute['services_attributes_units_price']) . "')");
									}

									//Description copy
									$description_query = tep_db_query("SELECT language_id, service_name, service_description,service_url from " . TABLE_SERVICES_DESCRIPTION . " where service_id = '" . (int) $service_id . "'");
									while ($description = tep_db_fetch_array($description_query)) {
										tep_db_query("insert into " . TABLE_SERVICES_DESCRIPTION . " (service_id, language_id, service_name, service_description, service_url, service_viewed) values ('" .
										(int) $dup_service_id . "', '" . (int) $description['language_id'] . "', '" . tep_db_input($description['service_name']) . "', '" . tep_db_input($description['service_description']) . "', '" .
										tep_db_input($description['service_url']) . "', '0')");
									}
									tep_db_query("insert into " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " (service_id, services_categories_id) values ('" . (int) $dup_service_id . "', '" . (int) $services_categories_id . "')");
									
									//Resource copy
									$service_resource_query = tep_db_query("select service_resource_id from " . TABLE_SERVICES_TO_SERVICES_RESOURCES . " where service_id=" . (int) $service_id);
									while ($service_resource = tep_db_fetch_array($service_resource_query)) {
										tep_db_query("insert into " . TABLE_SERVICES_TO_SERVICES_RESOURCES . "(service_id,service_resource_id) values( '" .
										(int) $dup_service_id . "' ,'" . tep_db_input($service_resource["service_resource_id"])  . "')");

									}

									//Booking copy
									$booking_query = tep_db_query("select no_booking_start_date, no_booking_end_date, no_booking_start_time, no_booking_end_time,recurring_type, recurring_details from " . TABLE_SERVICES_NO_BOOKING_DAYS . " where service_id=" . (int) $service_id);
									while ($booking = tep_db_fetch_array($booking_query)) {
										tep_db_query("insert into " . TABLE_SERVICES_NO_BOOKING_DAYS . "(service_id,no_booking_start_date,no_booking_end_date,no_booking_start_time,no_booking_end_time,recurring_type, recurring_details) values( '" .
										(int) $dup_service_id . "' ,'" . tep_db_input($booking["no_booking_start_date"]) . "' , '" . tep_db_input($booking["no_booking_end_date"]) . "' , '" . tep_db_input($booking["no_booking_start_time"]) . "', '" . tep_db_input($booking["no_booking_end_time"]) . "', '" . tep_db_input($booking["recurring_type"]) . "', '" . tep_db_input($booking["recurring_details"]) . "')");

									}

									//Loadings copy
									$loadings_query = tep_db_query("select loadings_start_date, loadings_end_date, loadings_start_time, loadings_end_time,recurring_type, recurring_details,loadings_price,loadings_type from " . TABLE_SERVICES_LOADINGS . " where service_id=" . (int) $service_id);
									while ($loadings = tep_db_fetch_array($loadings_query)) {
										tep_db_query("insert into " . TABLE_SERVICES_LOADINGS . "(service_id,loadings_start_date,loadings_end_date,loadings_start_time,loadings_end_time,recurring_type, recurring_details,loadings_price,loadings_type) values( '" .
										(int) $dup_service_id . "' ,'" . tep_db_input($loadings["loadings_start_date"]) . "' , '" . tep_db_input($loadings["loadings_end_date"]) . "' , '" . tep_db_input($loadings["loadings_start_time"]) . "', '" . tep_db_input($loadings["loadings_end_time"]) . "', '" . tep_db_input($loadings["recurring_type"]) . "', '" . tep_db_input($loadings["recurring_details"]) . "','" .
										tep_db_input($loadings['loadings_price']) . "','" . tep_db_input($loadings['loadings_type']) . "')");
									}

									// copy service messages
									if (isset ($HTTP_POST_VARS["copy_service"])) {
										$message_query = tep_db_query("SELECT message_send,message_subject,message_text,message_format,service_id,message_type,message_reply_to from " .
										TABLE_SERVICES_MESSAGES . " su where service_id='" . (int) $service_id . "'");
										while ($message_result = tep_db_fetch_array($message_query)) {
											$message_result["service_id"] = $dup_service_id;
											tep_db_perform(TABLE_SERVICES_MESSAGES, $message_result);
										}

									}
								}
							}
							if ($error != "")
								echo "copy_error^" . $error;
							else
								echo "copy_success^" . $services_categories_id;
						} else																	
							if ($action == 'move_product') {
								$move_to .= '<table  border="0" cellpadding="2" cellspacing="2" width="100%"><tr><td width="35" align="center">' . tep_image('images/template/move_blue.gif') . '</td>';
								$move_to .= '<td width="500" align="left" class="inner_title">' . TEXT_INFO_HEADING_MOVE_SERVICES . '</td><td></td></tr>';
								$move_to .= '<tr><td></td><td colspan="2" align="left" class="main">' . TEXT_INFO_CURRENT_SERVICES_CATEGORIES . '<b>' . tep_output_generated_service_category_path($suInfo->service_id, 'service') . '</td><td></td></tr>';
								$move_to .= '<tr><td></td><td width="500" align="left" class="main">' . sprintf(TEXT_MOVE_SERVICES_INTRO, $suInfo->service_name) . '</b></td><td></td></tr>';
								$move_to .= '<tr><td></td><td width="500" align="left" class="main">' . sprintf(TEXT_MOVE, $sucInfo->service_name) . '&nbsp;&nbsp;' . tep_draw_pull_down_menu('move_to_service_category_id', tep_get_services_category_tree('','',0), $current_service_category_id) . '</td></tr>';
								$move_to .= '<tr><td colspan="2">' . tep_draw_separator('pixel_trans.gif', 50, 10) . '</td></tr></table>';
								echo $move_to;
							} else
							if ($action == 'move_confirm') {
								$service_id = tep_db_prepare_input($HTTP_POST_VARS['product_id']);
								$new_parent_id = tep_db_prepare_input($HTTP_POST_VARS['move_to_service_category_id']);
								$current_service_category_id = $HTTP_POST_VARS['cPath'];
								if ($new_parent_id != 0) {
									// check if the moved service already exists in the category
									$duplicate_check_query = tep_db_query("SELECT count(*) as total from " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " where service_id = '" . (int) $service_id . "' and services_categories_id = '" . (int) $new_parent_id . "'");
									$duplicate_check = tep_db_fetch_array($duplicate_check_query);
									if ($duplicate_check['total'] < 1)
										tep_db_query("update " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " set services_categories_id = '" . (int) $new_parent_id . "' where service_id = '" . (int) $service_id . "' and services_categories_id = '" . (int) $current_service_category_id . "'");
								}
								echo 'move_success^' . $new_parent_id;
							}									
							else if ($action == 'edit_product'){
									$service_query = tep_db_query("SELECT su.service_id,su.service_image, su.service_date_added,su.service_location, su.service_last_modified, date_format(su.service_date_available, '%Y-%m-%d') " .
									"as service_date_available, su.span_days,su.include_resource,su.include_loadings,su.service_status,su.no_booking_time,su.max_bookings,su.quantity,su.service_total_time,su.booking_granular," .
									" su.pending_period, " .
									"su.service_renewal_start,su.service_renewal_end,su.conditions as service_conditions ,su.multiple_purchase," .
									"su.service_tax_class_id, su.service_costs,su.include_resource_price,su.booking_type,su.booking_buffer  " .
									" from " . TABLE_SERVICES . " su where su.service_id = '" . (int) $service_id . "' ");
									if (tep_db_num_rows($service_query) > 0) {
										$service = tep_db_fetch_array($service_query);
										$suInfo = new objectInfo($service);
									}

									#fetch tax descriptions start
									$tax_class_array = array (
										array (
											'id' => '0',
											'text' => TEXT_NONE
										)
									);
									$tax_class_query = tep_db_query("SELECT tax_class_id, tax_class_title from " . TABLE_TAX_CLASS . " order by tax_class_title");
									while ($tax_class = tep_db_fetch_array($tax_class_query)) {
										$tax_class_array[] = array (
											'id' => $tax_class['tax_class_id'],
											'text' => $tax_class['tax_class_title']
										);
									}
									#fetch tax descriptions end

									#fetch no booking days start

									//	$noaction=='edit_product' && $HTTP_GET_VARS['pID']EXT_NONE));
									$no_booking_array = array ();
									$book_text="";
									$no_booking_query = tep_db_query("select service_no_booking_id, no_booking_start_date, no_booking_end_date, recurring_type, recurring_details, time_format(no_booking_start_time,'%l:%i%p') as no_booking_stime, no_booking_start_time ,time_format(no_booking_end_time,'%l:%i%p') as no_booking_etime, no_booking_end_time from " . TABLE_SERVICES_NO_BOOKING_DAYS . "  where service_id= '" . (int) $service_id . "' order by no_booking_start_date");
									while ($no_booking_day = tep_db_fetch_array($no_booking_query)) {
										$no_booking_sdate = $no_booking_day['no_booking_start_date'];
										$no_booking_edate = $no_booking_day['no_booking_end_date'];
										if ($suInfo->booking_type == 'H' || $suInfo->booking_type == 'M'){
											$no_booking_stime = $no_booking_day['no_booking_start_time'];
											$no_booking_etime = $no_booking_day['no_booking_end_time'];
											$booking_stime = $no_booking_day['no_booking_stime'];
											$booking_etime = $no_booking_day['no_booking_etime'];
										}
										$recurring_type = $no_booking_day['recurring_type'];
										$recurring_details = $no_booking_day['recurring_details'];
										$no_booking_array[] = form_recurring_array($no_booking_sdate, $no_booking_edate, $no_booking_stime, $no_booking_etime, $booking_stime, $booking_etime, $recurring_type, $recurring_details);
										$book_text.=$no_booking_day['service_no_booking_id'] . "{}" .  (format_date($no_booking_sdate)."{}".format_date($no_booking_edate)."{}".$no_booking_stime."{}".$no_booking_etime."{}".$booking_stime."{}".$booking_etime."{}".$recurring_type."{}".$recurring_details) . '**';
										$edit_nbdates_string.=format_date($no_booking_sdate).'#'.format_date($no_booking_edate).'#'.$no_booking_stime.'#'.$no_booking_etime.'#'.$recurring_type.'#'.$recurring_details.'{}';
										$nobooking_array[] = array('id'=>$no_booking_day['service_no_booking_id']);
									}
									if($edit_nbdates_string!="") $edit_nbdates_string=substr($edit_nbdates_string,0,-2);																				
									if($book_text!="") $book_text=substr($book_text,0,-2);
									echo $book_text . '^';
									$loading_array = array (); //echo "select loadings_start_date, loadings_end_date, recurring_type, recurring_details, time_format(loadings_start_time,'%l:%i%p') as loadings_stime, loadings_start_time ,time_format(loadings_end_time,'%l:%i%p') as loadings_etime, loadings_end_time,loadings_price,loadings_type from " . TABLE_SERVICES_LOADINGS. "  where service_id= '" .(int)$HTTP_GET_VARS['seID']."' order by loadings_start_date";
									$loading_query = tep_db_query("select loadings_start_date, loadings_end_date, recurring_type, recurring_details, time_format(loadings_start_time,'%l:%i%p') as loadings_stime, loadings_start_time ,time_format(loadings_end_time,'%l:%i%p') as loadings_etime, loadings_end_time,loadings_price,loadings_type from " . TABLE_SERVICES_LOADINGS . "  where service_id= '" . (int) $HTTP_GET_VARS['pID'] . "' order by loadings_start_date");
									while ($loading_day = tep_db_fetch_array($loading_query)) {
										$loading_sdate = $loading_day['loadings_start_date'];
										$loading_edate = $loading_day['loadings_end_date'];
										$loading_stime = $loading_day['loadings_start_time'];
										$loading_etime = $loading_day['loadings_end_time'];
										$stime = $loading_day['loadings_stime'];
										$etime = $loading_day['loadings_etime'];
										$recurring_type = $loading_day['recurring_type'];
										$recurring_details = $loading_day['recurring_details'];
										$loading_price = (($loading_day['loadings_type']=='C')?'$':'').round($loading_day['loadings_price'],2);
										$loading_type = $loading_day['loadings_type'];
										$loading_array[] = form_load_recurring_array($loading_sdate, $loading_edate, $loading_stime, $loading_etime, $stime, $etime, $recurring_type, $recurring_details, $loading_price, $loading_type);
									}
									//	echo date('F',strtotime(10));	
									# fetch location names start
									$location_query = tep_db_query("SELECT * from " . TABLE_SERVICES_LOCATIONS . ' order by service_location_name');
									$location_array = array ();
									while ($location_result = tep_db_fetch_array($location_query)) {
										$location_array[] = array (
											'id' => $location_result['service_location_id'],
											'text' => $location_result['service_location_name'],
											'seats' => $location_result["service_location_seats"]
										);
									}
									$loading_type_array = array (
										array (
											'id' => 'C',
											'text' => 'Currency'
										),
										array (
											'id' => 'P',
											'text' => 'Percentage'
										)
									);

									#fetch selected categories start
									$services_categories_query_selected = tep_db_query("SELECT services_categories_id from " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " where service_id = '" . (int) $HTTP_GET_VARS['pID'] . "'");
									$first_category = tep_db_query("select services_categories_id from " . TABLE_SERVICES_CATEGORIES);
									$first_cate = tep_db_fetch_array($first_category);
									$sel_cat = $cID;
									if (!$sel_cat && $check_ID)
										$sel_cat = $check_ID;
									$services_categories_array_selected = array (
										array (
											'id' => $sel_cat
										)
									);
									if ($action == 'edit_product' && $HTTP_GET_VARS['pID']) {
										while ($services_categories = tep_db_fetch_array($services_categories_query_selected))
											$services_categories_array_selected[] = array (
												'id' => $services_categories['services_categories_id']
											);
									}
									#fetch selected resource start			
									$services_resources_query_selected = tep_db_query("SELECT service_resource_id from " . TABLE_SERVICES_TO_SERVICES_RESOURCES . " where service_id = '" . (int) $HTTP_GET_VARS['pID'] . "'");
									$services_resources_array_selected = array (
										array (
											'id' => ''
										)
									);
									while ($services_resources = tep_db_fetch_array($services_resources_query_selected)) {
										$services_resources_array_selected[] = array (
											'id' => $services_resources['service_resource_id']
										);
									}
									#fetch selected categories end

									$services_categories_array = array (
										array (
											'id' => '',
											'text' => TEXT_NONE
										)
									);
									$language_id = 1;
									$services_categories_array = tep_get_services_category_tree();
									$booking_type = array (
										array (
											'id' => 'M',
											'text' => TEXT_MINS
										),
										array (
											'id' => 'H',
											'text' => TEXT_HOURS
										),																					
										array (
											'id' => 'D',
											'text' => TEXT_DAYS
										)
									);
									$status_array = array (
										array (
											'id' => 1,
											'text' => TEXT_HIDE_NONE
										),
										array (
											'id' => 0,
											'text' => TEXT_HIDE_ALWAYS
										)
									);

									if (!isset ($suInfo->service_status))
										$suInfo->service_status = '1';

									$rate_type_array = array (
										array (
											'id' => 'GP',
											'text' => TEXT_RATE_TYPE_GP
										),
										array (
											'id' => 'MU',
											'text' => TEXT_RATE_TYPE_MU
										),
										array (
											'id' => 'FL',
											'text' => TEXT_RATE_TYPE_FL
										)
									);

									if ($no_booking_sdate == "" || $no_booking_sdate == "0000-00-00")
										$no_booking_sdate = $current_date;
									if ($no_booking_edate == "" || $no_booking_edate == "0000-00-00")
										$no_booking_edate = $current_date;
																				//echo 'edit^';						
?>
			<table border="0" width="100%" cellspacing="0" cellpadding="2">
				<tr>
					<td>
					<table border="0" width="100%" cellspacing="0" cellpadding="0">
						
						<?php
							if( ($action == 'edit_product') && (($HTTP_GET_VARS['cID'])!="") && (($HTTP_GET_VARS['pID'])=="") ) {
						?><tr>
							<td class="pageHeading"><?php 
							echo sprintf(TEXT_NEW_SERVICES, tep_output_generated_service_category_path($HTTP_GET_VARS['cID'])); 
						 ?></td>
							<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); } ?></td>
						</tr>
						
<!--						<tr>
							<td class="pageHeading"><?php 
							//echo $HTTP_GET_VARS['cID'];
							//if($action=='edit_product') { echo 'hello'; }
						//	echo $action;
							//if ($action == 'edit_product' && $HTTP_GET_VARS['cID']) {  echo 'hi';}
							if( ($action == 'edit_product') && (($HTTP_GET_VARS['cID'])!="") && (($HTTP_GET_VARS['pID'])=="") )
							echo sprintf(TEXT_NEW_SERVICES, tep_output_generated_service_category_path($HTTP_GET_VARS['cID'])); 
							?></td>
							<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></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">
							<tr>
								<td class="main" width="150" valign="top"><?php echo TEXT_SERVICES_CATEGORIES; ?></td>
								<td><?php
									$categories_query_selected = tep_db_query("select services_categories_id from " . TABLE_SERVICES_TO_SERVICES_CATEGORIES . " where service_id = '" . $HTTP_GET_VARS['pID'] . "'");
									$categories_selected=array();
									while ($categories = tep_db_fetch_array($categories_query_selected)) 
									$category_selected[]=array('id'=>$categories['services_categories_id']);
									$cat_query = tep_db_query("select cd.services_categories_name,cd.services_categories_id from " . TABLE_SERVICES_CATEGORIES . " c," . TABLE_SERVICES_CATEGORIES_DESCRIPTION . " cd where c.services_categories_id=cd.services_categories_id and cd.language_id='" . $language_id  ."'" );
									$categories_array=array();
									while($cat_array=tep_db_fetch_array($cat_query))
											$categories_array[]=array('id'=>$cat_array['services_categories_id'],'text'=>$cat_array['services_categories_name']);
									echo tep_draw_mselect_checkbox('service_categories_ids[]',$categories_array,$category_selected);
									?>
								</td>
								<td class="main" width="200"><?php //echo tep_draw_mselect_menu('service_categories_ids[]', $services_categories_array, $services_categories_array_selected, 'size=10 id=service_categories_ids style="width:400"'); ?></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">
						<tr>
							<td class="main" width="150" valign="top"><?php echo TEXT_SERVICES_STATUS; ?></td>
							<td class="main" width="200" valign="top"><?php echo tep_draw_pull_down_menu('service_status', $status_array, $suInfo->service_status); ?></td>
							<?php $_array=array('d','m','Y');  $replace_array=array('DD','MM','YYYY'); 	$date_format=str_replace($_array,$replace_array,EVENTS_DATE_FORMAT);?>
							<td class="main" width="150" valign="top"><?php echo TEXT_SERVICES_DATE_AVAILABLE; ?><br><small>(<?php echo $date_format;?>)</small></td>
							<td class="main" width="200" valign="top">
							<?php
								echo tep_draw_date_field("service_date_available", (tep_not_null($suInfo->service_date_available) ? format_date($suInfo->service_date_available) : format_date($current_date)), 'size=10');
							?>
						</tr>
					</table>
					</td>
				</tr>
				
				<?php tep_content_title_top("General"); ?>
				<tr>
					<td>
					<table border="0" cellpadding="4" cellspacing="0" >
						<tr>
							<td >
							<table border="0" cellpadding="0" cellspacing="0">
							<?php for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {?>
								<tr>
									<td class="main" valign="top" width="100"><?php  echo 'Service Name:'; ?></td>
									<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('service_name[' . $languages[$i]['id'] . ']', (isset($service_name[$languages[$i]['id']]) ? $service_name[$languages[$i]['id']] : tep_get_service_name($suInfo->service_id, $languages[$i]['id'])),'id=service_name_value[] maxlength=64 size=40'); ?></td>
								</tr>
							<?php }?>
							</table>
							</td>
						</tr>
						<tr>
							<td>
							<table border="0" cellpadding="0" cellspacing="0">
								<?php
								for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {?>
									<tr>
										<td class="main" valign="top" width="100"><?php if ($i == 0) echo TEXT_SERVICES_DESCRIPTION; ?></td>
										<td>
										<table border="0" cellspacing="0" cellpadding="0">
											<tr>
												<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>&nbsp;</td>
												<td class="main"><?php echo tep_draw_textarea_field('service_description[' . $languages[$i]['id'] . ']', 'soft', '80', '24', (isset($service_description[$languages[$i]['id']]) ? $service_description[$languages[$i]['id']] : tep_get_service_description($suInfo->service_id, $languages[$i]['id'])), 'id="service_description[' . $languages[$i]['id'] . ']"'); ?></td>
											</tr>
										</table>
										</td>
								</tr>
						<?php }?>
						</table>
						</td>
					</tr>
					<tr>
						<td colspan="2">
						<table cellpadding="0" cellspacing="0">
							<?php for ($i = 0, $n = sizeof($languages); $i < $n; $i++) { ?>
								<tr>
									<td class="main" width="150"><?php if ($i == 0) echo TEXT_SERVICES_URL . '<br><small>' . TEXT_SERVICES_URL_WITHOUT_HTTP . '</small>'; ?></td>
									<td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('service_url[' . $languages[$i]['id'] . ']', (isset($service_url[$languages[$i]['id']]) ? $service_url[$languages[$i]['id']] : tep_get_service_url($suInfo->service_id, $languages[$i]['id'])),' maxlength=255 '); ?></td>
									<td class="main" valign="middle"><?php echo '&nbsp;&nbsp;'.TEXT_SERVICES_IMAGE .'&nbsp;&nbsp;&nbsp;'. tep_draw_file_field('service_image_'.$languages[$i]['id']) .  tep_get_service_image($suInfo->service_id,$languages[$i]['id']) . tep_draw_hidden_field('service_previous_image['.$languages[$i]['id'].']', tep_get_service_image($suInfo->service_id,$languages[$i]['id'])); ?></td>
								</tr>
							<?php } ?>
							</table>
							</td>
					</tr>
					<tr>
						<td>
						<table border=0 cellpadding="0" cellspacing="0">
							<tr>
								<td class="main" width="150"><?php echo TEXT_SERVICES_LOCATION; ?></td>
								<td class="main" width="200"><?php echo tep_draw_pull_down_menu('service_location', $location_array,$suInfo->service_location); ?></td>
							</tr>
						</table>
						</td>
					</tr>
				</table>
				</td>
			</tr>
			<?php tep_content_title_bottom(); ?>
			
			<?php tep_content_title_top("Bookings"); ?>
			<tr>
				<td>
				<table border=0 cellpadding="4" cellspacing="0" width="100%">
					<tr>
						<td>
						<table cellpadding="2" cellspacing="0" border="0">
							<tr>
								<td class="main" width="180"><?php echo TEXT_BOOKING_TYPE;?></td>
								<td class="main"><?php echo tep_draw_pull_down_menu('booking_type',$booking_type,$suInfo->booking_type,'onchange="javascript:do_check_control(1);"');?></td>
								<td><?php echo tep_draw_separator('pixel_trans.gif', '80', '3'); ?></td> 
								<td class="main" width="160"><?php  echo  tep_draw_checkbox_field('span_days','Y',($suInfo->span_days=='Y'?true:false),'',($suInfo->booking_type=='D'?'disabled':'')).  TEXT_SPAN_DAYS;?></td>
									<?php
										$splt_book_buffer = split(",", $suInfo->booking_buffer);
										$bk_buffer = 'N';
										$bk_buffer_minute = 0;
										if ($splt_book_buffer[1]) {
											$bk_buffer = $splt_book_buffer[0];
											$bk_buffer_minute = $splt_book_buffer[1];
										}
										$minute_array=array();
										for($icnt=0;$icnt<=59;$icnt=$icnt+5){
										  $temp=sprintf("%02s",$icnt);
										  $minute_array[]=array('id'=>$temp,'text'=>$temp);
										}
									 ?>
							</tr>
						</table>
						</td>
					</tr>
					<tr>
						<td>
						<table cellpadding="2" cellspacing="0" border="0">
							<tr>
								<td class="main" width="180">
									<?php 
										echo TEXT_SERVICES_BOOKING_GRANULAR; 
										$type_string=TEXT_MINS;
										if($suInfo->booking_type=='D') $type_string=TEXT_DAYS;
										else  if($suInfo->booking_type=='H') $type_string=TEXT_HOURS;
										else  if($suInfo->booking_type=='M') $type_string=TEXT_MINS;
									?>
								</td>
								<td width="143" class="main"><?php echo tep_draw_input_field('booking_granular',(tep_not_null($suInfo->booking_granular) ? $suInfo->booking_granular:'1'),'onKeyPress="return keyRestrict(event)" size=2 maxlength=3').'&nbsp;<span id="spHours1">' .$type_string . '</span>';?></td>
								<?php if (defined("SERVICES_BUFFER_BOOKING") && (SERVICES_BUFFER_BOOKING == 'true' || SERVICES_BUFFER_BOOKING == 1)) { ?><td class="main" style="height:30px" nowrap=true align="left" id="box_buffer"><?php echo tep_draw_checkbox_field('sel_book_buffer','Y',(($bk_buffer=='Y')?true:false),'',' valign="top" onclick="javascript:do_booking_buffer(this.checked);"').TEXT_BOOKING_BUFFER.' ' .tep_draw_pull_down_menu("book_minute",$minute_array,$bk_buffer_minute,(($bk_buffer=='N')?'style="display:none"':'')) ;?></td><?php } ?>								
							</tr>								 
						  </table>
						 </td>
						</tr>							
					  </table>
					 </td>
					</tr>
					<tr>					  
					  <Td>
					    <table cellpadding="2" cellspacing="2" border="0">
							<tr>
								<td class="main" width="180"><?php echo '&nbsp;'.TEXT_SERVICES_TOTAL_TIME; ?></td>
								<td class="main" width="140"><?php echo tep_draw_input_field('service_total_time',(tep_not_null($suInfo->service_total_time) ? $suInfo->service_total_time:'1'),'onKeyPress="return keyRestrict(event)" size=2 maxlength=6').'&nbsp;<span id="spHours2">' .$type_string . '</span>';?></td>
								<td>
								<table cellpadding="2" cellspacing="2" border="0">
									<tr>
										<td class="main" width="180"><?php echo '&nbsp;'.TEXT_EVENTS_MAX_BOOKINGS; ?></td>
										<td class="main" width="140"><?php echo tep_draw_input_field('max_bookings',(tep_not_null($suInfo->max_bookings) ? $suInfo->max_bookings:'1'),' onKeyPress="return keyRestrict(event)" size=2 maxlength=6') . '&nbsp;<span id="spHours3">' . $type_string . '</span>';	?></td>
										
									</tr>
							    </table>
					   		    </td>																					
							</tr>
						</table>
					 </td>
					</tr> 		
					<tr> 
					   <Td>
					    <table cellpadding="0" cellspacing="2" border="0">
					    <tr>
						<td class="main" width="180"><?PHP echo tep_draw_radio_field('include_resource','Y',($suInfo->include_resource=='Y'?true:false),'','onClick="do_check_control(7)"').TEXT_INCLUDE_RESOURCE; ?></td>
						<td>
						  <table cellpadding="0" cellspacing="0" border="0">								  							
							<tr>
								<td class="main" width="160"><?php echo tep_draw_radio_field('sel_service_avilable','',(($suInfo->include_resource=='Y')?false:true),'','onclick="javascript:do_check_control(9);"').TEXT_QUANTITY; ?></td>
								<td class="main"><?php echo tep_draw_input_field('quantity',(tep_not_null($suInfo->quantity) ? $suInfo->quantity:'1'),' onKeyPress="return keyRestrict(event)" size=3 maxlength=6 '.(($suInfo->include_resource=='Y')?'style="display:none;"':'') . (($suInfo->include_resource=='Y')?'disabled':'enabled'));?></td>
								<td class="main" id="m_purchase" <?php echo (($suInfo->include_resource=='Y')?'style="display:none;"':''); ?>><?php echo '&nbsp;&nbsp;'.tep_draw_checkbox_field('multiple_purchase','Y',($suInfo->multiple_purchase=='Y'?true:false),'',($suInfo->include_resource=='Y')?'disabled':'enabled') . TEXT_MULTIPLE_PURCHASES;?></td>
							</tr>
				    	 </table>
					    </td>
					   </tr></table></td> 		
					</tr>		
					<tr>						
					</tr>															
					<Tr>
					 <Td><?php
						$services_resources_array = array (array ('id' => '','text' => TEXT_NONE)); ?>
						<table cellpadding="0" cellspacing="0" border="0" id="display_resource"  style="<?PHP echo (($suInfo->include_resource=='Y')?"display:''":"display:none");  ?>">
							<tr><?PHP $services_resources_array=tep_get_resource_tree(); ?>
							<td><?php
								$resource_query_selected = tep_db_query("select service_resource_id from " . TABLE_SERVICES_TO_SERVICES_RESOURCES . " where service_id = '" . $HTTP_GET_VARS['pID'] . "'");
								$resource_selected=array();
								while ($resource = tep_db_fetch_array($resource_query_selected))
									 $resource_selected[]=array('id'=>$resource['service_resource_id']);
								$res_cat_query = tep_db_query("select cd.resource_name,cd.resource_id from " . TABLE_RESOURCES . " c," . TABLE_RESOURCES_DESCRIPTION . " cd where c.resource_id=cd.resource_id and cd.language_id='" . $language_id  ."'" );
								$res_cat_array=array();
								while($res_array=tep_db_fetch_array($res_cat_query))
									$res_cat_array[]=array('id'=>$res_array['resource_id'],'text'=>$res_array['resource_name']);
								?></td>
						<?php echo tep_draw_mselect_checkbox('include_resource_arr[]',$res_cat_array,$resource_selected); ?>							 
								</tr>
							</table>
						</Td>						
			    	</Tr> 
			<!--	</table>
				</td>														
			</tr>   -->
			<?php tep_content_title_bottom(); ?>
			<?php tep_content_title_top("Fees"); ?>
			
			<tr>
				<td>
				<table border="0" cellpadding="4" cellspacing="0"  width="70%">
					<tr>
						<td valign="top" colspan="4">
							<table border="0" cellpadding="0" cellspacing="0">
							<tr>
								<td class="main"><?php echo tep_draw_checkbox_field('resource_price','Y',($suInfo->include_resource_price=='Y'?true:false),'',($suInfo->include_resource=='Y'?'enabled':'disabled') . ' onClick="do_check_control(6)"').TEXT_SERVICES_RESOURCE_PRICE; ?></td>
								<td class="main"><?php  ?></td>
							</tr>
							</table>
						</td>		
					</tr>
					<tr>
						<td class="main" width="80" nowrap="nowrap"><?php echo TEXT_SERVICES_TAX_CLASS; ?></td>
						<td class="main"><?php echo tep_draw_pull_down_menu('service_tax_class_id', $tax_class_array, $suInfo->service_tax_class_id, ($suInfo->include_resource_price=='Y'?'disabled':'enabled') .' onchange="updateGross()"'); ?></td>
					<!--</tr>
					<tr>-->
						<td class="main" width="80" nowrap="nowrap"><?php echo TEXT_SERVICES_FEES_NET_INFO; ?></td>
						<td class="main"><?php
						$price = $suInfo->service_costs;
						if (strpos($price, ".") && substr($price, strpos($price, ".")) <= 0)
							$price = (int) $price;
						echo tep_draw_input_field('service_costs_net', $price, ($suInfo->include_resource_price=='Y'?'disabled':'enabled') .' onKeyUp="updateGross()" maxlength="9"');
					?></td>
					<!--</tr>
					<tr>-->
						<td class="main" width="90" nowrap="nowrap"><?php echo TEXT_SERVICES_FEES_GROSS_INFO; ?></td>
						<td class="main"><?php echo tep_draw_input_field('service_costs_gross', $suInfo->service_costs, ($suInfo->include_resource_price=='Y'?'disabled':'enabled') .' OnKeyUp="updateNet()"') ; ?></td>
					</tr>
					  </table>
				</td>
			</tr>	 
				<?php tep_content_title_bottom(); ?>
				<?php tep_content_title_top("Blocked Out Time");?>				
				<tr>
				    <td>
					 <table border="0" cellpadding="4" cellspacing="0" width="100%">						
						<tr>
							<td colspan="8">
								<table width="100%" border="0" cellpadding="0" id="header_operation_id" cellspacing="0">
									<tr>
										<td colspan="2" width="500">&nbsp;</td>
										 <td>
										   <table style="background:#DEE4F5;cursor:pointer;" border="0" cellspacing="0" cellpadding="0" width="100%">
										     <tr>
										       <td class="cell_bg_popm_left">&nbsp;</td>
										        <?php echo '<td valign="top" align="center"><a href="javascript:do_add_block(\'add\',0);">' . tep_image(DIR_WS_IMAGES.'template/img_copy.gif',IMAGE_ADD_BLOCK_DATE) . '</a>&nbsp;<span id="img_delete" style="display:none"><a href="javascript:do_add_block(\'delete\',' . $service_id . ')">' . tep_image(DIR_WS_IMAGES.'template/img_trash.gif',IMAGE_DELETE_BLOCK_DATE) . '</a></span></td>';?>
										       <td class="cell_bg_popm_right">&nbsp;</td>
										     </tr>
										   </table>
										 </td>
										<td colspan="2" align="right" width="500"></td> 
									</tr>
								</table>
							</td>		
						</tr>
						<tr>
						<td>
						 <div id="div_nb_date_list" style="overflow:auto;width:100%;">
							<input type="hidden" name="nb_dates" id="nb_dates" value="<?php echo tep_output_string($edit_nbdates_string);?>">
							<input type="hidden" name="sel_nb_dates_id" id="sel_nb_dates_id">
							<input type="hidden" name="sel_count" id="sel_count">
						    <div id="div_tbl"><table border="0" cellspacing="0" class="main" cellpadding="0" width="100%" id="tbl_obj"></table></div>
						 </div>
						 </td>
						</tr>
						<tr><td>
						<div id="show_details" style="display:none;">
						<table cellpadding="0" cellspacing="0" width="100%" border="0">
							<tr>
								<td align="left"><table cellpadding="0" cellspacing="0" border="0" width="100%">
									<tr id="recurring_type_option">										
										<Td colspan="4" align="left" width="100%">
										<div style="width:100%;">
											<table cellpadding="0" cellspacing="0" width="100%" border="0">
												<tr>
													<td colspan="3" align="left"><?php echo tab_strip(); ?></td>
												</tr>											
											</table>
										</div>
										</Td>
									</Tr>
									<tr>
									 <Td colspan="4" align="left">
									   <table cellpadding="2" cellspacing="2" width="70%" border="0">
									     <tr>
											<?php  $_array = array ('d','m','Y'); $replace_array = array ('DD','MM','YYYY');$date_format = str_replace($_array, $replace_array, EVENTS_DATE_FORMAT);?>
											<td class="main" width="100" valign="top"><?php echo TEXT_SERVICE_NOBOOK_SDATE; ?><br><small>(<?php echo $date_format;?>)</small></td>
											<td class="main" width="150" valign="top" align="left"><?php echo tep_draw_date_field("no_booking_sdate", format_date($current_date), "size=10");?>
											<td class="main" width="100"><?php echo TEXT_SERVICE_NOBOOK_STIME; ?></td>
											<td class="main" width="150" align="left"><?php echo tep_draw_time_field("no_booking_stime",'');?></td>
										</tr>
										<tr>
											<td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '1', '3'); ?></td>
										</tr>
										<tr>
											<td class="main" valign="top"><?php echo TEXT_SERVICE_NOBOOK_EDATE;; ?><br><small>(<?php echo $date_format;?>)</small></td>
											<td class="main" valign="top" align="left"><?php echo tep_draw_date_field("no_booking_edate", format_date($current_date), "size=10");?>								
											<td class="main"><?php echo TEXT_SERVICE_NOBOOK_ETIME; ?></td>
											<td class="main" align="left"><?php echo tep_draw_time_field('no_booking_etime','');?></td>
										</tr>																		    
									   </table>
								     </td>
								   </tr>									 
								</table>
							   </td>
							</tr>	
						 </table>
						</div>
					   </td></tr>	
					</table>
					</td>
				</tr>
				<?php tep_content_title_bottom(); ?>
				<?php tep_content_title_top("Loadings"); 
				?>
				<!-- <tr>
				<td class="main"><?php //echo tep_draw_checkbox_field('include_loadings','Y',($suInfo->include_loadings=='Y'?true:false),'','onClick="do_check_control(8)"').'&nbsp;Includes Loading'; ?>
				</td>
				</tr> -->
				
				<tr>
				<td>
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
				<tr>
				<td colspan="2" width="500">&nbsp;</td>
				<td>
				   <table style="background:#DEE4F5;cursor:pointer;" id="loading_operation" border="0" cellspacing="0" cellpadding="0" width="100%">
				    <tr>
				    <td class="cell_bg_popm_left">&nbsp;</td>
				    <?php echo '<td valign="top" align="center"><a onmouseover="javascript: do_hover_change(this,2);" onmouseout="javascript: do_hover_change(this,1);" href="javascript: new_loading();">' . tep_image(DIR_WS_IMAGES.'template/img_copy.gif',IMAGE_ADD_LOAD_DATE) . '</a>&nbsp;<a style="display:none;"  onmouseover="javascript: do_hover_change(this,2);" onmouseOut="javascript: do_hover_change(this,1);" id="trash_button" href="javascript: do_date_action_load(\'delete\');">' . tep_image(DIR_WS_IMAGES.'template/img_trash.gif',IMAGE_DELETE_LOAD_DATE) . '</a></td>';?>
				    <td class="cell_bg_popm_right">&nbsp;</td>
				    </tr>
				   </table>
				</td>
				<td colspan="2" align="right" width="500"></td> 
				</tr>
				</table>
				</td>
				</tr>
		<tr>
		<td>
		<?php
		echo tep_draw_pull_down_menu('loading_date_list', $loading_array, '', ' border="0" id="loading_date_list" size=3  style="width:100%;  border-color:#EDF1FE; background:#EDF1FE;" onClick="javascript:do_date_action_load(\'select\');"');
		echo tep_draw_hidden_field('loading_dates'); ?>
		</td>
		</tr>						
		<tr id="load_check_condition" style="display:none;">
		<td valign="top"><table border="0" cellpadding="0" cellspacing="0" width="80%">
	    <tr>
		 <td  valign="top"><br />
		   <table border="0" cellpadding="0" cellspacing="0" width="100%"> 	
			 <tr height="15">				
				<td align="left" class="main" width="70" valign="top">&nbsp;&nbsp;<label for="daily_check"><input id="daily_check"  name="daily_check" onclick="javascript:open_loads('D');" type="checkbox">&nbsp;Daily</label></td>
				<td align="center" class="main" width="70"><label for="weekly_check"><input id="weekly_check"  name="weekly_check" onclick="javascript:open_loads('W');" type="checkbox">&nbsp;Weekly</label></td>
				<td align="center" class="main" width="70"><label for="monthly_check"><input id="monthly_check"  name="monthly_check" onclick="javascript:open_loads('M');" type="checkbox">&nbsp;Monthly</label></td>
				<td align="center" class="main" width="70"><label for="yearly_check"><input id="yearly_check"  name="yearly_check" onclick="javascript:open_loads('Y');" type="checkbox">&nbsp;Yearly</label></td>
			</tr>
		   </table>
		  </td>
		  <td width="250" align="right">&nbsp;<a id="save_button" href="javascript:do_date_action_load('add');"><img src="images/template/img_savel.gif" alt="save" title="save" border="0"></a>&nbsp;&nbsp;<a href="javascript:close_loaded_details();"><img src="images/template/img_closel.gif" alt="close" title="close" border="0"></a>&nbsp;&nbsp;</td>
		</tr></td>
		</tr>
		</table>
		</td></tr>
				
					<tr>
					<td><br /><table width="100%" cellpadding="0" cellspacing="0" border="0">
   					<tr>
					   <td>
							<table border="0" cellpadding="4" cellspacing="0" width="80%">
									<tr id="loading_recurring_type_option">
										<Td align="left">
											<table cellpadding="0" cellspacing="0" width="100%" border="0">
												<Tr id="load_daily" style="display:none;">
												<?php
										//tep_draw_input_field('loading_daily_days', $loading_daily_days,'size=5 maxlength=2')
																					echo $loading_daily_days;
																					if ($loading_recurring_type == "")
																						$loading_recurring_type = "DD"
													?>
													<td class="main">
														<table width="100%" cellpadding="0" cellspacing="0" border="0">
														<tr>
															<td width="60" align="left" class="main">&nbsp;&nbsp;<?php echo 'Every';?>&nbsp;</td>
															<td width="30" align="left"><?php echo tep_draw_input_field('loading_daily_days', $loading_daily_days,' onKeyPress="return keyRestrict(event)" size=5 maxlength=2'); ?></td>
															<td width="20" align="left"><img src="images/spin_up.gif" onclick="javascript:do_increment(document.new_product.loading_daily_days,'d');" /><br /><img src="images/spin_down.gif" onclick="javascript:do_decrement(document.new_product.loading_daily_days);" /></td>
															<td class="main">day(s)</td>
														</tr>
														<tr>
															<td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
														</tr>
														</table>
													</td>
												</Tr>												
												<Tr id="load_weekly" style="display:none;">
													<?php
																					$count = 0;
																					$icnt = 1;
																					$loading_week_days = array (
																						'Sun',
																						'Mon',
																						'Tue',
																						'Wed',
																						'Thu',
																						'Fri',
																						'Sat'
																					);
																					$loading_check_weekdays = "";
																					$loading_check_weekdays = '<table border="0" cellspacing="0" cellpadding="0" class="formArea"><tr>';
																					for ($i = 0, $n = sizeof($loading_week_days); $i < $n; $i++) {
																						$temp = '<td class="main"';
																						if ($i % 2 == 0)
																							$temp .= ' bgcolor="#ebebff" ';
																						$temp .= '>';
																						//	echo $no_booking_week_days[$i];
																						//	echo $i;
																						$temp .= tep_draw_checkbox_field('loading_week_days[]', $i +1, '', '', '') . '&nbsp;' . $loading_week_days[$i] . '&nbsp;';
																						//if($loading_days_select_array[$count]==$icnt)
																						//	$count++;
																						$temp .= '</td>';
																						$loading_check_weekdays .= $temp;
																						//	echo $check_weekdays;
																						//	echo $i;
																						$icnt++;
																					}

																					$loading_check_weekdays .= "</tr></table>";
?>
											 		  <td colspan="2" valign="middle">
											 		  	  <table cellpadding="0" border="0" cellspacing="0" width="100%">
											 		  	  	<tr>
											 		  	  		<td class="main" width="60">&nbsp;&nbsp;<?php  echo 'Every &nbsp;' ?></td>
														  		<td class="main" width="20"><?php echo tep_draw_input_field('loading_weekly_weeks', $loading_weekly_weeks,' onKeyPress="return keyRestrict(event)" size=5 maxlength=2'); ?></td>
																<td width="10"><img src="images/spin_up.gif" onclick="javascript:do_increment(document.new_product.loading_weekly_weeks,'w');" /><br /><img src="images/spin_down.gif" onclick="javascript:do_decrement(document.new_product.loading_weekly_weeks);" /></td>
																<td width="80" class="main">&nbsp;week(s) on&nbsp;</td>
																<td><?php  echo $loading_check_weekdays; ?></td>
											 	 			</tr>
											 	 			<tr>
																<td colspan="5"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
															</tr>
														  </table>
													 </td>
											</Tr>
											
										<tr id="load_monthly" style="display:none;">
											<td class="main">									
											<table cellpadding="0" border="0" cellspacing="0" style="border:solid 1px #7b9ebd;" align="left"> 
											<tr>
												<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
											</tr>
											<tr>
												<td width="115" align="left" class="main"><?php echo tep_draw_radio_field('loading_recurring_type', 'MD', ($sInfo->sessions_type_option=='MD'?true:false),'','onClick=javascript:clear_load_content();'). '&nbsp;Days&nbsp;'.tep_draw_input_field('loading_monthly_days', $loading_monthly_days ,'onKeyPress="return keyRestrict(event)" size=5 maxlength=2'); ?></td>
												<td width="20" align="left"><img src="images/spin_up.gif" onclick="javascript:do_increment(document.new_product.loading_monthly_days,'d');" /><br /><img src="images/spin_down.gif" onclick="javascript:do_decrement(document.new_product.loading_monthly_days);" /></td>
												<td class="main" width="100" align="right">&nbsp;Every&nbsp;<?php echo tep_draw_input_field('loading_monthly_months', $loading_monthly_months ,' onKeyPress="return keyRestrict(event)" size=5 maxlength=2'); ?></td>
												<td width="10"><img src="images/spin_up.gif" onclick="javascript:do_increment(document.new_product.loading_monthly_months,'m');" /><br /><img src="images/spin_down.gif" onclick="javascript:do_decrement(document.new_product.loading_monthly_months);" /></td>
												<td class="main" width="470"><?php echo ' &nbsp; month(s)';?></td>
											</tr>
										
											<tr style="height:50">
												<td colspan="5"><table cellpadding="0" cellspacing="0">
													<tr class="main">
														<td class="main"><?php echo tep_draw_radio_field('loading_recurring_type', 'MM', ($loading_recurring_type=='MM'?true:false),'','onClick=javascript:clear_load_content();') .'&nbsp;The&nbsp;'. tep_draw_date_combo_select('weeks','loading_monthly_weeks',$loading_monthly_weeks) . '&nbsp;' . tep_draw_date_combo_select('days',"loading_monthly_week_days",$loading_monthly_week_days) . '&nbsp;of Every ' . tep_draw_input_field('loading_monthly_week_months', $loading_monthly_week_months,' onKeyPress="return keyRestrict(event)" size=5 maxlength=2'); ?></td>
														<td><img src="images/spin_up.gif"  onclick="javascript:do_increment(document.new_product.loading_monthly_week_months,'m');" /><br /><img src="images/spin_down.gif" onclick="javascript:do_decrement(document.new_product.loading_monthly_week_months);" /></td>
														<td class="main">&nbsp;&nbsp;month(s)</td>
													</tr>
											  </table>
											</td>
											</tr>
																			
											</table>									
											</td>
										</tr>
																															
										<tr id="load_yearly" style="display:none;">
											<td class="main">
											<table border="0" cellspacing="0" cellpadding="0" style="border:solid 1px #7b9ebd;">
											<tr>
												<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
											</tr>
											<tr>
											<td class="main"><?php echo tep_draw_radio_field('loading_recurring_type', 'YD', ($loading_recurring_type=='YD'?true:false),'','onClick=javascript:clear_load_content();') .sprintf(TEXT_YEARS_DISPLAY1, tep_draw_date_combo_select('months','loading_yearly_months',$loading_yearly_months) , tep_draw_input_field('loading_yearly_month_days', $loading_yearly_month_days,' onKeyPress="return keyRestrict(event)" size=5 maxlength=2'));?></td>
											<td width="209"><img src="images/spin_up.gif" onclick="javascript:do_increment(document.new_product.loading_yearly_month_days,'d');" /><br /><img src="images/spin_down.gif" onclick="javascript:do_decrement(document.new_product.loading_yearly_month_days);" /></td>
											</tr>
											<tr style="height:50"><td class="main" colspan="2"><?php echo tep_draw_radio_field('loading_recurring_type', 'YY', ($loading_recurring_type=='YY'?true:false),'','onClick=javascript:clear_load_content();') .sprintf(TEXT_YEARS_DISPLAY2,tep_draw_date_combo_select('weeks','loading_yearly_weeks',$loading_yearly_weeks), tep_draw_date_combo_select('days',"loading_yearly_week_days",$loading_yearly_week_days), tep_draw_date_combo_select('months',"loading_yearly_week_months",$loading_yearly_week_months));?></td></tr>
											</table>
											</td>
										</tr>
										<tr>
											<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
										</tr>
										
										<tr id="date_id" style="display:none;">
										<td colspan="2"><table cellpadding="0" cellspacing="0" border="0">
										<tr>
										<td colspan="4"></td>
										</tr>

										<tr>
										<td width="100" class="main">&nbsp;&nbsp;<?php echo TEXT_SERVICE_NOBOOK_SDATE; ?><br>&nbsp;&nbsp;<small>(<?php echo $date_format;?>)</small></td>
										<td width="100" class="main"><?php
											$_array = array ('d','m','Y');
											$replace_array = array ('DD','MM','YYYY');
											$date_format = str_replace($_array, $replace_array, EVENTS_DATE_FORMAT);
											echo tep_draw_date_field("loading_sdate", (tep_not_null($loading_sdate) ? format_date($loading_sdate) : format_date($current_date)), "size=10");?>
										</td>
										<td width="100" align="right" class="main"><?php echo TEXT_SERVICE_NOBOOK_STIME; ?></td>
										<td class="main">&nbsp;<?php echo tep_draw_time_field("loading_stime",$loading_stime);?></td>
										</tr>
										<tr>
										<td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '1', '3'); ?></td>
										</tr>

										<tr>
										<td class="main">&nbsp;&nbsp;<?php echo TEXT_SERVICE_NOBOOK_EDATE; ?><br>&nbsp;&nbsp;<small>(<?php echo $date_format;?>)</small></td>
										<td class="main"><?php echo tep_draw_date_field("loading_edate", (tep_not_null($loading_edate) ? format_date($loading_edate) : format_date($current_date)), "size=10"); ?></td>
										<td align="right" class="main"><?php echo TEXT_SERVICE_NOBOOK_ETIME; ?></td>
										<td class="main">&nbsp;<?php echo tep_draw_time_field('loading_etime',$loading_etime);?></td>
										</tr>
										</table>
										</td>
										</tr>
										<tr id="loading_price_id" style="display:none;">
											<td colspan="2">
											<table border="0" cellpadding="0" cellspacing="0" width="500">
												<tr>
													<td width="100" class="main">&nbsp;<?php echo TEXT_SERVICES_LOADING_TYPE;?></td>
													<td class="main" valign="top"><?php echo tep_draw_pull_down_menu("loading_type",$loading_type_array,$loading_type,' onChange="do_change_event(this);"');?>
													<td width="100" class="main" valign="middle" id="price_label">&nbsp;<?php echo TEXT_SERVICES_LOADING_PRICE;?></td>
													<td class="main"><?php echo tep_draw_input_field('loading_price',$loading_price,' size=9 '.(loading_type.value == "P")?'maxlength=3':'maxlength=7');?></td>
													</td>
												</tr>
											</table>
											</td>										
									</Tr>	
								</table>							
					</td>
				</Tr> 
			</table>
</td>
			</tr>
				<?php
					tep_content_title_bottom();
					tep_content_title_top("Conditions");
				?>
					<tr>
						<td  width="400">
						<table border="0"  cellspacing="0" cellpadding="4">
							<tr>
								<td class="main" width="150"><?php echo TEXT_SERVICES_PENDING_PERIOD;?></td>
								<td class="main"><?php echo tep_draw_input_field("pending_period",(tep_not_null($suInfo->pending_period) ? $suInfo->pending_period:'1'),' onKeyPress="return keyRestrict(event)" size=5 maxlength=6') . '&nbsp;' . TEXT_SERVICES_DAYS;?></td>
							</tr>
							<tr>
								<td class="main" width="150"><?php echo TEXT_SERVICES_RENEWAL_START; ?></td>
								<td class="main" width="200" valign="top" ><?php echo tep_draw_input_field("service_renewal_start",(tep_not_null($suInfo->service_renewal_start) ? $suInfo->service_renewal_start:'0'),' onKeyPress="return keyRestrict(event)" size=5 maxlength=8').'&nbsp;' . TEXT_SERVICES_DAYS;?></td>
							</tr>
							<tr>
								<td class="main" width="150"><?php echo TEXT_SERVICES_RENEWAL_END;?></td>
								<td class="main" width="200" valign="top" ><?php echo tep_draw_input_field("service_renewal_end",(tep_not_null($suInfo->service_renewal_end) ? $suInfo->service_renewal_end:'0'),' onKeyPress="return keyRestrict(event)" size=5 maxlength=8') . '&nbsp;' . TEXT_SERVICES_DAYS;?></td>
							</tr>
						</table>
						</td>
						<td align="left" width="400" valign="top">
									<table border="0" cellpadding="0" cellspacing="0">
										<tr>	
											<td class="main" width="150" valign="top"><?php echo '&nbsp;&nbsp;'.TEXT_SERVICES_CONDITIONS;?></td>
											<td class="main" width="200"><?php echo tep_draw_textarea_field("service_conditions",'wrap',50,5,$suInfo->service_conditions);?></td>
										</tr>
									</table>
								</td>
					</tr>
					<?php

																					tep_content_title_bottom();
																					echo tep_draw_hidden_field('service_date_added', (($suInfo->date_added) ? $suInfo->date_added : date('Y-m-d')));
?>					
					<tr>
						<td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
					</tr>
					<tr align="right"><td colspan="10" width='1200' align='right'><input type='image' src='images/template/img_savel.gif' alt='save' title='save' border='0'>&nbsp;&nbsp;<a href="javascript:do_actions('get_details')"><img src='images/template/img_closel.gif' alt='close' title='close' border='0'></a>&nbsp;&nbsp;</td></tr>		
				</table>   
	 <?php

																				}
																				exit;
																			}
	function tep_create_new_product_category() {
		global $languages, $cInfo, $HTTP_GET_VARS, $check_ID;
		echo '<table width="100%" border="0" cellspacing="2" cellpadding="2" class="openContent">' . (($check_ID == 0 && !$HTTP_GET_VARS['cID']) ? '<tr class="openContent_top"><td class="main" colspan="' . (count($languages) + 1) . '">' . '</td><td class="main" align="right"><input type="image" border="0"  src="images/template/img_savel.gif">&nbsp;<a style="cursor:pointer" onClick="do_close_new_category();"><img src="images/template/img_closel.gif" alt="close"></a>&nbsp;</td></tr>' : '');
?>
				<?php if($cInfo->services_categories_id<=0) { ?> <tr>
 	  	   			<td colspan="2" class="main">&nbsp;&nbsp;<?php echo tep_draw_checkbox_field('main_category','Y').'&nbsp;&nbsp;'.TEXT_MAIN_CATEGORIES;?></td>	
			   	</tr>
				<?php

	}
	for ($i = 0; $i < sizeof($languages); $i++) {
?>
					<tr>
						<td class="main"><?php if ($i == 0) echo TEXT_EDIT_SERVICES_CATEGORIES_NAME; ?></td>
						<td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('services_categories_name[' . $languages[$i]['id'] . ']', (tep_not_null($services_categories_name[$languages[$i]['id']]) ? stripslashes($services_categories_name[$languages[$i]['id']]) : tep_get_service_category_name($cInfo->services_categories_id, $languages[$i]['id'])),' maxlength="32" '); ?></td>
					</tr>
				<?php

	}
?>
				<tr>
					<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
				</tr>
			<?php  for ($i=0; $i<sizeof($languages); $i++) { ?>
				<tr>
					<td class="main"><?php if ($i == 0) echo TEXT_EDIT_SERVICES_CATEGORIES_HEADING_TITLE; ?></td>
					<td class="main"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . tep_draw_input_field('services_categories_heading_title[' . $languages[$i]['id'] . ']', (tep_not_null($services_categories_heading_title[$languages[$i]['id']]) ? stripslashes($services_categories_heading_title[$languages[$i]['id']]) : tep_get_service_category_title($cInfo->services_categories_id, $languages[$i]['id'])),' maxlength="64" '); ?></td>
				</tr>
			<?php } ?>
				<tr>
					<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
				</tr>
			<?php for ($i=0; $i<sizeof($languages); $i++) {?>
				<tr>
					<td class="main" valign="top"><?php if ($i == 0) echo TEXT_EDIT_SERVICES_CATEGORIES_DESCRIPTION; ?></td>
					<td>
					<table border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td class="main" valign="top"><?php echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>&nbsp;</td>
							<td class="main"><?php echo tep_draw_textarea_field('services_categories_description[' . $languages[$i]['id'] . ']', 'soft', '70', '15', (tep_not_null($services_categories_description[$languages[$i]['id']]) ? stripslashes($services_categories_description[$languages[$i]['id']]) : tep_get_service_category_description($cInfo->services_categories_id, $languages[$i]['id']))); ?></td>
						</tr>
					</table>
					</td>
				</tr>
			<?php
	}
	for ($i = 0; $i < sizeof($languages); $i++) {
	?>
				<tr>
					<td class="main" valign="top"><?php if ($i == 0) echo TEXT_EDIT_SERVICES_CATEGORIES_NOTES; ?></td>
					<td>
					<table border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td class="main" valign="top"><?php  echo tep_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']); ?>&nbsp;</td>
							<td class="main"><?php echo tep_draw_textarea_field('services_categories_notes[' . $languages[$i]['id'] . ']', 'soft', '70', '15', (tep_not_null($services_categories_notes[$languages[$i]['id']]) ? stripslashes($services_categories_notes[$languages[$i]['id']]) : tep_get_service_category_notes($cInfo->services_categories_id, $languages[$i]['id']))); ?></td>
						</tr>
					</table>
					</td>
				</tr>
				<?php
				if($HTTP_GET_VARS['action']=='edit_category') echo tep_draw_hidden_field('sort_order',$cInfo->sort_order);
	}
	?>
				<tr>
					<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
				</tr>
				<tr>
					<td class="main"><?php echo TEXT_EDIT_SERVICES_CATEGORIES_IMAGE; ?></td>
					<td class="main"><?php echo tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . tep_draw_file_field('services_categories_image') . '<br>' . tep_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . $cInfo->services_categories_image . tep_draw_hidden_field('services_categories_previous_image', $cInfo->services_categories_image); ?></td>
				</tr>
				<tr>
					<td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
				</tr>											
	</table>
	<?php
 }
  function echo_get_details() {
	global $currencies, $languages_id, $service_id, $cID, $HTTP_POST_VARS;
	$str_vals = "";
	$service_query = tep_db_query("select su.service_id,sd.service_name, sd.service_description, su.quantity,su.service_tax_class_id,su.service_costs,date_format(su.service_date_added,'%Y-%m-%d') as service_date_added, date_format(su.service_last_modified,'%Y-%m-%d') as service_last_modified,su.service_status,su.service_image,date_format(su.service_date_available,'%Y-%m-%d') as service_date_available from " . TABLE_SERVICES . " su, " . TABLE_SERVICES_DESCRIPTION . " sd where su.service_id = '" . (int) $service_id . "' and su.service_id = sd.service_id and sd.language_id = '" . (int) $languages_id . "'");
	if (tep_db_num_rows($service_query) > 0) {
		$service = tep_db_fetch_array($service_query);
		$suInfo = new objectInfo($service);
	}
	$product_categories = tep_db_query("select cd.services_categories_id,cd.services_categories_name from " . TABLE_SERVICES_CATEGORIES . " c," . TABLE_SERVICES_CATEGORIES_DESCRIPTION . " cd where c.services_categories_id=cd.services_categories_id and cd.language_id='" . (int) $languages_id . "' and c.services_categories_id='" . (int) $cID . "'");
	if (tep_db_num_rows($product_categories) > 0) {
		$categories = tep_db_fetch_array($product_categories);
		while (list (, $vals) = each($categories)) {
			$str_vals .= $vals . '{}';
		}
	}
	if (tep_db_num_rows($service_query) > 0) {
		while (list ($key, $vals) = each($service)) {
			if ($key == 'service_description')
				$vals = str_replace("\n", "", $vals);
			if ($key == 'service_date_added' || $key == 'service_last_modified')
				$vals = format_date($vals);
			if ($key == 'service_tax_class_id') {
				$tax_id = $vals;
				continue;
			}
			if ($key == 'service_costs')
				$vals = $currencies->format(tep_add_tax($vals, tep_get_tax_rate($tax_id)));
			$str_vals .= $vals . "{}";
			if ($key == 'service_image')
				$str_vals .= "{}";
		}
	} else
		$str_vals = "No Record Found";
	echo (($HTTP_POST_VARS['action_type'] == 'new') ? '' : 'get_details^') . $str_vals;
 }
 function tab_strip(){?>	
<table border="0" cellpadding="0" cellspacing="0" width="90%">
	    <tr>
		 <td  valign="top">
		   <table border="0" cellpadding="0" cellspacing="0" width="100%"> 	
			 <tr height="15">				
				<td align="left" class="main" width="40"><label for="recurring_type_day_divs"><input id="recurring_type_open_divs"  name="recurring_type_open_divs" onclick="javascript:open_divs('D');" type="checkbox">&nbsp;Daily</label></td>
				<td align="center" class="main" width="50"><label for="recurring_type_week_divs"><input id="recurring_type_open_divs"  name="recurring_type_open_divs" onclick="javascript:open_divs('W');" type="checkbox">&nbsp;Weekly</label></td>
				<td align="center" class="main" width="50"><label for="recurring_type_month_divs"><input id="recurring_type_open_divs"  name="recurring_type_open_divs" onclick="javascript:open_divs('M');" type="checkbox">&nbsp;Monthly</label></td>
				<td align="center" class="main" width="50"><label for="recurring_type_year_divs"><input id="recurring_type_open_divs"  name="recurring_type_open_divs" onclick="javascript:open_divs('Y');" type="checkbox">&nbsp;Yearly</label></td>
			</tr>
		   </table>
		  </td>
		  <td width="250" align="right"><a href="javascript:save_blocked_detail();"><img src="images/template/img_savel.gif" alt="save" title="save" border="0"></a>&nbsp;&nbsp;<a href="javascript:close_blocked_detail();"><img src="images/template/img_closel.gif" alt="close" title="close" border="0"></a>&nbsp;&nbsp;</td>
		</tr>
		 <tr><td colspan="2">
		  	<table border="0" cellpadding="0" cellspacing="0" width="60%">
				<tr>
					<td>
						<table cellpadding="0" cellspacing="0" width="100%" border="0">							
							<tr>
								<td class="main" align="center"><div id="daily_div" style="display:none;width:600px">
									<table cellpadding="5" cellspacing="0" width="100%" border="0"><tr>
										<td valign="middle">
											<table cellpadding="0" cellspacing="0" width="100%" border="0">
												<tr>				
												<?php for($i=1;$i<=31;$i++)
															$days_array[]=array('id'=>$i,'text'=>$i);
														if ($recurring_type == "") $recurring_type = "DD";
													?>	
												<td  class="main" align="left" width="40">
												<?php echo  'Every '; ?></td>
												<td align="right" width="45"><?php echo tep_draw_input_field('daily_days','','onKeyPress="return keyRestrict(event)"  size="2" maxlength="2"') ;?></td>
												<td align="left" class="main"  width="30"><img src="images/spin_up.gif" onclick="javascript:do_increment(document.new_product.daily_days,'d');" /><br /><img src="images/spin_down.gif" onclick="javascript:do_decrement(document.new_product.daily_days);" /></td>
												<td class="main">days</td>
												</tr>
											</table>
										</td>	
									</tr>
									<tr>
										<td colspan="5"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
									</tr>
								</table>
								</div>
								</td>
								<td class="main"><div id="week_div" style="display:none;width:600px">
									<table border="0" cellpadding="0" cellspacing="0" width="100%">
										<tr>
											<td colspan="5"><?php echo tep_draw_separator('pixel_trans.gif', '1', '20'); ?></td>
										</tr>
										 <tr>
											 <td class="main" width="50" align="left">
											 <?php echo  '&nbsp;Every '; ?></td>
											 <td align="right" width="20"><?php echo tep_draw_input_field('weekly_weeks','','onKeyPress="return keyRestrict(event)" size=5');  ?></td>
											<td align="left" class="main" width="20"><img src="images/spin_up.gif" onclick="javascript:do_increment(document.new_product.weekly_weeks,'w');" /><br /><img src="images/spin_down.gif" onclick="javascript:do_decrement(document.new_product.weekly_weeks);" /></td>
											<td class="main">
											 <table border="0" cellspacing="0" cellpadding="0" width="100%">
											   <tr>
											     <td class="main">week(s) on</td>
											     <td>											     									 
								<?php
											$count = 0;
											$icnt = 1;
											$no_booking_week_days = array ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
											$check_weekdays = "";
											$check_weekdays = '<table border="0" cellspacing="0" cellpadding="0" class="formArea"><tr>';
											for ($i = 0, $n = sizeof($no_booking_week_days); $i < $n; $i++) {
												$temp = '<td class="main"';
												if ($i % 2 == 0) $temp .= ' bgcolor="#ebebff" ';
												$temp .= '>';
												$temp .= tep_draw_checkbox_field('no_booking_week_days[]', $i +1, '', '', '') . '&nbsp;' . $no_booking_week_days[$i] . '&nbsp;';
												$temp .= '</td>';
												$check_weekdays .= $temp;
												$icnt++;
											}
											$check_weekdays .= "</tr></table>";
											echo $check_weekdays;
											?>											
										 </td>	
								   	    </tr> 
									  </table>
									 </td>
									<tr>
										<td colspan="5"><?php echo tep_draw_separator('pixel_trans.gif', '1', '20'); ?></td>
									</tr>
								 </table>
								</div>
								</td>
								<td class="main"><div id="month_div" style="display:none;width:700px">
								<table border="0" cellspacing="2" cellpadding="2" width="100%" style="border:solid 1px #7b9ebd;">
								<tr><td>
									<table cellpadding="0" cellspacing="0" width="100%" border="0">
										<Tr class="main">
											<td class="main" width="115" align="left"><?php echo tep_draw_radio_field('recurring_type', 'MD', ($recurring_type=='MD'?true:false),'','onClick=javascript:clear_block_content();') . 'Days ' . tep_draw_input_field('monthly_days', '' ,'onKeyPress="return keyRestrict(event)" size=5 maxlength=2'); ?></td>
											<td align="left" class="main" width="10"><img src="images/spin_up.gif" onclick="javascript:do_increment(document.new_product.monthly_days,'d');" /><br /><img src="images/spin_down.gif" onclick="javascript:do_decrement(document.new_product.monthly_days);" /></td>
											<td class="main" width="100" align="right"><?php echo ' every ' . tep_draw_input_field('monthly_months', $monthly_months ,'onKeyPress="return keyRestrict(event)" size=5 maxlength=2') ;?></td>
											<td align="left" class="main" width="20"><img src="images/spin_up.gif"  onclick="javascript:do_increment(document.new_product.monthly_months,'m');" /><br /><img src="images/spin_down.gif"  onclick="javascript:do_decrement(document.new_product.monthly_months);" /></td>
											<td class="main" width="570"><?php echo ' &nbsp; month(s)'; ?></td>
										</Tr>
										<tr>
											<td colspan="5"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
										</tr>
									</table>
									<table cellpadding="0" cellspacing="0" width="100%" border="0">	
										<Tr class="main">										
											<td class="main" width="150" align="left" ><?php echo tep_draw_radio_field('recurring_type', 'MM', ($recurring_type=='MM'?true:false),'','onClick=javascript:clear_block_content();') . 'The ' . tep_draw_date_combo_select('weeks','monthly_weeks',$monthly_weeks); ?></td>
											<td align="left" width="110"><?php echo '&nbsp;' . tep_draw_date_combo_select('days',"monthly_week_days",$monthly_week_days) ; ?></td>
											<td class="main" width="100" align="right"><?php echo ' of every ' . tep_draw_input_field('monthly_week_months', $monthly_week_months,'onKeyPress="return keyRestrict(event)" size=5 maxlength=2') ;?></td>
											<td align="left" class="main" width="15"><img src="images/spin_up.gif"  onclick="javascript:do_increment(document.new_product.monthly_week_months,'m');"  /><br /><img src="images/spin_down.gif"  onclick="javascript:do_decrement(document.new_product.monthly_week_months);"  /></td>
											<td class="main" align="left"><?php echo 'month(s)'; ?></td>
											<td>&nbsp;</td>
										</Tr>
										<tr>
											<td colspan="6"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
										</tr>
									</table>		
								   </td>
								  </tr>
								</table>	
								</div>
								</td>
								<td class="main">
									 <div id="year_div" style="display:none;width:700px;">
									 <table cellpadding="0" cellspacing="0" width="100%" border="0" style="border:solid 1px #7b9ebd;">
									 	<tr>
											<td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
										</tr>
										<tr height="25">
											<td class="main" width="155" nowrap="nowrap" align"left"><?php echo tep_draw_radio_field('recurring_type', 'YD', ($recurring_type=='YD'?true:false),'','onClick=javascript:clear_block_content();') . 'Every ' . tep_draw_date_combo_select('months','yearly_months',$yearly_months) ;?></td>
											<td width="10"><?php echo tep_draw_input_field('yearly_month_days','','onKeyPress="return keyRestrict(event)" maxlength="2" size="2"');?></td>
											<td lang="left" width="10"><img src="images/spin_up.gif"  onclick="javascript:do_increment(document.new_product.yearly_month_days,'d');"  /><br /><img src="images/spin_down.gif"  onclick="javascript:do_decrement(document.new_product.yearly_month_days);"  /></td>
											<td width="500">&nbsp;</td>
										</tr>
										<tr>
											<td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
										</tr>
										<tr>
											<td  colspan="4" class="main"><?php echo tep_draw_radio_field('recurring_type', 'YY', ($recurring_type=='YY'?true:false),'','onClick=javascript:clear_block_content();') .sprintf(TEXT_YEARS_DISPLAY2,tep_draw_date_combo_select('weeks','yearly_weeks',$yearly_weeks), tep_draw_date_combo_select('days',"yearly_week_days",$yearly_week_days), tep_draw_date_combo_select('months',"yearly_week_months",$yearly_week_months));?></td>
										</tr>
										<tr>
											<td colspan="4"><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
										</tr>	
									</table>	
									</div>
								</td>
							</tr>							
						</table>
					</td>
				</tr>
			</table>
		  </td></tr>
	</table>
 <?php
 }
 
function get_recurring_text($service_id, $no_book_id) {
	$no_book_query=tep_db_query("Select *, time_format(no_booking_start_time,'%l:%i%p') as no_booking_stime, time_format(no_booking_end_time,'%l:%i%p') as no_booking_etime from services_no_booking_days where service_no_booking_id='" . $no_book_id . "' ");
	$no_book_result=tep_db_fetch_array($no_book_query);
	$recurring_type=$no_book_result['recurring_type'];
	$recurring_details=$no_book_result['recurring_details'];
	$sdate=$no_book_result['no_booking_start_date'];
	$edate=$no_book_result['no_booking_end_date'];
	$stime=$no_book_result['no_booking_start_time'];
	$etime=$no_book_result['no_booking_end_time'];
	$booking_stime=$no_book_result['no_booking_stime'];
	$booking_etime=$no_book_result['no_booking_etime'];
	$no_booking_array[] = form_recurring_array($sdate, $edate, $stime, $etime, $booking_stime, $booking_etime, $recurring_type, $recurring_details);
	if(sizeof($no_booking_array>0)) 
		return $no_booking_array;
}
?>
