<?php $__env->startSection('title'); ?><?php echo app('translator')->getFromJson('Vendor Dashboard'); ?> - <?php echo e(config('app.name')); ?><?php $__env->stopSection(); ?>

<?php $__env->startSection('styles'); ?>
	<style>
		.action-btn {
			margin-bottom: 5px;
		}
		#message {
			resize: vertical;
		}
		.payout-submission-message {
			margin-top: 25px;
		}
	</style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('scripts'); ?>
    <?php if(config('settings.toast_notifications_enable')): ?>
    <script>
        toastr.options.closeButton = true;
        <?php if(session()->has('success')): ?>
            toastr.success("<?php echo e(session('success')); ?>");
        <?php endif; ?>
    </script>
    <?php endif; ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page-header-title'); ?>
	<?php echo app('translator')->getFromJson('Vendor Dashboard'); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('page-header-description'); ?>
    <?php echo app('translator')->getFromJson('View your earnings and payouts'); ?>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>

	<div class="row">
		<div class="col-md-12">
			<?php echo $__env->make('includes.form_errors', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
            <?php if(session()->has('success')): ?>
                <div class="text-center alert alert-success alert-dismissible" role="alert">
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                    <strong><?php echo e(session('success')); ?></strong>
                </div>
            <?php endif; ?>

			<div class="row">
				<div class="col-md-8">
					<h3>
						<?php echo e($vendor->name); ?>

						<small><a target="_blank" href="<?php echo e(route('front.vendor.profile')); ?>"><i class="fa fa-edit"></i></a></small>
					</h3>
					<span><strong><?php echo app('translator')->getFromJson('Shop Name:'); ?></strong> <?php echo e($vendor->shop_name); ?></span><br>
					<span>
						<strong><?php echo app('translator')->getFromJson('Shop URL:'); ?></strong>
						<a class="text-primary" target="blank" href="<?php echo e(url('/shop')); ?>/<?php echo e($vendor->slug); ?>"><?php echo e(url('/shop')); ?>/<?php echo e($vendor->slug); ?></a>
					</span><br>
					<span><strong><?php echo app('translator')->getFromJson('Phone:'); ?></strong> <?php echo e($vendor->phone); ?></span><br>
					<span><strong><?php echo app('translator')->getFromJson('Address:'); ?></strong> <?php echo e($vendor->address); ?></span><br>
					<span><strong><?php echo app('translator')->getFromJson('City:'); ?></strong> <?php echo e($vendor->city); ?></span><br>
					<span><strong><?php echo app('translator')->getFromJson('State:'); ?></strong> <?php echo e($vendor->state); ?></span><br>
				</div>
				<div class="col-md-4">
					<br>
					<a href="<?php echo e(route('manage.products.create')); ?>" class="action-btn btn btn-primary"><?php echo app('translator')->getFromJson('Add Product'); ?></a>
					<a href="<?php echo e(route('manage.products.index')); ?>" class="action-btn btn btn-success"><?php echo app('translator')->getFromJson('Views Products'); ?></a>
				</div>
			</div>
			<?php echo $vendor->description; ?>

		</div>
	</div>

	<hr>

	<div class="row">
		<div class="col-md-12">
			<h4><?php echo app('translator')->getFromJson('Vendor Earnings'); ?></h4>
		</div>
		<div class="col-md-12 table-responsive">
			<table class="table table-striped table-hover well">
				<thead>
					<tr>
						<th><?php echo app('translator')->getFromJson('Product'); ?></th>
						<th><?php echo app('translator')->getFromJson('Quantity'); ?></th>
						<th><?php echo app('translator')->getFromJson('Total Price'); ?></th>
						<th><?php echo app('translator')->getFromJson('Vendor Amount'); ?></th>
						<th><?php echo app('translator')->getFromJson('Status'); ?></th>
						<th><?php echo app('translator')->getFromJson('Date'); ?></th>
					</tr>
				</thead>
				<tbody>
					<?php if(count($vendor_amounts)): ?>
						<?php $__currentLoopData = $vendor_amounts; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $vendor_amount): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
					<tr>
						<td><?php echo e($vendor_amount->product_name); ?></td>
						<td><?php echo e(ucwords($vendor_amount->product_quantity)); ?></td>
						<td><?php echo e(ucwords($vendor_amount->total_price)); ?></td>
						<td><?php echo e(ucwords($vendor_amount->vendor_amount)); ?></td>
						<td><?php echo e(ucwords($vendor_amount->status)); ?></td>
						<td>
							<?php if($vendor_amount->status == 'outstanding'): ?>
								<?php echo e($vendor_amount->outstanding_date->format('d-m-Y h:i A')); ?>

							<?php elseif($vendor_amount->status == 'earned'): ?>
								<?php echo e($vendor_amount->earned_date->format('d-m-Y h:i A')); ?>

							<?php elseif($vendor_amount->status == 'paid'): ?>
								<?php echo e($vendor_amount->payment_date->format('d-m-Y h:i A')); ?>

							<?php elseif($vendor_amount->status == 'cancelled'): ?>
								<?php echo e($vendor_amount->cancel_date->format('d-m-Y h:i A')); ?>

							<?php endif; ?>
						</td>
					</tr>
						<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
					<?php endif; ?>
				</tbody>
			</table>
		</div>
	</div>
	<div class="row">
		<div class="col-md-12 text-center">
			<?php echo e($vendor_amounts->links()); ?>

		</div>
	</div>
	<div class="row">
		<div class="col-md-6">
			<h4><?php echo app('translator')->getFromJson('Overall Summary'); ?></h4>
			<ul class="list-group">
				<li class="list-group-item"><strong><?php echo app('translator')->getFromJson('Outstanding Amount:'); ?> </strong><?php echo e(currency_format($outstanding_amount)); ?></li>
				<li class="list-group-item"><strong><?php echo app('translator')->getFromJson('Amount Earned:'); ?> </strong><?php echo e(currency_format($amount_earned)); ?>

				<?php if(!$allow_payout_request): ?>
				<div class="text-danger">
					<?php echo app('translator')->getFromJson('Minimum amount :amount is required before you can request for payout.', ['amount' => currency_format($minimum_amount_for_request)]); ?>
				</div>
				<?php endif; ?>
				</li>
				<li class="list-group-item"><strong><?php echo app('translator')->getFromJson('Amount Paid:'); ?> </strong><?php echo e(currency_format($amount_paid)); ?></li>
			</ul>
		</div>
		<div class="col-md-6">
		<?php if(!$has_pending_request && $allow_payout_request): ?>
			<h4><?php echo app('translator')->getFromJson('Submit Payout Request'); ?></h4>
			<form action="<?php echo e(route('manage.vendor.submit-payout-request')); ?>" method="post" id="submit-payout-request-form">
				<?php echo e(csrf_field()); ?>

				<div class="form-group">
					<textarea name="message" class="form-control" id="message" cols="30" rows="4" placeholder="<?php echo app('translator')->getFromJson('Enter your message'); ?>"></textarea>
				</div>

				<button type="submit" class="btn btn-primary btn-sm submit-payout-request" onclick="
                                    if(confirm('<?php echo app('translator')->getFromJson('Are you sure to submit a payout request?'); ?>')) {
                                    event.preventDefault();
                                    $('#submit-payout-request-form').submit();
                                    } else {
                                    event.preventDefault();
                                    }
                                    ">
					<?php echo app('translator')->getFromJson('Submit Payout Request'); ?>
				</button>
			</form>
		<?php elseif($has_pending_request): ?>
			<div class="payout-submission-message well text-primary text-center"><?php echo app('translator')->getFromJson('You submitted a payout request on <strong>:date_time</strong>.', ['date_time' => $payout_request_date_time]); ?></div>
		<?php endif; ?>
		</div>
	</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.manage', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>