seller api img
This commit is contained in:
parent
84a460bf53
commit
82b512e049
|
|
@ -56,15 +56,6 @@ class Seller extends ComponentBase
|
|||
return $dataqq;
|
||||
}
|
||||
|
||||
function onUploadImg()
|
||||
{
|
||||
// $dataInput = post();
|
||||
$file = files('image');
|
||||
dd($file);
|
||||
// Request::validate([
|
||||
// 'image.*' => 'required|image|max:1024',
|
||||
// ]);
|
||||
}
|
||||
|
||||
function onUpdateSellerProd()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,22 +2,22 @@
|
|||
<div class="box">
|
||||
<div class="p-5">
|
||||
<div class="h-40 2xl:h-56 image-fit rounded-md overflow-hidden before:block before:absolute before:w-full before:h-full before:top-0 before:left-0 before:z-10 before:bg-gradient-to-t before:from-black before:to-black/10">
|
||||
<img alt="Midone - HTML Admin Template" class="rounded-md" src="{{'assets/seller/images/preview-11.jpg'|theme}}">
|
||||
<img alt="{{name}}" class="rounded-md" src="{{img}}">
|
||||
|
||||
<!-- <span class="absolute top-0 bg-pending/80 text-white text-xs m-5 px-2 py-1 rounded z-10">{{new}}</span> -->
|
||||
|
||||
<div class="absolute bottom-0 text-white px-5 pb-6 z-10"> <a href="" class="block font-medium text-base">{{name}}</a> <span class="text-white/90 text-xs mt-3">Smartphone & Tablet</span> </div>
|
||||
<div class="absolute bottom-0 text-white px-5 pb-6 z-10"> <a href="" class="block font-medium text-base">{{name}}</a> <span class="text-white/90 text-xs mt-3">{{'prod.featured.title'|_}}: {{featured}}</span> </div>
|
||||
</div>
|
||||
<div class="text-slate-600 dark:text-slate-500 mt-5">
|
||||
<div class="flex items-center"> <i data-lucide="link" class="w-4 h-4 mr-2"></i> Bahasy: {{price}} </div>
|
||||
<div class="flex items-center mt-2"> <i data-lucide="layers" class="w-4 h-4 mr-2"></i> Remaining Stock: {{qty}} </div>
|
||||
<div class="flex items-center mt-2"> <i data-lucide="check-square" class="w-4 h-4 mr-2"></i> Status: {{status}} </div>
|
||||
<!-- <div class="flex items-center"> <i data-lucide="link" class="w-4 h-4 mr-2"></i> Bahasy: {{price}} </div> -->
|
||||
<div class="flex items-center mt-2"> <i data-lucide="layers" class="w-4 h-4 mr-2"></i> {{'stock.title'|_}}: {{qty}} </div>
|
||||
<div class="flex items-center mt-2"> <i data-lucide="check-square" class="w-4 h-4 mr-2"></i> {{'status.title'|_}}: {{status}} </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-center lg:justify-end items-center p-5 border-t border-slate-200/60 dark:border-darkmode-400">
|
||||
<a class="flex items-center text-primary mr-auto" href="javascript:;"> <i data-lucide="eye" class="w-4 h-4 mr-1"></i> Preview </a>
|
||||
<a class="flex items-center mr-3" href="/seller/product/update/{{id}}"> <i data-lucide="check-square" class="w-4 h-4 mr-1"></i> Edit </a>
|
||||
<a class="flex items-center text-danger" href="javascript:;" data-tw-toggle="modal" data-tw-target="#delete-confirmation-modal"> <i data-lucide="trash-2" class="w-4 h-4 mr-1"></i> Delete </a>
|
||||
<a class="flex items-center text-primary mr-auto" href="javascript:;"> <i data-lucide="eye" class="w-4 h-4 mr-1"></i> {{price}} </a>
|
||||
<a class="flex items-center mr-3" href="/seller/product/update/{{id}}"> <i data-lucide="check-square" class="w-4 h-4 mr-1"></i> {{'product.edit'|_}} </a>
|
||||
<a class="flex items-center text-danger" href="javascript:;" data-tw-toggle="modal" data-tw-target="#delete-confirmation-modal"> <i data-lucide="trash-2" class="w-4 h-4 mr-1"></i> {{'product.delete'|_}} </a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -10,138 +10,122 @@
|
|||
<div class="intro-y col-span-12 lg:col-span-8">
|
||||
<!-- BEGIN: Form Layout -->
|
||||
<div class="intro-y box p-5">
|
||||
{{ form_ajax('onUpdateSellerProd') }}
|
||||
<div>
|
||||
<label for="crud-form-1" class="form-label">SKU #No</label>
|
||||
<input id="crud-form-1" type="text" value="SKU" name="sku" class="form-control w-full" placeholder=""
|
||||
disabled>
|
||||
</div>
|
||||
<div class="grid grid-cols-12 gap-2">
|
||||
<div class="mt-3 col-span-6">
|
||||
<label for="crud-form-22" class="form-label">{{'product.status.title'|_}} </label>
|
||||
<select class="tom-select w-full" name="stat">
|
||||
<option value="1">{{'product.enable'|_}}</option>
|
||||
<option value="0">{{'product.disable'|_}}</option>
|
||||
</select>
|
||||
<form data-file-types="image/jpeg|image/png|image/jpg" id="imageUploadForm" method="POST"
|
||||
enctype="multipart/form-data">
|
||||
<div>
|
||||
<label for="crud-form-1" class="form-label">SKU #No</label>
|
||||
<input id="crud-form-1" type="text" value="SKU" name="sku" class="form-control w-full"
|
||||
placeholder="" disabled>
|
||||
</div>
|
||||
<div class="grid grid-cols-12 gap-2">
|
||||
<div class="mt-3 col-span-6">
|
||||
<label for="crud-form-22" class="form-label">{{'product.status.title'|_}} </label>
|
||||
<select class="form-control w-full" name="stat" id="product_status">
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mt-3 col-span-6 product_featured">
|
||||
<label for="crud-form-2" class="form-label">{{'product.featured.title'|_}} </label>
|
||||
<select data-placeholder="{{'product.featured.title'|_}}" class="tom-select w-full" name="featured">
|
||||
<option value="1">{{'product.enable'|_}}</option>
|
||||
<option value="0">{{'product.disable'|_}}</option>
|
||||
</select>
|
||||
<div class="mt-3 col-span-6 product_featured">
|
||||
<label for="crud-form-2" class="form-label">{{'product.featured.title'|_}} </label>
|
||||
<select class="form-control w-full" name="featured" id="product_featured">
|
||||
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="grid grid-cols-12 gap-2">
|
||||
<div class="mt-3 col-span-6">
|
||||
<label for="crud-form-1" class="form-label">{{'product.name'|_}}</label>
|
||||
<input type="text" class="form-control w-full" placeholder="{{'product.name'|_}}" name="name">
|
||||
</div>
|
||||
<div class="mt-3 col-span-6">
|
||||
<label for="crud-form-1" class="form-label">{{'product.number'|_}}</label>
|
||||
<input type="text" class="form-control w-full" placeholder="{{'product.name'|_}}"
|
||||
name="product_number">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<label>{{'product.short_description'|_}}</label>
|
||||
<div class="mt-2">
|
||||
<textarea class="form-control" name="short_description"
|
||||
style="height: 150px;">{{'product.short_description'|_}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<label>{{'product.description'|_}}</label>
|
||||
<div class="mt-2">
|
||||
<textarea class="form-control" name="description"
|
||||
style="height: 150px;">{{'product.description'|_}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="grid grid-cols-12 gap-2">
|
||||
<div class="mt-3 col-span-6">
|
||||
<label for="crud-form-3" class="form-label">{{'product.price'|_}}</label>
|
||||
<div class="input-group">
|
||||
<input id="crud-form-3" type="number" class="form-control" placeholder="{{'product.price'|_}}"
|
||||
aria-describedby="input-group-1" name="price">
|
||||
<div id="input-group-1" class="input-group-text">TMT</div>
|
||||
<div class="grid grid-cols-12 gap-2">
|
||||
<div class="mt-3 col-span-6">
|
||||
<label for="crud-form-1" class="form-label">{{'product.name'|_}}</label>
|
||||
<input type="text" class="form-control w-full" placeholder="{{'product.name'|_}}" name="name">
|
||||
</div>
|
||||
<div class="mt-3 col-span-6">
|
||||
<label for="crud-form-1" class="form-label">{{'product.number'|_}}</label>
|
||||
<input type="text" class="form-control w-full" placeholder="{{'product.number'|_}}"
|
||||
name="product_number">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mt-3 col-span-6">
|
||||
<label for="crud-form-3" class="form-label">{{'product.special_price'|_}}</label>
|
||||
<div class="input-group">
|
||||
<input id="crud-form-3" type="number" class="form-control"
|
||||
placeholder="{{'product.special_price'|_}}" aria-describedby="input-group-2"
|
||||
name="special_price">
|
||||
<div id="input-group-1" class="input-group-text">TMT</div>
|
||||
<div class="mt-3 mb-3">
|
||||
<label>{{'product.short_description'|_}}</label>
|
||||
<div action="#" class="dropzone">
|
||||
<div class="fallback"> <input name="images[files][]" type="file" multiple id="prodImgs" />
|
||||
</div>
|
||||
<div class="dz-message" data-dz-message>
|
||||
<div class="text-lg font-medium">Drop files here or click to upload.</div>
|
||||
<div class="text-slate-500"> This is just a demo dropzone. Selected files are <span
|
||||
class="font-medium">not</span> actually uploaded. </div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<label>{{'product.short_description'|_}}</label>
|
||||
<div class="mt-2">
|
||||
<textarea class="form-control" name="short_description" id="short_description"
|
||||
style="height: 150px;">{{'product.short_description'|_}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="crud-form-1" class="form-label">{{'product.qty'|_}}</label>
|
||||
<input id="crud-form-1" type="number" name="qty" class="form-control w-full"
|
||||
placeholder="{{'product.qty'|_}}">
|
||||
</div>
|
||||
|
||||
<div class="text-right mt-5">
|
||||
<a href="{{'detail-order'|page({orderId: order.id})}}" type="button"
|
||||
class="btn btn-outline-secondary mr-1">{{'order.form.cancel.btn'|_}}</a>
|
||||
<button type="submit" class="btn btn-primary">{{'order.form.update.btn'|_}}</button>
|
||||
</div>
|
||||
{{ form_close() }}
|
||||
</div>
|
||||
<!-- END: Form Layout -->
|
||||
</div>
|
||||
|
||||
<div class="intro-y col-span-12 lg:col-span-4">
|
||||
<!-- BEGIN: Form Layout -->
|
||||
<div class="intro-y box p-5" style="margin-bottom: 40px;">
|
||||
<div class="mt-3">
|
||||
<label>{{'product.description'|_}}</label>
|
||||
<div class="mt-2">
|
||||
<textarea class="form-control" name="description" id="description"
|
||||
style="height: 150px;">{{'product.description'|_}}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="mt-3">
|
||||
<label>{{'product.imgs'|_}}</label>
|
||||
<div class="mt-2">
|
||||
<input name="images[files][]" type="file" multiple class="form-control" id="prodImgs" />
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
|
||||
<form data-file-types="image/jpeg|image/png|image/jpg" class="dropzone" data-request="onUploadImg" data-request-files>
|
||||
<input name="image[]" type="file" multiple class="form-control"/>
|
||||
|
||||
<input name="product_id" value="{{id}}" type="hidden">
|
||||
<input name="user" value="romanah_" type="hidden">
|
||||
<input name="password" value="bt110226$$" type="hidden">
|
||||
<div class="grid grid-cols-12 gap-2">
|
||||
<div class="mt-3 col-span-6">
|
||||
<label for="crud-form-3" class="form-label">{{'product.price'|_}}</label>
|
||||
<div class="input-group">
|
||||
<input id="crud-form-3" type="number" class="form-control"
|
||||
placeholder="{{'product.price'|_}}" aria-describedby="input-group-1" name="price">
|
||||
<div id="input-group-1" class="input-group-text">TMT</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mt-3 col-span-6">
|
||||
<label for="crud-form-3" class="form-label">{{'product.special_price'|_}}</label>
|
||||
<div class="input-group">
|
||||
<input id="crud-form-3" type="number" class="form-control"
|
||||
placeholder="{{'product.special_price'|_}}" aria-describedby="input-group-2"
|
||||
name="special_price">
|
||||
<div id="input-group-1" class="input-group-text">TMT</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="crud-form-1" class="form-label">{{'product.qty'|_}}</label>
|
||||
<input id="crud-form-1" type="number" name="qty" class="form-control w-full"
|
||||
placeholder="{{'product.qty'|_}}">
|
||||
</div>
|
||||
|
||||
<div class="text-right mt-5">
|
||||
<button data-attach-loading class="btn btn-primary">{{'order.form.update.btn'|_}}</button>
|
||||
<a href="{{'detail-order'|page({orderId: order.id})}}" type="button"
|
||||
class="btn btn-outline-secondary mr-1">{{'order.form.cancel.btn'|_}}</a>
|
||||
<button data-attach-loading type="submit"
|
||||
class="btn btn-primary">{{'order.form.update.btn'|_}}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="intro-y box p-5">
|
||||
|
||||
{{ form_ajax('onUpdateSellesrProd') }}
|
||||
|
||||
<div class="grid grid-cols-12 gap-2">
|
||||
<div class="mt-3 col-span-12">
|
||||
<label for="crud-form-22" class="form-label">{{'product.category.title'|_}} </label>
|
||||
<select class="tom-select w-full" name="stat">
|
||||
<option value="1">{{'product.enable'|_}}</option>
|
||||
<option value="0">{{'product.disable'|_}}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-right mt-5">
|
||||
|
||||
<button type="submit" class="btn btn-primary">{{'order.form.update.btn'|_}}</button>
|
||||
</div>
|
||||
{{ form_close() }}
|
||||
|
||||
</div>
|
||||
<!-- END: Form Layout -->
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
|
@ -150,8 +134,6 @@
|
|||
{% put scripts %}
|
||||
|
||||
<script src="{{'assets/seller/js/ckeditor-classic.js'|theme}}"></script>
|
||||
|
||||
|
||||
<script>
|
||||
getProduct();
|
||||
// console.log("qqq");
|
||||
|
|
@ -175,8 +157,18 @@
|
|||
|
||||
var product = data.data;
|
||||
|
||||
$("select[name='status']").val(product.status);
|
||||
// $("select[name='status']").val(product.status);
|
||||
$("#product_status").html(`
|
||||
<option value="1" `+ (product.status == 1 ? `selected` : ``) + `>{{'product.enable'|_}}</option>
|
||||
<option value="0" `+ (product.status == 0 ? `selected` : ``) + `>{{'product.disable'|_}}</option>
|
||||
`);
|
||||
$("#product_featured").html(`
|
||||
<option value="1" `+ (product.featured == 1 ? `selected` : ``) + `>{{'product.enable'|_}}</option>
|
||||
<option value="0" `+ (product.featured == 0 ? `selected` : ``) + `>{{'product.disable'|_}}</option>
|
||||
`);
|
||||
|
||||
$("div.product_featured select").val(product.featured);
|
||||
$("input[name='images[files][]']").val(product.images[0].original_image_url);
|
||||
// $("#product_featured select").val(product.featured).change();
|
||||
// $('#product_featured option[value='+product.featured+']').attr('selected','selected');
|
||||
$("input[name='name']").val(product.name);
|
||||
|
|
@ -198,5 +190,65 @@
|
|||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
function convertToSlug(Text) {
|
||||
return Text.toLowerCase()
|
||||
.replace(/ /g, "-")
|
||||
.replace(/[^\w-]+/g, "");
|
||||
}
|
||||
|
||||
$(document).ready(function (e) {
|
||||
$('#imageUploadForm').on('submit', (function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
var productName = $("input[name='name']").val();
|
||||
var urlKey = convertToSlug(productName);
|
||||
var fd = new FormData(this);
|
||||
|
||||
fd.append('product_id', $("input[name='product_id']").val());
|
||||
fd.append('user', $("input[name='user']").val());
|
||||
fd.append('password', $("input[name='password']").val());
|
||||
fd.append('images[files][]', $("input[name='images[files][]']").val());
|
||||
fd.append('sku', $("input[name='sku']").val());
|
||||
fd.append('channels', "Nurgul");
|
||||
fd.append('short_description', $("textarea[name='short_description']").val());
|
||||
fd.append('description', $("textarea[name='description']").val());
|
||||
fd.append('name', $("input[name='name']").val());
|
||||
fd.append('url_key', urlKey);
|
||||
fd.append('new', 1);
|
||||
fd.append('visible_individually', 1);
|
||||
fd.append('status', $("select[name='stat']").val());
|
||||
fd.append('product_number', $("input[name='product_number']").val());
|
||||
fd.append('price', $("input[name='price']").val());
|
||||
fd.append('special_price', $("input[name='special_price']").val());
|
||||
fd.append('weight', 0);
|
||||
fd.append('qty', $("input[name='qty']").val());
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "https://nurgul.com.tm/app/api/seller/update/product",
|
||||
data: fd,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function (data) {
|
||||
console.log(fd);
|
||||
console.log("success");
|
||||
console.log(data);
|
||||
},
|
||||
error: function (data) {
|
||||
console.log("error");
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
$("#ImageBrowse").on("change", function () {
|
||||
$("#imageUploadForm").submit();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
{% endput %}
|
||||
|
|
|
|||
|
|
@ -22,10 +22,25 @@
|
|||
console.log(data.data);
|
||||
|
||||
var products = data.data;
|
||||
var testq = "";
|
||||
var prodFeatured = "";
|
||||
var prodImg = "";
|
||||
|
||||
for (var product of products) {
|
||||
|
||||
if(product.featured){
|
||||
prodFeatured = "HAWA";
|
||||
}else{
|
||||
prodFeatured = "ÝOK";
|
||||
}
|
||||
|
||||
if(product.images.length > 0){
|
||||
prodImg = product.images[0].original_image_url;
|
||||
}else{
|
||||
prodImg = `{{'assets/no_img.jpg'|theme}}`;
|
||||
}
|
||||
|
||||
// console.log(product.hasOwnProperty('special_price'));
|
||||
$('#products_{{id}}').append(`{% partial "seller/prod-card" qty="`+product.qty+`" status="`+product.status+`" id="`+product.id+`" new="`+product.new+`" name="`+product.name+`" price="`+product.formatted_price+`" %}`);
|
||||
$('#products_{{id}}').append(`{% partial "seller/prod-card" featured="`+ prodFeatured +`" price="`+product.formatted_price+`" qty="`+product.qty+`" status="`+product.status+`" id="`+product.id+`" new="`+product.new+`" name="`+product.name+`" price="`+product.formatted_price+`" img="`+prodImg+`" %}`);
|
||||
}
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue