transaction_tester.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. require_once dirname(__FILE__).'/../../main/inc/global.inc.php';
  3. require_once 'config.php';
  4. Display::display_header();
  5. $form = new FormValidator('transaction_tester');
  6. $form->addElement('header', 'Transaction tester');
  7. $form->addElement('text', 'transaction_id', get_lang('TransactionId'));
  8. $form->addElement('text', 'branch_id', get_lang('BranchId'));
  9. $form->addRule('transaction_id',get_lang('ThisFieldShouldBeNumeric'),'numeric');
  10. $form->addRule('branch_id',get_lang('ThisFieldShouldBeNumeric'),'numeric');
  11. $form->addElement('checkbox', 'forced', null, get_lang('ForceTransactionCreation'));
  12. $form->addElement('button', 'add', get_lang('Send'));
  13. $response = null;
  14. if ($form->validate()) {
  15. $values = $form->getSubmitValues();
  16. $transaction_id = $values['transaction_id'];
  17. $branch_id = $values['branch_id'];
  18. $response = Display::page_subheader2("Executing transaction #$transaction_id in branch_id: $branch_id");
  19. require_once 'migration.class.php';
  20. require_once 'migration.custom.class.php';
  21. //harcoded db_matches
  22. require_once 'db_matches.php';
  23. $migration = new Migration();
  24. $migration->set_web_service_connection_info($matches);
  25. $forced = isset($values['forced']) && $values['forced'] == 1 ? true : false;
  26. //This is the fault of the webservice
  27. $transaction_id--;
  28. $result = $migration->load_transaction_by_third_party_id($transaction_id, $branch_id, $forced);
  29. $response .= $result['message'];
  30. if (isset($result['raw_reponse'])) {
  31. $response .= $result['raw_reponse'];
  32. }
  33. }
  34. $form->setDefaults(array('transaction_id' => '376014', 'branch_id' => 2));
  35. $form->display();
  36. if (!empty($response)) {
  37. echo $response;
  38. }