本文整理汇总了PHP中QuickBooks_Utilities::convertActionToMod方法的典型用法代码示例。如果您正苦于以下问题:PHP QuickBooks_Utilities::convertActionToMod方法的具体用法?PHP QuickBooks_Utilities::convertActionToMod怎么用?PHP QuickBooks_Utilities::convertActionToMod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QuickBooks_Utilities
的用法示例。
在下文中一共展示了QuickBooks_Utilities::convertActionToMod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _queryResponse
//.........这里部分代码省略.........
//$Driver->log('Diagnostics for incoming: is_query[' . !empty($extra['is_query_response']) . '], is_import[' . !empty($extra['is_import_response']) . '], is_mod[' . !empty($extra['is_mod_response']) . '], is_add[' . !empty($extra['is_add_response']) . '], conflict mode: ' . $callback_config['conflicts'] . '', null, QUICKBOOKS_LOG_DEVELOP);
// Conflict handling code
// @todo I think this should only apply to query and improt, right? I mean, if it's a mod or add, then
// *of course* it was modified after resynced, thats how we knew to send it back to QuickBooks...
if ($tmp[QUICKBOOKS_DRIVER_SQL_FIELD_MODIFY] > $tmp[QUICKBOOKS_DRIVER_SQL_FIELD_RESYNC] and $callback_config['mode'] != QuickBooks_WebConnector_Server_SQL::MODE_READONLY) {
// CONFLICT resolution code
switch ($callback_config['conflicts']) {
case QuickBooks_WebConnector_Server_SQL::CONFLICT_NEWER:
$msg = 'Conflict mode: (newer) ' . $callback_config['conflicts'] . ' is not supported right now.';
trigger_error($msg);
die($msg);
case QuickBooks_WebConnector_Server_SQL::CONFLICT_QUICKBOOKS:
// QuickBooks is master, so remove all existing child records of this record, then apply the QuickBooks version update
$actually_do_deletechildren = true;
$actually_do_update = true;
//QuickBooks_Callbacks_SQL_Callbacks::_DeleteChildren($table, $user, $action, $ID, $object, $extra);
//$Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $object, array( $multipart ));
break;
case QuickBooks_WebConnector_Server_SQL::CONFLICT_CALLBACK:
$msg = 'Conflict mode: (callback) ' . $callback_config['conflicts'] . ' is not supported right now.';
trigger_error($msg);
die($msg);
break;
case QuickBooks_WebConnector_Server_SQL::CONFLICT_SQL:
// The SQL table is the master table, but we have an out-of-date EditSequence value
// In this case, what we want to do is update our record to the latest EditSequence value,
// and then re-queue the object so that it gets updated the next time the sync runs to
// the values from the SQL record
$tmp_editsequence_update = new QuickBooks_SQL_Object($table, null);
$tmp_editsequence_update->set('EditSequence', $object->get('EditSequence'));
// *Just* update the EditSequence value
$Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $tmp_editsequence_update, array($multipart), false);
// Re-queue it so the conflict gets resolved
$Driver->queueEnqueue($user, QuickBooks_Utilities::convertActionToMod($action), $tmp[QUICKBOOKS_DRIVER_SQL_FIELD_ID], true, QUICKBOOKS_SERVER_SQL_CONFLICT_QUEUE_PRIORITY, $extra);
break;
case QuickBooks_WebConnector_Server_SQL::CONFLICT_LOG:
default:
if (isset($extra['IsModResponse']) or isset($extra['is_mod_response']) or isset($extra['is_add_response'])) {
// If it's actually a mod response, then this isn't actually a conflict, it's just the mod response happening normally
$actually_do_update = true;
$actually_do_deletechildren = true;
$actually_do_updaterelatives = true;
} else {
// Log it...?
$Driver->log('Conflict occured at: ' . $table, null, QUICKBOOKS_LOG_NORMAL);
}
break;
}
}
//print_r($object);
//print_r($tmp);
// If the EditSequence has not changed since the last time this record was updated,
// then we can just skip this update because everything should already be up to
// date.
//
// This works around a very important issue as a result of Mod requests. When a Mod
// request is issued and succeeds, it updates the record. Then, on the next Query
// request, the record will be re-imported because the DateModified timestamp was
// updated as a result of the Mod request. However, if the record is modified
// by the end-user in between that Mod request and Import, the changes the user
// made will be overwritten/a conflict will occur *even though the Query response
// was only due to a Mod request that we sent ourselves* and the record in
// QuickBooks never actually changed between the Mod and the Query.
if (empty($extra['is_query_response']) and isset($tmp['EditSequence']) and $tmp['EditSequence'] == $object->get('EditSequence')) {
$actually_do_update = false;
$actually_do_deletechildren = false;
示例2: 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);
//.........这里部分代码省略.........
示例3: _QueryResponse
//.........这里部分代码省略.........
$Driver->queueEnqueue($user, $tempmap, $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:
// QuickBooks is master, so remove all existing child records of this record, then apply the QuickBooks version update
$actually_do_deletechildren = true;
$actually_do_update = true;
//QuickBooks_Server_SQL_Callbacks::_DeleteChildren($table, $user, $action, $ID, $object, $extra);
//$Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $object, array( $multipart ));
break;
case QUICKBOOKS_SERVER_SQL_CONFLICT_CALLBACK:
$msg = 'Conflict mode: ' . $callback_config['conflicts'] . ' is not supported right now.';
trigger_error($msg);
die($msg);
break;
case QUICKBOOKS_SERVER_SQL_CONFLICT_SQL:
// The SQL table is the master table, but we have an out-of-date EditSequence value
// In this case, what we want to do is update our record to the latest EditSequence value,
// and then re-queue the object so that it gets updated the next time the sync runs to
// the values from the SQL record
$tmp_editsequence_update = new QuickBooks_SQL_Object($table, null);
$tmp_editsequence_update->set('EditSequence', $object->get('EditSequence'));
// *Just* update the EditSequence value
$Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $tmp_editsequence_update, array($multipart), false);
// Re-queue it so the conflict gets resolved
$Driver->queueEnqueue($user, QuickBooks_Utilities::convertActionToMod($action), $tmp->get(QUICKBOOKS_DRIVER_SQL_FIELD_ID), true, QUICKBOOKS_SERVER_SQL_CONFLICT_QUEUE_PRIORITY, $extra);
break;
case QUICKBOOKS_SERVER_SQL_CONFLICT_LOG:
default:
if (isset($extra['IsModResponse'])) {
// If it's actually a mod response, then this isn't actually a conflict, it's just the mod response happening normally
$actually_do_update = true;
$actually_do_deletechildren = true;
$actually_do_updaterelatives = true;
} else {
// Log it...?
$Driver->log('Conflict occured at: ' . QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, null, QUICKBOOKS_LOG_NORMAL);
}
break;
}
} else {
if (isset($extra['IsAddResponse'])) {
// If this is set, it means we just added something
// to QuickBooks, and now we need to record the
// ListID and EditSequence provided to us by QuickBooks
$actually_do_update = true;
$actually_do_updaterelatives = true;
$actually_do_deletechildren = true;
}
}
/*else if (!isset($callback_config['conflicts']) or $callback_config['mode'] != QUICKBOOKS_SERVER_SQL_MODE_WRITEONLY)
{
// No conflicts have occurred, let's update the record in the SQL table
QuickBooks_Server_SQL_Callbacks::_DeleteChildren($table, $user, $action, $ID, $object, $extra);
QuickBooks_Server_SQL_Callbacks::_UpdateRelatives($table, $user, $action, $ID, $object, $extra);
$Driver->log('Applying UPDATE: ' . $table . ': ' . print_r($object) . ', where: ' . print_r($multipart), null, QUICKBOOKS_LOG_DEVELOP);
$Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table, $object, array( $multipart ));
}*/