@extends('yonetim.yonetim_master')

@section('main')
    <section class="section">
        <div class="section-body">
            <div class="row">
                <div class="col-12 col-md-9 col-lg-9">


                    <div class="card">
                        <div class="card-header">
                            <h4>Kupon Ekleme Alanı</h4>

                        </div>



                        <form action="{{route('kupon.veriekleson')}}" method="post">
                            @csrf
                            <div class="card-body">


                                <div class="col-lg-12 mx-auto">

                                    <a href="{{route('kupon.all')}}" class="btn-sm btn btn-success float-right"><i class="fa fa-backward"></i> Geri Dön</a>
                                    <br>
                                    <p>Lütfen İndirim miktarı veya indirim oranında sadece birini seçiniz.</p>
                                    <p>*İndirim miktarına değer girerseniz indirim oranı alanını boş bırakınız</p>

                                    <div class="form-group">
                                        <label>Kupon Şifre</label>
                                        <div class="row">
                                            <div class="col-md-9">
                                                <input id="myInput" name="kupon_sifre" required maxlength="255" type="text" class="form-control" value="">
                                            </div>
                                            <div class="col-md-3 p-0">
                                                <button id="myButton" type="button" class="btn btn-primary btn-sm">Kod Oluştur</button>
                                            </div>
                                        </div>

                                    </div>

                                    <div class="form-group">
                                        <label>İndirim Miktarı</label>
                                        <input name="indirim_miktar" type="number" class="form-control" value="">
                                    </div>


                                    <div class="form-group">
                                        <label>İndirim Oranı</label>
                                        <select class="form-control" name="indirim_orani">
                                            <option value="">Seçiniz</option>
                                            <option value="0.03">%3</option>
                                            <option value="0.05">%5</option>
                                            <option value="0.07">%7</option>
                                            <option value="0.10">%10</option>
                                            <option value="0.15">%15</option>
                                            <option value="0.20">%20</option>
                                            <option value="0.30">%30</option>
                                            <option value="0.40">%40</option>
                                            <option value="0.40">%50</option>
                                            <option value="0.70">%70</option>
                                        </select>
                                    </div>





                                    <div class="card-footer text-right">
                                        <button type="submit" name="genelayarkaydet" class="btn btn-primary">Kupon Ekle</button>
                                    </div>


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


                    </div>





                </div>

            </div>

        </div>
    </section>
@endsection

@section('jsler')
    <script>
        document.getElementById("myButton").addEventListener("click", function() {
            var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
            var stringLength = 20;
            var randomString = "";
            for (var i = 0; i < stringLength; i++) {
                var randomNum = Math.floor(Math.random() * chars.length);
                randomString += chars.substring(randomNum, randomNum + 1);
            }
            document.getElementById("myInput").value = randomString;
        });
    </script>
@endsection
