PageRenderTime 63ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 0ms

/coopcoffeebeans/Customer/product_results.php

https://github.com/gypsyfarm/gypsyfarm
PHP | 227 lines | 164 code | 55 blank | 8 comment | 37 complexity | d405825063e561126a85a8818119385e MD5 | raw file
  1. <?php
  2. require("../functions.php");
  3. require("../tables.php");
  4. session_start();
  5. require("../check_login.php");
  6. ?>
  7. <html>
  8. <head>
  9. <title>Cooperative Coffees - Order and Contact Database system</title>
  10. <link REL="stylesheet" TYPE="text/css" HREF="../general.css">
  11. <!-- changed #228B22 to #9bbcc2 -->
  12. </head>
  13. <?
  14. #require("../Bill/left_menu.php");
  15. echo '<table border="0" width="100%" cellspacing="0" cellpadding="0">';
  16. echo '<tr>';
  17. echo '<td width="150" valign="top">';
  18. echo '<table border="1" width="140" cellspacing="0" bordercolor="#FFFFFF" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" cellpadding="2">';
  19. echo '<tr>';
  20. echo '<td width="100%" bordercolor="#228B22" bgcolor="#228B22"><font face="Verdana" size="1" color="#FFFFFF"><b>::';
  21. echo "<a href=\"javascript:poptastic('Help.php?x=47A$menu_user_type');\"><font face='Verdana' size='1' color='#FFFFFF'>help</font</a>";
  22. echo '</tr>';
  23. echo '<tr>';
  24. echo '<td width="600" bordercolor="#228B22" bgcolor="#FFFFFF">';
  25. echo '<font face="Verdana" size="1">*<a href="../index.php">Back to Main Menu</a></font><br>';
  26. echo '<hr>';
  27. echo '<font face="Verdana" size="1">*<a href="cooporder.php">Create a new Order</a></font><br>';
  28. echo '<hr>';
  29. echo '<font face="Verdana" size="1">*<a href="reports/index.php">View Reports</a></font><br>';
  30. echo '<hr>';
  31. echo '<font face="Verdana" size="1">*<a href="../Contact_Search/contact_start.php">Contact Database</a></font><br>';
  32. echo '<hr>';
  33. echo '<font face="Verdana" size="1">*<a href="product_start.php">Lot Review</a></font><br>';
  34. echo '<hr>';
  35. echo '<font face="Verdana" size="1">*<a href="password.php">Change Password</a></font><br>';
  36. echo '<hr>';
  37. echo '<font face="Verdana" size="1">*<a href="../logout.php">Log out</a></font><br>';
  38. echo '</td>';
  39. echo '</tr>';
  40. echo '</table>';
  41. echo '</td>';
  42. echo '<td valign="top">';
  43. echo '<table border="1" width="100%" bordercolor="#FFFFFF" cellspacing="0" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" cellpadding="2">';
  44. echo '<tr>';
  45. echo '<td width="100%" bordercolor="#228B22" bgcolor="#228B22"><font face="Verdana" size="1" color="#FFFFFF"><b>::';
  46. echo '<u>C</u>ontent:</b></font></td>';
  47. echo '</tr>';
  48. echo '<tr>';
  49. echo '<td width="100%" bordercolor="#228B22" bgcolor="#FFFFFF">';
  50. echo '<p align="right">ยค ';
  51. echo date('H:i, jS F');
  52. echo '</p>';
  53. //********Present the Menus*********************************************
  54. if (isset($_SESSION['contact_id'])) {
  55. #echo 'document-root = '.$DOCUMENT_ROOT.'<BR>';
  56. $quicksearch = $_REQUEST['quicksearch'];
  57. $sort_option = $_REQUEST['sort_option'];
  58. $local = $_REQUEST['local'];
  59. $my_session_var = $_SESSION['search_string'];
  60. $db_conn = mysql_connect('mysql.coopcoffeesbeans.com', 'greenbeans3', 'annh401');
  61. mysql_select_db('cbeans', $db_conn);
  62. if ($sort_option == '2') {
  63. $sort_value = ' order by item_id ';
  64. }
  65. else {
  66. $sort_value = 'order by warehouse, item_code, (lot_ship + 0) ';
  67. }
  68. if ($local == 'yes') {
  69. $query = $my_session_var;
  70. $query_plus_sort = $my_session_var.$sort_value;
  71. }
  72. else {
  73. # set if search should include inactive records or not
  74. if ( $inactive_items_too == "on") {
  75. $item_active_where = '';
  76. }
  77. else {
  78. $item_active_where = ' item_active = 0 ';
  79. }
  80. if ($quicksearch != "no") {
  81. $query = "select * FROM $tbl_coop_item WHERE item_code like '$quicksearch%' and $item_active_where ";
  82. $query_plus_sort = "select * FROM $tbl_coop_item WHERE item_code like '$quicksearch%' and $item_active_where ".$sort_value;
  83. }
  84. else {
  85. $and = " ";
  86. $where = " where ";
  87. $search_string = "";
  88. $item_code = $_REQUEST['item_code'];
  89. $lot_ship = $_REQUEST['lot_ship'];
  90. $inactive_items_too = $_REQUEST['inactive_items_too'];
  91. if (isset($item_code) && $item_code != "") {
  92. $search_string = $where.$search_string.$and." item_code like '".$item_code."%' ";
  93. $and = " and ";
  94. $where = " ";
  95. }
  96. if (isset($lot_ship) && $lot_ship != "") {
  97. $search_string = $where.$search_string.$and." lot_ship like '".$lot_ship."%' ";
  98. $and = " and ";
  99. $where = " ";
  100. }
  101. if (isset($warehouse) && $warehouse != "") {
  102. $search_string = $where.$search_string.$and." warehouse like '".$warehouse."%' ";
  103. $and = " and ";
  104. $where = " ";
  105. }
  106. if (isset($scribd_id) && $scribd_id != "") {
  107. $search_string = $where.$search_string.$and." scribd_id like '".$scribd_id."%' ";
  108. $and = " and ";
  109. $where = " ";
  110. }
  111. if (isset($arrival_date) && $arrival_date != "") {
  112. $search_string = $where.$search_string.$and." arrival_date > '".$arrival_date."%' ";
  113. $and = " and ";
  114. $where = " ";
  115. }
  116. if ($item_active_where == '') {
  117. $and = " ";
  118. }
  119. $query = "select * from $tbl_coop_item $search_string $and $item_active_where ";
  120. $query_plus_sort = "select * from $tbl_coop_item $search_string $and $item_active_where ".$sort_value;
  121. }
  122. }
  123. $_SESSION['search_string'] = $query;
  124. #echo "<br>$query <br>";
  125. $result = mysql_query($query_plus_sort, $db_conn);
  126. if (mysql_num_rows($result) >0 ) {
  127. // if they are in the database register the user id
  128. $row = mysql_fetch_array($result);
  129. $num_results = mysql_num_rows($result);
  130. echo '<table border="1" width="100%" bordercolor="#FFFFFF" cellspacing="0" bordercolorlight="#FFFFFF" bordercolordark="#FFFFFF" cellpadding="2">';
  131. echo '<tr>';
  132. echo "<td><a href='product_results.php?sort_option=2&local=yes'>Item Nbr. </a> </td>";
  133. echo "<td><a href='product_results.php?sort_option=1&local=yes'>Item / Lot </a></td>";
  134. echo '<td colspan=2>Click on heading to left to change sort </td>';
  135. echo '</tr>';
  136. for ($i=0; $i <$num_results; $i++) {
  137. $Company = $row['Company'];
  138. if ($Company == "")
  139. $Company = "No Company Name";
  140. echo '<tr>';
  141. echo '<td>'.$row['item_id'].'</td>';
  142. echo '<td><a href="product_maint.php?item_id=';
  143. echo "'".$row['item_id']."'";
  144. echo '">'.$row['item_code'].' / '.$row['lot_ship'].'</a></td>';
  145. echo '<td>'.$row['warehouse'].'</td>';
  146. echo '<td>'.$row['item_description'].'</td>';
  147. echo '</tr>';
  148. $row = mysql_fetch_array($result);
  149. }
  150. echo '</table>';
  151. } # end if (mysql_num_rows($result) >0 )
  152. } # bad login id:
  153. else {
  154. if (isset($userid)) {
  155. // if they've tried and failed to log in
  156. echo 'Could not log you in';
  157. }
  158. else {
  159. // they have not tried to log in yet or have logged out
  160. echo '<font size=4 color=black>You are not logged in, please enter a valid userid and password.</font>';
  161. }
  162. }
  163. ?>
  164. <hr noshade size="1" color="#228B22">
  165. </td>
  166. </tr>
  167. </table>
  168. </td>
  169. </tr>
  170. </table>
  171. </body>
  172. </html>