Show all templates in menu builder regardless of links
- Changed template query to find ALL templates for business (ItemCategoryID=0, ItemParentItemID=0) - Previously only showed templates that were in ItemTemplateLinks - Now shows all templates so they can be viewed and manually assigned to items - Template children query also updated to include children of all templates Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d34d88e46a
commit
a4fb7e7503
1 changed files with 51 additions and 27 deletions
|
|
@ -178,7 +178,8 @@ try {
|
|||
ORDER BY tl.ItemID, tl.SortOrder
|
||||
", {}, { datasource: "payfrit" });
|
||||
|
||||
// Get all templates for this business (items that appear in ItemTemplateLinks)
|
||||
// Get all templates for this business
|
||||
// Templates are Items with ItemCategoryID=0 and ItemParentItemID=0
|
||||
if (newSchemaActive) {
|
||||
qTemplates = queryExecute("
|
||||
SELECT DISTINCT
|
||||
|
|
@ -190,9 +191,9 @@ try {
|
|||
t.ItemRequiresChildSelection as RequiresSelection,
|
||||
t.ItemMaxNumSelectionReq as MaxSelections
|
||||
FROM Items t
|
||||
INNER JOIN ItemTemplateLinks tl ON tl.TemplateItemID = t.ItemID
|
||||
INNER JOIN Items i ON i.ItemID = tl.ItemID
|
||||
WHERE i.ItemBusinessID = :businessID
|
||||
WHERE t.ItemBusinessID = :businessID
|
||||
AND t.ItemCategoryID = 0
|
||||
AND t.ItemParentItemID = 0
|
||||
AND t.ItemIsActive = 1
|
||||
ORDER BY t.ItemSortOrder, t.ItemName
|
||||
", { businessID: businessID }, { datasource: "payfrit" });
|
||||
|
|
@ -217,8 +218,30 @@ try {
|
|||
}
|
||||
|
||||
// Get all children of templates (options within modifier groups)
|
||||
// This now includes ALL descendants recursively via a recursive approach
|
||||
// Filter by business and use DISTINCT to avoid duplicates from multiple template links
|
||||
// Get children of ALL templates for this business (not just linked ones)
|
||||
if (newSchemaActive) {
|
||||
qTemplateChildren = queryExecute("
|
||||
SELECT DISTINCT
|
||||
c.ItemID,
|
||||
c.ItemParentItemID as ParentItemID,
|
||||
c.ItemName,
|
||||
c.ItemPrice,
|
||||
c.ItemIsCheckedByDefault as IsDefault,
|
||||
c.ItemSortOrder,
|
||||
c.ItemRequiresChildSelection as RequiresSelection,
|
||||
c.ItemMaxNumSelectionReq as MaxSelections
|
||||
FROM Items c
|
||||
WHERE c.ItemParentItemID IN (
|
||||
SELECT t.ItemID
|
||||
FROM Items t
|
||||
WHERE t.ItemBusinessID = :businessID
|
||||
AND t.ItemCategoryID = 0
|
||||
AND t.ItemParentItemID = 0
|
||||
)
|
||||
AND c.ItemIsActive = 1
|
||||
ORDER BY c.ItemSortOrder, c.ItemName
|
||||
", { businessID: businessID }, { datasource: "payfrit" });
|
||||
} else {
|
||||
qTemplateChildren = queryExecute("
|
||||
SELECT DISTINCT
|
||||
c.ItemID,
|
||||
|
|
@ -240,6 +263,7 @@ try {
|
|||
AND c.ItemIsActive = 1
|
||||
ORDER BY c.ItemSortOrder, c.ItemName
|
||||
", { businessID: businessID }, { datasource: "payfrit" });
|
||||
}
|
||||
|
||||
// Build lookup of children by parent ID (flat list for now)
|
||||
childrenByParent = {};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue