<!-- Receipt Modal Start  -->
<div class="modal fade receipt_model" id="adisyon_model" tabindex="-1" role="dialog" aria-labelledby="adisyon_modelTitle" aria-hidden="true">
    <div class="modal-dialog modal-dialog-right" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <div class="row no-gutters w-100 align-items-center">
                    <div class="col-12 col-lg-6 col-md-6 col-sm-6">
                        <h2>Siparişi Düzenle</h2>
                    </div>
                    <div class="col-12 col-lg-6 col-md-6 col-sm-6">
                        <div class="btn_container d-flex">
                            <button type="button" class="btn" >
                                <a href="javascript:void(0)" onclick="window.print();"><i class="zmdi zmdi-print"></i></a>
                            </button>
                        </div>
                    </div>
                </div>

            </div>
            <div class="modal-body p-0">
                <div class="about_restro text-center">
                    <h3>Parstech Restoran</h3>
                    <p>Eğitim Mh. Kentplus Sitesi</p>
                </div>
                <div class="about_customer">
                    <h3 class="d-flex"><span>Osman CEYHAN</span> <span class="mr-0 ml-auto">Sipariş No #21389223</span></h3>
                    <h3 class="d-flex"><span>20.10.2020 - 00:37</span> <span class="mr-0 ml-auto">Masa 4</span></h3>
                </div>
                <ul>
                    <li class="d-flex">
                        <div class="input-group">
          <span class="input-group-btn">
              <button type="button" class="btn btn-danger btn-number"  data-type="minus" data-field="quant[2]">
                <i class="zmdi zmdi-minus"></i>
              </button>
          </span>
                            <input type="text" name="quant[2]" class="form-control input-number" value="10" min="1" max="100">
                            <span class="input-group-btn">
              <button type="button" class="btn btn-success btn-number" data-type="plus" data-field="quant[2]">
                  <i class="zmdi zmdi-plus"></i>
              </button>
          </span>
                        </div>
                        <h4>1</h4>
                        <h3>Çay</h3>
                        <h5 class="mr-0 ml-auto">₺4.00</h5>
                    </li>
                    <li class="d-flex">
                        <h4>1</h4>
                        <h3>Karışık Pizza
                            <span>Ekstra Pastırmalı</span>
                        </h3>
                        <h5 class="mr-0 ml-auto">₺35.00
                            <span class="text-right">₺5.00</span>
                        </h5>
                    </li>
                    <li class="d-flex">
                        <h4>1</h4>
                        <h3>Hamburger</h3>
                        <h5 class="mr-0 ml-auto">₺30.00</h5>
                    </li>
                    <li class="d-flex">
                        <h4>1</h4>
                        <h3>Ice Latte</h3>
                        <h5 class="mr-0 ml-auto">₺8.00</h5>
                    </li>
                </ul>

                <div class="amount_details">
                    <h3 class="d-flex">Ara Toplam <span class="ml-auto mr-0">₺62.00</span></h3>
                    <h3 class="d-flex">Vergi (8%) <span class="ml-auto mr-0">₺4.96</span></h3>
                </div>
                <div class="total_paid">
                    <h3 class="d-flex align-items-center">Toplam Ödenecek <strong>Miktar</strong> <span class="ml-auto mr-0"₺66.96</span></h3>
                </div>
                <div class="receipt_footer">
                    <h2 class="text-center">Ziyaret ettiğiniz için teşekkürler <br> Parstech Restoran</h2>
                </div>
            </div>

        </div>
    </div>

</div>
<!-- Receipt Modal End  -->

<script type="text/javascript">
    $('.btn-number').click(function(e){
        e.preventDefault();
        fieldName = $(this).attr('data-field');
        type      = $(this).attr('data-type');
        var input = $("input[name='"+fieldName+"']");
        var currentVal = parseInt(input.val());
        if (!isNaN(currentVal)) {
            if(type == 'minus') {

                if(currentVal > input.attr('min')) {
                    input.val(currentVal - 1).change();
                }
                if(parseInt(input.val()) == input.attr('min')) {
                    $(this).attr('disabled', true);
                }

            } else if(type == 'plus') {

                if(currentVal < input.attr('max')) {
                    input.val(currentVal + 1).change();
                }
                if(parseInt(input.val()) == input.attr('max')) {
                    $(this).attr('disabled', true);
                }

            }
        } else {
            input.val(0);
        }
    });
    $('.input-number').focusin(function(){
        $(this).data('oldValue', $(this).val());
    });
    $('.input-number').change(function() {

        minValue =  parseInt($(this).attr('min'));
        maxValue =  parseInt($(this).attr('max'));
        valueCurrent = parseInt($(this).val());

        name = $(this).attr('name');
        if(valueCurrent >= minValue) {
            $(".btn-number[data-type='minus'][data-field='"+name+"']").removeAttr('disabled')
        } else {
            alert('Sorry, the minimum value was reached');
            $(this).val($(this).data('oldValue'));
        }
        if(valueCurrent <= maxValue) {
            $(".btn-number[data-type='plus'][data-field='"+name+"']").removeAttr('disabled')
        } else {
            alert('Sorry, the maximum value was reached');
            $(this).val($(this).data('oldValue'));
        }


    });
    $(".input-number").keydown(function (e) {
        // Allow: backspace, delete, tab, escape, enter and .
        if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 190]) !== -1 ||
            // Allow: Ctrl+A
            (e.keyCode == 65 && e.ctrlKey === true) ||
            // Allow: home, end, left, right
            (e.keyCode >= 35 && e.keyCode <= 39)) {
            // let it happen, don't do anything
            return;
        }
        // Ensure that it is a number and stop the keypress
        if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
            e.preventDefault();
        }
    });
</script>