<?php include "header.php";?>

<section>

<div class="content-border">

<?php if ($errors) { ?>
<div class="status-failure"><?php echo $errors["e"].$errors["e1"].$errors["e2"];?></div>
<?php } ?>

<form class="jak_form" method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<table  class="table">
<tr>
<td class="content-title" colspan="2"><?php echo $tl["title"]["t13"];?></td>
</tr>
<tr>
	<td class="go-right"><?php echo $tl["general"]["g16"];?></td>
	<td><input class="inputbig<?php if ($errors["e1"]) echo " error";?>" type="text" name="jak_title" value="<?php echo $JAK_FORM_DATA["title"];?>" /></td>
</tr>
<tr>
	<td class="go-right"><?php echo $tl["general"]["g52"];?></td>
	<td><textarea cols="60" rows="5" class="input_field jakeditor" name="jak_description"><?php echo $JAK_FORM_DATA["description"];?></textarea></td>
</tr>
<tr>
	<td class="go-right"><?php echo $tl["shop"]["m88"];?></td>
	<td><input<?php if ($errors["e2"]) { ?> class="error"<?php } ?> type="text" name="jak_code" value="<?php echo $JAK_FORM_DATA["code"];?>" /></td>
</tr>
<tr>
	<td class="go-right"><?php echo $tl["shop"]["m87"];?></td>
	<td><select name="jak_type" size="1"><option value="1"<?php if ($JAK_FORM_DATA["type"] == 1) { ?> selected="selected"<?php } ?>><?php echo $tl["shop"]["m89"];?></option><option value="2"<?php if ($JAK_FORM_DATA["type"] == 2) { ?> selected="selected"<?php } ?>><?php echo $tl["shop"]["m90"];?></option></select></td>
</tr>
<tr>
	<td class="go-right"><?php echo $tl["shop"]["m80"];?></td>
	<td><input<?php if ($errors["e3"]) { ?> class="error"<?php } ?> type="text" name="jak_discount" value="<?php echo $JAK_FORM_DATA["discount"];?>" /></td>
</tr>
<tr>
	<td class="go-right"><?php echo $tl["shop"]["m81"];?></td>
	<td><select name="jak_freeshipping" size="1"><option value="1"<?php if ($JAK_FORM_DATA["freeshipping"] == 1) { ?> selected="selected"<?php } ?>> <?php echo $tl["general"]["g19"];?></option><option value="0"<?php if ($JAK_FORM_DATA["freeshipping"] == 0) { ?> selected="selected"<?php } ?>><?php echo $tl["general"]["g18"];?></option></select></td>
</tr>
<tr>
	<td class="go-right"><?php echo $tl["shop"]["m84"];?></td>
	<td>
	
	<input type="text" name="jak_datefrom"<?php if ($errors["e2"]) echo ' class="error"';?> id="datepickerFrom" value="<?php if ($JAK_FORM_DATA["datestart"]) echo date("Y-m-d", $JAK_FORM_DATA["datestart"]); ?>" />
	
	<select name="jak_timefrom">
	<?php for ($i = 0; $i <= 24; $i++) { ?>
	<option value="<?php echo $i ?>"<?php if ($JAK_FORM_DATA["datestart"] && date('H', $JAK_FORM_DATA["datestart"]) == $i) { ?> selected="selected"<?php } ?>><?php echo str_pad($i, 2, "0", STR_PAD_LEFT); ?></option>
	<?php } ?>
	</select>
	
	<select name="jak_timefromm">
	<?php for ($i = 0; $i <= 60; $i++) { ?>
	<option value="<?php echo $i ?>"<?php if ($JAK_FORM_DATA["datestart"] && date('i', $JAK_FORM_DATA["datestart"]) == $i) { ?> selected="selected"<?php } ?>><?php echo str_pad($i, 2, "0", STR_PAD_LEFT); ?></option>
	<?php } ?>
	</select>	
	
	</td>
</tr>
<tr>
	<td class="go-right"><?php echo $tl["shop"]["m85"];?></td>
	<td><input type="text" name="jak_dateto"<?php if ($errors["e2"]) echo ' class="error"';?> id="datepickerTo" value="<?php if ($JAK_FORM_DATA["dateend"]) echo date("Y-m-d", $JAK_FORM_DATA["dateend"]); ?>" />
	
	<select name="jak_timeto">
	<?php for ($i = 0; $i <= 24; $i++) { ?>
	<option value="<?php echo $i ?>"<?php if ($JAK_FORM_DATA["dateend"] && date('H', $JAK_FORM_DATA["dateend"]) == $i) { ?> selected="selected"<?php } ?>><?php echo str_pad($i, 2, "0", STR_PAD_LEFT); ?></option>
	<?php } ?>
	</select>
	
	<select name="jak_timetom">
	<?php for ($i = 0; $i <= 60; $i++) { ?>
	<option value="<?php echo $i ?>"<?php if ($JAK_FORM_DATA["dateend"] && date('i', $JAK_FORM_DATA["dateend"]) == $i) { ?> selected="selected"<?php } ?>><?php echo str_pad($i, 2, "0", STR_PAD_LEFT); ?></option>
	<?php } ?>
	</select>
	
	</td>
</tr>
<tr>
	<td class="go-right"><?php echo $tl["shop"]["m82"];?></td>
	<td><input<?php if ($errors["e5"]) { ?> class="error"<?php } ?> type="text" name="jak_total" value="<?php echo $JAK_FORM_DATA["total"];?>" size="4" /> / <input<?php if ($errors["e6"]) { ?> class="error"<?php } ?> type="text" name="jak_used" value="<?php echo $JAK_FORM_DATA["used"];?>" size="4" /></td>
</tr>
<tr>
	<td valign="top" class="go-right"><?php echo $tl["shop"]["m91"];?></td>
	<td>
	
	<div class="show"><fieldset class="scroll_checkboxes"><label><input type="checkbox" name="jak_products[]" value="0"<?php if (in_array(0, explode(',', $JAK_FORM_DATA["products"]))) { ?> checked="checked"<?php } ?> /> <?php echo $tl["shop"]["m92"];?></label>
	<?php if (isset($JAK_PRODUCTS_CHOOSE) && is_array($JAK_PRODUCTS_CHOOSE)) foreach($JAK_PRODUCTS_CHOOSE as $z) { ?>
	<label><input type="checkbox" name="jak_products[]" value="<?php echo $z["id"];?>"<?php if (in_array($z["id"], explode(',', $JAK_FORM_DATA["products"]))) { ?> checked="checked"<?php } ?> /> <?php echo $z["title"];?></label>
	<?php } ?>
	</fieldset></div>
	
	</td>
</tr>
</table>
<div class="ustatus">
<a href="index.php?p=coupons" class="button"><?php echo $tl["general"]["g103"];?></a>
<button type="submit" name="save" class="button"><?php echo $tl["general"]["g38"];?></button>
</div>
</form>
	
</div><!-- #content -->

</section>

<div class="clear"></div>

<script type="text/javascript" src="js/editor/tinymce.min.js"></script>
<script type="text/javascript" src="js/editor.js"></script>
<script type="text/javascript" src="js/jqueryui.js"></script>

<script type="text/javascript">
$(function() {
	$("#datepickerFrom").datepicker({
		changeMonth: true,
		changeYear: true,
		minDate: 0,
		dateFormat: 'yy-mm-dd',
		onSelect: function( selectedDate ) {
		                $( "#datepickerTo" ).datepicker( "option", "minDate", selectedDate );
		            }
	});
	
	$("#datepickerTo").datepicker({
		changeMonth: true,
		changeYear: true,
		minDate: 0,
		dateFormat: 'yy-mm-dd',
		onSelect: function( selectedDate ) {
		                $( "#datepickerFrom" ).datepicker( "option", "maxDate", selectedDate );
		            }
	});
});
</script>
		
<?php include "footer.php";?>