本文整理汇总了PHP中QuickBooks_Utilities::keyForAction方法的典型用法代码示例。如果您正苦于以下问题:PHP QuickBooks_Utilities::keyForAction方法的具体用法?PHP QuickBooks_Utilities::keyForAction怎么用?PHP QuickBooks_Utilities::keyForAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QuickBooks_Utilities
的用法示例。
在下文中一共展示了QuickBooks_Utilities::keyForAction方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAuthenticate
//.........这里部分代码省略.........
if (strlen($arr[QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_NUMBER])) {
// Do not sync this record until the error is resolved
continue;
}
// Queue up this MOD request
$Driver->queueEnqueue($user, $action, $arr[QUICKBOOKS_DRIVER_SQL_FIELD_ID], true, $priority);
$actions[] = $action;
// Mark the record as enqueued - let's wait until the hashing is in for this
//$Driver->query(..., $errnum, $errmsg);
}
}
}
}
//print('4 [' . (microtime(true) - $start) . ']' . "\n\n"); $start = microtime(true);
if ($mode == QuickBooks_WebConnector_Server_SQL::MODE_WRITEONLY or $mode == QuickBooks_WebConnector_Server_SQL::MODE_READWRITE) {
// Check if any *voided* objects need to be voided in QuickBooks
foreach ($sql_add as $action => $priority) {
$object = QuickBooks_Utilities::actionToObject($action);
$dependency = null;
if ($object == QUICKBOOKS_OBJECT_BILL) {
// Bill VOID dependency is PurchaseOrderMod because we want to be able to manually close POs (but need to VOID the bills first)
$dependency = QUICKBOOKS_MOD_PURCHASEORDER;
}
$priority = QuickBooks_Utilities::priorityForAction(QUICKBOOKS_VOID_TRANSACTION, $dependency);
$table_and_field = array();
// Convert to table and primary key, select qbsql id
QuickBooks_SQL_Schema::mapPrimaryKey($object, QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $table_and_field);
//$Driver->log('Searching table: ' . print_r($table_and_field, true) . ' for VOIDED records.', null, QUICKBOOKS_LOG_DEBUG);
if (!empty($table_and_field[0])) {
$sql = "\n\t\t\t\t\t\tSELECT \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_ID . "\n\t\t\t\t\t\tFROM \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table_and_field[0] . " \n\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_DISCOVER . " IS NOT NULL AND \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_TO_DELETE . " != 1 AND \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_FLAG_DELETED . " != 1 AND \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_TO_VOID . " = 1 AND \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_FLAG_VOIDED . " != 1 AND \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_MODIFY . " <= '" . $NOW . "' ";
$errnum = 0;
$errmsg = '';
$res = $Driver->query($sql, $errnum, $errmsg);
$extra = array('object' => $object);
while ($arr = $Driver->fetch($res)) {
$Driver->queueEnqueue($user, QUICKBOOKS_VOID_TRANSACTION, $arr[QUICKBOOKS_DRIVER_SQL_FIELD_ID], true, $priority, $extra);
}
}
}
}
//print('5 [' . (microtime(true) - $start) . ']' . "\n\n"); $start = microtime(true);
if ($mode == QuickBooks_WebConnector_Server_SQL::MODE_WRITEONLY or $mode == QuickBooks_WebConnector_Server_SQL::MODE_READWRITE) {
// Check if any *deleted* objects need to be deleted from QuickBooks
foreach ($sql_add as $action => $priority) {
break;
$priority = 1000 - $priority;
$object = QuickBooks_Utilities::actionToObject($action);
$table_and_field = array();
// Convert to table and primary key, select qbsql id
QuickBooks_SQL_Schema::mapPrimaryKey($object, QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $table_and_field);
// Delete if it's marked for deletion and it hasn't been deleted already
if (!empty($table_and_field[0])) {
$sql = "\n\t\t\t\t\t\tSELECT \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_ID . "\n\t\t\t\t\t\tFROM \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table_and_field[0] . " \n\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t " . QUICKBOOKS_DRIVER_SQL_FIELD_TO_DELETE . " = 1 AND \n\t\t\t\t\t\t\t " . QUICKBOOKS_DRIVER_SQL_FIELD_FLAG_DELETED . " != 1 AND \n\t\t\t\t\t\t\t " . QUICKBOOKS_DRIVER_SQL_FIELD_MODIFY . " <= '" . $NOW . "' ";
$errnum = 0;
$errmsg = '';
$res = $Driver->query($sql, $errnum, $errmsg);
$key = QuickBooks_Utilities::keyForAction($action);
if ($key == 'ListID') {
$useAction = 'ListDel';
} else {
$useAction = 'TxnDel';
}
$extra['objectType'] = $object;
while ($arr = $Driver->fetch($res)) {
$Driver->queueEnqueue($user, $useAction, $extra['objectType'] . $arr[QUICKBOOKS_DRIVER_SQL_FIELD_ID], true, $priority, $extra);
}
}
}
}
//print('6 [' . (microtime(true) - $start) . ']' . "\n\n"); $start = microtime(true);
/*
// This makes sure that timestamps are set up for every action we're doing (fixes a bug where timestamps never get recorded on initial sync without iterator)
foreach ($actions as $action)
{
$module = __CLASS__;
$key_curr = QuickBooks_Callbacks_SQL_Callbacks::_keySyncCurr($action);
$key_prev = QuickBooks_Callbacks_SQL_Callbacks::_keySyncPrev($action);
$type = null;
$opts = null;
$curr_sync_datetime = $Driver->configRead($user, $module, $key_curr, $type, $opts); // last sync started...
$prev_sync_datetime = $Driver->configRead($user, $module, $key_prev, $type, $opts); // last sync started...
$datetime = QuickBooks_Utilities::datetime('1983-01-02');
if (!$curr_sync_datetime)
{
$Driver->configWrite($user, $module, $key_curr, $datetime, null);
}
if (!$prev_sync_datetime)
{
$Driver->configWrite($user, $module, $key_prev, $datetime, null);
}
}
*/
//print("\n\n" . 'here [ ' . (microtime(true) - $_start) . ']' . "\n\n\n");
return true;
}
示例2: receiveResponseXML
//.........这里部分代码省略.........
$action = '';
$ident = '';
$this->_parseRequestID($requestID, $action, $ident);
// Fetch the request that was processed and EXPERIENCED AN ERROR!
$extra = '';
if ($current = $this->_driver->queueFetch($user, $action, $ident, QUICKBOOKS_STATUS_PROCESSING)) {
if ($current['extra']) {
$extra = unserialize($current['extra']);
}
}
if ($obj->message) {
$errmsg = $obj->message;
} else {
if ($status = $this->_extractStatusMessage($obj->response)) {
$errmsg = $status;
}
}
$errerr = '';
$continue = $this->_handleError($obj->ticket, $errnum, $errmsg, $requestID, $action, $ident, $extra, $errerr, $obj->response, array());
// $errnum, $errmsg, $requestID, $action, $ident, $extra, &$err, $xml, $qb_identifiers = array()
if ($errerr) {
// The error handler returned an error too...
$this->_driver->log('An error occured while handling quickbooks error ' . $errnum . ': ' . $errmsg . ': ' . $errerr, $obj->ticket, QUICKBOOKS_LOG_NORMAL);
}
} else {
$errerr = '';
$continue = $this->_handleError($obj->ticket, $obj->hresult, $obj->message, null, null, null, null, $errerr, $obj->response, array());
if ($errerr) {
// The error handler returned an error too...
$this->_driver->log('An error occured while handling generic error ' . $obj->hresult . ': ' . $obj->message . ': ' . $errerr, $obj->ticket, QUICKBOOKS_LOG_NORMAL);
}
}
// Calculate the percentage done
$progress = $this->_calculateProgress($obj->ticket);
if (!$continue) {
$progress = -1;
}
$this->_driver->log('Transaction error at ' . $progress . '% complete... ', $obj->ticket, QUICKBOOKS_LOG_VERBOSE);
return new QuickBooks_Result_ReceiveResponseXML($progress);
}
$action = null;
$ident = null;
$requestID = null;
if ($requestID = $this->_extractRequestID($obj->response)) {
//$action = current(explode('|', $requestID));
//$ident = end(explode('|', $requestID));
$action = '';
$ident = '';
$this->_parseRequestID($requestID, $action, $ident);
// Fetch the request that's being processed
$extra = '';
if ($current = $this->_driver->queueFetch($user, $action, $ident, QUICKBOOKS_STATUS_PROCESSING)) {
if ($current['extra']) {
$extra = unserialize($current['extra']);
}
}
// Update the status to success (no error occured)
$this->_driver->queueStatus($obj->ticket, $action, $ident, QUICKBOOKS_STATUS_SUCCESS);
}
// Extract ListID, TxnID, etc. from the response
$identifiers = $this->_extractIdentifiers($obj->response);
//$this->_driver->log(var_export($identifiers, true), $obj->ticket, QUICKBOOKS_LOG_VERBOSE);
// Auto-map $ident unique identifier from web application to the QuickBooks ListID or TxnID
if ($this->_config['map_application_identifiers']) {
$adds = QuickBooks_Utilities::listActions('*Add*');
$mods = QuickBooks_Utilities::listActions('*Mod*');
$qbkey = QuickBooks_Utilities::keyForAction($action);
$type = QuickBooks_Utilities::actionToObject($action);
$EditSequence = '';
if (isset($identifiers['EditSequence'])) {
$EditSequence = $identifiers['EditSequence'];
}
if (in_array($action, $adds) and isset($identifiers[$qbkey]) and $type) {
// Try to map the $ident to the QuickBooks identifier
$this->_driver->identMap($user, $type, $ident, $identifiers[$qbkey], $EditSequence);
} else {
if (in_array($action, $mods) and isset($identifiers[$qbkey]) and $type) {
// Try to map the $ident to the QuickBooks identifier
$this->_driver->identMap($user, $type, $ident, $identifiers[$qbkey], $EditSequence);
}
}
}
$err = null;
$last_action_time = $this->_driver->queueActionLast($user, $action);
$last_actionident_time = $this->_driver->queueActionIdentLast($user, $action, $ident);
$this->_callMappedFunction(1, $user, $action, $ident, $extra, $err, $last_action_time, $last_actionident_time, $obj->response, $identifiers);
// Calculate the percentage done
$progress = $this->_calculateProgress($obj->ticket);
if ($err) {
$errerr = '';
$continue = $this->_handleError($obj->ticket, QUICKBOOKS_ERROR_HANDLER, $err, $requestID, $action, $ident, $extra, $errerr, $obj->response, $identifiers);
if (!$continue) {
$progress = -1;
}
}
$this->_driver->log($progress . '% complete... ', $obj->ticket, QUICKBOOKS_LOG_VERBOSE);
return new QuickBooks_Result_ReceiveResponseXML($progress);
}
return new QuickBooks_Result_ReceiveResponseXML(-1);
}
示例3: onAuthenticate
//.........这里部分代码省略.........
$sql_query[$action] = QuickBooks_Utilities::priorityForAction($action);
}
$sql_query = QuickBooks_Server_SQL_Callbacks::_filterActions($sql_query, $callback_config['_only_query'], $callback_config['_dont_query'], QUICKBOOKS_QUERY);
// Which things you want to *add* to QuickBooks (SQL => QuickBooks (adds only!))
// @todo These should be changed to use QuickBooks_Utilities::listActions('*ADD*')
foreach (QuickBooks_Utilities::listActions('*ADD*') as $action) {
$sql_add[$action] = QuickBooks_Utilities::priorityForAction($action);
}
$sql_add = QuickBooks_Server_SQL_Callbacks::_filterActions($sql_add, $callback_config['_only_add'], $callback_config['_dont_add'], QUICKBOOKS_ADD);
// Which things you want to *modify* in QuickBooks (SQL => QuickBooks (modifys only!))
// @todo These should be changed to use QuickBooks_Utilities::listActions('*MOD*')
foreach (QuickBooks_Utilities::listActions('*MOD*') as $action) {
$sql_mod[$action] = QuickBooks_Utilities::priorityForAction($action);
}
$sql_mod = QuickBooks_Server_SQL_Callbacks::_filterActions($sql_mod, $callback_config['_only_modify'], $callback_config['_dont_modify'], QUICKBOOKS_MOD);
// Queueing class
//$Queue = new QuickBooks_Queue($dsn_or_conn);
if ($mode == QUICKBOOKS_SERVER_SQL_MODE_READONLY or $mode == QUICKBOOKS_SERVER_SQL_MODE_READWRITE) {
//print_r($sql_query);
//print_r($sql_map);
// Register recurring events for things you want to query
foreach ($sql_query as $action => $priority) {
// Make sure that there are handlers registered for this recurring action
if (!isset($sql_map[$action])) {
//trigger_error('No registered handler for: ' . $action);
continue;
}
//$Queue->recurring($run_every, $action, md5(__FILE__), $priority, null, $user);
$Driver->recurEnqueue($user, $run_every, $action, md5(__FILE__), true, $priority);
}
}
// Objects that need to be *ADDED* to QuickBooks
if ($mode == QUICKBOOKS_SERVER_SQL_MODE_WRITEONLY or $mode == QUICKBOOKS_SERVER_SQL_MODE_READWRITE) {
// Check if any objects need to be pushed back to QuickBooks
foreach ($sql_add as $action => $priority) {
$object = QuickBooks_Utilities::actionToObject($action);
$table_and_field = array();
// Convert to table and primary key, select qbsql id
QuickBooks_SQL_Schema::mapPrimaryKey($object, QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $table_and_field);
//print_r($table_and_field);
if (!empty($table_and_field[0]) and !empty($table_and_field[1])) {
$sql = "\n\t\t\t\t\t\tSELECT \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_ID . "\n\t\t\t\t\t\tFROM \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table_and_field[0] . " \n\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t " . QUICKBOOKS_DRIVER_SQL_FIELD_MODIFY . " IS NOT NULL AND \n\t\t\t\t\t\t\t " . QUICKBOOKS_DRIVER_SQL_FIELD_RESYNC . " IS NULL AND \n\t\t\t\t\t\t\t " . QUICKBOOKS_DRIVER_SQL_FIELD_TO_SKIP . " != 1 ";
$errnum = 0;
$errmsg = '';
$res = $Driver->query($sql, $errnum, $errmsg);
while ($arr = $Driver->fetch($res)) {
$Driver->queueEnqueue($user, $action, $arr[QUICKBOOKS_DRIVER_SQL_FIELD_ID], true, $priority);
}
}
}
}
// Objects that need to be *MODIFIED* within QuickBooks
if ($mode == QUICKBOOKS_SERVER_SQL_MODE_WRITEONLY or $mode == QUICKBOOKS_SERVER_SQL_MODE_READWRITE) {
// Check if any objects need to be pushed back to QuickBooks
foreach ($sql_mod as $action => $priority) {
$object = QuickBooks_Utilities::actionToObject($action);
$table_and_field = array();
// Convert to table and primary key, select qbsql id
QuickBooks_SQL_Schema::mapPrimaryKey($object, QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $table_and_field);
$Driver->log('Searching table: ' . QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table_and_field[0] . ' for MODIFIED records.', null, QUICKBOOKS_LOG_DEBUG);
// If we managed to map a table, we need to search that table for changed records
if (!empty($table_and_field[0]) and !empty($table_and_field[1])) {
$sql = "\n\t\t\t\t\t\tSELECT \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_ID . "\n\t\t\t\t\t\tFROM \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table_and_field[0] . " \n\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_DISCOVER . " IS NOT NULL AND \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_RESYNC . " IS NOT NULL AND\n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_MODIFY . " > " . QUICKBOOKS_DRIVER_SQL_FIELD_RESYNC . " AND\n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_TO_DELETE . " != 1 AND \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_TO_SKIP . " != 1 ";
$errnum = 0;
$errmsg = '';
$res = $Driver->query($sql, $errnum, $errmsg);
while ($arr = $Driver->fetch($res)) {
$Driver->queueEnqueue($user, $action, $arr[QUICKBOOKS_DRIVER_SQL_FIELD_ID], true, $priority);
}
}
}
}
if ($mode == QUICKBOOKS_SERVER_SQL_MODE_WRITEONLY or $mode == QUICKBOOKS_SERVER_SQL_MODE_READWRITE) {
// Check if any *deleted* objects need to be deleted from QuickBooks
foreach ($sql_add as $action => $priority) {
$priority = 1000 - $priority;
$object = QuickBooks_Utilities::actionToObject($action);
$table_and_field = array();
// Convert to table and primary key, select qbsql id
QuickBooks_SQL_Schema::mapPrimaryKey($object, QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $table_and_field);
if (!empty($table_and_field[0])) {
$sql = "\n\t\t\t\t\t\tSELECT \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_FIELD_ID . "\n\t\t\t\t\t\tFROM \n\t\t\t\t\t\t\t" . QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table_and_field[0] . " \n\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t " . QUICKBOOKS_DRIVER_SQL_FIELD_TO_DELETE . " = 1 ";
$errnum = 0;
$errmsg = '';
$res = $Driver->query($sql, $errnum, $errmsg);
$key = QuickBooks_Utilities::keyForAction($action);
if ($key == 'ListID') {
$useAction = 'ListDel';
} else {
$useAction = 'TxnDel';
}
$extra['objectType'] = $object;
while ($arr = $Driver->fetch($res)) {
$Driver->queueEnqueue($user, $useAction, $extra['objectType'] . $arr[QUICKBOOKS_DRIVER_SQL_FIELD_ID], true, $priority, $extra);
}
}
}
}
return true;
}