summaryrefslogtreecommitdiff
path: root/templates/edit_assembly.tpl
blob: 66d815e24b3b6ff5f3ae762e23cfe518202ba300 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
{strip}
<div class="edit stock">
	<div class="header">
		<h1>
			{if $gContent->getTitle()}
				{tr}Edit Assembly{/tr}: {$gContent->getTitle()|escape}
			{else}
				{tr}Create Assembly{/tr}
			{/if}
		</h1>
	</div>

	<div class="body">
		{form id="editAssemblyForm" ipackage="stock" ifile="edit.php"}
			{formfeedback error=$errors success=$stockSuccess}

			<input type="hidden" name="content_id" value="{$gContent->mContentId|escape}"/>

			<div class="form-group">
				{formlabel label="Title" for="assembly-title" mandatory="y"}
				{forminput}
					<input type="text" name="title" id="assembly-title" value="{$gContent->getTitle()|escape}" maxlength="160" size="50"/>
				{/forminput}
			</div>

			<div class="form-group">
				{formlabel label="Description" for="assembly-desc"}
				{forminput}
					<textarea name="edit" id="assembly-desc" rows="4" cols="50">{$gContent->mInfo.data|default:''|escape}</textarea>
				{/forminput}
			</div>

			{if $gContent->mInfo.stockassembly_types}
				{jstabs}
					{section name=xrefGroup loop=$gContent->mInfo.stockassembly_types}
						{include file=$gContent->getXrefListTemplate($gContent->mInfo.stockassembly_types[xrefGroup].template)
							source=$gContent->mInfo.stockassembly_types[xrefGroup].source
							source_title=$gContent->mInfo.stockassembly_types[xrefGroup].title
							group=$gContent->mInfo.stockassembly_types[xrefGroup].sort_order
							allow_add=true}
					{/section}
				{/jstabs}
			{/if}

			<div class="form-group submit">
				{if $gContent->isValid()}
					<input type="submit" class="btn btn-default" name="cancelgallery" value="{tr}Cancel{/tr}"/>
				{/if}
				<input type="submit" class="btn btn-primary" name="savegallery" value="{tr}Save Assembly{/tr}"/>
			</div>
		{/form}

		{* ── Components section ── *}
		{if $gContent->isValid()}
			<hr/>
			<h3>{tr}Components{/tr}</h3>

			{* CSV upload results *}
			{if isset($csvLoaded)}
				<div class="alert alert-info">
					{tr}Loaded{/tr}: <strong>{$csvLoaded}</strong>
					{if $csvSkipped} &nbsp; {tr}Skipped (duplicate){/tr}: <strong>{$csvSkipped}</strong>{/if}
				</div>
				{if $csvErrors}
					<ul class="text-warning">
						{foreach from=$csvErrors item=msg}<li>{$msg|escape}</li>{/foreach}
					</ul>
				{/if}
			{/if}

			{* Components table *}
			{if $componentMap}
				{form ipackage="stock" ifile="edit.php"}
					<input type="hidden" name="content_id" value="{$gContent->mContentId|escape}"/>
					<table class="table table-condensed table-striped">
						<thead>
							<tr>
								<th>{smartlink ititle="Pos" isort="item_position" ifile="edit.php" ipackage="stock" idefault=1 content_id=$gContent->mContentId}</th>
								<th>{smartlink ititle="Component" isort="title" ifile="edit.php" ipackage="stock" content_id=$gContent->mContentId}</th>
								<th></th>
							</tr>
						</thead>
						<tbody>
							{foreach from=$componentMap key=contentId item=comp}
								<tr>
									<td>{$comp.item_position|escape}</td>
									<td>{$comp.title|escape}</td>
									<td>
										<input type="submit" class="btn btn-xs btn-default"
											name="remove_component_{$contentId}" value="{tr}Remove{/tr}"/>
									</td>
								</tr>
							{/foreach}
						</tbody>
					</table>
				{/form}
			{else}
				<p class="muted">{tr}No components yet.{/tr}</p>
			{/if}

			{* ── Upload BOM CSV ── *}
			<h4>{tr}Upload Parts List (BOM){/tr}</h4>
			<p class="help-block">{tr}Columns: ITEM, XORDER, XREF (component title), XKEY (quantity), XKEY_EXT (ref designators), DATA{/tr}</p>
			{form enctype="multipart/form-data" ipackage="stock" ifile="edit.php"}
				<input type="hidden" name="content_id" value="{$gContent->mContentId|escape}"/>
				<div class="form-inline">
					<input type="file" name="csv_file" accept=".csv,text/csv"/>
					<input type="submit" class="btn btn-default" name="upload_bom_csv" value="{tr}Upload BOM{/tr}"/>
				</div>
			{/form}
		{/if}

	</div><!-- end .body -->
</div><!-- end .stock -->
{/strip}