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