Skip to content

Commit

Permalink
ESDEV-3139 Move statistics feature to module
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiftas committed Jan 12, 2016
0 parents commit 49ed0b7
Show file tree
Hide file tree
Showing 107 changed files with 37,396 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
51 changes: 51 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
OE Statistics Module
====================

Module for logging and displaying shop statistics (OXID eShop CE/PE only).

Setup
-----

- Clone module to your eShop `modules/oe/` directory:

.. code:: bash
git clone https://github.com/OXID-eSales/oestatistics_module.git statistics
- Activate the module in administration area.
- Configure module for collecting the information for reports generation.

Collecting information
----------------------

At the module settings page "Activate Logging for Statistics" checkbox can be found. Whenever it is checked,
module will collect information about shop actions like viewed product and category, purchases, searches and so on.
Later on from this information statistics report can be generated.

Generating reports
------------------

When module is active new navigation options should appear - "Statistics -> Stats & Log-Maint.".
At this page all created reports can be seen and new ones can be created.

.. image:: https://cloud.githubusercontent.com/assets/3593099/12267730/3eab94b6-b952-11e5-86ea-03f5877decbc.png

To create new report:
* Enter report name and save it
* Then assign fields, which should be added to report with "Assign Reports"
* Choose time frame for which report should be generated
* Press "Generate Report" button

You should now have a new window opened with generated report in it:

.. image:: https://cloud.githubusercontent.com/assets/3593099/12267735/4179b3ee-b952-11e5-8ad1-58b104d61390.png

License
-------

Licensing of the software product depends on the shop edition used. The software for OXID eShop Community Edition
is published under the GNU General Public License v3. You may distribute and/or modify this software according to
the licensing terms published by the Free Software Foundation. Legal licensing terms regarding the distribution of
software being subject to GNU GPL can be found under http://www.gnu.org/licenses/gpl.html. The software for OXID eShop
Professional Edition and Enterprise Edition is released under commercial license. OXID eSales AG has the sole rights to
the software. Decompiling the source code, unauthorized copying as well as distribution to third parties is not
permitted. Infringement will be reported to the authorities and prosecuted without exception.
137 changes: 137 additions & 0 deletions controllers/admin/Report/oestatistics_report_base.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
<?php
/**
* This file is part of OXID eSales Statistics module.
*
* OXID eSales Statistics module is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OXID eSales Statistics module is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OXID eSales Statistics module. If not, see <http://www.gnu.org/licenses/>.
*
* @category module
* @package oestatistics
* @author OXID eSales AG
* @link http://www.oxid-esales.com
* @copyright (C) OXID eSales AG 2003-2015
*/
/**
* Base reports class
*/
class OeStatistics_Report_Base extends oxAdminView
{
/**
* Include JPGraph classes.
*/
public function __construct()
{
parent::__construct();

define('USE_CACHE', false);
define('CACHE_DIR', $this->getConfig()->getConfigParam('sCompileDir'));

$modulePath = $this->getViewConfig()->getModulePath('oestatistics');
require_once "$modulePath/core/jpgraph/jpgraph.php";
require_once "$modulePath/core/jpgraph/jpgraph_bar.php";
require_once "$modulePath/core/jpgraph/jpgraph_line.php";
require_once "$modulePath/core/jpgraph/jpgraph_pie.php";
require_once "$modulePath/core/jpgraph/jpgraph_pie3d.php";
}

/**
* Smarty object
*
* @return
*/
protected $smarty = null;

/**
* Returns name of template to render
*
* @return string
*/
public function render()
{
return $this->_sThisTemplate;
}

/**
* Smarty object setter
*
* @param smarty $oSmarty smarty object
*/
public function setSmarty($oSmarty)
{
$this->smarty = $oSmarty;
}

/**
* Returns Smarty object
*
* @return smarty
*/
public function getSmarty()
{
return $this->smarty;
}

/**
* Returns array with week range points
*
* @return array
*/
public function getWeekRange()
{
$config = $this->getConfig();

// initializing one week before current..
$from = oxRegistry::get("oxUtilsDate")->getWeekNumber($config->getConfigParam('iFirstWeekDay'), strtotime(oxRegistry::getConfig()->getRequestParameter("time_from")));
$to = oxRegistry::get("oxUtilsDate")->getWeekNumber($config->getConfigParam('iFirstWeekDay'), strtotime(oxRegistry::getConfig()->getRequestParameter("time_to")));

return array($from - 1, $to + 1);
}

/**
* Returns predefined graph object
*
* @param int $xSize graph image x size
* @param int $ySize graph image y size
* @param string $backgroundImg background filler image (full path)
* @param string $scaleType graph scale type ["textlin"]
*
* @return Graph
*/
public function getGraph($xSize, $ySize, $backgroundImg = null, $scaleType = "textlin")
{
$backgroundImage = $this->getViewConfig()->getModulePath('oestatistics', 'out/pictures/reportbgrnd.jpg');
$backgroundImg = $backgroundImg ? $backgroundImg : $backgroundImage;

// New graph with a drop shadow
$jpGraph = new Graph($xSize, $ySize);

$jpGraph->setBackgroundImage($backgroundImg, BGIMG_FILLFRAME);

// Use a "text" X-scale
$jpGraph->setScale($scaleType);

// Label align for X-axis
$jpGraph->xaxis->setLabelAlign('center', 'top', 'right');

// Label align for Y-axis
$jpGraph->yaxis->setLabelAlign('right', 'bottom');

// shadow
$jpGraph->setShadow();

// Use built in font
$jpGraph->title->setFont(FF_FONT1, FS_BOLD);

return $jpGraph;
}
}
Loading

0 comments on commit 49ed0b7

Please sign in to comment.