@extends('frontend.frontend-page-master')
@section('site-title')
    {{ __('Order Success') }}
@endsection
@section('page-meta-data')
    <title>{{ __('Order Success') }}</title>
@endsection
@section('page-title')
    <?php
    $page_info = request()->url();
    $str = explode("/",request()->url());
    $page_info = $str[count($str)-2];
    ?>
    {{ __(ucfirst(str_replace(['-','_'],' ',$page_info))) }}
@endsection
@section('style')
    <style>
        .add-to-calendar .icon-google {
            display: block!important;
        }
        .add-to-calendar-checkbox~a:before{
            display:none!important;
        }
    </style>

@endsection
@section('inner-title')
    {{ __('Order') }}
@endsection 

@section('content')
   <!-- Location Overview area starts -->
 <section class="location-overview-area padding-top-100">
    <div class="container">
        <div class="row">
            <div class="col-lg-12">
                <form id="msform" class="msform">
                    <!-- Successful Complete -->
                    <fieldset class="padding-top-80 padding-bottom-100">
                        <div class="form-card successful-card">
                            <h2 class="title-step"> {{ get_static_option('success_title') ?? __('SUCCESSFUL') }}</h2>
                            <a href="{{ route('homepage') }}" class="succcess-icon">
                                <i class="las la-check"></i>
                            </a>
                            <h5 class="purple-text text-center">{{ get_static_option('success_subtitle') ?? __('Your Order Successfully Completed') }}</h5>
                            <div class="btn-wrapper margin-top-35">
                                <h4 class="mb-3">{{ get_static_option('success_details_title') ?? __('Your Order Details') }}</h4>
                                <table class="table table-bordered">
                                    <thead>
                                        <tr>
                                            <th>{{ __('Date & Schedule') }}</th>
                                            <th>{{ __('Amount Details') }}</th>
                                            <th>{{ __('Order Status') }}</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <tr>
                                            <td>
                                                @if(!empty($order_details->date))
                                                <label><strong>{{ __('Date:') }}
                                                    </strong>{{ Carbon\Carbon::parse(strtotime($order_details->date))->format('d/m/y') }}</label>

                                                    <br>
                                                @endif
                                                @if(!empty($order_details->schedule))
                                                <label><strong>{{ __('Schedule:') }} </strong>{{ $order_details->schedule }}</label>
                                                @endif
                                            </td>
                                            <td>
                                                <label><strong>{{ __('Package Fee:') }} </strong>{{ float_amount_with_currency_symbol($order_details->package_fee) }}</label> <br>
                                                @if($order_details->extra_service >=1)
                                                <label><strong>{{ __('Extra Service:') }} </strong>{{ float_amount_with_currency_symbol($order_details->extra_service) }}</label> <br>
                                                @endif
                                                <label><strong>{{ __('Sub Total:') }}</strong>{{ float_amount_with_currency_symbol($order_details->sub_total) }}</label> <br>
                                                <label><strong>{{ __('Tax:') }} </strong>{{ float_amount_with_currency_symbol($order_details->tax) }}</label> <br>
                                                @if(!empty($order_details->coupon_amount))
                                                    <label><strong>{{ __('Coupon Amount:') }} </strong>{{ float_amount_with_currency_symbol($order_details->coupon_amount) }}</label> <br>
                                                @endif
                                                <label><strong>{{ __('Total:') }} </strong>{{ float_amount_with_currency_symbol($order_details->total) }}</label> <br>
                                                <label><strong>{{ __('Payment Gateway:') }} </strong>{{ __(ucwords(str_replace("_", " ", $order_details->payment_gateway))) }}</label> <br>
                                                <label><strong>{{ __('Payment Status:') }} </strong>{{ __(ucfirst($order_details->payment_status)) }}</label> <br>
                                            </td>
                                            <td>
                                                <label><strong>{{ __('Order Status:') }}</strong>
                                                    @if ($order_details->status == 0) <span>{{ __('Pending') }}</span>@endif
                                                    @if ($order_details->status == 1) <span>{{ __('Active') }}</span>@endif
                                                    @if ($order_details->status == 2) <span>{{ __('Completed') }}</span>@endif
                                                    @if ($order_details->status == 3) <span>{{ __('Delivered') }}</span>@endif
                                                    @if ($order_details->status == 4) <span>{{ __('Cancelled') }}</span>@endif
                                                </label>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                            <div class="btn-wrapper text-center margin-top-35">
                                <a href="{{ get_static_option('button_url') ?? route('homepage') }}" class="cmn-btn btn-bg-1">{{ get_static_option('button_title') ?? __('Back To Home') }}</a>
                                @if(auth('web')->check())
                                    @php
                                    $user_details = auth('web')->user();
                                    $route_prefix = $user_details->user_type === 0 ? 'seller' : 'buyer';
                                    @endphp
                                    <a href="{{ route($route_prefix.'.dashboard') }}" class="cmn-btn btn-bg-1">{{__('Go To Dashboard') }}</a>
                                    <a href="{{ route($route_prefix.'.orders') }}" class="cmn-btn btn-bg-1">{{__('All Orders') }}</a>
                                    <div class="cmn-btn btn-bg-1 new-cal"></div>
                                @endif
                            </div>
                        </div>

                    </fieldset>
                </form>
            </div>
        </div>
    </div>
</section>
<!-- Location Overview area end -->
@endsection
<scripts>
    <script>
        ;(function(exports) {
            var MS_IN_MINUTES = 60 * 1000;

            var formatTime = function(date) {
                return date.toISOString().replace(/-|:|\.\d+/g, '');
            };

            var calculateEndTime = function(event) {
                return event.end ?
                    formatTime(event.end) :
                    formatTime(new Date(event.start.getTime() + (event.duration * MS_IN_MINUTES)));
            };

            var calendarGenerators = {
                google: function(event) {
                    var startTime = formatTime(event.start);
                    var endTime = calculateEndTime(event);

                    build_http_query =[

                    ];
                    var href = encodeURI([
                        'https://www.google.com/calendar/render',
                        '?action=TEMPLATE',
                        '&text=' + (event.title || ''),
                        '&dates=' + (startTime || ''),
                        '/' + (endTime || ''),
                        '&details=' + (event.description || ''),
                        '&location=' + (event.address || ''),
                        '&sprop=&sprop=name:'
                    ].join(''));

                    return '<a class="icon-google" target="_blank" href="' +
                        href + '">"{{__('Add To Google Calendar')}}"</a>';
                },

                yahoo: function(event) {
                    var eventDuration = event.end ?
                        ((event.end.getTime() - event.start.getTime())/ MS_IN_MINUTES) :
                        event.duration;

                    // Yahoo dates are crazy, we need to convert the duration from minutes to hh:mm
                    var yahooHourDuration = eventDuration < 600 ?
                        '0' + Math.floor((eventDuration / 60)) :
                        Math.floor((eventDuration / 60)) + '';

                    var yahooMinuteDuration = eventDuration % 60 < 10 ?
                        '0' + eventDuration % 60 :
                        eventDuration % 60 + '';

                    var yahooEventDuration = yahooHourDuration + yahooMinuteDuration;

                    // Remove timezone from event time
                    var st = formatTime(new Date(event.start - (event.start.getTimezoneOffset() *
                        MS_IN_MINUTES))) || '';

                    var href = encodeURI([
                        'http://calendar.yahoo.com/?v=60&view=d&type=20',
                        '&title=' + (event.title || ''),
                        '&st=' + st,
                        '&dur=' + (yahooEventDuration || ''),
                        '&desc=' + (event.description || ''),
                        '&in_loc=' + (event.address || '')
                    ].join(''));

                    return '';
                },

                ics: function(event, eClass, calendarName) {
                    var startTime = formatTime(event.start);
                    var endTime = calculateEndTime(event);

                    var href = encodeURI(
                        'data:text/calendar;charset=utf8,' + [
                            'BEGIN:VCALENDAR',
                            'VERSION:2.0',
                            'BEGIN:VEVENT',
                            'URL:' + document.URL,
                            'DTSTART:' + (startTime || ''),
                            'DTEND:' + (endTime || ''),
                            'SUMMARY:' + (event.title || ''),
                            'DESCRIPTION:' + (event.description || ''),
                            'LOCATION:' + (event.address || ''),
                            'END:VEVENT',
                            'END:VCALENDAR'].join('\n'));

                    return '';
                },

                ical: function(event) {
                    return this.ics(event);
                },

                outlook: function(event) {
                    return this.ics(event);
                }
            };

            var generateCalendars = function(event) {
                return {
                    google: calendarGenerators.google(event),
                    yahoo: calendarGenerators.yahoo(event),
                    ical: calendarGenerators.ical(event),
                    outlook: calendarGenerators.outlook(event)
                };
            };

            // Create CSS
            var addCSS = function() {
                if (!document.getElementById('ouical-css')) {
                    document.getElementsByTagName('head')[0].appendChild(generateCSS());
                }
            };

            var generateCSS = function() {
                var styles = document.createElement('style');
                styles.id = 'ouical-css';

                styles.innerHTML = "#add-to-calendar-checkbox-label{cursor:pointer}.add-to-calendar-checkbox~a{display:none}.add-to-calendar-checkbox:checked~a{display:block;width:150px;margin-left:20px}input[type=checkbox].add-to-calendar-checkbox{position:absolute;top:-9999px;left:-9999px}.add-to-calendar-checkbox~a:before{width:16px;height:16px;display:inline-block;background-image:url(data:image/png;base64, );margin-right:.5em;content:' '}.icon-ical:before{background-position:-68px 0}.icon-outlook:before{}";

                return styles;
            };

            // Make sure we have the necessary event data, such as start time and event duration
            var validParams = function(params) {
                return params.data !== undefined && params.data.start !== undefined &&
                    (params.data.end !== undefined || params.data.duration !== undefined);
            };

            var generateMarkup = function(calendars, clazz, calendarId) {
                var result = document.createElement('div');

                result.innerHTML += '<input name="add-to-calendar-checkbox" class="add-to-calendar-checkbox" id="checkbox-for-' + calendarId + '" type="checkbox">';

                Object.keys(calendars).forEach(function(services) {
                    result.innerHTML += calendars[services];
                });

                result.className = 'add-to-calendar';
                if (clazz !== undefined) {
                    result.className += (' ' + clazz);
                }

                addCSS();

                result.id = calendarId;
                return result;
            };

            var getClass = function(params) {
                if (params.options && params.options.class) {
                    return params.options.class;
                }
            };

            var getOrGenerateCalendarId = function(params) {
                return params.options && params.options.id ?
                    params.options.id :
                    Math.floor(Math.random() * 1000000); // Generate a 6-digit random ID
            };

            exports.createCalendar = function(params) {
                if (!validParams(params)) {
                    return;
                }

                return generateMarkup(generateCalendars(params.data),
                    getClass(params),
                    getOrGenerateCalendarId(params));
            };
        })(this);
    </script>

</scripts>





