本文整理汇总了PHP中QuickBooks_Utilities类的典型用法代码示例。如果您正苦于以下问题:PHP QuickBooks_Utilities类的具体用法?PHP QuickBooks_Utilities怎么用?PHP QuickBooks_Utilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QuickBooks_Utilities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public static function create($dsn_or_conn, $mode, $user, $action, $config = array())
{
static $instances = array();
$key = (string) $dsn_or_conn . ',' . $mode . ',' . $user . ',' . $action . ',' . serialize($config);
if (!isset($instances[$key])) {
if (is_resource($dsn_or_conn)) {
$scheme = current(explode(' ', get_resource_type($dsn_or_conn)));
} else {
$scheme = QuickBooks_Utilities::parseDSN($dsn_or_conn, array(), 'scheme');
}
if (false !== strpos($scheme, 'sql')) {
$scheme = 'SQL_' . $scheme;
}
$class = 'QuickBooks_Transport_' . ucfirst(strtolower($scheme));
$file = 'QuickBooks/Transport/' . str_replace(' ', '/', ucwords(str_replace('_', ' ', strtolower($scheme)))) . '.php';
require_once $file;
if (class_exists($class)) {
$Transport = new $class($dsn_or_conn, $mode, $user, $action, $config);
$instances[$key] = $Transport;
} else {
$instances[$key] = null;
}
}
return $instances[$key];
}
示例2: create
/**
* Create an instance of a driver class from a DSN connection string *or* a connection resource
*
* You can actually pass in *either* a DSN-style connection string OR an already connected database resource
* - mysql://user:pass@localhost:port/database
* - $var (Resource ID #XYZ, valid MySQL connection resource)
*
* @param mixed $dsn_or_conn A DSN-style connection string or a PHP resource
* @param array $config An array of configuration options for the driver
* @param array $hooks An array mapping hooks to user-defined hook functions to call
* @param integer $log_level
* @return object A class instance, a child class of QuickBooks_Driver
*/
public static function create($dsn_or_conn, $config = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL)
{
static $instances = array();
if (!is_array($hooks)) {
$hooks = array();
}
$key = (string) $dsn_or_conn . serialize($config) . serialize($hooks) . $log_level;
if (!isset($instances[$key])) {
if (is_resource($dsn_or_conn)) {
$scheme = current(explode(' ', get_resource_type($dsn_or_conn)));
} else {
$scheme = QuickBooks_Utilities::parseDSN($dsn_or_conn, array(), 'scheme');
}
if (false !== strpos($scheme, 'sql')) {
$scheme = 'SQL_' . $scheme;
}
$class = 'QuickBooks_Driver_' . ucfirst(strtolower($scheme));
$file = 'QuickBooks/Driver/' . str_replace(' ', '/', ucwords(str_replace('_', ' ', strtolower($scheme)))) . '.php';
require_once $file;
if (class_exists($class)) {
$Driver = new $class($dsn_or_conn, $config);
$Driver->registerHooks($hooks);
$Driver->setLogLevel($log_level);
// @todo Ugh this is really ugly... maybe have $log_level passed in as a parameter? Not really a driver option at all?
//if (isset($config['log_level']))
//{
// $driver->setLogLevel($config['log_level']);
//}
$instances[$key] = $Driver;
} else {
$instances[$key] = null;
}
}
return $instances[$key];
}
示例3: __construct
/**
* Create a new PostgreSQL database authenticator
*
* @param string $dsn A DSN-style connection string for PostgreSQL (i.e.: pgsql://username:password@hostname:port/database)
*/
public function __construct($dsn)
{
$conn_defaults = array('scheme' => 'pgsql', 'user' => 'pgsql', 'pass' => '', 'host' => 'localhost', 'port' => 5432, 'path' => '/quickbooks', 'query' => '');
$param_defaults = array('table_name' => 'quickbooks_user', 'field_username' => 'qb_username', 'field_password' => 'qb_password', 'crypt_function' => 'sha1', 'field_company_file' => null, 'field_wait_before_next_update' => null, 'field_min_run_every_n_seconds' => null);
// mysql://user:pass@localhost:port/database?table_name=quickbooks_user&field_username=username&field_password=password&crypt_function=md5
$parse = QuickBooks_Utilities::parseDSN($dsn, $conn_defaults);
$vars = array();
parse_str($parse['query'], $vars);
$param_defaults = array_merge($param_defaults, $vars);
$conn_str = '';
if (strlen($parse['host'])) {
$conn_str .= ' host=' . $parse['host'];
}
if (strlen($parse['port'])) {
$conn_str .= ' port=' . (int) $parse['port'];
}
if (strlen($parse['user'])) {
$conn_str .= ' user=' . $parse['user'];
}
if (strlen($parse['pass'])) {
$conn_str .= ' password=' . $parse['pass'];
}
$conn_str .= ' dbname=' . substr($parse['path'], 1);
$this->_conn = pg_connect($conn_str, PGSQL_CONNECT_FORCE_NEW);
$this->_table_name = pg_escape_string($this->_conn, $param_defaults['table_name']);
$this->_field_username = pg_escape_string($this->_conn, $param_defaults['field_username']);
$this->_field_password = pg_escape_string($this->_conn, $param_defaults['field_password']);
$this->_crypt_function = $param_defaults['crypt_function'];
$this->_field_company_file = $param_defaults['field_company_file'];
$this->_field_wait_before_next_update = $param_defaults['field_wait_before_next_update'];
$this->_field_min_run_every_n_seconds = $param_defaults['field_min_run_every_n_seconds'];
}
示例4: getInstance
/**
*
*
* @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;
}
示例5: __construct
/**
* Create a new authentication handler
*
* @param string $dsn A DSN-style string indicating the function name and other parameters, i.e.: function://my_function_name?param1=value1¶m2=value2
*/
public function __construct($dsn)
{
$conn_defaults = array('scheme' => 'function', 'user' => '', 'pass' => '', 'host' => 'your_function_name', 'port' => 0, 'path' => '', 'query' => '');
// function://my_function_name?param1=value1¶m2=value2
$parse = QuickBooks_Utilities::parseDSN($dsn, $conn_defaults);
$vars = array();
parse_str($parse['query'], $vars);
$this->_function = $parse['host'];
$this->_params = array_merge($vars);
}
示例6: action_index
/**
* Houses the instance of the soap server and creates the mappings for errors, function callbacks
* @author Jayson Lindsley <jay.lindsley@gmail.com>
*/
public function action_index()
{
//Username and password used for the web connector, QWC file, and the QB Framework
$user = 'QBAPI Username';
$pass = 'QBAPI Password';
//Configure the logging level
$log_level = QUICKBOOKS_LOG_DEVELOP;
//Pure-PHP SOAP server
$soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN;
//we can turn this off
$handler_options = array('deny_concurrent_logins' => false, 'deny_reallyfast_logins' => false);
// The next three params $map, $errmap, and $hooks are callbacks which
// will be called when certain actions/events/requests/responses occur within
// the framework
// Maps inbound requests to functions
$map = array(QUICKBOOKS_ADD_CUSTOMER => array(array($this, '_quickbooks_customer_add_request'), array($this, '_quickbooks_customer_add_response')), QUICKBOOKS_MOD_CUSTOMER => array(array($this, '_quickbooks_customer_mod_request'), array($this, '_quickbooks_customer_mod_response')));
//Map error handling to functions
$errmap = array(3070 => array($this, '_quickbooks_error_stringtoolong'), 3140 => array($this, '_quickbooks_reference_error'), '*' => array($this, '_quickbooks_error_handler'));
//Login success callback
$hooks = array(QuickBooks_WebConnector_Handlers::HOOK_LOGINSUCCESS => array(array($this, '_quickbooks_hook_loginsuccess')));
//MySQL database name containing the QuickBooks tables is named 'quickbooks' (if the tables don't exist, they'll be created for you)
$dsn = 'mysql://username:password@host/databasename';
QuickBooks_WebConnector_Queue_Singleton::initialize($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);
// Initial test case customer
$primary_key_of_new_customer = 512;
// Fire up the Queue
$Queue = new QuickBooks_WebConnector_Queue($dsn);
// Drop the directive and the customer into the queue
$Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, $primary_key_of_new_customer);
// Also note the that ->enqueue() method supports some other parameters:
// string $action The type of action to queue up
// mixed $ident = null Pass in the unique primary key of your record here, so you can pull the data from your application to build a qbXML request in your request handler
// $priority = 0 You can assign priorities to requests, higher priorities get run first
// $extra = null Any extra data you want to pass to the request/response handler
// $user = null If you're using multiple usernames, you can pass the username of the user to queue this up for here
// $qbxml = null
// $replace = true
}
//To be used with singleton queue
$driver_options = array();
//Callback options, not needed at the moment
$callback_options = array();
//nothing needed here at the moment
$soap_options = array();
//construct a new instance of the web connector server
$Server = new QuickBooks_WebConnector_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
//instruct server to handle responses
$response = $Server->handle(true, true);
}
示例7: __construct
/**
* Create a new authentication handler
*
* @param string $dsn DSN-style connection string, something like: htpasswd:///path/to/your/htpasswd/file.htpasswd
*/
public function __construct($dsn)
{
$conn_defaults = array('scheme' => 'htpasswd', 'user' => '', 'pass' => '', 'host' => 'localhost', 'port' => 3306, 'path' => '/path/to/htpasswd', 'query' => '');
// htpasswd:///database?table_name=quickbooks_user&field_username=username&field_password=password&crypt_function=md5
$parse = QuickBooks_Utilities::parseDSN($dsn, $conn_defaults);
$this->_accounts = array();
if (is_file($parse['path']) and $lines = file($parse['path'])) {
foreach ($lines as $line) {
$explode = explode(':', trim($line));
$this->_accounts[$explode[0]] = $explode[1];
}
}
}
示例8: create
/**
* Create an instance of a driver class from a DSN connection string *or* a connection resource
*
* You can actually pass in *either* a DSN-style connection string OR an already connected database resource
* - mysql://user:pass@localhost:port/database
* - $var (Resource ID #XYZ, valid MySQL connection resource)
*
* @param mixed $dsn_or_conn A DSN-style connection string or a PHP resource
* @param array $config An array of configuration options for the driver
* @param array $hooks An array mapping hooks to user-defined hook functions to call
* @param integer $log_level
* @return object A class instance, a child class of QuickBooks_Driver
*/
public static function create($dsn_or_conn, $config = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL)
{
static $instances = array();
if (!is_array($hooks)) {
$hooks = array();
}
// Do not serialize the $hooks because they might contain non-serializeable objects
$key = (string) $dsn_or_conn . serialize($config) . $log_level;
if (!isset($instances[$key])) {
if (is_resource($dsn_or_conn)) {
$scheme = current(explode(' ', get_resource_type($dsn_or_conn)));
} else {
$scheme = QuickBooks_Utilities::parseDSN($dsn_or_conn, array(), 'scheme');
}
if (false !== strpos($scheme, 'sql')) {
$scheme = 'Sql_' . ucfirst(strtolower($scheme));
} else {
$scheme = ucfirst(strtolower($scheme));
}
$class = 'QuickBooks_Driver_' . $scheme;
$file = '/QuickBooks/Driver/' . str_replace(' ', '/', ucwords(str_replace('_', ' ', strtolower($scheme)))) . '.php';
//print('class: ' . $class . "\n");
//print('file: ' . $file . "\n");
QuickBooks_Loader::load($file);
if (class_exists($class)) {
$Driver = new $class($dsn_or_conn, $config);
$Driver->registerHooks($hooks);
$Driver->setLogLevel($log_level);
/*
static $static = 0;
$static++;
print('Constructed new instance ' . $static . ' [' . $key . ']' . "\n");
mysql_query("INSERT INTO quickbooks_log ( msg, log_datetime ) VALUES ( 'Here is my " . $static . " key: " . $key . "', NOW() )");
//print_r($hooks);
*/
// @todo Ugh this is really ugly... maybe have $log_level passed in as a parameter? Not really a driver option at all?
//if (isset($config['log_level']))
//{
// $driver->setLogLevel($config['log_level']);
//}
$instances[$key] = $Driver;
} else {
$instances[$key] = null;
}
}
return $instances[$key];
}
示例9: __construct
/**
* Create a new instance of the MySQL Web Connector authenticator
*
* @param string $dsn A DSN-style MySQL connection string (i.e.: mysql://your-username:your-password@your-localhost:port/your-database)
*/
public function __construct($dsn)
{
$conn_defaults = array('scheme' => 'mysql', 'user' => 'root', 'pass' => '', 'host' => 'localhost', 'port' => 3306, 'path' => '/quickbooks', 'query' => '');
$param_defaults = array('table_name' => 'quickbooks_user', 'field_username' => 'qb_username', 'field_password' => 'qb_password', 'field_company_file' => null, 'field_wait_before_next_update' => null, 'field_min_run_every_n_seconds' => null, 'crypt_function' => 'sha1');
// mysql://user:pass@localhost:port/database?table_name=quickbooks_user&field_username=username&field_password=password&crypt_function=md5
$parse = QuickBooks_Utilities::parseDSN($dsn, $conn_defaults);
$vars = array();
parse_str($parse['query'], $vars);
$param_defaults = array_merge($param_defaults, $vars);
$this->_conn = mysql_connect($parse['host'] . ':' . $parse['port'], $parse['user'], $parse['pass'], true);
mysql_select_db(substr($parse['path'], 1), $this->_conn);
$this->_table_name = mysql_real_escape_string($param_defaults['table_name'], $this->_conn);
$this->_field_username = mysql_real_escape_string($param_defaults['field_username'], $this->_conn);
$this->_field_password = mysql_real_escape_string($param_defaults['field_password'], $this->_conn);
$this->_crypt_function = $param_defaults['crypt_function'];
$this->_field_company_file = $param_defaults['field_company_file'];
$this->_field_wait_before_next_update = $param_defaults['field_wait_before_next_update'];
$this->_field_min_run_every_n_seconds = $param_defaults['field_min_run_every_n_seconds'];
}
示例10: __construct
/**
* Create a new authentication handler
*
* @param string $dsn DSN-style connection string, something like: htpasswd:///path/to/your/htpasswd/file.htpasswd
*/
public function __construct($dsn)
{
ini_set('auto_detect_line_endings', true);
$conn_defaults = array('scheme' => 'csv', 'user' => '', 'pass' => '', 'host' => '', 'port' => '', 'path' => '/path/to/file.csv', 'query' => '');
// htpasswd:///database?table_name=quickbooks_user&field_username=username&field_password=password&crypt_function=md5
$parse = QuickBooks_Utilities::parseDSN($dsn, $conn_defaults);
$this->_accounts = array();
if (is_file($parse['path']) and $fp = fopen($parse['path'], 'r')) {
while (false !== ($arr = fgetcsv($fp, 1000, ','))) {
if (empty($arr[0]) or empty($arr[1])) {
continue;
}
for ($i = 2; $i < 10; $i++) {
if (empty($arr[$i])) {
$arr[$i] = '';
}
}
$username = trim($arr[0]);
$this->_accounts[$username] = $arr;
}
}
}
示例11: qwcGenerate
public function qwcGenerate($MOD, $DO)
{
$qwc = $this->_HTTPPostDefaults();
extract($qwc);
if (empty($name)) {
return $this->qwcForm($MOD, $DO, 'You must enter an application name!');
} else {
if (empty($username)) {
return $this->qwcForm($MOD, $DO, 'You must enter a Web Connector username!');
}
}
if (empty($fileid)) {
$fileid = QuickBooks_Utilities::generateFileID();
}
if (empty($ownerid)) {
$ownerid = QuickBooks_Utilities::generateOwnerID();
}
$xml = QuickBooks_Utilities::generateQWC($name, $descrip, $appurl, $appsupport, $username, $fileid, $ownerid, $qbtype, $readonly, $run_every_n_seconds, $personaldata, $unattendedmode, $authflags, $notify, $appdisplayname, $appuniquename, $appid);
header('Content-type: text/plain');
print $xml;
exit;
}
示例12: addForm
public function addForm($MOD, $DO)
{
$this->_skin->assign('actions', QuickBooks_Utilities::listActions());
$users = array();
$iterator = $this->_driver->authView(0, 999);
while ($arr = $iterator->next()) {
$users[] = $arr['qb_username'];
}
$this->_skin->assign('users', $users);
$this->_skin->assign('error', $this->_stat() == QUICKBOOKS_FRONTEND_MODULE_RECUR_ERROR_FAILURE);
switch ($this->_stat()) {
case QUICKBOOKS_FRONTEND_MODULE_RECUR_ERROR_SUCCESS:
$this->_skin->assign('msg', 'Successfully added the event!');
break;
case QUICKBOOKS_FRONTEND_MODULE_RECUR_ERROR_FAILURE:
$this->_skin->assign('msg', 'Failed to add the event: ' . $this->_msg());
break;
default:
$this->_skin->assign('msg', '');
break;
}
$this->_skin->display('Recur/addForm.tpl');
}
示例13: _quickbooks_invoiceadd_response
function _quickbooks_invoiceadd_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
{
try {
$query = "update customer_order\r\n set status='S'\r\n where idcustomer_order='" . $ID . "'";
mysql_query($query);
} catch (Exception $e) {
QuickBooks_Utilities::log(QB_QUICKBOOKS_DSN, "_quickbooks_invoiceadd_request " . $e->getMessage());
}
}
示例14: QuickBooks_IPP_Service_TimeActivity
//print_r($creds);
// This is our current realm
$realm = $creds['qb_realm'];
// Load the OAuth information from the database
if ($Context = $IPP->context()) {
// Set the IPP version to v3
$IPP->version(QuickBooks_IPP_IDS::VERSION_3);
$TimeActivityService = new QuickBooks_IPP_Service_TimeActivity();
$TimeActivity = new QuickBooks_IPP_Object_TimeActivity();
$TimeActivity->setTxnDate('2013-10-10');
$TimeActivity->setNameOf('Vendor');
$TimeActivity->setVendorRef('89');
$TimeActivity->setItemRef('8');
$TimeActivity->setHourlyRate('250');
$TimeActivity->setStartTime(QuickBooks_Utilities::datetime('-5 hours'));
$TimeActivity->setEndTime(QuickBooks_Utilities::datetime('-1 hour'));
$TimeActivity->setDescription('Test entry.');
if ($resp = $TimeActivityService->add($Context, $realm, $TimeActivity)) {
print 'Our new TimeActivity ID is: [' . $resp . ']';
} else {
print $TimeActivityService->lastError($Context);
}
print '<br><br><br><br>';
print "\n\n\n\n\n\n\n\n";
print 'Request [' . $IPP->lastRequest() . ']';
print "\n\n\n\n";
print 'Response [' . $IPP->lastResponse() . ']';
print "\n\n\n\n\n\n\n\n\n";
} else {
die('Unable to load a context...?');
}
示例15: set_time_limit
set_time_limit(0);
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '/Users/kpalmer/Projects/QuickBooks');
require_once 'QuickBooks.php';
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('America/New_York');
}
$username = 'quickbooks';
$password = 'password';
error_reporting(E_ALL);
ini_set('display_errors', 1);
//rint(wtaf');
$dsn = 'mysql://root:s4p3rs3c4r3@localhost/quickbooksWIP2';
if (!QuickBooks_Utilities::initialized($dsn)) {
header('Content-Type: text/plain');
$driver_options = array();
$init_options = array('quickbooks_sql_enabled' => true);
QuickBooks_Utilities::initialize($dsn, $driver_options, $init_options);
QuickBooks_Utilities::createUser($dsn, $username, $password);
exit;
}
$mode = QUICKBOOKS_SERVER_SQL_MODE_READONLY;
//$mode = QUICKBOOKS_SERVER_SQL_MODE_WRITEONLY;
//$mode = QUICKBOOKS_SERVER_SQL_MODE_READWRITE;
//Delete Modes -- Remove or Flag?
//$deleteMode = QUICKBOOKS_SERVER_SQL_ON_DELETE_FLAG;
$deleteMode = QUICKBOOKS_SERVER_SQL_ON_DELETE_REMOVE;
// $dsn_or_conn, $how_often, $mode, $conflicts, $users = null,
// $map = array(), $onerror = array(), $hooks = array(), $log_level, $soap = QUICKBOOKS_SOAPSERVER_BUILTIN, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array()
$server = new QuickBooks_Server_SQL($dsn, '1 minute', $mode, $deleteMode, QUICKBOOKS_SERVER_SQL_CONFLICT_NEWER, $username, array(), array(), array(), QUICKBOOKS_LOG_DEVELOP, QUICKBOOKS_SOAPSERVER_PHP, QUICKBOOKS_WSDL);
$server->handle(true, true);