//	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
//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...?');
}
示例#3
0
    public static function ReceivePaymentQueryRequest($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale, $config = array())
    {
        $xml = '';
        //$iterator = QuickBooks_Callbacks_SQL_Callbacks::_buildIterator($extra);
        if (!QuickBooks_Callbacks_SQL_Callbacks::_requiredVersion(1.1, $version)) {
            return QUICKBOOKS_SKIP;
        }
        $tag1 = '';
        $tag2 = '';
        if (!empty($extra['TxnID'])) {
            $tag1 = '';
            $tag1 .= '<TxnID>' . $extra['TxnID'] . '</TxnID>';
        } else {
            if (!empty($extra['RefNumber'])) {
                $tag1 = '';
                $tag1 .= '<RefNumber>' . $extra['RefNumber'] . '</RefNumber>';
            } else {
                if (!empty($extra['Entity_FullName'])) {
                    $tag2 = '';
                    $tag2 .= '<MaxReturned>' . QUICKBOOKS_SERVER_SQL_ITERATOR_MAXRETURNED . '</MaxReturned>';
                    $tag2 .= '<EntityFilter>' . QUICKBOOKS_CRLF;
                    $tag2 .= "\t" . '<FullName>' . QuickBooks_Cast::cast(QUICKBOOKS_OBJECT_INVOICE, 'EntityFilter FullName', $extra['Entity_FullName']) . '</FullName>' . QUICKBOOKS_CRLF;
                    $tag2 .= '</EntityFilter>' . QUICKBOOKS_CRLF;
                } else {
                    if (!empty($extra['Entity_ListID'])) {
                        $tag2 = '';
                        $tag2 .= '<MaxReturned>' . QUICKBOOKS_SERVER_SQL_ITERATOR_MAXRETURNED . '</MaxReturned>';
                        $tag2 .= '<EntityFilter>' . QUICKBOOKS_CRLF;
                        $tag2 .= "\t" . '<ListID>' . $extra['Entity_ListID'] . '</ListID>' . QUICKBOOKS_CRLF;
                        $tag2 .= '</EntityFilter>' . QUICKBOOKS_CRLF;
                    } else {
                        if (!empty($extra['FromModifiedDate']) and !empty($extra['ToModifiedDate'])) {
                            $tag2 = '';
                            $tag2 .= '<MaxReturned>' . QUICKBOOKS_SERVER_SQL_ITERATOR_MAXRETURNED . '</MaxReturned>';
                            $tag2 .= '<ModifiedDateRangeFilter>' . QUICKBOOKS_CRLF;
                            $tag2 .= "\t" . '<FromModifiedDate>' . QuickBooks_Utilities::datetime($extra['FromModifiedDate']) . '</FromModifiedDate>' . QUICKBOOKS_CRLF;
                            $tag2 .= "\t" . '<ToModifiedDate>' . QuickBooks_Utilities::datetime($extra['ToModifiedDate']) . '</ToModifiedDate>' . QUICKBOOKS_CRLF;
                            $tag2 .= '</ModifiedDateRangeFilter>' . QUICKBOOKS_CRLF;
                        } else {
                            return QUICKBOOKS_NOOP;
                        }
                    }
                }
            }
        }
        $xml .= '<?xml version="1.0" encoding="utf-8"?>
			<?qbxml version="' . $version . '"?>
			<QBXML>
				<QBXMLMsgsRq onError="' . QUICKBOOKS_SERVER_SQL_ON_ERROR . '">
					<ReceivePaymentQueryRq>
						' . $tag1 . '
						' . $tag2 . '
						<IncludeLineItems>true</IncludeLineItems>
						' . QuickBooks_Callbacks_SQL_Callbacks::_requiredVersionForElement(2.0, $version, '<OwnerID>0</OwnerID>') . '
					</ReceivePaymentQueryRq>
				</QBXMLMsgsRq>
			</QBXML>';
        return $xml;
    }
示例#4
0
文件: API.php 项目: Edgargm87/efapcom
 public function listShipMethodsModifiedBetween($start_datetime, $end_datetime, $callback = null, $priority = null, $return = array(), $recur = null)
 {
     $obj = new QuickBooks_Object_ShipMethod();
     if (!is_null($start_datetime)) {
         $obj->set('FromModifiedDate', QuickBooks_Utilities::datetime($start_datetime));
     }
     if (!is_null($end_datetime)) {
         $obj->set('ToModifiedDate', QuickBooks_Utilities::datetime($end_datetime));
     }
     //$obj->set('IncludeRetElement', array( 'FullName', 'IsActive', 'AccountType', 'SpecialAccountType' ));
     $err = '';
     //						$method, $action, $type, $obj, $callbacks, $webapp_ID, $priority, &$err, $recur
     return $this->_doQuery(__METHOD__, QUICKBOOKS_QUERY_SHIPMETHOD, QUICKBOOKS_OBJECT_SHIPMETHOD, $obj, $callback, null, $priority, $err, $recur);
 }
示例#5
0
$creds = $IntuitAnywhere->load($the_username, $the_tenant);
// Tell the framework to load some data from the OAuth store
$IPP->authMode(QuickBooks_IPP::AUTHMODE_OAUTH, $the_username, $creds);
// Print the credentials we're using
//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);
    $CDCService = new QuickBooks_IPP_Service_ChangeDataCapture();
    // What types of objects do you want to get?
    $objects = array('Customer', 'Invoice');
    // The date they should have been updated after
    $timestamp = QuickBooks_Utilities::datetime('-5 years');
    $cdc = $CDCService->cdc($Context, $realm, $objects, $timestamp);
    print '<h2>Here are the ' . implode(', ', $objects) . ' that have changed since ' . $timestamp . '</h2>';
    foreach ($cdc as $object_type => $list) {
        print '<h3>Now showing ' . $object_type . 's</h3>';
        foreach ($list as $Object) {
            switch ($object_type) {
                case 'Customer':
                    print ' &nbsp; ' . $Object->getFullyQualifiedName() . '<br>';
                    break;
                case 'Invoice':
                    print ' &nbsp; ' . $Object->getDocNumber() . '<br>';
                    break;
                default:
                    print ' &nbsp; ' . $Object->getId() . '<br>';
                    break;