예제 #1
0
 public function onDisplayTransactionsPage()
 {
     $this->check_wplister_setup();
     // handle update ALL from eBay action
     if ($this->requestAction() == 'update_transactions') {
         $this->initEC();
         $tm = $this->EC->loadTransactions();
         $this->EC->updateListings();
         $this->EC->closeEbay();
         // show transaction report
         $msg = $tm->count_total . ' ' . __('Transactions were loaded from eBay.', 'wplister') . '<br>';
         $msg .= __('Timespan', 'wplister') . ': ' . $tm->getHtmlTimespan();
         $msg .= '&nbsp;&nbsp;';
         $msg .= '<a href="#" onclick="jQuery(\'#transaction_report\').toggle();return false;">' . __('show details', 'wplister') . '</a>';
         $msg .= $tm->getHtmlReport();
         $this->showMessage($msg);
     }
     // handle update from eBay action
     if ($this->requestAction() == 'update') {
         if (isset($_REQUEST['transaction'])) {
             $this->initEC();
             $this->EC->updateTransactionsFromEbay($_REQUEST['transaction']);
             $this->EC->closeEbay();
             $this->showMessage(__('Selected transactions were updated from eBay.', 'wplister'));
         } else {
             $this->showMessage(__('You need to select at least one item from the list below in order to use bulk actions.', 'wplister'), 1);
         }
     }
     // handle delete action
     if ($this->requestAction() == 'delete') {
         if (isset($_REQUEST['transaction'])) {
             $this->initEC();
             $this->EC->deleteTransactions($_REQUEST['transaction']);
             $this->EC->closeEbay();
             $this->showMessage(__('Selected items were removed.', 'wplister'));
         } else {
             $this->showMessage(__('You need to select at least one item from the list below in order to use bulk actions.', 'wplister'), 1);
         }
     }
     // handle wpl_revert_transaction action
     if ($this->requestAction() == 'wpl_revert_transaction') {
         if (isset($_REQUEST['id'])) {
             $tm = new TransactionsModel();
             $tm->revertTransaction($_REQUEST['id']);
             $this->showMessage(__('Selected transaction was reverted.', 'wplister'));
         } else {
             $this->showMessage(__('You need to select at least one item from the list below in order to use bulk actions.', 'wplister'), 1);
         }
     }
     // show warning if duplicate transactions found
     $this->checkForDuplicates();
     //Create an instance of our package class...
     $transactionsTable = new TransactionsTable();
     //Fetch, prepare, sort, and filter our data...
     $transactionsTable->prepare_items();
     $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'transactionsTable' => $transactionsTable, 'preview_html' => isset($preview_html) ? $preview_html : '', 'form_action' => 'admin.php?page=' . self::ParentMenuId . '-transactions');
     $this->display('transactions_page', $aData);
 }