<!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">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.3.1/css/ion.rangeSlider.min.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">
</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 %>/dashboard"><i
                                            data-feather="home"></i></a></li>
                            <li class="breadcrumb-item">تامین کننده ها</li>
                            <li class="breadcrumb-item">تامین کننده ها</li>
                            <li class="breadcrumb-item">لیست تامین کننده ها</li>
                            <li class="breadcrumb-item active">ویرایش تامین کننده <%= vendor.Name %></li>
                        </ol>
                    </div>
                </div>
            </div>
        </div>
        <!-- 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="theme-form form-label-align-right " action="/<%= lan.ShortName %>/vendor/workSchedule/<%= vendor._id %>"
                                          method="post">
                                        <a class="btn btn-info" id="AddNewTime" >افزودن زمان جدید</a>

                                        <% for(var i=0; i < vendor.WorkSchedule.length; i++){ %>
                                            <div class="form-group row">
                                                <% for(var j=0; j < vendor.WorkSchedule[i].Times.length; j++ ){ %>
                                                    <div class="row">
                                                        <div class="col-sm-4">
                                                            <label class="form-label" for="">روز هفته</label>
                                                            <select  name="<%= vendor.WorkSchedule[i].Day%>" id="<%= vendor.WorkSchedule[i].Day%>" class="form-select form-control-lg">
                                                                <% if(vendor.WorkSchedule[i].Day === "Saturday") { %>
                                                                    <option value="Saturday" selected>شنبه</option>
                                                                <% } else if(vendor.WorkSchedule[i].Day === "Sunday") { %>
                                                                    <option value="Sunday" selected>یکشنبه</option>
                                                                <% } else if(vendor.WorkSchedule[i].Day === "Monday") { %>
                                                                    <option value="Monday" selected>دوشنبه</option>
                                                                <% } else if(vendor.WorkSchedule[i].Day === "Tuesday") { %>
                                                                    <option value="Tuesday" selected>سه‌شنبه</option>
                                                                <% } else if(vendor.WorkSchedule[i].Day === "Wednesday") { %>
                                                                    <option value="Wednesday" selected>چهارشنبه</option>
                                                                <% } else if(vendor.WorkSchedule[i].Day === "Thursday") { %>
                                                                    <option value="Thursday" selected>پنج‌شنبه</option>
                                                                <% } else if(vendor.WorkSchedule[i].Day === "Friday") { %>
                                                                    <option value="Friday" selected>جمعه</option>
                                                                <% } %>
                                                            </select>
                                                        </div>

                                                        <div class="col-sm-3">
                                                            <label class="form-label">ساعت بازکردن </label>
                                                            <input class="form-control" name="Open<%= vendor.WorkSchedule[i].Day%>" id="Open<%= vendor.WorkSchedule[i].Day%>" type="number"
                                                                   placeholder="ساعت بازکردن " min="0" max="24" value="<%= vendor.WorkSchedule[i].Times[j].Open %>" required >
                                                        </div>

                                                        <div class="col-sm-3">
                                                            <label class="form-label">ساعت بستن </label>
                                                            <input class="form-control" name="Close<%= vendor.WorkSchedule[i].Day%>" id="Close<%= vendor.WorkSchedule[i].Day%>" type="number"
                                                                   placeholder="ساعت بستن " min="0" max="24" value="<%= vendor.WorkSchedule[i].Times[j].Close %>" required >
                                                        </div>

                                                        <a class="removeTag col-sm-2 text-center" style="margin-top: 7%;"><i class="fa fa-trash-o"></i></a>

                                                    </div>
                                                <% } %>
                                            </div>
                                        <% } %>

                                        <div class="form-group row time-list"></div>


                                        <div class="card-footer text-end">
                                            <button class="btn btn-primary" type="submit">ثبت</button>
                                            <a href="#" class="btn btn-secondary">بازگشت</a>
                                            <a href="/<%= lan.ShortName %>/vendorType/list" class="btn btn-success">مشاهده دسته بندی
                                                تامین کننده ها</a>
                                        </div>
                                    </form>

                                </div>

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

            </div>

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

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

    <%- 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 src="https://cdnjs.cloudflare.com/ajax/libs/ion-rangeslider/2.3.1/js/ion.rangeSlider.min.js"></script>

<script>
    $(".removeTag").click(function (){
        $(this).parent().remove();
    })

    $('.time-list').on('click', 'a.removeTag', function () {
        $(this).parent().remove();
    })
</script>

<script>
    $("#AddNewTime").click(function () {
        $(".time-list").append('<div class="row"><div class="col-sm-4"><label class="form-label" for="">روز هفته</label><select  name="Saturday" id="Saturday" class="form-select form-control-lg"><option value="Saturday" selected>شنبه</option><option value="Sunday">یکشنبه</option><option value="Monday">دوشنبه</option><option value="Tuesday">سه‌شنبه</option><option value="Wednesday">چهارشنبه</option><option value="Thursday">پنج‌شنبه</option><option value="Friday">جمعه</option></select></div><div class="col-sm-3"><label class="form-label">ساعت بازکردن </label><input class="form-control" name="OpenSaturday" id="OpenSaturday" type="number" placeholder="ساعت بازکردن " min="0" max="24" value="9" required ></div><div class="col-sm-3"><label class="form-label">ساعت بستن </label><input class="form-control" name="CloseSaturday" id="CloseSaturday" type="number" placeholder="ساعت بستن " min="0" max="24" value="18" required ></div><a class="removeTag col-sm-2 text-center" style="margin-top: 7%;"><i class="fa fa-trash-o"></i></a></div>')
    })

    $('.time-list').on('change', 'div div select', function () {
        console.log("hi")
        var day = $(this).val()
        console.log(day)
        $(this).attr("name", day)
        var siblings = $(this).parent().siblings()
        console.log(siblings)
        console.log(siblings[0].children[1])
        siblings[0].children[1].name = "Open" + day
        siblings[0].children[1].id = "Open" + day
        siblings[1].children[1].name = "Close" + day
        siblings[1].children[1].id = "Close" + day
            // .attr("name", "Close" + day)
    })

</script>

</body>
</html>
