
<table width="100%" celpadding="0" cellspacing="0" class="stealthfax-community">
	<tr>
		<td>
			<?=$order->restaurant()->communityNames();?> Student Order
		</td>
		<td style="text-align:right;">
			Ref. # <?php echo $order->id_order; ?>
		</td>
	</tr>
</table>

<table width="100%" celpadding="0" cellspacing="0" class="stealthfax-top">
	<tr>
		<td class="stealthfax-top-label">
			Date
		</td>
		<td class="stealthfax-top-label">
			Student
		</td>
		<td class="stealthfax-top-label">
			Phone
		</td>
		<td class="stealthfax-top-label stealthfax-top-content-last">
			Pickup Time
		</td>
	</tr>
	<tr>
		<td class="stealthfax-top-content">
			<?=$order->date()->format('D, M jS Y, h:i a T')?>
		</td>
		<td class="stealthfax-top-content">
			<?=$order->name?>
		</td>
		<td class="stealthfax-top-content">
			<?php /* instead of sending customer's phone number in stealth faxes, make the phone number 646-783-1444 #2819 */ ?>
			646-783-1444
		</td>
		<td class="stealthfax-top-content stealthfax-top-content-last">
			<?=$order->expectedByStealthFax()->format('h:i a')?>
		</td>
	</tr>
</table>

<br /><br />

<h1 class="stealthfax-takeout-message">
	Takeout - Student Will Pay In-Store
</h1>

<br />

<? if ($order->notes) : ?>
	<h2>NOTES:<br />
		<?=nl2br(strip_tags($order->notes))?>
	</h2><br />
<? endif ; ?>

<br />

<table width="100%" celpadding="0" cellspacing="0" class="stealthfax-grid">
	<thead style="font-weight:bold">
		<td class="stealthfax-grid">Qty</td>
		<td class="stealthfax-grid">Item</td>
	</thead>
	<?
	$dishes = $order->dishes( true );
	foreach ( $dishes as $dish) : ?>
		<tr>
			<td class="stealthfax-grid">1</td>
			<td class="stealthfax-grid"><?

				$food = $dish->dish()->name;

				$options = $dish->options();

				if (gettype($options) == 'array') {
					$options = i::o($options);
				}

				$withOptions = '';

				$dish = Dish::o( $dish->id_dish );

				$checkOptions = [];
				foreach ( $options as $option ) {
					$checkOptions[ $option->id_option ] = true;
				}

				foreach( $dish->options() as $option ){
					if( $checkOptions[ $option->id_option ] ){
						if( $option->id_option_parent ){
							$optionGroup = Crunchbutton_Option::o( $option->id_option_parent );
							if( $optionGroup->type == 'select' ){
								$withOptions .= $optionGroup->name . ': ';
								$withOptions .= $option->name.', ';
							}
						}
					}
				}

				foreach( $dish->options() as $option ){
					if( $checkOptions[ $option->id_option ] ){
						if( $option->id_option_parent ){
							$optionGroup = Crunchbutton_Option::o( $option->id_option_parent );
							if( $optionGroup->type != 'select' ){
								$withOptions .= '&nbsp;';
								$withOptions .= $optionGroup->name . ': ';
								$withOptions .= $option->name.', ';
							}
						} else {
							$withOptions .= '&nbsp;';
							$withOptions .= $option->name.', ';
						}
					} else {
						if( $option->default ){
							if( $option->id_option_parent ){
								continue;
							}
							$withOptions .= '&nbsp;';
							$withOptions .= 'NO ' . $option->name.', ';
						}
					}
				}

				if( $withOptions != '' ){
					$withOptions = substr( $withOptions, 0, -2 );
				}

				?>
				<?=$food?> <i style="font-weight:600;"><?php echo $withOptions; ?></i>
			</td>
		</tr>

	<? endforeach ; ?>
</table>
<table width="100%" celpadding="0" cellspacing="0">
	<tr>
		<td class="stealthfax-not-receipt">This is not a receipt</td>
	</tr>
</table>