public function displayAccountsPage() { // handle actions and show notes $this->handleActions(); if ($this->requestAction() == 'save_account') { $this->saveAccount(); } if ($this->requestAction() == 'edit_account') { return $this->displayEditAccountsPage(); } if ($default_account_id = get_option('wpla_default_account_id')) { $default_account = WPLA_AmazonAccount::getAccount($default_account_id); if (!$default_account) { $this->showMessage(__('Your default account does not exist anymore. Please select a new default account.', 'wpla'), 1); } } // create table and fetch items to show $this->accountsTable = new WPLA_AccountsTable(); $this->accountsTable->prepare_items(); $active_tab = 'accounts'; $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'accountsTable' => $this->accountsTable, 'amazon_markets' => WPLA_AmazonMarket::getAll(), 'amazon_accounts' => WPLA_AmazonAccount::getAll(true), 'default_account' => get_option('wpla_default_account_id'), 'settings_url' => 'admin.php?page=' . self::ParentMenuId . '-settings', 'form_action' => 'admin.php?page=' . self::ParentMenuId . '-settings' . '&tab=' . $active_tab); $this->display('settings_accounts', $aData); }
public function displayEditPage() { // init model // get item if ($this->requestAction() == 'add_new_profile') { $profile = new WPLA_AmazonProfile(); } else { $profile = new WPLA_AmazonProfile($_REQUEST['profile']); } // $listingsModel = new ListingsModel(); // $prepared_listings = $listingsModel->getAllPreparedWithProfile( $item['profile_id'] ); // $verified_listings = $listingsModel->getAllVerifiedWithProfile( $item['profile_id'] ); // $published_listings = $listingsModel->getAllPublishedWithProfile( $item['profile_id'] ); // $ended_listings = $listingsModel->getAllEndedWithProfile( $item['profile_id'] ); $lm = new WPLA_ListingsModel(); $listings = $profile->profile_id ? $lm->findAllListingsByColumn($profile->profile_id, 'profile_id') : array(); $accounts = WPLA_AmazonAccount::getAll(); $templates = WPLA_AmazonFeedTemplate::getAll(); // separate ListingLoader templates $category_templates = array(); $liloader_templates = array(); foreach ($templates as $tpl) { if ($tpl->title == 'Offer') { $tpl->title = "Listing Loader"; $liloader_templates[] = $tpl; } else { $category_templates[] = $tpl; } } $aData = array('plugin_url' => self::$PLUGIN_URL, 'message' => $this->message, 'profile' => $profile, 'accounts' => $accounts, 'category_templates' => $category_templates, 'liloader_templates' => $liloader_templates, 'profile_listings' => $listings, 'profile_details' => maybe_unserialize($profile->details), 'form_action' => 'admin.php?page=' . self::ParentMenuId . '-profiles'); // $this->display( 'profiles_edit_page', array_merge( $aData, $profile ) ); $this->display('profiles_edit_page', $aData); }
function extra_tablenav($which) { if ('top' != $which) { return; } $wpl_accounts = WPLA_AmazonAccount::getAll(true); $account_id = isset($_REQUEST['account_id']) ? $_REQUEST['account_id'] : false; ?> <div class="alignleft actions" style=""> <select name="account_id"> <option value=""><?php _e('All accounts', 'wpla'); ?> </option> <?php foreach ($wpl_accounts as $account) { ?> <option value="<?php echo $account->id; ?> " <?php if ($account_id == $account->id) { echo 'selected'; } ?> ><?php echo $account->title; ?> </option> <?php } ?> </select> <input type="submit" name="" id="post-query-submit" class="button" value="Filter"> </div> <?php }
public function handleActions() { // trigger reports update if ($this->requestAction() == 'update_reports') { do_action('wpla_update_reports'); } // trigger report request if ($this->requestAction() == 'request_report') { $accounts = WPLA_AmazonAccount::getAll(); foreach ($accounts as $account) { $api = new WPLA_AmazonAPI($account->id); // request report - returns request list as array on success $reports = $api->requestReport($_REQUEST['wpla_report_type']); if (is_array($reports)) { // process the result // $this->processReportsRequestList( $reports, $account ); WPLA_AmazonReport::processReportsRequestList($reports, $account); $this->showMessage(sprintf(__('Report requested for account %s.', 'wpla'), $account->title)); } elseif ($reports->Error->Message) { $this->showMessage(sprintf(__('There was a problem requesting the report for account %s.', 'wpla'), $account->title) . '<br>Error: ' . $reports->Error->Message, 1); } else { $this->showMessage(sprintf(__('There was a problem requesting the report for account %s.', 'wpla'), $account->title), 1); } } } // handle load report action if ($this->requestAction() == 'load_report_from_amazon') { $report = new WPLA_AmazonReport($_REQUEST['amazon_report']); $report->loadFromAmazon(); // $api = new WPLA_AmazonAPI( $report->account_id ); // $api->getReport( $report->GeneratedReportId ); $this->showMessage(__('Report was downloaded from Amazon.', 'wpla')); } // handle process report action if ($this->requestAction() == 'process_amazon_report') { $this->processReportData($_REQUEST['amazon_report']); $this->showMessage(__('Report was processed.', 'wpla')); } // handle process report action if ($this->requestAction() == 'process_fba_shipment_report') { $this->processFbaShipmentReportData($_REQUEST['amazon_report']); } // handle delete_amazon_report action if ($this->requestAction() == 'delete_amazon_report') { $this->deleteReports($_REQUEST['amazon_report']); $this->showMessage(__('Selected items were removed.', 'wpla')); } // handle update_amazon_report action if ($this->requestAction() == 'update_amazon_report') { $this->updateReports($_REQUEST['amazon_report']); $this->showMessage(__('Selected items were updated.', 'wpla')); } }
<?php wp_nonce_field('wpla_import_page'); ?> <input type="hidden" name="action" value="wpla_bulk_import_asins" /> <textarea name="wpla_asin_list" style="width:100%;height:230px;"><?php echo @$_REQUEST['wpla_asin_list']; ?> </textarea> <p> <select name="wpla_import_account_id"> <option>— select your account —</option> <?php $all_accounts = WPLA_AmazonAccount::getAll(true); ?> <?php $default_account_id = get_option('wpla_default_account_id'); ?> <?php foreach ($all_accounts as $account) { ?> <option value="<?php echo $account->id; ?> " <?php if ($account->id == $default_account_id) { echo 'selected'; }
static function updatePendingFeeds() { WPLA()->logger->info('updatePendingFeeds()'); $accounts = WPLA_AmazonAccount::getAll(); // WPLA()->logger->info('found accounts: '.print_r($accounts,1)); foreach ($accounts as $account) { self::updatePendingFeedForAccount($account); } }
public function request_daily_inventory_report() { $report_type = '_GET_MERCHANT_LISTINGS_DATA_'; $accounts = WPLA_AmazonAccount::getAll(); foreach ($accounts as $account) { $api = new WPLA_AmazonAPI($account->id); // request report - returns request list as array on success $reports = $api->requestReport($report_type); if (is_array($reports)) { // process the result WPLA_AmazonReport::processReportsRequestList($reports, $account, true); } elseif ($reports->Error->Message) { } else { } } // foreach account }
public function updateFeedStatus($feed_ids) { WPLA()->logger->info("updateFeedStatus() - " . join(', ', $feed_ids)); // echo "<pre>";print_r($feed_ids);echo"</pre>";die(); if (empty($feed_ids)) { return; } $accounts = WPLA_AmazonAccount::getAll(); foreach ($feed_ids as $feed_id) { $feed = new WPLA_AmazonFeed($feed_id); $account = new WPLA_AmazonAccount($feed->account_id); $api = new WPLA_AmazonAPI($feed->account_id); // get feed submissions $feeds = $api->getFeedSubmissionList($feed->FeedSubmissionId); if (is_array($feeds)) { // run the import WPLA_AmazonFeed::processFeedsSubmissionList($feeds, $account); $msg = sprintf(__('%s feed submission(s) were found for account %s.', 'wpla'), sizeof($feeds), $account->title); WPLA()->logger->info($msg); $this->showMessage(nl2br($msg), 0, 1); } elseif ($feeds->Error->Message) { $msg = sprintf(__('There was a problem fetching feed submissions for account %s.', 'wpla'), $account->title) . ' - Error: ' . $feeds->Error->Message; WPLA()->logger->error($msg); $this->showMessage(nl2br($msg), 1, 1); } else { $msg = sprintf(__('There was a problem fetching feed submissions for account %s.', 'wpla'), $account->title); WPLA()->logger->error($msg); $this->showMessage(nl2br($msg), 1, 1); } } }
public function loadAccounts() { $accounts = get_option('wpla_db_version') > 3 ? WPLA_AmazonAccount::getAll(true) : array(); foreach ($accounts as $account) { $this->accounts[$account->id] = $account; } $this->multi_account = count($this->accounts) > 1 ? true : false; }
function extra_tablenav($which) { if ('top' != $which) { return; } $wpl_profiles = WPLA_AmazonProfile::getAll(); $wpl_accounts = WPLA_AmazonAccount::getAll(true); $profile_id = isset($_REQUEST['profile_id']) ? $_REQUEST['profile_id'] : false; $account_id = isset($_REQUEST['account_id']) ? $_REQUEST['account_id'] : false; // echo "<pre>";print_r($wpl_profiles);echo"</pre>";die(); ?> <div class="alignleft actions" style=""> <select name="profile_id"> <option value=""><?php _e('All profiles', 'wpla'); ?> </option> <option value="_NONE_" <?php if ($profile_id == '_NONE_') { echo 'selected'; } ?> ><?php _e('No profile', 'wpla'); ?> </option> <?php foreach ($wpl_profiles as $profile) { ?> <option value="<?php echo $profile->profile_id; ?> " <?php if ($profile_id == $profile->profile_id) { echo 'selected'; } ?> ><?php echo $profile->profile_name; ?> </option> <?php } ?> </select> <select name="account_id"> <option value=""><?php _e('All accounts', 'wpla'); ?> </option> <?php foreach ($wpl_accounts as $account) { ?> <option value="<?php echo $account->id; ?> " <?php if ($account_id == $account->id) { echo 'selected'; } ?> ><?php echo $account->title; ?> (<?php echo $account->market_code; ?> )</option> <?php } ?> </select> <input type="submit" name="" id="post-query-submit" class="button" value="Filter"> </div> <?php }
function add_wc_order_table_filter_options() { global $typenow; if ($typenow != 'shop_order') { return; } if (!isset($_REQUEST['is_from_amazon'])) { return; } $wpl_accounts = WPLA_AmazonAccount::getAll(true); $account_id = isset($_REQUEST['wpla_account_id']) ? $_REQUEST['wpla_account_id'] : false; ?> <select name="wpla_account_id"> <option value=""><?php _e('All Amazon accounts', 'wpla'); ?> </option> <?php foreach ($wpl_accounts as $account) { ?> <option value="<?php echo $account->id; ?> " <?php if ($account_id == $account->id) { echo 'selected'; } ?> ><?php echo $account->title; ?> (<?php echo $account->market_code; ?> )</option> <?php } ?> </select> <input type="hidden" name="is_from_amazon" value="<?php echo isset($_REQUEST['is_from_amazon']) ? $_REQUEST['is_from_amazon'] : ''; ?> "> <?php }
public function requestNewInventoryReport($report_type = '_GET_MERCHANT_LISTINGS_DATA_') { $accounts = WPLA_AmazonAccount::getAll(); foreach ($accounts as $account) { $api = new WPLA_AmazonAPI($account->id); // request report - returns request list as array on success $reports = $api->requestReport($report_type); if (is_array($reports)) { // process the result // $this->processReportsRequestList( $reports, $account ); WPLA_AmazonReport::processReportsRequestList($reports, $account); $this->showMessage(sprintf(__('Report requested for account %s.', 'wpla'), $account->title)); } elseif ($reports->Error->Message) { $this->showMessage(sprintf(__('There was a problem requesting the report for account %s.', 'wpla'), $account->title) . '<br>Error: ' . $reports->Error->Message, 1); } else { $this->showMessage(sprintf(__('There was a problem requesting the report for account %s.', 'wpla'), $account->title), 1); } } }