Fix page JS files with full content for load-detail, load-update, route-planner, pallet-list

This commit is contained in:
Westech Admin
2026-05-20 04:20:04 +00:00
parent 34d5c9cf59
commit 9fc0a92618
8 changed files with 445 additions and 8 deletions
@@ -0,0 +1,53 @@
<div class="ld-container" style="padding: 20px;">
<style>
.ld-header { background: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 20px; }
.ld-table { width: 100%; border-collapse: collapse; margin-top: 20px; font-size: 13px; }
.ld-table th { background: #37474f; color: white; padding: 8px; text-align: left; }
.ld-table td { padding: 6px 8px; border-bottom: 1px solid #e0e0e0; }
.ld-table .num { text-align: right; font-family: monospace; }
.ld-btn { background: #455a64; color: white; border: none; padding: 8px 20px; border-radius: 4px; cursor: pointer; margin-bottom: 20px; margin-right: 10px; }
.ld-badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; margin-right: 4px; }
.bg-rcv { background: #e3f2fd; color: #1565c0; }
.bg-hdr { background: #fff3e0; color: #e65100; }
.bg-tst { background: #e8f5e9; color: #2e7d32; }
.bg-r2 { background: #f3e5f5; color: #7b1fa2; }
.bg-des { background: #ffebee; color: #c62828; }
</style>
<div class="ld-header">
<h2>Load: <span id="ld-name"></span></h2>
<div>In Date: <span id="ld-date"></span> | Customer: <span id="ld-cust"></span> | Devices: <span id="ld-dev"></span> | Weight: <span id="ld-wt"></span> lbs</div>
</div>
<div style="margin-bottom: 15px;">
<span class="ld-badge bg-rcv">Receiving</span>
<span class="ld-badge bg-hdr">HDR / Disassembly</span>
<span class="ld-badge bg-tst">Test</span>
<span class="ld-badge bg-r2">R2 Downstream</span>
<span class="ld-badge bg-des">Destruction</span>
</div>
<button class="ld-btn" onclick="window.print()">Print Data Tracking Worksheet</button>
<button class="ld-btn" style="background: #1976d2;" onclick="window.location.href='/app/load-list'">Back to Loads</button>
<table class="ld-table" id="ld-table">
<thead>
<tr>
<th rowspan="2">Material Type</th>
<th colspan="3" style="text-align:center; background:#1565c0;">Receiving</th>
<th colspan="3" style="text-align:center; background:#e65100;">HDR / Disassembly</th>
<th colspan="3" style="text-align:center; background:#2e7d32;">Test</th>
<th style="text-align:center; background:#7b1fa2;">R2</th>
<th colspan="4" style="text-align:center; background:#c62828;">Destruction</th>
</tr>
<tr>
<th>Count</th><th>Status</th><th>Send To</th>
<th>Recv'd</th><th>HDD Out</th><th>Send To</th>
<th>Sanitized</th><th>Status</th><th>Send To</th>
<th>Sent</th>
<th>Phys</th><th>HDD Need</th><th>HDD Phys</th><th>HDD Logic</th>
</tr>
</thead>
<tbody id="ld-body"></tbody>
</table>
</div>
+65 -1
View File
@@ -1 +1,65 @@
// Load Detail page JS
frappe.pages["load-detail"].on_page_load = function(wrapper) {
var page = frappe.ui.make_app_page({
parent: wrapper,
title: "Load Detail",
single_column: true
});
var loadName = frappe.utils.get_url_arg("load");
if (!loadName) {
$(page.body).html("<div style='padding:40px;text-align:center;'><h2>No load specified</h2><p>Use ?load=MMDDYYYY-XXXX</p></div>");
return;
}
frappe.call({
method: "frappe.client.get",
args: { doctype: "Load", name: loadName },
callback: function(r) {
if (r.message) { showLoad(page, r.message); }
else { $(page.body).html("<div style='padding:40px;text-align:center;'><h2>Load not found</h2></div>"); }
}
});
function showLoad(page, load) {
var h = "<div style='padding:20px;'>";
h += "<div style='background:#f8f9fa;padding:15px;border-radius:8px;margin-bottom:20px;'>";
h += "<h2>Load: " + load.name + "</h2>";
h += "<div>In Date: " + (load.incoming_date || "N/A") + " | Customer: " + (load.customer_name || load.customer_number || "N/A") + "</div>";
h += "<div>Devices: " + (load.total_devices || 0) + " | Weight: " + (load.total_weight || 0) + " lbs</div>";
h += "</div>";
h += "<button class='btn btn-primary' onclick='window.print()' style='margin-bottom:15px;'>Print Data Tracking Worksheet</button> ";
h += "<a href='/app/load/" + encodeURIComponent(load.name) + "' class='btn btn-default' style='margin-bottom:15px;'>Open Form View</a> ";
h += "<a href='/app/load-update?load=" + encodeURIComponent(load.name) + "' class='btn btn-default' style='margin-bottom:15px;'>Edit Load</a>";
h += "<table style='width:100%;border-collapse:collapse;font-size:13px;margin-top:20px;'>";
h += "<thead><tr style='background:#37474f;color:white;'>";
h += "<th>Material Type</th><th>Count</th><th>Rcv Status</th><th>Send To</th>";
h += "<th>Recv'd</th><th>HDD Out</th><th>Dis Send To</th>";
h += "<th>Sanitized</th><th>Test Status</th><th>Test Send</th>";
h += "<th>R2 Sent</th><th>Phys</th><th>HDD Need</th><th>HDD Phys</th><th>HDD Logic</th>";
h += "</tr></thead><tbody>";
if (load.material_items && load.material_items.length > 0) {
load.material_items.forEach(function(item) {
h += "<tr style='border-bottom:1px solid #e0e0e0;'>";
h += "<td><strong>" + (item.material_type || "") + "</strong></td>";
h += "<td style='text-align:right;'>" + (item.total_count || 0) + "</td>";
h += "<td>" + (item.initial_data_status || "") + "</td>";
h += "<td>" + (item.send_to || "") + "</td>";
h += "<td style='text-align:right;'>" + (item.devices_received || 0) + "</td>";
h += "<td style='text-align:right;'>" + (item.hdd_removed || 0) + "</td>";
h += "<td>" + (item.disassembly_send_to || "") + "</td>";
h += "<td style='text-align:right;'>" + (item.units_sanitized_software || 0) + "</td>";
h += "<td>" + (item.test_data_status || "") + "</td>";
h += "<td>" + (item.test_send_to || "") + "</td>";
h += "<td style='text-align:right;'>" + (item.r2_units_sent || 0) + "</td>";
h += "<td style='text-align:right;'>" + (item.units_physical_destruction || 0) + "</td>";
h += "<td style='text-align:right;'>" + (item.hdd_needs_sanitize || 0) + "</td>";
h += "<td style='text-align:right;'>" + (item.hdd_physical_destruction || 0) + "</td>";
h += "<td style='text-align:right;'>" + (item.hdd_logical_sanitization || 0) + "</td>";
h += "</tr>";
});
}
h += "</tbody></table></div>";
$(page.body).html(h);
}
};
+11 -7
View File
@@ -4,6 +4,7 @@ frappe.pages["load-update"].on_page_load = function(wrapper) {
title: "Load Update",
single_column: true
});
var loadName = frappe.utils.get_url_arg("load");
if (!loadName) {
$(page.body).html("<div style='padding:40px;text-align:center;'><h2>No load specified</h2><p>Use ?load=MMDDYYYY-XXXX</p></div>");
@@ -26,14 +27,17 @@ frappe.pages["load-update"].on_page_load = function(wrapper) {
h += "<h2>Update Load: " + load.name + "</h2>";
h += "<p>Date: " + (load.incoming_date || "N/A") + " | Customer: " + (load.customer_name || load.customer_number || "N/A") + "</p>";
h += "<div style='margin-bottom:15px;'>";
h += "<button id='lu-save' class='btn btn-primary'>Save Changes</button>";
h += " <button id='lu-print' class='btn btn-default'>Print Worksheet</button>";
h += " <a href='/app/load/" + encodeURIComponent(load.name) + "' class='btn btn-default'>Open Form View</a>";
h += "<button id='lu-save' class='btn btn-primary'>Save Changes</button> ";
h += "<button id='lu-print' class='btn btn-default'>Print Worksheet</button> ";
h += "<a href='/app/load/" + encodeURIComponent(load.name) + "' class='btn btn-default'>Open Form View</a>";
h += "</div>";
h += "<table style='width:100%;border-collapse:collapse;font-size:13px;'><thead>";
h += "<tr style='background:#37474f;color:white;'><th>Material Type</th><th>Count</th><th>Recv Status</th><th>Send To</th><th>Recv'd</th><th>HDD Out</th><th>Dis Send To</th><th>Sanitized</th><th>Test Status</th><th>Test Send</th><th>R2 Sent</th><th>Phys</th><th>HDD Need</th><th>HDD Phys</th><th>HDD Logic</th></tr>";
h += "</thead><tbody>";
h += "<table style='width:100%;border-collapse:collapse;font-size:13px;'>";
h += "<thead><tr style='background:#37474f;color:white;'>";
h += "<th>Material Type</th><th>Count</th><th>Recv Status</th><th>Send To</th>";
h += "<th>Recv'd</th><th>HDD Out</th><th>Dis Send To</th>";
h += "<th>Sanitized</th><th>Test Status</th><th>Test Send</th>";
h += "<th>R2 Sent</th><th>Phys</th><th>HDD Need</th><th>HDD Phys</th><th>HDD Logic</th>";
h += "</tr></thead><tbody>";
if (load.material_items && load.material_items.length > 0) {
load.material_items.forEach(function(item, idx) {
@@ -0,0 +1,82 @@
<style>
.pallet-list-page { font-family: Helvetica Neue, Arial, sans-serif; }
.pallet-list-page h2 { color: #2F5496; margin-bottom: 16px; font-size: 20px; }
.pallet-search-box { margin-bottom: 16px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.pallet-search-box input, .pallet-search-box select {
padding: 6px 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px;
}
.pallet-search-box button {
padding: 6px 14px; border: 1px solid #ddd; border-radius: 4px; cursor: pointer;
font-size: 13px; background: white;
}
.pallet-search-box button.btn-primary { background: #2F5496; color: white; border-color: #2F5496; }
.pallet-search-box button.btn-success { background: #548235; color: white; border-color: #548235; }
.pallet-table-container { padding: 0; overflow-x: auto; background: white; border-radius: 4px; }
.pallet-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pallet-table th {
background: #2F5496; color: white; padding: 8px 10px; text-align: left;
cursor: pointer; white-space: nowrap; font-weight: 500;
}
.pallet-table td { padding: 5px 10px; border-bottom: 1px solid #eee; }
.pallet-table tr:hover { background: #f5f5f5; }
.pallet-table tr.new-row { background: #FFF9E6 !important; }
.pallet-table a { color: #2F5496; text-decoration: none; font-weight: 600; }
.status-received { color: #2196F3; font-weight: 600; }
.status-sorting { color: #FF9800; font-weight: 600; }
.status-processing { color: #9C27B0; font-weight: 600; }
.status-complete { color: #4CAF50; font-weight: 600; }
.status-shipped { color: #607D8B; font-weight: 600; }
.pallet-pagination { margin-top: 12px; display: flex; gap: 5px; align-items: center; }
.pallet-pagination button {
padding: 5px 12px; border: 1px solid #ddd; background: white; cursor: pointer;
border-radius: 4px; font-size: 13px; color: #2F5496;
}
.pallet-pagination button.active { background: #2F5496; color: white; border-color: #2F5496; }
.pallet-pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
.pallet-count { margin-left: auto; color: #666; font-size: 13px; }
</style>
<div class="pallet-list-page">
<h2>📦 Pallet List</h2>
<div class="pallet-search-box">
<input type="text" id="pallet-search" placeholder="Search pallet #..." style="max-width:200px;">
<select id="status-filter">
<option value="">All Statuses</option>
<option value="Received">Received</option>
<option value="Sorting">Sorting</option>
<option value="Processing">Processing</option>
<option value="Complete">Complete</option>
<option value="Shipped">Shipped</option>
</select>
<button class="btn btn-default" id="btn-clear">✕ Clear</button>
<button class="btn btn-success" id="btn-export">⬇ Export CSV</button>
<span class="pallet-count" id="pallet-count"></span>
</div>
<div class="pallet-table-container">
<table class="pallet-table" id="pallet-table">
<thead>
<tr>
<th data-sort="pallet_number">Pallet # ⇅</th>
<th data-sort="date_reserved">Date Reserved ⇅</th>
<th data-sort="received_date">Rec. Date ⇅</th>
<th data-sort="customer_number">Customer # ⇅</th>
<th data-sort="inbound_weight">Lbs ⇅</th>
<th data-sort="tester">Who ⇅</th>
<th data-sort="description">Items Tested ⇅</th>
<th data-sort="qty_to_sales">QTY Sale ⇅</th>
<th data-sort="weight_to_sales">Lbs Sale ⇅</th>
<th data-sort="finish_date">Finish Date ⇅</th>
<th>Status</th>
<th>Notes</th>
</tr>
</thead>
<tbody id="pallet-tbody">
<tr><td colspan="12" style="text-align:center;padding:40px;color:#666;">Loading...</td></tr>
</tbody>
</table>
</div>
<div class="pallet-pagination" id="pallet-pagination"></div>
</div>
+128
View File
@@ -0,0 +1,128 @@
frappe.pages["pallet-list"].on_page_load = function(wrapper) {
var page = frappe.ui.make_app_page({
parent: wrapper,
title: __("Pallet List"),
single_column: true
});
var content = frappe.render_template("pallet-list", {});
$(page.body).append(content);
var currentPage = 1;
var pageSize = 100;
var currentSort = "pallet_number";
var sortDir = "desc";
var searchTerm = "";
var statusFilter = "";
function loadPallets() {
frappe.call({
method: "westech_r2.page.pallet-list.pallet-list.get_pallets",
args: {
page: currentPage,
page_size: pageSize,
sort_field: currentSort,
sort_dir: sortDir,
status_filter: statusFilter,
search: searchTerm
},
callback: function(r) {
if (r.message) {
renderPallets(r.message.pallets, r.message.total);
}
}
});
}
function renderPallets(pallets, total) {
var tbody = $("#pallet-tbody");
tbody.empty();
if (!pallets || pallets.length === 0) {
tbody.append('<tr><td colspan="13" style="text-align:center;padding:40px;">No pallets found</td></tr>');
return;
}
pallets.forEach(function(p) {
var statusClass = "status-" + (p.status || "").toLowerCase().replace(/\s+/g, "-");
var link = "/app/pallet/" + encodeURIComponent(p.name);
var pn = (p.pallet_number || "").replace(/</g, "&lt;").replace(/>/g, "&gt;");
var row = '<tr>' +
'<td><a href="' + link + '" style="color:#3cc062;text-decoration:none;font-weight:600;">' + pn + '</a></td>' +
'<td>' + fmtDate(p.date_reserved) + '</td>' +
'<td>' + fmtDate(p.received_date) + '</td>' +
'<td>' + (p.customer_number || "") + '</td>' +
'<td>' + (p.company_name || "") + '</td>' +
'<td>' + (p.inbound_weight || "") + '</td>' +
'<td>' + (p.tester || "") + '</td>' +
'<td>' + (p.description || "") + '</td>' +
'<td>' + (p.qty_to_sales || "") + '</td>' +
'<td>' + (p.weight_to_sales || "") + '</td>' +
'<td>' + fmtDate(p.finish_date) + '</td>' +
'<td class="' + statusClass + '">' + (p.status || "") + '</td>' +
'<td>' + (p.notes || "").substring(0, 50) + '</td>' +
'</tr>';
tbody.append(row);
});
renderPagination(total);
}
function renderPagination(total) {
var totalPages = Math.ceil(total / pageSize);
var pagination = $("#pallet-pagination");
pagination.empty();
if (totalPages <= 1) return;
var prevBtn = $('<button>&laquo; Prev</button>').attr("disabled", currentPage === 1)
.css({padding: "5px 12px", border: "1px solid #ddd", background: "white", cursor: "pointer", marginRight: "5px"})
.on("click", function() {
if (currentPage > 1) { currentPage--; loadPallets(); }
});
pagination.append(prevBtn);
var startPage = Math.max(1, currentPage - 2);
var endPage = Math.min(totalPages, startPage + 4);
for (var i = startPage; i <= endPage; i++) {
var btn = $('<button>' + i + '</button>')
.css({padding: "5px 12px", border: "1px solid #ddd", background: i === currentPage ? "#3cc062" : "white",
color: i === currentPage ? "white" : "#333", cursor: "pointer", marginRight: "5px"})
.on("click", function(page) {
return function() { currentPage = page; loadPallets(); };
}(i));
pagination.append(btn);
}
var nextBtn = $('<button>Next &raquo;</button>').attr("disabled", currentPage === totalPages)
.css({padding: "5px 12px", border: "1px solid #ddd", background: "white", cursor: "pointer", marginRight: "5px"})
.on("click", function() {
if (currentPage < totalPages) { currentPage++; loadPallets(); }
});
pagination.append(nextBtn);
}
function fmtDate(v) {
if (!v) return "";
var s = String(v);
if (s.indexOf("T") > -1) s = s.split("T")[0];
if (s.indexOf(" ") > -1) s = s.split(" ")[0];
return s;
}
$("#pallet-search").on("input", function() {
searchTerm = $(this).val();
currentPage = 1;
loadPallets();
});
$("#status-filter").on("change", function() {
statusFilter = $(this).val();
currentPage = 1;
loadPallets();
});
loadPallets();
};
@@ -0,0 +1,64 @@
import frappe
@frappe.whitelist()
def get_pallets(page=1, page_size=100, sort_field="pallet_number", sort_dir="desc", status_filter="", search=""):
page = int(page)
page_size = int(page_size)
offset = (page - 1) * page_size
conditions = [
"pallet_number IS NOT NULL",
"pallet_number != ''",
"date_reserved IS NOT NULL",
"customer_number IS NOT NULL",
"customer_number != ''"
]
junk = ["", "0", "0000", "N/A", "TBD", "null", "999990", "999995"]
junk_list = "', '".join(junk)
conditions.append("pallet_number NOT IN ('" + junk_list + "')")
conditions.append("pallet_number NOT LIKE '999%'")
conditions.append("pallet_number REGEXP '^[0-9]'")
if status_filter:
conditions.append("status = '" + frappe.db.escape(status_filter) + "'")
if search:
conditions.append("pallet_number LIKE '%" + frappe.db.escape(search) + "%'")
where_clause = " AND ".join(conditions)
total = frappe.db.sql("SELECT COUNT(*) FROM tabPallet WHERE " + where_clause)[0][0]
pallets = frappe.db.sql("SELECT name, pallet_number, date_reserved, received_date, customer_number, company_name, inbound_weight, tester, description, qty_to_sales, weight_to_sales, finish_date, notes, status FROM tabPallet WHERE " + where_clause + " ORDER BY CAST(pallet_number AS UNSIGNED) " + sort_dir + " LIMIT " + str(page_size) + " OFFSET " + str(offset), as_dict=True)
empty_pallet = frappe.db.sql("SELECT name, pallet_number, date_reserved, received_date, customer_number, company_name, inbound_weight, tester, description, qty_to_sales, weight_to_sales, finish_date, notes, status FROM tabPallet WHERE date_reserved IS NULL AND (customer_number IS NULL OR customer_number = '') AND pallet_number NOT IN ('" + junk_list + "') AND pallet_number NOT LIKE '999%' AND pallet_number REGEXP '^[0-9]' ORDER BY CAST(pallet_number AS UNSIGNED) DESC LIMIT 1", as_dict=True)
result = []
if empty_pallet:
empty_pallet[0]["_is_new"] = True
result.append(empty_pallet[0])
result.extend(pallets)
return {"pallets": result, "total": total, "page": page, "page_size": page_size}
@frappe.whitelist()
def update_pallet(docname, field, value):
pallet = frappe.get_doc("Pallet", docname)
pallet.set(field, value)
pallet.save(ignore_permissions=True)
frappe.db.commit()
return {"status": "ok", "message": "Updated " + field}
@frappe.whitelist()
def create_pallet(data):
data = frappe.parse_json(data)
pallet = frappe.new_doc("Pallet")
pallet.pallet_number = data.get("pallet_number")
pallet.status = data.get("status", "Received")
pallet.date_reserved = data.get("date_reserved")
for field, value in data.items():
if field not in ["pallet_number", "status", "date_reserved"] and value:
pallet.set(field, value)
pallet.insert(ignore_permissions=True)
frappe.db.commit()
return {"status": "ok", "name": pallet.name}
@@ -0,0 +1,4 @@
<div style="padding:20px;">
<h2>Route Planner</h2>
<p>Optimize pickup routes for scheduled pickups.</p>
</div>
@@ -0,0 +1,38 @@
frappe.pages["route-planner"].on_page_load = function(wrapper) {
var page = frappe.ui.make_app_page({
parent: wrapper,
title: "Route Planner",
single_column: true
});
frappe.call({
method: "westech_r2.api.optimize_routes.get_scheduled_pickups",
callback: function(r) {
if (r.message) {
renderRoutePlanner(page, r.message);
}
}
});
function renderRoutePlanner(page, data) {
var h = "<div style='padding:20px;'>";
h += "<h2>Route Planner</h2>";
h += "<p>Schedule and optimize pickup routes.</p>";
h += "<div id='route-map' style='width:100%;height:400px;background:#f0f0f0;margin:20px 0;'></div>";
h += "<button class='btn btn-primary' id='optimize-btn'>Optimize Routes</button>";
h += "<div id='routes-container' style='margin-top:20px;'></div>";
h += "</div>";
$(page.body).html(h);
$("#optimize-btn").on("click", function() {
frappe.call({
method: "westech_r2.api.optimize_routes.optimize_routes",
callback: function(r) {
if (r.message) {
frappe.show_alert({message: "Routes optimized", indicator: "green"});
}
}
});
});
}
};