summaryrefslogtreecommitdiff
path: root/trunk/reprap/web/part-lister/views/parts.embed.php
blob: f0cb82332be9efe7329f27f499ecb088670e1ff8 (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
<html>
	<head>
		<title><?=$part->get('name')?> - Bill of Materials</title>
		<link rel="stylesheet" type="text/css" href="http://<?=SITE_HOSTNAME?>/css/embed.css" />
		<meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
	</head>
	<body>
		<? if ($error): ?>
			<h2>Error:</h2>
			<h3 style="color: red;"><?=$error?></h3>
		<? else: ?>
			<h1><a href="http://<?=SITE_HOSTNAME?><?=$part->getViewUrl()?>" target="_blank"><?=$part->get('name')?></a></h1>
			<? if ($part->get('type') == 'module' || $part->get('type') == 'assembly' || $part->get('type') == 'kit'): ?>
				<h2>Bill of Materials</h2>
				<? if (!empty($list->type_list)): ?>
					<table>
						<tr>
							<th>Id</th>
							<th>Part</th>
							<th>Quantity</th>
						</tr>
						<? foreach ($list->type_list AS $type => $data): ?>
							<? foreach ($data AS $unique_id): ?>
								<? $unique = $list->getUnique($unique_id); ?>
								<?
									$raw_id = "";
									if (!empty($list->raw_list[$unique->id]))
									{
										$raw_ids = array();
										foreach ($list->raw_list[$unique->id] AS $raw)
										{
											$temp = explode(",", $raw->get("raw_id"));
											if (!empty($temp))
											{
												foreach ($temp AS $key => $tval)
													$temp[$key] = trim($tval);
											}
											$raw_ids[] = implode(", ", $temp);
										}
										$raw_id = implode(", ", $raw_ids);
									}
									
									//hack to get borders.
									if ($raw_id == "")
										$raw_id = "&nbsp;";
								?>
								<tr>
									<td><?=$raw_id?></td>
									<td><a href="http://<?=SITE_HOSTNAME?><?=$unique->getViewUrl()?>" target="_blank"><?=$unique->get('name')?></a></td>
									<td align="center"><?=$list->getUniqueQuantity($unique->id)?> <?=$unique->get('units')?></td>
								</tr>
							<? endforeach ?>
						<? endforeach ?>
					</table>
				<? else: ?>
					<b>No parts found.</b>
				<? endif ?>
			<? endif ?>
		<? endif ?>
		<br/>
		<span class="small">Generated by the <a href="http://<?=SITE_HOSTNAME?>" target="_blank"><?=RR_PROJECT_NAME?></a></span>
	</body>
</html>