feat: updated eBay Pricing page with Apply Pricing UI, item dropdown, pricing stats, and CSS
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
.badge-fresh { background-color: #28a745; }
|
||||||
|
.badge-aging { background-color: #ffc107; color: #212529; }
|
||||||
|
.badge-expired { background-color: #dc3545; }
|
||||||
|
.badge-needs { background-color: #fd7e14; }
|
||||||
|
.badge-error { background-color: #6c757d; }
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{% extends "templates/web.html" %}
|
{% extends "templates/web.html" %}
|
||||||
{% block style %}
|
{% block style %}
|
||||||
|
<link rel="stylesheet" href="/assets/westech_r2/css/ebay-pricing.css">
|
||||||
<style>
|
<style>
|
||||||
.badge.badge-fresh { background-color: #28a745; }
|
.badge.badge-fresh { background-color: #28a745; }
|
||||||
.badge.badge-aging { background-color: #ffc107; color: #212529; }
|
.badge.badge-aging { background-color: #ffc107; color: #212529; }
|
||||||
|
|||||||
@@ -39,6 +39,31 @@ frappe.pages['ebay-pricing'].on_page_load = function(wrapper) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-6">
|
||||||
|
<h4>Apply Pricing to Inventory</h4>
|
||||||
|
<div class="form-group">
|
||||||
|
<select class="form-control" id="ebay-apply-item" style="width: 100%;">
|
||||||
|
<option value="">Select Item to apply pricing...</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<button class="btn btn-success" id="ebay-apply-btn">
|
||||||
|
<i class="fa fa-check"></i> Apply Pricing
|
||||||
|
</button>
|
||||||
|
<button class="btn btn-info" id="ebay-apply-all-btn" style="margin-left: 0.5rem;">
|
||||||
|
<i class="fa fa-check-double"></i> Apply All
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-6 text-right">
|
||||||
|
<div class="well" style="display: inline-block; text-align: left;">
|
||||||
|
<h5>Pricing Status</h5>
|
||||||
|
<div id="pricing-stats">
|
||||||
|
<p class="text-muted">Click Apply All to see stats</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
<div id="ebay-results-area">
|
<div id="ebay-results-area">
|
||||||
<div class="text-muted text-center" style="padding: 4rem;">
|
<div class="text-muted text-center" style="padding: 4rem;">
|
||||||
<i class="fa fa-search" style="font-size: 3rem; opacity: 0.3;"></i>
|
<i class="fa fa-search" style="font-size: 3rem; opacity: 0.3;"></i>
|
||||||
@@ -47,6 +72,10 @@ frappe.pages['ebay-pricing'].on_page_load = function(wrapper) {
|
|||||||
</div>
|
</div>
|
||||||
</div>`).appendTo(page.main);
|
</div>`).appendTo(page.main);
|
||||||
|
|
||||||
|
// Load item dropdown
|
||||||
|
load_item_dropdown();
|
||||||
|
|
||||||
|
// Event handlers
|
||||||
$container.find('#ebay-search-btn').on('click', function() {
|
$container.find('#ebay-search-btn').on('click', function() {
|
||||||
let query = $container.find('#ebay-search-input').val().trim();
|
let query = $container.find('#ebay-search-input').val().trim();
|
||||||
if (!query) {
|
if (!query) {
|
||||||
@@ -67,6 +96,42 @@ frappe.pages['ebay-pricing'].on_page_load = function(wrapper) {
|
|||||||
run_batch(size);
|
run_batch(size);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$container.find('#ebay-apply-btn').on('click', function() {
|
||||||
|
let item = $container.find('#ebay-apply-item').val();
|
||||||
|
if (!item) {
|
||||||
|
frappe.msgprint(__('Select an Item first'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
apply_pricing(item);
|
||||||
|
});
|
||||||
|
|
||||||
|
$container.find('#ebay-apply-all-btn').on('click', function() {
|
||||||
|
apply_pricing_all();
|
||||||
|
});
|
||||||
|
|
||||||
|
function load_item_dropdown() {
|
||||||
|
frappe.call({
|
||||||
|
method: 'frappe.client.get_list',
|
||||||
|
args: {
|
||||||
|
doctype: 'Item',
|
||||||
|
filters: {
|
||||||
|
'disabled': 0,
|
||||||
|
'item_group': ['in', ['Laptop', 'Desktop', 'Tablet', 'Phone', 'Workstation']]
|
||||||
|
},
|
||||||
|
fields: ['name', 'item_name'],
|
||||||
|
limit: 1000
|
||||||
|
},
|
||||||
|
callback: function(r) {
|
||||||
|
if (r.message) {
|
||||||
|
let $select = $container.find('#ebay-apply-item');
|
||||||
|
r.message.forEach(item => {
|
||||||
|
$select.append(`<option value="${item.name}">${item.item_name || item.name}</option>`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function search_ebay(query) {
|
function search_ebay(query) {
|
||||||
frappe.call({
|
frappe.call({
|
||||||
method: 'westech_r2.api.ebay_pricing.search_model',
|
method: 'westech_r2.api.ebay_pricing.search_model',
|
||||||
@@ -100,6 +165,51 @@ frappe.pages['ebay-pricing'].on_page_load = function(wrapper) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function apply_pricing(item_code) {
|
||||||
|
frappe.call({
|
||||||
|
method: 'westech_r2.api.ebay_pricing.batch_apply_pricing',
|
||||||
|
args: { item_code: item_code },
|
||||||
|
freeze: true,
|
||||||
|
freeze_message: __('Applying pricing to Serial Nos...'),
|
||||||
|
callback: function(r) {
|
||||||
|
if (r.message) {
|
||||||
|
render_pricing_stats(r.message);
|
||||||
|
frappe.msgprint(__('Pricing applied: {0} priced, {1} commodity, {2} needs grading',
|
||||||
|
[r.message.priced, r.message.commodity, r.message.needs_grading]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function apply_pricing_all() {
|
||||||
|
frappe.call({
|
||||||
|
method: 'westech_r2.api.ebay_pricing.batch_apply_pricing',
|
||||||
|
args: { batch_size: 1000 },
|
||||||
|
freeze: true,
|
||||||
|
freeze_message: __('Applying pricing to all Serial Nos...'),
|
||||||
|
callback: function(r) {
|
||||||
|
if (r.message) {
|
||||||
|
render_pricing_stats(r.message);
|
||||||
|
frappe.msgprint(__('Batch pricing applied: {0} priced, {1} commodity, {2} needs grading, {3} errors',
|
||||||
|
[r.message.priced, r.message.commodity, r.message.needs_grading, r.message.errors]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function render_pricing_stats(stats) {
|
||||||
|
let html = `
|
||||||
|
<table class="table table-condensed" style="margin-bottom: 0;">
|
||||||
|
<tr><td>Priced</td><td><span class="badge badge-success">${stats.priced || 0}</span></td></tr>
|
||||||
|
<tr><td>Commodity</td><td><span class="badge badge-warning">${stats.commodity || 0}</span></td></tr>
|
||||||
|
<tr><td>Needs Grading</td><td><span class="badge badge-info">${stats.needs_grading || 0}</span></td></tr>
|
||||||
|
<tr><td>Needs Price Point</td><td><span class="badge badge-primary">${stats.needs_price_point || 0}</span></td></tr>
|
||||||
|
<tr><td>Errors</td><td><span class="badge badge-danger">${stats.errors || 0}</span></td></tr>
|
||||||
|
</table>
|
||||||
|
`;
|
||||||
|
$container.find('#pricing-stats').html(html);
|
||||||
|
}
|
||||||
|
|
||||||
function render_results(data) {
|
function render_results(data) {
|
||||||
let $area = $container.find('#ebay-results-area').empty();
|
let $area = $container.find('#ebay-results-area').empty();
|
||||||
if (!data.results || !data.results.length) {
|
if (!data.results || !data.results.length) {
|
||||||
|
|||||||
Reference in New Issue
Block a user