<!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">

    <!-- Mapp styles -->
    <link rel="stylesheet" href="https://cdn.map.ir/web-sdk/1.4.2/css/mapp.min.css">
    <link rel="stylesheet" href="https://cdn.map.ir/web-sdk/1.4.2/css/fa/style.css">
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/anse/map/map.css">
    <link rel="stylesheet" type="text/css" href="/RTL/superAdmin/css/anse/map/extras.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 active">لیست سفارش ها</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="form-space theme-form row" action="/<%= lan.ShortName %>/order/add"
                                          method="post">

                                        <div class="col-sm-6">
                                            <label class="form-label"> عنوان سفارش </label>
                                            <input class="form-control" name="Title" id="Title" type="text"
                                                   placeholder="عنوان سفارش" maxlength="80" required>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="col-form-label">کاربر</div>
                                            <select name="Karfarma" id="Karfarma"
                                                    class="js-example-rtl col-sm-12" required>
                                                <% for (var i = 0; i < users.length; i++) { %>
                                                    <option value="<%= users[i]._id %>"><%= users[i].Mobile %> <%= users[i].UserDocument.Name %> <%= users[i].UserDocument.LastName %></option>
                                                <% } %>
                                            </select>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="col-form-label">نوع سفارش</div>
                                            <select name="OrderType" id="OrderType" class="form-control" required>
                                                <% for (var i = 0; i < orderTypes.length; i++) { %>
                                                    <option value="<%= orderTypes[i]._id %>"><%= orderTypes[i].OrderTypeDocument.Name %></option>
                                                <% } %>
                                            </select>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="col-form-label">کالا</div>
                                            <select name="Product" id="Product" class="js-example-rtl col-sm-12"
                                                    required>
                                                <% for (var i = 0; i < products.length; i++) { %>
                                                    <option value="<%= products[i]._id %>"><%= products[i].Code %> <%= products[i].ProductDocument.Name %></option>
                                                <% } %>
                                            </select>
                                        </div>

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

                                        <div class="col-sm-6">
                                            <div class="col-form-label">واحد</div>
                                            <select name="Unit" id="Unit" class="form-control" required>
                                                <% for (var i = 0; i < productUnits.length; i++) { %>
                                                    <option value="<%= productUnits[i]._id %>"><%= productUnits[i].UnitDocument.Name %> <%= productUnits[i].Symbol %></option>
                                                <% } %>
                                            </select>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="col-form-label">رنگ</div>
                                            <select name="Color" id="Color" class="form-control" required disabled>
                                                <% for (var i = 0; i < colors.length; i++) { %>
                                                    <% if(colors[i].Default == true) { %>
                                                        <option value="<%= colors[i]._id %>"
                                                                selected><%= colors[i].ColorDocument.Name %></option>
                                                    <% } else { %>
                                                        <option value="<%= colors[i]._id %>"><%= colors[i].ColorDocument.Name %></option>
                                                    <% } %>
                                                <% } %>
                                            </select>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="col-form-label">سایز</div>
                                            <select name="Size" id="Size" class="form-control" required disabled>
                                                <% for (var i = 0; i < sizes.length; i++) { %>
                                                    <% if(sizes[i].Default == true) { %>
                                                        <option value="<%= sizes[i]._id %>"
                                                                selected><%= sizes[i].SizeDocument.Name %></option>
                                                    <% } else { %>
                                                        <option value="<%= sizes[i]._id %>"><%= sizes[i].SizeDocument.Name %></option>
                                                    <% } %>
                                                <% } %>
                                            </select>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="col-form-label">گارانتی</div>
                                            <select name="Guarantee" id="Guarantee" class="form-control" required
                                                    disabled>
                                                <% for (var i = 0; i < guarantees.length; i++) { %>
                                                    <% if(guarantees[i].Default == true) { %>
                                                        <option value="<%= guarantees[i]._id %>"
                                                                selected><%= guarantees[i].GuaranteeDocument.Name %></option>
                                                    <% } else { %>
                                                        <option value="<%= guarantees[i]._id %>"><%= guarantees[i].GuaranteeDocument.Name %></option>
                                                    <% } %>
                                                <% } %>
                                            </select>
                                        </div>

                                        <fieldset>
                                            <legend>پیشنهاد کاربر</legend>

                                            <div class="row">
                                                <div class="col-sm-6">
                                                    <label class="form-label" for="">قیمت</label>
                                                    <input type="number" class="form-control" id="SuggestionPrice" name="SuggestionPrice"
                                                           placeholder="قیمت">
                                                </div>

                                                <div class="col-sm-6">
                                                    <div class="col-form-label">ارز</div>
                                                    <select name="SuggestionCurrency" id="SuggestionCurrency" class="form-control" required>
                                                        <% for (var i = 0; i < currencys.length; i++) { %>
                                                            <option value="<%= currencys[i]._id %>"><%= currencys[i].Name %></option>
                                                        <% } %>
                                                    </select>
                                                </div>

                                                <div class="col-sm-6">
                                                    <label class="form-label" for="">زمان پیشنهادی</label>
                                                    <input type="number" class="form-control" id="SuggestionDuration" name="SuggestionDuration"
                                                           placeholder="زمان پیشنهادی">
                                                </div>

                                                <div class="col-sm-6">
                                                    <div class="col-form-label">زمان</div>
                                                    <select name="SuggestionUnit" id="SuggestionUnit" class="form-control" required>
                                                        <% for (var i = 0; i < timeUnits.length; i++) { %>
                                                            <option value="<%= timeUnits[i]._id %>"><%= timeUnits[i].UnitDocument.Name %> <%= timeUnits[i].Symbol %></option>
                                                        <% } %>
                                                    </select>
                                                </div>
                                            </div>

                                        </fieldset>

                                        <div class="col-sm-6">
                                            <label class="form-label">کشور</label>
                                            <select name="Country" id="Country" class="form-select form-control-lg">
                                                <% for(var i = 0; i < countrys.length; i++){ %>
                                                    <option value="<%= countrys[i]._id %>"><%= countrys[i].ZoneTypeDocument.Name %></option>
                                                <% } %>
                                            </select>
                                        </div>

                                        <div class="col-sm-6">
                                            <label class="form-label">استان</label>
                                            <select name="State" id="State" class="form-select form-control-lg">

                                            </select>
                                        </div>

                                        <div class="col-sm-6">
                                            <label class="form-label">شهر</label>
                                            <select name="ZoneType" id="ZoneType" class="form-select form-control-lg">

                                            </select>
                                        </div>

                                        <div class="col-sm-12">
                                            <label class="form-label">ادامه آدرس</label>
                                            <input class="form-control" name="Address" id="Address" type="text"
                                                   placeholder="ادامه آدرس">
                                        </div>

                                        <div class="col-sm-12 d-none">
                                            <input class="form-control" name="Latitude" id="Latitude" type="text">
                                        </div>

                                        <div class="col-sm-12 d-none">
                                            <input class="form-control" name="Longitude" id="Longitude" type="text">
                                        </div>

                                        <div class="container" style="height: 400px">
                                            <div class="app-wrapper h-100 w-100">
                                                <div id="app">
                                                    <div class="app-overlay"></div>
                                                </div>
                                                <div id="center-marker" class="hide"></div>
                                                <div id="latlong"></div>
                                            </div>
                                        </div>

                                        <div class="mb-3">
                                            <label class="form-label" for="SmallCaption">توضیحات کوتاه</label>
                                            <textarea class="form-control" id="SmallCaption" name="SmallCaption"
                                                      placeholder="توضیحات کوتاه این سفارش را وارد کنید" required
                                                      maxlength="200"></textarea>
                                        </div>
                                        <div class="mb-3">
                                            <label class="form-label" for="Caption">توضیحات سفارش</label>
                                            <textarea class="form-control" id="Caption" name="Caption"
                                                      placeholder="توضیحات این سفارش را وارد کنید"></textarea>
                                        </div>

                                        <div class="col-sm-3 m-4">
                                            <a href="#" class="btn btn-info" id="ChooseFiles" data-bs-toggle="modal"
                                               data-bs-target="#printModal"
                                               onclick="albumPopup(lan='<%= lan.ShortName %>', btn='ChooseFiles', albumFiles='AlbumFiles', multi=true, exist=false, model='order', modelId=null, modelFilesName='Files')">انتخاب
                                                تصاویر</a>
                                        </div>
                                        <div id="AlbumFiles">

                                        </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 %>/orderType/list" class="btn btn-success">مشاهده
                                                دسته بندی
                                                سفارش ها</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>
                                    <th scope="col">ثبت پیشنهاد</th>
                                    <th scope="col">ویرایش آدرس</th>
                                    <th scope="col">ویرایش</th>
                                    <th scope="col">حذف</th>
                                </tr>
                                </thead>
                                <tbody>

                                <% for (var i = 0; i < orders.length; i++) { %>
                                <tr class="border-bottom-info" style="text-align:center">
                                    <th scope="row"><%= i + 1 %></th>
                                    <td><%= orders[i].Title %></td>
                                    <td>
                                        <% if(orders[i].OrderTypeDocument.length > 0) { %>
                                            <%= orders[i].OrderTypeDocument[0].Name %>
                                        <% } else { %>
                                            <%= orders[i].OrderTypeDocuments[0].Name %>
                                        <% } %>
                                    </td>
                                    <td><%= orders[i].ProductDocument[0].Name %></td>
                                    <td><%= orders[i].MontasherKonandeDetail[0].Name %> <%= orders[i].MontasherKonandeDetail[0].LastName %></td>
                                    <% if(orders[i].Show == true) { %>
                                        <td><a href="/<%= lan.ShortName %>/order/show/<%= orders[i]._id %>"
                                               class="btn btn-square btn-info-gradien"><i class="fa fa-check"></i></a>
                                        </td>
                                    <% } else { %>
                                        <td><a href="/<%= lan.ShortName %>/order/show/<%= orders[i]._id %>"
                                               class="btn btn-square btn-warning-gradien"><i
                                                        class="fa fa-xmark"></i></a></td>
                                    <% } %>
                                    <td><a href="/<%= lan.ShortName %>/productOffer/list/<%= orders[i]._id %>"
                                           class="btn btn-square btn-dark-gradien"><i class="fa fa-solid fa-comments-dollar"></i></a>
                                    </td>
                                    <td><a href="/<%= lan.ShortName %>/address/edit/order/<%= orders[i]._id %>/<%= orders[i].Address %>"
                                           class="btn btn-square btn-info-gradien"><i class="fa-solid fa-map-location-dot"></i></a>
                                    </td>
                                    <td><a href="/<%= lan.ShortName %>/order/edit/<%= orders[i]._id %>"
                                           class="btn btn-square btn-primary-gradien"><i class="fa fa-edit"></i></a>
                                    </td>
                                    <td><a href="/<%= lan.ShortName %>/order/remove/<%= orders[i]._id %>"
                                           class="btn btn-square btn-danger-gradien"><i class="fa fa-trash-o"></i></a>
                                    </td>
                                    <% } %>

                                </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-->
    </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>

<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>

<!-- Mapp scripts -->
<script src="https://cdn.map.ir/web-sdk/1.4.2/js/jquery-3.2.1.min.js"></script>
<script src="https://cdn.map.ir/web-sdk/1.4.2/js/mapp.env.js"></script>
<script src="https://cdn.map.ir/web-sdk/1.4.2/js/mapp.min.js"></script>
<script src="/RTL/superAdmin/js/anse/map/hack.js"></script>
<script src="/RTL/superAdmin/js/anse/map/map.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>
    window.addEventListener("load", function () {
        makeMap(50, 50)

        var product = $("#Product").val()

        axios
            .get("/<%= lan.ShortName %>/productTypePrice/list/" + product)
            .then((res) => {
                if (res.data.productTypePrice.Color == true) {
                    $('#Color').prop('disabled', false);
                }

                if (res.data.productTypePrice.Size == true) {
                    $('#Size').prop('disabled', false);
                }

                if (res.data.productTypePrice.Guarantee == true) {
                    $('#Guarantee').prop('disabled', false);
                }
            })

        var country = $("#Country").val()

        axios
            .get("/<%= lan.ShortName %>/zonetype/getsubtype/" + country)
            .then((res) => {
                $("#State").empty()
                for (var i = 0; i < res.data.zoneTypeDocuments.length; i++) {
                    $("#State").append('<option value="' + res.data.zoneTypeDocuments[i].ZoneType._id + '">' + res.data.zoneTypeDocuments[i].Name + '</option>')
                }

                var state = $("#State").val()

                axios
                    .get("/<%= lan.ShortName %>/zonetype/getsubtype/" + state)
                    .then((res) => {
                        $("#ZoneType").empty()
                        for (var i = 0; i < res.data.zoneTypeDocuments.length; i++) {
                            $("#ZoneType").append('<option value="' + res.data.zoneTypeDocuments[i].ZoneType._id + '">' + res.data.zoneTypeDocuments[i].Name + '</option>')
                        }
                    })
            })
    })

    $("#Country").change(function () {
        var country = $("#Country").val()

        axios
            .get("/<%= lan.ShortName %>/zonetype/getsubtype/" + country)
            .then((res) => {
                $("#State").empty()
                for (var i = 0; i < res.data.zoneTypeDocuments.length; i++) {
                    $("#State").append('<option value="' + res.data.zoneTypeDocuments[i].ZoneType._id + '">' + res.data.zoneTypeDocuments[i].Name + '</option>')
                }

                var state = $("#State").val()

                axios
                    .get("/<%= lan.ShortName %>/zonetype/getsubtype/" + state)
                    .then((res) => {
                        $("#ZoneType").empty()
                        for (var i = 0; i < res.data.zoneTypeDocuments.length; i++) {
                            $("#ZoneType").append('<option value="' + res.data.zoneTypeDocuments[i].ZoneType._id + '">' + res.data.zoneTypeDocuments[i].Name + '</option>')
                        }
                    })
            })
    })

    $("#State").change(function () {
        var state = $("#State").val()

        axios
            .get("/<%= lan.ShortName %>/zonetype/getsubtype/" + state)
            .then((res) => {
                $("#ZoneType").empty()
                for (var i = 0; i < res.data.zoneTypeDocuments.length; i++) {
                    $("#ZoneType").append('<option value="' + res.data.zoneTypeDocuments[i].ZoneType._id + '">' + res.data.zoneTypeDocuments[i].Name + '</option>')
                }
            })
    })
</script>

<script>
    $("#Product").change(function () {
        var product = $("#Product").val()

        axios
            .get("/<%= lan.ShortName %>/productTypePrice/list/" + product)
            .then((res) => {
                if (res.data.productTypePrice.Color == true) {
                    $('#Color').prop('disabled', false);
                } else {
                    $('#Color').prop('disabled', 'disabled');
                }

                if (res.data.productTypePrice.Size == true) {
                    $('#Size').prop('disabled', false);
                } else {
                    $('#Size').prop('disabled', 'disabled');
                }

                if (res.data.productTypePrice.Guarantee == true) {
                    $('#Guarantee').prop('disabled', false);
                } else {
                    $('#Guarantee').prop('disabled', 'disabled');
                }
            })
    })
</script>

</body>
</html>
