blob: b1288d68a3528b866a9ebdd38f7c2c7d0775b00a [file] [log] [blame]
wdenkfe8c2802002-11-03 00:38:21 +00001<?php // php pages made with phpMyBuilder <http://kyber.dk/phpMyBuilder> ?>
2<?php
3 // (C) Copyright 2001
Wolfgang Denkb3b0fd52005-08-12 23:20:59 +02004 // Murray Jensen <Murray.Jensen@csiro.au>
wdenkfe8c2802002-11-03 00:38:21 +00005 // CSIRO Manufacturing Science and Technology, Preston Lab
6
7 // doedit page (hymod_bddb / boards)
8
9 require("defs.php");
10
11 pg_head("$bddb_label - Board Registration Results");
12
13 if (($serno=intval($serno)) != 0)
14 die("serial number must not be set ($serno) when Creating!");
15
16 $query="update boards set";
17
18 list($y, $m, $d) = split("-", $date);
19 if (!checkdate($m, $d, $y) || $y < 1999)
20 die("date is invalid (input '$date', yyyy-mm-dd '$y-$m-$d')");
21 $query.=" date='$date'";
22
23 if ($batch != '') {
24 if (strlen($batch) > 32)
25 die("batch field too long (>32)");
26 $query.=", batch='$batch'";
27 }
28
29 if (!in_array($type, $type_vals))
30 die("Invalid type ($type) specified");
31 $query.=", type='$type'";
32
33 if (($rev = intval($rev)) <= 0 || $rev > 255)
34 die("Revision number is invalid ($rev)");
35 $query.=sprintf(", rev=%d", $rev);
36
37 $query.=gather_enum_multi_query("sdram", 4);
38
39 $query.=gather_enum_multi_query("flash", 4);
40
41 $query.=gather_enum_multi_query("zbt", 16);
42
43 $query.=gather_enum_multi_query("xlxtyp", 4);
44 $nxlx = count_enum_multi("xlxtyp", 4);
45
46 $query.=gather_enum_multi_query("xlxspd", 4);
47 if (count_enum_multi("xlxspd", 4) != $nxlx)
48 die("number of xilinx speeds not same as number of types");
49
50 $query.=gather_enum_multi_query("xlxtmp", 4);
51 if (count_enum_multi("xlxtmp", 4) != $nxlx)
52 die("number of xilinx temps. not same as number of types");
53
54 $query.=gather_enum_multi_query("xlxgrd", 4);
55 if (count_enum_multi("xlxgrd", 4) != $nxlx)
56 die("number of xilinx grades not same as number of types");
57
58 if ($cputyp == '') {
59 if ($cpuspd != '')
60 die("can't specify cpu speed if there is no cpu");
61 if ($cpmspd != '')
62 die("can't specify cpm speed if there is no cpu");
63 if ($busspd != '')
64 die("can't specify bus speed if there is no cpu");
65 }
66 else {
67 $query.=", cputyp='$cputyp'";
68 if ($cpuspd == '')
69 die("must specify cpu speed if cpu type is defined");
70 $query.=", cpuspd='$cpuspd'";
71 if ($cpmspd == '')
72 die("must specify cpm speed if cpu type is defined");
73 $query.=", cpmspd='$cpmspd'";
74 if ($busspd == '')
75 die("must specify bus speed if cpu type is defined");
76 $query.=", busspd='$busspd'";
77 }
78
79 if (($hschin = intval($hschin)) < 0 || $hschin > 4)
80 die("Invalid number of hs input chans ($hschin)");
81 if (($hschout = intval($hschout)) < 0 || $hschout > 4)
82 die("Invalid number of hs output chans ($hschout)");
83 if ($hstype == '') {
84 if ($hschin != 0)
85 die("number of high-speed input channels must be zero"
86 . " if high-speed chip is not present");
87 if ($hschout != 0)
88 die("number of high-speed output channels must be zero"
89 . " if high-speed chip is not present");
90 }
91 else
92 $query.=", hstype='$hstype'";
93 $query.=", hschin='$hschin'";
94 $query.=", hschout='$hschout'";
95
96 // echo "final query = '$query'<br>\n";
97
98 $quant = intval($quant);
99 if ($quant <= 0) $quant = 1;
100
101 $sernos = array();
102 if ($geneths)
103 $ethaddrs = array();
104
105 $sqlerr = '';
106
107 while ($quant-- > 0) {
108
109 mysql_query("insert into boards (serno) values (null)");
110 if (mysql_errno()) {
111 $sqlerr = mysql_error();
112 break;
113 }
114
115 $serno = mysql_insert_id();
116 if (!$serno) {
117 $sqlerr = "couldn't allocate new serial number";
118 break;
119 }
120
121 mysql_query($query . " where serno=$serno");
122 if (mysql_errno()) {
123 $sqlerr = mysql_error();
124 break;
125 }
126
127 array_push($sernos, $serno);
128
129 if ($geneths) {
130
131 $ethaddr = gen_eth_addr($serno);
132
133 mysql_query("update boards set ethaddr='$ethaddr'" .
134 " where serno=$serno");
135 if (mysql_errno()) {
136 $sqlerr = mysql_error();
137
138 array_push($ethaddrs,
139 "<font color=#ff0000><b>" .
140 "db save fail" .
141 "</b></font>");
142 break;
143 }
144
145 array_push($ethaddrs, $ethaddr);
146 }
147 }
148
149 $nsernos = count($sernos);
150
151 if ($nsernos > 0) {
152
153 write_eeprom_cfg_file();
154
155 echo "<font size=+2>\n";
156 echo "\t<p>\n";
157 echo "\t\tThe following board serial numbers were"
158 . " successfully allocated";
159 if ($numerrs > 0)
160 echo " (but with $numerrs cfg file error" .
161 ($numerrs > 1 ? "s" : "") . ")";
162 echo ":\n";
163 echo "\t</p>\n";
164
165 echo "</font>\n";
166
167 echo "<table align=center width=\"100%\">\n";
168 echo "<tr>\n";
169 echo "\t<th>Serial Number</th>\n";
170 if ($numerrs > 0)
171 echo "\t<th>Cfg File Errs</th>\n";
172 if ($geneths)
173 echo "\t<th>Ethernet Address</th>\n";
174 echo "</tr>\n";
175
176 for ($i = 0; $i < $nsernos; $i++) {
177
178 $serno = sprintf("%010d", $sernos[$i]);
179
180 echo "<tr>\n";
181
182 echo "\t<td align=center><font size=+2>" .
183 "<b>$serno</b></font></td>\n";
184
185 if ($numerrs > 0) {
186 if (($errstr = $cfgerrs[$i]) == '')
187 $errstr = '&nbsp;';
188 echo "\t<td align=center>" .
189 "<font size=+2 color=#ff0000><b>" .
190 $errstr .
191 "</b></font></td>\n";
192 }
193
194 if ($geneths) {
195 echo "\t<td align=center>" .
196 "<font size=+2 color=#00ff00><b>" .
197 $ethaddrs[$i] .
198 "</b></font></td>\n";
199 }
200
201 echo "</tr>\n";
202 }
203
204 echo "</table>\n";
205 }
206
207 if ($sqlerr != '') {
208 echo "\t<font size=+4>\n";
209 echo "\t\t<p>\n";
210 echo "\t\t\tThe following SQL error was encountered:\n";
211 echo "\t\t</p>\n";
212 echo "\t\t<center>\n";
213 printf("\t\t\t<b>%s</b>\n", $sqlerr);
214 echo "\t\t</center>\n";
215 echo "\t</font>\n";
216 }
217
218?>
219<p>
220<table align=center width="100%">
221<tr>
222 <td align=center><a href="browse.php">Go to Browse</a></td>
223 <td align=center><a href="index.php">Back to Start</a></td>
224</tr>
225</table>
226<?php
227 pg_foot();
228?>