<?php
/*

  osCommRes, Services Online
  http://www.oscommres.com

  Copyright (c) 2005 osCommRes

  Released under the GNU General Public License
  
  Freeway eCommerce from ZacWare
http://www.zac-ware.com/freeway

Copyright 2007 ZacWare Pty. Ltd
*/

	require('includes/application_top.php');
  
	// get the type of action
	$action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
	$survey_id = (isset($HTTP_GET_VARS['suID']) ? (int)$HTTP_GET_VARS['suID'] : 0);
?>
<!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();">
<div id="spiffycalendar" class="text"></div>
<!-- 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 class="pageHeading"><?php echo HEADING_TITLE ; ?></td>
			</tr>
			<tr><td><?php echo tep_draw_separator('pixel_trans.gif', '2', '10'); ?></td></tr>
			<link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
			<script language="JavaScript" src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
			<script language="javascript"><!--
				var dateFrom = new ctlSpiffyCalendarBox("dateFrom", "survey_reports", "survey_report_from","btnDate1","",scBTNMODE_CUSTOMBLUE);
				var dateTo = new ctlSpiffyCalendarBox("dateTo", "survey_reports", "survey_report_to","btnDate2","",scBTNMODE_CUSTOMBLUE);
			//--></script>
			<script language="javascript">
				function validateForm(){
					var type=document.survey_reports.survey_report_type.options[document.survey_reports.survey_report_type.selectedIndex].value;
					var output=document.survey_reports.survey_output_to.options[document.survey_reports.survey_output_to.selectedIndex].value;
					var filename="";
					if (output==2){
						if (type==3) {
							alert("<?php echo addslashes(stripslashes(ERR_QUESTION_REPORT_VALID));?>");
							return;
						}
						document.survey_reports.action="<?php echo tep_href_link(FILENAME_EVENTS_REPORTS_SURVEYS_FILE);?>";
						open_popup(350,330,",location=no,menubar=no,resizable=no,scrollbars=no,toolbar=no,status=no");
						return true;
					}
					switch(type){
						case "1":
							filename="<?php echo tep_href_link(FILENAME_EVENTS_REPORTS_SURVEYS_SUMMARY);?>";
							break;
						case "2":
							filename="<?php echo tep_href_link(FILENAME_EVENTS_REPORTS_SURVEYS_DETAIL);?>";
							break;
						case "3":
							filename="<?php echo tep_href_link(FILENAME_EVENTS_REPORTS_SURVEYS_RELATION);?>";
							break;
						case "4":
							filename="<?php echo tep_href_link(FILENAME_EVENTS_REPORTS_SURVEYS_CROSSTAB);?>";
							break;
					}
					if (type==1 || type==2) {
						document.survey_reports.action=filename+"?only_content=Y";
						open_popup(650,350,",location=no,menubar=no,resizable=yes,scrollbars=yes,toolbar=no,status=yes");
					} else {
						document.survey_reports.action=filename;
						document.survey_reports.target='_self';
						document.survey_reports.submit();
					}
					return true;
				}
				function open_popup(width,height,params){
					var vtop;
					var vleft;
					var wFeats;

					vtop=(screen.availHeight-height)/2;
					vleft=(screen.availWidth-width)/2;
					wFeats="height="+height+",width="+width+params+",left=" + vleft + ",top=" + vtop ;
					//window.open("about:blank",'relation_results',wFeats)
					document.survey_reports.target='relation_results';
					document.survey_reports.submit();
				}
			</script>
			<?php // get the survey names
				$survey_query=tep_db_query("SELECT survey_id,survey_name from " . TABLE_EVENTS_SURVEYS . " order by survey_name");
				$surveys=array();
				while($survey_result=tep_db_fetch_array($survey_query)){
					$surveys[]=array('id'=>$survey_result["survey_id"],'text'=>$survey_result["survey_name"]);
				}
				// get the report types
				$report_types=array();
				for ($icnt=1;$icnt<=3;$icnt++) $report_types[]=array('id'=>$icnt,'text'=>constant('REPORT_TYPE_' . $icnt));
				$report_to=array(array('id'=>1,'text'=>REPORT_TO_SCREEN),array('id'=>2,'text'=>REPORT_TO_FILE));
				echo tep_draw_form("survey_reports",FILENAME_EVENTS_REPORTS_SURVEYS,'','post');
			?>
			<tr>
				<td valign="top">
				<table border="0" cellspacing="0" cellpadding="4" class="formArea">
					<tr>
						<td class="main"><?php echo SURVEY_NAME;?></td>
						<td class="main"><?php echo tep_draw_separator('pixel_trans.gif','10','1') . tep_draw_pull_down_menu('survey_id',$surveys,$tx_id);?></td>
						<td class="main"><?php echo SURVEY_DATE_FROM;?><br><small>(YYYY-MM-DD)</small></td>
						<td class="main"><?php echo tep_draw_separator('pixel_trans.gif','10','1');?><script language="javascript">dateFrom.writeControl(); dateFrom.dateFormat="yyyy-MM-dd";</script></td>
						<td class="main"><?php echo SURVEY_DATE_TO;?><br><small>(YYYY-MM-DD)</small></td>
						<td class="main"><?php echo tep_draw_separator('pixel_trans.gif','10','1');?><script language="javascript">dateTo.writeControl(); dateTo.dateFormat="yyyy-MM-dd";</script></td>
					</tr>
					<tr><td><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td></tr>
					<tr>
						<td class="main"><?php echo SURVEY_REPORT_TYPE;?></td>
						<td class="main"><?php echo tep_draw_separator('pixel_trans.gif','10','1') . tep_draw_pull_down_menu('survey_report_type',$report_types,$tx_report_type);?></td>
						<td class="main"><?php echo SURVEY_REPORT_TO;?></td>
						<td class="main"><?php echo tep_draw_separator('pixel_trans.gif','10','1') . tep_draw_pull_down_menu('survey_output_to',$report_to,$tx_output_to);?></td>
						<td class="main" align="right" colspan="2">
						<?php 
							echo '<span class="cursorHand" onClick="javascript:validateForm();">' . tep_image_button('button_submit.gif',IMAGE_SUBMIT) . '</span>&nbsp;';
							echo '<a href="' . tep_href_link(FILENAME_EVENTS_SURVEYS) . '">' . tep_image_button('button_cancel.gif',IMAGE_CANCEL) . '</a>';
						?>
						</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'); ?>