Exemplo n.º 1
0
 public static function e3200_editsequence($requestID, $user, $action, $ID, $extra, &$err, $xml, $errnum, $errmsg, $config)
 {
     switch ($action) {
         case QUICKBOOKS_MOD_CUSTOMER:
             // EditSequence for this customer is out-of-date, query for the customer to get the latest EditSequence, and re-send
             return QuickBooks_Server_Integrator_Callbacks::integrateQueryCustomer($ID);
         default:
             return false;
     }
 }
Exemplo n.º 2
0
 /**
  * 
  * 
  * @param string $method
  * @param string $action
  * @param mixed $ID
  * @param string $err
  * @param string $qbxml
  * @param QuickBooks_Iterator $Iterator
  * @param resource $qbres
  * @return boolean
  */
 public static function getCustomerByName($method, $action, $ID, $err, $qbxml, $Iterator, $qbres)
 {
     $API = QuickBooks_API_Singleton::getInstance();
     $Integrator = QuickBooks_Integrator_Singleton::getInstance();
     if ($Iterator->count() == 1) {
         // If we found the customer in QuickBooks, create a mapping with the ListID value
         $Customer = $Iterator->next();
         if ($API->createMapping(QUICKBOOKS_OBJECT_CUSTOMER, $ID, $Customer->getListID(), $Customer->getEditSequence())) {
             // Let's make sure that this customer is up-to-date
             return QuickBooks_Server_Integrator_Callbacks::integrateModCustomer($ID);
         }
     } else {
         if ($Iterator->count() == 0) {
             // Otherwise, we need to queue up an add request to add this cart item to QuickBooks
             return QuickBooks_Server_Integrator_Callbacks::integrateAddCustomer($ID);
         }
     }
     return false;
 }
Exemplo n.º 3
0
 protected function _integrateNewOrders($orders)
 {
     // Let's start with new orders
     foreach ($orders as $OrderID) {
         $this->_api->log('Analyzing order #' . $OrderID, QUICKBOOKS_LOG_VERBOSE);
         $Order = $this->_integrator->getOrder($OrderID);
         $this->_integrateOrder($Order, $OrderID);
         $Payment = $this->_integrator->getPayment($OrderID);
         if ($Payment and $Payment->getTotalAmount() > 0) {
             $this->_integratePayment($Payment, $OrderID);
         }
         // Customer
         $CustomerID = $Order->getCustomerApplicationID();
         if ($ListID = $Order->getCustomerListID()) {
             // xxx Do nothing, already in QuickBooks
             // Add it again, just in case!
             QuickBooks_Server_Integrator_Callbacks::integrateAddCustomer($CustomerID);
             //$extras = $this->_integrator->getCustomerExtras($CustomerID, __FILE__, __LINE__);
             //$Customer = $this->_integrator->getCustomer($CustomerID, __FILE__, __LINE__);
             //$this->_integrateCustomer($Customer, $CustomerID, $extras);
             //$this->_api->getCustomerByName($this->_integrator->getCustomerNameForQuery($CustomerID), 'QuickBooks_Server_Integrator_Callbacks::getCustomerByName', $CustomerID);
         } else {
             if ($this->_integrator_config['lookup_customers']) {
                 // Try to fetch the customer by name
                 $this->_api->getCustomerByName($this->_integrator->getCustomerNameForQuery($CustomerID), 'QuickBooks_Server_Integrator_Callbacks::getCustomerByName', $CustomerID);
                 // TEMP TEMP TEMP
                 //QuickBooks_Server_Integrator_Callbacks::integrateAddCustomer($CustomerID);
                 //QuickBooks_Server_Integrator_Callbacks::integrateModCustomer($CustomerID);
                 //$extras = $this->_integrator->getCustomerExtras($CustomerID, __FILE__, __LINE__);
                 //$Customer = $this->_integrator->getCustomer($CustomerID, __FILE__, __LINE__);
                 //$this->_integrateCustomer($Customer, $CustomerID, $extras);
             } else {
                 // Add the customer to QuickBooks
                 QuickBooks_Server_Integrator_Callbacks::integrateAddCustomer($CustomerID);
                 //$extras = $this->_integrator->getCustomerExtras($CustomerID, __FILE__, __LINE__);
                 //$Customer = $this->_integrator->getCustomer($CustomerID, __FILE__, __LINE__);
                 //$this->_integrateCustomer($Customer, $CustomerID, $extras);
             }
         }
         // ShipMethod
         $ShipMethodID = $Order->getShipMethodApplicationID();
         if (is_numeric($ShipMethodID) and (int) $ShipMethodID or !is_numeric($ShipMethodID) and strlen($ShipMethodID)) {
             if ($ListID = $Order->getShipMethodListID()) {
                 // xxx Do nothing, already in QuickBooks
                 // Add it again anyway, just in case!
                 $ShipMethod = $this->_integrator->getShipMethod($ShipMethodID);
                 $this->_integrateShipMethod($ShipMethod, $ShipMethodID);
             } else {
                 if ($this->_integrator_config['lookup_shipmethods'] and $ShipMethodID) {
                     // Try to fetch the shipping method by name
                     $this->_api->getShipMethodByName($this->_integrator->getShipMethodNameForQuery($ShipMethodID), 'QuickBooks_Server_Integrator_Callbacks::getShipMethodByName', $ShipMethodID);
                 } else {
                     if ($ShipMethodID) {
                         $ShipMethod = $this->_integrator->getShipMethod($ShipMethodID);
                         $this->_integrateShipMethod($ShipMethod, $ShipMethodID);
                     }
                 }
             }
         }
         // Account
         switch ($Order->object()) {
             case QUICKBOOKS_OBJECT_INVOICE:
                 $AccountID = $Order->getARAccountApplicationID();
                 if ($AccountID) {
                     if ($ListID = $Order->getARAccountListID()) {
                         // XXX Do nothing, already in QuickBooks
                         // Add it again anyway, just in case
                         $Account = $this->_integrator->getAccount($AccountID);
                         $this->_integrateAccount($Account, $AccountID);
                     } else {
                         if ($this->_integrator_config['lookup_accounts'] and $AccountID) {
                         } else {
                             if ($AccountID) {
                                 $Account = $this->_integrator->getAccount($AccountID);
                                 $this->_integrateAccount($Account, $AccountID);
                             }
                         }
                     }
                 }
                 break;
             case QUICKBOOKS_OBJECT_SALESRECEIPT:
                 break;
         }
         $list = $this->_integrator->getOrderItems($OrderID);
         foreach ($list as $OrderItem) {
             //print_r($OrderItem);
             //print("\n");
             //exit;
             $ProductID = $OrderItem->getItemApplicationID();
             if (!$ProductID) {
                 continue;
             }
             //print('product id is: ' . $ProductID . "\n");
             ///
             //header('Content-Type: text/plain');
             //$Product = $this->_integrator->getProduct($ProductID, __FILE__, __LINE__);
             //$this->_integrateProduct($Product, $ProductID);
             //print_r($Product);
             //exit;
             ///
             if ($ListID = $OrderItem->getItemListID()) {
                 //print('push');
                 // XXX Do nothing, already in QuickBooks
                 // Add it again anyway, just in case
                 $Product = $this->_integrator->getProduct($ProductID, __FILE__, __LINE__);
                 $this->_integrateProduct($Product, $ProductID);
             } else {
                 if ($this->_integrator_config['lookup_products']) {
                     // Queue a request *for each type* of item
                     // These next two lines are just for testing
                     //$Product = $this->_integrator->getProduct($ProductID, __FILE__, __LINE__);
                     //$this->_integrateProduct($Product, $ProductID);
                     // Try to fetch the product from QuickBooks
                     $this->_api->getItemByName($this->_integrator->getProductNameForQuery($ProductID), 'QuickBooks_Server_Integrator_Callbacks::getProductByName', $ProductID);
                 } else {
                     //print('else');
                     $Product = $this->_integrator->getProduct($ProductID, __FILE__, __LINE__);
                     $this->_integrateProduct($Product, $ProductID);
                 }
             }
             //print('here');
         }
     }
 }