Я использую примеры веб-коннектора, включенные в пакет Quickbooks-PHP для Quickbooks для Windows 2011, и он отлично работает для заказов на продажу, клиентов, товаров и счетов.Когда я пытаюсь включить заказы на покупку, я получаю эту ошибку итератора в разных точках процесса.Вот функции, которые я включил и отредактировал.
function _quickbooks_purchaseorder_import_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale){
$attr_iteratorID = '';
$attr_iterator = ' iterator="Start" ';
if (empty($extra['iteratorID']))
{
$last = _quickbooks_get_last_run($user, $action);
_quickbooks_set_last_run($user, $action);
_quickbooks_set_current_run($user, $action, $last);
}
else
{
$attr_iteratorID = ' iteratorID="' . $extra['iteratorID'] . '" ';
$attr_iterator = ' iterator="Continue" ';
$last = _quickbooks_get_current_run($user, $action);
}
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="' . $version . '"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<PurchaseOrderQueryRq ' . $attr_iterator . ' ' . $attr_iteratorID . '>
<MaxReturned>' . QB_QUICKBOOKS_MAX_RETURNED . '</MaxReturned>
<ModifiedDateRangeFilter>
<FromModifiedDate>2018-01-01T00:00:00</FromModifiedDate>
</ModifiedDateRangeFilter>
<IncludeLineItems>true</IncludeLineItems>
<OwnerID>0</OwnerID>
</PurchaseOrderQueryRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
Функция для ответа
function _quickbooks_purchaseorder_import_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents){
if (!empty($idents['iteratorRemainingCount']))
{
$Queue = QuickBooks_Queue_Singleton::getInstance();
$Queue->enqueue(QUICKBOOKS_IMPORT_PURCHASEORDER, null, QB_PRIORITY_PURCHASEORDER, array( 'iteratorID' => $idents['iteratorID'] ));
}
$errnum = 0;
$errmsg = '';
$Parser = new QuickBooks_XML_Parser($xml);
if ($Doc = $Parser->parse($errnum, $errmsg))
{
$Root = $Doc->getRoot();
$List = $Root->getChildAt('QBXML/QBXMLMsgsRs/PurchaseOrderQueryRs');
foreach ($List->children() as $PurchaseOrder)
{
$arr = array(
'TxnID' => $PurchaseOrder->getChildDataAt('PurchaseOrderRet TxnID'),
'TimeCreated' => $PurchaseOrder->getChildDataAt('PurchaseOrderRet TimeCreated'),
'TimeModified' => $PurchaseOrder->getChildDataAt('PurchaseOrderRet TimeModified'),
'RefNumber' => $PurchaseOrder->getChildDataAt('PurchaseOrderRet RefNumber'),
'Customer_ListID' => $PurchaseOrder->getChildDataAt('PurchaseOrderRet CustomerRef ListID'),
'Customer_FullName' => $PurchaseOrder->getChildDataAt('PurchaseOrderRet CustomerRef FullName'),
);
QuickBooks_Utilities::log(QB_QUICKBOOKS_DSN, 'Importing purchase order #' . $arr['RefNumber'] . ': ' . print_r($arr, true));
foreach ($arr as $key => $value)
{
$arr[$key] = mysql_real_escape_string($value);
}
mysql_query("
REPLACE INTO
purchaseorders
(
" . implode(", ", array_keys($arr)) . "
) VALUES (
'" . implode("', '", array_values($arr)) . "'
)") or die(trigger_error(mysql_error()));
mysql_query("DELETE FROM purchaseorder_lineitems WHERE TxnID = '" . mysql_real_escape_string($arr['TxnID']) . "' ") or die(trigger_error(mysql_error()));
foreach ($PurchaseOrder->children() as $Child)
{
if ($Child->name() == 'PurchaseOrderLineRet')
{
$PurchaseOrderLine = $Child;
$lineitem = array(
'TxnID' => $arr['TxnID'],
'TxnLineID' => $PurchaseOrderLine->getChildDataAt('PurchaseOrderLineRet TxnLineID'),
'Item_ListID' => $PurchaseOrderLine->getChildDataAt('PurchaseOrderLineRet ItemRef ListID'),
'Item_FullName' => $PurchaseOrderLine->getChildDataAt('PurchaseOrderLineRet ItemRef FullName'),
'Descrip' => $PurchaseOrderLine->getChildDataAt('PurchaseOrderLineRet Desc'),
'Quantity' => $PurchaseOrderLine->getChildDataAt('PurchaseOrderLineRet Quantity'),
'Rate' => $PurchaseOrderLine->getChildDataAt('PurchaseOrderLineRet Rate'),
);
foreach ($lineitem as $key => $value)
{
$lineitem[$key] = mysql_real_escape_string($value);
}
QuickBooks_Utilities::log(QB_QUICKBOOKS_DSN, ' - line item #' . $lineitem['TxnLineID'] . ': ' . print_r($lineitem, true));
mysql_query("
INSERT INTO
purchaseorder_lineitems
(
" . implode(", ", array_keys($lineitem)) . "
) VALUES (
'" . implode("', '", array_values($lineitem)) . "'
) ") or die(trigger_error(mysql_error()));
}
else if ($Child->name() == 'DataExtRet')
{
$DataExt = $Child;
$dataext = array(
'DataExtName' => $Child->getChildDataAt('DataExtRet DataExtName'),
'DataExtValue' => $Child->getChildDataAt('DataExtRet DataExtValue'),
);
QuickBooks_Utilities::log(QB_QUICKBOOKS_DSN, ' - custom field "' . $dataext['DataExtName'] . '": ' . $dataext['DataExtValue']);
}
}
}
}
return true;
}
Заранее спасибо за ваш ввод.