api order

This commit is contained in:
Kerim 2023-09-02 18:35:19 +05:00
parent 02b0646832
commit bd5540ac8f
7 changed files with 201971 additions and 63 deletions

View File

@ -25033,42 +25033,42 @@ __webpack_require__.r(__webpack_exports__);
/* harmony import */ var dropzone__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(dropzone__WEBPACK_IMPORTED_MODULE_0__); /* harmony import */ var dropzone__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(dropzone__WEBPACK_IMPORTED_MODULE_0__);
(function () { // (function () {
"use strict"; // Dropzone // "use strict"; // Dropzone
//
(dropzone__WEBPACK_IMPORTED_MODULE_0___default().autoDiscover) = false; // (dropzone__WEBPACK_IMPORTED_MODULE_0___default().autoDiscover) = false;
$(".dropzone").each(function () { // $(".dropzone").each(function () {
var _this = this; // var _this = this;
//
var options = { // var options = {
accept: function accept(file, done) { // accept: function accept(file, done) {
console.log("Uploaded"); // console.log("Uploaded");
done(); // done();
} // }
}; // };
//
if ($(this).data("single")) { // if ($(this).data("single")) {
options.maxFiles = 1; // options.maxFiles = 1;
} // }
//
if ($(this).data("file-types")) { // if ($(this).data("file-types")) {
options.accept = function (file, done) { // options.accept = function (file, done) {
if ($(_this).data("file-types").split("|").indexOf(file.type) === -1) { // if ($(_this).data("file-types").split("|").indexOf(file.type) === -1) {
alert("Error! Files of this type are not accepted"); // alert("Error! Files of this type are not accepted");
done("Error! Files of this type are not accepted"); // done("Error! Files of this type are not accepted");
} else { // } else {
console.log("Uploaded"); // console.log("Uploaded");
done(); // done();
} // }
}; // };
} // }
//
var dz = new (dropzone__WEBPACK_IMPORTED_MODULE_0___default())(this, options); // var dz = new (dropzone__WEBPACK_IMPORTED_MODULE_0___default())(this, options);
dz.on("maxfilesexceeded", function (file) { // dz.on("maxfilesexceeded", function (file) {
alert("No more files please!"); // alert("No more files please!");
}); // });
}); // });
})(); // })();
/***/ }), /***/ }),

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,94 @@
title = "Seller order detail"
url = "/seller/order/:id"
meta_title = "Seller Order"
layout = "seller-master"
==
<div class="intro-y flex flex-col sm:flex-row items-center mt-8">
<h2 class="text-lg font-medium mr-auto">
{{'order.detail.title'|_}}
</h2>
<div class="w-full sm:w-auto flex mt-4 sm:mt-0">
<!-- <button class="btn btn-primary shadow-md mr-2">Print</button> -->
</div>
</div>
<!-- BEGIN: Transaction Details -->
<div class="intro-y grid grid-cols-11 gap-5 mt-5">
<div class="col-span-12 lg:col-span-4 2xl:col-span-3">
<div class="box p-5 rounded-md">
<div class="flex items-center border-b border-slate-200/60 dark:border-darkmode-400 pb-5 mb-5">
<div class="font-medium text-base truncate">{{'order.detail.title'|_}}</div>
</div>
<div class="flex items-center"> <i data-lucide="clipboard" class="w-4 h-4 text-slate-500 mr-2"></i>
{{'order.no.title'|_}}: <a href=""
class="underline decoration-dotted ml-1">INV/20220217/MPL/2053411933</a> </div>
<div class="flex items-center mt-3"> <i data-lucide="calendar" class="w-4 h-4 text-slate-500 mr-2"></i>
{{'order.date'|_}} </div>
<div class="flex items-center mt-3"> <i data-lucide="map-pin" class="w-4 h-4 text-slate-500 mr-2"></i>
{{'order.address'|_}} <span class="bg-success/20 text-success rounded px-2 ml-1">Completed</span>
</div>
<div class="flex items-center border-t border-slate-200/60 dark:border-darkmode-400 pt-5 mt-5 font-medium">
<i data-lucide="credit-card" class="w-4 h-4 text-slate-500 mr-2"></i> Grand Total:
<div class="ml-auto">$15,000.00</div>
</div>
</div>
</div>
<div class="col-span-12 lg:col-span-7 2xl:col-span-8">
<div class="box p-5 rounded-md">
<div class="flex items-center border-b border-slate-200/60 dark:border-darkmode-400 pb-5 mb-5">
<div class="font-medium text-base truncate">{{'order.items.title'|_}}</div>
</div>
<div class="overflow-auto lg:overflow-visible -mt-3">
<table class="table table-striped">
<thead>
<tr>
<th class="whitespace-nowrap !py-5">{{'product.title'|_}}</th>
<th class="whitespace-nowrap text-right">{{'product.price.title'|_}}</th>
<th class="whitespace-nowrap text-right">{{'product.qty'|_}}</th>
<th class="whitespace-nowrap text-right">{{'product.total'|_}}</th>
</tr>
</thead>
<tbody>
<tr>
<td class="!py-4">
<div class="flex items-center">
<div class="w-10 h-10 image-fit zoom-in">
<img alt="Midone - HTML Admin Template"
class="rounded-lg border-2 border-white shadow-md tooltip"
src="dist/images/preview-2.jpg" title="Uploaded at 9 October 2020">
</div>
<a href="" class="font-medium whitespace-nowrap ml-4">Nike Tanjun</a>
</div>
</td>
<td class="text-right">$25,000.00</td>
<td class="text-right">2</td>
<td class="text-right">$50,000.00</td>
</tr>
<tr>
<td class="!py-4">
<div class="flex items-center">
<div class="w-10 h-10 image-fit zoom-in">
<img alt="Midone - HTML Admin Template"
class="rounded-lg border-2 border-white shadow-md tooltip"
src="dist/images/preview-9.jpg" title="Uploaded at 23 December 2020">
</div>
<a href="" class="font-medium whitespace-nowrap ml-4">Nike Tanjun</a>
</div>
</td>
<td class="text-right">$69,000.00</td>
<td class="text-right">2</td>
<td class="text-right">$138,000.00</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- END: Transaction Details -->

View File

@ -23,12 +23,16 @@ layout = "seller-master"
<th class="whitespace-nowrap">{{'order.no'|_}}</th> <th class="whitespace-nowrap">{{'order.no'|_}}</th>
<th class="whitespace-nowrap">{{'customer.name'|_}}</th> <th class="whitespace-nowrap">{{'customer.name'|_}}</th>
<th class="text-center whitespace-nowrap">{{'order.status'}}</th> <th class="text-center whitespace-nowrap">{{'order.status'}}</th>
<th class="text-right whitespace-nowrap"> <th class="text-center whitespace-nowrap">{{'order.shipping.desc'}}</th>
<th class="text-center whitespace-nowrap">
<div class="pr-16">{{'order.total.transaction'|_}}</div> <div class="pr-16">{{'order.total.transaction'|_}}</div>
</th> </th>
<th class="text-right whitespace-nowrap"> <th class="text-center whitespace-nowrap">
{{'order.qty'|_}} {{'order.qty'|_}}
</th> </th>
<th class="text-center whitespace-nowrap">
{{'order.date'|_}}
</th>
</tr> </tr>
</thead> </thead>

67
themes/nurgul/partials/seller/prod-update.htm Executable file → Normal file
View File

@ -50,7 +50,7 @@
<label>{{'product.file.upload'|_}}</label> <label>{{'product.file.upload'|_}}</label>
<div action="#" class="dropzone" id="upload-widget"> <div action="#" class="dropzone" id="upload-widget">
<div class="fallback"> <div class="fallback">
<input name="images[files][]" type="file" multiple id="prodImgs" onchange="getFile(this)" /> <input type="file" multiple id="prodImgs" onchange="getFile(this)" />
</div> </div>
<div class="dz-message" data-dz-message> <div class="dz-message" data-dz-message>
<div class="text-lg font-medium">Drop files here or click to upload.</div> <div class="text-lg font-medium">Drop files here or click to upload.</div>
@ -74,14 +74,8 @@
style="height: 150px;">{{'product.description'|_}}</textarea> style="height: 150px;">{{'product.description'|_}}</textarea>
</div> </div>
</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> -->
<input style="display:none" name="images[files][]" type="file" multiple class="form-control" id="prodImgs2" />
<input name="product_id" value="{{id}}" type="hidden"> <input name="product_id" value="{{id}}" type="hidden">
<input name="user" value="romanah_" type="hidden"> <input name="user" value="romanah_" type="hidden">
@ -136,14 +130,8 @@
<script src="{{'assets/seller/js/ckeditor-classic.js'|theme}}"></script> <script src="{{'assets/seller/js/ckeditor-classic.js'|theme}}"></script>
<script> <script>
function getFile(fileq) {
var value = fileq.value;
console.log(value);
}
getProduct(); getProduct();
// console.log("qqq");
function getProduct() { function getProduct() {
$(document).ready(function () { $(document).ready(function () {
@ -155,13 +143,10 @@
// $('#deatil_screen').hide(); // $('#deatil_screen').hide();
// $('#loader').show(); // $('#loader').show();
}, },
success: function (data, textStatus, xhr) { success: async function (data, textStatus, xhr) {
// $('#loader').hide(); // $('#loader').hide();
// $('#deatil_screen').show(); // $('#deatil_screen').show();
console.log(data.data);
var product = data.data; var product = data.data;
// $("input[name='images[files][]']").val(product.images[0].original_image_url); // $("input[name='images[files][]']").val(product.images[0].original_image_url);
@ -189,6 +174,27 @@
$("input[name='special_price']").val(Number(product.special_price)); $("input[name='special_price']").val(Number(product.special_price));
$("input[name='qty']").val(product.qty); $("input[name='qty']").val(product.qty);
product.images.forEach(image => {
let mockFile = { name: image.original_image_url, size: 12345 };
myDropzone.options.addedfile.call(myDropzone, mockFile);
myDropzone.options.thumbnail.call(myDropzone, mockFile, image.original_image_url);
myDropzone.emit("complete", mockFile);
let blob = null
let xhrr = new XMLHttpRequest()
xhrr.open("GET", image.original_image_url)
xhrr.responseType = "blob"
xhrr.onload = function()
{
blob = xhrr.response
let file = new File([blob], image.original_image_url);
container.items.add(file);
document.querySelector('#prodImgs2').files = container.files;
}
xhrr.send()
})
}, },
error: function (xhr, textStatus, errorThrown) { error: function (xhr, textStatus, errorThrown) {
console.log('Error in Operation'); console.log('Error in Operation');
@ -197,6 +203,14 @@
}); });
} }
async function getFileFromUrl(url, name, defaultType = 'image/jpeg'){
const response = await fetch(url);
const data = await response.blob();
return new File([data], name, {
type: data.type || defaultType,
});
}
</script> </script>
<script> <script>
function convertToSlug(Text) { function convertToSlug(Text) {
@ -205,6 +219,22 @@
.replace(/[^\w-]+/g, ""); .replace(/[^\w-]+/g, "");
} }
Dropzone.autoDiscover = false; // Disabling autoDiscover, otherwise Dropzone will try to attach twice.
let container = new DataTransfer();
let myDropzone = new Dropzone(".dropzone", {
addRemoveLinks: true,
});
myDropzone.on("addedfile", function(file) {
container.items.add(file);
document.querySelector('#prodImgs2').files = container.files;
});
myDropzone.on("removedfile", function(file) {
container.items.remove(file);
document.querySelector('#prodImgs2').files = container.files;
});
$(document).ready(function (e) { $(document).ready(function (e) {
$('#imageUploadForm').on('submit', (function (e) { $('#imageUploadForm').on('submit', (function (e) {
e.preventDefault(); e.preventDefault();
@ -243,6 +273,7 @@
console.log(fd); console.log(fd);
console.log("success"); console.log("success");
console.log(data); console.log(data);
location.reload()
}, },
error: function (data) { error: function (data) {
console.log("error"); console.log("error");

View File

@ -0,0 +1,262 @@
<div class="intro-y flex items-center mt-8">
<h2 class="text-lg font-medium mr-auto">
{{'seller.product.update.title'|_}}
</h2>
<div class="flex items-center ml-auto alert alert-success-soft show flex items-center mb-2" role="alert"
style="padding: 5px;font-size: 12px;padding-top: 2px;padding-bottom: 2px;">USD: {{order.kurs}}</div>
</div>
<div class="grid grid-cols-12 gap-6 mt-5">
<div class="intro-y col-span-12 lg:col-span-8">
<!-- BEGIN: Form Layout -->
<div class="intro-y box p-5">
<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 class="form-control w-full" name="featured" id="product_featured">
</select>
</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.number'|_}}"
name="product_number">
</div>
</div>
<div class="mt-3 mb-3">
<label>{{'product.file.upload'|_}}</label>
<div action="#" class="dropzone" id="upload-widget">
<div class="fallback">
<input name="images[files][]" type="file" multiple id="prodImgs" onchange="getFile(this)" />
</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 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> -->
<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">
<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>
<!-- END: Form Layout -->
</div>
</div>
{% put scripts %}
<script src="{{'assets/seller/js/ckeditor-classic.js'|theme}}"></script>
<script>
function getFile(fileq) {
var value = fileq.value;
console.log(value);
}
getProduct();
// console.log("qqq");
function getProduct() {
$(document).ready(function () {
$.ajax({
url: `https://nurgul.com.tm/app/api/products/{{id}}`,
type: 'GET',
dataType: 'json',
beforeSend: function () {
// $('#deatil_screen').hide();
// $('#loader').show();
},
success: function (data, textStatus, xhr) {
// $('#loader').hide();
// $('#deatil_screen').show();
console.log(data.data);
var product = data.data;
// $("input[name='images[files][]']").val(product.images[0].original_image_url);
// $("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);
// $("#product_featured select").val(product.featured).change();
// $('#product_featured option[value='+product.featured+']').attr('selected','selected');
$("input[name='name']").val(product.name);
$("input[name='sku']").val(product.sku);
$("textarea[name='short_description']").val(product.short_description);
$("textarea[name='description']").val(product.description);
$("input[name='name']").val(product.name);
$("input[name='product_number']").val(product.product_number);
$("input[name='price']").val(product.regular_price);
$("input[name='special_price']").val(Number(product.special_price));
$("input[name='qty']").val(product.qty);
},
error: function (xhr, textStatus, errorThrown) {
console.log('Error in Operation');
}
});
});
}
</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 %}

View File

@ -1,10 +1,32 @@
{% put scripts %} {% put scripts %}
<script> <script>
function formatDate(date) {
var d = new Date(date),
month = '' + (d.getMonth() + 1),
day = '' + d.getDate(),
year = d.getFullYear();
hour = d.getHours();
minute = d.getMinutes();
if (month.length < 2)
month = '0' + month;
if (day.length < 2)
day = '0' + day;
var date = [day, month, year].join('.');
var time = [hour, minute].join(':');
var result = date + " / " + time;
return result;
}
getOrders(`{{sellerId}}`); getOrders(`{{sellerId}}`);
// console.log("qqq"); // console.log("qqq");
function getOrders(sellerId) { function getOrders(sellerId) {
let formData = new FormData() let formData = new FormData()
formData.append('user', "romanah_") formData.append('user', "romanah_")
formData.append('password', "bt110226$$") formData.append('password', "bt110226$$")
formData.append('seller_id', sellerId) formData.append('seller_id', sellerId)
@ -34,22 +56,28 @@
$('#seller_order').append(` $('#seller_order').append(`
<tr class="intro-x"> <tr class="intro-x">
<td class="w-40 !py-4"> <a href="" <td class="w-40 !py-4"> <a href="/seller/order/`+order.order_id+`"
class="underline decoration-dotted whitespace-nowrap">#{{'order.title'|_}} `+ order.order_id + `</a> </td> class="underline decoration-dotted whitespace-nowrap">#{{'order.title'|_}} `+ order.order_id + `</a> </td>
<td class="w-40"> <td class="w-40">
<a href="" class="font-medium whitespace-nowrap">Keanu Reeves</a> <a href="" class="font-medium whitespace-nowrap">`+ order.order.customer_first_name + `</a>
<div class="text-slate-500 text-xs whitespace-nowrap mt-0.5">Ohio, Ohio</div> <div class="text-slate-500 text-xs whitespace-nowrap mt-0.5">`+ order.order.customer.phone + `</div>
</td> </td>
<td class="text-center"> <td class="text-center w-40">
<div class="flex items-center justify-center whitespace-nowrap text-success"> <i <div class="flex items-center justify-center whitespace-nowrap text-success"> <i
data-lucide="check-square" class="w-4 h-4 mr-2"></i> `+ order.status + ` </div> data-lucide="check-square" class="w-4 h-4 mr-2"></i> `+ order.status + ` </div>
</td> </td>
<td class="w-40 text-right"> <td class="w-40 text-center">
`+ order.order.shipping_description + `
</td>
<td class="w-40 text-center">
<div class="pr-16">`+ order.base_seller_total + ` TMT</div> <div class="pr-16">`+ order.base_seller_total + ` TMT</div>
</td> </td>
<td class="w-40 text-right"> <td class="w-40 text-center">
`+ order.total_qty_ordered + ` `+ order.total_qty_ordered + `
</td> </td>
<td class="w-40 text-center">
<span class="bg-success/20 text-success rounded px-2 ml-1">`+ formatDate(order.created_at) + `</span>
</td>
</tr> </tr>
`); `);