本文整理汇总了PHP中QuickBooks_Utilities::actionToXMLElement方法的典型用法代码示例。如果您正苦于以下问题:PHP QuickBooks_Utilities::actionToXMLElement方法的具体用法?PHP QuickBooks_Utilities::actionToXMLElement怎么用?PHP QuickBooks_Utilities::actionToXMLElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QuickBooks_Utilities
的用法示例。
在下文中一共展示了QuickBooks_Utilities::actionToXMLElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catchall
/**
* @TODO Change this to return false by default, and only catch the specific errors we're concerned with.
*
*/
public static function catchall($requestID, $user, $action, $ident, $extra, &$err, $xml, $errnum, $errmsg, $config)
{
$Driver = QuickBooks_Driver_Singleton::getInstance();
/*
$Parser = new QuickBooks_XML($xml);
$errnumTemp = 0;
$errmsgTemp = '';
$Doc = $Parser->parse($errnumTemp, $errmsgTemp);
$Root = $Doc->getRoot();
$emailStr = var_export($Root->children(), true);
$List = $Root->getChildAt('QBXML QBXMLMsgsRs '.QuickBooks_Utilities::actionToResponse($action));
$Node = current($List->children());
*/
$map = array();
$others = array();
QuickBooks_SQL_Schema::mapToSchema(trim(QuickBooks_Utilities::actionToXMLElement($action)), QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $map, $others);
$sqlObject = new QuickBooks_SQL_Object($map[0], trim(QuickBooks_Utilities::actionToXMLElement($action)));
$table = $sqlObject->table();
switch ($errnum) {
case 1:
// These errors occur when we search for something and it doesn't exist
// These errors occur when we search for something and it doesn't exist
case 500:
// i.e. we query for invoices modified since xyz, but there are none that have been modified since then
// This isn't really an error, just ignore it
return true;
case 1000:
// An internal error occured
// @todo Hopefully at some point we'll have a better idea of how to handle this error...
return true;
case 3200:
// Ignore EditSequence errors (the record will be picked up and a conflict reported next time it runs... maybe?)
// @todo Think about this one more
return true;
case 3250:
// This feature is not enabled or not available in this version of QuickBooks.
// Do nothing (this can be safely ignored)
return true;
case 3100:
// Name of List Element is already in use.
$multipart = array(QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ident);
$sqlObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_NUMBER, $errnum);
$sqlObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_MESSAGE, $errmsg);
$Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $sqlObject, array($multipart));
break;
case 3260:
// Insufficient permission level to perform this action.
// There's nothing we can do about this, if they don't grant the user permission, just skip it
return true;
case 3200:
// The provided edit sequence is out-of-date.
if (!($tmp = $Driver->get(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, array(QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ident)))) {
return true;
}
switch ($config['conflicts']) {
case QUICKBOOKS_SERVER_SQL_CONFLICT_LOG:
$multipart = array(QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ident);
$sqlObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_NUMBER, $errnum);
$sqlObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_MESSAGE, $errmsg);
$Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $sqlObject, array($multipart));
break;
case QUICKBOOKS_SERVER_SQL_CONFLICT_NEWER:
$Parser = new QuickBooks_XML_Parser($xml);
$errnumTemp = 0;
$errmsgTemp = '';
$Doc = $Parser->parse($errnumTemp, $errmsgTemp);
$Root = $Doc->getRoot();
$List = $Root->getChildAt('QBXML QBXMLMsgsRs ' . QuickBooks_Utilities::actionToResponse($action));
$TimeModified = $Root->getChildDataAt('QBXML QBXMLMsgsRs ' . QuickBooks_Utilities::actionToResponse($action) . ' ' . QuickBooks_Utilities::actionToXMLElement($action) . ' TimeModified');
$EditSequence = $Root->getChildDataAt('QBXML QBXMLMsgsRs ' . QuickBooks_Utilities::actionToResponse($action) . ' ' . QuickBooks_Utilities::actionToXMLElement($action) . ' EditSequence');
$multipart = array(QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ident);
if (QuickBooks_Utilities::compareQBTimeToSQLTime($TimeModified, $tmp->get(QUICKBOOKS_DRIVER_SQL_FIELD_MODIFY)) >= 0 && $config['mode'] != QUICKBOOKS_SERVER_SQL_MODE_WRITEONLY) {
//@TODO: Make this get only a single item, not the whole table
$Driver->queueEnqueue($user, QuickBooks_Utilities::convertActionToQuery($action), __FILE__, true, QUICKBOOKS_SERVER_SQL_CONFLICT_QUEUE_PRIORITY, $extra);
} else {
if (QuickBooks_Utilities::compareQBTimeToSQLTime($TimeModified, $tmp->get(QUICKBOOKS_DRIVER_SQL_FIELD_MODIFY)) < 0) {
//Updates the EditSequence without marking the row as resynced.
$tmpSQLObject = new QuickBooks_SQL_Object($table, null);
$tmpSQLObject->set("EditSequence", $EditSequence);
$Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $tmpSQLObject, array($multipart));
$Driver->queueEnqueue($user, QuickBooks_Utilities::convertActionToMod($action), $tmp->get(QUICKBOOKS_DRIVER_SQL_FIELD_ID), true, QUICKBOOKS_SERVER_SQL_CONFLICT_QUEUE_PRIORITY, $extra);
} else {
//Trash it, set synced.
$tmpSQLObject = new QuickBooks_SQL_Object($table, null);
$tmpSQLObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_MESSAGE, "Read/Write Mode is WRITEONLY, and Conflict Mode is NEWER, and Quickbooks has Newer data, so no Update Occured.");
$Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $tmpSQLObject, array($multipart));
}
}
break;
case QUICKBOOKS_SERVER_SQL_CONFLICT_QUICKBOOKS:
if ($config['mode'] == QUICKBOOKS_SERVER_SQL_MODE_READWRITE) {
//@TODO: Make this get only a single item, not the whole table
$Driver->queueEnqueue($user, QuickBooks_Utilities::convertActionToQuery($action), null, true, QUICKBOOKS_SERVER_SQL_CONFLICT_QUEUE_PRIORITY, $extra);
$multipart = array(QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ident);
$sqlObject->set(QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_NUMBER, $errnum);
//.........这里部分代码省略.........
示例2: _QueryResponse
/**
*
*
*
*/
protected static function _QueryResponse($type, $List, $requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents, $callback_config = array())
{
$type = strtolower($type);
$Driver = QuickBooks_Driver_Singleton::getInstance();
$objects = array();
// For each one of the objects we got back in the qbXML response...
foreach ($List->children() as $Node) {
// If this object is a base-level object, we're going to keep track of it's TxnID or
// ListID so that we can use it to tie child elements back to this base-level
// element (about 20 or 30 lines below this is that code)
// Convert the XML nodes to objects, based on the XML to SQL schema definitions in Schema.php
$objects = array();
QuickBooks_Server_SQL_Callbacks::_transformToSQLObjects('', $Node, $objects);
// For each object we created from the XML nodes...
// (might have created more than one, e.g. an Invoice, plus 10 InvoiceLines, plus a Invoice_DataExt, etc.)
/*
if (count($objects) > 1)
{
print_r($objects);
exit;
}
*/
foreach ($objects as $key => $object) {
$table = $object->table();
$path = $object->path();
$map = array();
QuickBooks_SQL_Schema::mapPrimaryKey($path, QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $map);
// This is a list of "Boolean" fields in QuickBooks
// QuickBooks sends us boolean value as the strings "true" and
// "false", so we need to convert them to 1 and 0 so that we
// can store this in an INT field in the database (not all
// databases support a BOOLEAN type)
$qb_to_sql_booleans = array('EmployeePayrollInfo_IsUsingTimeDataToCreatePaychecks', 'EmployeePayrollInfo_ClearEarnings', 'EmployeePayrollInfo_SickHours_IsResettingHoursEachNewYear', 'EmployeePayrollInfo_VacationHours_IsResettingHoursEachNewYear', 'IsAdjustment', 'IsActive', 'IsBillable', 'IsBilled', 'IsClosed', 'IsFinanceCharge', 'IsFullyInvoiced', 'IsFullyReceived', 'IsManuallyClosed', 'IsPaid', 'IsPending', 'IsPrintItemsInGroup', 'IsToBeEmailed', 'IsToBePrinted', 'IsSampleCompany', 'IsTaxable', 'IsVendorEligibleFor1099');
// Cast QuickBooks booleans (strings, "true" and "false") to database booleans (tinyint 1 and 0)
foreach ($qb_to_sql_booleans as $qb_field_boolean) {
$qb_bool = $object->get($qb_field_boolean, false);
if ($qb_bool !== false) {
if ($qb_bool == 'true') {
$object->set($qb_field_boolean, 1);
} else {
$object->set($qb_field_boolean, 0);
}
}
}
//
if (count($map) and $map[0] and $map[1]) {
$addMapTest = array();
$addMapTestOthers = array();
QuickBooks_SQL_Schema::mapToSchema(trim(QuickBooks_Utilities::actionToXMLElement($action)), QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $addMapTest, $addMapTestOthers);
if (!isset($extra['IsAddResponse']) or !(count($addMapTest) and $addMapTest[0]) or $map[0] != $addMapTest[0]) {
//echo "<br /> ".$path."<br />";
//GARRETT'S bug Fix -- Arrays with primary keys consisting of multiple fields weren't updating properly
//due to failure to check for arrays.
$multipart = array();
if (is_array($map[1])) {
foreach ($map[1] as $table_name) {
$multipart[$table_name] = $object->get($table_name);
}
} else {
$multipart[$map[1]] = $object->get($map[1]);
}
} else {
$multipart[QUICKBOOKS_DRIVER_SQL_FIELD_ID] = $ID;
}
$hooks = array();
if (isset($callback_config['hooks'])) {
$hooks = $callback_config['hooks'];
}
if ($tmp = $Driver->get(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $multipart)) {
$actually_do_update = false;
$actually_do_updaterelatives = false;
$actually_do_deletechildren = false;
$extra['AddResponse_OldKey'] = $tmp->get(Quickbooks_Utilities::keyForAction($action));
if ($extra['AddResponse_OldKey'] == null and Quickbooks_Utilities::keyForAction($action) == "TxnID") {
$extra['AddResponse_OldKey'] = $tmp->get("TxnLineID");
}
if (isset($extra['IsAddResponse']) and stripos($action, 'dataext') === false) {
// DATAEXT custom field handling
// Handling data extensions here...
$tmpSQLObject = new QuickBooks_SQL_Object("dataext", null);
$tempMulti = array();
if (Quickbooks_Utilities::keyForAction($action) == "ListID") {
$tmpSQLObject->set('Entity_ListID', $object->get("ListID"));
$tempMulti["Entity_ListID"] = $extra['AddResponse_OldKey'];
$wField = "Entity_ListID";
$wValue = $object->get("ListID");
} else {
$tmpSQLObject->set('Txn_TxnID', $object->get("TxnID"));
$tempMulti["Txn_TxnID"] = $extra['AddResponse_OldKey'];
$wField = "Txn_TxnID";
$wValue = $object->get("TxnID");
if ($object->get("TxnID") == null) {
$tmpSQLObject->set('Txn_TxnID', $object->get("TxnLineID"));
$wValue = $object->get("TxnLineID");
}
//.........这里部分代码省略.........
示例3: _queryResponse
/**
*
*
*
*/
protected static function _queryResponse($type, $List, $requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents, $callback_config = array())
{
$type = strtolower($type);
$Driver = QuickBooks_Driver_Singleton::getInstance();
$objects = array();
// For each one of the objects we got back in the qbXML response...
foreach ($List->children() as $Node) {
// If this object is a base-level object, we're going to keep track of it's TxnID or
// ListID so that we can use it to tie child elements back to this base-level
// element (about 20 or 30 lines below this is that code)
// Child records get deleted, and then re-created with the same
// qbsql_id values so that we don't muck up people's associated
// records. This keeps track of deleted records so we can re-create
// the records with the same qbsql_id values.
$deleted = array();
// Convert the XML nodes to objects, based on the XML to SQL schema definitions in Schema.php
$objects = array();
QuickBooks_Callbacks_SQL_Callbacks::_transformToSQLObjects('', $Node, $objects);
//print_r($objects);
//exit;
// For each object we created from the XML nodes...
// (might have created more than one, e.g. an Invoice, plus 10 InvoiceLines, plus a Invoice_DataExt, etc.)
/*
if (count($objects) > 1)
{
print_r($objects);
exit;
}
*/
// This keeps track of whether or not we're ignoring this entire batch of UPDATES/INSERTS
$ignore_this_and_its_children = false;
foreach ($objects as $key => $object) {
$Object =& $object;
if ($ignore_this_and_its_children) {
// If we're supposed to ignore this object and it's children, then just continue
continue;
}
$table = $Object->table();
$path = $Object->path();
$map = array();
QuickBooks_SQL_Schema::mapPrimaryKey($path, QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $map);
// Special hack for preferences
if ($Object->table() == 'preferences') {
$map = array('qb_preferences', 'qbsql_external_id');
}
//print_r($Object);
//print_r($path);
//print_r($map);
//exit;
//
if ($table and count($map) and $map[0] and $map[1]) {
$addMapTest = array();
$addMapTestOthers = array();
QuickBooks_SQL_Schema::mapToSchema(trim(QuickBooks_Utilities::actionToXMLElement($action)), QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $addMapTest, $addMapTestOthers);
if (!isset($extra['IsAddResponse']) and !isset($extra['is_add_response']) or !(count($addMapTest) and $addMapTest[0]) or $map[0] != $addMapTest[0]) {
// GARRETT'S bug Fix -- Arrays with primary keys consisting of multiple fields weren't updating properly
// due to failure to check for arrays.
$multipart = array();
if (is_array($map[1])) {
foreach ($map[1] as $table_name) {
$multipart[$table_name] = $object->get($table_name);
}
} else {
$multipart[$map[1]] = $object->get($map[1]);
}
} else {
$multipart[QUICKBOOKS_DRIVER_SQL_FIELD_ID] = $ID;
}
$hooks = array();
if (isset($callback_config['hooks'])) {
$hooks = $callback_config['hooks'];
}
if ($tmp = $Driver->get(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $multipart)) {
$actually_do_update = false;
$actually_do_updaterelatives = false;
$actually_do_deletechildren = false;
if (isset($tmp[Quickbooks_Utilities::keyForAction($action)])) {
// I have no idea what this does or what this is for....
// > EDIT: This keeps track of what the old TxnID or ListID is, so that we can use it to update relative tables
$extra['AddResponse_OldKey'] = $tmp[Quickbooks_Utilities::keyForAction($action)];
$extra['temporary_TxnID_or_ListID_or_LineID'] = $tmp[Quickbooks_Utilities::keyForAction($action)];
}
if (empty($extra['AddResponse_OldKey']) and Quickbooks_Utilities::keyForAction($action) == 'TxnID' and isset($tmp['TxnLineID'])) {
//$extra['AddResponse_OldKey'] = $tmp->get("TxnLineID");
$extra['AddResponse_OldKey'] = $tmp['TxnLineID'];
$extra['temporary_TxnID_or_ListID_or_LineID'] = $tmp['TxnLineID'];
}
// Make sure a conflict mode has been selected
if (empty($callback_config['conflicts'])) {
$callback_config['conflicts'] = null;
}
if (empty($callback_config['mode'])) {
$callback_config['mode'] = QuickBooks_WebConnector_Server_SQL::MODE_READONLY;
}
if (isset($extra['is_query_response']) or isset($extra['is_import_response']) or isset($extra['is_mod_response']) or isset($extra['is_add_response'])) {
//.........这里部分代码省略.........
示例4: catchall
/**
* @TODO Change this to return false by default, and only catch the specific errors we're concerned with.
*
*/
public static function catchall($requestID, $user, $action, $ident, $extra, &$err, $xml, $errnum, $errmsg, $config)
{
$Driver = QuickBooks_Driver_Singleton::getInstance();
$ignore = array(QUICKBOOKS_IMPORT_DELETEDTXNS => true, QUICKBOOKS_QUERY_DELETEDTXNS => true, QUICKBOOKS_IMPORT_DELETEDLISTS => true, QUICKBOOKS_QUERY_DELETEDLISTS => true, QUICKBOOKS_VOID_TRANSACTION => true, QUICKBOOKS_DELETE_TRANSACTION => true, QUICKBOOKS_DELETE_LIST => true);
if (isset($ignore[$action])) {
// Ignore errors for these requests
return true;
}
/*
$Parser = new QuickBooks_XML($xml);
$errnumTemp = 0;
$errmsgTemp = '';
$Doc = $Parser->parse($errnumTemp, $errmsgTemp);
$Root = $Doc->getRoot();
$emailStr = var_export($Root->children(), true);
$List = $Root->getChildAt('QBXML QBXMLMsgsRs '.QuickBooks_Utilities::actionToResponse($action));
$Node = current($List->children());
*/
$map = array();
$others = array();
QuickBooks_SQL_Schema::mapToSchema(trim(QuickBooks_Utilities::actionToXMLElement($action)), QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $map, $others);
$object = new QuickBooks_SQL_Object($map[0], trim(QuickBooks_Utilities::actionToXMLElement($action)));
$table = $object->table();
$existing = null;
if ($table and is_numeric($ident)) {
$multipart = array(QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ident);
$existing = $Driver->get(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $multipart);
}
switch ($errnum) {
case 1:
// These errors occur when we search for something and it doesn't exist
// These errors occur when we search for something and it doesn't exist
case 500:
// i.e. we query for invoices modified since xyz, but there are none that have been modified since then
// This isn't really an error, just ignore it
if ($action == QUICKBOOKS_DERIVE_CUSTOMER) {
// Tried to derive, doesn't exist, add it
$Driver->queueEnqueue($user, QUICKBOOKS_ADD_CUSTOMER, $ident, true, QuickBooks_Utilities::priorityForAction(QUICKBOOKS_ADD_CUSTOMER));
} else {
if ($action == QUICKBOOKS_DERIVE_INVOICE) {
// Tried to derive, doesn't exist, add it
$Driver->queueEnqueue($user, QUICKBOOKS_ADD_INVOICE, $ident, true, QuickBooks_Utilities::priorityForAction(QUICKBOOKS_ADD_INVOICE));
} else {
if ($action == QUICKBOOKS_DERIVE_RECEIVEPAYMENT) {
// Tried to derive, doesn't exist, add it
$Driver->queueEnqueue($user, QUICKBOOKS_ADD_RECEIVEPAYMENT, $ident, true, QuickBooks_Utilities::priorityForAction(QUICKBOOKS_ADD_RECEIVEPAYMENT));
}
}
}
return true;
case 1000:
// An internal error occured
// @todo Hopefully at some point we'll have a better idea of how to handle this error...
return true;
//case 3120: // 3120 errors are handled in the 3210 error handler section
// break;
//case 3120: // 3120 errors are handled in the 3210 error handler section
// break;
case 3170:
// This list has been modified by another user.
// This list has been modified by another user.
case 3175:
case 3176:
case 3180:
// This error can occur in several different situations, so we test per situation
if (false !== strpos($errmsg, 'list has been modified by another user') or false !== strpos($errmsg, 'internals could not be locked') or false !== strpos($errmsg, 'failed to acquire the lock') or false !== strpos($errmsg, 'list element is in use')) {
// This is *not* an error, we can just send the request again, and it'll go through just fine
return true;
}
break;
case 3200:
// Ignore EditSequence errors (the record will be picked up and a conflict reported next time it runs... maybe?)
if ($action == QUICKBOOKS_MOD_CUSTOMER and $existing) {
// Queue up a derive customer request
// Tried to derive, doesn't exist, add it
$Driver->queueEnqueue($user, QUICKBOOKS_DERIVE_CUSTOMER, $ident, true, 9999, array('ListID' => $existing['ListID']));
} else {
if ($action == QUICKBOOKS_MOD_INVOICE and $existing) {
// Queue up a derive customer request
// Tried to derive, doesn't exist, add it
$Driver->queueEnqueue($user, QUICKBOOKS_DERIVE_INVOICE, $ident, true, 9999, array('TxnID' => $existing['TxnID']));
}
}
return true;
case 3120:
case 3210:
//print_r($existing);
//print('TXNID: [' . $existing['TxnID'] . ']');
// 3210: The "AppliedToTxnAdd payment amount" field has an invalid value "129.43". QuickBooks error message: You cannot pay more than the amount due.
if ($action == QUICKBOOKS_ADD_RECEIVEPAYMENT and (false !== strpos($errmsg, 'pay more than the amount due') or false !== strpos($errmsg, 'cannot be found')) and $existing) {
// If this happens, we're going to try to re-submit the payment, *without* the AppliedToTxn element
$db_errnum = null;
$db_errmsg = null;
$Driver->query("\n\t\t\t\t\t\tUPDATE \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . "receivepayment_appliedtotxn \n\t\t\t\t\t\tSET \n\t\t\t\t\t\t\tqbsql_to_skip = 1 \n\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\tReceivePayment_TxnID = '%s' ", $db_errnum, $db_errmsg, null, null, array($existing['TxnID']));
return true;
//.........这里部分代码省略.........