<?
	$this->title = 'Gift cards';
	$this->titleicon = 'gift';
	$this->titleLink = '/giftcards';
	
	$this->title2 = 'Email';
	$this->title2icon = 'envelope-alt';

?>


<div class="container-fluid padded">
	<div class="row-fluid">
		<div class="box">
			<div class="box-content padded">

		
		
		
				<table><tr><td>
				<table class="admin-giftcard-form">
					<tr>
						<td class="label-primary">Promo code:</td>
						<td class="content-primary">
							<div class="check-wrap">
								<div class="check-content">
									<table style="width:100%;">
										<tbody>
											<tr>
												<td class="label-sub">Value:</td>
												<td class="content-sub"><input type="text" id="value" name="value"></div></td>
											</tr>
											<tr>
												<td class="label-sub">Emails:</td>
												<td class="content-sub">
													<textarea style="height:100px;width:300px;" name="emails" id="emails"></textarea>
													<br/>
													*One email per line.
												</td>
											</tr>
											<tr>
												<td class="label-sub">Type:</td>
												<td class="content-sub">gift_card</td>
											</tr>
											<tr>
												<td class="label-sub">Restaurant:</td>
												<td class="content-sub">
													<select id="id_restaurant" class="chosen-select" name="id_restaurant" data-placeholder="Choose a restaurant" style="width:350px;">
														<option value="" selected></option>
														<option value="*" selected>** ANY RESTAURANT **</option>
														<? foreach (Restaurant::q('SELECT * FROM restaurant WHERE giftcard = 1 ORDER BY name') as $restaurant) : ?>
															<option value="<?=$restaurant->id_restaurant?>"><?=$restaurant->name?></option>
														<? endforeach ; ?>
													</select>
												</td>
											</tr>
											<tr>
												<td class="label-sub" nowrap="nowrap">Paid by:</td>
												<td class="content-sub">
													<select name="paid_by" id="paid_by">
														<option value="crunchbutton">crunchbutton</option>
														<option value="restaurant">restaurant</option>
														<option value="promotional">promotional</option>
														<option value="other_restaurant">other_restaurant</option>
													</select>
												</td>
											</tr>
											<tr id="row_id_restaurant_paid_by" style="display:none;">
												<td class="label-sub">Restaurant that paid the credit:</td>
												<td class="content-sub">
													<select id="id_restaurant_paid_by" class="chosen-select" name="id_restaurant_paid_by" data-placeholder="Choose a restaurant" style="width:350px;">
														<option value="" selected></option>
														<? foreach (Restaurant::q('SELECT * FROM restaurant ORDER BY name') as $restaurant) : ?>
															<option value="<?=$restaurant->id_restaurant?>" <?php if( $this->id_restaurant == $restaurant->id_restaurant ){ echo 'selected="selected"'; } ?> ><?=$restaurant->name?></option>
														<? endforeach ; ?>
													</select>
												</td>
											</tr>
											<tr>
										</tbody>
									</table>
								</div>
							</div>
						</td>
					</tr>
					<tr>
						<td class="label-primary">Email:</td>
						<td class="content-primary">
							<div class="check-wrap">
								<div class="check-content">
									<table style="width:100%;">
										<tbody>
											<tr>
												<td class="label-sub">Subject:</td>
												<td class="content-sub">
													<input type="text" name="subject" id="subject"></textarea>
												</td>
											</tr>
											<tr>
												<td class="label-sub">Content:</td>
												<td class="content-sub">
													<textarea style="height:100px;width:300px;" name="content" id="content">Congrats, you got a gift card to <?php echo Crunchbutton_Promo::TAG_RESTAURANT_NAME; ?>! To receive it, enter code: <?php echo Crunchbutton_Promo::TAG_GIFT_CODE; ?> in your order notes or click here: <?php echo Crunchbutton_Promo::TAG_GIFT_URL; ?>.</textarea>
												</td>
											</tr>
										</tbody>
									</table>
		
		
		
								</div>
							</div>
						</td>
					</tr>
				</table>
		
		
			<table class="admin-giftcard-form">
					<tr>
						<td class="label-primary">More info:</td>
						<td class="content-primary">
							<div class="check-wrap">
								<div class="check-content">
									<table style="width:100%;">
										<tbody>
											<tr>
												<td class="label-sub">Created by:</td>
												<td class="content-sub"><input type="text" id="created_by" name="created_by" value="<?=c::admin()->login?>"></td>
											</tr>
											<tr>
												<td class="label-sub"></td>
												<td class="content-sub"><input type="checkbox" id="track" value="1" name="track"> Track this gift card</td>
											</tr>
											<tr class="track-fields">
												<td class="label-sub">Notify phone:</td>
												<td class="content-sub">

													<input type="text" id="notify_phone" value="<?=c::admin()->testphone?>" name="notify_phone">
													<br />
													<span style="font-size:11px;">
														*Phone number that will receive a sms <br/>notification when this gift card is redeemed.
													</span>
												</td>
											</tr>
											<tr class="track-fields">
												<td class="label-sub">Customer Name:</td>
												<td class="content-sub"><input type="text" id="name" value="" name="name"></td>
											</tr>
											<tr class="track-fields">
												<td class="label-sub">Contact Info:</td>
												<td class="content-sub"><textarea name="contact" id="contact"></textarea></td>
											</tr>
											<tr>
												<td class="label-sub">Notes + Follow-up?</td>
												<td class="content-sub"><textarea name="note" id="note"></textarea></td>
											</tr>
										</tbody>
									</table>
									<div class="divisor"></div>
								</div>
							</div>

						</td>
					</tr>
				</table>
							<button type="submit" class="btn btn-blue admin-giftcard-save"><i class="icon-save"></i>&nbsp;&nbsp;&nbsp; Save </button> 
		
				</td>
				<td>
					<div style="margin:10px;">
					<h2 style="font-weight:bold;">Email tags:</h2>
					<br/>
					<ul>
						<li style="margin:5px;"><strong style="font-weight:bold;"><?php echo Crunchbutton_Promo::TAG_GIFT_VALUE; ?></strong> - gift's value</li>
						<li style="margin:5px;"><strong style="font-weight:bold;"><?php echo Crunchbutton_Promo::TAG_GIFT_URL; ?></strong> - url to get the gift</li>
						<li style="margin:5px;"><strong style="font-weight:bold;"><?php echo Crunchbutton_Promo::TAG_RESTAURANT_NAME; ?></strong> - restaurant's name</li>
					</ul>
					<br/>
					<i>*use this tags at the content field.</i>
					</div>
				</td>
				</tr></table>
			</div>
		</div>
	</div>
</div>


<script>
$(function() {
	$( '#paid_by' ).change( function(){
		var self = $( this );
		$( '#row_id_restaurant_paid_by' ).hide();
		if( self.val() == 'other_restaurant' ){
			$( '#row_id_restaurant_paid_by' ).show();
		}
	} );
	App.giftcards.prepareFormBunchEMAIL();
	$(".chosen-select").chosen();
});
</script>