<?php
	Assets::add( 'order-front.min.js' );
	// Assets::add( 'begin.css' );
	// Assets::add( 'momentjs' );
	AMIB::add_js_translation( trans( 'order.js-msgs' ) );
?>

<?php $__env->startSection( 'head' ); ?>
	<script>
		var deleteUrl = '<?php echo route( "delete-detail-ajax" ); ?>';
	</script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection( 'content' ); ?>
	<div id="main-content" class="cc padding">
		<h1><?php echo e($page_title); ?></h1>
		
		<?php echo error_html( $errors ); ?>

		
		<?php if( count( $order->Details ) ): ?>
			<table class="default" id="orders-table">
				<thead>
					<tr>
						<th><?php echo trans( 'main.row' ); ?></th>
						<th><?php echo trans( 'order.detail.type' ); ?></th>
						<th><?php echo trans( 'order.detail.product' ); ?></th>
						<th><?php echo trans( 'order.detail.price' ); ?></th>
						<th></th>
					</tr>
				</thead>
				
				<tfoot>
					<tr>
						<td colspan="3"><?php echo trans( 'order.total' ); ?></td>
						<td><?php echo en2fa( number_format( $order->total ) ); ?></td>
						<td></td>
					</tr>
				</tfoot>
				
				<tbody>
					<?php $row = 0; ?>
					<?php foreach( $order->Details as $detail ): ?>
						<tr data-id="<?php echo $detail->id; ?>">
							<td><?php echo en2fa( ++$row ); ?></td>
							<td><?php echo $detail->product_type_text; ?></td>
							<td><?php echo $detail->Product->name; ?><?php echo $detail->get_data( 'package_id' ) ? ' <i class="fa fa-th-large"></i>' : ''; ?></td>
							<td><?php echo en2fa( number_format( $detail->price ) ); ?></td>
							<td>
								<?php if( Auth::user()->isAdmin() || false == $detail->get_data( 'undeletable', false ) ): ?>
									<a href="#" class="button delete"><?php echo trans( 'main.delete' ); ?></a>
								<?php endif; ?>
							</td>
						</tr>
					<?php endforeach; ?>
				</tbody>
				
			</table>
		<?php else: ?>
			<div class="msg-info"><?php echo trans( 'order.no-details' ); ?></div>
		<?php endif; ?>
	
		<?php if( count( $order->Payments ) ): ?>
			<h2><?php echo trans( 'order.payments' ); ?></h2>	
			<table class="default">
				<thead>
					<tr>
						<th><?php echo trans( 'main.row' ); ?></th>
						<th><?php echo trans( 'order.payment.type' ); ?></th>
						<th><?php echo trans( 'order.payment.amount' ); ?></th>
					</tr>
				</thead>
				
				<tbody>
					<?php foreach( $order->Payments as $row => $payment ): ?>
						<tr>
							<td><?php echo en2fa( $row + 1 ); ?></td>
							<td><?php echo $payment->type_text; ?></td>
							<td><?php echo en2fa( number_format( $payment->amount ) ); ?></td>
						</tr>
					<?php endforeach; ?>
				</tbody>
				
			</table>
		<?php else: ?>
			<!-- <div class="msg-info"><?php echo trans( 'order.no-payments' ); ?></div> -->
		
			<?php if( $order->total > 0 && $order->finalized == 0 ): ?>
				<h2><?php echo trans( 'order.payment.begin' ); ?></h2>
				<?php echo Form::open( array() ); ?>

					<?php echo Form::label( 'type', trans( 'order.payment.type' ) ); ?>

					<?php echo Form::select( 'type', $pay_types_select ); ?>

					<?php echo Form::submit( trans( 'order.payment.begin' ) ); ?>

				<?php echo Form::close(); ?>

			<?php endif; ?>
		<?php endif; ?>
	</div>
<?php $__env->stopSection(); ?>