<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description"
          content="Cuba admin is super flexible, powerful, clean &amp; modern responsive bootstrap 5 admin template with unlimited possibilities.">
    <meta name="keywords"
          content="admin template, Cuba admin template, dashboard template, flat admin template, responsive admin template, web app">
    <meta name="author" content="pixelstrap">
    <link rel="icon" href="/RTL/superAdmin/images/favicon.png" type="image/x-icon">
    <link rel="shortcut icon" href="/RTL/superAdmin/images/favicon.png" type="image/x-icon">
    <title>آنسه تیم</title>
    <!-- Google font-->

    <script src="https://cdn.ckeditor.com/ckeditor5/35.0.1/classic/ckeditor.js"></script>

    <link href="https://fonts.googleapis.com/css?family=Rubik:400,400i,500,500i,700,700i&amp;display=swap"
          rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i,900&amp;display=swap"
          rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/font-awesome.css">
    <!-- ico-font-->
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/vendors/icofont.css">
    <!-- Themify icon-->
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/vendors/themify.css">
    <!-- Flag icon-->
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/vendors/flag-icon.css">
    <!-- Feather icon-->
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/vendors/feather-icon.css">
    <!-- Plugins css start-->
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/vendors/scrollbar.css">
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/vendors/prism.css">
    <!-- Plugins css Ends-->
    <!-- Bootstrap css-->
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/vendors/bootstrap.css">
    <!-- App css-->
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/style.css">
    <link id="color" rel="stylesheet" href="/RTL/superAdmin/css/color-1.css" media="screen">
    <!-- Responsive css-->
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/responsive.css">
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/vendors/select2.css">
    <link href="https://cdn.jsdelivr.net/npm/persian-datepicker@1.2.0/dist/css/persian-datepicker.min.css" rel="stylesheet">
    <!-- pesiandate picker css-->
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/persiandatepicker/persian-datepicker.min.css">

</head>
<body class="rtl">
<!-- tap on top starts-->
<div class="tap-top"><i data-feather="chevrons-up"></i></div>
<!-- tap on tap ends-->
<!-- page-wrapper Start-->
<div class="page-wrapper compact-wrapper" id="pageWrapper">
    <!-- Page Header Start-->

    <%- include('../../partials/header') %>

    <!-- Page Sidebar Ends-->
    <div class="page-body">
        <div class="container-fluid">
            <div class="page-title">
                <div class="row">
                    <div class="col-12">
                        <ol class="breadcrumb" style="-webkit-box-pack: start!important;">
                            <li class="breadcrumb-item"><a href="/<%= lan.ShortName %>/user/dashboard"><i
                                            data-feather="home"></i></a></li>
                            <li class="breadcrumb-item">تخفیفات</li>
                            <li class="breadcrumb-item">تخفیفات</li>
                            <li class="breadcrumb-item active">لیست پاداش</li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>



        <!-- Container-fluid starts-->
        <!-- Container-fluid starts-->
        <!-- Container-fluid starts-->
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-12 col-xl-12">
                    <div class="row">
                        <div class="col-sm-10" style="margin:0 auto">

                            <div class="card">
                                <div class="card-header">
                                    <h5>ثبت پاداش تخفیف در سامانه آنسه تیم</h5>
                                </div>

                                <div class="card-body">
                                    <form class="form-space theme-form row" action="/<%= lan.ShortName %>/reward/add/<%= discount._id%>"
                                          method="post">
                                        <div class="col-sm-6">
                                            <div class="col-form-label">نام پاداش</div>
                                            <input type="text" name="Name"    class=" form-control" required/>

                                        </div>

                                        <div class="col-sm-6">
                                            <label class="form-label">نحوه ی اجرای پاداش </label>
                                            <select name="Direct" id="RewardType" class="js-example-rtl col-sm-12"  onchange="changedirect()">
                                                <option value="true">مستقیم</option>
                                                <option value="false">غیر مستقیم</option>
                                            </select>
                                        </div>
                                        <div class="col-sm-6">
                                            <label class="form-label">انتخاب ارز</label>
                                            <select name="Currency" id="Currency" class="js-example-rtl col-sm-12"  >
                                                <% for (var i = 0; i < currency.length; i++) { %>
                                                    <option value="<%= currency[i]._id %>" ><%= currency[i].SmallCaption %></option>
                                                <% } %>
                                            </select>
                                        </div>
                                        <div class="row" id="Direct">
                                            <div class="col-sm-6">
                                            <label class="form-label">نحوه پاداش </label>
                                            <select name="ValueStatus" id="ValueStatus" class="js-example-rtl col-sm-12">
                                                <option value="0">درصدی</option>
                                                <option value="1">نقدی</option>

                                            </select>
                                        </div>
                                            <div class="col-sm-6">
                                            <label class="form-label">مقدار</label>
                                            <input class="form-control" name="Value" id="Value" type="Number"
                                                   placeholder="مقدار"   />

                                        </div>

                                        </div>
                                        <div class="row" id="inDirect" style="display:none">
                                        <div class="col-sm-6">
                                            <label class="form-label">انتخاب نوع پاداش</label>
                                            <select name="ReferenceStatus" id="Reward" class="js-example-rtl col-sm-12"  onchange="changetypereward()">
                                                <option value="defult" >نوع پاداش را انتخاب نمایید</option>
                                                <option value="Coupon">کوپن</option>
                                                <option value="ProductPrice">کالا</option>
                                                <option value="ServicePrice">خدمات</option>
                                                <option value="transport">حمل و نقل</option>

                                            </select>
                                        </div>
                                            <div class="col-sm-6" id="productPrice"  style="display: none">
                                                <label class="form-label">انتخاب برچسب محصولات </label>
                                                <select name="productReferences" id="productPrice1" class="js-example-rtl col-sm-12" onchange="getprovider()" >
                                                    <option value="defult" >یک  پرچسب محصول را انتخاب نمایید</option>
                                                <% for (var i = 0; i < productPrice.length; i++) { %>
                                                        <option value="<%= productPrice[i]._id %>" ><%= productPrice[i].Title %></option>
                                                    <% } %>

                                                </select>
                                            </div>
                                            <div class="col-sm-6" id="Coupon">
                                                <label class="form-label" for="">انتخاب کوپن </label>
                                                <select name="Coupon" id="Coupon1" class="js-example-rtl col-sm-12" onchange="getprovider()"  >
                                                    <option value="defult" >یک کوپن را انتخاب نمایید</option>
                                                <% for (var i = 0; i < coupon.length; i++) { %>
                                                        <option value="<%= coupon[i]._id %>" ><%= coupon[i].Name %></option>
                                                    <% } %>

                                                </select>
                                            </div>
                                            <div class="col-sm-6" id="servicePrice" style="display: none">
                                                <label class="form-label" for="">انتخاب برچسب خدمات </label>
                                                <select name="serviceReferences" id="servicePrice1" class="js-example-rtl col-sm-12" onchange="getprovider()">
                                                    <option value="defult" >یک برچسب خدمات را انتخاب نمایید</option>
                                                <% for (var i = 0; i < servicePrice.length; i++) { %>
                                                        <option value="<%= servicePrice[i]._id %>" ><%= servicePrice[i].Title %></option>
                                                    <% } %>

                                                </select>
                                            </div>

                                            <div class="col-sm-6" style="display: none" id="Count" style="display: none" >
                                                <label class="form-label" for="">تعداد</label>
                                                <input type="number" class="form-control"  name="Count"
                                                       placeholder="تعداد" >
                                            </div>
                                            <div class="col-sm-6" id="listprovider" style="display: none" >
                                                <div class="col-form-label">از چه ارائه دهنده ای </div>
                                                <select name="Providers" id="Providers" class="js-example-rtl col-sm-12" multiple="multiple">

                                                </select>
                                            </div>


                                        </div>
                                        <div class="col-sm-6">
                                            <div class="col-form-label">کمترین مقدار خرید برای پاداش</div>
                                            <input type="text" name="MinPrice" class=" form-control" style="border: 1px solid;height: 34px;" />

                                        </div>
                                        <div class="col-sm-6">
                                            <div class="col-form-label">بیشترین مقدار خرید برای پاداش</div>
                                            <input type="text" name="MaxPrice"    class=" form-control"   style="border: 1px solid;height: 34px;"/>

                                        </div>
                                        <div class="col-sm-6">
                                            <div class="col-form-label">تاریخ شروع پاداش</div>
                                            <input type="text" name="StartDate" class=" datediscount form-control" style="border: 1px solid;height: 34px;" />

                                        </div>
                                        <div class="col-sm-6">
                                            <div class="col-form-label">تاریخ پایان پاداش</div>
                                            <input type="text" name="EndDate"    class="datediscount form-control"   style="border: 1px solid;height: 34px;"/>

                                        </div>
                                        <div class="card-footer text-end">
                                            <button class="btn btn-primary" type="submit">ثبت</button>
                                            <a href="#" class="btn btn-secondary">بازگشت</a>

                                        </div>
                                    </form>

                                </div>

                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12">
                    <div class="card">
                        <div class="card-header">
                            <h5>مشاهده لیست پاداش ها آنسه تیم </h5>
                        </div>
                        <div class="table-responsive">
                            <table class="table">
                                <thead>
                                <tr class="border-bottom-primary" style="text-align:center">
                                    <th scope="col"></th>
                                    <th scope="col">نام پاداش</th>
                                    <th scope="col">نحوه اجرای پاداش</th>
                                    <th scope="col">نوع پاداش</th>
                                    <th scope="col">ویرایش</th>
                                    <th scope="col">حذف</th>
                                </tr>
                                </thead>
                                <tbody>
                                <% for (var i = 0; i < discount.Rewards.length; i++) { %>
                                    <tr class="border-bottom-info" style="text-align:center">
                                        <th scope="row"><%= i + 1 %></th>
                                        <td><%= discount.Rewards[i].Name %></td>
                                        <td><% if(discount.Rewards[i].Options.Direct){ %> مستقیم  <%}else{%> غیر مستقیم<%}%></td>
                                        <% if(discount.Rewards[i].Options.Direct){
                                         if(discount.Rewards[i].Prices.ValueStatus=="0"){ %>
                                            <td>درصدی</td>
                                        <% }  if(discount.Rewards[i].Prices.ValueStatus=="1"){ %>
                                            <td>نقدی</td>
                                        <% } %>

                                        <%}else{
                                            if(discount.Rewards[i].Options.ReferenceStatus=="ProductPrice"){ %>
                                            <td>کالا</td>
                                        <%}  if(discount.Rewards[i].Options.ReferenceStatus=="ServicePrice"){ %>
                                            <td>خدمات</td>
                                        <% }if(discount.Rewards[i].Options.ReferenceStatus=="Coupon"){  %>
                                            <td>کوپن</td>
                                      <% }%>
                                        <% }%>

                                        <td><a href="/<%= lan.ShortName %>/reward/edit/<%= discount.Rewards[i]._id%>"
                                                    class="btn btn-square btn-primary-gradien"><i class="fa fa-edit"></i></a>
                                        </td>
                                        <td><a href="/<%= lan.ShortName %>/reward/remove/<%= discount.Rewards[i]._id%>"
                                               class="btn btn-square btn-danger-gradien"><i class="fa fa-trash-o"></i></a>
                                        </td>
                                    </tr>
                                <% } %>

                                </tbody>
                                </tr>

                                </tbody>
                            </table>

                            <nav aria-label="...">
                                <ul class="pagination pagination-primary m-3">
                                    <li class="page-item"><a class="page-link" href="javascript:void(0)">بعدی</a></li>
                                    <li class="page-item"><a class="page-link" href="javascript:void(0)">3</a></li>
                                    <li class="page-item "><a class="page-link" href="javascript:void(0)">2 <span
                                                    class="sr-only">(current)</span></a></li>
                                    <li class="page-item active"><a class="page-link" href="javascript:void(0)">1</a>
                                    </li>
                                    <li class="page-item disabled"><a class="page-link" href="javascript:void(0)"
                                                                      tabindex="-1">قبلی</a></li>
                                </ul>
                            </nav>
                        </div>
                    </div>
                </div>

            </div>

        </div>
        <!-- Container-fluid Ends-->

        <!-- Container-fluid Ends-->




        <!-- Container-fluid Ends-->



    </div>
    <!-- popup -->
    <%- include("../../partials/popup") %>
    <!-- popup-->

    <%- include("../../partials/footer") %>
</div>
</div>
<!-- latest jquery-->
<script src="/RTL/superAdmin/js/jquery-3.5.1.min.js"></script>
<!-- Bootstrap js-->
<script src="/RTL/superAdmin/js/bootstrap/bootstrap.bundle.min.js"></script>
<!-- feather icon js-->
<script src="/RTL/superAdmin/js/icons/feather-icon/feather.min.js"></script>
<script src="/RTL/superAdmin/js/icons/feather-icon/feather-icon.js"></script>
<!-- scrollbar js-->
<script src="/RTL/superAdmin/js/scrollbar/simplebar.js"></script>
<script src="/RTL/superAdmin/js/scrollbar/custom.js"></script>
<!-- Sidebar jquery-->
<script src="/RTL/superAdmin/js/config.js"></script>
<!-- Plugins JS start-->
<script src="/RTL/superAdmin/js/sidebar-menu.js"></script>
<script src="/RTL/superAdmin/js/prism/prism.min.js"></script>
<script src="/RTL/superAdmin/js/clipboard/clipboard.min.js"></script>
<script src="/RTL/superAdmin/js/custom-card/custom-card.js"></script>
<script src="/RTL/superAdmin/js/tooltip-init.js"></script>
<!-- Plugins JS Ends-->
<!-- Theme js-->
<script src="/RTL/superAdmin/js/script.js"></script>
<!-- login js-->
<!--error message for inputs-->
<script src="/RTL/superAdmin/js/input-error.js"></script>
<script src="/RTL/superAdmin/js/tiny/tinymce.min.js"></script>
<!-- Plugin used-->
<script src="/RTL/superAdmin/js/select2/select2.full.min.js"></script>
<script src="/RTL/superAdmin/js/select2/select2-custom.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.0/axios.min.js"></script>
<!-- script pop up -->
<script src="/RTL/superAdmin/js/anse/albumPopup.js"></script>
<!-- script pesiandate picker up -->
<script src="/RTL/superAdmin/js/pesiandatepicker/persian-date.min.js"></script>
<script src="/RTL/superAdmin/js/pesiandatepicker/persian-datepicker.min.js"></script>
<script src="/RTL/superAdmin/js/pesiandatepicker/app.js"></script>
<script>
    $('.datepicker').persianDatepicker({
        format: 'YYYY/MM/DD',
        calendarType: 'persian'
    });
</script>
<script>
    $(document).ready(function () {
        $('#addTags').click(function () {
            $('#rowTags').append(
                "<div class='col-sm-6'><a class='removeTag'><i class='fa fa-trash-o'></i></a><input class='form-control' name='Tags' id='Tags' type='text' placeholder='متن تگ را وارد کنید '></div>"
            );
        });
        $('#rowTags').on('click', 'div a.removeTag', function () {
            $(this).parent().remove();
        });
    });
    function changetype(){
        var typelist = document.getElementById("ModelType").value;
        if(typelist=="Vendor") {
            document.getElementById("vendor").style.display = 'revert';
            document.getElementById("team").style.display = 'none';
        }
        if(typelist=="Team") {
            document.getElementById("vendor").style.display = 'none';
            document.getElementById("team").style.display = 'revert';

        }

        // alert(typelist);
    }
 function changedirect(){
     var RewardType = document.getElementById("RewardType").value;
     if(RewardType=="true") {
         document.getElementById("Direct").style.display = 'inline-flex';
         document.getElementById("inDirect").style.display = 'none';
     }
     if(RewardType=="false") {
         document.getElementById("Direct").style.display = 'none';
         document.getElementById("inDirect").style.display = 'inline-flex';
     }

 }
    function changetypereward(){
        var RewardType = document.getElementById("Reward").value;
        if(RewardType=="ProductPrice") {
            document.getElementById("productPrice").style.display = 'revert';
            document.getElementById("servicePrice").style.display = 'none';
            document.getElementById("Coupon").style.display = 'none';
            document.getElementById("Count").style.display = 'revert';
            $('#Providers').html('');

        }
        if(RewardType=="ServicePrice") {
            document.getElementById("productPrice").style.display = 'none';
            document.getElementById("servicePrice").style.display = 'revert';
            document.getElementById("Coupon").style.display = 'none';
            document.getElementById("Count").style.display = 'revert';
            $('#Providers').html('');
        }
        if(RewardType=="Coupon") {
            document.getElementById("productPrice").style.display = 'none';
            document.getElementById("servicePrice").style.display = 'none';
            document.getElementById("Coupon").style.display = 'revert';
            document.getElementById("Count").style.display = 'none';
            $('#Providers').html('');
        }

    }
    function getprovider(){
        var RewardType = document.getElementById("Reward").value;
        $('#listprovider').show();
        $('#Providers').html('');
     if(RewardType=="ProductPrice"){
         var productvalue = document.getElementById("productPrice1").value;

     }
         if(RewardType=="ServicePrice"){
             var productvalue = document.getElementById("servicePrice1").value;
         }
        if(RewardType=="Coupon"){
            var productvalue = document.getElementById("Coupon1").value;
        }
         axios.post('/<%= lan.ShortName %>/reward/getproviders',{
            type: RewardType,
             value:productvalue

        })
             .then((res)=>{
                 $('#Providers').html('');
                 if(res.data.type=="ProductPrice"){
                     $('#listprovider').css("display","revert");
                 for(var i=0; i < res.data.listVendors.length; i++) {

                     $("#Providers").append('<option value="'+res.data.listVendors[i]._id +'">'+res.data.listVendors[i].Name+'</option>');
                 }
                 }
                 if(res.data.type=="ServicePrice"){
                     for(var i=0; i < res.data.listTeams.length; i++) {
                         $("#Providers").append('<option value="'+res.data.listTeams[i]._id +'">'+res.data.listTeams[i].Name+'</option>');
                     }
                 }

                 if(res.data.type=="Coupon"){
                     for(var i=0; i < res.data.UseableItems.length; i++) {
                         $("#Providers").append('<option value="'+res.data.UseableItems[i]._id +'">'+res.data.UseableItems[i].Name+'</option>');
                     }
                 }



             })


                //$('#Providers').css("display", "revert");

            .catch(function (error) {
                console.log(error);
            });
    }
</script>
<script>
</script>

<script>
    tinymce.init({
        selector: '#editor',
        plugins: 'anchor autolink charmap codesample emoticons image link lists media searchreplace table visualblocks wordcount',
        toolbar: 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | link image media table | align lineheight | numlist bullist indent outdent | emoticons charmap | removeformat',
    });
</script>

</body>
</html>
