Пример #1
0
 /**
  * Delivers order export files to the browser
  *
  * @author Jonathan Davis
  * @since 1.1
  *
  * @return void
  **/
 public function export_purchases()
 {
     if (!current_user_can('shopp_financials') || !current_user_can('shopp_export_orders')) {
         exit;
     }
     if (!isset($_POST['settings']['purchaselog_columns'])) {
         $Purchase = ShoppPurchase::exportcolumns();
         $Purchased = ShoppPurchased::exportcolumns();
         $_POST['settings']['purchaselog_columns'] = array_keys(array_merge($Purchase, $Purchased));
         $_POST['settings']['purchaselog_headers'] = 'on';
     }
     shopp_set_formsettings();
     // Save workflow setting
     $format = shopp_setting('purchaselog_format');
     if (empty($format)) {
         $format = 'tab';
     }
     switch ($format) {
         case 'csv':
             new PurchasesCSVExport();
             break;
         case 'iif':
             new PurchasesIIFExport();
             break;
         default:
             new PurchasesTabExport();
     }
     exit;
 }
Пример #2
0
 /**
  * Renders the admin screen
  *
  * @author Jonathan Davis
  * @since 1.3
  *
  * @return void
  **/
 public function screen()
 {
     if (!current_user_can('shopp_financials')) {
         wp_die(__('You do not have sufficient permissions to access this page.', 'Shopp'));
     }
     extract($this->options, EXTR_SKIP);
     $Report = $this->Report;
     $Report->pagination();
     $ListTable = ShoppUI::table_set_pagination($screen, $Report->total, $Report->pages, $per_page);
     $ranges = array('all' => __('Show All Orders', 'Shopp'), 'today' => __('Today', 'Shopp'), 'week' => __('This Week', 'Shopp'), 'month' => __('This Month', 'Shopp'), 'quarter' => __('This Quarter', 'Shopp'), 'year' => __('This Year', 'Shopp'), 'yesterday' => __('Yesterday', 'Shopp'), 'lastweek' => __('Last Week', 'Shopp'), 'last30' => __('Last 30 Days', 'Shopp'), 'last90' => __('Last 3 Months', 'Shopp'), 'lastmonth' => __('Last Month', 'Shopp'), 'lastquarter' => __('Last Quarter', 'Shopp'), 'lastyear' => __('Last Year', 'Shopp'), 'custom' => __('Custom Dates', 'Shopp'));
     $exports = array('tab' => __('Tab-separated.txt', 'Shopp'), 'csv' => __('Comma-separated.csv', 'Shopp'));
     $format = shopp_setting('report_format');
     if (!$format) {
         $format = 'tab';
     }
     $columns = array_merge(ShoppPurchase::exportcolumns(), ShoppPurchased::exportcolumns());
     $selected = shopp_setting('purchaselog_columns');
     if (empty($selected)) {
         $selected = array_keys($columns);
     }
     $reports = self::reports();
     $report_title = isset($reports[$report]) ? $reports[$report]['name'] : __('Report', 'Shopp');
     include $this->ui('reports.php');
 }
Пример #3
0
 /**
  * Interface processor for the orders list interface
  *
  * @author Jonathan Davis
  *
  * @return void
  **/
 public function orders()
 {
     if (!current_user_can('shopp_orders')) {
         wp_die(__('You do not have sufficient permissions to access this page.', 'Shopp'));
     }
     global $Shopp, $Orders;
     $defaults = array('page' => false, 'update' => false, 'newstatus' => false, 'paged' => 1, 'per_page' => 20, 'status' => false, 's' => '', 'range' => '', 'startdate' => '', 'enddate' => '');
     $args = array_merge($defaults, $_GET);
     extract($args, EXTR_SKIP);
     $s = stripslashes($s);
     $statusLabels = shopp_setting('order_status');
     if (empty($statusLabels)) {
         $statusLabels = array('');
     }
     $txnstatus_labels = Lookup::txnstatus_labels();
     $Purchase = new ShoppPurchase();
     $Orders = $this->orders;
     $ordercount = $this->ordercount;
     $num_pages = ceil($ordercount->total / $per_page);
     $ListTable = ShoppUI::table_set_pagination($this->screen, $ordercount->total, $num_pages, $per_page);
     $ranges = array('all' => __('Show All Orders', 'Shopp'), 'today' => __('Today', 'Shopp'), 'week' => __('This Week', 'Shopp'), 'month' => __('This Month', 'Shopp'), 'quarter' => __('This Quarter', 'Shopp'), 'year' => __('This Year', 'Shopp'), 'yesterday' => __('Yesterday', 'Shopp'), 'lastweek' => __('Last Week', 'Shopp'), 'last30' => __('Last 30 Days', 'Shopp'), 'last90' => __('Last 3 Months', 'Shopp'), 'lastmonth' => __('Last Month', 'Shopp'), 'lastquarter' => __('Last Quarter', 'Shopp'), 'lastyear' => __('Last Year', 'Shopp'), 'lastexport' => __('Last Export', 'Shopp'), 'custom' => __('Custom Dates', 'Shopp'));
     $exports = array('tab' => __('Tab-separated.txt', 'Shopp'), 'csv' => __('Comma-separated.csv', 'Shopp'), 'xls' => __('Microsoft® Excel.xls', 'Shopp'), 'iif' => __('Intuit® QuickBooks.iif', 'Shopp'));
     $formatPref = shopp_setting('purchaselog_format');
     if (!$formatPref) {
         $formatPref = 'tab';
     }
     $exportcolumns = array_merge(ShoppPurchase::exportcolumns(), ShoppPurchased::exportcolumns());
     $selected = shopp_setting('purchaselog_columns');
     if (empty($selected)) {
         $selected = array_keys($exportcolumns);
     }
     $Gateways = $Shopp->Gateways;
     include $this->ui('orders.php');
 }
Пример #4
0
 public function __construct()
 {
     $this->purchase_cols = ShoppPurchase::exportcolumns();
     $this->purchased_cols = ShoppPurchased::exportcolumns();
     $this->defined = array_merge($this->purchase_cols, $this->purchased_cols);
     $this->sitename = get_bloginfo('name');
     $this->headings = shopp_setting('purchaselog_headers') == "on";
     $this->selected = shopp_setting('purchaselog_columns');
     $this->date_format = get_option('date_format');
     $this->time_format = get_option('time_format');
     shopp_set_setting('purchaselog_lastexport', current_time('timestamp'));
 }
Пример #5
0
/**
 * shopp_rmv_order_line_data - remove all or one data key=>value pair from the order line data array
 *
 * @api
 * @since 1.2
 *
 * @param int $order (required) the order id
 * @param int $line (required) the order line item
 * @param string $name (optional default:false) the key to remove, removes all data when false
 * @return bool true on success, false on failure
 **/
function shopp_rmv_order_line_data($order = false, $line = 0, $name = false)
{
    $Lines = shopp_order_lines($order);
    if (empty($Lines) || $line >= count($Lines) || !isset($Lines[$line])) {
        return false;
    }
    $Purchased = new ShoppPurchased();
    $Purchased->populate($Lines[$line]);
    if (!is_array($Purchased->data)) {
        $Purchased->data = array();
    }
    if ($name && in_array($name, array_keys($Purchased->data))) {
        unset($Purchased->data[$name]);
    }
    $Purchased->save();
}
Пример #6
0
 /**
  * Builds purchased records from cart items attached to the given Purchase ID
  *
  * @author Jonathan Davis
  * @since 1.2.2
  *
  * @param int $purchaseid The Purchase id to attach the purchased records to
  * @return void
  **/
 public function items($purchaseid)
 {
     foreach ($this->Cart as $Item) {
         // Build purchased records from cart items
         $Purchased = new ShoppPurchased();
         $Purchased->purchase = $purchaseid;
         $Purchased->copydata($Item);
         $Purchased->save();
     }
     $this->checksum = $this->Cart->checksum;
     // Track the cart contents checksum to detect changes.
 }
Пример #7
0
 protected function bottom_tablenav()
 {
     if (!current_user_can('shopp_financials') || !current_user_can('shopp_export_orders')) {
         return;
     }
     $exporturl = add_query_arg(urlencode_deep(array_merge(stripslashes_deep($_GET), array('src' => 'export_purchases'))));
     echo '<div class="alignleft actions">' . '	</form><form action="' . esc_url($exporturl) . '" id="log" method="post">' . '		<button type="button" id="export-settings-button" name="export-settings" class="button-secondary">' . Shopp::__('Export Options') . '</button>' . '	<div id="export-settings" class="hidden">' . '		<div id="export-columns" class="multiple-select">' . '			<ul>';
     $even = true;
     echo '				<li' . ($even ? '' : ' class="odd"') . '><input type="checkbox" name="selectall_columns" id="selectall_columns" /><label for="selectall_columns"><strong>' . Shopp::__('Select All') . '</strong></label></li>';
     $even = !$even;
     echo '				<li' . ($even ? '' : ' class="odd"') . '><input type="hidden" name="settings[purchaselog_headers]" value="off" /><input type="checkbox" name="settings[purchaselog_headers]" id="purchaselog_headers" value="on" /><label for="purchaselog_headers"><strong>' . Shopp::__('Include column headings') . '</strong></label></li>';
     $even = !$even;
     $exportcolumns = array_merge(ShoppPurchase::exportcolumns(), ShoppPurchased::exportcolumns());
     $selected = shopp_setting('purchaselog_columns');
     if (empty($selected)) {
         $selected = array_keys($exportcolumns);
     }
     foreach ($exportcolumns as $name => $label) {
         if ('cb' == $name) {
             continue;
         }
         echo '				<li' . ($even ? '' : ' class="odd"') . '><input type="checkbox" name="settings[purchaselog_columns][]" value="' . esc_attr($name) . '" id="column-' . esc_attr($name) . '" ' . (in_array($name, $selected) ? ' checked="checked"' : '') . ' /><label for="column-' . esc_attr($name) . '">' . esc_html($label) . '</label></li>';
         $even = !$even;
     }
     echo '			</ul>' . '		</div>';
     PurchasesIIFExport::settings();
     $exports = array('tab' => Shopp::__('Tab-separated.txt'), 'csv' => Shopp::__('Comma-separated.csv'), 'iif' => Shopp::__('Intuit&reg; QuickBooks.iif'));
     $format = shopp_setting('purchaselog_format');
     if (!$format) {
         $format = 'tab';
     }
     echo '		<br />' . '		<select name="settings[purchaselog_format]" id="purchaselog-format">' . '			' . menuoptions($exports, $format, true) . '		</select>' . '		</div>' . '	<button type="submit" id="download-button" name="download" value="export" class="button-secondary"' . (count($this->items) < 1 ? ' disabled="disabled"' : '') . '>' . Shopp::__('Download') . '</button>' . '	<div class="clear"></div>' . '	</form>' . '</div>';
 }