blob: d027d45997f7a7631fbe4ebfcad0520b8fa6ad7c (
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
<? if ($error): ?>
<h1>Error:</h1>
<h3 style="color: red"><?=$error?></h3>
<? else: ?>
<script type="text/javascript">
function generateShoppingList()
{
$('shopping_list').innerHTML = 'Loading...';
var params = Form.serialize($('bom_form'));
new Ajax.Updater('shopping_list', '/partlist', {
parameters: params,
method: 'post'
});
}
function toggleBreakdown(id)
{
Element.toggle('breakdown_' + id);
Element.toggle('plus_' + id);
Element.toggle('minus_' + id);
}
</script>
<? if ($module): ?>
<h1><a href="<?=$module->getViewUrl()?>"><?=$module->get('name')?></a> - <?=date("M j, Y")?></h1>
<? else: ?>
<h1>Custom Part List - <?=date("M j, Y")?></h1>
<table>
<tr>
<td colspan="2"><b>Modules used:</b></td>
</tr>
<? foreach ($modules AS $module): ?>
<tr>
<td><b><a href="<?=$module->getViewUrl()?>"><?=$module->get('name')?></a></b></td>
<td>x <?=$quantities[$module->id]?></td>
</tr>
<? endforeach ?>
</table>
<br/>
<? endif ?>
<em>
<strong>Note:</strong> This list is reasonably accurate, but it is not guaranteed. Please review it before you buy anything.<br/>
If you do happen to find an error, please report it in the <a href="http://forums.reprap.org">forums</a>.
</em>
<br/>
<br/>
<? if (!empty($list->uniques)): ?>
<?= Controller::byName('main')->renderView('global_suppliers', array('suppliers' => $list->getSupplierList())); ?>
<form onsubmit="return false;" method="POST" id="bom_form">
<input type="hidden" name="module_id" value="<?=$module->id?>" />
<table width="100%">
<? foreach ($list->type_list AS $type => $data): ?>
<? $data = $list->getTypeList($type)->getAll(); ?>
<? foreach ($data AS $row): ?>
<? $unique = $row['UniquePart']; ?>
<? $quantity = $list->getUniqueQuantity($unique->id); ?>
<? $type = $unique->get('type'); ?>
<? if ($unique->get('type') != $old_type): ?>
<tr>
<td colspan="3">
<br/>
<span style="font-size: 23px; margin: 15 0 5 0"><?=UniquePart::typeToEnglish($type)?></a></span>
<a href="/type/<?=$type?>">view all</a>
</td>
</tr>
<? endif ?>
<? $old_type = $type; ?>
<? if ($quantity): ?>
<tr>
<td>
<img src="/img/plus-icon.gif" id="plus_<?=$unique->id?>" onclick="toggleBreakdown(<?=$unique->id?>)" style="cursor: pointer;"/>
<img src="/img/minus-icon.gif" id="minus_<?=$unique->id?>" onclick="toggleBreakdown(<?=$unique->id?>)" style="cursor: pointer; display: none"/>
<input type="checkbox" id="use_<?=$unique->id?>" name="use_part[<?=$unique->id?>]" value="1" checked="true"/>
<a href="<?=$unique->getViewUrl()?>"><?=$unique->get('name')?></a>
<img src="/img/help-icon.gif" onclick="Element.toggle('tooltip_<?=$unique->id?>')" style="cursor: pointer;">
<? if ($unique->get('url')): ?>
<a href="<?=$unique->get('url')?>" target="_blank"><img src="/img/url-icon.gif" border="0"></a>
<? endif ?>
<div id="tooltip_<?=$unique->id?>" class="tooltip" style="display: none; margin-left: 20px; font-size: 90%;"><?=$unique->get('description')?></div>
</td>
<td>
<input type="text" name="quantity[<?=$unique->id?>]" value="<?=$quantity?>" size="3">
<?= $unique->get('units') ?>
</td>
<td><?= Controller::byName('main')->renderView('part_suppliers', array('part' => $unique))?></td>
</tr>
<tr id="breakdown_<?=$unique->id?>" class="breakdown" style="display: none;">
<td colspan="4">
<div style="margin-left: 20px">
<table>
<tr>
<td><b>Part</b></td>
<td><b>Quantity</b></td>
</tr>
<? $raws = array(); ?>
<? foreach ($list->raw_list[$unique->id] AS $part): ?>
<?
$parent = new RawPart($part->get('parent_id'));
if ($parent->get('type') == 'assembly')
{
$assembly = $parent;
$parent = new RawPart($assembly->get('parent_id'));
}
else
{
$grandparent = new RawPart($parent->get('parent_id'));
$assembly = false;
}
?>
<tr>
<td><?=$part->get('raw_text')?> <span style="font-size: 90%">(from
<? $unique_parent = new UniquePart($parent->get('part_id')); ?>
<? if ($assembly instanceOf RawPart): ?>
<a href="<?=$unique_parent->getViewUrl()?>"><?=$parent->get('raw_text')?></a> / <?=$assembly->get('raw_text')?>)</span>
<? else: ?>
<a href="<?=$unique_parent->getViewUrl()?>"><?=$parent->get('raw_text')?></a>)</span>
<? endif ?>
</td>
<td><?=$part->get('quantity')?> <?= $unique->get('units') ?></td>
</tr>
<? endforeach ?>
</table>
</div>
</td>
</tr>
<? endif ?>
<? endforeach ?>
<? endforeach ?>
</table>
<br/>
<input type="button" style="font-size: 22px" value="Generate Shopping List" onclick="generateShoppingList()"/>
</form>
<br/>
<div id="shopping_list"></div>
<? else: ?>
<b>No components found!</b>
<? endif?>
<? endif ?>
|