Version Notes
- Improve the module by using a custom collection to be able to filter, sort and change the limit of the grid.
Download this release
Release Info
| Developer | Digital Pianism |
| Extension | DigitalPianism_ReportsViewer |
| Version | 0.1.0 |
| Comparing to | |
| See all releases | |
Code changes from version 0.0.5 to 0.1.0
- app/code/community/DigitalPianism/ReportsViewer/Block/Adminhtml/Reportsviewer.php +11 -20
- app/code/community/DigitalPianism/ReportsViewer/Block/Adminhtml/Reportsviewer/Grid.php +7 -67
- app/code/community/DigitalPianism/ReportsViewer/Helper/Data.php +52 -0
- app/code/community/DigitalPianism/ReportsViewer/Model/Report.php +29 -0
- app/code/community/DigitalPianism/ReportsViewer/Model/Reports/Collection.php +45 -0
- app/code/community/DigitalPianism/ReportsViewer/controllers/Adminhtml/ReportsviewerController.php +27 -57
- app/code/community/DigitalPianism/ReportsViewer/etc/config.xml +7 -1
- app/design/adminhtml/default/default/layout/digitalpianism/reportsviewer.xml +0 -8
- app/design/adminhtml/default/default/template/digitalpianism/reportsviewer/list.phtml +1 -3
- package.xml +5 -5
app/code/community/DigitalPianism/ReportsViewer/Block/Adminhtml/Reportsviewer.php
CHANGED
|
@@ -3,36 +3,27 @@
|
|
| 3 |
/**
|
| 4 |
* Class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer
|
| 5 |
*/
|
| 6 |
-
class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer extends
|
| 7 |
{
|
| 8 |
/**
|
| 9 |
-
*
|
|
|
|
|
|
|
| 10 |
*/
|
| 11 |
-
|
| 12 |
-
{
|
| 13 |
-
$this->_controller = 'adminhtml_reportsviewer';
|
| 14 |
-
$this->_blockGroup = 'reportsviewer';
|
| 15 |
-
$this->_headerText = Mage::helper('reportsviewer')->__('Reports Viewer');
|
| 16 |
-
parent::__construct();
|
| 17 |
-
$this->setTemplate('digitalpianism/reportsviewer/list.phtml');
|
| 18 |
-
}
|
| 19 |
|
| 20 |
-
/**
|
| 21 |
-
* Prepare the layout
|
| 22 |
-
*/
|
| 23 |
protected function _prepareLayout()
|
| 24 |
{
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
| 28 |
}
|
| 29 |
|
| 30 |
-
/**
|
| 31 |
-
* Getter for the grid HTML
|
| 32 |
-
*/
|
| 33 |
public function getGridHtml()
|
| 34 |
{
|
| 35 |
-
return $this->getChildHtml('
|
| 36 |
}
|
| 37 |
|
| 38 |
}
|
| 3 |
/**
|
| 4 |
* Class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer
|
| 5 |
*/
|
| 6 |
+
class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer extends Mage_Adminhtml_Block_Template
|
| 7 |
{
|
| 8 |
/**
|
| 9 |
+
* Block's template
|
| 10 |
+
*
|
| 11 |
+
* @var string
|
| 12 |
*/
|
| 13 |
+
protected $_template = 'digitalpianism/reportsviewer/list.phtml';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
|
|
|
|
|
|
|
|
|
| 15 |
protected function _prepareLayout()
|
| 16 |
{
|
| 17 |
+
parent::_prepareLayout();
|
| 18 |
+
|
| 19 |
+
$this->setChild('reportsviewerGrid',
|
| 20 |
+
$this->getLayout()->createBlock('reportsviewer/adminhtml_reportsviewer_grid')
|
| 21 |
+
);
|
| 22 |
}
|
| 23 |
|
|
|
|
|
|
|
|
|
|
| 24 |
public function getGridHtml()
|
| 25 |
{
|
| 26 |
+
return $this->getChildHtml('reportsviewerGrid');
|
| 27 |
}
|
| 28 |
|
| 29 |
}
|
app/code/community/DigitalPianism/ReportsViewer/Block/Adminhtml/Reportsviewer/Grid.php
CHANGED
|
@@ -9,13 +9,11 @@ class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer_Grid extends Ma
|
|
| 9 |
/**
|
| 10 |
* Constructor the grid
|
| 11 |
*/
|
| 12 |
-
public function
|
| 13 |
{
|
| 14 |
-
parent::__construct();
|
| 15 |
-
$this->setId('reportsviewerGrid');
|
| 16 |
-
$this->setDefaultSort('report_id');
|
| 17 |
-
$this->setDefaultDir('ASC');
|
| 18 |
$this->setSaveParametersInSession(true);
|
|
|
|
|
|
|
| 19 |
}
|
| 20 |
|
| 21 |
/**
|
|
@@ -24,65 +22,7 @@ class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer_Grid extends Ma
|
|
| 24 |
protected function _prepareCollection()
|
| 25 |
{
|
| 26 |
// Create a collection
|
| 27 |
-
$collection =
|
| 28 |
-
|
| 29 |
-
// Add the reports from the var folder to the collection
|
| 30 |
-
$reportFolder = Mage::getBaseDir('var') . '/report';
|
| 31 |
-
|
| 32 |
-
// If the report folder is a directory
|
| 33 |
-
if (is_dir($reportFolder))
|
| 34 |
-
{
|
| 35 |
-
// And if we can read it
|
| 36 |
-
if ($dh = opendir($reportFolder))
|
| 37 |
-
{
|
| 38 |
-
// We loop through its readable files
|
| 39 |
-
while (($file = readdir($dh)) !== false)
|
| 40 |
-
{
|
| 41 |
-
// Except "." and ".."
|
| 42 |
-
if ($file != "." && $file != "..")
|
| 43 |
-
{
|
| 44 |
-
// For each file we create a new object
|
| 45 |
-
$newItem = new Varien_Object();
|
| 46 |
-
// Set some data
|
| 47 |
-
$newItem->setReportId($file);
|
| 48 |
-
$newItem->setFile($reportFolder . "/" . $file);
|
| 49 |
-
// Set the date properly
|
| 50 |
-
$dateAdded = Mage::getModel('core/date')->date(null,filemtime($reportFolder . "/" . $file));
|
| 51 |
-
$newItem->setAdded($dateAdded);
|
| 52 |
-
|
| 53 |
-
// Get the content of the file
|
| 54 |
-
$content = file_get_contents($reportFolder . "/" . $file);
|
| 55 |
-
// Decode it
|
| 56 |
-
$content = unserialize($content);
|
| 57 |
-
// Loop through the array
|
| 58 |
-
foreach ($content as $key => $value)
|
| 59 |
-
{
|
| 60 |
-
// Value with key = 0 is always the error message
|
| 61 |
-
if (!$key)
|
| 62 |
-
{
|
| 63 |
-
$newItem->setError($value);
|
| 64 |
-
}
|
| 65 |
-
elseif ($key == "url")
|
| 66 |
-
{
|
| 67 |
-
$newItem->setUrl($value);
|
| 68 |
-
}
|
| 69 |
-
elseif ($key == "script_name")
|
| 70 |
-
{
|
| 71 |
-
$newItem->setScriptName($value);
|
| 72 |
-
}
|
| 73 |
-
elseif ($key == "skin")
|
| 74 |
-
{
|
| 75 |
-
$newItem->setSkin($value);
|
| 76 |
-
}
|
| 77 |
-
}
|
| 78 |
-
// Once the data are set, we add the object to the collection
|
| 79 |
-
$collection->addItem($newItem);
|
| 80 |
-
}
|
| 81 |
-
}
|
| 82 |
-
// We close the folder
|
| 83 |
-
closedir($dh);
|
| 84 |
-
}
|
| 85 |
-
}
|
| 86 |
|
| 87 |
// We set the collection of the grid
|
| 88 |
$this->setCollection($collection);
|
|
@@ -148,7 +88,7 @@ class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer_Grid extends Ma
|
|
| 148 |
'filter' => false,
|
| 149 |
'width' => '160',
|
| 150 |
'is_system' => true,
|
| 151 |
-
'renderer' => '
|
| 152 |
));
|
| 153 |
|
| 154 |
return parent::_prepareColumns();
|
|
@@ -159,8 +99,8 @@ class DigitalPianism_Reportsviewer_Block_Adminhtml_Reportsviewer_Grid extends Ma
|
|
| 159 |
*/
|
| 160 |
protected function _prepareMassaction()
|
| 161 |
{
|
| 162 |
-
$this->setMassactionIdField('
|
| 163 |
-
$this->getMassactionBlock()->setFormFieldName('
|
| 164 |
|
| 165 |
// Delete action
|
| 166 |
$this->getMassactionBlock()->addItem('delete', array(
|
| 9 |
/**
|
| 10 |
* Constructor the grid
|
| 11 |
*/
|
| 12 |
+
public function _construct()
|
| 13 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
$this->setSaveParametersInSession(true);
|
| 15 |
+
$this->setId('reportsviewerGrid');
|
| 16 |
+
$this->setDefaultSort('added','DESC');
|
| 17 |
}
|
| 18 |
|
| 19 |
/**
|
| 22 |
protected function _prepareCollection()
|
| 23 |
{
|
| 24 |
// Create a collection
|
| 25 |
+
$collection = Mage::getSingleton('reportsviewer/reports_collection');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
// We set the collection of the grid
|
| 28 |
$this->setCollection($collection);
|
| 88 |
'filter' => false,
|
| 89 |
'width' => '160',
|
| 90 |
'is_system' => true,
|
| 91 |
+
'renderer' => 'reportsviewer/adminhtml_template_grid_renderer_action'
|
| 92 |
));
|
| 93 |
|
| 94 |
return parent::_prepareColumns();
|
| 99 |
*/
|
| 100 |
protected function _prepareMassaction()
|
| 101 |
{
|
| 102 |
+
$this->setMassactionIdField('id');
|
| 103 |
+
$this->getMassactionBlock()->setFormFieldName('ids');
|
| 104 |
|
| 105 |
// Delete action
|
| 106 |
$this->getMassactionBlock()->addItem('delete', array(
|
app/code/community/DigitalPianism/ReportsViewer/Helper/Data.php
CHANGED
|
@@ -17,4 +17,56 @@ class DigitalPianism_ReportsViewer_Helper_Data extends Mage_Core_Helper_Abstract
|
|
| 17 |
Mage::log($data, null, $this->_logFileName);
|
| 18 |
}
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
}
|
| 17 |
Mage::log($data, null, $this->_logFileName);
|
| 18 |
}
|
| 19 |
|
| 20 |
+
/**
|
| 21 |
+
* Extracts information from report's filepath
|
| 22 |
+
*
|
| 23 |
+
* @param string $filepath
|
| 24 |
+
* @return Varien_Object
|
| 25 |
+
*/
|
| 26 |
+
public function extractDataFromFile($filepath)
|
| 27 |
+
{
|
| 28 |
+
// Read the unserialize content of the file
|
| 29 |
+
$content = unserialize(file_get_contents($filepath));
|
| 30 |
+
|
| 31 |
+
// Loop through the array
|
| 32 |
+
foreach ($content as $key => $value)
|
| 33 |
+
{
|
| 34 |
+
// Value with key = 0 is always the error message
|
| 35 |
+
if (!$key)
|
| 36 |
+
{
|
| 37 |
+
$error = $value;
|
| 38 |
+
}
|
| 39 |
+
elseif ($key == "url")
|
| 40 |
+
{
|
| 41 |
+
$url = $value;
|
| 42 |
+
}
|
| 43 |
+
elseif ($key == "script_name")
|
| 44 |
+
{
|
| 45 |
+
$script_name = $value;
|
| 46 |
+
}
|
| 47 |
+
elseif ($key == "skin")
|
| 48 |
+
{
|
| 49 |
+
$skin = $value;
|
| 50 |
+
}
|
| 51 |
+
else
|
| 52 |
+
{
|
| 53 |
+
// The trace has the key = 1, we do it last
|
| 54 |
+
$trace = $value;
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
// Create the result object
|
| 59 |
+
$result = new Varien_Object();
|
| 60 |
+
$result->addData(array(
|
| 61 |
+
'error' => $error ? $error : "",
|
| 62 |
+
'url' => $url ? $url : "",
|
| 63 |
+
'script_name' => $script_name ? $script_name : "",
|
| 64 |
+
'skin' => $skin ? $skin : "",
|
| 65 |
+
'trace' => $trace ? $trace : "",
|
| 66 |
+
'time' => filemtime($filepath)
|
| 67 |
+
));
|
| 68 |
+
|
| 69 |
+
return $result;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
}
|
app/code/community/DigitalPianism/ReportsViewer/Model/Report.php
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class DigitalPianism_ReportsViewer_Model_Report extends Varien_Object
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Load report file info
|
| 7 |
+
*
|
| 8 |
+
* @param string fileName
|
| 9 |
+
* @param string filePath
|
| 10 |
+
* @return FactoryX_ReportsViewer_Model_Report
|
| 11 |
+
*/
|
| 12 |
+
public function load($fileName, $filePath)
|
| 13 |
+
{
|
| 14 |
+
$reportData = Mage::helper('reportsviewer')->extractDataFromFile($filePath . DS . $fileName);
|
| 15 |
+
|
| 16 |
+
$this->addData(array(
|
| 17 |
+
'report_id' => $fileName,
|
| 18 |
+
'error' => $reportData->getError(),
|
| 19 |
+
'url' => $reportData->getUrl(),
|
| 20 |
+
'script_name' => $reportData->getScriptName(),
|
| 21 |
+
'skin' => $reportData->getSkin(),
|
| 22 |
+
'trace' => $reportData->getTrace(),
|
| 23 |
+
'file' => $filePath . DS . $fileName,
|
| 24 |
+
'added' => new Zend_Date((int)$reportData->getTime(), Mage::app()->getLocale()->getLocaleCode())
|
| 25 |
+
));
|
| 26 |
+
|
| 27 |
+
return $this;
|
| 28 |
+
}
|
| 29 |
+
}
|
app/code/community/DigitalPianism/ReportsViewer/Model/Reports/Collection.php
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class DigitalPianism_ReportsViewer_Model_Reports_Collection extends Varien_Data_Collection_Filesystem
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* Folder, where all reports are stored
|
| 7 |
+
*
|
| 8 |
+
* @var string
|
| 9 |
+
*/
|
| 10 |
+
protected $_baseDir;
|
| 11 |
+
|
| 12 |
+
/**
|
| 13 |
+
* Set collection specific parameters and make sure report folder will exist
|
| 14 |
+
*/
|
| 15 |
+
public function __construct()
|
| 16 |
+
{
|
| 17 |
+
parent::__construct();
|
| 18 |
+
|
| 19 |
+
$this->_baseDir = Mage::getBaseDir('var') . DS . 'report';
|
| 20 |
+
|
| 21 |
+
$this
|
| 22 |
+
->setOrder('time', self::SORT_ORDER_DESC)
|
| 23 |
+
->addTargetDir($this->_baseDir)
|
| 24 |
+
->setFilesFilter('/^[0-9]+$/')
|
| 25 |
+
->setCollectRecursively(false)
|
| 26 |
+
;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* Get backup-specific data from model for each row
|
| 31 |
+
*
|
| 32 |
+
* @param string $filename
|
| 33 |
+
* @return array
|
| 34 |
+
*/
|
| 35 |
+
protected function _generateRow($filename)
|
| 36 |
+
{
|
| 37 |
+
$row = parent::_generateRow($filename);
|
| 38 |
+
foreach (Mage::getSingleton('reportsviewer/report')->load($row['basename'], $this->_baseDir)
|
| 39 |
+
->getData() as $key => $value) {
|
| 40 |
+
$row[$key] = $value;
|
| 41 |
+
}
|
| 42 |
+
$row['id'] = $row['report_id'];
|
| 43 |
+
return $row;
|
| 44 |
+
}
|
| 45 |
+
}
|
app/code/community/DigitalPianism/ReportsViewer/controllers/Adminhtml/ReportsviewerController.php
CHANGED
|
@@ -16,27 +16,34 @@ class DigitalPianism_ReportsViewer_Adminhtml_ReportsviewerController extends Mag
|
|
| 16 |
}
|
| 17 |
|
| 18 |
/**
|
| 19 |
-
*
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
protected function _initAction()
|
| 23 |
{
|
| 24 |
-
$this->
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
}
|
| 28 |
|
| 29 |
/**
|
| 30 |
-
*
|
| 31 |
-
|
| 32 |
-
public function
|
| 33 |
{
|
| 34 |
-
|
| 35 |
-
$this->_initAction()->renderLayout();
|
| 36 |
-
}
|
| 37 |
-
catch(Exception $ex) {
|
| 38 |
-
Mage::helper('reportsviewer')->log(sprintf("%s->error=%s", __METHOD__, print_r($ex, true)), Zend_Log::DEBUG );
|
| 39 |
-
}
|
| 40 |
}
|
| 41 |
|
| 42 |
/**
|
|
@@ -71,7 +78,7 @@ class DigitalPianism_ReportsViewer_Adminhtml_ReportsviewerController extends Mag
|
|
| 71 |
public function massDeleteAction()
|
| 72 |
{
|
| 73 |
// We get the IDs of the items that need to be deleted
|
| 74 |
-
$reportIds = $this->getRequest()->getParam('
|
| 75 |
// Set the location of the reports
|
| 76 |
$reportFolder = Mage::getBaseDir('var') . '/report';
|
| 77 |
|
|
@@ -110,47 +117,11 @@ class DigitalPianism_ReportsViewer_Adminhtml_ReportsviewerController extends Mag
|
|
| 110 |
{
|
| 111 |
// We first retrieve the report ID
|
| 112 |
$id = $this->getRequest()->getParam('id');
|
|
|
|
|
|
|
| 113 |
|
| 114 |
-
//
|
| 115 |
-
$
|
| 116 |
-
|
| 117 |
-
// Then we create a new Object
|
| 118 |
-
$model = new Varien_Object();
|
| 119 |
-
// Set some data
|
| 120 |
-
$model->setReportId($id);
|
| 121 |
-
$model->setFile($reportFolder . "/" . $id);
|
| 122 |
-
$model->setAdded(filemtime($reportFolder . "/" . $id));
|
| 123 |
-
|
| 124 |
-
// Retrieve the content from the file
|
| 125 |
-
$content = file_get_contents($reportFolder . "/" . $id);
|
| 126 |
-
// Decode it
|
| 127 |
-
$content = unserialize($content);
|
| 128 |
-
// Loop through the content array
|
| 129 |
-
foreach ($content as $key => $value)
|
| 130 |
-
{
|
| 131 |
-
// The value with the key = 0 of the array is always the error message
|
| 132 |
-
if (!$key)
|
| 133 |
-
{
|
| 134 |
-
$model->setError($value);
|
| 135 |
-
}
|
| 136 |
-
elseif ($key == "url")
|
| 137 |
-
{
|
| 138 |
-
$model->setUrl($value);
|
| 139 |
-
}
|
| 140 |
-
elseif ($key == "script_name")
|
| 141 |
-
{
|
| 142 |
-
$model->setScriptName($value);
|
| 143 |
-
}
|
| 144 |
-
elseif ($key == "skin")
|
| 145 |
-
{
|
| 146 |
-
$model->setSkin($value);
|
| 147 |
-
}
|
| 148 |
-
else
|
| 149 |
-
{
|
| 150 |
-
// The trace has the key = 1, we do it last
|
| 151 |
-
$model->setTrace($value);
|
| 152 |
-
}
|
| 153 |
-
}
|
| 154 |
|
| 155 |
// Register the data so we can use it in the form
|
| 156 |
Mage::register('report_data', $model);
|
|
@@ -165,7 +136,6 @@ class DigitalPianism_ReportsViewer_Adminhtml_ReportsviewerController extends Mag
|
|
| 165 |
|
| 166 |
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
| 167 |
|
| 168 |
-
|
| 169 |
$this->renderLayout();
|
| 170 |
}
|
| 171 |
|
| 16 |
}
|
| 17 |
|
| 18 |
/**
|
| 19 |
+
* This is the action used to display the grid
|
| 20 |
+
*/
|
| 21 |
+
public function indexAction()
|
|
|
|
| 22 |
{
|
| 23 |
+
$this->_title($this->__('System'))->_title($this->__('Tools'))->_title($this->__('Reports Viewer'));
|
| 24 |
|
| 25 |
+
if($this->getRequest()->getParam('ajax')) {
|
| 26 |
+
$this->_forward('grid');
|
| 27 |
+
return;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
$this->loadLayout();
|
| 31 |
+
$this->_setActiveMenu('system');
|
| 32 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('System'), Mage::helper('adminhtml')->__('System'));
|
| 33 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Tools'), Mage::helper('adminhtml')->__('Tools'));
|
| 34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Reports Viewer'), Mage::helper('adminhtml')->__('Reports Viewer'));
|
| 35 |
+
|
| 36 |
+
$this->_addContent($this->getLayout()->createBlock('reportsviewer/adminhtml_reportsviewer', 'reportsviewer'));
|
| 37 |
+
|
| 38 |
+
$this->renderLayout();
|
| 39 |
}
|
| 40 |
|
| 41 |
/**
|
| 42 |
+
* Report list action
|
| 43 |
+
*/
|
| 44 |
+
public function gridAction()
|
| 45 |
{
|
| 46 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('reportsviewer/adminhtml_reportsviewer_grid')->toHtml());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
}
|
| 48 |
|
| 49 |
/**
|
| 78 |
public function massDeleteAction()
|
| 79 |
{
|
| 80 |
// We get the IDs of the items that need to be deleted
|
| 81 |
+
$reportIds = $this->getRequest()->getParam('ids');
|
| 82 |
// Set the location of the reports
|
| 83 |
$reportFolder = Mage::getBaseDir('var') . '/report';
|
| 84 |
|
| 117 |
{
|
| 118 |
// We first retrieve the report ID
|
| 119 |
$id = $this->getRequest()->getParam('id');
|
| 120 |
+
// Then we generate the report path
|
| 121 |
+
$path = Mage::getBaseDir('var') . DS . 'report';
|
| 122 |
|
| 123 |
+
// Load the report
|
| 124 |
+
$model = Mage::getModel('reportsviewer/report')->load($id, $path);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
// Register the data so we can use it in the form
|
| 127 |
Mage::register('report_data', $model);
|
| 136 |
|
| 137 |
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
| 138 |
|
|
|
|
| 139 |
$this->renderLayout();
|
| 140 |
}
|
| 141 |
|
app/code/community/DigitalPianism/ReportsViewer/etc/config.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<DigitalPianism_ReportsViewer>
|
| 5 |
-
<version>0.0
|
| 6 |
</DigitalPianism_ReportsViewer>
|
| 7 |
</modules>
|
| 8 |
|
|
@@ -31,6 +31,12 @@
|
|
| 31 |
</adminhtml>
|
| 32 |
|
| 33 |
<global>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
<helpers>
|
| 35 |
<!-- Helper declaration -->
|
| 36 |
<reportsviewer>
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<DigitalPianism_ReportsViewer>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
</DigitalPianism_ReportsViewer>
|
| 7 |
</modules>
|
| 8 |
|
| 31 |
</adminhtml>
|
| 32 |
|
| 33 |
<global>
|
| 34 |
+
<models>
|
| 35 |
+
<!-- Model declaration -->
|
| 36 |
+
<reportsviewer>
|
| 37 |
+
<class>DigitalPianism_ReportsViewer_Model</class>
|
| 38 |
+
</reportsviewer>
|
| 39 |
+
</models>
|
| 40 |
<helpers>
|
| 41 |
<!-- Helper declaration -->
|
| 42 |
<reportsviewer>
|
app/design/adminhtml/default/default/layout/digitalpianism/reportsviewer.xml
CHANGED
|
@@ -1,13 +1,5 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<layout version="0.1.0">
|
| 3 |
-
<!-- Grid handle -->
|
| 4 |
-
<reportsviewer_admin_adminhtml_reportsviewer_index>
|
| 5 |
-
<update handle="editor" />
|
| 6 |
-
<reference name="content">
|
| 7 |
-
<!-- Grid parent block -->
|
| 8 |
-
<block type="reportsviewer/adminhtml_reportsviewer" name="reportsviewer" />
|
| 9 |
-
</reference>
|
| 10 |
-
</reportsviewer_admin_adminhtml_reportsviewer_index>
|
| 11 |
<!-- View handle -->
|
| 12 |
<reportsviewer_admin_adminhtml_reportsviewer_view>
|
| 13 |
<update handle="editor" />
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<layout version="0.1.0">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
<!-- View handle -->
|
| 4 |
<reportsviewer_admin_adminhtml_reportsviewer_view>
|
| 5 |
<update handle="editor" />
|
app/design/adminhtml/default/default/template/digitalpianism/reportsviewer/list.phtml
CHANGED
|
@@ -10,6 +10,4 @@
|
|
| 10 |
</tr>
|
| 11 |
</table>
|
| 12 |
</div>
|
| 13 |
-
|
| 14 |
-
<?php echo $this->getGridHtml() ?>
|
| 15 |
-
</div>
|
| 10 |
</tr>
|
| 11 |
</table>
|
| 12 |
</div>
|
| 13 |
+
<?php echo $this->getGridHtml() ?>
|
|
|
|
|
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>DigitalPianism_ReportsViewer</name>
|
| 4 |
-
<version>0.0
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -32,11 +32,11 @@
|
|
| 32 |
<p>The only data not included in the grid is the trace.</p>
|
| 33 |
<p>So when you click the "view details" link or if you click directly on the row, you will get access to a page that displays all the data of the grid PLUS the trace of the report.</p>
|
| 34 |
<p>From this page, you can also delete a report.</p></description>
|
| 35 |
-
<notes>-
|
| 36 |
<authors><author><name>Digital Pianism</name><user>digitalpianism</user><email>contact@digital-pianism.com</email></author></authors>
|
| 37 |
-
<date>2015-
|
| 38 |
-
<time>
|
| 39 |
-
<contents><target name="magecommunity"><dir name="DigitalPianism"><dir name="ReportsViewer"><dir name="Block"><dir name="Adminhtml"><dir name="Reportsviewer"><file name="Grid.php" hash="
|
| 40 |
<compatible/>
|
| 41 |
<dependencies><required><php><min>4.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 42 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>DigitalPianism_ReportsViewer</name>
|
| 4 |
+
<version>0.1.0</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
| 7 |
<channel>community</channel>
|
| 32 |
<p>The only data not included in the grid is the trace.</p>
|
| 33 |
<p>So when you click the "view details" link or if you click directly on the row, you will get access to a page that displays all the data of the grid PLUS the trace of the report.</p>
|
| 34 |
<p>From this page, you can also delete a report.</p></description>
|
| 35 |
+
<notes>- Improve the module by using a custom collection to be able to filter, sort and change the limit of the grid.</notes>
|
| 36 |
<authors><author><name>Digital Pianism</name><user>digitalpianism</user><email>contact@digital-pianism.com</email></author></authors>
|
| 37 |
+
<date>2015-09-17</date>
|
| 38 |
+
<time>10:33:45</time>
|
| 39 |
+
<contents><target name="magecommunity"><dir name="DigitalPianism"><dir name="ReportsViewer"><dir name="Block"><dir name="Adminhtml"><dir name="Reportsviewer"><file name="Grid.php" hash="e9655334d95023c571172a26a504ca77"/><dir name="View"><file name="Form.php" hash="a8ababaf7401b1c294685eb483327c72"/></dir><file name="View.php" hash="c234f392f8c3d030d27740ba8036715e"/></dir><file name="Reportsviewer.php" hash="dafd160401e4ccd6b3a724199b53cc31"/><dir name="Template"><dir name="Grid"><dir name="Renderer"><file name="Action.php" hash="ab39437238ad1c8e22f8dd3746865679"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f935bdafe07317db7f3ca3e29f5daabd"/></dir><dir name="Model"><file name="Report.php" hash="6a127d94d02c50463dc3836d7faf2628"/><dir name="Reports"><file name="Collection.php" hash="f331931709f211467faf7351221f00c8"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ReportsviewerController.php" hash="29769722164e5fe17a0448a57068fdda"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="b460c9d10c922c26c1bbf121933992a5"/><file name="config.xml" hash="df4cabc3fd37a939dacda036bf3b5fb2"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="DigitalPianism_ReportsViewer.xml" hash="bc4370b8f8905113dcf26afbbbd062c6"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="digitalpianism"><file name="reportsviewer.xml" hash="79f624cf29d2c203ff48a1634f081ceb"/></dir></dir><dir name="template"><dir name="digitalpianism"><dir name="reportsviewer"><file name="list.phtml" hash="5fab98e4c9239730200be43f40a49ca1"/></dir></dir></dir></dir></dir></dir></target></contents>
|
| 40 |
<compatible/>
|
| 41 |
<dependencies><required><php><min>4.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 42 |
</package>
|
