コード例 #1
0
ファイル: Factory.php プロジェクト: Edgargm87/efapcom
 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
0
 /**
  * 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
0
ファイル: Pgsql.php プロジェクト: Edgargm87/efapcom
 /**
  * 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='******'user'];
     }
     if (strlen($parse['pass'])) {
         $conn_str .= ' password='******'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
0
ファイル: Singleton.php プロジェクト: Edgargm87/efapcom
 /**
  * 
  * 
  * @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
0
 /**
  * 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&param2=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&param2=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
0
 /**
  * Houses the instance of the soap server and creates the mappings for errors, function callbacks
  * @author Jayson Lindsley <*****@*****.**>
  */
 public function action_index()
 {
     //Username and password used for the web connector, QWC file, and the QB Framework
     $user = '******';
     $pass = '******';
     //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://*****:*****@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
0
 /**
  * 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
0
ファイル: Factory.php プロジェクト: cpnporg/quickbooks-php
 /**
  * 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
0
ファイル: Mysql.php プロジェクト: Edgargm87/efapcom
 /**
  * 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
0
ファイル: Csv.php プロジェクト: Edgargm87/efapcom
 /**
  * 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
0
ファイル: Setup.php プロジェクト: Edgargm87/efapcom
 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
0
 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
0
ファイル: exportServer.php プロジェクト: Edgargm87/efapcom
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
0
//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
0
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 = '******';
$password = '******';
error_reporting(E_ALL);
ini_set('display_errors', 1);
//rint(wtaf');
$dsn = 'mysql://*****:*****@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);
コード例 #16
0
ファイル: Errors.php プロジェクト: Edgargm87/efapcom
 /**
  * @TODO Change this to return false by default, and only catch the specific errors we're concerned with.
  * 
  */
 public static function catchall($requestID, $user, $action, $ident, $extra, &$err, $xml, $errnum, $errmsg, $config)
 {
     $Driver = QuickBooks_Driver_Singleton::getInstance();
     /*
     $Parser = new QuickBooks_XML($xml);
     $errnumTemp = 0;
     $errmsgTemp = '';
     $Doc = $Parser->parse($errnumTemp, $errmsgTemp);
     $Root = $Doc->getRoot();		
     $emailStr = var_export($Root->children(), true);
     	
     $List = $Root->getChildAt('QBXML QBXMLMsgsRs '.QuickBooks_Utilities::actionToResponse($action));
     $Node = current($List->children());
     */
     $map = array();
     $others = array();
     QuickBooks_SQL_Schema::mapToSchema(trim(QuickBooks_Utilities::actionToXMLElement($action)), QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $map, $others);
     $sqlObject = new QuickBooks_SQL_Object($map[0], trim(QuickBooks_Utilities::actionToXMLElement($action)));
     $table = $sqlObject->table();
     switch ($errnum) {
         case 1:
             // These errors occur when we search for something and it doesn't exist
         // These errors occur when we search for something and it doesn't exist
         case 500:
             // 	i.e. we query for invoices modified since xyz, but there are none that have been modified since then
             // This isn't really an error, just ignore it
             return true;
         case 1000:
             // An internal error occured
             // @todo Hopefully at some point we'll have a better idea of how to handle this error...
             return true;
         case 3200:
             // Ignore EditSequence errors (the record will be picked up and a conflict reported next time it runs... maybe?)
             // @todo Think about this one more
             return true;
         case 3250:
             // This feature is not enabled or not available in this version of QuickBooks.
             // Do nothing (this can be safely ignored)
             return true;
         case 3100:
             // Name of List Element is already in use.
             $multipart = array(QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ident);
             $sqlObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_NUMBER, $errnum);
             $sqlObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_MESSAGE, $errmsg);
             $Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $sqlObject, array($multipart));
             break;
         case 3260:
             // Insufficient permission level to perform this action.
             // There's nothing we can do about this, if they don't grant the user permission, just skip it
             return true;
         case 3200:
             // The provided edit sequence is out-of-date.
             if (!($tmp = $Driver->get(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, array(QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ident)))) {
                 return true;
             }
             switch ($config['conflicts']) {
                 case QUICKBOOKS_SERVER_SQL_CONFLICT_LOG:
                     $multipart = array(QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ident);
                     $sqlObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_NUMBER, $errnum);
                     $sqlObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_MESSAGE, $errmsg);
                     $Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $sqlObject, array($multipart));
                     break;
                 case QUICKBOOKS_SERVER_SQL_CONFLICT_NEWER:
                     $Parser = new QuickBooks_XML_Parser($xml);
                     $errnumTemp = 0;
                     $errmsgTemp = '';
                     $Doc = $Parser->parse($errnumTemp, $errmsgTemp);
                     $Root = $Doc->getRoot();
                     $List = $Root->getChildAt('QBXML QBXMLMsgsRs ' . QuickBooks_Utilities::actionToResponse($action));
                     $TimeModified = $Root->getChildDataAt('QBXML QBXMLMsgsRs ' . QuickBooks_Utilities::actionToResponse($action) . ' ' . QuickBooks_Utilities::actionToXMLElement($action) . ' TimeModified');
                     $EditSequence = $Root->getChildDataAt('QBXML QBXMLMsgsRs ' . QuickBooks_Utilities::actionToResponse($action) . ' ' . QuickBooks_Utilities::actionToXMLElement($action) . ' EditSequence');
                     $multipart = array(QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ident);
                     if (QuickBooks_Utilities::compareQBTimeToSQLTime($TimeModified, $tmp->get(QUICKBOOKS_DRIVER_SQL_FIELD_MODIFY)) >= 0 && $config['mode'] != QUICKBOOKS_SERVER_SQL_MODE_WRITEONLY) {
                         //@TODO: Make this get only a single item, not the whole table
                         $Driver->queueEnqueue($user, QuickBooks_Utilities::convertActionToQuery($action), __FILE__, true, QUICKBOOKS_SERVER_SQL_CONFLICT_QUEUE_PRIORITY, $extra);
                     } else {
                         if (QuickBooks_Utilities::compareQBTimeToSQLTime($TimeModified, $tmp->get(QUICKBOOKS_DRIVER_SQL_FIELD_MODIFY)) < 0) {
                             //Updates the EditSequence without marking the row as resynced.
                             $tmpSQLObject = new QuickBooks_SQL_Object($table, null);
                             $tmpSQLObject->set("EditSequence", $EditSequence);
                             $Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $tmpSQLObject, array($multipart));
                             $Driver->queueEnqueue($user, QuickBooks_Utilities::convertActionToMod($action), $tmp->get(QUICKBOOKS_DRIVER_SQL_FIELD_ID), true, QUICKBOOKS_SERVER_SQL_CONFLICT_QUEUE_PRIORITY, $extra);
                         } else {
                             //Trash it, set synced.
                             $tmpSQLObject = new QuickBooks_SQL_Object($table, null);
                             $tmpSQLObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_MESSAGE, "Read/Write Mode is WRITEONLY, and Conflict Mode is NEWER, and Quickbooks has Newer data, so no Update Occured.");
                             $Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $tmpSQLObject, array($multipart));
                         }
                     }
                     break;
                 case QUICKBOOKS_SERVER_SQL_CONFLICT_QUICKBOOKS:
                     if ($config['mode'] == QUICKBOOKS_SERVER_SQL_MODE_READWRITE) {
                         //@TODO: Make this get only a single item, not the whole table
                         $Driver->queueEnqueue($user, QuickBooks_Utilities::convertActionToQuery($action), null, true, QUICKBOOKS_SERVER_SQL_CONFLICT_QUEUE_PRIORITY, $extra);
                         $multipart = array(QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ident);
                         $sqlObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_NUMBER, $errnum);
                         $sqlObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_MESSAGE, $errmsg);
                         $Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $sqlObject, array($multipart));
                         //Use what's on quickbooks, and trash whatever is here.
                     } else {
                         $multipart = array(QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ident);
                         $sqlObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_NUMBER, $errnum);
                         $sqlObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_MESSAGE, $errmsg);
                         $Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $sqlObject, array($multipart));
                         // @TODO: Raise Notification that the conflicts level requires writing to SQL table, but Mode disallows this
                     }
                     break;
                 case QUICKBOOKS_SERVER_SQL_CONFLICT_SQL:
                     // Updates the EditSequence without marking the row as resynced.
                     $tmpSQLObject = new QuickBooks_SQL_Object($table, null);
                     $tmpSQLObject->set("EditSequence", $EditSequence);
                     $Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $tmpSQLObject, array($multipart));
                     $Driver->queueEnqueue($user, QuickBooks_Utilities::convertActionToMod($action), $tmp->get(QUICKBOOKS_DRIVER_SQL_FIELD_ID), true, QUICKBOOKS_SERVER_SQL_CONFLICT_QUEUE_PRIORITY, $extra);
                     break;
                 case QUICKBOOKS_SERVER_SQL_CONFLICT_CALLBACK:
                     break;
                 default:
                     break;
             }
             break;
         default:
             if (strstr($xml, 'statusSeverity="Info"') === false) {
                 //
             }
             break;
     }
     // Please don't change this, it stops us from knowing what's actually
     //	going wrong. If an error occurs, we should either catch it if it's
     //	recoverable, or treated as a fatal error so we know about it and
     //	can address it later.
     //return false;
     return true;
 }
コード例 #17
0
ファイル: Payments.php プロジェクト: rnewton/quickbooks-php
 protected function _http($Context, $url_path, $raw_body)
 {
     $method = 'GET';
     if ($raw_body) {
         $method = 'POST';
     }
     $url = $this->_getBaseURL() . $url_path;
     $authcreds = $Context->authcreds();
     $params = array();
     $OAuth = new QuickBooks_IPP_OAuth($this->_oauth_consumer_key, $this->_oauth_consumer_secret);
     $signed = $OAuth->sign($method, $url, $authcreds['oauth_access_token'], $authcreds['oauth_access_token_secret'], $params);
     //print_r($signed);
     $HTTP = new QuickBooks_HTTP($signed[2]);
     $headers = array('Content-Type' => 'application/json', 'Request-Id' => QuickBooks_Utilities::GUID());
     $HTTP->setHeaders($headers);
     // Turn on debugging for the HTTP object if it's been enabled in the payment processor
     $HTTP->useDebugMode($this->_debug);
     //
     $HTTP->setRawBody($raw_body);
     $HTTP->verifyHost(false);
     $HTTP->verifyPeer(false);
     if ($method == 'POST') {
         $return = $HTTP->POST();
     } else {
         if ($method == 'GET') {
             $return = $HTTP->GET();
         } else {
             $return = null;
             // ERROR
         }
     }
     $this->_last_request = $HTTP->lastRequest();
     $this->_last_response = $HTTP->lastResponse();
     //
     $this->log($HTTP->getLog(), QUICKBOOKS_LOG_DEBUG);
     $info = $HTTP->lastInfo();
     print "Info: ";
     print_r($info);
     $errnum = $HTTP->errorNumber();
     $errmsg = $HTTP->errorMessage();
     if ($errnum) {
         // An error occurred!
         $this->_setError(QuickBooks_Payments::ERROR_HTTP, $errnum . ': ' . $errmsg);
         return false;
     }
     if ($info['http_code'] == 401) {
         $this->_setError(QuickBooks_Payments::ERROR_AUTH, 'Payments return a 401 Unauthorized status.');
         return false;
     }
     // Everything is good, return the data!
     $this->_setError(QuickBooks_Payments::ERROR_OK, '');
     return $return;
 }
コード例 #18
0
//	large that the transfer takes a long time, the Web Connector times out, or
//	the HTTP server throws an error after receiving to much data.
//
//	Thus, instead of sending just a single request, we're going to fetch the
//	list of customers by date range instead.
$seconds_in_a_day = 60 * 60 * 24;
for ($i = strtotime('2009-04-07'); $i < time(); $i = $i + $seconds_in_a_day) {
    $search = array('FromModifiedDate' => QuickBooks_Utilities::datetime($i), 'ToModifiedDate' => QuickBooks_Utilities::datetime($i + $seconds_in_a_day));
    if ($API->searchCustomers($search, '_quickbooks_ca_customer_search_callback')) {
        print 'Fetch customers from: ' . $search['FromModifiedDate'] . ' to ' . $search['ToModifiedDate'] . "\n";
    }
}
// Get a complete list of "Invoices" from QuickBooks
$seconds_in_a_day = 60 * 60 * 24;
for ($i = strtotime('2009-04-07'); $i < time(); $i = $i + $seconds_in_a_day) {
    $search = array('ModifiedDateRangeFilter FromModifiedDate' => QuickBooks_Utilities::datetime($i), 'ModifiedDateRangeFilter ToModifiedDate' => QuickBooks_Utilities::datetime($i + $seconds_in_a_day));
    if ($API->searchInvoices($search, '_quickbooks_ca_invoice_search_callback')) {
        print 'Fetch invoices from: ' . $search['ModifiedDateRangeFilter FromModifiedDate'] . ' to ' . $search['ModifiedDateRangeFilter ToModifiedDate'] . "\n";
    }
}
// Fetch a specific customer from QuickBooks by Name
//
// We're going to query QuickBooks for a customer named "Keith Palmer".
//	The query will be executed against QuickBooks and the function named
//	"_quickbooks_ca_customer_getbyname_callback" will be called with an
//	Iterator object. The Iterator will either be empty (there is no customer by
//	the name of "Keith Palmer") or contain Keith's complete customer record.
//
// Pretend for a minute that we actually have "Keith Palmer" in our own web
//	application, and what we'd really like to do is check if he exists in
//	QuickBooks, and then create a mapping so we know that Keith's primate key
コード例 #19
0
ファイル: Oe.php プロジェクト: rme/pm2qb
 /**
  * 
  * 
  * 
  * @param string $message
  * @param integer $level
  * @return boolean
  */
 protected function _log($message, $level = QUICKBOOKS_LOG_NORMAL)
 {
     if ($this->_masking) {
         // Mask credit card numbers, session tickets, and connection tickets
         $message = QuickBooks_Utilities::mask($message);
     }
     if ($this->_debug) {
         print $message . QUICKBOOKS_CRLF;
     }
     if ($this->_driver) {
         $this->_driver->log($message, $this->_ticket_session, $level);
     }
     return true;
 }
コード例 #20
0
ファイル: example_api_server.php プロジェクト: rme/pm2qb
/**
 * This function is called as a result of an ->addReceivePayment() method call
 *
 *
 */
function _quickbooks_ca_payment_add_callback($method, $action, $ID, &$err, $qbxml, $Payment, $resource)
{
    global $dsn;
    QuickBooks_Utilities::log($dsn, 'Added payment: ' . print_r($Payment, true));
}
コード例 #21
0
 /**
  * Create a new MySQL back-end driver
  * 
  * @param string $dsn		A DSN-style connection string (i.e.: "mysql://*****:*****@your-mysql-host:port/your-mysql-database")
  * @param array $config		Configuration options for the driver (not currently supported)
  */
 public function __construct($dsn_or_conn, $config)
 {
     $config = $this->_defaults($config);
     $this->_log_level = (int) $config['log_level'];
     if (is_resource($dsn_or_conn)) {
         $this->_conn = $dsn_or_conn;
     } else {
         $defaults = array('scheme' => 'mysql', 'host' => 'localhost', 'port' => 3306, 'user' => 'root', 'pass' => '', 'path' => '/quickbooks');
         $parse = QuickBooks_Utilities::parseDSN($dsn_or_conn, $defaults);
         $this->_connect($parse['host'], $parse['port'], $parse['user'], $parse['pass'], substr($parse['path'], 1), $config['new_link'], $config['client_flags']);
     }
     // Call the parent constructor too
     parent::__construct($dsn_or_conn, $config);
 }
コード例 #22
0
<?php

require_once '../../QuickBooks.php';
$out = QuickBooks_Utilities::actionToObject('VendorCreditAdd');
print "\n\n" . $out . "\n\n";
//$out = QuickBooks_Utilities::actionToObject('VendorAdd');
//print("\n\n" . $out . "\n\n");
//print_r(QuickBooks_Utilities::listObjects());
コード例 #23
0
				$CustomerID AS ListObjID, 
				ordbillemail AS DataExtValue
			FROM
				isc_orders
			WHERE
				orderid = SUBSTRING($CustomerID, 3) AND 
				$CustomerID LIKE \'O:%\'
		) '), 'orderitem_additional_queries' => array(0 => '
			SELECT 
				ordershipmodule AS ShipMethodID, 
				(ordhandlingcost + ordshipcost) AS Amount,
				CONCAT(\'Shipping and Handling: \', ordshipmethod) AS Descrip,
				\'' . QUICKBOOKS_NONTAXABLE . '\' AS SalesTaxCodeName
			FROM
				isc_orders
			WHERE
				orderid = $OrderID', 1 => '
			SELECT
				CONCAT(\'Billing phone number: \', ordbillphone, \', Shipping phone number: \', ordshipphone) AS Descrip
			FROM
				isc_orders
			WHERE
				orderid = $OrderID '));
$callback_options = array();
if (!QuickBooks_Utilities::initialized($dsn)) {
    QuickBooks_Utilities::initialize($dsn);
    QuickBooks_Utilities::createUser($dsn, $user, $pass);
}
//
$Server = new QuickBooks_Server_Integrator_Interspire($dsn, $integrator_dsn, $alert, $user, $map, $onerror, $hooks, $log_level, $soap, $wsdl, $soap_options, $handler_options, $driver_options, $api_options, $source_options, $integrator_options, $callback_options);
$Server->handle(true, true);
コード例 #24
0
 /**
  * ReceiveResponseXML() method for the QuickBooks Web Connector - Receive and handle a resonse form QuickBooks 
  * 
  * The stdClass object passed as a parameter will have the following members: 
  * 	- ->ticket 		The QuickBooks Web Connector ticket
  * 	- ->response	An XML response message
  * 	- ->hresult		Error code
  * 	- ->message		Error message
  * 
  * The sole data member of the returned object should be an integer. 
  * 	- The data member should be -1 if an error occured and QBWC should call ->getLastError()
  * 	- Should be an integer 0 <= x < 100 to indicate success *and* that the application should continue to call ->sendRequestXML() at least one more time (more queued items still in the queue, the integer represents the percentage complete the total batch job is)
  * 	- Should be 100 to indicate success *and* that the queue has been exhausted
  * 
  * The following user-defined hooks are invoked:
  * 	- QUICKBOOKS_HANDLERS_HOOK_RECEIVERESPONSEXML
  * 
  * @param stdClass $obj
  * @return QuickBooks_Result_ReceiveResponseXML
  */
 public function receiveResponseXML($obj)
 {
     $this->_driver->log('receiveResponseXML()', $obj->ticket, QUICKBOOKS_LOG_VERBOSE);
     if ($this->_driver->authCheck($obj->ticket)) {
         $user = $this->_driver->authResolve($obj->ticket);
         $hookdata = array('username' => $user, 'ticket' => $obj->ticket);
         $hookerr = '';
         $this->_callHook($obj->ticket, QUICKBOOKS_HANDLERS_HOOK_RECEIVERESPONSEXML, null, null, null, null, $hookerr, null, array(), $hookdata);
         $this->_driver->log('Incoming XML response: ' . $obj->response, $obj->ticket, QUICKBOOKS_LOG_DEBUG);
         // Check if we got a error message...
         if (strlen($obj->message) or $this->_extractStatusCode($obj->response)) {
             if ($requestID = $this->_extractRequestID($obj->response)) {
                 $errnum = $this->_extractStatusCode($obj->response);
                 //$action = current(explode('|', $requestID));
                 //$ident = next(explode('|', $requestID));
                 $action = '';
                 $ident = '';
                 $this->_parseRequestID($requestID, $action, $ident);
                 // Fetch the request that was processed and EXPERIENCED AN ERROR!
                 $extra = '';
                 if ($current = $this->_driver->queueFetch($user, $action, $ident, QUICKBOOKS_STATUS_PROCESSING)) {
                     if ($current['extra']) {
                         $extra = unserialize($current['extra']);
                     }
                 }
                 if ($obj->message) {
                     $errmsg = $obj->message;
                 } else {
                     if ($status = $this->_extractStatusMessage($obj->response)) {
                         $errmsg = $status;
                     }
                 }
                 $errerr = '';
                 $continue = $this->_handleError($obj->ticket, $errnum, $errmsg, $requestID, $action, $ident, $extra, $errerr, $obj->response, array());
                 //					$errnum, $errmsg, $requestID, $action, $ident, $extra, &$err, $xml, $qb_identifiers = array()
                 if ($errerr) {
                     // The error handler returned an error too...
                     $this->_driver->log('An error occured while handling quickbooks error ' . $errnum . ': ' . $errmsg . ': ' . $errerr, $obj->ticket, QUICKBOOKS_LOG_NORMAL);
                 }
             } else {
                 $errerr = '';
                 $continue = $this->_handleError($obj->ticket, $obj->hresult, $obj->message, null, null, null, null, $errerr, $obj->response, array());
                 if ($errerr) {
                     // The error handler returned an error too...
                     $this->_driver->log('An error occured while handling generic error ' . $obj->hresult . ': ' . $obj->message . ': ' . $errerr, $obj->ticket, QUICKBOOKS_LOG_NORMAL);
                 }
             }
             // Calculate the percentage done
             $progress = $this->_calculateProgress($obj->ticket);
             if (!$continue) {
                 $progress = -1;
             }
             $this->_driver->log('Transaction error at ' . $progress . '% complete... ', $obj->ticket, QUICKBOOKS_LOG_VERBOSE);
             return new QuickBooks_Result_ReceiveResponseXML($progress);
         }
         $action = null;
         $ident = null;
         $requestID = null;
         if ($requestID = $this->_extractRequestID($obj->response)) {
             //$action = current(explode('|', $requestID));
             //$ident = end(explode('|', $requestID));
             $action = '';
             $ident = '';
             $this->_parseRequestID($requestID, $action, $ident);
             // Fetch the request that's being processed
             $extra = '';
             if ($current = $this->_driver->queueFetch($user, $action, $ident, QUICKBOOKS_STATUS_PROCESSING)) {
                 if ($current['extra']) {
                     $extra = unserialize($current['extra']);
                 }
             }
             // Update the status to success (no error occured)
             $this->_driver->queueStatus($obj->ticket, $action, $ident, QUICKBOOKS_STATUS_SUCCESS);
         }
         // Extract ListID, TxnID, etc. from the response
         $identifiers = $this->_extractIdentifiers($obj->response);
         //$this->_driver->log(var_export($identifiers, true), $obj->ticket, QUICKBOOKS_LOG_VERBOSE);
         // Auto-map $ident unique identifier from web application to the QuickBooks ListID or TxnID
         if ($this->_config['map_application_identifiers']) {
             $adds = QuickBooks_Utilities::listActions('*Add*');
             $mods = QuickBooks_Utilities::listActions('*Mod*');
             $qbkey = QuickBooks_Utilities::keyForAction($action);
             $type = QuickBooks_Utilities::actionToObject($action);
             $EditSequence = '';
             if (isset($identifiers['EditSequence'])) {
                 $EditSequence = $identifiers['EditSequence'];
             }
             if (in_array($action, $adds) and isset($identifiers[$qbkey]) and $type) {
                 // Try to map the $ident to the QuickBooks identifier
                 $this->_driver->identMap($user, $type, $ident, $identifiers[$qbkey], $EditSequence);
             } else {
                 if (in_array($action, $mods) and isset($identifiers[$qbkey]) and $type) {
                     // Try to map the $ident to the QuickBooks identifier
                     $this->_driver->identMap($user, $type, $ident, $identifiers[$qbkey], $EditSequence);
                 }
             }
         }
         $err = null;
         $last_action_time = $this->_driver->queueActionLast($user, $action);
         $last_actionident_time = $this->_driver->queueActionIdentLast($user, $action, $ident);
         $this->_callMappedFunction(1, $user, $action, $ident, $extra, $err, $last_action_time, $last_actionident_time, $obj->response, $identifiers);
         // Calculate the percentage done
         $progress = $this->_calculateProgress($obj->ticket);
         if ($err) {
             $errerr = '';
             $continue = $this->_handleError($obj->ticket, QUICKBOOKS_ERROR_HANDLER, $err, $requestID, $action, $ident, $extra, $errerr, $obj->response, $identifiers);
             if (!$continue) {
                 $progress = -1;
             }
         }
         $this->_driver->log($progress . '% complete... ', $obj->ticket, QUICKBOOKS_LOG_VERBOSE);
         return new QuickBooks_Result_ReceiveResponseXML($progress);
     }
     return new QuickBooks_Result_ReceiveResponseXML(-1);
 }
コード例 #25
0
ファイル: IPP.php プロジェクト: rnewton/quickbooks-php
 /**
  * 
  * 
  * 
  * @param string $message
  * @param integer $level
  * @return boolean
  */
 protected function _log($message, $level = QUICKBOOKS_LOG_NORMAL)
 {
     if ($this->_masking) {
         $message = QuickBooks_Utilities::mask($message);
     }
     if ($this->_debug) {
         print $message . QUICKBOOKS_CRLF;
     }
     if ($this->_driver) {
         //die('logging to driver: [' . $level . ']');
         // Send it to the driver to be logged
         $this->_driver->log($message, null, $level);
     }
     return true;
 }
コード例 #26
0
ファイル: config.php プロジェクト: djeraseit/quickbooks-php
// This is the menu URL script
$quickbooks_menu_url = 'http://quickbooks.v3.com:8888/quickbooks-php/docs/partner_platform/example_app_ipp_v3/menu.php';
// This is a database connection string that will be used to store the OAuth credentials
// $dsn = 'pgsql://*****:*****@hostname/database';
// $dsn = 'mysql://*****:*****@hostname/database';
$dsn = 'mysqli://*****:*****@localhost/example_app_ipp_v3';
// You should set this to an encryption key specific to your app
$encryption_key = 'bcde1234';
// Do not change this unless you really know what you're doing!!!  99% of apps will not require a change to this.
$the_username = '******';
// The tenant that user is accessing within your own app
$the_tenant = 12345;
// Initialize the database tables for storing OAuth information
if (!QuickBooks_Utilities::initialized($dsn)) {
    // Initialize creates the neccessary database schema for queueing up requests and logging
    QuickBooks_Utilities::initialize($dsn);
}
// Instantiate our Intuit Anywhere auth handler
//
// The parameters passed to the constructor are:
//	$dsn
//	$oauth_consumer_key		Intuit will give this to you when you create a new Intuit Anywhere application at AppCenter.Intuit.com
//	$oauth_consumer_secret	Intuit will give this to you too
//	$this_url				This is the full URL (e.g. http://path/to/this/file.php) of THIS SCRIPT
//	$that_url				After the user authenticates, they will be forwarded to this URL
//
$IntuitAnywhere = new QuickBooks_IPP_IntuitAnywhere($dsn, $encryption_key, $oauth_consumer_key, $oauth_consumer_secret, $quickbooks_oauth_url, $quickbooks_success_url);
// Are they connected to QuickBooks right now?
if ($IntuitAnywhere->check($the_username, $the_tenant) and $IntuitAnywhere->test($the_username, $the_tenant)) {
    // Yes, they are
    $quickbooks_is_connected = true;
コード例 #27
0
ファイル: Server.php プロジェクト: djeraseit/quickbooks-php
 /**
  * Log a message to the error/debug log
  *
  * @param string $msg
  * @param string $ticket
  * @param integer $level
  * @return boolean
  */
 protected function _log($msg, $ticket, $level = QUICKBOOKS_LOG_NORMAL)
 {
     $Driver = $this->_driver;
     $msg = QuickBooks_Utilities::mask($msg);
     if ($Driver) {
         return $Driver->log($msg, $ticket, $level);
     }
     return false;
 }
コード例 #28
0
ファイル: HTTP.php プロジェクト: scragz/quickbooks-php
 /**
  * 
  * 
  * 
  * @param string $message
  * @param integer $level
  * @return boolean
  */
 protected function _log($message)
 {
     if ($this->_masking) {
         $message = QuickBooks_Utilities::mask($message);
     }
     if ($this->_debug) {
         print $message . QUICKBOOKS_CRLF;
     }
     //
     $this->_log .= $message . QUICKBOOKS_CRLF;
     return true;
 }
コード例 #29
0
ファイル: Frontend.php プロジェクト: Edgargm87/efapcom
 /**
  * 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;
     }
 }
コード例 #30
0
 * 
 */
require_once 'QuickBooks.php';
$user = '******';
$source_type = QUICKBOOKS_API_SOURCE_WEB;
$api_driver_dsn = 'mysql://*****:*****@localhost/quickbooks_api';
//$api_driver_dsn = 'pgsql://pgsql@localhost/quickbooks';
$source_dsn = 'http://*****:*****@localhost/path/to/server.php';
$api_options = array();
$source_options = array();
$driver_options = array();
if (!QuickBooks_Utilities::initialized($api_driver_dsn)) {
    //
    QuickBooks_Utilities::initialize($api_driver_dsn);
    //
    QuickBooks_Utilities::createUser($api_driver_dsn, 'api', 'password');
}
$API = new QuickBooks_API($api_driver_dsn, $user, $source_type, $source_dsn, $api_options, $source_options, $driver_options);
// CUSTOMERS
$fname = 'Shannon ' . mt_rand();
$lname = 'Daniels';
$Customer = new QuickBooks_Object_Customer();
$Customer->setFirstName($fname);
$Customer->setLastName($lname);
$Customer->setShipAddress('56 Cowles Road', '', '', '', '', 'Willington', 'CT');
$Customer->setMiddleName('R');
$Customer->setSalutation('Mr.');
$Customer->setPhone('1.860.634.1602');
$API->addCustomer($Customer, '_quickbooks_customer_add_callback', 15);
// INVOICES
$Invoice = new QuickBooks_Object_Invoice();