foreach (explode(';', $contents) as $sql) { if (!trim($sql)) { continue; } mysql_query($sql) or die(trigger_error(mysql_error())); } } else { die('Could not locate "./example.sql" to create the demo SQL schema!'); } // QuickBooks_Utilities::initialize($api_driver_dsn); // This QuickBooks_Utilities::createUser($api_driver_dsn, $user, $pass); } // $API = new QuickBooks_API($api_driver_dsn, $user, $source_type, $source_dsn, $api_options, $source_options, $driver_options); // Get the complete list of "Customers" from QuickBooks // // Unfortunately, non-US versions of QuickBooks do not yet support the use of // "iterators" to break up the response from QuickBooks into many smaller // chunks. So, if we ask for the complete customer list, the response is so // 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";
public function addInventoryAdjustment($obj, $callback = null, $webapp_ID = null, $priority = null, $dependency = null) { if (is_null($priority) and !is_null($dependency)) { $priority = QuickBooks_API::priority(QUICKBOOKS_ADD_INVENTORYADJUSTMENT, $dependency); } $err = ''; return $this->_doAdd(__METHOD__, QUICKBOOKS_ADD_INVENTORYADJUSTMENT, QUICKBOOKS_OBJECT_INVENTORYADJUSTMENT, $obj, $callback, $webapp_ID, $priority, $err); }
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(); //$Invoice->setOther('test of other'); // for some reason this field doesn't work... $Invoice->setMemo('test of a memo');
public function encodeApplicationEditSequence($type, $tag, $ID) { return QuickBooks_API::encodeApplicationEditSequence($type, $tag, $ID); }
//ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '/Users/keithpalmerjr/Sites/QuickBooks_2008-07-05'); ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . realpath('../../')); require_once 'QuickBooks.php'; //require_once 'QuickBooks/Object/Invoice/InvoiceLine.php'; $user = '******'; $source_type = QUICKBOOKS_API_SOURCE_WEB; $api_driver_dsn = 'mysql://root:@localhost/quickbooks'; //$api_driver_dsn = 'pgsql://pgsql@localhost/quickbooks'; $source_dsn = 'http://*****:*****@localhost/path/to/server.php'; $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 = array(), $source_options = array(), $driver_options = array()); $fname = 'Shannon ' . mt_rand(1, 1000); $lname = 'Daniels'; $Customer = new QuickBooks_Object_Customer(); $Customer->setParentApplicationID(15); $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); $Invoice = new QuickBooks_Object_Invoice(); $Invoice->setOther('test of other'); $Invoice->setMemo('test of a memo'); $Invoice->setCustomerApplicationID(15);
/** * Try to guess the queueing priority for this action * * @param string $action The action you're trying to guess for * @param string $dependency If the action depends on another action (i.e. a DataExtAdd for a CustomerAdd) you can pass the dependency here * @return integer A best guess at the proper priority */ public static function priorityForAction($action, $dependency = null) { // low priorities up here (*lots* of dependencies) static $priorities = array(QUICKBOOKS_DEL_DATAEXT, QUICKBOOKS_MOD_DATAEXT, QUICKBOOKS_ADD_DATAEXT, QUICKBOOKS_MOD_RECEIVEPAYMENT, QUICKBOOKS_ADD_RECEIVEPAYMENT, QUICKBOOKS_MOD_BILLPAYMENTCHECK, QUICKBOOKS_ADD_BILLPAYMENTCHECK, QUICKBOOKS_ADD_BILLPAYMENTCREDITCARD, QUICKBOOKS_MOD_BILL, QUICKBOOKS_ADD_BILL, QUICKBOOKS_MOD_PURCHASEORDER, QUICKBOOKS_ADD_PURCHASEORDER, QUICKBOOKS_MOD_SALESORDER, QUICKBOOKS_ADD_SALESORDER, QUICKBOOKS_MOD_ESTIMATE, QUICKBOOKS_ADD_ESTIMATE, QUICKBOOKS_MOD_INVOICE, QUICKBOOKS_ADD_INVOICE, QUICKBOOKS_ADD_INVENTORYADJUSTMENT, QUICKBOOKS_ADD_RECEIPTITEM, QUICKBOOKS_MOD_RECEIPTITEM, QUICKBOOKS_MOD_SALESRECEIPT, QUICKBOOKS_ADD_SALESRECEIPT, QUICKBOOKS_ADD_SALESTAXITEM, QUICKBOOKS_MOD_SALESTAXITEM, QUICKBOOKS_ADD_DISCOUNTITEM, QUICKBOOKS_MOD_DISCOUNTITEM, QUICKBOOKS_ADD_OTHERCHARGEITEM, QUICKBOOKS_MOD_OTHERCHARGEITEM, QUICKBOOKS_MOD_NONINVENTORYITEM, QUICKBOOKS_ADD_NONINVENTORYITEM, QUICKBOOKS_MOD_INVENTORYITEM, QUICKBOOKS_ADD_INVENTORYITEM, QUICKBOOKS_MOD_SERVICEITEM, QUICKBOOKS_ADD_SERVICEITEM, QUICKBOOKS_MOD_SALESREP, QUICKBOOKS_ADD_SALESREP, QUICKBOOKS_MOD_EMPLOYEE, QUICKBOOKS_ADD_EMPLOYEE, QUICKBOOKS_ADD_SALESTAXCODE, QUICKBOOKS_MOD_VENDOR, QUICKBOOKS_ADD_VENDOR, QUICKBOOKS_MOD_CUSTOMER, QUICKBOOKS_ADD_CUSTOMER, QUICKBOOKS_MOD_ACCOUNT, QUICKBOOKS_ADD_ACCOUNT, QUICKBOOKS_ADD_CLASS, QUICKBOOKS_ADD_PAYMENTMETHOD, QUICKBOOKS_ADD_SHIPMETHOD, QUICKBOOKS_QUERY_PURCHASEORDER, QUICKBOOKS_QUERY_RECEIPTITEM, QUICKBOOKS_QUERY_SALESORDER, QUICKBOOKS_QUERY_SALESRECEIPT, QUICKBOOKS_QUERY_INVOICE, QUICKBOOKS_QUERY_ESTIMATE, QUICKBOOKS_QUERY_RECEIVEPAYMENT, QUICKBOOKS_QUERY_BILLPAYMENTCHECK, QUICKBOOKS_QUERY_BILLPAYMENTCREDITCARD, QUICKBOOKS_QUERY_BILLTOPAY, QUICKBOOKS_QUERY_BILL, QUICKBOOKS_QUERY_CREDITCARDCHARGE, QUICKBOOKS_QUERY_CREDITCARDCREDIT, QUICKBOOKS_QUERY_CHECK, QUICKBOOKS_QUERY_CHARGE, QUICKBOOKS_QUERY_DELETEDITEMS, QUICKBOOKS_QUERY_DELETEDTXNS, QUICKBOOKS_QUERY_TIMETRACKING, QUICKBOOKS_QUERY_VENDORCREDIT, QUICKBOOKS_QUERY_INVENTORYADJUSTMENT, QUICKBOOKS_QUERY_ITEM, QUICKBOOKS_QUERY_DISCOUNTITEM, QUICKBOOKS_QUERY_SALESTAXITEM, QUICKBOOKS_QUERY_SERVICEITEM, QUICKBOOKS_QUERY_NONINVENTORYITEM, QUICKBOOKS_QUERY_INVENTORYITEM, QUICKBOOKS_QUERY_SALESREP, QUICKBOOKS_QUERY_VEHICLEMILEAGE, QUICKBOOKS_QUERY_VEHICLE, QUICKBOOKS_QUERY_CUSTOMER, QUICKBOOKS_QUERY_VENDOR, QUICKBOOKS_QUERY_EMPLOYEE, QUICKBOOKS_QUERY_WORKERSCOMPCODE, QUICKBOOKS_QUERY_UNITOFMEASURESET, QUICKBOOKS_QUERY_JOURNALENTRY, QUICKBOOKS_QUERY_DEPOSIT, QUICKBOOKS_QUERY_SHIPMETHOD, QUICKBOOKS_QUERY_PAYMENTMETHOD, QUICKBOOKS_QUERY_PRICELEVEL, QUICKBOOKS_QUERY_DATEDRIVENTERMS, QUICKBOOKS_QUERY_BILLINGRATE, QUICKBOOKS_QUERY_CUSTOMERTYPE, QUICKBOOKS_QUERY_CUSTOMERMSG, QUICKBOOKS_QUERY_TERMS, QUICKBOOKS_QUERY_SALESTAXCODE, QUICKBOOKS_QUERY_ACCOUNT, QUICKBOOKS_QUERY_CLASS, QUICKBOOKS_QUERY_JOBTYPE, QUICKBOOKS_QUERY_VENDORTYPE, QUICKBOOKS_QUERY_COMPANY); // high priorities down here (no dependencies OR queries) // Now, let's space those priorities out a little bit, it gives us some // wiggle room in case we need to add things inbetween the default // priority values static $wiggled = false; $wiggle = 4; if (!$wiggled) { $count = count($priorities); for ($i = $count - 1; $i >= 0; $i--) { $priorities[$i * $wiggle] = $priorities[$i]; unset($priorities[$i]); // with a wiggle multiplier of 2... // priority 25 goes to 50 // priority 24 goes to 48 // priority 23 goes to 46 // etc. etc. etc. } $wiggled = true; //print_r($priorities); } if ($dependency) { // // This is a list of dependency modifications // For instance, normally, you'd want to send just any old DataExtAdd // with a really low priority, because whatever record it applies to // must be in QuickBooks before you send the DataExtAdd/Mod request. // // However, if we pass in the $dependency of QUICKBOOKS_ADD_CUSTOMER, // then we know that this DataExt applies to a CustomerAdd, and can // therefore be sent with a priority *just barely lower than* than a // CustomerAdd request, which will ensure this gets run as soon as // possible, but not sooner than the CustomerAdd. // // This is important because in some cases, this data will be // automatically used by QuickBooks. For instance, a custom field that // is placed on an Invoice *must already be populated for the // Customer* before the invoice is created. // // This priority list is without dependencies, and it's bad: // CustomerAdd, InvoiceAdd, DataExtAdd // (the custom field for the customer doesn't get populated in the invoice) // // This priority list is with dependencies, and it's good: // CustomerAdd, DataExtAdd, InvoiceAdd // $dependencies = array(QUICKBOOKS_ADD_DATAEXT => array(QUICKBOOKS_ADD_CUSTOMER => QuickBooks_API::priority(QUICKBOOKS_ADD_CUSTOMER) - 1, QUICKBOOKS_MOD_CUSTOMER => QuickBooks_API::priority(QUICKBOOKS_MOD_CUSTOMER) - 1), QUICKBOOKS_MOD_DATAEXT => array(QUICKBOOKS_ADD_CUSTOMER => QuickBooks_API::priority(QUICKBOOKS_ADD_CUSTOMER) - 1, QUICKBOOKS_MOD_CUSTOMER => QuickBooks_API::priority(QUICKBOOKS_MOD_CUSTOMER) - 1)); } // Check for dependency priorities if ($dependency and isset($dependencies[$action]) and isset($dependencies[$action][$dependency])) { // Dependency modified priority return $dependencies[$action][$dependency]; } else { if ($key = array_search($action, $priorities)) { // Regular priority return $key; } } // Default priority return 999; }
require_once 'QuickBooks.php'; //$user = '******'; $user = '******'; $source_type = QUICKBOOKS_API_SOURCE_WEB; //$api_driver_dsn = 'mysql://*****:*****@localhost/quickbooks_api'; $api_driver_dsn = 'mysql://*****:*****@192.168.1.86/wf_HSU'; //$api_driver_dsn = 'pgsql://pgsql@localhost/quickbooks'; $source_dsn = 'http://*****:*****@localhost/qb/HSU/example_api_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); $dac = $_REQUEST["dac"]; $dam = $_REQUEST["dam"]; $cac = $_REQUEST["cac"]; $cam = $_REQUEST["cam"]; //------------------------------------------------------------------------------------------------------------------------------- // Journal entry $JournalEntry = new QuickBooks_Object_JournalEntry(); $dDate = date("F d, Y"); //$JournalEntry->setTransactionDate('July 23, 2012'); $JournalEntry->setTransactionDate($dDate); $DebitLine = new QuickBooks_Object_JournalEntry_JournalDebitLine(); //$DebitLine->setAccountName('Travel Expense'); //$JournalEntry->addDebitLine($DebitLine); $DebitLine->setAccountName($dac); $DebitLine->setAmount($dam);
// $api_driver_dsn = 'pgsql://pgsql@localhost/quickbooks_onlineedition'; // This is not applicable to QBOE $source_dsn = null; // Various API options $api_options = array(); // Options for QBOE $source_options = array('certificate' => '/Users/kpalmer/Projects/QuickBooks/QuickBooks/dev/test_qboe.pem', 'connection_ticket' => 'TGT-47-1sRm2nXMVfm$n8hb2MZfVQ', 'application_login' => 'test.www.academickeys.com', 'application_id' => '134476472'); // Driver options $driver_options = array(); // If you want to log requests/responses to a database, initialize the database if ($api_driver_dsn and !QuickBooks_Utilities::initialized($api_driver_dsn)) { QuickBooks_Utilities::initialize($api_driver_dsn); QuickBooks_Utilities::createUser($api_driver_dsn, $username, $password); } // Create the API instance $API = new QuickBooks_API($api_driver_dsn, $username, $source_type, $source_dsn, $api_options, $source_options, $driver_options); // Turn on debugging mode //$API->useDebugMode(true); // With QuickBooks Online Edition, the API can return values to you rather than // using callback functions to return values. Remember that is you use this, // your code will be less portable to systems using non-real-time connections // (i.e. the QuickBooks Web Connector). //$API->enableRealtime(true); // Let's get some general information about this connection to QBOE: print 'Our connection ticket is: ' . $API->connectionTicket() . "\n"; print 'Our session ticket is: ' . $API->sessionTicket() . "\n"; print 'Our application id is: ' . $API->applicationID() . "\n"; print 'Our application login is: ' . $API->applicationLogin() . "\n"; print "\n"; print 'Last error number: ' . $API->errorNumber() . "\n"; print 'Last error message: ' . $API->errorMessage() . "\n";
//require_once 'QuickBooks/Object/Invoice/InvoiceLine.php'; $user = '******'; $source_type = QUICKBOOKS_API_SOURCE_WEB; $api_driver_dsn = 'mysql://*****:*****@localhost/quickbooks'; //$api_driver_dsn = 'pgsql://pgsql@localhost/quickbooks'; $source_dsn = 'http://*****:*****@localhost/path/to/server.php'; $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_options = array('qbxml_version' => 'CA3.0'); $source_options = array(); $driver_options = array(); $API = new QuickBooks_API($api_driver_dsn, $user, $source_type, $source_dsn, $api_options, $source_options, $driver_options); $fname = 'Shannon ' . mt_rand(1, 1000); $lname = 'Daniels'; $Customer = new QuickBooks_Object_Customer(); $Customer->setFirstName($fname); $Customer->setLastName($lname); $Customer->setShipAddress('56 Cowles Road', '', '', '', '', 'Willington', '', 'Quebec', 'Canada'); $Customer->setMiddleName('R'); $Customer->setSalutation('Mr.'); $Customer->setPhone('1.860.634.1602'); $API->addCustomer($Customer, '_quickbooks_customer_add_callback', 15); $Class = new QuickBooks_Object_Class(); $Class->setName('My Test Class ' . mt_rand()); $API->addClass($Class, 'callback', 15); function my_customer_callback() {
protected static function _decodeApplicationEditSequence($encode, &$type, &$tag, &$ID) { return QuickBooks_API::decodeApplicationEditSequence($encode, $type, $tag, $ID); }