<!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-->
    <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">
    <!-- 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 %>/user/edit/<%= currentUser._id %>"
                                          method="post">
                                        <div class="col-sm-6">
                                            <label class="form-label">نام</label>
                                            <input class="form-control" name="Name" id="Name" type="text"
                                                   placeholder="نام" required value="<%= currentUser.Name %>">
                                        </div>
                                        <div class="col-sm-6">
                                            <label class="form-label">نام خانوادگی</label>
                                            <input class="form-control" name="LastName" id="LastName" type="text"
                                                   placeholder="نام خانوادگی" required value="<%= currentUser.LastName %>">
                                        </div>
                                        <div class="col-sm-6">
                                            <label class="form-label">جنسیت</label>
                                            <select name="Gender" id="Gender" class="form-select form-control-lg">
                                                <% if( currentUser.Gender == "Female" ){ %>
                                                    <option value="Female" selected>زن</option>
                                                    <option value="Male">مرد</option>
                                                <% } else { %>
                                                    <option value="Female">زن</option>
                                                    <option value="Male" selected>مرد</option>
                                                <% } %>
                                            </select>
                                        </div>
                                        <div class="col-sm-6">
                                            <label class="form-label">کدملی</label>
                                            <input class="form-control" name="NationalCode" id="NationalCode"
                                                   type="text" required placeholder="کدملی" value="<%= currentUser.NationalCode %>">
                                        </div>

                                        <div class="col-sm-6">
                                            <label class="form-label">شماره تماس</label>
                                            <input class="form-control" name="Mobile" id="Mobile" type="text" required
                                                   placeholder="شماره تماس" value="<%= currentUser.Mobile %>" readonly>
                                        </div>

                                        <div class="col-sm-6">
                                            <label class="form-label">ایمیل</label>
                                            <input class="form-control" name="Email" id="Email" type="text"
                                                   placeholder="ایمیل" value="<%= currentUser.Email %>">
                                        </div>

                                        <div class="col-sm-6">
                                            <label class="form-label">کد معرف</label>
                                            <input class="form-control" name="Moaref" id="Moaref" type="text"
                                                   placeholder="کد معرف" value="<%= currentUser.Moaref %>">
                                        </div>


                                        <div class="col-sm-6">
                                            <label class="form-label">ارز </label>
                                            <select class="form-control" name="Currency" id="Currency" type="text"
                                                    placeholder="ارز " 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">دسته بندی کاربر</label>
                                            <select name="UserType" id="UserType" class="form-select form-control-lg">
                                                <% for(var i = 0; i < userTypes.length; i++) { %>
                                                    <% if( userTypes[i]._id.equals(currentUser.UserType._id) ){ %>
                                                        <option value="<%= userTypes[i]._id %>" selected><%= userTypes[i].UserTypeDocument.Name %></option>
                                                    <% } else { %>
                                                        <option value="<%= userTypes[i]._id %>"><%= userTypes[i].UserTypeDocument.Name %></option>
                                                    <% } %>
                                                <% } %>
                                            </select>
                                        </div>

                                        <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++){ %>
                                                    <% if( countrys[i]._id.equals(userZoneTypeDocuments[0].ZoneType._id) ){ %>
                                                        <option value="<%= countrys[i]._id %>" selected><%= countrys[i].ZoneTypeDocument.Name %></option>
                                                    <% } else { %>
                                                        <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">
                                                <option value="<%= userZoneTypeDocuments[1].ZoneType._id %>" selected><%= userZoneTypeDocuments[1].ZoneType.Name %></option>
                                            </select>
                                        </div>

                                        <div class="col-sm-6">
                                            <label class="form-label">شهر</label>
                                            <select name="ZoneType" id="ZoneType" class="form-select form-control-lg">
                                                <option value="<%= userZoneTypeDocuments[2].ZoneType._id %>" selected><%= userZoneTypeDocuments[2].ZoneType.Name %></option>
                                            </select>
                                        </div>

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

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

                                        <div class="col-sm-12 d-none">
                                            <input class="form-control" name="Longitude" id="Longitude" type="text" value="<%= currentUser.Address.Longitude %>">
                                        </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="iding">-->
                                                <!--                                                    <span>ساخته شده توسط: </span>-->
                                                <!--                                                    <a href="http://iding.ir" target="_blank">آیدین قانع خ.</a>-->
                                                <!--                                                    <span> برای </span>-->
                                                <!--                                                    <a href="https://corp.map.ir" target="_blank">مپ</a>-->
                                                <!--                                                </div>-->
                                                <div id="latlong"></div>
                                            </div>
                                        </div>

                                        <div class="col-sm-3 m-4">
                                            <a href="#" class="btn btn-info" id="ChooseFile" data-bs-toggle="modal" data-bs-target="#printModal" onclick="albumPopup(lan='<%= lan.ShortName %>', btn='ChooseFile', albumFiles='AlbumFile', multi=false, exist=true, model='user', modelId='<%= currentUser._id %>', modelFilesName='ProfileImage')">انتخاب تصویر پروفایل</a>
                                        </div>
                                        <div id="AlbumFile">

                                        </div>

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

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

            </div>

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

        <!-- Container-fluid Ends-->
    </div>
    <!-- popup -->
    <%- include("../../../partials/popup") %>
    <!-- popup-->
    <!-- footer start-->
    <%- include("../../../partials/footer") %>

</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-->
<!-- Plugin used-->
<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 type="text/javascript" src="https://cdn.map.ir/web-sdk/1.4.2/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="https://cdn.map.ir/web-sdk/1.4.2/js/mapp.env.js"></script>
<script type="text/javascript" src="https://cdn.map.ir/web-sdk/1.4.2/js/mapp.min.js"></script>
<script type="text/javascript" src="/RTL/superAdmin/js/anse/map/hack.js"></script>
<script type="text/javascript" src="/RTL/superAdmin/js/anse/map/map.js"></script>

<script>
    window.onload = function () {
        makeMap('<%= currentUser.Address.Latitude %>', '<%= currentUser.Address.Longitude %>')
        getModelFiles(lan='<%= lan.ShortName %>', albumFiles='AlbumFile', model='user', modelId='<%= currentUser._id %>', modelFilesName='ProfileImage')
    }
</script>

<script>

    $("#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>

</body>
</html>
