Exemple #1
0
 /**
  * 
  * 
  * @param
  * @param 
  * @return boolean
  */
 public function handle($return = false, $debug = false)
 {
     $this->_headers();
     // This is the *very first time the integration was run!*
     //	Orders *will not* be fetched from before this time!
     $type = null;
     $opts = null;
     $first_datetime = $this->_api->configRead(get_class($this), 'initial', $type, $opts);
     $first = false;
     if (!$first_datetime) {
         $first_datetime = date('Y-m-d H:i:s');
         $this->_api->configWrite(get_class($this), 'initial', $first_datetime);
         $first = true;
     }
     // The is the last time the integration was run!
     $type = null;
     $opts = null;
     $last_datetime = $this->_api->configRead(get_class($this), 'datetime', $type, $opts);
     if (!$last_datetime) {
         $last_datetime = date('Y-m-d H:i:s');
     }
     if (!empty($this->_integrator_config['debug_datetime'])) {
         $last_datetime = date('Y-m-d H:i:s', strtotime($this->_integrator_config['debug_datetime']));
         $first_datetime = date('Y-m-d H:i:s', strtotime($this->_integrator_config['debug_datetime']));
     }
     $force = false;
     /*
     $force = false;
     if (isset($_GET['OrderID']))
     {
     	$force = true;
     }
     */
     $this_datetime = date('Y-m-d H:i:s');
     if (strtotime($this_datetime) - strtotime($last_datetime) > QUICKBOOKS_SERVER_INTEGRATOR_RECUR or $first or $force) {
         $this->_api->log('Last integration timestamp: ' . $last_datetime . ', current timestamp: ' . $this_datetime, QUICKBOOKS_LOG_VERBOSE);
         // Do some integration routines
         $this->_integrate($last_datetime, $first_datetime, $first);
         $this->_api->configWrite(get_class($this), 'datetime', $this_datetime);
     } else {
         $this->_api->log('Integration was not due yet (only ' . (strtotime($this_datetime) - strtotime($last_datetime)) . ' seconds since last run)', QUICKBOOKS_LOG_DEVELOP);
     }
     // Call the parent handler
     return parent::handle($return, $debug);
 }
Exemple #2
0
require_once 'QuickBooks.php';
// Database DSN-style connection string which stores the queue and logging tables
$dsn = 'mysql://*****:*****@192.168.1.86/wf_HSU';
// This should match the user you used to queue things up with in the QuickBooks_API client
$user = '******';
// You can ignore these for now...
$map = array();
$onerror = array();
$hooks = array();
// Logging level
$log_level = QUICKBOOKS_LOG_DEVELOP;
//$log_level = QUICKBOOKS_LOG_VERBOSE;
//$log_level = QUICKBOOKS_LOG_NORMAL;
//$log_level = QUICKBOOKS_LOG_NONE;
// Create the server instance and handle any requests
$Server = new QuickBooks_Server_API($dsn, $user, $map, $onerror, $hooks, $log_level);
$Server->handle(true, true);
// The QuickBooks API will call your callback functions when the action or
//	event is processed by QuickBooks. As shown in the
//	docs/example_api_client*.php examples, whenever you make an API call you
//	provide the name of a callback function. Here, we define those callback
//	functions and make them operate on the data that is returned from
//	QuickBooks.
/**
 * This callback gets called when we fetch a customer by name 
 * 
 * This callback is attached to the API method $API->getCustomerByName(...) in 
 * the docs/example_api_client_canadian.php script. 
 * 
 * @param string $method	
 * @param string $action	The action type of method being executed (CustomerQuery)
<?php

if (function_exists('date_default_timezone_set')) {
    date_default_timezone_set('America/New_York');
}
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '/home/library_php');
require_once 'QuickBooks.php';
$dsn = 'mysql://*****:*****@localhost/quickbooks';
$map = array();
$onerror = array();
$hooks = array();
$log_level = QUICKBOOKS_LOG_DEVELOP;
$soap = QUICKBOOKS_SOAPSERVER_BUILTIN;
$Server = new QuickBooks_Server_API($dsn, $map, $onerror, $hooks, $log_level, $soap);
$Server->handle();
/**
 * 
 */
function _quickbooks_customer_add_callback($method, $action, $ID, $err, $qbxml, $qbobject, $qbres)
{
    if (is_object($qbobject)) {
        $fp = fopen('/home/kpalmer/logs/customer_add.log', 'w+');
        fwrite($fp, var_export($qbobject, true));
        fclose($fp);
        return true;
    }
    return false;
}
function _quickbooks_customer_get_callback($method, $action, $ID, $err, $qbxml, $qbiterator, $qbres)
{
    if (is_object($qbiterator)) {