<?php $__env->startSection('icerik'); ?>
    <section id="section-cars" style="background-size: 100%; background-repeat: no-repeat;">
        <div class="container" style="background-size: 100%; background-repeat: no-repeat;">
            <div class="row" style="background-size: 100%; background-repeat: no-repeat;">

                <h2><?php echo e($tur->baslik); ?></h2>


                <div class="container">
                   <div class="de-item">
                       <div class="row">
                           <div class="col-lg-3 col-md-12">
                               <ul style="list-style: none">
                                   <li><i class="fa fa-calendar"></i> <b>Başlama:</b> <?php echo e($tur->baslama); ?></li>
                                   <li><i class="fa fa-calendar"></i> <b>Bitiş:</b> <?php echo e($tur->bitis); ?></li>
                               </ul>
                           </div>
                           <div class="col-lg-9 col-md-12">
<?php echo $tur->turkisatanim; ?>                       </div>
                   </div>
                </div>


                <div class="container mt-4">
                    <div class="row">
                        <div class="col-lg-4 col-md-12">
                            <div class="de-box">

                                <form action="/tur-kayit" method="post">
                                    <?php echo csrf_field(); ?>


                                    <input type="hidden" name="turid" value="<?php echo e($tur->turlar_id); ?>">

                                    Tarih Seçin
                                    <input type="date" name="turtarih" class="form-control mb-3" required >

                                    <b>Eklenebilir Kişiler</b>

                                    <hr class="mt-2 mb-2">



                                    <div class="textbox-container">
                                        <div class="label">Yetişkin (12 Yaş+)

                                    <div class="fw-bold">
                                            <?php if($ayar['pb']==session()->get('pb')): ?>
                                            <input type="text" class="deger" name="yetiskinx" value="<?php echo e($tur->yetiskin); ?>"  >
                                                 <span><?php echo e($tur->yetiskin); ?><small>  <?php echo e($ayar['pb']); ?></small>  <i class="fa fa-refresh"  onclick="modal('parabirimi','')"></i></span>
                                            <?php else: ?>
                                            <input type="text" class="deger" name="yetiskinx" value="<?php echo e(number_format(($tur->yetiskin * $doviz[$ayar['pb']]) / $doviz[session()->get('pb')], 2)); ?>"  >
                                                 <span><?php echo e(number_format(($tur->yetiskin * $doviz[$ayar['pb']]) / $doviz[session()->get('pb')], 2)); ?> <small><?php echo e(session()->get('pb')); ?></small>  <i class="fa fa-refresh"  onclick="modal('parabirimi','')"></i></span>
                                            <?php endif; ?>
                                    </div>

                                        </div>
                                        <div class="yuvar btn minus">-</div>
                                        <input class="value form-control" type="text" value="0" name="yetiskin">
                                        <div class="yuvar btn plus">+</div>
                                    </div>
                                    <div class="textbox-container">
                                        <div class="label">Çocuk (7 - 11.99 Yaş)

                                    <div class="fw-bold">
                                            <?php if($ayar['pb']==session()->get('pb')): ?>
                                                 <span><?php echo e($tur->bcocuk); ?><small>  <?php echo e($ayar['pb']); ?></small>  <i class="fa fa-refresh"  onclick="modal('parabirimi','')"></i></span>
                                            <input type="text" class="deger" name="bcocukx" value="<?php echo e($tur->bcocuk); ?>"  >
                                            <?php else: ?>
                                            <input type="text" class="deger" name="bcocukx" value="<?php echo e(number_format(($tur->bcocuk * $doviz[$ayar['pb']]) / $doviz[session()->get('pb')], 2)); ?>"  >
                                                 <span><?php echo e(number_format(($tur->bcocuk * $doviz[$ayar['pb']]) / $doviz[session()->get('pb')], 2)); ?> <small><?php echo e(session()->get('pb')); ?></small>  <i class="fa fa-refresh"  onclick="modal('parabirimi','')"></i></span>
                                            <?php endif; ?>
                                    </div>

                                        </div>
                                        <div class="yuvar btn minus">-</div>
                                        <input class="value form-control" type="text" value="0" name="bcocuk">
                                        <div class="yuvar btn plus">+</div>
                                    </div>
                                    <div class="textbox-container">
                                        <div class="label">Çocuk (2 - 6.99 Yaş)

                                            <div class="fw-bold">
                                                <?php if($ayar['pb']==session()->get('pb')): ?>
                                                    <span><?php echo e($tur->kcocuk); ?><small>  <?php echo e($ayar['pb']); ?></small>  <i class="fa fa-refresh"  onclick="modal('parabirimi','')"></i></span>
                                                    <input type="text" class="deger" name="kcocukx" value="<?php echo e($tur->kcocuk); ?>"  >
                                                <?php else: ?>
                                                    <input type="text" class="deger" name="kcocukx" value="<?php echo e(number_format(($tur->kcocuk * $doviz[$ayar['pb']]) / $doviz[session()->get('pb')], 2)); ?>"  >
                                                    <span><?php echo e(number_format(($tur->kcocuk * $doviz[$ayar['pb']]) / $doviz[session()->get('pb')], 2)); ?> <small><?php echo e(session()->get('pb')); ?></small>  <i class="fa fa-refresh"  onclick="modal('parabirimi','')"></i></span>
                                                <?php endif; ?>
                                            </div>

                                        </div>
                                        <div class="yuvar btn minus">-</div>
                                        <input class="value form-control" type="text" value="0" name="kcocuk">
                                        <div class="yuvar btn plus">+</div>
                                    </div>
                                    <div class="textbox-container">
                                        <div class="label">Bebek (0 - 1.99 Yaş)


                                            <div class="fw-bold">
                                                <?php if($ayar['pb']==session()->get('pb')): ?>
                                                    <span><?php echo e($tur->bebek); ?><small>  <?php echo e($ayar['pb']); ?></small>  <i class="fa fa-refresh"  onclick="modal('parabirimi','')"></i></span>
                                                    <input type="text" class="deger" name="bebekx" value="<?php echo e($tur->bebek); ?>"  >
                                                <?php else: ?>
                                                    <input type="text" class="deger" name="bebekx" value="<?php echo e(number_format(($tur->bebek * $doviz[$ayar['pb']]) / $doviz[session()->get('pb')], 2)); ?>"  >
                                                    <span><?php echo e(number_format(($tur->bebek * $doviz[$ayar['pb']]) / $doviz[session()->get('pb')], 2)); ?> <small><?php echo e(session()->get('pb')); ?></small>  <i class="fa fa-refresh"  onclick="modal('parabirimi','')"></i></span>
                                                <?php endif; ?>
                                            </div>

                                        </div>
                                        <div class="yuvar btn minus">-</div>
                                        <input class="value form-control" type="text" value="0" name="bebek">
                                        <div class="yuvar btn plus">+</div>
                                    </div>




                                    <div style="display: flex">
                                        <div style="width: 200px; text-align: right">
                                            Toplam
                                        </div>
                                        <div style="text-align: right; margin-left: 30px; width: 200px;">
                                            <h4><span id="tutar">0</span> <small style="margin-left: 10px;"><?php echo e(session()->get('pb')); ?> <i class="fa fa-refresh"  onclick="modal('parabirimi','')"></i></small></h4>

                                        </div>
                                    </div>

                                    <hr>

                                    <input type="text" id="toplam" name="gosterilen" min="1" required>
                                    <button class="btn btn-lg btn-success form-control mt-1"><i class="fa fa-check-circle"></i> Rezervasyon Yap</button>




                                </form>

                            </div>
                        </div>
                        <div class="col-lg-8 col-md-12">
                            <div class="de-box p-3">


                                <img src="<?php echo e($tur->img); ?>" alt="" width="100%">

                                <hr>

                                <h3>Tur Programı</h3>
<?php echo $tur->program; ?>


                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </section>

    <script>
        $('.btn').on('click', function(event) {
            var button = $(this);
            var container = button.parent();
            var valueElement = container.find('.value');
            var currentValue = parseInt(valueElement.val());

            if (button.hasClass('plus')) {
                if (currentValue < 30) {
                    valueElement.val(currentValue + 1);
                }
            } else if (button.hasClass('minus')) {
                if (currentValue > 0) {
                    valueElement.val(currentValue - 1);
                }
            }

            calculateTotal();

        });

        // Limit input value to 0-30 range
        $('.value').on('input', function() {
            var valueElement = $(this);
            var currentValue = parseInt(valueElement.val());

            if (currentValue < 0 || isNaN(currentValue)) {
                valueElement.val(0);
            } else if (currentValue > 30) {
                valueElement.val(30);
            }
        });
    </script>

    <script>
        // Function to calculate and update the total value
        function calculateTotal() {
            let total = 0;
            const containers = $(".textbox-container");

            containers.each(function () {
                const valueInput = $(this).find(".value");
                const degerInput = $(this).find(".deger");
                const value = parseFloat(valueInput.val());
                const deger = parseFloat(degerInput.val().replace(",", ""));

                total += value * deger;
            });

            // Format the total value with two decimal places
            const formattedTotal = total.toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 });

            $("#tutar").text(formattedTotal);
            $("#toplam").val(total);
        }

        // Add event listener to the "value" input fields using jQuery
        $(".value").on("input", calculateTotal);

    </script>



    <style>

        .yuvar {
            width: 40px!important;
            line-height: 40px;
            border-radius: 40px;
            border: 1px solid lightgray;
            padding: 0px;
            height: 40px!important;
            padding-top: -10px;
        }
        /* Add some CSS styles to align the labels and elements properly */
        .textbox-container {
            display: flex;
            align-items: center;
            margin-bottom: 30px;
            border-bottom: lightgray solid 0.5px;
            padding-bottom: 20px;
        }

        .label {
            margin-right: 10px;
            width: 200px; /* Adjust the width as needed */
            text-align: right;
        }



        .value {
            width: 60px; /* Adjust the width as needed */
            margin-left: 10px;
            margin-right: 10px;
        }

        .plus { color: green}
        .minus { color: red}
        .deger { display: none}
        #toplam { display: none}

    </style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('title',$tur->baslik); ?>

<?php echo $__env->make('master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\laragon\www\transferpro2\resources\views/tur.blade.php ENDPATH**/ ?>