protected function _void($Context, $realmID, $resource, $ID) { // v3 only $IPP = $Context->IPP(); // Get the object first... because IDS is stupid and wants us to send // the entire object even though we know the Id of the object that we // want to delete... *sigh* $objects = $this->_query($Context, $realmID, "SELECT * FROM " . $resource . " WHERE Id = '" . QuickBooks_IPP_IDS::usableIDType($ID) . "' "); if (isset($objects[0]) and is_object($objects[0])) { $Object = $objects[0]; $unsets = array(); foreach ($unsets as $unset) { $Object->remove($unset); } // Generate the XML $xml = $Object->asXML(0, null, null, null, QuickBooks_IPP_IDS::VERSION_3); //die($xml); // Send the data to IPP $return = $IPP->IDS($Context, $realmID, $resource, QuickBooks_IPP_IDS::OPTYPE_VOID, $xml); $this->_setLastRequestResponse($Context->lastRequest(), $Context->lastResponse()); $this->_setLastDebug($Context->lastDebug()); //print('erro code: [' . $IPP->errorCode() . ']' . "\n"); //print("\n\n\n\n\n" . $Context->lastResponse() . "\n\n\n\n\n"); if ($IPP->errorCode() != QuickBooks_IPP::ERROR_OK) { $this->_setError($IPP->errorCode(), $IPP->errorText(), $IPP->errorDetail()); return false; } return true; } $this->_setError(QuickBooks_IPP::ERROR_INTERNAL, 'Could not find ' . $resource . ' ' . QuickBooks_IPP_IDS::usableIDType($ID) . ' to void.', 'Could not find ' . $resource . ' ' . QuickBooks_IPP_IDS::usableIDType($ID) . ' to void.'); return false; }
// 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); $CustomerService = new QuickBooks_IPP_Service_Customer(); $InvoiceService = new QuickBooks_IPP_Service_Invoice(); $customers = $CustomerService->query($Context, $realm, "SELECT * FROM Customer WHERE FamilyName = 'Palmer' "); //print_r($customers); if (count($customers)) { foreach ($customers as $Customer) { print 'Customer Id=' . $Customer->getId() . ' is named: ' . $Customer->getFullyQualifiedName() . '<br>'; $invoices = $InvoiceService->query($Context, $realm, "SELECT * FROM Invoice WHERE CustomerRef = '" . QuickBooks_IPP_IDS::usableIDType($Customer->getId()) . "' "); /* print("\n\n\n\n"); print('Request [' . $IPP->lastRequest() . ']'); print("\n\n\n\n"); print('Response [' . $IPP->lastResponse() . ']'); print("\n\n\n\n"); exit; */ if (count($invoices)) { foreach ($invoices as $Invoice) { print ' Invoice #' . $Invoice->getDocNumber() . ' on date ' . $Invoice->getTxnDate() . '<br>'; } } else { print ' This customer has no invoices.<br>'; }
<?php $InvoiceService = new QuickBooks_IPP_Service_Invoice(); $ItemService = new QuickBooks_IPP_Service_Item(); $invoices = $InvoiceService->query($Context, $realm, "SELECT *, Line.* FROM Invoice STARTPOSITION 1 MAXRESULTS 5"); //print_r($customers); foreach ($invoices as $Invoice) { $num_lines = $Invoice->countLine(); // How many line items are there? for ($i = 0; $i < $num_lines; $i++) { $Line = $Invoice->getLine($i); // Let's find out what item this uses if ($Line->getDetailType() == 'SalesItemLineDetail') { $Detail = $Line->getSalesItemLineDetail(); $item_id = $Detail->getItemRef(); print 'Item id is: ' . $item_id . "\n"; $items = $ItemService->query($Context, $realm, "SELECT * FROM Item WHERE Id = '" . QuickBooks_IPP_IDS::usableIDType($item_id) . "' "); print ' That item is named: ' . $items[0]->getName() . "\n"; } } print "\n\n\n"; } /* print("\n\n\n\n"); print('Request [' . $IPP->lastRequest() . ']'); print("\n\n\n\n"); print('Response [' . $IPP->lastResponse() . ']'); print("\n\n\n\n"); */ ?> </pre>
public function setTxnId($Id) { return $this->set('TxnId', QuickBooks_IPP_IDS::usableIDType($Id)); }