<!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">
</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="form-space theme-form row" action="/<%= lan.ShortName %>/vendor/edit/<%= vendor._id %>"
                                          method="post">

                                        <div class="col-sm-6">
                                            <label class="form-label"> نام تامین کننده </label>
                                            <input class="form-control" name="Name" id="Name" type="text"
                                                   placeholder="نام تامین کننده" maxlength="80" required value="<%= vendor.Name %>" >
                                        </div>

                                        <div class="col-sm-6">
                                            <label class="form-label" for="">نوع مالکیت</label>
                                            <select  name="OwnerType" id="OwnerType" class="form-select form-control-lg" >
                                                <% if(vendor.Owner.User == undefined){ %>
                                                    <option value="1" >حقوقی</option>
                                                <% } else { %>
                                                    <option value="0" >حقیقی</option>
                                                <% } %>
                                            </select>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="col-form-label">نام مالک</div>
                                            <select name="User" id="User" class="js-example-rtl col-sm-12"
                                                    required>
                                                <% for (var i = 0; i < users.length; i++) { %>
                                                    <% if(vendor.Owner.User.equals(users[i]._id)) { %>
                                                        <option value="<%= users[i]._id %>" selected><%= users[i].UserDocument.Name %> <%= users[i].UserDocument.LastName %></option>
                                                    <% } else { %>
                                                        <option value="<%= users[i]._id %>"><%= users[i].UserDocument.Name %> <%= users[i].UserDocument.LastName %></option>
                                                    <% } %>
                                                <% } %>
                                            </select>
                                        </div>

                                        <div class="row" id="OwnerTypeDetail">

                                            <div class="col-sm-6 d-none">
                                                <label class="form-label">نوع شرکت</label>
                                                <input class="form-control" name="TypeOfCompany" id="TypeOfCompany" type="hidden"
                                                       placeholder="نوع شرکت" maxlength="80" required value="<%= vendor.Owner.TypeOfCompany %>" >
                                            </div>

                                            <div class="col-sm-6 d-none">
                                                <label class="form-label">شماره ثبت</label>
                                                <input class="form-control" name="ShomareSabt" id="ShomareSabt" type="hidden"
                                                       placeholder="شماره ثبت" maxlength="80" required value="<%= vendor.Owner.ShomareSabt %>" >
                                            </div>

                                            <div class="col-sm-6 d-none">
                                                <label class="form-label">شناسه ملی</label>
                                                <input class="form-control" name="ShenaseMeli" id="ShenaseMeli" type="hidden"
                                                       placeholder="شناسه ملی" maxlength="80" required value="<%= vendor.Owner.ShenaseMeli %>" >
                                            </div>

                                            <div class="col-sm-6 d-none">
                                                <label class="form-label">کد اقتصادی</label>
                                                <input class="form-control" name="CodeEghtesadi" id="CodeEghtesadi" type="hidden"
                                                       placeholder="کد اقتصادی" maxlength="80" required value="<%= vendor.Owner.CodeEghtesadi %>" >
                                            </div>

                                            <div class="col-sm-6 d-none">
                                                <label class="form-label">صاحبان حق امضا</label>
                                                <input class="form-control" name="SahebanHaghEmza" id="SahebanHaghEmza" type="hidden"
                                                       placeholder="صاحبان حق امضا" maxlength="80" required value="<%= vendor.Owner.SahebanHaghEmza %>" >
                                            </div>
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="col-form-label">نوع تامین کننده</div>
                                            <select name="VendorType" id="VendorType" class="js-example-rtl col-sm-12"
                                                    required>
                                                <% for (var i = 0; i < vendorTypes.length; i++) { %>
                                                    <% if(vendor.VendorType.equals(vendorTypes[i]._id)) { %>
                                                        <option value="<%= vendorTypes[i]._id %>" selected><%= vendorTypes[i].VendorTypeDocument.Name %></option>
                                                    <% } else { %>
                                                        <option value="<%= vendorTypes[i]._id %>"><%= vendorTypes[i].VendorTypeDocument.Name %></option>
                                                    <% } %>
                                                <% } %>
                                            </select>
                                        </div>

                                        <div class="col-sm-6">
                                            <label class="form-label" for="">رتبه دهی</label>
                                            <input type="number" class="form-control" id="Rate" name="Rate"
                                                   placeholder="رتبه دهی" value="<%= vendor.Rate %>">
                                        </div>

                                        <div class="col-sm-6">
                                            <div class="col-form-label">انواع کالا</div>
                                            <select name="ProductTypes" id="ProductTypes" class="js-example-rtl col-sm-12"
                                                    multiple="multiple">
                                                <% for (var i = 0; i < productTypes.length; i++) { %>
                                                    <% if(vendor.ProductTypes.includes(productTypes[i]._id)) { %>
                                                        <option value="<%= productTypes[i]._id %>" selected><%= productTypes[i].ProductTypeDocument.Name %></option>
                                                    <% } else { %>
                                                        <option value="<%= productTypes[i]._id %>"><%= productTypes[i].ProductTypeDocument.Name %></option>
                                                    <% } %>
                                                <% } %>
                                            </select>
                                        </div>

                                        <div class="col-sm-6">
                                            <label class="form-label" for="">کد پستی</label>
                                            <input type="text" class="form-control" id="PostalCode" name="PostalCode"
                                                   placeholder="کد پستی" value="<%= vendor.PostalCode %>">
                                        </div>

                                        <div class="col-sm-6">
                                            <label class="form-label" for="">تلفن ثابت</label>
                                            <input type="text" class="form-control" id="TellSabet" name="TellSabet"
                                                   placeholder="تلفن ثابت" value="<%= vendor.TellSabet %>">
                                        </div>

                                        <div class="col-sm-6">
                                            <label class="form-label" for="">تلفن همراه</label>
                                            <input type="text" class="form-control" id="Mobile" name="Mobile"
                                                   placeholder="تلفن همراه" value="<%= vendor.Mobile %>">
                                        </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='vendor', modelId='<%= vendor._id %>', modelFilesName='Logo')">انتخاب لوگو</a>
                                        </div>
                                        <div id="AlbumFile">

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

<script>
    window.addEventListener("load", function () {
        getModelFiles(lan='<%= lan.ShortName %>', albumFiles='AlbumFile', model='vendor', modelId='<%= vendor._id %>', modelFilesName='Logo')


        var ownerType = $("#OwnerType").val()

        if(ownerType == "0") {
            $("#OwnerTypeDetail input:text").attr("type", "hidden")
            $("#OwnerTypeDetail input").parent().addClass("d-none")
        } else if(ownerType == "1") {
            $("#OwnerTypeDetail input:hidden").attr("type", "text")
            $("#OwnerTypeDetail input").parent().removeClass("d-none")
        }
    })

    $("#OwnerType").change(function () {
        var ownerType = $("#OwnerType").val()

        if(ownerType == "0") {
            $("#OwnerTypeDetail input:text").attr("type", "hidden")
            $("#OwnerTypeDetail input").parent().addClass("d-none")
        } else if(ownerType == "1") {
            $("#OwnerTypeDetail input:hidden").attr("type", "text")
            $("#OwnerTypeDetail input").parent().removeClass("d-none")
        }
    })
</script>

</body>
</html>
