<?php
	Assets::add( 'payments.min.js' );
	Assets::add( 'amib-datepicker' );
?>
<?php $__env->startSection( 'head' ); ?>
	<style>
		.sc {
			background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
			border-radius: 1rem;
			padding: 1.25rem 1.5rem;
			margin-bottom: 1.5rem;
			display: flex;
			align-items: center;
			justify-content: space-between;
			flex-wrap: wrap;
			gap: 1rem;
			box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
		}

		.sc-title {
			margin: 0;
			color: white;
			font-weight: 600;
			font-size: 1.1rem;
		}

		.sc-amount-wrapper {
			background: rgba(255, 255, 255, 0.2);
			backdrop-filter: blur(4px);
			padding: 0.5rem 1.2rem;
			border-radius: 2rem;
		}

		.sc-amount {
			color: white;
			font-size: 1.5rem;
			font-weight: bold;
			letter-spacing: 1px;
		}

		.sc-currency {
			font-size: 0.9rem;
		}
	</style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection( 'content' ); ?>
	<?php echo Form::model( $old_search_data, array( 'method' => 'get', 'id' => 'search_form' ) ); ?>

		<?php echo Form::text( 's_user', null, array( 'placeholder' => trans( 'payment.user' ) ) ); ?>

		<?php echo Form::text( 's_order_id', null, array( 'placeholder' => trans( 'payment.order_id' ) ) ); ?>

		<?php echo Form::select( 's_type', $payment_types, null, array( 'placeholder' => trans( 'payment.type' ) ) ); ?>

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

		<?php echo Form::text( 'filter_start' ); ?>

		<?php echo Form::hidden( 'filter_start_gregorian', null, array( 'id' => 'filter_start_gregorian' ) ); ?>


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

		<?php echo Form::text( 'filter_end' ); ?>

		<?php echo Form::hidden( 'filter_end_gregorian', null, array( 'id' => 'filter_end_gregorian' ) ); ?>

		<br>
		<?php echo Form::submit( trans( 'main.search' ) ); ?>

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


	<?php if( count( $payments ) ): ?>
		<div class="sc">
			<h3 class="sc-title">جمع کل مبالغ (همه صفحه‌ها)</h3>
			<div class="sc-amount-wrapper">
				<span class="sc-amount">
					<!--<?php echo en2fa( number_format( $total_amount ) ); ?>-->
					<?php echo en2fa( number_format( $total_amount * 0.95 )); ?>

					<small class="sc-currency">ریال</small>
				</span>
			</div>
		</div>

		<table id="payments-table" class="default">
			<thead>
				<tr>
					<th><?php echo trans( 'main.row' ); ?></th>
					<th><?php echo trans( 'payment.id' ); ?></th>
					<th><?php echo trans( 'payment.user' ); ?></th>
					<th><?php echo trans( 'payment.order_details' ); ?></th>
					<th><?php echo trans( 'payment.amount' ); ?></th>
					<th><?php echo trans( 'payment.type' ); ?></th>
					<th><?php echo trans( 'payment.created_at' ); ?></th>
				</tr>
			</thead>
			<tbody>
				<?php $row = $payments->getFrom(); ?>
				<?php foreach( $payments as $payment ): ?>
					<tr>
						<td><?php echo en2fa( $row++ ); ?></td>
						<td><?php echo en2fa( $payment->id ); ?></td>
						<td>
							<?php if( $payment->Order && $payment->Order->User ): ?>
								<?php echo e($payment->Order->User->full_name); ?>

								<br>
								<small>&lrm;🆔 (<?php echo en2fa( $payment->Order->User->national_code ); ?>)</small>
								<br>
								<small>&lrm;📱 (<?php echo en2fa( $payment->Order->User->mobile ); ?>)</small>
							<?php else: ?>
								-
							<?php endif; ?>
						</td>
						<td>
							<?php echo en2fa( $payment->order_id ); ?>


							<?php if( $payment->Order && $payment->Order->Details->count() ): ?>
								<br>
								<?php foreach( $payment->Order->Details as $detail ): ?>
									<div><small>
										<?php echo $detail->product_type_text; ?> :
										<?php echo $detail->Product ? $detail->Product->name : '-'; ?>

									</small></div>
								<?php endforeach; ?>
							<?php endif; ?>
						</td>
						<td><?php echo en2fa( number_format( $payment->amount ) ); ?></td>
						<td><?php echo trans( "payment.types.{$payment->type}" ); ?></td>
						<td><?php echo convert_date_time_to_persian( $payment->Order->updated_at ); ?></td>
					</tr>
				<?php endforeach; ?>
			</tbody>
		</table>
		<div>
			<?php echo $payments->appends( $old_search_data )->links(); ?>

		</div>
	<?php else: ?>
		<div class="info-message"><?php echo trans( 'main.empty' ); ?></div>
	<?php endif; ?>
<?php $__env->stopSection(); ?>