示例#1
0
/**
 * 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)
 * @param mixed $ID			The primary key of the customer you tried to fetch
 * @param string $err		If an error occurs, you should pass back the error message here
 * @param string $qbxml		The raw qbXML response from QuickBooks
 * @param QuickBooks_API_Iterator
 * @param resource $resource	
 * @return void
 */
function _quickbooks_ca_customer_getbyname_callback($method, $action, $ID, &$err, $qbxml, $Iterator, $resource)
{
    global $dsn;
    global $user;
    if (is_object($Iterator) and $Iterator->count() > 0) {
        // We found a record matching this name, let's build a mapping of the
        //	primary key in QuickBooks to the primary key in our own application
        //
        //	The primary key in QuickBooks for anything transaction related
        //	(invoices, sales receipts, payments, etc.) is "TxnID", while the
        //	primary key in QuickBooks for anything non-transaction related
        //	(customers, sales tax codes, items, vendors, etc.) is "ListID"
        // Fetch the first item from the Iterator
        $Customer = $Iterator->next();
        // Build your own mapping...
        // mysql_query("INSERT INTO my_mapping_table ( qbType, qbListID_or_TxnID, application_primary_key ) VALUES ( 'Customer', '" . mysql_real_escape_string($Customer->getListID()) . "', " . (int) $ID . " ) ");
        // ... or use the built-in mapping methods
        QuickBooks_Utilities::createMapping($dsn, $user, QUICKBOOKS_OBJECT_CUSTOMER, $Customer->getListID(), $ID, $Customer->getEditSequence());
    } else {
        // No customer with that name was found
    }
}
示例#2
0
<?php

require_once '/home/library_php/QuickBooks.php';
$dsn = 'mysql://*****:*****@localhost/quickbooks';
$user = '******';
QuickBooks_Utilities::createMapping($dsn, $user, QUICKBOOKS_OBJECT_CUSTOMER, '1234-1234', 15);
print "\n";
print "\n";
print 'App ID: ' . QuickBooks_Utilities::fetchApplicationID($dsn, $user, QUICKBOOKS_OBJECT_CUSTOMER, '1234-1234');
print "\n";
print "\n";
print 'QB ID: ' . QuickBooks_Utilities::fetchQuickbooksID($dsn, $user, QUICKBOOKS_OBJECT_CUSTOMER, 15);
print "\n";
print "\n";