colonymech / docs / www / colonyscout / internal / viewinventory_old.php @ f59acf11
History | View | Annotate | Download (6.48 KB)
1 | f59acf11 | Dan Shope | <?php require("includes/internal.php")?> |
---|---|---|---|
2 | |||
3 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head> |
||
5 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> |
||
6 | <meta name="description" content="FILL IN"/> |
||
7 | <meta name="keywords" content="FILL IN"/> |
||
8 | <?php include($docRoot."header.php"); ?> |
||
9 | <title>View Parts | ColonyScout.com</title> |
||
10 | <?php include('includes/querybox.php');?> |
||
11 | <style>
|
||
12 | .sort-up {background:url('images/up.gif') no-repeat;float:left;width:12px;height:12px;margin:3px 5px 3px 10px;}
|
||
13 | .sort-down {background:url('images/down.gif') no-repeat;float:right;width:12px;height:12px;margin:3px 10px 3px 5px;}
|
||
14 | </style>
|
||
15 | </head>
|
||
16 | <body bgcolor="#eeeeee"> |
||
17 | |||
18 | <div id="general"> |
||
19 | <?php include("includes/nav_internal.php"); ?> |
||
20 | <div id="body"> |
||
21 | <div id="body-boxes"> |
||
22 | <div class="box-row" style="margin-top: 7px;"> |
||
23 | <div class="white-top"></div> |
||
24 | <div class="white-body text-box"> |
||
25 | <div id="breadcrumbs"><a href="viewinventory.php">Inventory></a></div> |
||
26 | <div id="livesearch"><div id="box0"><!-- livesearch--></div></div> |
||
27 | <br/> |
||
28 | <div class="hr"></div> |
||
29 | </div><!--end 'TEMP' collapse--> |
||
30 | |||
31 | <div class="white-body text-box"> |
||
32 | <?php
|
||
33 | $pageNum = (isset($_GET['page'])) ? $_GET['page'] : 1; // if $_GET['page'] defined, use it as page number |
||
34 | $rowsPerPage = 30; // how many rows to show per page |
||
35 | $offset = ($pageNum - 1) * $rowsPerPage; // counting the offset |
||
36 | |||
37 | $sortColumn="VendorID"; $sortOrder="DESC"; |
||
38 | if(isset($_GET["sortby"])) { |
||
39 | switch ($_GET["sortby"]) { |
||
40 | case "valinc": |
||
41 | $sortColumn = "Description"; $sortOrder="ASC"; |
||
42 | break;
|
||
43 | case "valdec": |
||
44 | $sortColumn = "Description"; $sortOrder="DESC"; |
||
45 | break;
|
||
46 | case "manfinc": |
||
47 | $sortColumn = "ManufacturerName"; $sortOrder="ASC"; |
||
48 | break;
|
||
49 | case "manfdec": |
||
50 | $sortColumn = "ManufacturerName"; $sortOrder="DESC"; |
||
51 | break;
|
||
52 | case "veninc": |
||
53 | $sortColumn = "VendorID"; $sortOrder="ASC"; |
||
54 | break;
|
||
55 | case "vendec": |
||
56 | $sortColumn = "VendorID"; $sortOrder="DESC"; |
||
57 | break;
|
||
58 | case "qtyinc": |
||
59 | $sortColumn = "qty"; $sortOrder="ASC"; |
||
60 | break;
|
||
61 | case "qtydec": |
||
62 | $sortColumn = "qty"; $sortOrder="DESC"; |
||
63 | break;
|
||
64 | case "priceinc": |
||
65 | $sortColumn = "cost_1"; $sortOrder="ASC"; |
||
66 | break;
|
||
67 | case "pricedec": |
||
68 | $sortColumn = "cost_1"; $sortOrder="DESC"; |
||
69 | break;
|
||
70 | } |
||
71 | } |
||
72 | |||
73 | |||
74 | //gather the inventory based on search term or all
|
||
75 | $get_inventory_sql = "SELECT ID,name,manufacturername,manufacturerpartno,VendorPartNo,description,qty,cost_1, (select name from vendors WHERE vendors.id=inventory.vendorid) as vendorname FROM inventory ORDER BY $sortColumn $sortOrder LIMIT $offset, $rowsPerPage"; |
||
76 | $get_inventory_res = mysqli_query($mysqli, $get_inventory_sql) or die(mysqli_error($mysqli)); |
||
77 | |||
78 | if (mysqli_num_rows($get_inventory_res) < 1) { |
||
79 | $display_block = "</table><br/><h1>No inventory matched those search terms.</h1>"; |
||
80 | } else {
|
||
81 | //create the display string
|
||
82 | $display_block = ""; |
||
83 | |||
84 | while ($inv = mysqli_fetch_array($get_inventory_res)) { |
||
85 | $display_block .=
|
||
86 | "<tr>
|
||
87 | <td><a href=\"viewpart.php?q=".$inv["VendorPartNo"]."\">".$inv["name"]."</a></td> |
||
88 | <td>".$inv["description"]."</td><td>".$inv["manufacturername"]."</td> |
||
89 | <td><a target=\"_blank\" href=\"".getURL($inv["VendorPartNo"],$inv["vendorname"])."\">".$inv["manufacturerpartno"]."</a></td> |
||
90 | <td>".$inv["vendorname"]."</td> |
||
91 | <td>".$inv["qty"]."</td> |
||
92 | <td>\$".$inv["cost_1"]."</td></tr>"; |
||
93 | } |
||
94 | |||
95 | $display_block .= "</table><br/><br/>"; |
||
96 | |||
97 | |||
98 | // how many rows we have in database
|
||
99 | $get_num_inventory_sql = "SELECT COUNT(*) AS inventory_count FROM inventory"; |
||
100 | $get_num_inventory_res = mysqli_query($mysqli, $get_num_inventory_sql) or die(mysqli_error($mysqli)); |
||
101 | |||
102 | while ($inventory_info = mysqli_fetch_array($get_num_inventory_res)) { |
||
103 | $numrows = $inventory_info['inventory_count']; |
||
104 | } |
||
105 | |||
106 | // how many pages we have when using paging?
|
||
107 | $maxPage = ceil($numrows/$rowsPerPage); |
||
108 | |||
109 | // print the link to access each page
|
||
110 | $self = $_SERVER['PHP_SELF']; |
||
111 | $nav = ''; |
||
112 | for($page = 1; $page <= $maxPage; $page++) { |
||
113 | if ($page == $pageNum) { |
||
114 | $nav .= "<li class=\"currentpage\">$page</li>\n"; // no need to create a link to current page |
||
115 | } else {
|
||
116 | $nav .= "<li><a href=\"$self?page=$page\">$page</a></li>\n"; |
||
117 | } |
||
118 | } |
||
119 | |||
120 | // creating previous and next link
|
||
121 | // plus the link to go straight to
|
||
122 | // the first and last page
|
||
123 | |||
124 | if ($pageNum > 1) { |
||
125 | $page = $pageNum - 1; |
||
126 | $prev = "<li><a href=\"$self?page=$page\">prev</a></li>\n"; |
||
127 | } else {
|
||
128 | $prev = ' '; // we're on page one, don't print previous link |
||
129 | } |
||
130 | |||
131 | if ($pageNum < $maxPage) { |
||
132 | $page = $pageNum + 1; |
||
133 | $next = "<li><a href=\"$self?page=$page\">next</a></li>\n"; |
||
134 | } else {
|
||
135 | $next = ' '; // we're on the last page, don't print next link |
||
136 | } |
||
137 | |||
138 | // print the navigation link
|
||
139 | $navString = "<div id=\"navcontainer\"> |
||
140 | <ul>".$prev.$nav.$next."</ul>\n</div>"; |
||
141 | |||
142 | |||
143 | //free results
|
||
144 | mysqli_free_result($get_inventory_res);
|
||
145 | |||
146 | } |
||
147 | |||
148 | //close connection to MySQL
|
||
149 | mysqli_close($mysqli);
|
||
150 | |||
151 | $address = '?page='.$pageNum."&"; |
||
152 | ?>
|
||
153 | <table>
|
||
154 | <tr>
|
||
155 | <th width="220px">Part Name<br/> |
||
156 | </th>
|
||
157 | <th width="70px">Value<br/> |
||
158 | <a href="<?php echo $address;?>sortby=valinc"><div class="sort-up"></div></a> |
||
159 | <a href="<?php echo $address;?>sortby=valdec"><div class="sort-down"></div></a> |
||
160 | </th>
|
||
161 | <th width="210px">Manufacturer<br/> |
||
162 | <a href="<?php echo $address;?>sortby=manfinc"><div class="sort-up"></div></a> |
||
163 | <a href="<?php echo $address;?>sortby=manfdec"><div class="sort-down"></div></a> |
||
164 | </th>
|
||
165 | <th width="240px">Manufacturer Part No<br/> |
||
166 | </th>
|
||
167 | <th width="60px">Vendor<br/> |
||
168 | <a href="<?php echo $address;?>sortby=veninc"><div class="sort-up"></div></a> |
||
169 | <a href="<?php echo $address;?>sortby=vendec"><div class="sort-down"></div></a> |
||
170 | </th>
|
||
171 | <th width="70px">Qty<br/> |
||
172 | <a href="<?php echo $address;?>sortby=qtyinc"><div class="sort-up"></div></a> |
||
173 | <a href="<?php echo $address;?>sortby=qtydec"><div class="sort-down"></div></a> |
||
174 | </th>
|
||
175 | <th width="70px">$/each<br/> |
||
176 | <a href="<?php echo $address;?>sortby=priceinc"><div class="sort-up"></div></a> |
||
177 | <a href="<?php echo $address;?>sortby=pricedec"><div class="sort-down"></div></a> |
||
178 | </th>
|
||
179 | </tr>
|
||
180 | <?php echo $display_block; echo $navString;?> |
||
181 | |||
182 | </div>
|
||
183 | |||
184 | </div>
|
||
185 | <div class="white-bottom"></div> |
||
186 | </div>
|
||
187 | |||
188 | |||
189 | </div>
|
||
190 | </div> <!--BODY!--> |
||
191 | |||
192 | |||
193 | <?php include($docRoot."footer.php"); ?> |
||
194 | |||
195 | </div><!--GENERAL!--> |
||
196 | |||
197 | |||
198 | </body></html> |