gurl_o/themes/gurlushyk/pages/addProduct.htm

414 lines
24 KiB
HTML

title = "Haryt goşmak"
url = "/add-product/:productId?"
layout = "default"
is_hidden = 0
robot_index = "index"
robot_follow = "follow"
[offerform]
productId = "{{ :productId }}"
==
{% set categories = offerform.categories %}
{% set subcategories = offerform.subcategories %}
{% set states = offerform.states %}
{% set cities = offerform.cities %}
{% set productIdOption = offerform.productIdOption %}
{% set productForEditing = offerform.productForEditing %}
{% set vipRemainingDay = offerform.vipRemainingDay %}
<!-- Breadcumb Area -->
<div class="breadcumb_area">
<div class="container h-100">
<div class="row h-100 align-items-center">
<div class="col-12">
{% if productForEditing %}
<h5>{{ 'productAdd.HarytUytgetmek'|_ }}</h5>
{% else %}
<h5>{{ 'productAdd.HarytGosmak'|_ }}</h5>
{% endif %}
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="{{ 'index'|page }}">{{ 'breadcrumbEsasySahypa'|_ }}</a></li>
{% if productForEditing %}
<li class="breadcrumb-item active">{{ 'productAdd.HarytUytgetmek'|_ }}</li>
{% else %}
<li class="breadcrumb-item active">{{ 'productAdd.HarytGosmak'|_ }}</li>
{% endif %}
</ol>
</div>
</div>
</div>
</div>
<!-- Breadcumb Area -->
<!-- addProducts Area -->
<div class="bigshop_reg_log_area section_padding_100_50" id="mainDiv">
<div class="container">
<div class="row">
<div class="col-12 col-md-12">
<div class="login_form mb-50">
<h5 class="mb-3">
{% if productForEditing %}
{{ 'productAdd.HarytUytgetmek'|_ }}
{% else %}
{{ 'productAdd.HarytGosmak'|_ }}
{% endif %}
</h5>
{% if not productForEditing %}
<div class="shortcodes_content">
<form id="offerForm" action="#"
data-request="onSave"
data-request-flash
data-request-validate
data-request-files
data-request-success="resetForm()"
data-request-error="resetForm()"
enctype="multipart/form-data">
<div class="row">
<div class="col-md-12 mb-3" style='display: grid;'>
<label for="category">{{ 'productAdd.Kategoriya'|_ }}</label>
<button data-request="onSetCategoryModal" type="button" class="btn form-control" style="font-weight: normal;text-align: left;text-transform: capitalize;background: white;" data-toggle="modal" data-target="#exampleModal" id="category_title">
Kategoriýa saýla
</button>
<input type="hidden" name="category_id" id="catSelected">
<input type="hidden" name="subcategory_id" id="subCatSelected">
</div>
<div class="col-md-6 mb-3">
<label for="city">{{ 'productAdd.Welayat'|_ }}</label>
<select class="custom-select d-block w-100 form-control" id="city" name="state_id">
<option value=null disabled>{{ 'productAdd.WelayatSayla'|_ }}</option>
{% for state in states %}
<option value="{{ state.id }}">{{ state.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-6 mb-3">
<label for="subCityAdd">{{ 'productAdd.Saher'|_ }}</label>
<select class="custom-select d-block w-100 form-control" id="subCityAdd" name="city_id" disabled>
<option value=null>{{ 'productAdd.SaherSayla'|_ }}</option>
</select>
</div>
<div class="col-md-6 mb-3">
<label for="name">{{ 'productAdd.HarydynAdy'|_ }}</label>
<input type="text" class="form-control" id="name" placeholder="{{ 'productAdd.HarydynAdy'|_ }}" name="name" required>
</div>
<div class="col-md-6 mb-3">
<label for="price">{{ 'productAdd.Bahasy'|_ }}</label>
<input type="number" class="form-control" id="price" name="price" min="0" required>
</div>
<!-- <div class="col-md-12 mb-3">
<label for="shortDescription">{{ 'productAdd.GysgaBeyany'|_ }}</label>
<textarea class="form-control" id="shortDescription" cols="30" name="short_description" rows="10" placeholder="{{ 'productAdd.GysgaBeyany'|_ }}" style="height: 160px;" required></textarea>
</div> -->
<div class="col-md-12 mb-3">
<label for="description">{{ 'productAdd.GinsileyinBeyany'|_ }}</label>
<textarea class="form-control" id="description" cols="30" rows="20" name="description" style="height: 160px;" placeholder="{{ 'productAdd.GinsileyinBeyany'|_ }}" required></textarea>
</div>
<div class="col-md-6 mb-3">
<label for="phone">{{ 'productAdd.TelefonBelgisi2'|_ }}</label>
<span style="position:relative;top: 42px;left: -110px;font-size: 13px;">+993</span>
<input type="tel" class="form-control" style="padding-left: 52px;" id="phone" name="phone" min="61000000" max="65999999">
</div>
<div class="col-md-6 mb-3">
<label for="stock">{{ 'productAdd.SkladdaBarmy'|_ }} ?</label>
<select class="custom-select d-block w-100 form-control" id="stock" name="stock">
<option value="not_selected">{{ 'productAdd.NotSelected'|_ }}</option>
<option value="1">{{ 'productAdd.ElimizdeBar'|_ }}</option>
<option value="0">{{ 'productAdd.ZakazaGelyar'|_ }}</option>
</select>
</div>
<div class="col-md-6 mb-3">
<label for="new_img">{{ 'productAdd.Suratlar'|_ }}</label>
<input type="file" class="form-control" id="new_img" name="new_img[]" multiple required>
<input type="hidden" value="0" name="is_file" id="isFile">
</div>
<div class="col-md-6 mb-3 d-none" id="newFileDiv">
<label for="new_file">{{ 'productAdd.FaylGosmak'|_ }}</label>
<input type="file" class="form-control" id="new_file" name="new_file" multiple>
</div>
</div>
<input type="hidden" name="resetForm" id="resetForm" value="0"/>
<button type="submit" class="btn btn-primary btn-sm mt-3">{{ 'productAdd.HarytGosmak'|_ }}</button>
</form>
</div>
{% endif %}
{% if productForEditing %}
<div class="shortcodes_content">
<form id="offerUpdateForm" action="#"
data-request="onUpdate"
data-request-flash
data-request-validate
data-request-files
enctype="multipart/form-data">
<div class="row">
<div class="col-md-12 mb-3" style='display: grid;'>
<label for="category">{{ 'productAdd.Kategoriya'|_ }}</label>
<button data-request="onSetCategoryModal" type="button" class="btn form-control" style="font-weight: normal;text-align: left;text-transform: capitalize;background: white;" data-toggle="modal" data-target="#exampleModal" id="category_title">
{{productForEditing.categories[0].name}}
</button>
<input type="hidden" name="category_id" id="catSelected" value="{{productForEditing.categories[0].id}}">
<input type="hidden" name="subcategory_id" id="subCatSelected" value="{{productForEditing.categories[0].id}}">
</div>
<div class="col-md-6 mb-3">
<label for="cityEdit">{{ 'productAdd.Welayat'|_ }}</label>
<select class="custom-select d-block w-100 form-control" id="cityEdit" name="state_id">
<option value=null>{{ 'productAdd.WelayatSayla'|_ }}</option>
{% for state in states %}
<option value="{{ state.id }}" {{ productForEditing.place_id == state.id ? 'selected' : '' }}>{{ state.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-6 mb-3">
<label for="subCityEdit">{{ 'productAdd.Saher'|_ }}</label>
<select class="custom-select d-block w-100 form-control" id="subCityEdit" name="city_id">
<option value=null>{{ 'productAdd.SaherSayla'|_ }}</option>
{% for city in cities %}
<option value="{{ city.id }}" {{ productForEditing.place_id == city.id ? 'selected' : '' }}>{{ city.name }}</option>
{% endfor %}
</select>
</div>
<div class="col-md-6 mb-3">
<label for="name">{{ 'productAdd.HarydynAdy'|_ }}</label>
<input type="text" class="form-control" id="name" placeholder="Harydyň ady" name="name" value="{{ productForEditing.name }}" required>
</div>
<div class="col-md-6 mb-3">
<label for="price">{{ 'productAdd.Bahasy'|_ }}</label>
<input type="number" class="form-control" id="price" name="price" min="0" value="{{ productForEditing.price }}" required>
</div>
<div class="col-md-12 mb-3">
<label for="description">{{ 'productAdd.GinsileyinBeyany'|_ }}</label>
<textarea class="form-control" id="description" cols="30" rows="20" name="description" style="height: 160px;" placeholder="{{ 'productAdd.GinsileyinBeyany'|_ }}" required>{{ productForEditing.description|striptags|raw }}</textarea>
</div>
<div class="col-md-6 mb-3">
<label for="phone">{{ 'productAdd.TelefonBelgisi2'|_ }}</label>
<span style="position:relative;top: 42px;left: -110px;font-size: 13px;">+993</span>
<input type="tel" class="form-control" style="padding-left: 52px;" id="phone" name="phone" min="61000000" max="65999999" value="{{ productForEditing.phone}}">
</div>
<div class="col-md-6 mb-3">
<label for="stock">{{ 'productAdd.SkladdaBarmy'|_ }} ?</label>
<select class="custom-select d-block w-100 form-control" id="stock" name="stock">
<option value="not_selected" {{ productForEditing.stock == 'not_selected' ? 'selected': '' }}>{{ 'productAdd.NotSelected'|_ }}</option>
<option value="1" {{ productForEditing.stock == 1 ? 'selected': '' }}>{{ 'productAdd.ElimizdeBar'|_ }}</option>
<option value="0" {{ productForEditing.stock == 0 ? 'selected': '' }}>{{ 'productAdd.ZakazaGelyar'|_ }}</option>
</select>
</div>
<div class="col-md-6 mb-3">
<label for="new_img">{{ 'productAdd.Suratlar'|_ }}</label>
<input type="file" class="form-control" id="new_img" name="new_img[]" multiple>
<input type="hidden" value="0" name="is_file" id="isFile">
</div>
<div class="col-md-6 mb-3 d-none" id="newFileDiv">
<label for="new_file">{{ 'productAdd.FaylGosmak'|_ }}</label>
<input type="file" class="form-control" id="new_file" name="new_file" multiple>
</div>
<div class="col-12">
<!-- Shortcodes Title -->
<div class="shortcodes_title mb-30 mt-5">
<h5>{{ 'productAdd.OnkiSuratlar'|_ }}</h5>
</div>
<!-- Gallery Area -->
{% for key, image in productForEditing.images %}
<div class="col-9 col-sm-12 col-md-6 col-lg-4" id="image-{{ key }}">
<div class="single-product-area mb-30">
<div class="product_image">
<!-- Product Image -->
<img class="normal_img" src="{{ image.path }}" alt="Gurluşyk, Gurluşyk platform, bezeg gurluşyk, gipsler merkezi">
</div>
<div class="product_description">
<div class="product_add_to_cart">
<a href="#"
data-request="onImageDelete"
data-request-data="product_id: {{ productForEditing.id }}, product_image_id: {{ image.id }}"
data-request-flash
style="width:100%; background-color:red;"><i class="icofont-trash"></i> Pozmak</a>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
<input type="hidden" name="resetForm" id="resetForm" value="0"/>
<input type="hidden" name="product_id" value="{{ productForEditing.id }}"/>
<button type="submit" class="btn btn-primary btn-sm mt-3">{{ 'productAdd.Uytgetmek'|_ }}</button>
</form>
<a href="#" data-request="onUpdateEndsAt" data-request-data="id: {{ productForEditing.id }}" data-request-flash class="btn btn-primary btn-sm mt-3">{{ 'productAdd.WagtynyTazelemek'|_ }}</a>
<a href="#" data-request="onUpdateStatus" data-request-data="id: {{ productForEditing.id }}" data-request-flash class="btn btn-primary btn-sm mt-3">{{ 'productAdd.StatusTazelemek'|_ }}</a>
{% if productForEditing.type != 'vip' %}
<a href="#" onclick="callAdmin()" data-request="onMakeVIP" data-request-data="id: {{ productForEditing.id }}" data-request-flash class="btn btn-success btn-sm mt-3">{{ 'productAdd.VipEtmek'|_ }}</a>
{% endif %}
{% if productForEditing.type == 'vip' %}
<a href="#" class="btn btn-success btn-sm mt-3">{{ vipRemainingDay }} gün galdy</a>
{% endif %}
</div>
{% endif %}
</div>
</div>
</div>
<div id="close_modal">
</div>
<div id="set_cat">
</div>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Kategoriýalar</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body" id="modal_content">
</div>
<div class="modal-footer" id="modal_footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Ýap</button>
<!-- <button type="button" class="btn btn-primary">Save changes</button> -->
</div>
</div>
</div>
</div>
</div>
</div>
{% put scripts %}
<script>
function callAdmin(){
//window.open('tel:+99364004929');
window.location.href = 'tel:+99364004929';
}
function getCategories(catId) {
$.request('onGetCategorySubs', {
data: {'mainCat': catId},
success: function(data) {
if(data.length > 0){
$('#subcategoryAdd').prop("disabled", false);
$('#subcategoryAdd').html(`<option value=null>Subkategoriýa saýla</option>`);
for (var sub of data) {
$('#subcategoryAdd').append(`<option value="`+sub.id+`">`+sub.name+`</option>`);
}
}else{
$('#subcategoryAdd').prop("disabled", true);
}
}
});
}
function getCategoriesForEdit(catId) {
console.log(catId);
$.request('onGetCategorySubs', {
data: {'mainCat': catId},
success: function(data) {
if(data.length > 0){
$('#subcategoryEdit').prop("disabled", false);
$('#subcategoryEdit').html(`<option value=null>Subkategoriýa saýla</option>`);
for (var sub of data) {
$('#subcategoryEdit').append(`<option value="`+sub.id+`">`+sub.name+`</option>`);
}
}else{
$('#subcategoryEdit').prop("disabled", true);
}
}
});
}
</script>
<script>
function resetForm() {
document.getElementById('offerForm').reset(); // Reset the form
}
</script>
<script>
$(document).ready(function() {
$("#category").on("change", function() {
var selectedValue = $(this).val();
var isFile = $(this).find(':selected').data('file');
if (isFile > 0){
$("#isFile").val(1);
$("#newFileDiv").removeClass("d-none");
$("#new_file").attr("required", "true");
}else{
$("#isFile").val(0);
$("#new_file").removeAttr("required");
$("#newFileDiv").addClass("d-none");
}
});
$("#city").on("change", function() {
var selectedValue = $(this).val();
var url = '{{ route("place.subs", ":id") }}';
url = url.replace(':id', selectedValue);
$.get(url, function (data){
if(data.length > 0)
{
$('#subCityAdd').attr("disabled", false);
$('#subCityAdd').empty();
for (let i = 0; i < data.length; i++) {
$('#subCityAdd').append('<option value ="'+data[i]['id']+'" data-file="'+data[i]['is_file_category']+'">'+data[i]['name']+'</option>');
}
}
else
{
$('#subCityAdd').empty();
$('#subCityAdd').append('<option value ="">Degişli şäher ýok</option>');
$('#subCityAdd').attr("disabled", true);
}
});
});
$("#cityEdit").on("change", function() {
var selectedValue = $(this).val();
var url = '{{ route("place.subs", ":id") }}';
url = url.replace(':id', selectedValue);
$.get(url, function (data){
if(data.length > 0)
{
$('#subCityEdit').attr("disabled", false);
$('#subCityEdit').empty();
for (let i = 0; i < data.length; i++) {
$('#subCityEdit').append('<option value ="'+data[i]['id']+'" data-file="'+data[i]['is_file_category']+'">'+data[i]['name']+'</option>');
}
}
else
{
$('#subCityEdit').empty();
$('#subCityEdit').append('<option value ="">Degişli şäher ýok</option>');
$('#subCityEdit').attr("disabled", true);
}
});
});
});
</script>
{% endput %}