<?php
/**
 * survey_add_view.php - Add and edit page for survey.
 *
 * @author $Author: dtong $
 * @version $Id: survey_add_view.php,v 1.12 2011/03/14 04:26:27 dtong Exp $
 * @copyright Copyright (c) ${year}, Tiller Software Co., Ltd.
*/
if ( $is_edit ) {
	echo '<center><br /><br /><b><font size="+1">' . lang('survey_edit_title') . '</font></b><br /><br /></center>';
	$submit_url = base_url(). 'survey/util/updates';
}
else {
	echo '<center><br /><br /><b><font size="+1">' . lang('survey_create_title') . '</font></b><br /><br /></center>';
	$submit_url = base_url(). 'survey/util/creates';
}

?>
<form name="frm_survey_add" method="POST" >
<input type="hidden" name="extid" value="<?php echo $extid;?>" />
<?php if ( isset($surveyid) ) {?>
	<input type="hidden" name="surveyid" value="<?php echo $surveyid;?>" />
<?php } ?>
<center>
<?php if (isset($survey_url)) {
	echo lang('survey_url_link_label') . ' <u>' . $survey_url . '</u><br /><br />';
}?>
<table class="survey_tablex" border="0">
	<tr>
		<td align="right" class="required"><div style="margin-bottom:5px"><?php echo lang('survey_col_title')?></div></td>
		<td align="left">
			<div style="margin-bottom:5px"><input type="text" name="title" size="50" value="<?php echo $title?>" /></div>
		</td>
	</tr><tr>
		<td align="right" class="required"><div style="margin-bottom:5px"><?php echo lang('survey_col_survey')?></div></td>
		<td align="left">
			<?php
				if ( !isset($survey_dirty) || !$survey_dirty ) {
					echo form_dropdown('template', $survey_selections, $survey_selected, "size=\"{$survey_selections_size}\"");
					echo '<br /><span style="font-size:10px;font-style:italic">(' . lang('survey_template_warning') . ')</span>';
				}
				else {
					echo $selected_template_title;
					echo '<br /><span style="font-size:10px;font-style:italic">(' . lang('survey_template_cant_change') . ')</span>';
					echo "<input type='hidden' name='template' value='{$survey_selected}' />";
				}
			?>
		</td>
	</tr><tr>
		<td align="right" class="required"><?php echo lang('survey_col_startdate')?></td>
		<td align="left" >
			<input type="text" id="startdate" name="startdate" size="20" onClick="this.blur();"
	     		value="<?php echo $startdate;?>" />
	      <input type="image" src="<?php echo osa_imagepath().'calen.gif'?>" name="startdatebutton" id="startdatebutton">
		</td>
	</tr>
	<tr><td colspan="2"></td></tr>
	<tr>
		<td align="right" class="required"><?php echo lang('survey_col_enddate')?></td>
		<td align="left" >
			<input type="text" id="enddate" name="enddate" size="20" onClick="this.blur();"
            		value="<?php echo $enddate;?>" />
      	<input type="image" src="<?php echo osa_imagepath().'calen.gif'?>" name="enddatebutton" id="enddatebutton">
		</td>
	</tr>
	<tr><td colspan="2"></td></tr>
	<tr>
		<td colspan="2">
			<table><tr>
			<td align="right" valign="top"><?php echo lang('survey_blocks')?></td>
			<td valign="top"><?php echo form_dropdown('blocks[]', $blocks, $selected_blocks, 'size="8" multiple="multiple"'); ?></td>
			<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
			<td align="right" valign="top"><?php echo lang('survey_courses')?></td>
			<td><?php echo form_dropdown('courses[]', $courses, $selected_courses, 'size="15" multiple="multiple"'); ?></td>
			</tr></table>
		</td>
	</tr>

	<tr><td colspan="2"><br /></td></tr>
	<tr>
		<td colspan="2" align="center">
			<?php if ($is_edit) { ?>
				<input type="button" value="<?php echo lang('survey_btn_cancel')?>" <?php osa_btn();?>
					onClick="return cancelInput('page_content', '<?php echo base_url() . "survey/util/lists/$extid"?>');" />
				<span style="margin-left:30px"></span>
				<input type="button" value="<?php echo lang('survey_btn_save');?>" <?php osa_btn();?>
					onClick="ajaxPostform('','<?php echo $submit_url?>','frm_survey_add');
								ajaxGetpage('page_content','<?php echo base_url() . "survey/util/lists/$extid"?>');return false;" />
			<?php } else { ?>
				<input type="button" value="<?php echo lang('survey_btn_cancel')?>" <?php osa_btn();?>
					onClick="return cancelInput('page_content', '<?php echo osa_url_history(CMS_URLHISTORY_GOAL)?>');" />
				<span style="margin-left:30px"></span>
				<input type="button" value="<?php echo lang('survey_btn_save');?>" <?php osa_btn();?>
					onClick="ajaxPostform('page_content','<?php echo $submit_url?>','frm_survey_add', false); return false;" />
			<?php } ?>
		</td>
	</tr>
</table>
</center>
</form>