|
|
1) {
echo ' ' . tep_draw_form('filter', FILENAME_MARGIN_REPORT, '', 'get') . TEXT_SHOW . ' ';
if (isset($_GET['manufacturers_id'])) {
echo tep_draw_hidden_field('manufacturers_id', $_GET['manufacturers_id']);
$options = array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES_BY_MANUFACTURER));
} else {
echo tep_draw_hidden_field('cPath', $cPath);
$options = array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS));
}
echo tep_draw_hidden_field('sort', $_GET['sort']);
while ($filterlist = tep_db_fetch_array($filterlist_query)) {
$options[] = array('id' => $filterlist['id'], 'text' => $filterlist['name']);
}
if (!isset($_GET['manufacturers_id'])) echo tep_draw_pull_down_menu('manufacturers_id', $options, (isset($_GET['filter_id']) ? $_GET['filter_id'] : ''), 'onchange="this.form.submit()"');
if (isset($_GET['manufacturers_id'])) echo tep_draw_pull_down_menu('filter_id', $options, (isset($_GET['filter_id']) ? $_GET['filter_id'] : ''), 'onchange="this.form.submit()"');
echo ' | ' . "\n";
}
?>
|
'1',
'PRODUCT_LIST_COST' => '2',
'PRODUCT_LIST_PRICE' => '3',
'PRODUCT_LIST_SPECIAL_PRICE' => '4',
'PRODUCT_LIST_MARGIN_DOLLARS' => '5',
'PRODUCT_LIST_MARGIN_PERCENTAGE' => '6');
asort($define_list);
$column_list = array();
reset($define_list);
while (list($key, $value) = each($define_list)) {
if ($value > 0) $column_list[] = $key;
}
// show the products of a specified manufacturer
if (isset($_GET['manufacturers_id'])) {
if (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
// We are asked to show only a specific category
$listing_sql = "select p.products_id, p.products_price as products_price, p.products_cost, pd.products_name, IF(s.status, s.specials_new_products_price, NULL) as specials_price, if(s.status, s.specials_new_products_price-p.products_cost, p.products_price-p.products_cost) as margin_dollars, if(s.status, (s.specials_new_products_price-p.products_cost)/s.specials_new_products_price*100, (p.products_price-p.products_cost)/p.products_price*100) as margin_percentage, p2c.categories_id as category, c.parent_id as parent from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where pd.language_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id and p2c.products_id = p.products_id and c.categories_id = p2c.categories_id and p2c.categories_id = '" . (int)$_GET['filter_id'] . "' and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'";
} else {
// We show them all
$listing_sql = "select p.products_id, p.products_price as products_price, p.products_cost, pd.products_name, IF(s.status, s.specials_new_products_price, NULL) as specials_price, if(s.status, s.specials_new_products_price-p.products_cost, p.products_price-p.products_cost) as margin_dollars, if(s.status, (s.specials_new_products_price-p.products_cost)/s.specials_new_products_price*100, (p.products_price-p.products_cost)/p.products_price*100) as margin_percentage, p2c.categories_id as category, c.parent_id as parent from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_MANUFACTURERS . " m, " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where pd.language_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id and p2c.products_id = p.products_id and c.categories_id = p2c.categories_id and p.manufacturers_id = m.manufacturers_id and m.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "'";
}
} elseif (isset($_GET['filter_id']) && tep_not_null($_GET['filter_id'])) {
// show the products in a given category
// We are asked to show only specific category
$listing_sql = "select p.products_id, p.products_price as products_price, p.products_cost, pd.products_name, IF(s.status, s.specials_new_products_price, NULL) as specials_price, if(s.status, s.specials_new_products_price-p.products_cost, p.products_price-p.products_cost) as margin_dollars, if(s.status, (s.specials_new_products_price-p.products_cost)/s.specials_new_products_price*100, (p.products_price-p.products_cost)/p.products_price*100) as margin_percentage, p2c.categories_id as category, c.parent_id as parent from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where pd.language_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id and p2c.products_id = p.products_id and c.categories_id = p2c.categories_id and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'";
} elseif (isset($_GET['report_id']) && tep_not_null($_GET['report_id'])) {
// Show the products from the time frame defined by the report variable.
$listing_sql = "select p.products_id, p.products_price as products_price, p.products_cost, pd.products_name, IF(s.status, s.specials_new_products_price, NULL) as specials_price, if(s.status, s.specials_new_products_price-p.products_cost, p.products_price-p.products_cost) as margin_dollars, if(s.status, (s.specials_new_products_price-p.products_cost)/s.specials_new_products_price*100, (p.products_price-p.products_cost)/p.products_price*100) as margin_percentage, p2c.categories_id as category, c.parent_id as parent from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where pd.language_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id and p2c.products_id = p.products_id and c.categories_id = p2c.categories_id and p2c.categories_id = '" . (int)$_GET['filter_id'] . "'";
} else {
// We show them all
$listing_sql = "select " . $select_column_list . " p.products_id, p.products_price as products_price, p.products_cost, pd.products_name, IF(s.status, s.specials_new_products_price, NULL) as specials_price, if(s.status, s.specials_new_products_price-p.products_cost, p.products_price-p.products_cost) as margin_dollars, if(s.status, (s.specials_new_products_price-p.products_cost)/s.specials_new_products_price*100, (p.products_price-p.products_cost)/p.products_price*100) as margin_percentage, p2c.categories_id as category, c.parent_id as parent from (" . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_DESCRIPTION . " pd) left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id where pd.language_id = '" . (int)$languages_id . "' and p.products_id = pd.products_id and p2c.products_id = p.products_id and c.categories_id = p2c.categories_id";
}
if ( (!isset($_GET['sort'])) || (!ereg('[1-8][ad]', $_GET['sort'])) || (substr($_GET['sort'], 0, 1) > sizeof($column_list)) ) {
for ($i=0, $n=sizeof($column_list); $i<$n; $i++) {
if ($column_list[$i] == 'PRODUCT_LIST_PRODUCT') {
$_GET['sort'] = $i+1 . 'a';
$listing_sql .= " order by pd.products_name";
break;
}
}
} else {
$sort_col = substr($_GET['sort'], 0 , 1);
$sort_order = substr($_GET['sort'], 1);
$listing_sql .= ' order by ';
switch ($column_list[$sort_col-1]) {
case 'PRODUCT_LIST_PRODUCT':
$listing_sql .= "pd.products_name " . ($sort_order == 'd' ? 'desc' : '');
break;
case 'PRODUCT_LIST_COST':
$listing_sql .= "p.products_cost " . ($sort_order == 'd' ? 'desc' : '');
break;
case 'PRODUCT_LIST_PRICE':
$listing_sql .= "p.products_price " . ($sort_order == 'd' ? 'desc' : '');
break;
case 'PRODUCT_LIST_SPECIAL_PRICE':
$listing_sql .= "specials_price " . ($sort_order == 'd' ? 'desc' : '');
break;
case 'PRODUCT_LIST_MARGIN_DOLLARS':
$listing_sql .= "margin_dollars " . ($sort_order == 'd' ? 'desc' : '');
break;
case 'PRODUCT_LIST_MARGIN_PERCENTAGE':
$listing_sql .= "margin_percentage " . ($sort_order == 'd' ? 'desc' : '');
break;
}
}
$listing_split = new splitPageResults2($listing_sql, MAX_DISPLAY_SEARCH_RESULTS);
if (($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
| display_count2(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?> |
display_links2(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('info', 'x', 'y'))); ?> |
$lc_align,
'params' => 'class="dataTableHeadingRow"',
'text' => ' ' . $lc_text . ' ');
}
if ($listing_split->number_of_rows > 0) {
$rows = 0;
$listing_query = tep_db_query($listing_split->sql_query);
while ($listing = tep_db_fetch_array($listing_query)) {
$rows++;
if (($rows/2) == floor($rows/2)) {
$list_box_contents[] = array('params' => 'class="dataTableContent"');
} else {
$list_box_contents[] = array('params' => 'class="dataTableContent"');
}
$cur_row = sizeof($list_box_contents) - 1;
for ($col=0, $n=sizeof($column_list); $col<$n; $col++) {
$lc_align = '';
switch ($column_list[$col]) {
case 'PRODUCT_LIST_PRODUCT':
$lc_align = '';
if ($listing['parent'] == '0') {
$lc_text = ' ' . $listing['products_name'] . ' ';
} else {
$lc_text = ' ' . $listing['products_name'] . ' ';
}
break;
case 'PRODUCT_LIST_COST':
$lc_align = '';
$lc_text = ' ' . $currencies->format($listing['products_cost']) . ' ';
break;
case 'PRODUCT_LIST_PRICE':
$lc_align = '';
if (tep_not_null($listing['specials_price'])) {
$lc_text = ' ' . $currencies->format($listing['products_price']) . ' ';
} else {
$lc_text = ' ' . $currencies->format($listing['products_price']) . ' ';
}
break;
case 'PRODUCT_LIST_SPECIAL_PRICE':
$lc_align = 'right';
if (tep_not_null($listing['specials_price'])) {
$lc_text = ' ' . '' . $currencies->format($listing['specials_price']) . ' ';
} else {
$lc_text = ' ' . ' ' . ' ';
}
break;
case 'PRODUCT_LIST_MARGIN_DOLLARS':
$lc_align = 'right';
if ($listing['products_price'] > $listing['products_cost']) {
$lc_text = ' ' . $currencies->format($listing['margin_dollars']) . ' ';
} else {
$lc_text = ' ' . '' . $currencies->format($listing['margin_dollars']) . '' . ' ';
}
break;
case 'PRODUCT_LIST_MARGIN_PERCENTAGE':
$lc_align = 'right';
if ($listing['products_price'] > $listing['products_cost']) {
$lc_text = ' ' . number_format($listing['margin_percentage'], '2', '.', ',') . '%' . ' ';
} else {
$lc_text = ' ' . '' . number_format($listing['margin_percentage'], '2', '.', ',') . '%' . ' ';
}
break;
}
$list_box_contents[$cur_row][] = array('align' => $lc_align,
'params' => 'class="dataTableRow"',
'text' => $lc_text);
}
}
new productListingBox($list_box_contents);
} else {
$list_box_contents = array();
$list_box_contents[0] = array('params' => 'class="productListing-odd"');
$list_box_contents[0][] = array('params' => 'class="productListing-data"',
'text' => TEXT_NO_PRODUCTS);
new productListingBox($list_box_contents);
}
if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
| display_count2(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?> |
display_links2(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('info', 'x', 'y'))); ?> |
| ' . tep_image_button('button_back.gif', BUTTON_BACK_TO_MAIN) . ''; ?> |
' . tep_draw_form('report', FILENAME_MARGIN_REPORT2, '', 'get') . TEXT_SHOW . ' ';
$options = array();
$options[] = array('id' => 'all', 'text' => TEXT_SELECT_REPORT);
$options[] = array('id' => 'daily', 'text' => TEXT_SELECT_REPORT_DAILY);
$options[] = array('id' => 'weekly', 'text' => TEXT_SELECT_REPORT_WEEKLY);
$options[] = array('id' => 'monthly', 'text' => TEXT_SELECT_REPORT_MONTHLY);
$options[] = array('id' => 'quarterly', 'text' => TEXT_SELECT_REPORT_QUARTERLY);
$options[] = array('id' => 'semiannually', 'text' => TEXT_SELECT_REPORT_SEMIANNUALLY);
$options[] = array('id' => 'annually', 'text' => TEXT_SELECT_REPORT_ANNUALLY);
echo tep_draw_pull_down_menu('report_id', $options, (isset($_GET['report_id']) ? $_GET['report_id'] : '1'), 'onchange="this.form.submit()"');
echo '' . "\n";
}
if (isset($_GET['manufacturers_id']) && ($_GET['manufacturers_id'] != '') && (!isset($_GET['filter_id']))) {
$get_vars = tep_draw_hidden_field('manufacturers_id', $_GET['manufacturers_id']);
} elseif (isset($_GET['manufacturers_id']) && ($_GET['manufacturers_id'] != '') && (isset($_GET['filter_id']) && ($_GET['filter_id'] != ''))) {
$get_vars = tep_draw_hidden_field('manufacturers_id', $_GET['manufacturers_id']) . tep_draw_hidden_field('filter_id', $_GET['filter_id']);
} else {
$get_vars = '';
}
?>
|
|
|
|