<div class="top-pad"></div>

<div class="content-padding" ng-if="ready">

	<div ng-if="result.id_payment_schedule">

		<h1 class="title left"><i class="fa fa-bank"></i>
			<span>{{result.title}} #{{result.id_payment_schedule}} - {{result.driver}}</span>
		</h1>

		<div class="divider"></div>

			<table class="tb-grid tb-zebra">

				<tbody>

					<tr ng-if="result.range_date">
						<td><strong>Period</strong></td>
						<td>{{result.range_date}}</td>
					</tr>

					<tr ng-if="result.payment_date">
						<td><strong>{{result.title}} Deposit Initiated</strong></td>
						<td>{{result.payment_date}}</td>
					</tr>

					<tr ng-if="result.expected_date">
						<td><strong>{{result.title}} Estimated Date In Your Account</strong></td>
						<td>{{result.expected_date}}</td>
					</tr>

					<tr>
						<td><strong>{{result.title}} method</strong></td>
						<td>{{result.payment_method}}</td>
					</tr>

					<tr ng-if="result.payment_date">
						<td>
							<strong>Summary sent date</strong>
						</td>
						<td>
							<span ng-if="result.summary_sent_date">{{result.summary_sent_date}}</span>
							<span ng-if="!result.summary_sent_date"><i>Summary not sent</i></span>
						</td>
					</tr>

					<tr class="transparent"><td></td><td></td></tr>

					<tr ng-if="result.driver_payment_hours && result.driver_payment_type != 'making_whole'">
						<td>Worked hours</td>
						<td><div class="summary-calc-values">${{result.shifts_hours_amount | formatPrice}}</div></td>
					</tr>

					<tr ng-if="result.driver_payment_type == 'making_whole'">
						<td><i>Worked hours</i></td>
						<td><div class="summary-calc-values">${{result.shifts_hours_amount | formatPrice}}</div></td>
					</tr>

					<tr ng-if="result.driver_payment_type == 'making_whole'" class="transparent"><td></td><td></td></tr>

					<tr ng-if="( !result.hourly || result.driver_payment_type == 'making_whole' ) && result.calcs.delivery_fee && pay_type_payment">
						<td>Delivery Commission</td>
						<td><div class="summary-calc-values">${{result.calcs.amount_per_order | formatPrice}}</div></td>
					</tr>

					<tr ng-if="( result.driver_payment_type == 'making_whole' || result.driver_payment_type == 'hours' || result.driver_payment_type == 'orders' ) && result.calcs.tip && pay_type_payment">
						<td>Tips</td>
						<td><div class="summary-calc-values">+ ${{result.calcs.tip | formatPrice}}</div></td>
					</tr>

					<tr ng-if="pay_type_payment && result.calcs.total_commissioned && result.driver_payment_type != 'making_whole'">
						<td>Delivery Commission</td>
						<td><div class="summary-calc-values">+ ${{result.calcs.total_commissioned | formatPrice}}</div></td>
					</tr>

					<tr ng-if="pay_type_payment && result.calcs.total_commissioned_tip && result.driver_payment_type != 'making_whole' && result.driver_payment_type != 'hours'">
						<td>Tips</td>
						<td><div class="summary-calc-values">+ ${{result.calcs.total_commissioned_tip | formatPrice}}</div></td>
					</tr>

					<tr ng-if="result.invites_amount">
						<td>New Invited Users</td>
						<td><div class="summary-calc-values">+ ${{result.invites_amount | formatPrice}}</div></td>
					</tr>

					<tr ng-if="result.adjustment">
						<td>Adjustments*</td>
						<td><div class="summary-calc-values">- ${{result.adjustment | formatPrice}}</div></td>
					</tr>

					<tr ng-if="result.driver_payment_type == 'making_whole' && result.calcs.delivery_fee_plus_tips">
						<td></td>
						<td><div class="summary-calc-values calcs-dash">&nbsp;&nbsp;${{result.calcs.delivery_fee_plus_tips | formatPrice}}</div></td>
					</tr>

					<tr ng-if="result.driver_payment_type == 'making_whole' && result.calcs.make_whole_amount">
						<td>Make Whole Amount</td>
						<td><div class="summary-calc-values">+ ${{result.calcs.make_whole_amount | formatPrice}}</div></td>
					</tr>

					<tr ng-if="pay_type_payment && result.calcs.total_commissioned && result.driver_payment_type == 'making_whole'">
						<td>(Commissioned Orders) Delivery Commission</td>
						<td><div class="summary-calc-values">+ ${{result.calcs.total_commissioned | formatPrice}}</div></td>
					</tr>
					<tr ng-if="pay_type_payment && result.calcs.total_commissioned_tip && result.driver_payment_type == 'making_whole'">
						<td>(Commissioned Orders) Tips</td>
						<td><div class="summary-calc-values">+ ${{result.calcs.total_commissioned_tip | formatPrice}}</div></td>
					</tr>

					<tr ng-show="result.show_money_make_week">
						<td>Total Money Made This Week</td>
						<td><div class="summary-calc-values calcs-dash">&nbsp;&nbsp;${{result.calcs.earnings | formatPrice}}</div></td>
					</tr>

					<tr ng-if="result.calcs.delivery_fee_collected && pay_type_payment">
						<td>Delivery Fee Already Collected in Cash</td>
						<td><div class="summary-calc-values">- ${{result.calcs.delivery_fee_collected | formatPrice}}</div></td>
					</tr>

					<tr ng-if="result.calcs.markup && pay_type_payment">
						<td>Crunchbutton’s Markup Already Collected In Cash</td>
						<td><div class="summary-calc-values">- ${{result.calcs.markup | formatPrice}}</div></td>
					</tr>

					<tr ng-if="result.calcs.customer_fee_collected && pay_type_payment">
						<td>Customer Fee Already Collected In Cash</td>
						<td><div class="summary-calc-values">- ${{result.calcs.customer_fee_collected | formatPrice}}</div></td>
					</tr>

					<tr ng-if="result.total_payment && pay_type_payment">
						<td>Total Deposited</td>
						<td><div class="summary-calc-values" ng-class="{'calcs-dash':result.has_stuff_to_remove}">${{result.total_payment | formatPrice}}</div></td>
					</tr>

					<tr ng-if="result._total_reimburse_ && pay_type_reimbursement">
						<td>Reimbursement</td>
						<td>${{result._total_reimburse_ | formatPrice}}</td>
					</tr>

					<tr ng-if="result.adjustment" class="transparent"><td></td><td></td></tr>

					<tr ng-if="result.adjustment">
						<td>*Cash Already Collected From Orders Paid With Pex Card</td>
						<td></td>
					</tr>

					<?php /* ?>
					<tr ng-if="result.adjustment_note">
						<td>Adjustments Note</td>
						<td>{{result.adjustment_note}}</td>
					</tr>
					<?php */ ?>

				</tbody>
			</table>

			<br/>

			<table class="tb-grid tb-zebra" ng-if="result.shifts.length">
				<thead>
					<tr>
						<td colspan="4" class="title">Shifts</td>
					</tr>
				</thead>
				<thead>
					<tr>
						<td></td>
						<td></td>
						<td></td>
						<td></td>
					</tr>
				</thead>
				<thead>
					<tr>
						<td>Started at</td>
						<td>Finished at</td>
						<td>Hours</td>
						<td>Amount</td>
					</tr>
				</thead>
				<tbody>
					<tr ng-repeat="shift in result.shifts">
						<td>{{shift.period.start}}</td>
						<td>{{shift.period.end}}</td>
						<td>{{shift.hours}}</td>
						<td>
							<span ng-if="!shift.created_by_driver">${{shift.amount | formatPrice}}</span>
							<span ng-if="shift.created_by_driver">$0.00</span>
						</td>
					</tr>
				</tbody>
				<tbody>
					<tr class="transparent">
						<td></td>
						<td></td>
						<td></td>
						<td></td>
					</tr>
					<tr class="transparent">
						<td></td>
						<td>Total By Hours</td>
						<td>${{result.shifts_hours_amount | formatPrice}}</td>
						<td></td>
					</tr>
				</tbody>
			</table>

		<br/>

		<table class="tb-grid tb-zebra" ng-if="result.invites.length">
			<thead>
				<tr>
					<td colspan="3" class="title">New Invited Users</td>
				</tr>
			</thead>
			<thead>
				<tr>
					<td></td>
					<td></td>
					<td></td>
				</tr>
			</thead>
			<thead>
				<tr>
					<td>Customer Name</td>
					<td>First Order At</td>
					<td>Amount</td>
				</tr>
			</thead>
			<tbody>
				<tr ng-repeat="invite in result.invites">
					<td>{{invite.user.name}}</td>
					<td>{{invite.date}}</td>
					<td>$ {{invite.amount | formatPrice}}</td>
				</tr>
			</tbody>
				<tbody>
					<tr class="transparent">
						<td></td>
						<td></td>
						<td></td>
					</tr>
					<tr class="transparent">
						<td></td>
						<td>Total By Invited Users</td>
						<td>${{result.invites_amount | formatPrice}}</td>
					</tr>
				</tbody>
		</table>

		<br/>

		<table class="tb-grid tb-zebra">
			<thead ng-if="result.orders.included.length">
				<tr>
					<td colspan="9" class="title">Orders</td>
				</tr>
			</thead>
			<thead ng-if="result.orders.included.length">
				<tr>
					<td class="hide-tiny-screen">#</td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
			</thead>
			<thead ng-if="result.orders.included.length">
				<tr>
					<td class="hide-tiny-screen">Order #</td>
					<td>
						<span class="hide-tiny-screen">Customer</span>
						<span class="show-tiny-screen">Order #/<br>Customer</span>
					</td>
					<td>Restaurant</td>
					<td>Date</td>
					<td>
						<span ng-if="pay_type_payment && result.show_credit_card_tips">Tip</span>
					</td>
					<td>
						<span ng-if="pay_type_payment && ( !result.hourly || result.driver_payment_type == 'making_whole' ) && result.show_delivery_fees">Delivery<br>Commission</span>
					</td>
					<td>Delivery Fee Already<br>Collected in Cash</td>
					<td>Markup Already<br>Collected in Cash</td>
					<td ng-if="pay_type_reimbursement">Reimburse</td>
					<td>
						<span ng-if="pay_type_payment && ( !result.hourly || result.driver_payment_type == 'making_whole' )">Money Made</span>
					</td>
				</tr>
			</thead>
			<tbody ng-if="result.orders.included">
				<tr ng-repeat="order in result.orders.included" ng-if="!order.force_to_be_commissioned">
					<td class="hide-tiny-screen">{{order.id_order}}</td>
					<td>
						<span class="hide-tiny-screen">{{order.name}}</span>
						<span class="show-tiny-screen">#{{order.id_order}}<br>{{order.name}}</span>
					</td>
					<td>{{order.restaurant}}</td>
					<td>{{order.date}}</td>
					<td><span ng-if="pay_type_payment && result.show_credit_card_tips">${{order.tip | formatPrice}}</span></td>
					<td>
						<span ng-if="pay_type_payment && ( !result.hourly || result.driver_payment_type == 'making_whole' ) && result.show_delivery_fees">${{order.amount_per_order | formatPrice}}</span>
					</td>
					<td>${{order.delivery_fee_collected | formatPrice}}</td>
					<td>
						<span ng-if="order.markup < 0">${{order.markup | formatPrice}}</span>
						<span ng-if="order.markup >= 0">$0.00</span>
					</td>
					<td ng-if="pay_type_reimbursement">${{order.total_reimburse | formatPrice}}</td>
					<td ng-if="pay_type_payment">
						<span ng-if="( !result.hourly || result.driver_payment_type == 'making_whole' )">
							${{order.total_payment | formatPrice}}
						</span>
					</td>
				</tr>
			</tbody>
			<tbody>
				<tr class="transparent">
					<td class="hide-tiny-screen"></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
			</tbody>
		</table>

		<br>

		<table class="tb-grid tb-zebra" ng-if="pay_type_payment && result.has_commissioned_order">
			<thead ng-if="result.orders.included.length">
				<tr>
					<td colspan="9" class="title">Commissioned Orders</td>
				</tr>
			</thead>
			<thead ng-if="result.orders.included.length">
				<tr>
					<td class="hide-tiny-screen">#</td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
			</thead>
			<thead ng-if="result.orders.included.length">
				<tr>
					<td class="hide-tiny-screen">Order #</td>
					<td>
						<span class="hide-tiny-screen">Customer</span>
						<span class="show-tiny-screen">Order #/<br>Customer</span>
					</td>
					<td>Restaurant</td>
					<td>Date</td>
					<td>Tip</td>
					<td>Delivery<br>Commission</td>
					<td>Delivery Fee Already<br>Collected in Cash</td>
					<td>Markup Already<br>Collected in Cash</td>
					<td>Money Made</td>
				</tr>
			</thead>
			<tbody ng-if="result.orders.included">
				<tr ng-repeat="order in result.orders.included" ng-if="order.force_to_be_commissioned">
					<td class="hide-tiny-screen">{{order.id_order}}</td>
					<td>
						<span class="hide-tiny-screen">{{order.name}}</span>
						<span class="show-tiny-screen">#{{order.id_order}}<br>{{order.name}}</span>
					</td>
					<td>{{order.restaurant}}</td>
					<td>{{order.date}}</td>
					<td>${{order.tip | formatPrice}}</td>
					<td>${{order.amount_per_order | formatPrice}}</td>
					<td>${{order.delivery_fee_collected | formatPrice}}</td>
					<td>
						<span ng-if="order.markup < 0">${{order.markup | formatPrice}}</span>
						<span ng-if="order.markup >= 0">$0.00</span>
					</td>
					<td>${{order.total_payment | formatPrice}}</td>
				</tr>
			</tbody>
			<tbody>
				<tr class="transparent">
					<td class="hide-tiny-screen"></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
					<td></td>
				</tr>
			</tbody>
		</table>


		<table class="tb-grid tb-zebra">
				<tbody>

					<tr ng-if="result.id_payment">
						<td><strong>{{result.title}} ID</strong></td>
						<td>
							# {{result.id_payment}}
						</td>
					</tr>
					<tr ng-if="result.id_payment_schedule">
						<td><strong>{{result.title}} Schedule ID</strong></td>
						<td>
							# {{result.id_payment_schedule}}
						</td>
					</tr>
					<tr ng-if="result.balanced_id">
						<td><strong>Balanced Reference</strong></td>
						<td>{{result.balanced_id}}</td>
					</tr>
					<tr ng-if="result.stripe_id">
						<td><strong>Stripe</strong></td>
						<td>{{result.stripe_id}}</td>
					</tr>
				</tbody>
			</table>

	</div>

	<div ng-if="!result.id_payment_schedule" class="box-content">
			Nothing here.
	</div>

</div>

<spinner-loading></spinner-loading>
<hack-expand-content></hack-expand-content>