root / docs / www / colonyscout / internal / parts.php @ f59acf11
History | View | Annotate | Download (5.92 KB)
1 |
<?php require("includes/internal.php"); |
---|---|
2 |
$pageType="parts"; |
3 |
?>
|
4 |
|
5 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
6 |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head> |
7 |
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> |
8 |
<meta name="description" content="FILL IN"/> |
9 |
<meta name="keywords" content="FILL IN"/> |
10 |
<?php include($docRoot."internal/includes/header_internal.php"); ?> |
11 |
<script src="js/jquery-1.4.1-and-plugins.min.js" type="text/javascript"></script> |
12 |
<title>Parts | ColonyScout.com</title> |
13 |
<?php include('includes/querybox.php');?> |
14 |
<script type="text/javascript"> |
15 |
// Custom sorting plugin
|
16 |
(function($) {
|
17 |
$.fn.sorted = function(customOptions) {
|
18 |
var options = {
|
19 |
reversed: false,
|
20 |
by: function(a) { return a.text(); }
|
21 |
};
|
22 |
$.extend(options, customOptions);
|
23 |
$data = $(this);
|
24 |
arr = $data.get();
|
25 |
arr.sort(function(a, b) {
|
26 |
var valA = options.by($(a));
|
27 |
var valB = options.by($(b));
|
28 |
if (options.reversed) {
|
29 |
return (valA < valB) ? 1 : (valA > valB) ? -1 : 0;
|
30 |
} else {
|
31 |
return (valA < valB) ? -1 : (valA > valB) ? 1 : 0;
|
32 |
}
|
33 |
});
|
34 |
return $(arr);
|
35 |
};
|
36 |
})(jQuery);
|
37 |
|
38 |
// DOMContentLoaded
|
39 |
$(function() {
|
40 |
|
41 |
// bind radiobuttons in the form
|
42 |
var $filterType = $('#filter input[name="type"]');
|
43 |
var $filterSort = $('#filter input[name="sort"]');
|
44 |
|
45 |
// get the first collection
|
46 |
var $applications = $('#applications');
|
47 |
|
48 |
// clone applications to get a second collection
|
49 |
var $data = $applications.clone();
|
50 |
|
51 |
// attempt to call Quicksand on every form change
|
52 |
$filterType.add($filterSort).change(function(e) {
|
53 |
if ($($filterType+':checked').val() == 'all') {
|
54 |
var $filteredData = $data.find('li');
|
55 |
} else {
|
56 |
var $filteredData = $data.find('li[data-type=' + $($filterType+":checked").val() + ']');
|
57 |
}
|
58 |
|
59 |
// if sorted by size
|
60 |
if ($('#filter input[name="sort"]:checked').val() == "tags") {
|
61 |
var $sortedData = $filteredData.sorted({
|
62 |
by: function(v) {
|
63 |
return $(v).find('span[data-type=tags]').text().toLowerCase();
|
64 |
}
|
65 |
});
|
66 |
} else if ($('#filter input[name="sort"]:checked').val() == "name") {
|
67 |
// if sorted by name
|
68 |
var $sortedData = $filteredData.sorted({
|
69 |
by: function(v) {
|
70 |
return $(v).find('b').text().toLowerCase();
|
71 |
}
|
72 |
});
|
73 |
} else {
|
74 |
// if sorted by price
|
75 |
var $sortedData = $filteredData.sorted({
|
76 |
by: function(v) {
|
77 |
return parseFloat($(v).find('span[data-type=price]').text());
|
78 |
}
|
79 |
});
|
80 |
}
|
81 |
|
82 |
|
83 |
// finally, call quicksand
|
84 |
$applications.quicksand($sortedData, {
|
85 |
duration: 800,
|
86 |
easing: 'easeInOutQuad'
|
87 |
});
|
88 |
|
89 |
});
|
90 |
|
91 |
});
|
92 |
</script>
|
93 |
</head>
|
94 |
<body bgcolor="#eeeeee"> |
95 |
|
96 |
<div id="general"> |
97 |
<?php include("includes/nav_internal.php"); ?> |
98 |
<div id="body"> |
99 |
<div id="body-boxes"> |
100 |
<div class="box-row" style="margin-top: 7px;"> |
101 |
<div class="white-top"></div> |
102 |
<div class="white-body text-box"> |
103 |
<?php
|
104 |
|
105 |
//gather the inventory based on search term or all
|
106 |
$get_inventory_sql = "SELECT ID,name,manufacturername,manufacturerpartno,VendorPartNo,VendorID,description,qty,cost_1,tags, (select name from vendors WHERE vendors.id=inventory.vendorid) as vendorname FROM inventory"; |
107 |
$get_inventory_res = mysqli_query($mysqli, $get_inventory_sql) or die(mysqli_error($mysqli)); |
108 |
|
109 |
if (mysqli_num_rows($get_inventory_res) < 1) { |
110 |
$display_block = "</table><br/><h1>No inventory matched those search terms.</h1>"; |
111 |
} else {
|
112 |
//create the display string
|
113 |
$display_block = ""; |
114 |
|
115 |
while ($inv = mysqli_fetch_array($get_inventory_res)) { |
116 |
$imgURL=getThumbFromDisk($inv["VendorPartNo"]); |
117 |
$display_block .=
|
118 |
"<li data-id=\"id-".$inv['ID']."\" data-type=\"".$inv['vendorname']."\"> |
119 |
<a href=\"partsview.php?q=".$inv['VendorPartNo']."\"> |
120 |
<div style=\"height:180px;\"><img src=\"".$imgURL."\" width=\"140px\"/></div> |
121 |
<b>".$inv['name']."</b><br/> |
122 |
<span data-type=\"tags\">".$inv['tags']."</span><br/> |
123 |
$<span data-type=\"price\">".$inv["cost_1"]."</span> |
124 |
</a>
|
125 |
</li>";
|
126 |
} |
127 |
} |
128 |
?>
|
129 |
|
130 |
<form id="filter"> |
131 |
<fieldset>
|
132 |
<legend>Filter by Vendor</legend> |
133 |
<label><input type="radio" name="type" value="all" checked="checked">All</label> |
134 |
<label><input type="radio" name="type" value="Digikey">Digikey</label> |
135 |
<label><input type="radio" name="type" value="Jameco">Jameco</label> |
136 |
<label><input type="radio" name="type" value="Mouser">Mouser</label> |
137 |
<label><input type="radio" name="type" value="Newark">Newark</label> |
138 |
<label><input type="radio" name="type" value="Pololu">Pololu</label> |
139 |
<label><input type="radio" name="type" value="SparkFun">Sparkfun</label> |
140 |
</fieldset>
|
141 |
<fieldset>
|
142 |
<legend>Sort by Type</legend> |
143 |
<label><input type="radio" name="sort" value="tags" checked="checked">Category</label> |
144 |
<label><input type="radio" name="sort" value="name">Name</label> |
145 |
<label><input type="radio" name="sort" value="price">Price</label> |
146 |
</fieldset>
|
147 |
</form>
|
148 |
|
149 |
<!-- read the documentation to understand what?s going on here -->
|
150 |
<ul id="applications" class="image-grid"> |
151 |
<?php echo $display_block; ?> |
152 |
</ul>
|
153 |
|
154 |
</div>
|
155 |
<div class="white-bottom"></div> |
156 |
</div>
|
157 |
|
158 |
|
159 |
</div>
|
160 |
</div> <!--BODY!--> |
161 |
|
162 |
|
163 |
<?php include($docRoot."footer.php"); ?> |
164 |
|
165 |
</div><!--GENERAL!--> |
166 |
|
167 |
|
168 |
</body></html> |
169 |
<?php mysqli_close($mysqli);?> |