<?php
	$this->title = $this->restaurant->name;
	$this->titleicon = 'food';
?>
<!-- restaurants page -->

	<div class="container-fluid padded">
		<ul class="action-nav-normal rounded" style="margin-left: 0;">

			<li class="action-nav-button">
				<a class="tip" data-original-title="Vitals" href="#vitals" title="">
					<i class="icon-medkit"></i>
				</a>
				<span>Vitals</span>
			</li>

			<li class="action-nav-button">
				<a class="tip" data-original-title="Menu" href="#menu" title="">
					<i class="icon-th-list"></i>
				</a>
				<span>Menu</span>
			</li>

			<li class="action-nav-button">
				<a class="tip" data-original-title="Notes" href="#notes" title="">
					<i class="icon-file-alt"></i>
				</a>
				<span>Notes</span>
			</li>

			<?php if (c::admin()->permission()->check(['global', 'restaurants-all', "restaurant-{$this->restaurant->id_restaurant}-all", "restaurant-{$this->restaurant->id_restaurant}-fax" ])) { ?>
				<li class="action-nav-button">
					<a class="tip" data-original-title="Fax" href="/restaurants/<?php echo $this->restaurant->id_restaurant?>/fax" title="">
						<i class="icon-print"></i>
					</a>
					<span>Fax</span>
				</li>
			<?php } ?>

			<?php if (c::admin()->permission()->check(['global', 'restaurants-all', "restaurant-{$this->restaurant->id_restaurant}-all", "restaurant-{$this->restaurant->id_restaurant}-pay" ])) { ?>
				<li class="action-nav-button">
					<a class="tip" data-original-title="Pay" href="/restaurants/<?php echo $this->restaurant->id_restaurant?>/pay" title="">
						<i class="icon-money"></i>
					</a>
					<span>Pay</span>
				</li>
			<?php } ?>

			<li class="action-nav-button">
				<a class="tip" data-original-title="View" href="http://crunchbutton.com/food-delivery/<?php echo $this->restaurant->permalink?>" target="_blank" title="">
					<i class="icon-file"></i>
				</a>
				<span>View</span>
			</li>

			<?php if (c::admin()->permission()->check(['global', 'restaurants-all', "restaurant-{$this->restaurant->id_restaurant}-all" ])) { ?>
				<li class="action-nav-button">
					<a class="tip" data-original-title="Duplicate" href="javascript:if(confirm('Confirm duplicate this restaurant?')){ document.location.href='/restaurants/<?php echo $this->restaurant->id_restaurant?>/duplicate'; }" title="">
						<i class="icon-copy"></i>
					</a>
					<span>Duplicate</span>
				</li>
			<?php } ?>

			<li class="action-nav-button">
				<a class="tip" data-original-title="Revert" href="javascript:;" id="revert-button" title="">
					<i class="icon-undo"></i>
				</a>
				<span>Revert</span>
			</li>
		</ul>
		<hr class="divider">

		<div class="row-fluid">
			<div class="box">
				<div class="box-header">
					<span class="title">Basic Information</span>
				</div>

				<div class="box-content padded">
					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Restaurant Name
							</div>

							<div class="admin-item-desc">
								displayed to customers and the restaurant
							</div>
						</div>

						<div class="admin-item-right">
							<input id="restaurant-name" type="input">
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Permalink
							</div>

							<div class="admin-item-desc" style="width:340px;">
								crunchbutton.com/food-delivery/<b>whateveryouwritehere</b>
							</div>
						</div>

						<div class="admin-item-right">
							<input id="restaurant-permalink" type="input">
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Community
							</div>

							<div class="admin-item-desc">
								<!-- give all your restaurants the EXACT SAME community -->
							</div>
						</div>

						<div class="admin-item-right">

							<!-- <input id="restaurant-community" type="input"> -->

							<select id="restaurant-id-community">
								<option value=""></option>
								<?php
								$communities = Crunchbutton_Community::q( 'SELECT * FROM community WHERE active = true ORDER BY name ASC' );
								foreach( $communities as $community ){
									?>
									<option value="<?php echo $community->id_community; ?>">
										<?php echo $community->name; ?>
									</option>
									<?php
								}
								?>
							</select>

						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Text under Restaurant Name on Choose Restaurant Page
							</div>

							<div class="admin-item-desc">
								choose something funny, awesome, and cool, but descriptive like “delicious chijapanesethai in yo mouth" or "chicken tikka delicious"
							</div>

							<div class="admin-item-desc">
								text size limit 45 chars
							</div>
						</div>

						<div class="admin-item-right">
							<input id="restaurant-short-description" maxlength="45" type="input">
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Force close tagline
							</div>

							<div class="admin-item-desc">
								Tagline will be shown when you force close a restaurant.
							</div>

							<div class="admin-item-desc">
								text size limit 45 chars
							</div>
						</div>

						<div class="admin-item-right">
							<input id="restaurant-force-close-tagline" type="input">
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Text under Restaurant Name on Restaurant Checkout Page
							</div>

							<div class="admin-item-desc">
								write something that’s different from the text on Choose Restaurant page AND that works well with the restaurant’s menu
							</div>
						</div>

						<div class="admin-item-right">
							<input id="restaurant-message" type="input" maxlength="45">
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Phone Number
							</div>

							<div class="admin-item-desc">
								publicly listed
							</div>
						</div>

						<div class="admin-item-right">
							<input id="restaurant-phone" type="input">
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Address
							</div>

							<div class="admin-item-desc">
								for delivery radius and pickup
							</div>
						</div>

						<div class="admin-item-right">
							<textarea id="restaurant-address"></textarea>

							<div class="admin-item-col-med">
								Latitude (automagically calculated) <input id="restaurant-lat" type="input">
							</div>

							<div class="admin-item-col-med">
								Longitude (automagically calculated) <input id="restaurant-lng" type="input">
							</div>

							<div class="admin-item-col-med">
								How far from community (miles)<input id="restaurant-community-distance" type="input">
							</div>

							<div class="admin-item-col-large">
								<br>
								<div class="admin-map" id="restaurant-map">
								</div>
							</div>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Delivery Radius Type
							</div>
						</div>
						<div class="admin-item-right">
							<select id="restaurant-delivery_radius_type">
								<option value="restaurant">
									Restaurant
								</option>
								<option value="community">
									Community
								</option>
							</select>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Delivery by Crunchbutton (3rd-party delivery)
							</div>
						</div>

						<div class="admin-item-right">
							<div class="admin-item-col-small" id="restaurant-delivery-service-container"></div>
						</div>
					</div>

					<div class="admin-item" id="formal-relationship-container">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Formal billing relationship?
							</div>

							<div class="admin-item-desc">
								e.g. if a rep is doing delivery from McDonald’s but has no formal relationship with them, select “no”"
							</div>
						</div>

						<div class="admin-item-right">
							<div class="admin-item-col-small" id="restaurant-formal-relationship-container"></div>
						</div>
					</div>


					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Is It Active?
							</div>

							<div class="admin-item-desc">
								(listed on choose restaurant page)
							</div>

							<div class="admin-item-desc">
								Leave inactive you place a “Test Order” and call the restaurant to tell them they’re active.
							</div>
						</div>

						<div class="admin-item-right">
							<div class="admin-item-col-small" id="restaurant-active-container"></div>
						</div>
					</div>



					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Is It Accepting Orders?
							</div>

							<div class="admin-item-desc">
								close on snowdays, etc.
							</div>

						</div>

						<div class="admin-item-right">
							<br>

							<div class="admin-item-col-small" id="restaurant-open-for-business-container"></div>
							<a class="btn btn-green modal-hour_override" data-toggle="modal" href= "#modal-hour_override">
								<i class="icon-calendar"></i>
								Holidays
							</a>
							<div>
								<br/>
									<div class="admin-restaurant-open-closed"></div>
								<br/>
							</div>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Order Ahead Time (minutes)
							</div>
							<div class="admin-item-desc">
								This is the number of minutes it takes before an order is ready for pickup if the driver calls the restaurant ahead of time or orders online.
								For fast food restaurants this is typically 0.  For other types of restaurants, you can get this information by calling the restaurant
								and/or looking at the restaurant's website where
								it may give you the earliest pickup time when ordering online.  This information is important for helping us to correctly route orders to drivers, so
								the more accurate you can get this number to be, the more you help us to serve more customers faster.  Use the General Notes section
								if you have any other comments related to this.
							</div>
						</div>

						<div class="admin-item-right">
							<input id="restaurant-order_ahead_time" type="input">
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Service Time (minutes)
							</div>
							<div class="admin-item-desc">
								This is the number of minutes it takes once a driver has parked for him/her to pick up the food at the restaurant.
								Some restaurants don't allow you to order ahead, so this number may be higher for those restaurants.
								For a restaurant where the driver already ordered ahead of time and is just picking up, this is probably like 5 minutes.
								For other restaurants, it could be closer to 10-15 minutes or more if the driver has to wait in line.  A Yelp review search might give you a sense of how bad lines are.
								Use whatever information you can obtain.
								This information is important for helping us to correctly route orders to drivers, so
								the more accurate you can get this number to be, the more you help us to serve more customers faster.
								We do understand that this can vary over time of day and day of week, but do your best.
								Use the General Notes section
								if you have any other comments related to this.
							</div>
						</div>

						<div class="admin-item-right">
							<input id="restaurant-service_time" type="input">
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Image
							</div>
						</div>

						<div class="admin-item-right" id="restaurant-image">
							<a target='_blank'><img><br>Change</a>
						</div>
					</div>
				</div>
			</div>

			<div class="box">
				<a id="vitals" name="vitals"></a>

				<div class="box-header">
					<span class="title">Vitals</span>
				</div>

				<div class="box-content padded">

					<div class="admin-item">
						<div class="admin-item-left">

							<div class="admin-item-name">
								Notifications
							</div>

							<div class="admin-item-desc">
								how restaurants are notified of orders
							</div>
						</div>

						<div class="admin-item" id="order-notifications-sent-container">
							<div class="admin-item-left">
								<div class="admin-item-name">
									Order Notifications Sent to Restaurant?
								</div>

								<div class="admin-item-desc"></div>
							</div>

							<div class="admin-item-right">
								<div class="admin-item-col-small" id="restaurant-order-notifications-sent-container"></div>
							</div>
						</div>

						<br/>

						<div class="admin-item-right">
							<div class="admin-item-col-x-wide" id="notifications-container"></div>

							<div class="admin-item-col-med">
								<div class="admin-button-workflow" id="add-notification">
									add another method
								</div>
							</div>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Timezone Where the Restaurant Is
							</div>

							<div class="admin-item-desc">
								if you screw this up, you will die
							</div>
						</div>

						<div class="admin-item-right">
							<select id="restaurant-timezone">
								<option value="America/New_York">
									Eastern
								</option>

								<option value="America/Chicago">
									Central
								</option>

								<option value="America/Denver">
									Mountain
								</option>

								<option value="America/Los_Angeles">
									Pacific
								</option>

								<option value="America/Phoenix">
									Mountain (Arizona)
								</option>

							</select>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Make active for the restaurant to input orders by themselves into our system?
							</div>

							<div class="admin-item-desc">
								(cockpit.la)
							</div>

						</div>

						<div class="admin-item-right">
							<div class="admin-item-col-small" id="restaurant-active-restaurant-order-placement-container"></div>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Display on Choose Restaurant Page When Closed?
							</div>
						</div>

						<div class="admin-item-right">
							<div class="admin-item-col-small" id="restaurant-show-when-closed-container"></div>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Hours
							</div>

							<div class="admin-item-desc">
								e.g. “12 PM - 2:30 AM”
							</div>

							<div class="admin-item-desc">
								use a comma for multiple time segments
							</div>

							<div class="admin-item-desc">
								e.g. “11 am - 1:30 PM, 2:15 PM - 1 AM”
							</div>

							<div class="admin-item-desc">
								If Crunchbutton drivers do the delivery, hours are the intersection of the restaurants hours and Crunchbutton delivery hours.
							</div>
							<div class="admin-item-desc">
								Don’t forget to include a buffer for closing, if appropriate.
							</div>
						</div>

						<div class="admin-item-right" id="restaurant-hours">
							<div class="admin-item-right-row">
								<div class="admin-item-col-wide">
									<input id="restaurant-hours-mon" type="input">
								</div>

								<div class="admin-item-col-small">
									Monday
								</div>

								<div class="admin-item-col-med"></div>
							</div>

							<div class="admin-item-right-row">
								<div class="admin-item-col-wide">
									<input id="restaurant-hours-tue" type="input">
								</div>

								<div class="admin-item-col-small">
									Tuesday
								</div>

								<div class="admin-item-col-med">
									<div class="admin-button-workflow" id="copy-tue-from-mon">
										copy from Mon
									</div>
								</div>
							</div>

							<div class="admin-item-right-row">
								<div class="admin-item-col-wide">
									<input id="restaurant-hours-wed" type="input">
								</div>

								<div class="admin-item-col-small">
									Wednesday
								</div>

								<div class="admin-item-col-med">
									<div class="admin-button-workflow" id="copy-wed-from-tue">
										copy from Tue
									</div>
								</div>
							</div>

							<div class="admin-item-right-row">
								<div class="admin-item-col-wide">
									<input id="restaurant-hours-thu" type="input">
								</div>

								<div class="admin-item-col-small">
									Thursday
								</div>

								<div class="admin-item-col-med">
									<div class="admin-button-workflow" id="copy-thu-from-wed">
										copy from Wed
									</div>
								</div>
							</div>

							<div class="admin-item-right-row">
								<div class="admin-item-col-wide">
									<input id="restaurant-hours-fri" type="input">
								</div>

								<div class="admin-item-col-small">
									Friday
								</div>

								<div class="admin-item-col-med">
									<div class="admin-button-workflow" id="copy-fri-from-thu">
										copy from Thu
									</div>
								</div>
							</div>

							<div class="admin-item-right-row">
								<div class="admin-item-col-wide">
									<input id="restaurant-hours-sat" type="input">
								</div>

								<div class="admin-item-col-small">
									Saturday
								</div>

								<div class="admin-item-col-med">
									<div class="admin-button-workflow" id="copy-sat-from-fri">
										copy from Fri
									</div>
								</div>
							</div>

							<div class="admin-item-right-row">
								<div class="admin-item-col-wide">
									<input id="restaurant-hours-sun" type="input">
								</div>

								<div class="admin-item-col-small">
									Sunday
								</div>

								<div class="admin-item-col-med">
									<div class="admin-button-workflow" id="copy-sun-from-sat">
										copy from Sat
									</div>
								</div>
							</div>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Transactions
							</div>
						</div>

						<div class="admin-item-right">
							<div class="admin-item-col-small">
								Cash

								<div id="restaurant-cash-container"></div>
							</div>

							<div class="admin-item-col-small">
								Credit

								<div id="restaurant-credit-container"></div>
							</div>

							<div class="admin-item-col-small">
								Gift card

								<div id="restaurant-any-gift-card-container">
								</div>
							</div>

							<div class="admin-item-col-small">
								Fee on Subtotal Only?

								<div id="restaurant-fee_on_subtotal-container">
								</div>
							</div>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Delivery Options
							</div>

							<div class="admin-item-desc"></div>
						</div>

						<div class="admin-item-right">
							<div class="admin-item-col-small">
								<div class="admin-item-label">
									Delivery
								</div>

								<div id="restaurant-delivery-container"></div>
							</div>

							<div class="admin-item-col-small">
								<div class="admin-item-label">
									Delivery minimum ($)
								</div><input id="restaurant-delivery-min" type="input">
							</div>

							<div class="admin-item-col-small">
								<div class="admin-item-label">
									Based on
								</div><select id="restaurant-delivery-min-amt">
									<option value="subtotal">
										Subtotal
									</option>

									<option value="total">
										Total
									</option>
								</select>
							</div>

							<div class="admin-item-col-small">
								<div class="admin-item-label">
									Delivery fee ($)
								</div><input id="restaurant-delivery-fee" type="input">
							</div>

							<div class="admin-item-col-small">
								<div class="admin-item-label">
									Radius (miles)
								</div><input id="restaurant-delivery-radius"
								type="input">
							</div>

							<div class="admin-item-col-small">
								<div class="admin-item-label">
									Est. delivery time (minutes)
								</div><input id="restaurant-delivery-estimated-time" type="input">
							</div>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Takeout Options
							</div>

							<div class="admin-item-desc"></div>
						</div>

						<div class="admin-item-right">
							<div class="admin-item-col-small">
								<div class="admin-item-label">
									Takeout
								</div>

								<div id="restaurant-takeout-container"></div>
							</div>

							<div class="admin-item-col-small">
								<div class="admin-item-label">
									Est. takeout time (minutes)
								</div><input id="restaurant-pickup-estimated-time" type="input">
							</div>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Taxes and Fees
							</div>

							<div class="admin-item-desc"></div>
						</div>

						<div class="admin-item-right">
							<div class="admin-item-col-small">
								Restaurant fee (%) <input id="restaurant-fee-restaurant" type="input">
							</div>

							<div class="admin-item-col-small">
								Customer fee (always leave 0) <input id="restaurant-fee-customer" type="input">
							</div>

							<div class="admin-item-col-small">
								Tax charged (%) <input id="restaurant-tax" type="input">
							</div>

							<div class="admin-item-col-small">
								<div class="admin-item-label">
									Delivery service percent markup
								</div><input id="restaurant-delivery-service-markup" type="input">
							</div>
						</div>
					</div><!--
				<div class=admin-item>
					<div class=admin-item-left>
						<div class=admin-item-name>Sorting</div>
						<div class=admin-item-desc>
							see <a href='https://github.com/crunchbutton/crunchbutton/issues/787#issuecomment-15988987' target='_blank'>here</a> for explanation
						</div>
					</div>
					<div class=admin-item-right>
						<div class=admin-item-col-small>
							Sort weight adjustment
							<input type=input id=restaurant-weight-adj />
						</div>
					</div>
				</div>
			-->

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Summary Method
							</div>
							<div class="admin-item-desc"></div>
						</div>

						<div class="admin-item-right">
							<select id="restaurant-summary_method">
								<option value=""></option>
								<option value="fax">Fax</option>
								<option value="email">Email</option>
							</select>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Payment Method
							</div>
							<div class="admin-item-desc"></div>
						</div>
						<div class="admin-item-right">
							<select id="restaurant-payment_method">
								<option value=""></option>
								<option value="check">Check</option>
								<option value="deposit">Deposit</option>
							</select>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Actions
							</div>

							<div class="admin-item-desc">
								ignore this if you’re a Brand Representative
							</div>
						</div>

						<div class="admin-item-right">
							<div class="admin-item-col-med">
								<a class="button-pay" target='_blank'>
								<div class="admin-button-workflow">
									send payment
								</div></a>
							</div>

							<div class="admin-item-col-med">
								<a class="button-fax" target='_blank'>
								<div class="admin-button-workflow">
									send a fax
								</div></a>
							</div>
						</div>
					</div>

				</div>
			</div>


			<div class="box">
				<a id="menu" name="menu"></a>

				<div class="box-header">
					<span class="title">Menu</span>
				</div>

				<div class="padded">
					<a class="btn btn-blue" data-toggle="modal" href="#modal-curation">
					<i class="icon-info-sign"></i>
					Curation instructions</a>
				</div>

				<div class="box-content padded">
					<div id="restaurant-menu-container"></div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-button-workflow" id="add-menu-category">
								add another category
							</div>
						</div>
					</div><!--
				<div class=admin-item>
					<div class=admin-item-left>
						<div class=admin-item-name>Full Menu</div>
						<div class=admin-item-desc></div>
					</div>
					<div class=admin-item-right id=restaurant-menu-container>
					</div>
				</div>
				-->
				</div>
			</div>

			<div class="box">
				<a id="notes" name="notes"></a>

				<div class="box-header">
					<span class="title">Notes on Restaurant (optional)</span>
				</div>

				<div class="box-content padded">
					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Restaurant Email or Owner’s Email
							</div>

							<div class="admin-item-desc"></div>
						</div>

						<div class="admin-item-right">
							<input id="restaurant-email" type="input">
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								General Notes
							</div>

							<div class="admin-item-desc"></div>
						</div>

						<div class="admin-item-right">
							<textarea id="restaurant-notes"></textarea>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Notes to Driver
							</div>

							<div class="admin-item-desc"></div>
						</div>

						<div class="admin-item-right">
							<textarea id="notes-to-drivers"></textarea>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								TODO
							</div>

							<div class="admin-item-desc"></div>
						</div>

						<div class="admin-item-right">
							<textarea id="restaurant-notes-todo"></textarea>
						</div>
					</div>

					<div class="admin-item">
						<div class="admin-item-left">
							<div class="admin-item-name">
								Owner’s name, phone number, best times to reach him and notes on his personality, attitude towards Crunchbutton
							</div>

							<div class="admin-item-desc"></div>
						</div>

						<div class="admin-item-right">
							<textarea id="restaurant-notes-owner"></textarea>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<!-- // end restaurants page -->

	<div id="admin-body-content">
		<!-- floating things -->

		<div id="float-bottom-right-container">
			<div class="admin-button" id="save-button">
				Loading
			</div>
		</div>

		<div id="float-bottom-left-container">
			<div id="admin-msg"></div>
		</div>
	</div><!-- templates -->

	<div class="template-container">
		<div class="admin-toggle-active" id="toggle-template">
			active
		</div>

		<div class="admin-notifications" id="notifications-template"></div>

		<div class="admin-notification" id="notification-template">
			<div class="admin-item-col-small">
				<div class="admin-toggle-active"></div>
			</div>

			<div class="admin-item-col-med-2 restaurant-notification">
				<select name="type">
					<option value="fax">Fax</option>
					<option value="sms">Text Message</option>
					<option value="email">Email</option>
					<option value="phone">Phone Call</option>
					<option value="url">URL Request</option>
					<option value="confirmation">Confirmation Phone Call</option>
					<option value="admin">Admin</option>
					<option value="stealth">Stealth fax</option>
				</select>
			</div>

			<div class="admin-item-col-med-2">

				<input name="val" type="input">

				<select name="id_admin" style="display:none;">
					<option value="">Choose the admin</option>
					<?php
					$admins = Crunchbutton_Admin::getAdminsWithNotifications();
					if( $admins->count() > 0 ){
						foreach( $admins as $admin ){
							echo "<option value='{$admin->id_admin}'>{$admin->name}</option>";
						}
					}
					?>
				</select>

				<select name="confirmation_type" style="display:none;">
					<option value="regular">Regular</option>
					<option value="stealth">Stealth Confirmation</option>
				</select>

			</div>

		</div>

		<div class="admin-menu" id="menu-template">
			<div class="admin-menu-categories"></div>
		</div>

		<div class="admin-menu-category admin-item" id="menu-category-template">
			<div class="admin-item-left">
				<input class="admin-menu-category-id" type="hidden">
				<input class="admin-menu-category-loc" type="hidden">
				<input class="admin-menu-category-sort" type="hidden">
				<input class="admin-menu-category-name" placeholder="Category name" type="input">

				<div class="hr"></div>

				<div class="admin-button-workflow add-menu-dish">
					add dish
				</div>&nbsp;

				<div class="admin-button-workflow delete-menu-category">
					delete category
				</div>&nbsp;

				<div class="hr"></div>

				<div class="move_category_up sprite-arrow_up" title="Move this category up"></div>

				<div class="move_category_down sprite-arrow_down" title="Move this category down"></div>
			</div>

			<div class="admin-item-right restaurant-dishes-container"></div>
		</div>

		<div class="admin-menu-dish" id="menu-dish-template">
			<input class="admin-menu-dish-active-id" type="hidden">
			<input class="admin-menu-dish-id" type="hidden"> <input class="admin-menu-dish-id_dish" type="hidden"> <input class="admin-menu-dish-sort" type="hidden"> <input class="admin-menu-dish-top" type="hidden"> <input class="admin-menu-dish-top_name" type="hidden"> <input class="admin-menu-dish-image" type="hidden"> <!-- expose this field? -->

			<div class="admin-item-col-small">
				<div class="admin-menu-dish-active-button"></div>
			</div>

			<div class="admin-item-col-med-2">
				<input class="admin-menu-dish-name" placeholder="Dish name"
				type="input">
			</div>

			<div class="admin-item-col-small">
				$ <input class="admin-menu-dish-price" placeholder="$" style="width:70%" type="input">
			</div>

			<div class="admin-item-col-small">
				<div class="admin-button-workflow-fit details-button">
					expand details
				</div>
			</div>

			<div class="admin-item-col-no-pad vertical-middle">
				<div class="move_dish_up sprite-arrow_up" title="Move this dish up"></div>

				<div class="move_dish_down sprite-arrow_down" title="Move this dish down"></div>

				<div class="dish_lightning sprite-bolt" title="Copy this dish or its options"></div>

				<div class="delete-menu-dish sprite-x_alt" title="Delete this dish"></div>
			</div>

			<div class="admin-item-right hidden admin-menu-dish-details">
				<span><strong>Description (required)</strong></span><br>
				<span class="description-warning">60</span> characters remaining (before text is cut off)
				<input class="small admin-menu-dish-description" maxlength="60" type="text">

				<div class="admin-option-group-hr"></div>

				<div class="admin-item-col-fit">
					<label><input class="admin-menu-dish-expand-view" type="checkbox">
					Expanded view when added to cart (for when you want the user to see options, like sizes and pizza toppings)</label>
					<label><input class="admin-menu-dish-top-item" type="checkbox"> Show STAR (usually just for items in the first category on the menu)</label>
				</div>

				<div class="admin-option-group-hr"></div>

				<div class="admin-item-col-med">
					<div class="admin-button-workflow-fit add-checkbox-option">
						add checkbox option
					</div>
				</div>

				<div class="admin-item-col-med">
					<div class="admin-button-workflow-fit add-option-group">
						add dropdown option
					</div>
				</div>

				<div class="admin-option-group-hr"></div>

				<div class="dish-option-groups-container"></div>
			</div>
		</div>

		<div class="admin-menu-option-group" id="menu-option-group-template">
			<input class="admin-menu-option-group-id" type="hidden">
			<input class="admin-menu-option-group-id_dish_option" type="hidden">
			<input class="admin-menu-option-group-id_option" type="hidden">
			<input class="admin-menu-option-group-id_option_parent" type="hidden">
			<input class="admin-menu-option-group-id_restaurant" type="hidden">
			<input class="admin-menu-option-group-sort" type="hidden">
			<input class="admin-menu-option-group-price" placeholder="$" type="hidden">

			<div class="admin-item-col-med-2">
				<input class="admin-menu-option-group-name" placeholder="Option name" type="input">
			</div>

			<div class="hidden">
				<select class="admin-menu-option-group-type">
					<option selected value="select">
						Choose one
					</option>

					<option value="check">
						Choose many
					</option>
				</select>
			</div>

			<div class="admin-item-col-fit vertical-middle">
				<div class="move_option_group_up sprite-arrow_up" title="Move this option up"></div>

				<div class="move_option_group_down sprite-arrow_down" title="Move this option down"></div>

				<div class="delete-option-group sprite-x_alt" title="Delete this option"></div>
			</div><input class="admin-menu-option-group-description" placeholder="Description" type="hidden"><br>

			<div class="admin-menu-options-container"></div>

			<div class="admin-item-col-wide not-visible-for-basic-option-group">
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

				<div class="admin-button-workflow add-option">
					add another value
				</div>
			</div>

			<div class="admin-option-group-hr"></div>
		</div>

		<div class="admin-menu-option" id="menu-option-template">
			&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input class="admin-menu-option-id" type="hidden"> <input class="admin-menu-option-id_dish_option" type="hidden"> <input class="admin-menu-option-id_option" type="hidden"> <input class="admin-menu-option-id_restaurant" type="hidden"> <input class="admin-menu-option-description" type="hidden"> <input class="admin-menu-option-sort" type="hidden"> <label></label>

			<div class="admin-item-col-no-pad">
				<label><input class="admin-menu-option-default" title="Option is selected by default" type="checkbox"></label>
			</div><label></label>

			<div class="admin-item-col-med">
				<input class="admin-menu-option-name" placeholder="Option name" type="input">
			</div>

			<div class="admin-item-col-med">
				additional $$ amount <input class="admin-menu-option-price" placeholder="$" style="width:70%" type="input">
			</div>

			<div class="admin-item-col-fit vertical-middle">
				<div class="move_option_up sprite-arrow_up" title="Move this option up"></div>

				<div class="move_option_down sprite-arrow_down" title="Move this option down"></div>

				<div class="delete-option sprite-x_alt" title="Delete this option"></div>
			</div>
		</div>

		<div id="admin-dish-lightning-modal">
			<div class="admin-modal-title">
				Dish
			</div>

			<div class="admin-modal-item">
				<div class="admin-modal-explanation">
					Move this dish to a different category
				</div>&nbsp;&nbsp;

				<div class="admin-modal-right">
					<select class="move-dish-to-category-select"></select> &nbsp;&nbsp;

					<div class="move-dish-to-category-button admin-button-workflow">
						move
					</div>
				</div>
			</div>
<!--
			<div class="admin-modal-item">
				<div class="admin-modal-explanation">
					Create a new <b>linked</b> copy of this dish in the same or another
					category.
				</div>&nbsp;&nbsp;

				<div class="admin-modal-right">
					<select class="copy-dish-to-category-select"></select> &nbsp;&nbsp;

					<div class="copy-dish-to-category-button admin-button-workflow">
						copy &amp; link
					</div>
				</div>
			</div>
-->
			<!--
		<div class=admin-modal-item>
			<div class=admin-modal-explanation>
				Copy the options for this dish to another dish, and keep them linked (option names and prices stay synced).
			</div>
			&nbsp;&nbsp;
			<div class=admin-modal-right>
				<select class=copy-options-to-dish-linked-select></select>
				&nbsp;&nbsp;
				<div class="copy-options-to-dish-linked-button admin-button-workflow">copy</div>
			</div>
		</div>
		 -->

			<div class="admin-modal-item">
				<div class="admin-modal-explanation">
					Copy the options for this dish to another dish, and <b>unlink</b> them (option names and prices can be changed independently).
				</div>&nbsp;&nbsp;

				<div class="admin-modal-right">
					<select class="copy-options-to-dish-unlinked-select"></select> &nbsp;&nbsp;

					<div class="copy-options-to-dish-unlinked-button admin-button-workflow">
					copy
					</div>
				</div>
			</div>

			<div class="admin-modal-item">
				<div class="admin-modal-right">
					<div class="lightning-cancel admin-button-workflow">
						do nothing
					</div>
				</div>
			</div>
		</div>
	</div>

	<div class="modal hide fade" id="modal-curation" style="display: none;">
		<div class="modal-header">
			<button class="close" data-dismiss="modal" type="button">×</button>

			<h6 id="modal-tablesLabel">Curation instructions</h6>
		</div>

		<div class="modal-body">
			<h4>Categories and Dishes</h4>

			<ul>
				<li>Put the top 1-3 dishes in the first category, usually
				titled “Recommended Order”</li>
				<li>Except at Pizza restaurants, where the first category should be titled “Pizza” and include all the size options as separate food items, with basic options for all toppings they can add</li>
				<li>Make “Drinks” the last category</li>
				<li>Have a “Vegetarian” category, if possible</li>
				<li>Don't include a category called "Miscellaneous" or "Other" - every category should have a clear theme</li>
				<li>No more than 4-5 items in a category (except sushi)</li>
				<li>Keep item names short and visually pleasing</li>
				<li>When possible, it should be obvious what an item is without having to check the description</li>
			</ul>

			<h4>Options</h4>

			<ul>
				<li>Use Checkbox options for things like toppings and Dropdown options for things like sizes and flavors of Nantucket Nectar
					<ul>
						<li>Dropdown options are used for sizes and other situations in which only 1 of a set of options can be chosen, like a flavor of Nantucket Nectar.</li>
						<li>Checkboxes are for basic included options (like toppings) and additional optional options.
							<ul>
								<li>For basic included options, save them Default Checked.</li>
								<li>For additional optional options, save them Default Unchecked.</li>
								<li>E.G. on an item called BLT Sandwich
									<ul>
										<li>make these options default checked: Bacon, Lettuce, Tomato</li>
										<li>make these options default unchecked: Add Hot Sauce, Add Avocado</li>
									</ul>
								</li>
							</ul>
						</li>
					</ul>
				</li>
			</ul>

			<ul>
				<li>If it is unclear what a dish is, and the description is too long, then use checkbox options to list all the toppings/ingredients in the dish, ie “Lomo Saltado” would have 5 separate checkbox options, all checked by default, Red Onions, Cilantro, Tomatoes, Steamed Rice, and French Fries</li>
				<li>The dish name should be self-explanatory without having to look at the category name (aka "Italian Sub" not just "Italian")</li>
			</ul>
		</div>

		<div class="modal-footer">
			<button class="btn btn-default" data-dismiss="modal">Close</button>
		</div>
	</div><!-- hour_override stuff -->

	<div class="modal hide fade" id="modal-hour_override" style=
	"display: none;">
		<div class="modal-header">
			<button class="close" data-dismiss="modal" type="button">×</button>

			<h6 id="modal-tablesLabel">Close times (holidays)</h6>
		</div>

		<div class="modal-body modal-hour_override-body"></div>

		<div class="modal-footer">
			<button class="btn btn-default" data-dismiss="modal">Close</button>
		</div>
	</div>

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false&key=AIzaSyDNJ0f3yxbeksuiQh0iG1_drBO1Mmhg_Bg"></script>
<script type="text/javascript" src="/assets/js/admin_restaurant.js?v=<?=$_ENV['HEROKU_SLUG_COMMIT']?>"></script>
<script type="text/javascript" src="/assets/js/intro.js?v=<?=$_ENV['HEROKU_SLUG_COMMIT']?>"></script>
<script>
$( document ).ready( function(){
	$('.modal-hour_override').click(function(e) {
		e.preventDefault();
		hour_override.load();
	} );

	$( '#restaurant-delivery-service-container' ).click( function(){
		isDeliveryServiceChecked();
	} );

	$( '#restaurant-id-community' ).change( function(){
		var value = $(this).val();
		getCommunityPosition( value );
	} );

} );

var community_pos = {};

function getCommunityPosition(){
	var id_community = $( '#restaurant-id-community' ).val();
	if( id_community ){
		var url = '/api/community/position/' + id_community;
		$.ajax( { url: url }).done( function( json ) { community_pos = json; calcCommunityDistance(); });
	}
}

function calcCommunityDistance(){

	if( community_pos.lat && community_pos.lon ){
		var restauran_lat = $( '#restaurant-lat' ).val();
		var restauran_lon = $( '#restaurant-lng' ).val();
		if( restauran_lat && restauran_lon ){

			var toRad = function( number ){
				return number * Math.PI / 180;
			}

			var km2Miles = function (km) {
				return km * 0.621371;
			}

			var calc = function() {
				try {
					var R = 6371; // Radius of the earth in km
					var dLat = toRad( restauran_lon - restauran_lat );
					var dLon = toRad( community_pos.lon - community_pos.lat );
					var a = Math.sin( dLat / 2 ) * Math.sin( dLat / 2 ) +
						Math.cos( toRad( restauran_lat ) ) * Math.cos( toRad( restauran_lon) ) * Math.sin( dLon / 2 ) * Math.sin( dLon / 2 );
					var c = 2 * Math.atan2( Math.sqrt( a ), Math.sqrt( 1 - a ) );
					var d = R * c;
					return km2Miles( d ).toFixed(2);
				} catch (e) {
					console.log( 'distance::error', e );
				}
			}

			var distance = calc();
			console.log('distance',distance);
			if( distance ){
				$( '#restaurant-community-distance' ).val( distance );
			} else {
				$( '#restaurant-community-distance' ).val( '' );
			}

		}
	} else {
		getCommunityPosition();
	}
}


function isDeliveryServiceChecked(){
	return;
	if( $( '#restaurant-delivery-service-container' ).text() == 'no' ){
		$( '#formal-relationship-container' ).hide();
	} else {
		$( '#formal-relationship-container' ).show();
	}
}
var _id_restaurant = '<?php echo $this->restaurant->id_restaurant?>';
var expanded_view_checked = <?php echo ( Crunchbutton_Config::getVal( 'cockpit-expanded-view-checked-as-default' ) == '1' ) ? '1' : '0'; ?>;
ADMIN.restaurant_init(<?php echo $this->restaurant->id_restaurant?>);
</script>