Index: uc_order/uc_order.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/uc_order/uc_order.admin.inc,v
retrieving revision 1.39
diff -u -p -r1.39 uc_order.admin.inc
--- uc_order/uc_order.admin.inc	8 Feb 2011 10:23:00 -0000	1.39
+++ uc_order/uc_order.admin.inc	8 Feb 2011 15:42:19 -0000
@@ -685,10 +685,6 @@ function uc_order_create_form($form, &$f
     '#size' => 10,
     '#disabled' => TRUE,
   );
-  $form['customer']['primary_email'] = array(
-    '#type' => 'hidden',
-    '#default_value' => '',
-  );
   $form['customer']['text']['primary_email_text'] = array(
     '#type' => 'textfield',
     '#title' => t('Primary e-mail'),
@@ -845,37 +841,31 @@ function uc_order_select_customer($email
 
   // Return the search results and let them pick one!
   if (arg(4) == 'search') {
-    $first_name = str_replace('*', '%', db_like(arg(5)));
-    $last_name = str_replace('*', '%', db_like(arg(6)));
-    $email = str_replace('*', '%', db_like(arg(7)));
+    $first_name = str_replace('*', '%', db_like($_POST['first_name']));
+    $last_name = str_replace('*', '%', db_like($_POST['last_name']));
+    $email = str_replace('*', '%', db_like($_POST['email']));
 
     $query = db_select('users', 'u')->distinct();
-    $o = $query->leftJoin('uc_orders', 'o', 'u.uid = o.uid');
-
-    $u_uid = $query->addField('u', 'uid', 'u_uid');
-    $u_mail = $query->addField('u', 'mail', 'u_mail');
-    $o_email = $query->addField('o', 'primary_email', 'o_email');
-    $ob_first_name = $query->addField('o', 'billing_first_name', 'ob_first_name');
-    $ob_last_name = $query->addField('o', 'billing_last_name', 'ob_last_name');
-    $o_order_status = $query->addField('o', 'order_status', 'o_order_status');
-
-    $query->condition($u_uid, 0, '>')
+    $query->leftJoin('uc_orders', 'o', 'u.uid = o.uid');
+    $query->fields('u', array('uid', 'mail'))
+      ->fields('o', array('billing_first_name', 'billing_last_name'))
+      ->condition('u.uid', 0, '>')
       ->condition(db_or()
-        ->isNull($o_order_status)
-        ->condition($o_order_status, uc_order_status_list('general', TRUE), 'IN')
+        ->isNull('o.order_status')
+        ->condition('o.order_status', uc_order_status_list('general', TRUE), 'IN')
       )
-      ->orderBy($ob_last_name);
+      ->orderBy('o.billing_last_name');
 
-    if ($first_name !== '0' && $first_name !== '%') {
-      $query->condition($ob_first_name, $first_name, 'LIKE');
+    if ($first_name && $first_name !== '%') {
+      $query->condition('o.billing_first_name', $first_name, 'LIKE');
     }
-    if ($last_name !== '0' && $last_name !== '%') {
-      $query->condition($ob_last_name, $last_name, 'LIKE');
+    if ($last_name && $last_name !== '%') {
+      $query->condition('o.billing_last_name', $last_name, 'LIKE');
     }
-    if ($email !== '0' && $email !== '%') {
+    if ($email && $email !== '%') {
       $query->condition(db_or()
-        ->condition($o_email, $email, 'LIKE')
-        ->condition($u_mail, $email, 'LIKE')
+        ->condition('o.primary_email', $email, 'LIKE')
+        ->condition('u.mail', $email, 'LIKE')
       );
     }
 
@@ -903,7 +893,7 @@ function uc_order_select_customer($email
 
   // Check to see if the e-mail address for a new user is unique.
   if (arg(5) == 'check') {
-    $email = check_plain(arg(6));
+    $email = check_plain($_POST['email']);
     $build['email'] = array('#markup' => '');
     if (!valid_email_address($email)) {
       $build['email']['#markup'] .= t('Invalid e-mail address.') . '<br />';
@@ -912,7 +902,7 @@ function uc_order_select_customer($email
     if ($user = $result->fetchObject()) {
       $build['email']['#markup'] .= t('An account already exists for that e-mail.') . '<br /><br />';
       $build['email']['#markup'] .= '<b>' . t('Use this account now?') . '</b><br />'
-        . t('User !uid - !mail', array('!uid' => $user->uid, '!mail' => $user->mail)) . ' <input type="button" '
+        . t('User @uid - @mail', array('@uid' => $user->uid, '@mail' => $user->mail)) . ' <input type="button" '
         . 'onclick="select_existing_customer(' . $user->uid . ', \''
         . $user->mail . '\');" value="' . t('Apply') . '" /><br /><br /><hr /><br/>';
     }
Index: uc_order/uc_order.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/ubercart/uc_order/uc_order.js,v
retrieving revision 1.14
diff -u -p -r1.14 uc_order.js
--- uc_order/uc_order.js	2 Nov 2010 20:51:05 -0000	1.14
+++ uc_order/uc_order.js	8 Feb 2011 15:42:19 -0000
@@ -181,22 +181,12 @@ function load_customer_search() {
  * Display the results of the customer search.
  */
 function load_customer_search_results() {
-  var first_name = jQuery('#customer-select #edit-first-name').val();
-  var last_name = jQuery('#customer-select #edit-last-name').val();
-  var email = jQuery('#customer-select #edit-email').val();
-
-  if (first_name == '') {
-    first_name = '0';
-  }
-  if (last_name == '') {
-    last_name = '0';
-  }
-  if (email == '') {
-    email = '0';
-  }
-
-  jQuery.post(Drupal.settings.ucURL.adminOrders + 'customer/search/' + encodeURIComponent(first_name) + '/' + encodeURIComponent(last_name) + '/' + encodeURIComponent(email),
-    { },
+  jQuery.post(Drupal.settings.ucURL.adminOrders + 'customer/search',
+    {
+      first_name: jQuery('#customer-select #edit-first-name').val(),
+      last_name: jQuery('#customer-select #edit-last-name').val(),
+      email: jQuery('#customer-select #edit-email').val()
+    },
     function (contents) {
       jQuery('#customer-select').empty().append(contents);
     }
@@ -209,16 +199,8 @@ function load_customer_search_results() 
  */
 function select_customer_search() {
   var data = jQuery('#edit-cust-select').val();
-  jQuery('#edit-uid').val(data.substr(0, data.indexOf(':')));
-  jQuery('#edit-uid-text').val(data.substr(0, data.indexOf(':')));
-  jQuery('#edit-primary-email').val(data.substr(data.indexOf(':') + 1));
-  jQuery('#edit-primary-email-text').val(data.substr(data.indexOf(':') + 1));
-  try {
-    jQuery('#edit-submit-changes').get(0).click();
-  }
-  catch (err) {
-  }
-  return close_customer_select();
+  var i = data.indexOf(':');
+  return select_existing_customer(data.substr(0, i), data.substr(i + 1));
 }
 
 /**
@@ -246,7 +228,7 @@ function check_new_customer_address() {
     'email' : jQuery('#customer-select #edit-email').val(),
     'sendmail' : jQuery('#customer-select #edit-sendmail').attr('checked')
   };
-  jQuery.post(Drupal.settings.ucURL.adminOrders + 'customer/new/check/' + encodeURIComponent(options['email']), options,
+  jQuery.post(Drupal.settings.ucURL.adminOrders + 'customer/new/check', options,
     function (contents) {
       jQuery('#customer-select').empty().append(contents);
     }
@@ -258,10 +240,8 @@ function check_new_customer_address() {
  * Load existing customer as new order's customer.
  */
 function select_existing_customer(uid, email) {
-  jQuery('#edit-uid').val(uid);
-  jQuery('#edit-uid-text').val(uid);
-  jQuery('#edit-primary-email').val(email);
-  jQuery('#edit-primary-email-text').val(email);
+  jQuery('input[name=uid], #edit-uid-text').val(uid);
+  jQuery('input[name=primary_email], #edit-primary-email-text').val(email);
   try {
     jQuery('#edit-submit-changes').click();
   }
