shekil_oct/themes/dagdan/partials/sellerApi/getOrders.htm

94 lines
3.5 KiB
HTML

{% put scripts %}
<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}}`);
// console.log("qqq");
function getOrders(sellerId) {
let formData = new FormData()
formData.append('user', "romanah_")
formData.append('password', "bt110226$$")
formData.append('seller_id', sellerId)
$(document).ready(function () {
$.ajax({
url: `http://216.250.11.229/app/api/seller/orders`,
type: 'POST',
data: formData,
cache: false,
contentType: false,
processData: false,
beforeSend: function () {
// $('#products_{{id}}').hide();
// $('#loader_{{id}}').show();
},
success: function (data, textStatus, xhr) {
// $('#loader_{{id}}').hide();
// $('#products_{{id}}').show();
console.log(data.data);
var orders = data.data;
for (var order of orders) {
$('#seller_order').append(`
<tr class="intro-x">
<td class="w-40 !py-4"> <a href="/seller/order/`+order.id+`"
class="underline decoration-dotted whitespace-nowrap">#{{'order.title'|_}} `+ order.order_id + `</a> </td>
<td class="w-40">
<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">`+ order.order.customer.phone + `</div>
</td>
<td class="text-center w-40">
<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>
</td>
<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>
</td>
<td class="w-40 text-center">
`+ order.total_qty_ordered + `
</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>
`);
}
},
error: function (xhr, textStatus, errorThrown) {
console.log('Error in Operation');
}
});
});
}
</script>
{% endput %}