That patch had a few bugs in it, this one is better.

Chris




On Friday 26 March 2004 10:52 pm, Chris Morgan wrote:
> This look alright?  I'm still trying to learn php ;-)
>
> account.php, appsubmit.php, admin/adminAppQueue.php
> Chris Morgan <[EMAIL PROTECTED]>
> Add a dropdown list of vendors to the app submit page.  Automatch the
> dropdown vendor selection on the admin side of there is an exact or partial
> name match.  Clear out the vendor field if a match is found.  Display
> username when logging in to the db.
>
> Chris
Index: account.php
===================================================================
RCS file: /home/wine/appdb/account.php,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 account.php
--- account.php	15 Mar 2004 16:22:00 -0000	1.1.1.1
+++ account.php	27 Mar 2004 03:42:06 -0000
@@ -184,7 +184,7 @@
     if($result == null)
 	{
 	    $current = $user;
-	    addmsg("You are successfully logged in.", "green");
+	    addmsg("You are successfully logged in as '$user->username'.", "green");
 	    redirect(apidb_fullurl("index.php"));    	    
 	}
     else
Index: appsubmit.php
===================================================================
RCS file: /home/wine/appdb/appsubmit.php,v
retrieving revision 1.3
diff -u -r1.3 appsubmit.php
--- appsubmit.php	24 Mar 2004 15:49:59 -0000	1.3
+++ appsubmit.php	27 Mar 2004 03:42:06 -0000
@@ -23,7 +23,8 @@
         $errors .= "<li>Please enter an application version.</li>\n";
     }
 
-    if ( empty( $fields['queueVendor']) )
+    // No vendor entered, and nothing in the list is selected
+    if ( empty( $fields['queueVendor']) and $fields['altvendor'] == '0' )
     {
         $errors .= "<li>Please enter a vendor.</li>\n";
     }
@@ -51,12 +52,11 @@
 
 include("path.php");
 require(BASE."include/"."incl.php");
+require(BASE."include/"."tableve.php");
 global $current;
 
 if ($_REQUEST['queueName'])
 {
-	// add to queue
-    
     // Check input and exit if we found errors
     $errors = checkInput($_REQUEST);
     if( !empty($errors) )
@@ -64,10 +64,25 @@
         errorpage("We found the following errors:","<ul>$errors</ul><br>Please go back and correct them.");
         exit;
     }
+
+    /* if the user picked the vendor we need to retrieve the vendor name */
+    /* and store it into the $queueVendor */
+    if($_REQUEST['altvendor'])
+    {
+        /* retrieve the actual name here */
+        $query = "select * from vendor where vendorId = '$altvendor';";
+        $result = mysql_query($query);
+        if($result)
+        {
+            $ob = mysql_fetch_object($result);
+            $_REQUEST['queueVendor'] = $ob->vendorName;
+        }
+    }
     
     // header
     apidb_header("Submit Application");    
-    
+
+    // add to queue
     $query = "INSERT INTO appQueue VALUES (null, '".
             addslashes($_REQUEST['queueName'])."', '".
             addslashes($_REQUEST['queueVersion'])."', '".
@@ -88,7 +103,6 @@
         echo "<p>Your application has been submitted for Review. You should hear back\n";
         echo "soon about the status of your submission</p>\n";
     }
-    
 }
 else
 {
@@ -122,6 +136,13 @@
 	    echo '<tr valign=top><td class=color0><b>App Name</b></td><td><input type=text name="queueName" value="" size=20></td></tr>',"\n";
 	    echo '<tr valign=top><td class=color0><b>App Version</b></td><td><input type=text name="queueVersion" value="" size=20></td></tr>',"\n";
 	    echo '<tr valign=top><td class=color0><b>App Vendor</b></td><td><input type=text name="queueVendor" value="" size=20></td></tr>',"\n";
+
+        //alt vendor
+        $x = new TableVE("view");
+        echo '<tr valign=top><td class=color0>&nbsp;</td><td>',"\n";
+        $x->make_option_list("altvendor","","vendor","vendorId","vendorName");
+        echo '</td></tr>',"\n";
+
 	    echo '<tr valign=top><td class=color0><b>App URL</b></td><td><input type=text name="queueURL" value="" size=20></td></tr>',"\n";
 	    echo '<tr valign=top><td class=color0><b>App Desc</b></td><td><textarea name="queueDesc" rows=10 cols=35></textarea></td></tr>',"\n";
 	    echo '<tr valign=top><td class=color0><b>Email</b></td><td><input type=text name="queueEmail" value="'.$email.'" size=20></td></tr>',"\n";
Index: admin/adminAppQueue.php
===================================================================
RCS file: /home/wine/appdb/admin/adminAppQueue.php,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 adminAppQueue.php
--- admin/adminAppQueue.php	15 Mar 2004 16:22:01 -0000	1.1.1.1
+++ admin/adminAppQueue.php	27 Mar 2004 03:42:07 -0000
@@ -84,13 +84,41 @@
 	//version
 	echo '<tr valign=top><td class=color0><b>App Version</b></td><td><input type=text name="queueVersion" value="'.stripslashes($ob->queueVersion).'" size=20></td></tr>',"\n";
  	
-	//vendor
- 	echo '<tr valign=top><td class=color0><b>App Vendor</b></td><td><input type=text name="queueVendor" value="'.stripslashes($ob->queueVendor).'" size=20></td></tr>',"\n";
+	//vendor/alt vendor fields
+    // try for an exact match
+    $query = "select * from vendor where vendorname = '$ob->queueVendor';";
+    $result = mysql_query($query);
+    if(!$result)
+    {
+        // try for a partial match
+        $query = "select * from vendor where vendorname like '%$ob->queueVendor%';";
+        $result = mysql_query($query);
+    }
+
+    // Use the first match if we found one and clear out the vendor field,
+    // otherwise don't pick a vendor
+    if($result)
+    {
+        $ob->queueVendor = '';
+
+        //vendor field
+        echo '<tr valign=top><td class=color0><b>App Vendor</b></td><td><input type=text name="queueVendor" value="'.stripslashes($ob->queueVendor).'" size=20></td></tr>',"\n";
 	
-	//alt vendor
-	echo '<tr valign=top><td class=color0>&nbsp;</td><td>',"\n";
-	$x->make_option_list("altvendor","","vendor","vendorId","vendorName");
-	echo '</td></tr>',"\n";
+        $ob2 = mysql_fetch_object($result);
+
+        echo '<tr valign=top><td class=color0>&nbsp;</td><td>',"\n";
+        $x->make_option_list("altvendor","$ob2->vendorId","vendor","vendorId","vendorName");
+        echo '</td></tr>',"\n";
+    } else
+    {
+        //vendor field
+        echo '<tr valign=top><td class=color0><b>App Vendor</b></td><td><input type=text name="queueVendor" value="'.stripslashes($ob->queueVendor).'" size=20></td></tr>',"\n";
+	
+        echo '<tr valign=top><td class=color0>&nbsp;</td><td>',"\n";
+        $x->make_option_list("altvendor","","vendor","vendorId","vendorName");
+        echo '</td></tr>',"\n";
+    }
+    
 		
 	//url
 	echo '<tr valign=top><td class=color0><b>App URL</b></td><td><input type=text name="queueURL" value="'.stripslashes($ob->queueURL).'" size=20></td></tr>',"\n";

Reply via email to