コード例 #1
0
 public function saveAll($dir)
 {
     $Parser = new QuickBooks_XML($this->_xml);
     $arr_actions_adds = QuickBooks_Utilities::listActions('*Add', false);
     $arr_actions_mods = QuickBooks_Utilities::listActions('*Mod', false);
     //print_r($arr_actions_mods);
     //exit;
     $i = 0;
     $errnum = 0;
     $errmsg = '';
     if ($Doc = $Parser->parse($errnum, $errmsg)) {
         $children = $Doc->children();
         $children = $children[0]->children();
         foreach ($children as $Action) {
             print 'Action name is: ' . $Action->name() . "\n";
             //if ($Action->name() != 'VendorAddRq')
             //{
             //	continue;
             //}
             //print_r($Action);
             $section = $this->_extractSectionForTag($this->_xml, $Action->name());
             //print($section);
             $wrapper = '';
             if ($Action->hasChildren()) {
                 $first = $Action->getChild(0);
                 //print_r($first);
                 if (in_array($first->name(), $arr_actions_mods) or in_array($first->name(), $arr_actions_adds)) {
                     $wrapper = $first->name();
                     print '	WRAPPER NODE IS: ' . $wrapper . "\n";
                 }
             }
             //exit;
             $paths_datatype = array();
             $paths_maxlength = array();
             $paths_isoptional = array();
             $paths_sinceversion = array();
             $paths_isrepeatable = array();
             $paths_reorder = array();
             //$curdepth = 0;
             $lastdepth = 0;
             $paths = $Action->asArray(QUICKBOOKS_XML_ARRAY_PATHS);
             foreach ($paths as $path => $datatype) {
                 $tmp = explode(' ', $path);
                 $tag = end($tmp);
                 $comment = $this->_extractCommentForTag($section, $tag);
                 //print("\t{" . $path . '} => ' . $datatype . ' (' . $comment . ')' . "\n");
                 $parse = $this->_parseComment($comment);
                 //print_r($parse);
                 //print("\n");
                 $path = trim(substr($path, strlen($Action->name())));
                 if (strlen($wrapper) and substr($path, 0, strlen($wrapper)) == $wrapper) {
                     $path = substr($path, strlen($wrapper) + 1);
                 }
                 $paths_datatype[$path] = $datatype;
                 $paths_maxlength[$path] = $parse['maxlength'];
                 $paths_isoptional[$path] = $parse['isoptional'];
                 $paths_sinceversion[$path] = $parse['version'];
                 $paths_isrepeatable[$path] = $parse['mayrepeat'];
                 $curdepth = substr_count($path, ' ');
                 if ($curdepth - $lastdepth > 1) {
                     $tmp2 = explode(' ', $path);
                     for ($i = 1; $i < count($tmp2); $i++) {
                         $paths_reorder[] = implode(' ', array_slice($tmp2, 0, $i));
                     }
                 }
                 $lastdepth = substr_count($path, ' ');
                 $paths_reorder[] = $path;
             }
             //print(var_export($paths_datatype));
             //print(var_export($paths_maxlength));
             //print(var_export($paths_isoptional));
             //print(var_export($paths_sinceversion));
             //print(var_export($paths_isrepeatable));
             //print(var_export($paths_reorder));
             $contents = file_get_contents('/home/asdg/QuickBooks/QBXML/Schema/Object/Template.php');
             $contents = str_replace('Template', $Action->name(), $contents);
             $contents = str_replace('\'_qbxmlWrapper\'', var_export($wrapper, true), $contents);
             $contents = str_replace('\'_dataTypePaths\'', var_export($paths_datatype, true), $contents);
             $contents = str_replace('\'_maxLengthPaths\'', var_export($paths_maxlength, true), $contents);
             $contents = str_replace('\'_isOptionalPaths\'', var_export($paths_isoptional, true), $contents);
             $contents = str_replace('\'_sinceVersionPaths\'', var_export($paths_sinceversion, true), $contents);
             $contents = str_replace('\'_isRepeatablePaths\'', var_export($paths_isrepeatable, true), $contents);
             $contents = str_replace('\'_reorderPaths\'', var_export($paths_reorder, true), $contents);
             $fp = fopen('/home/adg/QuickBooks/tmp/' . $Action->name() . '.php', 'w+');
             fwrite($fp, $contents);
             fclose($fp);
             print "\n\n";
             if ($i > 150) {
                 exit;
             }
             $i++;
         }
     }
 }
コード例 #2
0
<?php

ini_set('include_path', ini_get('include_path') . ':' . realpath(dirname(__FILE__) . '/..'));
require_once 'QuickBooks.php';
require_once 'QuickBooks/XML.php';
$xml = file_get_contents('/home/library_php/QuickBooks/data/InvoiceQuery.xml');
$Parser = new QuickBooks_XML($xml);
$errnum = 0;
$errmsg = '';
$Parser->parse($errnum, $errmsg);
//print_R($Parser);
$tmp = $Parser->children();
$base = current($tmp);
$tmp = $base->children();
$rs = next($tmp);
$tmp = $rs->children();
$qbxml = current($tmp);
Transform($qbxml);
function Transform($node)
{
    $name = $node->name();
    // table name
    $fields = array();
    $subtables = array();
    foreach ($node->children() as $child) {
        if (substr($child->name(), -3) == 'Ref') {
            // We need to look through the reference, and see if we can find it's unique identifier (is it a ListID? a FullName? a TxnID?)
            $fields[substr($child->name(), 0, -3) . '_ListID'] = array('link!');
        } else {
            if ($child->childCount()) {
                $child->setName($node->name() . '_' . $child->name());
コード例 #3
0
<DataExtName>Alternate Email</DataExtName>
<DataExtType>STR255TYPE</DataExtType>
<DataExtValue>helpdesk@stmatthews.edu</DataExtValue>
</DataExtRet>
</DataExtModRs>
<DataExtModRs statusCode="0" statusSeverity="Info" statusMessage="Status OK">
<DataExtRet>
<OwnerID>0</OwnerID>
<DataExtName>Location</DataExtName>
<DataExtType>STR255TYPE</DataExtType>
<DataExtValue>Cayman</DataExtValue>
</DataExtRet>
</DataExtModRs>
</QBXMLMsgsRs>
</QBXML>';
$Parser = new QuickBooks_XML($xml);
$err = '';
$err2 = '';
$Doc = $Parser->parse($err, $err2);
$Root = $Doc->getRoot();
print_r($Root);
exit;
$children1 = $Doc->children();
foreach ($children1 as $child) {
    print_r($child->asXML());
}
print "\n\n\n";
$children2 = $Doc->children('InvoiceLineAdd');
foreach ($children2 as $child) {
    print_r($child->asXML());
}
コード例 #4
0
 /**
  * Take a qbXML schema and transform that schema to an SQL schema definition
  * 
  * @param string $xml			The XML string to transform
  * @param array $tables			An array of... erm... something?
  * @return boolean 
  */
 public static function mapSchemaToSQLDefinition($xml, &$tables)
 {
     $Parser = new QuickBooks_XML($xml);
     $errnum = 0;
     $errmsg = '';
     $tmp = $Parser->parse($errnum, $errmsg);
     $tmp = $tmp->children();
     $base = current($tmp);
     $tmp = $base->children();
     $rs = next($tmp);
     foreach ($rs->children() as $qbxml) {
         QuickBooks_SQL_Schema::_transform('', $qbxml, $tables);
     }
     /*
     while (count($subtables) > 0)
     {
     	$node = array_shift($subtables);
     	
     	$subsubtables = array();
     	$tables[] = QuickBooks_SQL_Schema::_transform('', $node, $subsubtables);
     	
     	$subtables = array_merge($subtables, $subsubtables);
     }
     */
     // The code below tries to guess as a good set of indexes to use for
     //	any database tables we've generated from the schema. The code looks
     //	at all of the fields in the table and if any of them are *ListID or
     //	*TxnID it makes them indexes.
     // This is a list of field names that will *always* be assigned
     //	indexes, regardless of what table they are in
     $always_index_fields = array('Name', 'FullName', 'EntityType', 'TxnType', 'Email', 'IsActive', 'RefNumber', 'Address_State', 'Address_Country', 'BillAddress_State', 'BillAddress_Country', 'ShipAddress_State', 'ShipAddress_Country', 'CompanyName', 'LastName', 'TxnDate', 'IsPaid', 'IsPending', 'IsManuallyClosed', 'IsFullyReceived', 'IsToBePrinted', 'IsToBeEmailed', 'IsFullyInvoiced');
     // This is a list of table.field names that will be assigned indexes
     $always_index_tablefields = array();
     /*
     '*FullName', 
     '*ListID', 
     '*TxnID', 
     '*EntityType', 
     '*TxnType', 
     '*LineID', 
     */
     foreach ($tables as $table => $tabledef) {
         $uniques = array();
         $indexes = array();
         foreach ($tabledef[1] as $field => $fielddef) {
             if ($field == 'ListID' or $field == 'TxnID' or $field == 'Name') {
                 // We can't apply indexes to TEXT columns, so we need to
                 //	check and make sure the column isn't of type TEXT
                 //	before we decide to use this as an index
                 if ($fielddef[0] != QUICKBOOKS_DRIVER_SQL_TEXT) {
                     $uniques[] = $field;
                 }
             } else {
                 if (substr($field, -6, 6) == 'ListID' or substr($field, -5, 5) == 'TxnID' or substr($field, -6, 6) == 'LineID' or in_array($field, $always_index_fields) or in_array($table . '.' . $field, $always_index_tablefields)) {
                     // We can't apply indexes to TEXT columns, so we need to
                     //	check and make sure the column isn't of type TEXT
                     //	before we decide to use this as an index
                     if ($fielddef[0] != QUICKBOOKS_DRIVER_SQL_TEXT) {
                         $indexes[] = $field;
                     }
                 }
             }
         }
         //print_r($indexes);
         //print_r($uniques);
         $tables[$table][3] = $indexes;
         $tables[$table][4] = $uniques;
     }
     return true;
 }
コード例 #5
0
ファイル: Callbacks.php プロジェクト: Edgargm87/efapcom
 /**
  * 
  * @param string $requestID
  * @param string $user
  * @param string $action
  * @param mixed $ID
  * @param mixed $extra
  * @param string $err
  * @param integer $last_action_time
  * @param integer $last_actionident_time
  * @param string $xml
  * @param array $idents
  * @return boolean
  */
 protected static function _doQueryResponse($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents, $callback_options = array())
 {
     // This is stuff we'll be passing to the callback handler functions/methods
     // $action
     // $ID
     $err = '';
     $qbxml =& $xml;
     $qbiterator = null;
     $qbres = null;
     $method = null;
     if (isset($extra['method'])) {
         $method = $extra['method'];
     }
     $xml_errnum = 0;
     $xml_errmsg = '';
     $Parser = new QuickBooks_XML($xml);
     if ($Parser->validate($xml_errnum, $xml_errmsg) and $Doc = $Parser->parse($xml_errnum, $xml_errmsg)) {
         $list = array();
         $Root = $Doc->getRoot();
         // Get rid of some gunk...
         $Response = $Root->getChildAt('QBXML QBXMLMsgsRs ' . $action . 'Rs');
         if ($Response) {
             foreach ($Response->children() as $Child) {
                 if ($Object = QuickBooks_Callbacks_API_Callbacks::_objectFromXML($action, $Child)) {
                     $list[] = $Object;
                 }
             }
         }
         $Iterator = new QuickBooks_Iterator($list);
     } else {
         $err = 'XML parser error: ' . $xml_errnum . ': ' . $xml_errmsg;
     }
     if ($err) {
         return false;
     }
     //print_r($extra);
     //print_r($Iterator);
     if (isset($extra['callbacks']) and is_array($extra['callbacks'])) {
         QuickBooks_Callbacks_API_Callbacks::_callCallbacks($extra['callbacks'], $method, $action, $ID, $err, $qbxml, $Iterator, $qbres, $callback_options);
     }
     return true;
 }