<?php echo $header; ?>

<div class="container">
    <ul id="breadcrumbs-one">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
        <?php } ?>
    </ul>
    <?php if ($attention) { ?>
    <div class="alert alert-info"><i class="fa fa-info-circle"></i> <?php echo $attention; ?>
        <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    <?php } ?>
    <?php if ($success) { ?>
    <div class="alert alert-success"><i class="fa fa-check-circle"></i> <?php echo $success; ?>
        <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    <?php } ?>
    <?php if ($error_warning) { ?>
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
        <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    <?php } ?>
    <div class="row">
        <?php echo $column_left; ?>
        <?php if ($column_left && $column_right) { ?>
        <?php $class = 'col-sm-6'; ?>
        <?php } elseif ($column_left || $column_right) { ?>
        <?php $class = 'col-sm-9'; ?>
        <?php } else { ?>
        <?php $class = 'col-sm-12'; ?>
        <?php } ?>
        <div id="content" class="col-sm-12">
            <h2 class="text-center"><?php echo $heading_title; ?>

            </h2>

            <form action="<?php echo $check; ?>" method="post" enctype="multipart/form-data" id="form1">
                <div class="table-responsive">
                    <table class="table table-bordered-cart">
                        <tbody>
                        <?php foreach ($products as $product) { ?>
                        <tr <?php if (!$product['stock']) { echo 'class="no-limit"'; } ?>>
                        <td class="text-left td-img"><?php if ($product['thumb']) { ?>
                            <a href="<?php echo $product['href']; ?>"><img class="small-img" src="<?php echo $product['thumb']; ?>" alt="<?php echo $product['name']; ?>" title="<?php echo $product['name']; ?>"
                                                                           title="cart-img"></a>
                            <?php } ?></td>
                        <td class="text-left td-name">
                            <a href="<?php echo $product['href']; ?>" class="cart-name"><?php echo $product['name']; ?></a>
                            <span class="cart-date"><?php echo date("d.m.Y", strtotime($product['booking_day'])); ?></span>
                            <?php if (!$product['stock']) { ?>
                            <span class="text-danger">***</span>
                            <?php } ?>
                            <?php if (!$product['stock']) { ?>
                            <div class="alert"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
                            </div>
                            <?php } ?>
                            <p><?php echo $product['amounts']; ?>  <?php echo $product['product_price']; ?></p>
                        </td>
                        <td class="text-center td-text-text">
                            <?php if ($product['option']) { ?>
                            <?php foreach ($product['option'] as $option) { ?>
                            <span class="dop-cart"><i class="fa fa-plus-square" aria-hidden="true"></i><?php echo $option['name']; ?>: <?php echo $option['value']; ?></span>
                            <?php } ?>
                            <?php } ?>
                        </td>
                        <td class="text-right td-price"><?php echo $product['total_']; ?>
                        </td>
                        <td class="hiden-delete text-right">
                            <button type="button" data-toggle="tooltip" title="<?php echo $button_remove; ?>"
                                    class="pe-7s-close button-remove" data-original-title="<?php echo $button_remove; ?>" onclick="cart.remove('<?php echo $product['cart_id']; ?>');"></button>
                        </td>
                        </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                </div>
                <div class="col-xs-12 bucket-total">
                    <?php foreach ($totals as $total) { ?>
                    <div class="text-right total-price text-price"><?php echo $text_total_products; ?>
                        <span class="text-right total-price number-price"><?php echo $total['text']; ?></span></div>
                    <?php break; ?>
                    <?php } ?>
                </div>



                <?php if($user_id==0){ ?>
                <div class="row cart-details register-cart">
                    <div class="col-xs-12 col-xs-offset-0 col-sm-12 col-sm-offset-0 col-md-4 col-md-offset-4">
                        <div class="row">
                            <div class="text-center catr-link"><a class="text-center" href="<?php echo $login; ?>"><?php echo $text_register; ?></a>
                            </div>
                            <div class="text-center text-contact-date"><?php echo $text_user_information; ?></div>
                        </div>
                    </div>
                    <div class="col-xs-12 col-xs-offset-0 col-sm-9 col-sm-offset-0 col-md-6 col-cart-offset">
                        <div class="row">

                            <div class="form-group">
                                <span class="col-sm-3 col-md-3 text-right"><label class="control-label" for="input-firstname"> <?php echo $entry_firstname; ?></label></span>
                                <div class="col-sm-9 col-md-9 nopadding">
                                    <input type="text" name="firstname" value="" placeholder="<?php echo $entry_firstname; ?>" id="input-firstname" class="form-control input-grey ">
                                    <div class="text-danger" style="display:none"><?php echo $error_firstname; ?></div>
                                </div>
                            </div>
                            <div class="form-group">
                                <span class="col-sm-3 col-md-3 text-right"><label class="control-label" for="input-lastname"> <?php echo $entry_lastname; ?></label></span>
                                <div class="col-sm-9 col-md-9 nopadding">
                                    <input type="text" name="lastname" value="" placeholder="<?php echo $entry_lastname; ?>" id="input-lastname" class="form-control input-grey ">
                                    <div class="text-danger" style="display:none"><?php echo $error_lastname; ?></div>
                                </div>
                            </div>


                            <div class="form-group">
                                <span class="col-sm-3 col-md-3 text-right"><label class="control-label" for="input-email"><?php echo $entry_email; ?></label></span>
                                <div class="col-sm-9 col-md-9 nopadding">
                                    <input type="text" name="email" value="" placeholder="<?php echo $entry_email; ?>" id="input-email" class="form-control input-grey">
                                    <div class="text-danger" style="display:none"><?php echo $error_email; ?></div>
                                </div>
                            </div>

                            <div class="form-group">
                                <span class="col-sm-3 col-md-3 text-right"><label class="control-label" for="input-telephone"><?php echo $entry_telephone; ?></label></span>
                                <div class="col-sm-9 col-md-9 nopadding">
                                    <input type="tel" name="telephone" value="" placeholder="+38(0__)___-__-__" id="input-telephone" class="form-control input-grey">
                                    <div class="text-danger" style="display:none"><?php echo $error_telefone; ?></div>
                                </div>
                            </div>

                            <div class="form-group">
                                <span class="col-sm-3 col-md-3 text-right"><label class="control-label" for="input-password"><?php echo $entry_password; ?></label></span>
                                <div class="col-sm-9 col-md-9 nopadding">
                                    <input type="password" name="password" value="" placeholder="<?php echo $entry_password; ?>" id="input-password" class="form-control input-grey">
                                    <div class="text-danger" style="display:none"><?php echo $error_password; ?></div>
                                </div>
                            </div>
                            <div class="form-group form-group-last">
                                <span class="col-sm-3 col-md-3 text-right"><label class="control-label" for="input-confirm"><?php echo $entry_confirm; ?></label></span>
                                <div class="col-sm-9 col-md-9 nopadding">
                                    <input type="password" name="confirm" value="" placeholder="<?php echo $entry_confirm; ?>" id="input-confirm" class="form-control input-grey">
                                    <div class="text-danger" style="display:none"><?php echo $error_confirm; ?></div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <?php foreach($informations as $i=>$information){ ?>
                    <div class="col-xs-12 col-sm-6">
                        <h3><?php echo $i; ?></h3>
                        <?php foreach($information as $ii=>$children){ ?>
                        <div class="checkout-inform checkbox-contein">
                            <input type="checkbox" id="c<?php echo $ii; ?>" name="information[]" value="<?php echo $ii; ?>">
                            <span class="check pull-left"></span>
                            <label for="c<?php echo $ii; ?>"><?php echo $children; ?> </label>
                        </div>
                        <?php } ?>
                    </div>

                    <?php } ?>
                    <div class="row cart-details register-cart">
                        <div class="col-xs-12 col-xs-offset-0 col-sm-12 col-sm-offset-0 col-md-4 col-md-offset-4">
                            <div class="checkout-button text-center">
                                <input type="button" value="<?php echo $button_confirm; ?>" class="btn booking btn-orange" id="checkout_confirme" >
                            </div>
                        </div>
                    </div>


                    <style>
                        .errors_register {
                            display: none;
                            color: red;
                        }
                    </style>

                </div>

                <?php } else { ?>
                <?php foreach($informations as $i=>$information){ ?>
                    <div class="col-xs-12 col-sm-6">
                        <h3><?php echo $i; ?></h3>
                        <?php foreach($information as $ii=>$children){ ?>
                        <div class="checkout-inform checkbox-contein">
                            <input type="checkbox" id="c<?php echo $ii; ?>" name="information[]" value="<?php echo $ii; ?>">
                            <span class="check pull-left"></span>
                            <label for="c<?php echo $ii; ?>"><?php echo $children; ?> </label>
                        </div>
                        <?php } ?>
                    </div>

                    <?php } ?>
                <div class="row cart-details register-cart">
                    <div class="col-xs-12 col-xs-offset-0 col-sm-12 col-sm-offset-0 col-md-6 col-md-offset-3">
                        <div class="checkout-button text-center">
                            <input  type="button" value="<?php echo $button_confirm; ?>" class="btn booking btn-orange" id="checkout_confirme2" >
                        </div>
                    </div>
                </div>
                    <?php } ?>
                    
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $('#checkout_confirme2').on('click',function(){
        $( "#form1" ).submit()
    })

    $('#checkout_confirme').on('click',function(){
        confirm(1);
    })
    function confirm(par) {


        var err = 0;
        $('.text-danger').hide();
        if ($('#input-firstname').val().length < 1) {
            $('#input-firstname').parent('div').children('.text-danger').show();
            err = 1;
        }
        if ($('#input-lastname').val().length < 1) {
            $('#input-lastname').parent('div').children('.text-danger').show();
            err = 1;
        }

        if ($('#input-email').val().length < 3) {
            $('#input-email').parent('div').children('.text-danger').show();
            err = 1;
        }

        var r = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);

        if (!r.test($('#input-email').val())) {
            $('#input-email').parent('div').children('.text-danger').show();
            err = 1;
        }

        if ($('#input-password').val().length < 4) {
            $('#input-password').parent('div').children('.text-danger').show();
            err = 1;
        }
        if ($('#input-telephone').val().length < 3) {
            $('#input-telephone').parent('div').children('.text-danger').show();
            err = 1;
        }
        var password=$('#input-password').val();
        var confirm=$('#input-confirm').val();

        if (confirm!=password) {
            $('#input-confirm').parent('div').children('.text-danger').show();
            err = 1;
        }

        if(err==0 && par==1){
            $( "#form1" ).submit()
        }
    }

    /*		if (!email.match(/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/)) {
     document.getElementById("erremail").innerHTML=checkoutmodalerr['email'];
     err=1;
     } else {
     document.getElementById("erremail").innerHTML="";
     lurl+='&email='+email;
     }*/
    $(document).ready(function() {
        jQuery(function($) {
            $("#input-telephone").mask("+38(099)999-99-99");
        });
    });

</script>
<script src="/catalog/view/javascript/jquery.maskedinput.js" type="text/javascript"></script>
<?php echo $footer; ?>
