Guest User

Untitled

a guest
Jun 16th, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. ## input.php, receives $_POST data from a simple .html file
  2. ## handles the $_POST and forms it into qbXML
  3.  
  4. <?php
  5. // Require the queueuing class
  6. require_once 'QuickBooks.php';
  7. // Require the mysql class
  8. require_once 'mysql.php'
  9. // Require the qb server
  10. require_once 'server.php'
  11. $dsn = 'mysql://qb:3rJjKc6ybHRrPCde@localhost/qb';
  12.  
  13. error_reporting(E_ALL);
  14. ini_set('display_errors', 1);
  15.  
  16.  
  17. //$open = mysql_connect($db->host, $db->user, $db->password);
  18. //mysql_select_db('qb_sql')
  19.  
  20. // Insert into our local MySQL database
  21. //mysql_query("INSERT INTO qb_customer ( Name, Fullname, email ) VALUES ( '" . $_POST['customer']['name'] . "', '" . $_POST['customer']['phone'] . "', '" . $_POST['customer']['email'] . "' ) ");
  22. //$id_value = mysql_insert_id();
  23.  
  24. // QuickBooks queueing class
  25. $queue = new QuickBooks_Queue($dsn);
  26.  
  27. // Queue it up!
  28. $queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, 5);
  29.  
  30. ?>
  31.  
  32.  
  33. ## server.php
  34. ## Quickbooks SOAP Server
  35.  
  36. // Require the framework
  37. require_once 'QuickBooks.php';
  38.  
  39. $user = 'Admin';
  40. $pass = '<PASSWORD>';
  41.  
  42. // Map QuickBooks actions to handler functions
  43. $map = array(
  44. QUICKBOOKS_ADD_CUSTOMER => array( '_quickbooks_customer_add_request', '_quickbooks_customer_add_response' ),
  45. // ... more action handlers here ...
  46. );
  47.  
  48. // This is entirely optional, use it to trigger actions when an error is returned by QuickBooks
  49. $errmap = array();
  50.  
  51. // An array of callback hooks
  52. $hooks = array();
  53.  
  54. // Logging level
  55. //$log_level = QUICKBOOKS_LOG_NORMAL;
  56. //$log_level = QUICKBOOKS_LOG_VERBOSE;
  57. $log_level = QUICKBOOKS_LOG_DEBUG;
  58.  
  59. $soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN;
  60.  
  61. $soap_options = array();
  62.  
  63. $handler_options = array();
  64.  
  65. $driver_options = array();
  66.  
  67. $callback_options = array();
  68.  
  69. $dsn = 'mysql://qb:<PASSWORD>@localhost/qb';
  70.  
  71.  
  72. /*
  73. Take the initialization part out
  74. if (!QuickBooks_Utilities::initialized($dsn))
  75. {
  76. QuickBooks_Utilities::initialize($dsn);
  77. QuickBooks_Utilities::createUser($dsn, $user, $pass);
  78.  
  79. $Queue = new QuickBooks_Queue($dsn);
  80. $Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, 5);
  81. }
  82. */
  83.  
  84. $server = new QuickBooks_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
  85.  
  86. $response = $server->handle(true, true);
  87. ?>
  88.  
  89.  
  90. ## function that forms the QBXML
  91. ## placed in the Quickbooks.php
  92.  
  93. class xml_build {
  94. function build_CustomerAdd ($_POST) {
  95. $xml = '<?xml version="1.0" encoding="utf-8"?>
  96. <?qbxml version="2.0"?>
  97. <QBXML>
  98. <QBXMLMsgsRq onError="stopOnError">
  99. <CustomerAddRq requestID="' . $requestID . '">
  100. <CustomerAdd>
  101. <Name>' . $_POST['firstname'] . ' ' . $_POST['lastname'] . '</Name>
  102. <CompanyName></CompanyName>
  103. <FirstName>' . $_POST['firstname'] . '</FirstName>
  104. <LastName>' . $_POST['lastname'] . '</LastName>
  105. <BillAddress>
  106. <Addr1>' . $_POST['address_1'] . '</Addr1>
  107. <Addr2>' . $_POST['address_2'] . '</Addr2>
  108. <City>' . $_POST['city'] . '</City>
  109. <State>' . $_POST['state'] . '</State>
  110. <PostalCode>' . $_POST['zip'] . '</PostalCode>
  111. <Country>United States</Country>
  112. </BillAddress>
  113. <Phone>' . $_POST['home_phone_1'] . '-' . $_POST['home_phone_2'] . '-' . $_POST['home_phone_3'] .'</Phone>
  114. <AltPhone>' . $_POST['cell_phone_1'] . '-' . $_POST['cell_phone_2'] . '-' . $_POST['cell_phone_3'] .'</AltPhone>
  115. <Fax></Fax>
  116. <Email>' . $_POST['email'] . '</Email>
  117. <Contact>' . $_POST['firstname'] . ' ' . $_POST['lastname'] . '</Contact>
  118. </CustomerAdd>
  119. </CustomerAddRq>
  120. </QBXMLMsgsRq>
  121. </QBXML>';
  122. return $xml;
  123. }
  124. }
  125.  
  126. $xml_out = new xml_build;
  127.  
  128. function _quickbooks_customer_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
  129. {
  130. $xml_out->buildCustomerAdd($_POST);
  131. }
  132.  
  133. function _quickbooks_customer_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents)
  134. {
  135. }
Add Comment
Please, Sign In to add comment