Пример #1
0
 /**
  * 
  * 
  *
  */
 public function handle($return = false, $debug = false)
 {
     if ($this->_transport_in->ready()) {
         $this->_bridge();
     } else {
         parent::handle($return, $debug);
     }
 }
Пример #2
0
$handler_options = array();
// See the comments in the QuickBooks/Server/Handlers.php file
$driver_options = array();
$callback_options = array();
//$dsn = 'mysql://*****:*****@localhost/efapcom_quickbooks'; //Original Line
$dsn = 'mysql://*****:*****@192.168.129.116/efapcom_quickbooks';
define('QB_QUICKBOOKS_DSN', $dsn);
if (!QuickBooks_Utilities::initialized($dsn)) {
    // Initialize creates the neccessary database schema for queueing up requests and logging
    QuickBooks_Utilities::initialize($dsn);
    // This creates a username and password which is used by the Web Connector to authenticate
    QuickBooks_Utilities::createUser($dsn, $user, $pass);
}
// Create a new server and tell it to handle the requests
// __construct($dsn_or_conn, $map, $errmap = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_PHP, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array(), $callback_options = array()
$Server = new QuickBooks_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
$response = $Server->handle(true, true);
/**
 * Catch and handle a "that string is too long for that field" error (err no. 3070) from QuickBooks
 * 
 * @param string $requestID			
 * @param string $action
 * @param mixed $ID
 * @param mixed $extra
 * @param string $err
 * @param string $xml
 * @param mixed $errnum
 * @param string $errmsg
 * @return void
 */
function _quickbooks_error_stringtoolong($requestID, $user, $action, $ID, $extra, &$err, $xml, $errnum, $errmsg)
Пример #3
0
            }
            mysql_query($sql) or die(trigger_error(mysql_error()));
        }
    } else {
        die('Could not locate "./example.sql" to create the demo SQL schema!');
    }
    // Create the database tables
    QuickBooks_Utilities::initialize($dsn);
    // Add the default authentication username/password
    QuickBooks_Utilities::createUser($dsn, $user, $pass);
}
// Initialize the queue
QuickBooks_Queue_Singleton::initialize($dsn);
// Create a new server and tell it to handle the requests
// __construct($dsn_or_conn, $map, $errmap = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_PHP, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array(), $callback_options = array()
$Server = new QuickBooks_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
$response = $Server->handle(TRUE, TRUE);
// If you wanted, you could do something with $response here for debugging
$fp = fopen('/vservers/horsdoeuvres/htdocs/qbwc/qb_xml.xml', 'a+');
fwrite($fp, $response);
fclose($fp);
/**
 * Login success hook - perform an action when a user logs in via the Web Connector
 *
 * 
 */
function _quickbooks_hook_loginsuccess($requestID, $user, $hook, &$err, $hook_data, $callback_config)
{
    // For new users, we need to set up a few things
    // Fetch the queue instance
    $Queue = QuickBooks_Queue_Singleton::getInstance();
Пример #4
0
 /**
  * 
  * 
  * You can run this server in one of three modes:
  * 	- QUICKBOOKS_SERVER_SQL_MODE_READONLY: Data will only be read from 
  * 		QuickBooks; changes to data in the SQL database will never be 
  * 		pushed back to QuickBooks. 
  * 	- QUICKBOOKS_SERVER_SQL_MODE_WRITEONLY: Data will only be pushed to 
  * 		QuickBooks, and nothing that already exists in QuickBooks will be 
  * 		imported into the SQL database.
  * 	- QUICKBOOKS_SERVER_SQL_MODE_READWRITE: The server will do it's best to 
  * 		try to import all QuickBooks data into the SQL database, and then 
  * 		push changes that occur in either location to the other location. 
  * 		The server will try to syncronise the two locations as much as is 
  * 		possible. 
  * 
  * @param string $dsn_or_conn		DSN-style connection string or an already opened connection to the driver
  * @param string $how_often			The maximum time we wait between updates/syncs (you can use any valid interval: "1 hour", "15 minutes", 60, etc.)
  * @param char $mode				The mode the server should run in (see constants above)
  * @param char $conflicts			The steps towards update conflict resolution the server should take (see constants above)
  * @param mixed $users				The user (or an array of users) who will be using the SQL server
  * @param array $map				
  * @param array $onerror			
  * @param string $wsdl				
  * @param array $soap_options		
  * @param array $handler_options	
  * @param array $driver_options		
  */
 public function __construct($dsn_or_conn, $how_often, $mode, $delete, $conflicts, $users = null, $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(), $sql_options = array(), $callback_options = array())
 {
     // $dsn_or_conn, $map, $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()
     if (!is_array($users)) {
         $users = array($users);
     }
     // Map of callback handlers
     $sql_map = array();
     foreach (get_class_methods('QuickBooks_Server_SQL_Callbacks') as $method) {
         if (strtolower(substr($method, -7)) == 'request') {
             $action = substr($method, 0, -7);
             $sql_map[$action] = array('QuickBooks_Server_SQL_Callbacks::' . $action . 'Request', 'QuickBooks_Server_SQL_Callbacks::' . $action . 'Response');
         }
     }
     // Default error handlers
     $sql_onerror = array('*' => 'QuickBooks_Server_SQL_Errors::catchall');
     $sql_onerror = $this->_merge($sql_onerror, $onerror, false);
     // Default hooks
     $sql_hooks = array(QUICKBOOKS_HANDLERS_HOOK_LOGINSUCCESS => array('QuickBooks_Server_SQL_Callbacks::onAuthenticate'));
     // Merge with user-defined hooks
     $sql_hooks = $this->_merge($hooks, $sql_hooks, true);
     // @TODO Prefix these with _ so that people don't accidentally overwrite them
     $sql_callback_options = array('hooks' => $sql_hooks, 'conflicts' => $conflicts, 'mode' => $mode, 'delete' => $delete, 'recur' => QuickBooks_Utilities::intervalToSeconds($how_often), 'map' => $sql_map);
     //print_r($sql_options);
     //exit;
     $defaults = $this->_sqlDefaults($sql_options);
     $sql_callback_options['_only_query'] = $defaults['only_query'];
     $sql_callback_options['_dont_query'] = $defaults['dont_query'];
     $sql_callback_options['_only_add'] = $defaults['only_add'];
     $sql_callback_options['_dont_add'] = $defaults['dont_add'];
     $sql_callback_options['_only_modify'] = $defaults['only_modify'];
     $sql_callback_options['_dont_modify'] = $defaults['dont_modify'];
     // Merge default values with passed in values
     //	(in this case, we are *required* to have these values present, so
     //	we make sure that the SQL options override any user-defined options
     $sql_callback_options = $this->_merge($callback_options, $sql_callback_options, false);
     // Initialize the Driver singleton
     $Driver = QuickBooks_Driver_Singleton::getInstance($dsn_or_conn, $driver_options, $sql_hooks, $log_level);
     // $dsn_or_conn, $map, $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()
     parent::__construct($dsn_or_conn, $sql_map, $sql_onerror, $sql_hooks, $log_level, $soap, $wsdl, $soap_options, $handler_options, $driver_options, $sql_callback_options);
 }
Пример #5
0
 /**
  * QuickBooks API server class
  * 
  * @param string $dsn_or_conn
  * @param array $map
  * @param array $onerror
  * @param array $hooks
  * @param integer $log_level
  * @param string $soap
  * @param string $wsdl
  * @param array $soap_options
  * @param array $handler_options
  * @param array $driver_options
  * @param array $callback_options
  */
 public function __construct($dsn_or_conn, $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(), $callback_options = array())
 {
     // NORMAL:
     // $dsn_or_conn, $map, $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()
     // SQL:
     // $dsn_or_conn, $how_often, $mode, $conflicts, $users = null, $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_map = array();
     foreach (get_class_methods('QuickBooks_Callbacks_API_Callbacks') as $method) {
         if (strtolower(substr($method, -7)) == 'request') {
             $action = substr($method, 0, -7);
             $api_map[$action] = array('QuickBooks_Callbacks_API_Callbacks::' . $action . 'Request', 'QuickBooks_Callbacks_API_Callbacks::' . $action . 'Response');
         }
     }
     // Register default API error handlers, and merge them with user-supplied handlers
     $api_onerror = array(1 => 'QuickBooks_Callbacks_API_Errors::e1_notfound', 500 => 'QuickBooks_Callbacks_API_Errors::e500_notfound');
     // By default, we register our own error handlers. If the user wants to
     //	register their own error handlers, their error handlers override
     //	the API error handlers, and they'll be expected to handle all of
     //	those errors themselves.
     $api_onerror = $this->_merge($api_onerror, $onerror, false);
     // Register default API hooks, and merge them with user-supplied hooks
     $api_hooks = array();
     // Merge user-defined hooks with our API hooks
     $api_hooks = $this->_merge($api_hooks, $hooks, true);
     // Initialize the Driver singleton
     $tmp = QuickBooks_Driver_Singleton::getInstance($dsn_or_conn, $driver_options, $hooks, $log_level);
     $source_type = QUICKBOOKS_API_SOURCE_WEB;
     $source_dsn = null;
     // Initialize the API singleton
     $tmp = QuickBooks_API_Singleton::getInstance($dsn_or_conn, $user, $source_type, $source_dsn, $api_options, $source_options, $driver_options, $callback_options);
     // $dsn_or_conn, $map, $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()
     parent::__construct($dsn_or_conn, $api_map, $api_onerror, $api_hooks, $log_level, $soap, $wsdl, $soap_options, $handler_options, $driver_options, $callback_options);
 }