-
Most-Viewed Products - Reports
www.jaysmodelkits.com ZC-v1.5.7d
Okay, so I wanted to use the Most-Viewed Products report tool today and I see it has been "improved" and that it now has a date range facility.
That's cool. It's default is a one month period from the current day and 30 days prior. The problem comes when you attempt to alter the dates. The new date settings only remain for the first page of results then when you click on page two they revert back to the default of one month.
Is this a known problem? I thought it may have been a problem with Safari (Mac) as it does have a habit of throwing up some odd issues, but I tried it in Firefox and found the same problem.
Cheers, John.
-
Re: Most-Viewed Products - Reports
pretty sure this is fixed in 1.5.8.
-
Re: Most-Viewed Products - Reports
I was unable to test the 1.5.8 fix on my test site as it did not have enough product views to generate a second page.
I placed the file on the OP's site and the dates do remain as selected. There are some PHP warnings of undefined items and the date selection appears to be in Chinese but dates can be selected manually and produce the desired results so this temporary workaround is useful.
I'll try to smooth things out and post a corrected file for 1.5.7# when I can.
-
Re: Most-Viewed Products - Reports
-
Re: Most-Viewed Products - Reports
I tried it in 158, it carried the dates through the pages.
-
Re: Most-Viewed Products - Reports
Did the drop-down turn to Chinese?
-
Re: Most-Viewed Products - Reports
If it helps:
on zc158 with PHP 8.0 or PHP 8.1 the start date defaults to the first day of the current year. The dates selected are carried through on all subsequent pages when using "Next" to select a page or using the drop down page number list. Either date can be selected and changed. No errors reported.
Zen Cart 158 Alpha PHP 8.1.7
-
Re: Most-Viewed Products - Reports
Fix:
a) copy admin/stats_products_viewed.php from 158
b) Update language file admin/includes/languages/english/stats_products_viewed.php - add these defines at the bottom:
define('TABLE_HEADING_PRODUCTS_ID', 'ID#');
define('TABLE_HEADING_PRODUCTS_NAME','Name');
-
Re: Most-Viewed Products - Reports
Quote:
Originally Posted by
swguy
Fix:
a) copy admin/stats_products_viewed.php from 158
b) Update language file ???/includes/languages/english/stats_products_viewed.php - add these defines at the bottom:
define('TABLE_HEADING_PRODUCTS_ID', 'ID#');
define('TABLE_HEADING_PRODUCTS_NAME','Name');
Should that not be YOUR_ADMIN?
BTW, I still get Chinese(?) in the drop-down date selector
-
Re: Most-Viewed Products - Reports
Yes, the language file path starts with admin.
No idea on the Chinese issue.
-
Re: Most-Viewed Products - Reports
Have at least two sites with identical files but, the report for one gives the date dropdown in (apparently) chinese.
Haven't been able to find a differing file between the two yet, the different date pull-down.:dontgetit
-
Re: Most-Viewed Products - Reports
When you said chinese, I didn't understand you actually meant chinese!
Can you post an image?
-
1 Attachment(s)
Re: Most-Viewed Products - Reports
-
Re: Most-Viewed Products - Reports
If I hadn't seen it, I wouldn't have believed it.
But this is specific to your installation, not a bug in Zen Cart.
-
Re: Most-Viewed Products - Reports
It's just that I have compared all our sites using this mod and all are using files that are exactly the same.
Very open to suggestions as to where it may have come from or what files might be involved.
:frusty:
-
Re: Most-Viewed Products - Reports
Are all those characters chinese (or other asian language) equivalents to what should be there?
Or are they unrelated characters that are the character represented by whatever extended-ascii bit pattern is getting to the browser?
If the files are identical, it must be an environment issue, (*nix/windows, mysql, php versions and their defaults).
-
Re: Most-Viewed Products - Reports
All tested sites are on the same server with same PHP:blink:
-
Re: Most-Viewed Products - Reports
-
Re: Most-Viewed Products - Reports
This is the culprit
1.5.7d No Chinese but date changes on second page
Code:
<?php/**
* @copyright Copyright 2003-2020 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: DrByte 2020 May 17 Modified in v1.5.7 $
*/
require 'includes/application_top.php';
if (!function_exists('makeUnixTimestampFromDate')) {
function makeUnixTimestampFromDate($input, $format)
{
if (strtolower($format) == 'mm/dd/yyyy') {
// Use US date format (m/d/Y)
return mktime(0, 0, 0, (int)substr($input, 0, 2), (int)substr($input, 3, 2), (int)substr($input, 6, 4));
}
if (strtolower($format) == 'dd/mm/yyyy') {
// Use UK date format (d/m/Y)
return mktime(0, 0, 0, (int)substr($input, 3, 2), (int)substr($input, 0, 2), (int)substr($input, 6, 4));
}
if (strtolower($format) == 'dd.mm.yyyy') {
// Use CZ, SK date format (d/m/Y)
return mktime(0, 0, 0, (int)substr($input, 3, 2), (int)substr($input, 0, 2), (int)substr($input, 6, 4));
}
}
}
$convertedFormat = str_replace(['mm', 'MM', 'dd', 'yyyy'], ['m', 'm', 'd', 'Y'], DATE_FORMAT_SPIFFYCAL);
$startdate = makeUnixTimestampFromDate(date($convertedFormat, strtotime('-30 days')), DATE_FORMAT_SPIFFYCAL);
$enddate = makeUnixTimestampFromDate(date($convertedFormat), DATE_FORMAT_SPIFFYCAL);
if (!empty($_POST['start_date'])) $startdate = makeUnixTimestampFromDate(zen_db_input($_POST['start_date']), DATE_FORMAT_SPIFFYCAL);
if (!empty($_POST['end_date'])) $enddate = makeUnixTimestampFromDate(zen_db_input($_POST['end_date']), DATE_FORMAT_SPIFFYCAL);
$sql = "SELECT p.products_id, pd.products_name, sum(v.views) as total_views, l.name as language, p.products_type, pt.type_handler, pt.allow_add_to_cart
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id
LEFT JOIN " . TABLE_LANGUAGES . " l ON l.languages_id = pd.language_id
INNER JOIN " . TABLE_COUNT_PRODUCT_VIEWS . " v ON p.products_id = v.product_id AND v.language_id = l.languages_id
LEFT JOIN " . TABLE_PRODUCT_TYPES . " pt ON p.products_type = pt.type_id
WHERE date_viewed BETWEEN CAST(:startdate AS DATE) AND CAST(:enddate AS DATE)
GROUP BY p.products_id, pd.products_name, language, p.products_type, pt.type_handler, pt.allow_add_to_cart
ORDER BY total_views DESC";
$sql = $db->bindVars($sql, ':startdate', date('Y-m-d', $startdate), 'string');
$sql = $db->bindVars($sql, ':enddate', date('Y-m-d', $enddate), 'string');
$products_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS_REPORTS, $sql, $products_query_numrows);
$products = $db->Execute($sql);
?>
<!doctype html>
<html <?php echo HTML_PARAMS; ?>>
<head>
<?php require DIR_WS_INCLUDES . 'admin_html_head.php'; ?>
<link rel="stylesheet" type="text/css" href="includes/javascript/spiffyCal/spiffyCal_v2_1.css">
<script src="includes/javascript/spiffyCal/spiffyCal_v2_1.js"></script>
<script>
var StartDate = new ctlSpiffyCalendarBox("StartDate", "date_range", "start_date", "btnDate1", "<?php echo date($convertedFormat, $startdate); ?>", scBTNMODE_CUSTOMBLUE);
var EndDate = new ctlSpiffyCalendarBox("EndDate", "date_range", "end_date", "btnDate2", "<?php echo date($convertedFormat, $enddate); ?>", scBTNMODE_CUSTOMBLUE);
</script>
</head>
<body>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<div id="spiffycalendar" class="text"></div>
<div class="container-fluid">
<!-- body //-->
<h1 class="pageHeading"><?php echo HEADING_TITLE; ?></h1>
<div class="row">
<?php echo zen_draw_form('date_range', FILENAME_STATS_PRODUCTS_VIEWED, '', 'post', 'onsubmit="return check_dates(start_date, StartDate.required, end_date, EndDate.required);" class="form-horizontal"'); ?>
<div class="form-group">
<?php echo zen_draw_label(TEXT_REPORT_START_DATE, 'start_date', 'class="col-sm-3 control-label"'); ?>
<div class="col-sm-4 col-md-3">
<script>StartDate.writeControl();
StartDate.dateFormat = "<?php echo DATE_FORMAT_SPIFFYCAL; ?>";
</script>
</div>
</div>
<div class="form-group">
<?php echo zen_draw_label(TEXT_REPORT_END_DATE, 'end_date', 'class="col-sm-3 control-label"'); ?>
<div class="col-sm-4 col-md-3">
<script>EndDate.writeControl();
EndDate.dateFormat = "<?php echo DATE_FORMAT_SPIFFYCAL; ?>";
</script>
</div>
</div>
<div class="col-sm-7 col-md-6 text-right">
<button type="submit" class="btn btn-primary"><?php echo IMAGE_SUBMIT; ?></button>
</div>
<?php echo '</form>'; ?>
</div>
<br>
<table class="table table-hover">
<thead>
<tr class="dataTableHeadingRow">
<th class="dataTableHeadingContent right"><?php echo TABLE_HEADING_NUMBER; ?></th>
<th class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS; ?></th>
<th class="dataTableHeadingContent text-center"><?php echo TABLE_HEADING_VIEWED; ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($products as $product) {
$cPath = zen_get_product_path($product['products_id']);
$type_handler = $product['type_handler'] . '.php';
?>
<tr class="dataTableRow"
onclick="document.location.href = '<?php echo zen_href_link($type_handler, '&product_type=' . $product['products_type'] . '&cPath=' . $cPath . '&pID=' . $product['products_id'] . '&action=new_product'); ?>'">
<td class="dataTableContent text-right"><?php echo $product['products_id']; ?></td>
<td class="dataTableContent">
<a href="<?php echo zen_href_link($type_handler, '&product_type=' . $product['products_type'] . '&cPath=' . $cPath . '&pID=' . $product['products_id'] . '&action=new_product'); ?>"><?php echo $product['products_name']; ?></a>
(<?php echo $product['language']; ?>)
</td>
<td class="dataTableContent text-center"><?php echo $product['total_views']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<table class="table">
<tr>
<td><?php echo $products_split->display_count($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_REPORTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="text-right"><?php echo $products_split->display_links($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_REPORTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></td>
</tr>
</table>
<!-- body_text_eof //-->
<!-- body_eof //-->
</div>
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php');
1.5.8 No date change but Chinese
Code:
<?php/**
* @copyright Copyright 2003-2022 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: Scott C Wilson 2022 Jan 25 Modified in v1.5.8-alpha $
*/
require 'includes/application_top.php';
if (!function_exists('makeUnixTimestampFromDate')) {
function makeUnixTimestampFromDate($input, $format)
{
if (strtolower($format) == 'mm/dd/yyyy') {
// Use US date format (m/d/Y)
return mktime(0, 0, 0, (int)substr($input, 0, 2), (int)substr($input, 3, 2), (int)substr($input, 6, 4));
}
if (strtolower($format) == 'dd/mm/yyyy') {
// Use UK date format (d/m/Y)
return mktime(0, 0, 0, (int)substr($input, 3, 2), (int)substr($input, 0, 2), (int)substr($input, 6, 4));
}
if (strtolower($format) == 'dd.mm.yyyy') {
// Use CZ, SK date format (d/m/Y)
return mktime(0, 0, 0, (int)substr($input, 3, 2), (int)substr($input, 0, 2), (int)substr($input, 6, 4));
}
}
}
$startdate = zen_db_input($_REQUEST['start_date'] ?? date('Y') . '-01-01');
$enddate = zen_db_input($_REQUEST['end_date'] ?? date('Y-m-d'));
$sql = "SELECT p.products_id, pd.products_name, sum(v.views) as total_views, l.name as language, p.products_type, pt.type_handler, pt.allow_add_to_cart
FROM " . TABLE_PRODUCTS . " p
LEFT JOIN " . TABLE_PRODUCTS_DESCRIPTION . " pd ON p.products_id = pd.products_id
LEFT JOIN " . TABLE_LANGUAGES . " l ON l.languages_id = pd.language_id
INNER JOIN " . TABLE_COUNT_PRODUCT_VIEWS . " v ON p.products_id = v.product_id AND v.language_id = l.languages_id
LEFT JOIN " . TABLE_PRODUCT_TYPES . " pt ON p.products_type = pt.type_id
WHERE date_viewed BETWEEN CAST(:startdate AS DATE) AND CAST(:enddate AS DATE)
GROUP BY p.products_id, pd.products_name, language, p.products_type, pt.type_handler, pt.allow_add_to_cart
ORDER BY total_views DESC";
$sql = $db->bindVars($sql, ':startdate', $startdate, 'string');
$sql = $db->bindVars($sql, ':enddate', $enddate, 'string');
$products_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS_REPORTS, $sql, $products_query_numrows);
$products = $db->Execute($sql);
?>
<!doctype html>
<html <?php echo HTML_PARAMS; ?>>
<head>
<?php require DIR_WS_INCLUDES . 'admin_html_head.php'; ?>
</head>
<body>
<!-- header //-->
<?php require(DIR_WS_INCLUDES . 'header.php'); ?>
<!-- header_eof //-->
<div class="container-fluid">
<!-- body //-->
<h1 class="pageHeading"><?php echo HEADING_TITLE; ?></h1>
<div class="row">
<?php echo zen_draw_form('date_range', FILENAME_STATS_PRODUCTS_VIEWED, '', 'post', 'class="form-horizontal"'); ?>
<div class="form-group">
<?php echo zen_draw_label(TEXT_REPORT_START_DATE, 'start_date', 'class="col-sm-3 control-label"'); ?>
<div class="col-sm-4 col-md-3">
<div class="date input-group" id="datepicker_start_date">
<span class="input-group-addon datepicker_icon">
<i class="fa fa-calendar fa-lg"></i>
</span>
<?php echo zen_draw_input_field('start_date', $startdate, 'class="form-control" id="start_date"'); ?>
</div>
<span class="help-block errorText">(<?php echo zen_datepicker_format_full(); ?>)</span>
</div>
</div>
<div class="form-group">
<?php echo zen_draw_label(TEXT_REPORT_END_DATE, 'end_date', 'class="col-sm-3 control-label"'); ?>
<div class="col-sm-4 col-md-3">
<div class="date input-group" id="datepicker_end_date">
<span class="input-group-addon datepicker_icon">
<i class="fa fa-calendar fa-lg"></i>
</span>
<?php echo zen_draw_input_field('end_date', $enddate, 'class="form-control" id="end_date"'); ?>
</div>
<span class="help-block errorText">(<?php echo zen_datepicker_format_full(); ?>)</span>
</div>
</div>
<div class="col-sm-7 col-md-6 text-right">
<button type="submit" class="btn btn-primary"><?php echo IMAGE_SUBMIT; ?></button>
</div>
<?php echo '</form>'; ?>
</div>
<br>
<table class="table table-hover">
<thead>
<tr class="dataTableHeadingRow">
<th class="dataTableHeadingContent right"><?php echo TABLE_HEADING_PRODUCTS_ID; ?></th>
<th class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_NAME; ?></th>
<th class="dataTableHeadingContent text-center"><?php echo TABLE_HEADING_VIEWED; ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($products as $product) {
$cPath = zen_get_product_path($product['products_id']);
$type_handler = $product['type_handler'] . '.php';
?>
<tr class="dataTableRow"
onclick="document.location.href = '<?php echo zen_href_link(FILENAME_PRODUCT, '&product_type=' . $product['products_type'] . '&cPath=' . $cPath . '&pID=' . $product['products_id'] . '&action=new_product'); ?>'">
<td class="dataTableContent text-right"><?php echo $product['products_id']; ?></td>
<td class="dataTableContent">
<a href="<?php echo zen_href_link(FILENAME_PRODUCT, '&product_type=' . $product['products_type'] . '&cPath=' . $cPath . '&pID=' . $product['products_id'] . '&action=new_product'); ?>"><?php echo $product['products_name']; ?></a>
(<?php echo $product['language']; ?>)
</td>
<td class="dataTableContent text-center"><?php echo $product['total_views']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<table class="table">
<tr>
<td><?php echo $products_split->display_count($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_REPORTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
<td class="text-right"><?php echo $products_split->display_links($products_query_numrows, MAX_DISPLAY_SEARCH_RESULTS_REPORTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page'], 'start_date=' . $startdate . '&end_date=' . $enddate); ?></td>
</tr>
</table>
<!-- body_text_eof //-->
<!-- body_eof //-->
</div>
<!-- footer //-->
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
<!-- footer_eof //-->
<!-- script for datepicker -->
<script>
$(function () {
$('input[name="start_date"]').datepicker();
$('input[name="end_date"]').datepicker();
})
</script>
</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php');
-
Re: Most-Viewed Products - Reports
1.5.7 uses spiffyCal.
1.5.8 uses jQuery DatePicker.
Did you look at the link I sent you about jQuery DatePicker?
-
Re: Most-Viewed Products - Reports
yep, and compared all the files.
Just did what was in https://www.zen-cart.com/showthread....42#post1390342 and that worked for keeping the date but gave us Chinese.
Make sense if they are using different date systems.
-
Re: Most-Viewed Products - Reports
Have you searched for the sources of the jquery datepicker function on the server?
-
Re: Most-Viewed Products - Reports
Okay, wow, this thread has grown some legs and has gone for a run. It's been a while since I have checked in on it and, for the most part, I don't follow whats being suggested. I don't think I will be making any changes to any code, besides, it seems to be mostly to do with fixing the Chinese text problem. Just checked today and I don't have any odd text, it's all English again but, the original problem still remains. After setting the date range and clicking on the next page the date range reverts back to the month default setting.
Anyhow, hope you guys are having a great Christmas.
Cheers, John.
-
Re: Most-Viewed Products - Reports
Your easiest path to get this fixed is to upgrade.
-
Re: Most-Viewed Products - Reports
Unfortunately thats not an option right now. Cheers.