/** * Gets the current progress of a specific listing job * */ private function getListingProgressAction() { $jobId = $_POST['jobId']; $jobKey = 'ebay:list_products:id:' . $jobId; $prefix = 'ebay:list_products:' . $jobId . ':'; $keystore = Interspire_KeyStore::instance(); $percent = 0; $eta = ''; $progress = ''; $progressBasic = ''; if ($keystore->exists($jobKey)) { $offset = (int)$keystore->get($prefix . 'actual_processed'); $abort = (bool)$keystore->get($prefix . 'abort'); $error = (int)$keystore->get($prefix . 'error_count'); $total = (int)$keystore->get($prefix . 'estimated_total'); if ($total) { if ($offset) { $percent = round($offset / $total * 100); if ($percent > 100) { $percent = 100; } $per = (time() - (int)$keystore->get($prefix . 'started')) / $offset; $remaining = Store_DateTime::duration(($total - $offset) * $per, Store_DateTime::DURATION_MINUTES); $eta = "<br />" . GetLang('EbayListingETA', array( 'remaining' => $remaining, )); } $total = GetLang('of') . ' ' . number_format($total, 0, GetConfig('DecimalToken'), GetConfig('ThousandsToken')); } else { $total = ''; } $offset = number_format($offset, 0, GetConfig('DecimalToken'), GetConfig('ThousandsToken')); $error = number_format($error, 0, GetConfig('DecimalToken'), GetConfig('ThousandsToken')); $progress = GetLang('EbayListingProgress', array( 'offset' => $offset, 'total' => $total, 'error' => $error, 'eta' => $eta )); $progressBasic = GetLang('EbayListingProgressBasic', array( 'offset' => $offset, 'total' => $total, )); } else { $percent = 100; } ISC_JSON::output('', true, array('percent' => $percent, 'progress' => $progress, 'progressBasic' => $progressBasic)); }
protected function getEbayListingNotifications() { $notifications = array(); // Show information about email integration tasks in progress $keystore = Interspire_KeyStore::instance(); $exports = $keystore->multiGet('ebay:list_products:id:*'); foreach ($exports as $exportId) { $prefix = 'ebay:list_products:' . $exportId . ':'; $offset = (int)$keystore->get($prefix . 'true_offset'); $abort = (bool)$keystore->get($prefix . 'abort'); $error = (int)$keystore->get($prefix . 'error_count'); $total = (int)$keystore->get($prefix . 'estimated_total'); $eta = ''; if ($total) { if ($offset) { $per = (time() - (int)$keystore->get($prefix . 'started')) / $offset; $remaining = Store_DateTime::duration(($total - $offset) * $per, Store_DateTime::DURATION_MINUTES); if ($remaining) { $eta = '<br />' . GetLang('Ebay_Notifications_InProgress_ETA', array( 'remaining' => $remaining, )); } } $total = GetLang('of') . ' ' . number_format($total, 0, GetConfig('DecimalToken'), GetConfig('ThousandsToken')); } else { $total = ''; } $offset = number_format($offset, 0, GetConfig('DecimalToken'), GetConfig('ThousandsToken')); $error = number_format($error, 0, GetConfig('DecimalToken'), GetConfig('ThousandsToken')); $template = $keystore->get($prefix . 'template_name'); $notice = ''; if ($abort) { $notice = GetLang('Ebay_Notifications_Abort', array( 'template' => $template, )); } else { $notice = GetLang('Ebay_Notifications_InProgress', array( 'offset' => $offset, 'total' => $total, 'error' => $error, 'eta' => $eta, 'template' => $template, )) . '<br /><a href="#" class="Ebay_Export_Abort" id="Ebay_Export_Abort_' . isc_html_escape($exportId) . '" title="' . isc_html_escape(GetLang('Ebay_Notifications_InProgress_Abort_Title')) . '">' . GetLang('Ebay_Notifications_InProgress_Abort_Label') . '</a>'; } if ($notice) { $notifications[] = $notice; } } return $notifications; }