338 lines
18 KiB
HTML
338 lines
18 KiB
HTML
{% set categories = __SELF__.categories %}
|
|
{% set subcategories = __SELF__.subcategories %}
|
|
{% set states = __SELF__.states %}
|
|
{% set cities = __SELF__.cities %}
|
|
{% set productIdOption = __SELF__.productIdOption %}
|
|
{% set productForEditing = __SELF__.productForEditing %}
|
|
|
|
|
|
|
|
<!-- Breadcumb Area -->
|
|
<div class="breadcumb_area">
|
|
<div class="container h-100">
|
|
<div class="row h-100 align-items-center">
|
|
<div class="col-12">
|
|
<h5>Haryt goşmak üýtgetmek</h5>
|
|
<ol class="breadcrumb">
|
|
<li class="breadcrumb-item"><a href="{{ 'index'|page }}">Esasy sahypa</a></li>
|
|
<li class="breadcrumb-item active">Haryt goşmak/üýtgetmek</li>
|
|
</ol>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Breadcumb Area -->
|
|
|
|
<!-- addProducts Area -->
|
|
<div class="bigshop_reg_log_area section_padding_100_50">
|
|
<div class="container">
|
|
<div class="row">
|
|
<div class="col-12 col-md-12">
|
|
<div class="login_form mb-50">
|
|
<h5 class="mb-3">Haryt maglumatlary</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-6 mb-3">
|
|
<label for="category">Kategoriýa goshmak</label>
|
|
<select class="custom-select d-block w-100 form-control" id="category" data-belongsto="product" name="category_id" required>
|
|
<option value="" disabled>Kategoriýa saýla</option>
|
|
{% for category in categories %}
|
|
<option value="{{ category.id }}" data-file="{{ category.is_file_category }}">{{ category.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<label for="subcategory">Ikinji kategoriýa</label>
|
|
<select class="custom-select d-block w-100 form-control" id="subcategoryAdd" name="subcategory_id" disabled>
|
|
<option value=null>Subkategoriýa saýla</option>
|
|
|
|
</select>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<label for="city">Welaýat</label>
|
|
<select class="custom-select d-block w-100 form-control" id="city" name="state_id">
|
|
<option value=null disabled>Welaýat saýla</option>
|
|
{% for state in states %}
|
|
<option value="{{ state.id }}">{{ state.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<label for="subCity">Şäher</label>
|
|
<select class="custom-select d-block w-100 form-control" id="subCityAdd" name="city_id" disabled>
|
|
<option value=null>Şäher saýla</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="col-md-6 mb-3">
|
|
<label for="name">Harydyň ady</label>
|
|
<input type="text" class="form-control" id="name" placeholder="Harydyň ady" name="name" required>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<label for="price">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="order-notes">Gysga beýany</label>
|
|
<textarea class="form-control" id="shortDescription" cols="30" name="short_description" rows="10" placeholder="Gysga beýany" style="height: 160px;" required></textarea>
|
|
</div>
|
|
<div class="col-md-12 mb-3">
|
|
<label for="order-notes">Giňişleýin beýany</label>
|
|
<textarea class="form-control" id="description" cols="30" rows="20" name="description" style="height: 160px;" placeholder="Giňişleýin beýany" required></textarea>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<label for="phone">Telefon belgisi</label>
|
|
<input type="number" class="form-control" id="phone" name="phone" required>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<label for="images">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="files">Faýl goşmak</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">Haryt goşmak</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
|
|
data-request-success="resetForm()"
|
|
data-request-error="resetForm()"
|
|
enctype="multipart/form-data">
|
|
|
|
<div class="row">
|
|
<div class="col-md-6 mb-3">
|
|
<label for="category">Kategoriýa</label>
|
|
<select class="custom-select d-block w-100 form-control" id="categoryEdit" data-belongsto="product" name="category_id" required>
|
|
<option value="">Kategoriýa saýla</option>
|
|
{% for category in categories %}
|
|
<option value="{{ category.id }}" {{ productForEditing.categories.contains(category.id) ? 'selected' : '' }} data-file="{{ category.is_file_category }}">{{ category.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<label for="subcategory">Ikinji kategoriýa</label>
|
|
<select class="custom-select d-block w-100 form-control" id="subcategoryEdit" name="subcategory_id" required>
|
|
<option value=null>Subkategoriýa saýla</option>
|
|
{% for sub in subcategories %}
|
|
<option value="{{ sub.id }}" {{ productForEditing.categories.contains(sub.id) ? 'selected' : '' }} data-file="{{ sub.is_file_category }}">{{ sub.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<label for="city">Welaýat</label>
|
|
<select class="custom-select d-block w-100 form-control" id="cityEdit" name="state_id">
|
|
<option value=null>Welaýat saýla</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="subCity">Şäher</label>
|
|
<select class="custom-select d-block w-100 form-control" id="subCityEdit" name="city_id">
|
|
<option value=null>Şäher saýla</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">Harydyň ady</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">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="order-notes">Gysga beýany</label>
|
|
<textarea class="form-control" id="shortDescription" cols="30" name="short_description" rows="10" placeholder="Gysga beýany" required>{{ productForEditing.short_description }}</textarea>
|
|
</div>
|
|
<div class="col-md-12 mb-3">
|
|
<label for="order-notes">Giňişleýin beýany</label>
|
|
<textarea class="form-control" id="description" cols="30" rows="20" name="description" placeholder="Giňişleýin beýany" required>{{ productForEditing.description }}</textarea>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<label for="phone">Telefon belgisi</label>
|
|
<input type="number" class="form-control" id="phone" name="phone" value="{{ productForEditing.phone }}" required>
|
|
</div>
|
|
<div class="col-md-6 mb-3">
|
|
<label for="images">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="files">Faýl goşmak</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"/>
|
|
<input type="hidden" name="product_id" value="{{ productForEditing.id }}"/>
|
|
<button type="submit" class="btn btn-primary btn-sm mt-3">Üýtgetmek</button>
|
|
</form>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{% put scripts %}
|
|
<script>
|
|
function resetForm() {
|
|
document.getElementById('offerForm').reset(); // Reset the form
|
|
var updateForm = document.getElementById('offerUpdateForm');
|
|
if (updateForm){
|
|
document.getElementById('offerUpdateForm').reset()
|
|
}
|
|
}
|
|
</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");
|
|
}
|
|
|
|
//get subcategories
|
|
var url = '{{ route("category.subs", ":id") }}';
|
|
url = url.replace(':id', selectedValue);
|
|
$.get(url, function (data){
|
|
if(data.length > 0)
|
|
{
|
|
$('#subcategoryAdd').attr("disabled", false);
|
|
$('#subcategoryAdd').empty();
|
|
for (let i = 0; i < data.length; i++) {
|
|
$('#subcategoryAdd').append('<option value ="'+data[i]['id']+'" data-file="'+data[i]['is_file_category']+'">'+data[i]['name']+'</option>');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$('#subcategoryAdd').empty();
|
|
$('#subcategoryAdd').append('<option value ="">Ikinji kategoriýa ýok</option>');
|
|
$('#subcategoryAdd').attr("disabled", true);
|
|
}
|
|
});
|
|
});
|
|
|
|
$("#categoryEdit").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").val(null);
|
|
$("#newFileDiv").addClass("d-none");
|
|
}
|
|
|
|
//get subcategories
|
|
var url = '{{ route("category.subs", ":id") }}';
|
|
url = url.replace(':id', selectedValue);
|
|
$.get(url, function (data){
|
|
if(data.length > 0)
|
|
{
|
|
$('#subcategoryEdit').attr("disabled", false);
|
|
$('#subcategoryEdit').empty();
|
|
for (let i = 0; i < data.length; i++) {
|
|
$('#subcategoryEdit').append('<option value ="'+data[i]['id']+'" data-file="'+data[i]['is_file_category']+'">'+data[i]['name']+'</option>');
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$('#subcategoryEdit').empty();
|
|
$('#subcategoryEdit').append('<option value ="">Ikinji kategoriýa ýok</option>');
|
|
$('#subcategoryEdit').attr("disabled", true);
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
|
|
//places
|
|
$("#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[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 %} |