Exemplo n.º 1
0
 public static function listEstimatesModifiedAfter($method, $action, $ID, $err, $qbxml, $Iterator, $qbres)
 {
     $API = QuickBooks_API_Singleton::getInstance();
     $Integrator = QuickBooks_Integrator_Singleton::getInstance();
     while ($Estimate = $Iterator->next()) {
         // Let's check if this estimate already exists in the system
         $EstimateID = null;
         if ($API->hasApplicationID(QUICKBOOKS_OBJECT_ESTIMATE, $Estimate->getTxnID())) {
             $EstimateID = $API->fetchApplicationID(QUICKBOOKS_OBJECT_ESTIMATE, $Estimate->getTxnID());
         }
         // Now, there's a customer assigned to this estimate, let's make sure the customer exists
         if ($API->hasApplicationID(QUICKBOOKS_OBJECT_CUSTOMER, $Estimate->getCustomerListID())) {
             // Great, it exists!
         } else {
             // Uh oh... create it!
             $Customer = new QuickBooks_Object_Customer();
             $Customer->setListID($Estimate->getCustomerListID());
             $Customer->setName($Estimate->getCustomerName());
             $Integrator->setCustomer(null, $Customer);
         }
         // There are line items assigned to this estimate too, and each line item has a product...
         //foreach ($Estimate->listLineItems
         $Integrator->setEstimate($EstimateID, $Estimate);
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * 
  * 
  * 
  */
 public function __construct($dsn_or_conn, $integrator_dsn_or_conn, $email, $user, $map = array(), $onerror = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_BUILTIN, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array(), $api_options = array(), $source_options = array(), $integrator_options = array(), $callback_options = array())
 {
     $integrator_onerror = array('3100' => 'QuickBooks_Server_Integrator_Errors::e3100_alreadyexists', '3170' => 'QuickBooks_Server_Integrator_Errors::e3170_errorsaving', '3180' => 'QuickBooks_Server_Integrator_Errors::e3180_errorsaving', '3200' => 'QuickBooks_Server_Integrator_Errors::e3200_editsequence', '*' => 'QuickBooks_Server_Integrator_Errors::e_catchall');
     // Merge integration options over default options
     //	(allow overrides, they'll need to handle errors manually...)
     $integrator_onerror = $this->_merge($integrator_onerror, $onerror, false);
     // Merge hooks in
     $integrator_hooks = array();
     $integrator_hooks = $this->_merge($integrator_hooks, $hooks, false);
     // Callback options
     $integrator_callback_options = array('_error_email' => $email, '_error_subject' => 'QuickBooks Error on ' . $_SERVER['HTTP_HOST'], '_error_from' => 'quickbooks@' . implode('.', array_slice(explode('.', $_SERVER['HTTP_HOST']), -2)));
     //print_r($integrator_callback_options);
     //exit;
     // Merge callback options
     $integrator_callback_options = $this->_merge($integrator_callback_options, $callback_options, false);
     // QuickBooks_Server_API::__construct( ... )
     parent::__construct($dsn_or_conn, $user, $map, $integrator_onerror, $integrator_hooks, $log_level, $soap, $wsdl, $soap_options, $handler_options, $driver_options, $api_options, $source_options, $callback_options);
     //header('Content-Type: text/plain');
     //print_r($this);
     //exit;
     $source_type = QUICKBOOKS_API_SOURCE_WEB;
     $source_dsn = null;
     // Set up the API
     // $api_driver_dsn, $user, $source_type, $source_dsn, $api_options = array(), $source_options = array(), $driver_options = array(), $callback_options = array()
     $API = QuickBooks_API_Singleton::getInstance($dsn_or_conn, $user, $source_type, $source_dsn, $api_options, $source_options, $driver_options, $callback_options);
     $this->_api = $API;
     // new QuickBooks_API($dsn_or_conn, $user, $source_type, $source_dsn, $api_options, $source_options, $driver_options, $callback_options);
     // Set up the integrator
     $this->_integrator = $this->_integratorFactory($integrator_dsn_or_conn, $integrator_options, $API);
     // Initialize the Integrator singleton
     $tmp = QuickBooks_Integrator_Singleton::getInstance($this->_integrator);
     // Integrator options (shared between the server component and actual integrator)
     $this->_integrator_config = $this->_integratorDefaults($integrator_options);
 }