コード例 #1
0
<?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>
コード例 #2
0
<?php

require_once dirname(__FILE__) . '/config.php';
require_once dirname(__FILE__) . '/views/header.tpl.php';
?>

<pre>

<?php 
$ItemService = new QuickBooks_IPP_Service_Item();
// Get the existing item
$items = $ItemService->query($Context, $realm, "SELECT * FROM Item WHERE Id = '2' ");
$Item = $items[0];
// Update the name of the item
$Item->setName($Item->getName() . ' ' . mt_rand(0, 1000));
if ($resp = $ItemService->update($Context, $realm, $Item->getId(), $Item)) {
    print 'Updated the item name to ' . $Item->getName();
} else {
    print 'ERROR!';
    print $ItemService->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");
*/
?>