/** * * * @param string $dsn_or_conn * @param array $options * @return QuickBooks_Driver */ public static function getInstance($dsn_or_conn = null, $options = array(), $hooks = array(), $log_level = null) { static $instance = null; if (is_null($instance)) { $instance = QuickBooks_Utilities::driverFactory($dsn_or_conn, $options, $hooks, $log_level); } return $instance; }
/** * Create a new QuickBooks queue instance * * @param mixed $dsn_or_conn A DSN-style connection string (i.e.: mysq://root:pass@locahost/database) or a database connection (if you wish to re-use an existing database connection) * @param array $config Configuration array for the driver */ public function __construct($dsn_or_conn, $user = null, $config = array()) { $this->_driver = QuickBooks_Utilities::driverFactory($dsn_or_conn, $config); // No default username was provided, fetch the default from the driver if (!$user) { $user = $this->_driver->authDefault(); } // Set the default username $this->_user = $user; }
/** * Start the front-end and handle any requests * * @return boolean */ public function handle() { header('Content-type: text/html'); $menu = null; $this->_importModules($menu); $driver = QuickBooks_Utilities::driverFactory($this->_dsn); $skin = $this->_skinFactory($this->_skin, $menu); $MOD = 'Home'; if (isset($_REQUEST['MOD'])) { $MOD = strtolower(trim(strip_tags($_REQUEST['MOD']))); } $DO = 'home'; if (isset($_REQUEST['DO'])) { $DO = strtolower(trim(strip_tags($_REQUEST['DO']))); } $module = ucfirst(strtolower($MOD)); $class = 'QuickBooks_Frontend_Module_' . $module; if (class_exists($class)) { $Object = new $class($driver, $skin, $menu); if (method_exists($Object, $DO) and $Object instanceof QuickBooks_Frontend_Module) { return $Object->{$DO}($MOD, $DO); } else { return $Object->error($MOD, $DO); } } else { /* * @todo Better error handling... */ die('Error!'); return false; } }
/** * Create a new QuickBooks SOAP server * * @param mixed $dsn_or_conn Either a DSN-style connection string *or* a database resource (if reusing an existing connection) * @param array $map An associative array mapping queued commands to function/method calls * @param array $onerror An associative array mapping error codes to function/method calls * @param arary $hooks An associative array mapping events to hook function/method calls * @param string $wsdl The path to the WSDL file to use for the SOAP server methods * @param array $soap_options Options to pass to the SOAP server (these mirror the default PHP SOAP server options) * @param array $handler_options Options to pass to the handler class * @param array $driver_options Options to pass to the driver class (i.e.: MySQL, etc.) */ public function __construct($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(), $callback_options = array()) { $soap_options = $this->_defaults($soap_options); // If safe mode is turned on, this causes a NOTICE/WARNING to be issued... if (!ini_get('safe_mode')) { set_time_limit($soap_options['time_limit']); } /* if ($soap_options['error_handler']) { set_error_handler($soap_options['error_handler']); } else if ($soap_options['use_builtin_error_handler']) { set_error_handler( array( 'QuickBooks_ErrorHandler', 'handle' ) ); } if ($soap_options['log_to_syslog']) { } if ($soap_options['log_to_file']) { } */ // WSDL location $this->_wsdl = $wsdl; // Logging level $this->_loglevel = $log_level; if ($this->_loglevel >= QUICKBOOKS_LOG_DEVELOP) { $this->_driver = QuickBooks_Utilities::driverFactory($dsn_or_conn, $driver_options, $hooks, $log_level); } // SOAP server adapter class $this->_server = $this->_adapterFactory($soap, $wsdl, $soap_options, $log_level); /* $this->_hooks = array(); foreach ($hooks as $hook => $funcs) { if (!is_array($funcs)) { $funcs = array( $funcs ); } $hooks[$hook] = $funcs; // Do this so that when we pass it to the handlers, the hooks are already in lists $this->_hooks[$hook] = $funcs; } */ // Assign hooks $this->_hooks = $hooks; // Assign callback configuration info $this->_callback_config = $callback_options; // Raw input $input = file_get_contents('php://input'); $this->_input = $input; // Base handlers // $dsn_or_conn, $map, $onerror, $hooks, $log_level, $input, $handler_config = array(), $driver_config = array() $this->_server->setClass('QuickBooks_WebConnector_Handlers', $dsn_or_conn, $map, $onerror, $hooks, $log_level, $input, $handler_options, $driver_options, $callback_options); }
/** * Create the server handler instance * * Optional configuration items should be passed as an associative array with any of these keys: * - qb_company_file The full filesystem path to a specific QuickBooks company file (by default, it will use the currently open company file) * - qbwc_min_version Minimum version of the Web Connector that must be used to connect (by default, any version may connect) * - qbwc_wait_before_next_update Tell the Web Connector to wait this number of seconds before doign another update * - qbwc_min_run_every_n_seconds Tell the Web Connector to run every n seconds (overrides whatever was in the .QWC web connector configuration file) * - qbwc_interactive_url The URL to use for Interactive QuickBooks Web Connector sessions * - server_version Server version string * - authenticate_handler If you want to use some custom authentication method, put the function name of your custom authentication function here * - autoadd_missing_requestid This defaults to TRUE, if TRUE and you forget to embed a requestID="..." attribute, it will try to automatically add that attribute for you * * @param mixed $dsn_or_conn DSN connection string for QuickBooks queue * @param array $map A map of QuickBooks API calls to callback functions/methods * @param array $onerror A map of QuickBooks error codes to callback functions/methods * @param array $hooks A map of hook names to callback functions/methods * @param string $input Raw XML input from QuickBooks API call * @param array $handler_config An array of configuration options * @param array $driver_config An array of driver configuration options */ public function __construct($dsn_or_conn, $map, $onerror, $hooks, $log_level, $input, $handler_config = array(), $driver_config = array(), $callback_config = array()) { $this->_driver = QuickBooks_Utilities::driverFactory($dsn_or_conn, $driver_config, $hooks, $log_level); $this->_input = $input; $this->_map = $map; $this->_onerror = $onerror; $this->_hooks = array(); foreach ($hooks as $hook => $funcs) { if (!is_array($funcs)) { $funcs = array($funcs); } $this->_hooks[$hook] = $funcs; } $this->_config = $this->_defaults($handler_config); $this->_callback_config = $callback_config; $this->_driver->log('Handler is starting up...: ' . var_export($this->_config, true), '', QUICKBOOKS_LOG_DEBUG); }
<?php require_once '../../QuickBooks.php'; require_once 'QuickBooks/Integrator/Imscart.php'; $dsn = 'mysql://root:@localhost/imscart'; $driver = QuickBooks_Utilities::driverFactory($dsn); $api = QuickBooks_API_Singleton::getInstance($dsn, 'imscart', QUICKBOOKS_API_SOURCE_WEB); $Imscart = new QuickBooks_Integrator_Imscart($driver, array()); //$Customer = $Imscart->getCustomer(2680); //print($Customer->asQBXML('CustomerAddRq')); //$ServiceItem = $Imscart->getProduct(5); //print($ServiceItem->asQBXML('ItemServiceAddRq')); $Order = $Imscart->getOrder(191); print $Order->asQBXML('InvoiceAddRq'); //$ShipMethod = $Imscart->getShipMethod(50); //print($ShipMethod->asQBXML('ShipMethodAddRq')); //$Payment = $Imscart->getPayment(207); //print($Payment->asQBXML('ReceivePaymentAddRq')); //$Shipping = $Imscart->getShippingForOrder(191); //print($Shipping->asQBXML(QUICKBOOKS_ADD_SERVICEITEM));
/** * Tell whether or not a driver has been initialized * * @param string $dsn * @param array $driver_options * @return boolean */ public static function initialized($dsn, $driver_options = array()) { $Driver = QuickBooks_Utilities::driverFactory($dsn, $driver_options); return $Driver->initialized(); }
/** * Get the IMSCart integrator object for the IMSCart integrator server * * @param string $integrator_dsn_or_conn * @param array $integrator_options * @return QuickBooks_Integrator */ protected function _integratorFactory($integrator_dsn_or_conn, $integrator_options, $API) { $driver = QuickBooks_Utilities::driverFactory($integrator_dsn_or_conn); return new QuickBooks_Integrator_Zencart($driver, $integrator_options); }