Index: README.txt
=========================================================
--- README.txt	(revision 1.1.2.1)
+++ README.txt	Working Copy
@@ -3,7 +3,7 @@
 ********************************************************************
 Name: Quickbooks Ubercart Integration
 Author: Sarva Bryant <sarva at aliandesign dot com>
-Drupal: 5.0.x
+Drupal: 6.x
 ********************************************************************
 DESCRIPTION:
 
Index: uc_qb.info
=========================================================
--- uc_qb.info	(revision 1.1.2.1)
+++ uc_qb.info	Working Copy
@@ -1,4 +1,6 @@
 name = QuickBooks Ubercart Integration
 description = Uses QuickBooks Web Connector to send and receive Ubercart data to/from QuickBooks
-dependencies = qbwc uc_store
-core = ubercart
+dependencies[] = qbwc
+dependencies[] = uc_store
+core = 6.x
+php = 5
Index: uc_qb.module
=========================================================
--- uc_qb.module	(revision 1.1.2.1)
+++ uc_qb.module	Working Copy
@@ -6,35 +6,31 @@
  *
  * 1. Advanced/separated error system (using QBWC interactive error handling)
  * 2. Import product data from QuickBooks
- * 3. **Important** Update customer email addresses in QuickBooks when the user changes them 
+ * 3. **Important** Update customer email addresses in QuickBooks when the user changes them
  */
 
 /**
  *  Implementation of hook_menu()
  */
-function uc_qb_menu($may_cache = false) {
+function uc_qb_menu() {
   $items = array();
 
-  if ($may_cache) {
-  	$items[] = array(
-      'path' => 'admin/store/settings/qb',
-      'title' => t('QB import/export'),
-      'description' => t('Import/Export store data to QuickBooks using Web Connector'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('uc_qb_settings'),
-      'access' => user_access('administer quickbooks import/export'),
+  $items['admin/store/settings/qb'] = array(
+    'title' => 'QB import/export',
+    'description' => 'Import/Export store data to QuickBooks using Web Connector',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('uc_qb_settings'),
+    'access arguments' => array('administer quickbooks import/export'),
-      'type' => MENU_NORMAL_ITEM,
-    );
-    // TODO: Write help page that also can display the latest errors
+    'type' => MENU_NORMAL_ITEM,
+  );
+  // TODO: Write help page that also can display the latest errors
-    $items[] = array(
-      'path' => 'admin/store/settings/qb/help',
-      'title' => t('QuickBooks Import/Export Help'),
-      'description' => t('Detailed information for importing and exporting to QuickBooks using the Web Connector.'),
-      'callback' => 'uc_qb_admin_help',
-      'access' => user_access('administer quickbooks import/export'),
+  $items['admin/store/settings/qb/help'] = array(
+    'title' => 'QuickBooks Import/Export Help',
+    'description' => 'Detailed information for importing and exporting to QuickBooks using the Web Connector.',
+    'page callback' => 'uc_qb_admin_help',
+    'access arguments' => array('administer quickbooks import/export'),
-      'type' => MENU_CALLBACK,
-    );
+    'type' => MENU_CALLBACK,
+  );
-  }
 
   return $items;
 }
@@ -43,7 +39,7 @@
  * Menu callback for settings related to QB import
  */
 function uc_qb_settings() {
-	$form = array();
+  $form = array();
 
   $form['uc_qb_start_order'] = array(
     '#type' => 'textfield',
@@ -72,7 +68,7 @@
  * Implementation of hook_qbwc_authenticate()
  */
 function uc_qb_qbwc_authenticate($ticket, $user) {
-	  // Make sure this is defined and set to an array to avoid errors
+    // Make sure this is defined and set to an array to avoid errors
   if (!is_array($_SESSION['qb_orders'])) {
     $_SESSION['qb_orders'] = array();
   }
@@ -83,8 +79,9 @@
 
   // Get a list of orders needing exported
   $result = db_query('SELECT DISTINCT(uop.order_id), uc.uid, uc.modified, uc.order_total, uc.primary_email, uc.order_status, uc.data as order_data, u.name, u.data as user_data FROM {uc_orders} uc INNER JOIN {users} u ON uc.uid = u.uid LEFT JOIN {uc_order_products} uop ON uc.order_id = uop.order_id WHERE uc.modified > "%d" AND order_status IN ("completed", "payment_received") AND uop.nid IS NOT NULL AND uc.order_id >= "%d" ORDER BY uc.modified ASC', $last_export, variable_get('uc_qb_start_order', 0));
+  $count = db_result(db_query('SELECT COUNT(DISTINCT(uop.order_id)) FROM {uc_orders} uc INNER JOIN {users} u ON uc.uid = u.uid LEFT JOIN {uc_order_products} uop ON uc.order_id = uop.order_id WHERE uc.modified > "%d" AND order_status IN ("completed", "payment_received") AND uop.nid IS NOT NULL AND uc.order_id >= "%d"', $last_export, variable_get('uc_qb_start_order', 0)));
 
-  $_SESSION['qb_orders_count'] = db_num_rows($result);
+  $_SESSION['qb_orders_count'] = $count;
   $_SESSION['qb_orders_done'] = 0;
 
   while ($item = db_fetch_object($result)) {
@@ -101,15 +98,15 @@
     $_SESSION['qb_orders'][$item->order_id] = $item;
   }
 
-  // Return true if orders need processing signaling we have work for QB
+  // Return TRUE if orders need processing signaling we have work for QB
   if (!empty($_SESSION['qb_orders'])) {
-  	return true;
+    return TRUE;
   }
 }
 
 /**
  * Implementation of hook_qbwc_response()
- * 
+ *
  * @Description: Receive queries for QB data and set appropriate session variables for use in hook_qbwc_request()
  */
 function uc_qb_qbwc_response($response, $hresult, $message, $saved) {
@@ -121,42 +118,42 @@
     $returnCnt = $element->getAttribute('retCount');
     $statusCode = $element->getAttribute('statusCode');
     $statusMessage = $element->getAttribute('statusMessage');
-    
+
     if ($statusCode > 0) {
-    	watchdog('uc_qb', t('QB responded to a request with error #%code (%message)', array('%code' => $statusCode, '%message' => $statusMessage)), WATCHDOG_ERROR);
+      watchdog('uc_qb', 'QB responded to a request with error #%code (%message)', array('%code' => $statusCode, '%message' => $statusMessage), WATCHDOG_ERROR);
     }
     if ($statusCode == 3231) {
       // This element was not processed, so skip it
-    	continue;
+      continue;
     }
 
     switch($element->tagName) {
       // Check if the checked shipping method is available or not, and if not queries it to be created
       case 'ShipMethodAddRs':
         if (!isset($saved[$requestId])) {
-          $error = true;
+          $error = TRUE;
           break;
         }
 
         if ($statusCode == 0) {
-        	$_SESSION['qb_shipping_methods'][$saved[$requestId]['method']] = true;
+          $_SESSION['qb_shipping_methods'][$saved[$requestId]['method']] = TRUE;
         }
         else {
-        	$error = true;
+          $error = TRUE;
           break;
         }
       break;
-    	case 'ShipMethodQueryRs':
+      case 'ShipMethodQueryRs':
         if (!isset($saved[$requestId])) {
-          $error = true;
+          $error = TRUE;
           break;
         }
 
         if ($returnCnt > 0) {
-        	$_SESSION['qb_shipping_methods'][$saved[$requestId]['method']] = true;
+          $_SESSION['qb_shipping_methods'][$saved[$requestId]['method']] = TRUE;
         }
         else {
-        	$new[] = array(
+          $new[] = array(
             'name' => 'ShipMethodAddRq',
             'request' => array('ShipMethodAdd' => array(
               'Name' => $saved[$requestId]['method'],
@@ -168,27 +165,27 @@
       break;
       case 'ItemServiceAddRs':
         if (!isset($saved[$requestId])) {
-          $error = true;
+          $error = TRUE;
           break;
         }
 
         if ($statusCode == 0) {
-        	$_SESSION['qb_services'][$saved[$requestId]] = true;
+          $_SESSION['qb_services'][$saved[$requestId]] = TRUE;
         }
         else {
-        	$error = true;
+          $error = TRUE;
           break;
         }
       break;
       // Check if the SHIPPING service is available and create if necessary
       case 'ItemServiceQueryRs':
         if (!isset($saved[$requestId])) {
-          $error = true;
+          $error = TRUE;
           break;
         }
 
         if ($returnCnt > 0) {
-          $_SESSION['qb_services'][$saved[$requestId]] = true;
+          $_SESSION['qb_services'][$saved[$requestId]] = TRUE;
         }
         else {
           $new[] = array(
@@ -209,28 +206,28 @@
       break;
       case 'PaymentMethodAddRs':
         if (!isset($saved[$requestId])) {
-          $error = true;
+          $error = TRUE;
           break;
         }
 
         // Check if the checked payment method is available or not, and if not queries it to be created
         if ($statusCode == 0) {
-          $_SESSION['qb_payment_methods'][$saved[$requestId]] = true;
+          $_SESSION['qb_payment_methods'][$saved[$requestId]] = TRUE;
         }
         else {
-          $error = true;
+          $error = TRUE;
           break;
         }
       break;
       case 'PaymentMethodQueryRs':
         if (!isset($saved[$requestId])) {
-          $error = true;
+          $error = TRUE;
           break;
         }
 
       // Check if the checked payment method is available or not, and if not queries it to be created
         if ($returnCnt > 0) {
-          $_SESSION['qb_payment_methods'][$saved[$requestId]] = true;
+          $_SESSION['qb_payment_methods'][$saved[$requestId]] = TRUE;
         }
         else {
           $new[] = array(
@@ -246,12 +243,12 @@
       // Check if the checked tax name is available or not, and if not queries it to be created
       case 'ItemSalesTaxQueryRs':
         if (!isset($saved[$requestId])) {
-          $error = true;
+          $error = TRUE;
           break;
         }
 
         if ($returnCnt > 0) {
-          $_SESSION['qb_tax_types'][$saved[$requestId]->type] = true;
+          $_SESSION['qb_tax_types'][$saved[$requestId]->type] = TRUE;
         }
         else {
           $new[] = array(
@@ -267,12 +264,12 @@
       case 'CustomerQueryRs':
       case 'CustomerAddRs':
         if (!isset($saved[$requestId])) {
-          $error = true;
+          $error = TRUE;
           break;
         }
 
         $data = &$_SESSION['qb_orders'][$saved[$requestId]->order_id];
-        $data->qb_user_id_pending = false;
+        $data->qb_user_id_pending = FALSE;
         if ($statusCode == 0 && $user_id = $element->getElementsByTagName('ListID')->item(0)->nodeValue) {
           $data->qb_user_id = $user_id;
           if ($data->uid) {
@@ -286,7 +283,7 @@
         }
         // If this is an anonymous user and already exists, get the ListID for it, any other situation should not happen and is an error
         else if ($data->uid == 0 && $statusCode == 3100) {
-        	$new[] = array(
+          $new[] = array(
               'name' => 'CustomerQueryRq',
               'request' => array(
                 'FullName' => $data->primary_email,
@@ -297,14 +294,14 @@
         }
         else {
           // This should never happen. If it does, make a log entry for this order saying that it failed to get exported
-          watchdog('uc_qb', t('Order #%order_id (and possibly others from this user) failed to get exported to QB because the user failed to get exported with status code #%code (%message).', array('%code' => $statusCode, '%order_id' => $data->order_id, '%message' => $statusMessage)), WATCHDOG_ERROR);
+          watchdog('uc_qb', 'Order #%order_id (and possibly others from this user) failed to get exported to QB because the user failed to get exported with status code #%code (%message).', array('%code' => $statusCode, '%order_id' => $data->order_id, '%message' => $statusMessage), WATCHDOG_ERROR);
         }
       break;
       // Response to adding a receipt
       case 'SalesReceiptAddRs':
-        $error = true;
+        $error = TRUE;
         $data = &$_SESSION['qb_orders'][$saved[$requestId]->order_id];
-        $data->order_data['QBProcessed'] =  true;
+        $data->order_data['QBProcessed'] =  TRUE;
         $total = $element->getElementsByTagName('TotalAmount')->item(0)->nodeValue;
         if ($statusCode == 0 && round($total, 2) == round($data->order_total, 2)) {
           db_query('UPDATE {uc_orders} SET data = "%s" WHERE order_id = "%d"', serialize($data->order_data), $data->order_id);
@@ -314,7 +311,7 @@
         // The amount recorded in QB does not match the right amount for some reason
         else if ($statusCode == 0) {
           $_SESSION['qb_failed_orders'][] = $saved[$requestId];
-          watchdog('uc_qb', t('Order #%order exported successfully, but the sales receipt total did not match the correct total', array('%order' => $saved[$requestId]->order_id, '%code' => $statusCode, '%message' => $statusMessage)), WATCHDOG_ERROR);
+          watchdog('uc_qb', 'Order #%order exported successfully, but the sales receipt total did not match the correct total', array('%order' => $saved[$requestId]->order_id, '%code' => $statusCode, '%message' => $statusMessage), WATCHDOG_ERROR);
 
           // Make the receipt pending so that it does not get processed fully before somebody takes a look at it
           $new[] = array(
@@ -328,18 +325,18 @@
           );
         }
         else {
-        	$_SESSION['qb_failed_orders'][] = $saved[$requestId];
+          $_SESSION['qb_failed_orders'][] = $saved[$requestId];
           $_SESSION['qb_orders_count']--;
-          watchdog('uc_qb', t('Failed to export the order #%order with error code %code (%message) to QB', array('%order' => $saved[$requestId]->order_id, '%code' => $statusCode, '%message' => $statusMessage)), WATCHDOG_ERROR);
+          watchdog('uc_qb', 'Failed to export the order #%order with error code %code (%message) to QB', array('%order' => $saved[$requestId]->order_id, '%code' => $statusCode, '%message' => $statusMessage), WATCHDOG_ERROR);
         }
       break;
       case 'SalesReceiptModRs':
         //Successfully changed the receipt to pending. Mark this as done.
         if ($statusCode == 0) {
-        	$_SESSION['qb_orders_count']--;
+          $_SESSION['qb_orders_count']--;
         }
         else {
-          watchdog('uc_qb', t('Failed to change the ', array('%order' => $saved[$requestId]->order_id, '%code' => $statusCode, '%message' => $statusMessage)), WATCHDOG_ERROR);        	
+          watchdog('uc_qb', 'Failed to change the ', array('%order' => $saved[$requestId]->order_id, '%code' => $statusCode, '%message' => $statusMessage), WATCHDOG_ERROR);
         }
       break;
       // Response to a product search query
@@ -363,7 +360,7 @@
         }
         // Create the product if it was not there
         else {
-        	$new[] = array(
+          $new[] = array(
             'name' => 'ItemInventoryAddRq',
             'request' => array(
               'ItemInventoryAdd' => array(
@@ -410,8 +407,8 @@
           }
         }
         else {
-        	// Failed to add the product
+          // Failed to add the product
-          watchdog('uc_qb', t('Failed to export the product %product in order #%order with error code %code (%message) to QB', array('%product' => $saved[$requestId]->title, '%order' => $saved[$requestId]->order_id, '%code' => $statusCode, '%message' => $statusMessage)), WATCHDOG_ERROR);
+          watchdog('uc_qb', 'Failed to export the product %product in order #%order with error code %code (%message) to QB', array('%product' => $saved[$requestId]->title, '%order' => $saved[$requestId]->order_id, '%code' => $statusCode, '%message' => $statusMessage), WATCHDOG_ERROR);
         }
       break;
       case 'ItemInventoryModRs':
@@ -433,12 +430,12 @@
         }
         else {
           // Failed to add the product
-          watchdog('uc_qb', t('Failed to change the product price of %product in order #%order with error code %code (%message) to QB', array('%product' => $saved[$requestId]->title, '%order' => $saved[$requestId]->order_id, '%code' => $statusCode, '%message' => $statusMessage)), WATCHDOG_ERROR);
+          watchdog('uc_qb', 'Failed to change the product price of %product in order #%order with error code %code (%message) to QB', array('%product' => $saved[$requestId]->title, '%order' => $saved[$requestId]->order_id, '%code' => $statusCode, '%message' => $statusMessage), WATCHDOG_ERROR);
         }
       break;
       case 'AccountQueryRs':
         if (!isset($saved[$requestId])) {
-          $error = true;
+          $error = TRUE;
           break;
         }
 
@@ -455,7 +452,7 @@
       break;
       case 'AccountAddRs':
         if ($statusCode != 0) {
-          $error = true;
+          $error = TRUE;
           break;
         }
       break;
@@ -464,54 +461,54 @@
         $taxes = $element->getElementsByTagName('SalesTaxPreferences');
         $inventory = $element->getElementsByTagName('IsUsingInventory');
         if ($taxes->length == 0) {
-        	// Taxes are not turned on. Will fail
+          // Taxes are not turned on. Will fail
-          watchdog('uc_qb', t('Failed to start QB export as taxes are not turned on in the company preferences.'), WATCHDOG_ERROR);
-          $error = true;
+          watchdog('uc_qb', 'Failed to start QB export as taxes are not turned on in the company preferences.', array(), WATCHDOG_ERROR);
+          $error = TRUE;
           break;
         }
         if (!($inventory = $inventory->item(0)) || $inventory->nodeValue == 'false') {
-        	// Taxes are not turned on. Will fail
+          // Taxes are not turned on. Will fail
-          watchdog('uc_qb', t('Failed to start QB export as inventory is not turned on in the company preferences.'), WATCHDOG_ERROR);
-          $error = true;
+          watchdog('uc_qb', 'Failed to start QB export as inventory is not turned on in the company preferences.', array(), WATCHDOG_ERROR);
+          $error = TRUE;
           break;
         }
       break;
     }
   }
-  
+
   // Stop processing on errors
   if ($error) {
     return -1;
   }
 
   if (!empty($new)) {
-  	$_SESSION['qb_pending_requests'][] = $new;
+    $_SESSION['qb_pending_requests'][] = $new;
   }
-  
+
   if ($_SESSION['qb_orders_count'] == 0) {
-  	return 100;
+    return 100;
   }
 
-	return ($done / $_SESSION['qb_orders_count']) * 100;
+  return ($done / $_SESSION['qb_orders_count']) * 100;
 }
 
 /**
  * Implementation of hook_qbwc_request()
- * 
+ *
  * @Description: Send requests for data from quickbooks (existing customers/orders)
  *    or requests for additions into Quickbooks
  */
 function uc_qb_qbwc_request() {
   // Check if we have any pending requests to make as a response to QB returned data
   if (!empty($_SESSION['qb_pending_requests'])) {
-  	return array_shift($_SESSION['qb_pending_requests']);
+    return array_shift($_SESSION['qb_pending_requests']);
   }
 
   // Get a list of orders needing exported
   if (!isset($_SESSION['qb_started_processing'])) {
-    $_SESSION['qb_started_processing'] = true;
+    $_SESSION['qb_started_processing'] = TRUE;
     $checked_users = $products  = array();
-    
+
     // Checks for accounts/settings to exist that need to happen on first connect
     if (count($_SESSION['qb_orders'])) {
       // Check that certain required service accounts exist
@@ -539,7 +536,7 @@
     $products = &$_SESSION['QBProducts'];
     foreach($_SESSION['qb_orders'] as &$copy) {
       // Check that all of the products exist in QB and if not create them
-    	$product_result = db_query('SELECT uop.nid, uop.title, uop.model, uop.order_id, up.sell_price FROM {uc_order_products} uop INNER JOIN {uc_products} up ON uop.nid = up.nid WHERE uop.order_id = "%d"', $copy->order_id);
+      $product_result = db_query('SELECT uop.nid, uop.title, uop.model, uop.order_id, up.sell_price FROM {uc_order_products} uop INNER JOIN {uc_products} up ON uop.nid = up.nid WHERE uop.order_id = "%d"', $copy->order_id);
       while ($product = db_fetch_object($product_result)) {
         if (!array_key_exists($product->model, $products)) {
           $product->order_id = array($product->order_id);
@@ -555,7 +552,7 @@
           $products[$product->model] = $product;
         }
         else {
-        	$products[$product->model]->order_id[] = $product->order_id;
+          $products[$product->model]->order_id[] = $product->order_id;
         }
       }
 
@@ -568,7 +565,7 @@
           $copy->qb_user_id = $copy->order_data['QBListID'];
         }
         else if (!$copy->primary_email) {
-        	watchdog('uc_qb', t('Order #%order could not be exported to QB because anonymous user did not provide an email address.', array('%order' => $copy->order_id)), WATCHDOG_ERROR);
+          watchdog('uc_qb', 'Order #%order could not be exported to QB because anonymous user did not provide an email address.', array('%order' => $copy->order_id), WATCHDOG_ERROR);
         }
         else {
           $check[] = array(
@@ -577,27 +574,27 @@
               'Name' => $copy->uid ? $copy->name : $copy->primary_email,
               'IsActive' => 'true',
               'Email' => $copy->primary_email,
-              'Notes' => $copy->uid ? url('user/'. $copy->uid, null, null, true) : ' '
+              'Notes' => $copy->uid ? url('user/'. $copy->uid, array('absolute' => TRUE)) : ' '
             )),
             'data' => $copy
           );
-          $copy->qb_user_id_pending = true;
+          $copy->qb_user_id_pending = TRUE;
         }
 
-        $checked_users[$copy->uid ? $copy->uid : $copy->primary_email] = true;
+        $checked_users[$copy->uid ? $copy->uid : $copy->primary_email] = TRUE;
       }
     }
   }
   else if (empty($_SESSION['qb_orders'])) {
-  	return;
+    return;
   }
 
   $requests = array();
-  $first = true;
+  $first = TRUE;
   foreach($_SESSION['qb_orders'] as &$item) {
     if ($item->order_data['QBProcessed']) {
       // This order was already processed
-    	continue;
+      continue;
     }
 
     $receipt = array();
@@ -605,7 +602,7 @@
     $order = uc_order_load($item->order_id);
 
     // Is there a better way to get at the customer message?
-    $message = db_result(db_query('SELECT message FROM {uc_order_comments} WHERE order_id = "%d" AND order_status = "pending" AND message != "-" LIMIT 1', $order->order_id));
+    $message = db_result(db_query_range('SELECT message FROM {uc_order_comments} WHERE order_id = "%d" AND order_status = "pending" AND message <> "-"', $order->order_id, 0, 1));
     $billing_country = uc_get_country_data(array('country_id' => $order->billing_country));
     $shipping_country = uc_get_country_data(array('country_id' => $order->delivery_country));
 
@@ -632,7 +629,7 @@
         'data' => $order->payment_method
       );
     }
-    
+
     // Make various checks on line items
     foreach((array)$order->line_items as $line) {
       $line = (object)$line;
@@ -641,7 +638,7 @@
       }
 
       if (!array_key_exists($line->type, (array)$_SESSION['qb_services'])) {
-      	$check[] = array(
+        $check[] = array(
           'name' => 'ItemServiceQueryRq',
           'request' => array(
             'FullName' => $line->type,
@@ -653,17 +650,17 @@
     }
 
     if (!$item->qb_user_id_pending && !$item->qb_user_id) {
-    	// This should never happen. If it does, make a log entry for this order saying that it failed to get exported
+      // This should never happen. If it does, make a log entry for this order saying that it failed to get exported
-      $item->order_data['QBProcessed'] = true;
+      $item->order_data['QBProcessed'] = TRUE;
       $_SESSION['qb_orders_count']--;
       $_SESSION['qb_failed_orders'][] = $item;
-      watchdog('uc_qb', t('Order #%order_id failed to get exported to QB because the user did not exist in (failed to create properly) inside QB.', array('%order_id' => $item->order_id)), WATCHDOG_ERROR);
+      watchdog('uc_qb', 'Order #%order_id failed to get exported to QB because the user did not exist in (failed to create properly) inside QB.', array('%order_id' => $item->order_id), WATCHDOG_ERROR);
       continue;
     }
 
     // If any check items were marked, send them all at once
     if (!empty($check)) {
-    	return $check;
+      return $check;
     }
 
     // Set the available info to get imported into QB
@@ -700,16 +697,16 @@
     );
     $receipt['IsPending'] = 'false';
     if ($order->payment_method) {
-    	$receipt['PaymentMethodRef']['FullName'] = $order->payment_method;
+      $receipt['PaymentMethodRef']['FullName'] = $order->payment_method;
     }
     if ($order->quote['method']) {
-    	$receipt['ShipMethodRef']['FullName'] = $order->quote['method'];
+      $receipt['ShipMethodRef']['FullName'] = $order->quote['method'];
     }
     $receipt['Memo'] = substr($message, 0, 101);
     $receipt['DepositToAccountRef']['FullName'] = variable_get('uc_qb1_income_account', 'Undeposited Funds');
     //$receipt['Other'] = 'CC:'. $order->payment_details['cc_number'] . ' UserID:'. $order->uid;
 
-    $added_products = false;
+    $added_products = FALSE;
     $total = 0;
     if (is_array($order->products) && count($order->products) > 0) {
       $lineItems = &$receipt['SalesReceiptLineAdd'];
@@ -717,17 +714,17 @@
       foreach ($order->products as $product) {
         if (!$item->order_data['QBProducts'][$product->model]) {
           // The product was not created/set properly in QB
-          $added_products = false;
+          $added_products = FALSE;
           break;
         }
 
         $description = $product->title .' x'. $product->qty;
         if (is_array($product->data['attributes'])) {
           $description .= ', ';
-          $start = true;
+          $start = TRUE;
           foreach ($product->data['attributes'] as $key => $value) {
             if ($start) {
-              $start = false;
+              $start = FALSE;
             }
             else {
               $description .= ', ';
@@ -735,11 +732,11 @@
             $description .= $key .': '. $value;
           }
         }
-        
+
         if ($item->order_data['QBProducts'][$product->model]['price'] != $product->price) {
           // TODO: Change the price in QB of the product if it had been changed for this product
-        	$requests[] = array(
-          
+          $requests[] = array(
+
           );
         }
 
@@ -750,26 +747,26 @@
         $product_line['Rate'] = uc_currency_format($product->price, FALSE, FALSE, '.');
         $product_line['SalesTaxCodeRef']['FullName'] = 'NON';
 
-        $added_products = true;
+        $added_products = TRUE;
         $total += $product->qty * $product->price;
         $lineItems[] = $product_line;
       }
-      
+
       if (!$added_products) {
         // Make sure to keep total orders to be processed up to date
-        $item->order_data['QBProcessed'] = true;
+        $item->order_data['QBProcessed'] = TRUE;
         $_SESSION['qb_orders_count']--;
         $_SESSION['qb_failed_orders'][] = $item;
-      	watchdog('uc_qb', t('Failed to export order #%order because some or all of the purchased products could not be created/found in QB.', array('%order' => $item->order_id)), WATCHDOG_ERROR);
+        watchdog('uc_qb', 'Failed to export order #%order because some or all of the purchased products could not be created/found in QB.', array('%order' => $item->order_id), WATCHDOG_ERROR);
         continue;
       }
     }
     else {
       // Make sure to keep total orders to be processed up to date
-      $item->order_data['QBProcessed'] = true;
+      $item->order_data['QBProcessed'] = TRUE;
       $_SESSION['qb_orders_count']--;
       $_SESSION['qb_failed_orders'][] = $item;
-    	watchdog('uc_qb', t('Failed to export order #%order because no products were purchased.', array('%order' => $item->order_id)), WATCHDOG_ERROR);
+      watchdog('uc_qb', 'Failed to export order #%order because no products were purchased.', array('%order' => $item->order_id), WATCHDOG_ERROR);
       continue;
     }
 
@@ -777,7 +774,7 @@
     foreach((array)$order->line_items as $line) {
       // Only look at calculated line items
       if (_line_item_data($line['type'], 'calculated') != TRUE) {
-      	continue;
+        continue;
       }
       $lineItems = &$receipt['SalesReceiptLineAdd'];
 
@@ -790,20 +787,20 @@
       $total += $line['amount'];
       $lineItems[] = $line_item;
     }
-    
+
     // Add any customer messages as a blank line item
-    if ($message && variable_get('uc_qb_include_messages', true)) {
+    if ($message && variable_get('uc_qb_include_messages', TRUE)) {
       // Add two blank lines in front
       $receipt['SalesReceiptLineAdd'][] = array('Desc' => ' ');
       $receipt['SalesReceiptLineAdd'][] = array('Desc' => ' ');
-    	$receipt['SalesReceiptLineAdd'][] = array(
+      $receipt['SalesReceiptLineAdd'][] = array(
         'Desc' => substr($message, 0, 4000)
       );
     }
 
     // Only add items if we are calculating the total properly
     if (round($total, 2) == round($order->order_total, 2)) {
-    	$requests[] = array(
+      $requests[] = array(
         'name' => 'SalesReceiptAddRq',
         'request' => array(
           'SalesReceiptAdd' => $receipt,
@@ -812,14 +809,14 @@
       );
     }
     else {
-    	$item->order_data['QBProcessed'] = true;
+      $item->order_data['QBProcessed'] = TRUE;
       $_SESSION['qb_orders_count']--;
       $_SESSION['qb_failed_orders'][] = $item;
-      watchdog('uc_qb', t('Failed to export order #%order the calculated total meant for QB did not match the order total.', array('%order' => $item->order_id)), WATCHDOG_ERROR);
+      watchdog('uc_qb', 'Failed to export order #%order the calculated total meant for QB did not match the order total.', array('%order' => $item->order_id), WATCHDOG_ERROR);
       continue;
     }
-    
+
-    $first = false;
+    $first = FALSE;
   }
 
   return $requests;
@@ -827,19 +824,19 @@
 
 /**
  * Implementation of hook qbwc_close()
- * 
+ *
  * Send email alerts on failed orders
  */
 function uc_qb_qbwc_close($ticket) {
-	if (!empty($_SESSION['qb_failed_orders']) && ($mail = variable_get('uc_qb_failed_orders_email', ''))) {
+  if (!empty($_SESSION['qb_failed_orders']) && ($mail = variable_get('uc_qb_failed_orders_email', ''))) {
     foreach($_SESSION['qb_failed_orders'] as $order) {
-    	$orders[] = t('#%order (@link)', array('%order' => $order->order_id, '@link' => url('fleurville/admin/store/orders/'. $order->order_id, null, null, true)));
+      $orders[] = t('#%order (@link)', array('%order' => $order->order_id, '@link' => url('fleurville/admin/store/orders/'. $order->order_id, array('absolute' => TRUE))));
     }
-    
+
     $output = t('There were errors exporting the following orders to QB via Web Connector: ') . "\n\n";
     $output .= implode("\n", $orders) . "\n\n";
-    $output .= t('To find more details about the errors, view the error logs at %url and filter by "uc_qb"', array('%url' => url('admin/logs/watchdog', null, null, true)));
+    $output .= t('To find more details about the errors, view the error logs at %url and filter by "uc_qb"', array('%url' => url('admin/reports/watchdog', array('absolute' => TRUE))));
 
-		drupal_mail('uc_qb_failed_exports', $mail, t('Errors exporting orders to QB'), $output, uc_store_email_from());
-	}
+    drupal_mail('uc_qb_failed_exports', $mail, t('Errors exporting orders to QB'), $output, uc_store_email_from());
+  }
 }
