Skip to content

Commit

Permalink
#9: Add orders-status to omit
Browse files Browse the repository at this point in the history
... also corrects the capturing/defaulting of the other status-related
selections.
  • Loading branch information
lat9 committed Jun 24, 2019
1 parent 15b3b3a commit 814c10d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions YOUR_ADMIN/includes/classes/sales_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function __construct($parms)
$this->payment_method = $parms['payment_method'];
$this->payment_method_omit = $parms['payment_method_omit'];
$this->current_status = $parms['current_status'];
$this->excluded_status = $parms['excluded_status'];
$this->manufacturer = $parms['manufacturer'];
$this->detail_level = $parms['detail_level'];
$this->output_format = $parms['output_format'];
Expand Down Expand Up @@ -225,6 +226,9 @@ function build_timeframe()
if ($this->current_status) {
$sql .= "AND o.orders_status = {$this->current_status}" . PHP_EOL;
}
if ($this->excluded_status) {
$sql .= "AND o.orders_status != {$this->excluded_status}" . PHP_EOL;
}
if ($this->product_filter != '') {
$sql .= $this->product_filter . PHP_EOL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
define('SEARCH_PAYMENT_METHOD', 'Payment Method');
define('SEARCH_PAYMENT_METHOD_OMIT', 'Payment Method To Omit');
define('SEARCH_CURRENT_STATUS', 'Current Order Status');
define('SEARCH_EXCLUDED_STATUS', 'Order Status to Omit');
define('SEARCH_SPECIFIC_CUSTOMERS', 'Only include specific Customer IDs (comma separated list)');
define('SEARCH_SPECIFIC_PRODUCTS', 'Only include specific Product IDs (comma separated list)');
define('SEARCH_MANUFACTURER', 'Product Manufacturer');
Expand Down
15 changes: 10 additions & 5 deletions YOUR_ADMIN/stats_sales_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
'id' => $orders_status->fields['id'],
'text' => $orders_status->fields['text'] . ' [' . $orders_status->fields['id'] . ']'
);
$status_key[$orders_status->fields['id'] ] = $orders_status->fields['text'];
$status_key[$orders_status->fields['id']] = $orders_status->fields['text'];
$orders_status->MoveNext();
}

Expand Down Expand Up @@ -224,14 +224,15 @@

$date_target = (isset($_GET['date_target']) && in_array($_GET['date_target'], array('purchased', 'status'))) ? $_GET['date_target'] : 'purchased';
if ($date_target == 'status') {
$date_status = (isset($_GET['date_status']) && in_array((int)$_GET['date_status'], $status_key)) ? (int)$_GET['date_status'] : DEFAULT_ORDERS_STATUS_ID;
$date_status = (isset($_GET['date_status']) && array_key_exists((int)$_GET['date_status'], $status_key)) ? (int)$_GET['date_status'] : DEFAULT_ORDERS_STATUS_ID;
} else {
$date_status = false;
}

$payment_method = (isset($_GET['payment_method']) && in_array($_GET['payment_method'], $payment_key)) ? $_GET['payment_method'] : '0';
$payment_method_omit = (isset($_GET['payment_method_omit']) && in_array($_GET['payment_method_omit'], $payment_key)) ? $_GET['payment_method_omit'] : '0';
$current_status = (isset($_GET['current_status']) && in_array((int)$_GET['current_status'], $status_key)) ? (int)$_GET['current_status'] : 0;
$current_status = (isset($_GET['current_status']) && array_key_exists((int)$_GET['current_status'], $status_key)) ? (int)$_GET['current_status'] : 0;
$excluded_status = (isset($_GET['excluded_status']) && array_key_exists((int)$_GET['excluded_status'], $status_key)) ? (int)$_GET['excluded_status'] : 0;
$manufacturer = (isset($_GET['manufacturer']) && in_array((int)$_GET['manufacturer'], $manufacturer_key)) ? (int)$_GET['manufacturer'] : 0;
$detail_level = (isset($_GET['detail_level']) && in_array($_GET['detail_level'], $detail_types)) ? $_GET['detail_level'] : 'order';
switch ($detail_level) {
Expand Down Expand Up @@ -364,6 +365,7 @@
'payment_method' => $payment_method,
'payment_method_omit' => $payment_method_omit,
'current_status' => $current_status,
'excluded_status' => $excluded_status,
'manufacturer' => $manufacturer,
'detail_level' => $detail_level,
'output_format' => $output_format,
Expand Down Expand Up @@ -625,7 +627,10 @@ function init()
<td class="smallText"><strong><?php echo SEARCH_PAYMENT_METHOD_OMIT . '</strong><br />' . zen_draw_pull_down_menu('payment_method_omit', $payments_array, $payment_method_omit, 'id="payment_method_omit"'); ?></td>
</tr>
<tr>
<td class="smallText"><strong><?php echo SEARCH_CURRENT_STATUS . '</strong><br />' . zen_draw_pull_down_menu('current_status', array_merge(array(array('id' => 0, 'text' => TEXT_EMPTY_SELECT)), $status_array), $current_status, 'id="current_status"'); ?></td>
<td class="smallText"><strong><?php echo SEARCH_CURRENT_STATUS . '</strong><br />' . zen_draw_pull_down_menu('current_status', array_merge(array(array('id' => '0', 'text' => TEXT_EMPTY_SELECT)), $status_array), $current_status, 'id="current_status"'); ?></td>
</tr>
<tr>
<td class="smallText"><strong><?php echo SEARCH_EXCLUDED_STATUS . '</strong><br />' . zen_draw_pull_down_menu('excluded_status', array_merge(array(array('id' => '0', 'text' => TEXT_EMPTY_SELECT)), $status_array), $excluded_status, 'id="excluded-status"'); ?></td>
</tr>
<?php
if (count($manufacturer_array) != 0) {
Expand Down Expand Up @@ -725,7 +730,7 @@ function init()
<span id="span-csv-header"><?php echo zen_draw_checkbox_field('csv_header', '1', false) . CHECKBOX_CSV_HEADER; ?></span>
</td>
<td class="smallText right" id="order-total-validation"><?php echo zen_draw_checkbox_field('order_total_validation', '1', false) . CHECKBOX_VALIDATE_TOTALS; ?></td>
<td class="smallText right"><?php echo zen_draw_checkbox_field('new_window', '1', $new_window) . CHECKBOX_NEW_WINDOW; ?>
<td class="smallText right"><?php echo zen_draw_checkbox_field('new_window', '1', $new_window, '', 'id="new-window"') . CHECKBOX_NEW_WINDOW; ?>
<br /><button type="button" id="btn-submit"><?php echo BUTTON_SEARCH; ?></button>
</td>
</tr>
Expand Down

0 comments on commit 814c10d

Please sign in to comment.