<?php $__env->startSection('extra_scripts'); ?>
    <script type="text/javascript" src="<?php echo asset('js/jquery-validation/jquery.validate.min.js'); ?>"></script>
    <script type="text/javascript" src="<?php echo asset('js/jquery-validation/localization/messages_pl.min.js'); ?>"></script>
    <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $('.save-quantity').on('click', function(event) {
                var dataToSend = {
                    'id': $(this).data('id'),
                    'quantity': $(this).siblings('input.quantity').val()
                };
                window.location = "<?php echo route('front::order.changeQuantity'); ?>?" + $.param(dataToSend);
            });
            $('.quantity').on('change', function(event) {
                var currenyValue = parseInt($(this).val());
                var orgValue = parseInt($(this).data('org-quantity'));
                console.log(currenyValue);
                console.log(orgValue);
                if (currenyValue != orgValue) {
                    $(this).siblings('.save-quantity').show();
                } else {
                    $(this).siblings('.save-quantity').hide();
                }
            });
            $('#contact').validate({
                rules: {
                    first_name: {
                        minlength: 2,
                        maxlength: 50,
                        required: true
                    },
                    last_name: {
                        minlength: 2,
                        maxlength: 50,
                        required: true
                    },
                    company: {
                        minlength: 1,
                        maxlength: 100,
                        required: true
                    },
                    nip: {
                        minlength: 7,
                        maxlength: 25,
                        required: true
                    },

                    postcode: {
                        minlength: 3,
                        maxlength: 10,
                        required: true
                    },
                    city: {
                        minlength: 3,
                        maxlength: 50,
                        required: true
                    },
                    street: {
                        minlength: 3,
                        maxlength: 50,
                        required: true
                    },
                    street_nr: {
                        minlength: 1,
                        maxlength: 20,
                        required: true
                    },

                    email: {
                        required: true,
                        email: true
                    },
                    phone: {
                        minlength: 5,
                        maxlength: 40,
                        required: true
                    }
                },
                highlight: function(element) {
                    $(element).closest('.form-group').addClass('has-error');
                },
                unhighlight: function(element) {
                    $(element).closest('.form-group').removeClass('has-error');
                },
                errorElement: 'span',
                errorClass: 'help-block',
                errorPlacement: function(error, element) {
                    if (element.hasClass('no-error-placement')) {

                    } else {
                        if(element.parent('.input-group').length) {
                            error.insertAfter(element.parent());
                        } else {
                            error.insertAfter(element);
                        }
                    }
                }
            });
        });
    </script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <div class="container">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <h3 class="title">Koszyk</h3>
                <?php if($cart): ?>
                <table class="table table-striped table-bordered">
                    <thead>
                    <tr>
                        <th>Szerokość pas.</th>
                        <th>Zachodzenie pas.</th>
                        <th>Rodzaj pas.</th>
                        <th>Szerokość ot.</th>
                        <th>Wysokość os.</th>
                        <th>Cena jedn.</th>
                        <th style="width: 50px;">Ilość</th>
                        <th>Wartość</th>
                        <th>Usuń</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach($cart as $id => $item): ?>
                        <tr>
                            <td><?php echo e($item->stripsWidth); ?></td>
                            <td><?php echo e($item->overlapping); ?></td>
                            <td><?php echo e($item->stripsKind == 'normal' ? 'normalne' : 'chłodnicze'); ?></td>
                            <td><?php echo e($item->B); ?>mm</td>
                            <td><?php echo e($item->H); ?>mm</td>
                            <td><?php echo e($item->calculationDetails->price); ?>&nbsp;<?php echo e($currency); ?></td>
                            <td>
                                <input class="quantity" name="quantity" type="number" value="<?php echo e($item->quantity); ?>" data-org-quantity="<?php echo e($item->quantity); ?>" min="1" style="width: 50px;"/>
                                <a href="#" data-id="<?php echo e($id); ?>" class="save-quantity" style="display: none">Zapisz</a>
                            </td>
                            <td><?php echo e($item->calculationDetails->totalPrice); ?>&nbsp;<?php echo e($currency); ?></td>
                            <td><a style="cursor: pointer;" href="<?php echo route('front::order.deleteFromCart'); ?>?id=<?php echo e($id); ?>"><i class="fa fa-trash"></i></a></td>
                        </tr>
                    <?php endforeach; ?>
                    </tbody>
                </table>
                <?php else: ?>
                    <strong>Koszyk jest pusty!</strong>
                    <br/><br/>
                <?php endif; ?>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-7 col-md-7 col-sm-7 col-xs-12">
                <a style="cursor: pointer;" href="<?php echo route('front::calculation'); ?>">Dodaj <?php if($cart): ?>kolejną <?php endif; ?> kurtynę <i class="fa fa-plus"></i></a>
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <a style="cursor: pointer;" href="<?php echo route('front::order.deleteFromCart'); ?>?id=all">Wyczyść koszyk <i class="fa fa-trash"></i></a>
            </div>
            <div class="col-lg-5 col-md-5 col-sm-5 col-xs-12">
                <h3 class="title">Podsumowanie koszyka</h3>

                <table class="table table-striped table-bordered">
                    <tr>
                        <td>Suma zamówienia netto:</td>
                        <td><?php echo e($summary->sum); ?> <?php echo e($currency); ?></td>
                    </tr>
                    <tr>
                        <td>Wartość VAT (<?php echo e(isset($settings['vat']) ? $settings['vat'] : 23); ?>%) <?php echo e($currency); ?>: </td>
                        <td><?php echo e($summary->sumTax); ?> <?php echo e($currency); ?></td>
                    </tr>
                    <tr style="background-color: #b2dba1">
                        <td><strong>Wartość brutto:</strong></td>
                        <td><strong><?php echo e($summary->sumBrutto); ?> <?php echo e($currency); ?></strong></td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="row order-row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12" id="order-form">
                <h3 class="title">Zamówienie</h3>

                <form method="post" class="reply" id="contact" action="<?php echo route('front::order.store'); ?>">

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

                    <?php echo csrf_field(); ?>

                    <fieldset>
                        <div class="row">
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-6 form-group">
                                <label for="first_name">Imię: <span>*</span> <small>(nie będzie na fakturze)</small></label>
                                <input class="form-control" id="first_name" name="first_name" type="text" value="<?php echo e(Input::old('first_name')); ?>" required>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-6 form-group">
                                <label for="last_name">Nazwisko: <span>*</span> <small>(nie będzie na fakturze)</small></label>
                                <input class="form-control" type="text" id="last_name" name="last_name" value="<?php echo e(Input::old('last_name')); ?>" required>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-6 form-group">
                                <label for="company" class="hidden-xs">Pełna nazwa firmy: <span>*</span></label>
                                <label for="company" class="visible-xs">Nazwa firmy: <span>*</span></label>
                                <input class="form-control" id="company" name="company" type="text" value="<?php echo e(Input::old('company')); ?>" required>
                            </div>
                            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-6 form-group">
                                <label for="nip">NIP: <span>*</span></label>
                                <input class="form-control" type="text" id="nip" name="nip" value="<?php echo e(Input::old('nip')); ?>" required>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                                <h4>Adres do fakturowania: <span>*</span></h4>

                                <div class="row">
                                    <div class="col-lg-5 col-md-5 col-sm-5 col-xs-5">
                                        <div class="form-group">
                                            <input class="form-control no-error-placement" id="postcode" name="postcode" type="text" value="<?php echo e(Input::old('postcode')); ?>"
                                               placeholder="Kod pocztowy*" required>
                                        </div>
                                    </div>
                                    <div class="col-lg-7 col-md-7 col-sm-7 col-xs-7">
                                        <div class="form-group">
                                            <input class="form-control no-error-placement" id="city" name="city" type="text" value="<?php echo e(Input::old('city')); ?>"
                                               placeholder="Miasto*" required>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-lg-9 col-md-9 col-sm-9 col-xs-9">
                                        <div class="form-group">
                                            <input class="form-control no-error-placement" id="street" name="street" type="text" value="<?php echo e(Input::old('street')); ?>"
                                               placeholder="Ulica*" required>
                                        </div>
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                                        <div class="form-group">
                                            <input class="form-control no-error-placement" id="street_nr" name="street_nr" type="text" value="<?php echo e(Input::old('street_nr')); ?>"
                                                   placeholder="Nr*" required>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                                <h4>Adres do wysyłki
                                    <small>(gdy inny niż adres fakturowania)</small>
                                    :
                                </h4>
                                <div class="row">
                                    <div class="col-lg-5 col-md-5 col-sm-5 col-xs-5">
                                        <input class="form-control" id="delivery_postcode" name="delivery_postcode"
                                               type="text" value="<?php echo e(Input::old('delivery_postcode')); ?>" placeholder="Kod pocztowy">
                                    </div>
                                    <div class="col-lg-7 col-md-7 col-sm-7 col-xs-7">
                                        <input class="form-control" id="delivery_city" name="delivery_city" type="text"
                                               value="<?php echo e(Input::old('delivery_city')); ?>" placeholder="Miasto">
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-lg-9 col-md-9 col-sm-9 col-xs-9">
                                        <input class="form-control" id="delivery_street" name="delivery_street"
                                               type="text" value="<?php echo e(Input::old('delivery_street')); ?>" placeholder="Ulica">
                                    </div>
                                    <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
                                        <input class="form-control" id="delivery_street_nr" name="delivery_street_nr"
                                               type="text" value="<?php echo e(Input::old('delivery_street_nr')); ?>" placeholder="Nr">
                                    </div>
                                </div>
                            </div>
                            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
                                <h4>Dane kontaktowe:</h4>
                                <div class="form-group">
                                    <label for="email">Adres Email: <span>*</span></label>
                                    <input class="form-control" id="email" name="email" type="email" value="<?php echo e(Input::old('email')); ?>" required>
                                </div>
                                <div class="form-group">
                                    <label for="phone">Telefon kontaktowy: <span>*</span></label>
                                    <input class="form-control" id="phone" name="phone" type="text" value="<?php echo e(Input::old('phone')); ?>" required>
                                </div>
                                <div class="form-group">
                                    <label>Weryfikacja - podaj wynik działania 2 + 3 = <span>*</span></label>
                                    <input class="form-control" id="spmtest" placeholder="2 + 3 =" name="spmtest" type="text" required>
                                </div>
                            </div>
                            <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12 form-group">
                                <h4>Informacje dodatkowe:</h4>
                                <textarea class="form-control" id="extra_info" name="extra_info" rows="11"
                                          cols="40"><?php echo e(Input::old('extra_info')); ?></textarea>
                            </div>
                        </div>
                    </fieldset>

                    <a href="<?php echo route('front::order.print'); ?>" target="_blank" class="pull-right">Drukuj zamówienie <i class="fa fa-print"></i></a>
                    <button class="btn btn-normal btn-color submit bottom-pad" type="submit">Wyślij zamówienie <i class="fa fa-shopping-cart "></i></button>
                    <div class="clearfix">
                    </div>
                </form>
            </div>
        </div>
    </div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>