summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-09 11:15:23 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-09 11:15:23 +0100
commit1de8f2f90284c375449326285f0b87e5e700a0c8 (patch)
treef5d0d33b7229f4094ae30563b3b7d6ec4b934ea7 /templates
parenta838a2d3963738b2e9bc496b31e078ead79d4a43 (diff)
downloadstock-1de8f2f90284c375449326285f0b87e5e700a0c8.tar.gz
stock-1de8f2f90284c375449326285f0b87e5e700a0c8.tar.bz2
stock-1de8f2f90284c375449326285f0b87e5e700a0c8.zip
stock: PCK/SHT fractional display, movement qty summing, import qty type
Display fixes: - list_stock, list_movements, view_component: PCK stock divides by pack_size for fractional strip display; SHT shows 2 decimal places - list_movements: pack_size fetched per component for PCK display - All fractional formats use %.2f consistently StockMovement::getList component filter: - Replace INNER JOIN on xcmp with EXISTS subquery to avoid duplicate rows when a component appears multiple times in a movement BOM - cmp_qty now SUMs all matching xref rows so multi-assembly RQs show total quantity rather than silently dropping duplicate rows Movement BOM edit templates: - stockmovement/edit_xref_bom_item.tpl: proper edit form for SGL/SHT/VOL lines linking back to view_component - stockmovement/edit_xref_bompck_item.tpl: same for PCK with pack size hint Import: - ImportSimpleComponent: columns 6/7 (qty_type, qty_value) wired up; PCK/SHT/VOL writes qty xref so movement CSV imports pick up default type Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'templates')
-rw-r--r--templates/list_movements.tpl2
-rw-r--r--templates/list_stock.tpl6
-rw-r--r--templates/stockmovement/edit_xref_bom_item.tpl51
-rw-r--r--templates/stockmovement/edit_xref_bompck_item.tpl52
-rwxr-xr-xtemplates/view_component.tpl2
5 files changed, 108 insertions, 5 deletions
diff --git a/templates/list_movements.tpl b/templates/list_movements.tpl
index aef033b..e50979e 100644
--- a/templates/list_movements.tpl
+++ b/templates/list_movements.tpl
@@ -55,7 +55,7 @@
<td><a href="{$mov.display_url|escape}">{$mov.title|escape}</a></td>
<td>{$mov.ref_type|escape|default:'—'}</td>
{if $componentContentId}
- <td class="text-right">{$mov.cmp_qty|string_format:"%.0f"} {$mov.cmp_qty_type|escape}</td>
+ <td class="text-right">{if $mov.cmp_qty_type eq 'PCK' && $packSize > 0}{math equation="q/p" q=$mov.cmp_qty p=$packSize format="%.2f"}{elseif $mov.cmp_qty_type eq 'SHT'}{$mov.cmp_qty|string_format:"%.2f"}{else}{$mov.cmp_qty|string_format:"%.0f"}{/if} {$mov.cmp_qty_type|escape}</td>
{/if}
<td>{if $mov.ref_start_date}{$mov.ref_start_date|bit_short_date}{else}—{/if}</td>
<td>{if $mov.event_time}{$mov.event_time|bit_short_date}{else}—{/if}</td>
diff --git a/templates/list_stock.tpl b/templates/list_stock.tpl
index edb6afe..6e9ede7 100644
--- a/templates/list_stock.tpl
+++ b/templates/list_stock.tpl
@@ -80,11 +80,11 @@
<td rowspan="{$comp.stock|@count}">{$comp.data|escape}</td>
<td rowspan="{$comp.stock|@count}">{$comp.part_number|escape}</td>
{/if}
- {if $showBom}<td class="text-right">{math equation="b*k" b=$row.bom_qty k=$kitCount format="%.0f"}</td>{/if}
+ {if $showBom}<td class="text-right">{if $qtype eq 'PCK' && $row.pack_size > 0}{math equation="b*k/p" b=$row.bom_qty k=$kitCount p=$row.pack_size format="%.2f"}{elseif $qtype eq 'SHT'}{math equation="b*k" b=$row.bom_qty k=$kitCount format="%.2f"}{else}{math equation="b*k" b=$row.bom_qty k=$kitCount format="%.0f"}{/if}</td>{/if}
<td>{$qtype|escape}</td>
- <td class="text-right">{$row.level|string_format:"%.0f"}</td>
+ <td class="text-right">{if $qtype eq 'PCK' && $row.pack_size > 0}{math equation="l/p" l=$row.level p=$row.pack_size format="%.2f"}{elseif $qtype eq 'SHT'}{$row.level|string_format:"%.2f"}{else}{$row.level|string_format:"%.0f"}{/if}</td>
{if $showBom}
- <td class="text-right{if $remaining < 0} text-danger{/if}">{$remaining|string_format:"%.0f"}</td>
+ <td class="text-right{if $remaining < 0} text-danger{/if}">{if $qtype eq 'PCK' && $row.pack_size > 0}{math equation="r/p" r=$remaining p=$row.pack_size format="%.2f"}{elseif $qtype eq 'SHT'}{$remaining|string_format:"%.2f"}{else}{$remaining|string_format:"%.0f"}{/if}</td>
{/if}
</tr>
{/foreach}
diff --git a/templates/stockmovement/edit_xref_bom_item.tpl b/templates/stockmovement/edit_xref_bom_item.tpl
new file mode 100644
index 0000000..29c1aa8
--- /dev/null
+++ b/templates/stockmovement/edit_xref_bom_item.tpl
@@ -0,0 +1,51 @@
+{strip}
+<div class="edit stock">
+ <div class="header">
+ <h1>{tr}Edit Item{/tr}: {$gContent->getTitle()|escape}</h1>
+ </div>
+ <div class="body">
+ {formfeedback error=$errors}
+ {form id="editXrefForm"}
+ <input type="hidden" name="content_id" value="{$xrefInfo.content_id|escape}" />
+ <input type="hidden" name="xref_id" value="{$xrefInfo.xref_id|escape}" />
+ <input type="hidden" name="item" value="{$xrefInfo.item|escape}" />
+ <input type="hidden" name="xorder" value="{$xrefInfo.xorder|escape}" />
+
+ <div class="form-group">
+ {formlabel label="Component"}
+ {forminput}
+ <p class="form-control-static">
+ <a href="{$smarty.const.STOCK_PKG_URL}view_component.php?content_id={$xrefInfo.xref|escape}">{$xrefInfo.xref_title|default:$xrefInfo.xref|escape}</a>
+ </p>
+ {/forminput}
+ </div>
+
+ <div class="form-group">
+ {formlabel label="Quantity" for="xkey"}
+ {forminput}
+ <input type="text" class="form-control input-small" name="xkey" id="xkey" value="{$xrefInfo.xkey|escape}" />
+ {/forminput}
+ </div>
+
+ <div class="form-group">
+ {formlabel label="Ref designators" for="xkey_ext"}
+ {forminput}
+ <input type="text" class="form-control" name="xkey_ext" id="xkey_ext" value="{$xrefInfo.xkey_ext|escape}" />
+ {/forminput}
+ </div>
+
+ <div class="form-group">
+ {formlabel label="Note" for="edit"}
+ {forminput}
+ <input type="text" class="form-control" name="edit" id="edit" value="{$xrefInfo.data|escape}" />
+ {/forminput}
+ </div>
+
+ <div class="form-group submit">
+ <input type="submit" class="btn btn-default" name="fCancel" value="{tr}Cancel{/tr}" />
+ <input type="submit" class="btn btn-primary" name="fSaveXref" value="{tr}Save{/tr}" />
+ </div>
+ {/form}
+ </div>
+</div>
+{/strip}
diff --git a/templates/stockmovement/edit_xref_bompck_item.tpl b/templates/stockmovement/edit_xref_bompck_item.tpl
new file mode 100644
index 0000000..bd69cff
--- /dev/null
+++ b/templates/stockmovement/edit_xref_bompck_item.tpl
@@ -0,0 +1,52 @@
+{strip}
+<div class="edit stock">
+ <div class="header">
+ <h1>{tr}Edit Item{/tr}: {$gContent->getTitle()|escape}</h1>
+ </div>
+ <div class="body">
+ {formfeedback error=$errors}
+ {form id="editXrefForm"}
+ <input type="hidden" name="content_id" value="{$xrefInfo.content_id|escape}" />
+ <input type="hidden" name="xref_id" value="{$xrefInfo.xref_id|escape}" />
+ <input type="hidden" name="item" value="{$xrefInfo.item|escape}" />
+ <input type="hidden" name="xorder" value="{$xrefInfo.xorder|escape}" />
+
+ <div class="form-group">
+ {formlabel label="Component"}
+ {forminput}
+ <p class="form-control-static">
+ <a href="{$smarty.const.STOCK_PKG_URL}view_component.php?content_id={$xrefInfo.xref|escape}">{$xrefInfo.xref_title|default:$xrefInfo.xref|escape}</a>
+ </p>
+ {/forminput}
+ </div>
+
+ <div class="form-group">
+ {formlabel label="Pieces required" for="xkey"}
+ {forminput}
+ <input type="text" class="form-control input-small" name="xkey" id="xkey" value="{$xrefInfo.xkey|escape}" />
+ {if $xrefInfo.pack_size}<span class="help-block">{tr}of{/tr} {$xrefInfo.pack_size|escape} {tr}per pack{/tr}</span>{/if}
+ {/forminput}
+ </div>
+
+ <div class="form-group">
+ {formlabel label="Ref designators" for="xkey_ext"}
+ {forminput}
+ <input type="text" class="form-control" name="xkey_ext" id="xkey_ext" value="{$xrefInfo.xkey_ext|escape}" />
+ {/forminput}
+ </div>
+
+ <div class="form-group">
+ {formlabel label="Note" for="edit"}
+ {forminput}
+ <input type="text" class="form-control" name="edit" id="edit" value="{$xrefInfo.data|escape}" />
+ {/forminput}
+ </div>
+
+ <div class="form-group submit">
+ <input type="submit" class="btn btn-default" name="fCancel" value="{tr}Cancel{/tr}" />
+ <input type="submit" class="btn btn-primary" name="fSaveXref" value="{tr}Save{/tr}" />
+ </div>
+ {/form}
+ </div>
+</div>
+{/strip}
diff --git a/templates/view_component.tpl b/templates/view_component.tpl
index f0b3c8a..37b42ef 100755
--- a/templates/view_component.tpl
+++ b/templates/view_component.tpl
@@ -47,7 +47,7 @@
{foreach from=$componentStockLevels key=qtype item=level}
<tr{if $level < 0} class="danger"{elseif $level == 0} class="warning"{/if}>
<td>{$qtype|escape}</td>
- <td class="text-right">{$level|string_format:"%.0f"}</td>
+ <td class="text-right">{if $qtype eq 'PCK' && $packSize > 0}{math equation="l/p" l=$level p=$packSize format="%.2f"}{elseif $qtype eq 'SHT'}{$level|string_format:"%.2f"}{else}{$level|string_format:"%.0f"}{/if}</td>
</tr>
{/foreach}
{else}