<?php

/*

 osCommRes, Services Oline 
http://www.oscommres.com 
Copyright (c) 2005 osCommRes 

Freeway eCommerce 
http://www.zac-ware.com/freeway 
Copyright (c) 2007 ZacWare

Released under the GNU General Public License
*/
// Set flag that this is a parent file
	define( '_FEXEC', 1 );

	require('includes/application_top.php');
	tep_get_last_access_file();                                                                                                   $action=(isset($HTTP_GET_VARS['action'])?$HTTP_GET_VARS['action']:'');
  
	switch($action)
	{
		case 'set_value':
			// set configuration value
			$config_id=(isset($HTTP_POST_VARS['configuration_id'])?(int)$HTTP_POST_VARS['configuration_id']:0);
			if ($config_id>0){
				$value=$HTTP_POST_VARS['configuration_value'];
				if (is_array($value)){
					$value=join(",",$value);
				}
			   tep_db_query("UPDATE " . TABLE_CONFIGURATION . " set configuration_value='" . tep_db_input($value) . "' where configuration_id='" . $config_id . "'");
			}
			tep_redirect(tep_href_link(FILENAME_EVENTS_OPTIONS));
		case 'activate':
			/*$err='';
			if (EVENTS_SMS_KEY=='')
				$err=ERR_EMPTY_SMS_KEY;
			else if(EVENTS_SMS_EMAIL=='')
				$err=ERR_EMPTY_SMS_EMAIL;
			else if(EVENTS_SMS_TEST_PHONE=='')
				$err=ERR_EMPTY_SMS_TEST_PHONE;
			else if(EVENTS_SMS_GATEWAY=='')
				$err=ERR_EMPTY_GATEWAY;
			if ($err==''){
				$message = new email(array('X-Mailer: osCommerce'));
				
				$message->add_text('Activate');
				
				$message->build_message();
				$message->send('', tep_get_sms_address(EVENTS_SMS_TEST_PHONE), STORE_OWNER, EVENTS_SMS_EMAIL, EVENTS_SMS_KEY);
			} else {
				$messageStack->add_session($err,'error');
			}*/
		tep_redirect(tep_href_link(FILENAME_EVENTS_OPTIONS));
  }
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title><?php echo TITLE; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
<script language="javascript" src="includes/menu.js"></script>
<script language="javascript" src="includes/general.js"></script>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onLoad="SetFocus();">
	<!-- header //-->
	<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
	<!-- header_eof //-->

	<!-- body //-->
<table border="0" width="100%" cellspacing="2" cellpadding="2">
	<tr> 
	<!-- body_text //-->
	<td width="100%" valign="top">
	<table border="0" width="100%" cellspacing="0" cellpadding="2">
		<tr>
			<td>
			<table border="0" cellspacing="0" cellpadding="4" width="95%">
			<?php
				// Group Configuration settings with headings
				$heading=array(	TEXT_PRESENTATION_OPTIONS=>array("EVENTS_VIEW_STYLE","EVENTS_CALENDAR_STYLE"),	
							//	TEXT_EMAIL_OPTIONS=>array("EMAIL_ACTIVATE","EVENTS_TEST_EMAIL_ADDRESS","EVENTS_EMAIL_TIMINGS","EMAIL_TIME_LIMIT"),
							//	TEXT_SURVEY_OPTIONS=>array("EVENTS_SURVEY_TEXT","CUSTOMER_BOOKING_DETAILS"),
							//	TEXT_DATE_OPTIONS=>array("EVENTS_DATE_FORMAT","EVENTS_SERVER_DATE_OFFSET"),
							//	TEXT_SMS_OPTIONS=>array("SMS_GATEWAY","SMS_ACTIVATE","SMS_EMAIL","SMS_FROM_NAME","SMS_TEST_PHONE","EVENTS_SMS_TIMINGS"),
							//	TEXT_ORDER_OPTIONS=>array("EVENTS_ORDER_TIMEOUT","EVENTS_ORDER_AMOUNT_ROUND","EVENTS_RENEWAL_CHECK","NO_CHECKOUT_ZERO_PRICE"),
							//	TEXT_REPORT_OPTIONS=>array("REPORT_MAX_ROWS_PAGE","REPORT_MAX_LINKS_PAGE"),
							//	TEXT_WEBSERVICE_OPTIONS=>array("ENABLE_WEB_SERVICE")
								);
				reset($heading);
				while(list($id,)=each($heading)){
				//tep_content_title_top($id); 
			?>
			
			<?php
				// select event configuration settings
				$key_string=join("','",$heading[$id]);
				$configuration_query = tep_db_query("select configuration_id, configuration_key,configuration_title, configuration_description,configuration_value, set_function,sort_order from " . TABLE_CONFIGURATION . " where configuration_key in ('" . $key_string . "') order by sort_order");
				while ($configuration = tep_db_fetch_array($configuration_query)) {
					$value_field='';
					// evaluate the configuration function
					if ($configuration['set_function']) {
						eval('$value_field = ' . $configuration['set_function'] . '"' . htmlspecialchars($configuration['configuration_value']) . '");');
					} else {
						$value_field = tep_draw_input_field('configuration_value', $configuration['configuration_value'],'size=40') . '&nbsp;';
						$value_field .= tep_image_submit('button_modify.gif',IMAGE_MODIFY . $configuration['configuration_title'],'align=absmiddle');
					}
					echo tep_draw_form('configuration_' . $configuration['configuration_id'],FILENAME_EVENTS_OPTIONS,'action=set_value');
			?>
			<tr><td><?php echo tep_draw_separator('pixel_trans.gif',1,3); ?></td></tr>
			<tr class='attributes-odd'>
                <td class="main"><?php echo $configuration['configuration_title']; ?></td>
                <td class="main" valign=top>
				<?php 
					echo tep_draw_separator('pixel_trans.gif',20,1) . $value_field; 
					if ($configuration['configuration_key']=='EVENTS_SMS_KEY')
						echo '&nbsp;<a href="' . tep_href_link(FILENAME_EVENTS_OPTION,'action=activate') . '">' . tep_image_button('button_activate.gif',IMAGE_ACTIVATE,'align=absmiddle') . '</a>';
				?>
				</td>
				<td class="smallText" valign=top><?php echo $configuration['configuration_description']; ?></td>
				<?php echo "<input type=hidden name='configuration_id' value='" . $configuration['configuration_id'] . "'></form>"; }?>
			</tr>
			<tr><td><?php echo tep_draw_separator('pixel_trans.gif',1,5); ?></td></tr>
			<?php // tep_content_title_bottom();
			}
			?>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
<!-- body_text_eof //-->
  </tr>
</table>
<!-- body_eof //-->

<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
