<!DOCTYPE html>
<html lang="en" class="h-100">


<head>
    <!-- meta and links start -->
    <%- include('templet/meta')-%>



</head>

<body>
    <%- include('templet/preloder_topbar_sidebar',{titel: accessdata?.topbardata?.name})-%>

        <!--********** Content body start **********-->

        <div class="content-body">

            <div class="container-fluid" style="min-height: 100vh;">
                <div class="row">
                    <div class="col-12">
                        <div class="card ">
                            <div class="card-header">
                                <h3 class="card-title">
                                    <%= language.Add_New_Shop %>
                                </h3>
                            </div>
                            <div class="card-body">

                                <form class="row g-4 align-items-center need-validation" action="/tool/shopregister"
onsubmit="return validateForm()"
                                    method="post" enctype="multipart/form-data" >

                                    <h4>
                                        <%= language.APPLICATION_DETAILS %>
                                    </h4>

                                    <hr>
                                    <div class="row">

                                        <div class="col-xl-9">
                                            <div class="row mt-3">
                                                <div class="col-md-6">
                                                    <label class="form-label">
                                                        <%= language.Application_Name %> <span
                                                                class="text-danger">*</span>
                                                    </label>
                                                    <input type="text" placeholder="Enter Application Name"
                                                        class="form-control" name="name" value="" required>
                                                </div>

                                                <div class="col-md-6">
                                                    <label class="form-label">
                                                        <%= language.Phone_Number %> <span class="text-danger">*</span>
                                                    </label>
                                                    <input type="number" class="form-control"
                                                        placeholder="Enter Phone Number" name="number" value=""
                                                        required>
                                                </div>
                                            </div>

                                            <div class="row mt-4">
                                                <div class="col-md-6">
                                                    <label class="form-label">
                                                        <%= language.Username %> <span class="text-danger">*</span>
                                                    </label>
                                                    <input type="text" class="form-control"
                                                        placeholder="Enter User Name" name="username" value="" required>
                                                </div>

                                                <div class="col-md-6">
                                                    <label class="form-label">
                                                        <%= language.Password %> <span class="text-danger">*</span>
                                                    </label>
                                                    <input type="text" class="form-control" placeholder="Enter Password"
                                                        name="password"  value="" required >
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-xl-3">
                                            <div class="center">
                                                <div class="form-input">
                                                    <div class="preview m-3 mt-0">
                                                        <img id="file-preview" width="180" src="../images/one.png"
                                                            alt="image">
                                                    </div>

                                                    <input class="d-none" type="file" id="file-1" name="logo"
                                                        accept="image/*" onchange="showPreview(event);">

                                                    <label class="btn btn-primary w-100" onclick="resetPreview()" for="file-1">
                                                        <%= language.Upload_App_Logo %>
                                                    </label>
                                                    <span class="text-center d-none text-danger fw-bold"
                                                        id="ImgRequired"> <strong>⚠ Image is required!</strong></span>


                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-md-4 mt-4">
                                            <label class="form-label">
                                                Walk In Customer
                                            </label>
                                            <input type="text" class="form-control" placeholder="Add WalK Customer name"
                                                name="walkincustome" value="Walk in Customer" required>
                                        </div>
                                    </div>

                                    <hr>

                                    <h4>
                                        <%= language.FINANCE_SETTINGS %>
                                    </h4>

                                    <hr>

                                    <div class="col-md-4">
                                        <label class="form-label">
                                            <%= language.Shop_Commission %>
                                        </label>
                                        <input type="number" class="form-control" placeholder="Shop Commission"
                                            name="commission" value="" required>
                                    </div>

                                    <div class="col-md-4">
                                        <label class="form-label">
                                            <%= language.Tax_Percentage %>
                                        </label>
                                        <input type="text" class="form-control" name="taxpercent" value="" required>
                                    </div>

                                    <hr>

                                    <h4>
                                        <%= language.FIRM_ADDRESS %>
                                    </h4>

                                    <hr>

                                    <div class="col-md-3">
                                        <label class="form-label">
                                            <%= language.Country %>
                                        </label>
                                        <input type="text" class="form-control" placeholder="Enter Country Name"
                                            name="country" value="" required>
                                        <!-- <select class="default-select form-control wide mb-3" name="country" required >
                                            <option value="" selected disabled>Select One</option>
                                            <option value="AR"  >Argentina [AR]</option>
                                            <option value="AU" >Australia [AU]</option>
                                            <option value="BE" >Belgium [BE]</option>
                                            <option value="BR" >Brazil [BR]</option>
                                            <option value="CA" >Canada [CA]</option>
                                            <option value="CN" >China [CN]</option>
                                            <option value="DK" >Denmark [DK]</option>
                                            <option value="IN" >India [IN]</option>
                                            <option value="EG" >Egypt [EG]</option>
                                            <option value="FR" >France [FR]</option>
                                            <option value="DE" >Germany [DE]</option>
                                            <option value="JP" >Japan [JP]</option>
                                        </select> -->
                                    </div>

                                    <div class="col-md-3">
                                        <label class="form-label">
                                            <%= language.State %>
                                        </label>
                                        <input type="text" class="form-control" placeholder="Enter State Name"
                                            name="state" value="" required>
                                    </div>

                                    <div class="col-md-3">
                                        <label class="form-label">
                                            <%= language.City %>
                                        </label>
                                        <input type="text" class="form-control" placeholder="Enter City Name"
                                            name="city" value="" required>
                                    </div>

                                    <div class="col-md-3">
                                        <label class="form-label">
                                            <%= language.District %>
                                        </label>
                                        <input type="text" class="form-control" placeholder="Enter District Name"
                                            name="district" value="" required>
                                    </div>

                                    <div class="col-md-3">
                                        <label class="form-label">
                                            <%= language.Zip_Code %>
                                        </label>
                                        <input type="text" class="form-control" placeholder="Enter Zip Code"
                                            name="zip_code" value="" required>
                                    </div>

                                    <div class="col-md-3">
                                        <label class="form-label">
                                            <%= language.Store_Email %>
                                        </label>
                                        <input type="email" class="form-control" placeholder="Enter Store Email"
                                            name="store_email" value="" required>
                                    </div>

                                    <div class="col-md-3">
                                        <label class="form-label">
                                            <%= language.Store_Tax_Number %>
                                        </label>
                                        <input type="text" class="form-control" placeholder="Enter Store Tax Number"
                                            name="tax_number" value="" required>
                                    </div>

                                    <div class="col-12 mb-3">
                                        <label for="inputAddress" class="form-label">
                                            <%= language.Address %>
                                        </label>
                                        <input type="text" class="form-control" placeholder="Enter Address"
                                            name="address" value="" required>
                                    </div>

                                    <hr>

                                    <h4>
                                        <%= language.Store_Status %>
                                    </h4>
                                    <div class="col-12 mb-5 d-flex justify-content-between">
                                        <div class="col-md-2">
                                            <div class="form-check custom-checkbox mb-3 checkbox-success">
                                                <input type="radio" class="form-check-input" id="approved" name="status"
                                                    value="1" required>
                                                <label class="form-check-label text-success" for="approved">
                                                    <%= language.Approved %>
                                                </label>
                                            </div>
                                        </div>
                                        <div class="col-md-2">
                                            <div class="form-check custom-checkbox mb-3 checkbox-danger">
                                                <input type="radio" class="form-check-input" id="rejected" name="status"
                                                    value="0" required>
                                                <label class="form-check-label text-danger" for="rejected">
                                                    <%= language.Rejected %>
                                                </label>
                                            </div>
                                        </div>

                                        <div class="col-md-4">
                                            <!-- blank div -->
                                        </div>

                                        <div class="col-md-4">
                                            <!-- <label class="form-label">
                                                <%= language.Store_Access_Roll %>
                                            </label>
                                            <select class="default-select form-control wide mb-3" name="roll" required>
                                                <option value="" selected disabled>Select One</option>
                                                <% rolldata.forEach(function(x){ %>
                                                    <option value="<%= x.id %>">
                                                        <%= x.roll %>
                                                    </option>
                                                    <% }) %>

                                            </select> -->


                                            <% let storeRole=rolldata.find(val=> val.rollType === 'store'); %>
                                                <input type="hidden" name="roll" value="<%= storeRole.id%>">


                                        </div>



                                    </div>

                                    <hr>

                                    <button type="submit" class="btn btn-primary">
                                        <%= language.Save_Data %>
                                    </button>

                                </form>

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


        </div>

        <!--********** Content body end **********-->

        </div>
        <!--**********************************
            Footer start
        ***********************************-->
        <%- include('templet/footer')-%>

            <!--**********************************
            Footer end
        ***********************************-->

            </div>

            <!--********** Main wrapper end **********-->
            <%- include('templet/script')-%>

                <script>
                    function validateForm() {
                        const fileInput = document.getElementById('file-1');
                        const errorSpan = document.getElementById('ImgRequired');

                        if (!fileInput.files.length) {
                            errorSpan.classList.remove('d-none');
                            return false;
                        } else {
                            errorSpan.classList.add('d-none');
                            return true;
                        }

                    }

                    function showPreview(event) {
                        const file = event.target.files[0];
                        if (file) {
                            const preview = document.getElementById('file-preview');
                            preview.src = URL.createObjectURL(file);
                            document.getElementById('ImgRequired').classList.add('d-none');
                        }
                    }

                    function resetPreview() {
                        document.getElementById('file-preview').src = '../images/one.png';
                        const fileInput = document.getElementById('file-1');
                        fileInput.value = '';
                        document.getElementById('ImgRequired').classList.add('d-none');
                    }
                </script>


</body>


</html>