Version Notes
First development release
Download this release
Release Info
| Developer | BrainSINS |
| Extension | Vtrio |
| Version | 0.1.0 |
| Comparing to | |
| See all releases | |
Version 0.1.0
- app/code/community/Vtrio/CustomReports/Block/Report/Custom.php +23 -0
- app/code/community/Vtrio/CustomReports/Block/Report/Custom/Grid.php +69 -0
- app/code/community/Vtrio/CustomReports/Helper/Data.php +201 -0
- app/code/community/Vtrio/CustomReports/Model/Collection.php +248 -0
- app/code/community/Vtrio/CustomReports/controllers/Report/IndexController.php +95 -0
- app/code/community/Vtrio/CustomReports/etc/adminhtml.xml +15 -0
- app/code/community/Vtrio/CustomReports/etc/config.xml +36 -0
- app/design/adminhtml/default/default/template/vtrio/customreports/gridproduct.phtml +326 -0
- app/etc/modules/Vtrio_CustomReports.xml +10 -0
- package.xml +21 -0
- skin/adminhtml/default/default/vtriocustomreport/pagination.css +5 -0
app/code/community/Vtrio/CustomReports/Block/Report/Custom.php
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Vtrio_CustomReports_Block_Report_Custom extends Mage_Adminhtml_Block_Widget_Grid_Container
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* Initialize container block settings
|
| 8 |
+
*
|
| 9 |
+
*/
|
| 10 |
+
public function __construct()
|
| 11 |
+
{
|
| 12 |
+
$this->_blockGroup = 'customreports'; // This is your module’s name.
|
| 13 |
+
$this->_controller = 'report_custom'; //This is not the controller class name. It is actually your Block class name.
|
| 14 |
+
$this->_headerText = Mage::helper('customreports')->__('Custom Report');
|
| 15 |
+
parent::__construct();
|
| 16 |
+
$this->_removeButton('add');
|
| 17 |
+
$this->addButton('filter_form_submit', array(
|
| 18 |
+
'label' => Mage::helper('reports')->__('Show Report'),
|
| 19 |
+
'onclick' => 'filterFormSubmit()'
|
| 20 |
+
));
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
}
|
app/code/community/Vtrio/CustomReports/Block/Report/Custom/Grid.php
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
class Vtrio_CustomReports_Block_Report_Custom_Grid extends Mage_Adminhtml_Block_Report_Grid
|
| 5 |
+
{
|
| 6 |
+
|
| 7 |
+
protected $_subReportSize = 0;
|
| 8 |
+
|
| 9 |
+
/**
|
| 10 |
+
* Initialize Grid settings
|
| 11 |
+
*
|
| 12 |
+
*/
|
| 13 |
+
public function __construct()
|
| 14 |
+
{
|
| 15 |
+
parent::__construct();
|
| 16 |
+
$this->setFilterVisibility(true);
|
| 17 |
+
$this->setPagerVisibility(true);
|
| 18 |
+
$this->setId('customReport');
|
| 19 |
+
$this->setSaveParametersInSession(true);
|
| 20 |
+
$this->setUseAjax(true);
|
| 21 |
+
$this->setDefaultLimit(1);
|
| 22 |
+
$this->setTemplate('vtrio/customreports/gridproduct.phtml');
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
protected function _prepareColumns()
|
| 26 |
+
{
|
| 27 |
+
$this->addColumn('name', array(
|
| 28 |
+
'header' => Mage::helper('reports')->__('Product Name'),
|
| 29 |
+
'index' => 'sales_items',
|
| 30 |
+
'align' => 'right',
|
| 31 |
+
'width' => '300px',
|
| 32 |
+
'total' => 'sum',
|
| 33 |
+
'type' => 'number'
|
| 34 |
+
));
|
| 35 |
+
|
| 36 |
+
$this->addColumn('ordered_qty', array(
|
| 37 |
+
'header' => Mage::helper('reports')->__('SKU'),
|
| 38 |
+
'width' => '100px',
|
| 39 |
+
'align' => 'right',
|
| 40 |
+
'index' => 'sales_total',
|
| 41 |
+
'total' => 'sum',
|
| 42 |
+
'type' => 'number'
|
| 43 |
+
));
|
| 44 |
+
$this->addColumn('invoiced_qty', array(
|
| 45 |
+
'header' => Mage::helper('reports')->__('Total Price'),
|
| 46 |
+
'width' => '80px',
|
| 47 |
+
'align' => 'right',
|
| 48 |
+
'index' => 'invoiced',
|
| 49 |
+
'total' => 'sum',
|
| 50 |
+
'type' => 'number'
|
| 51 |
+
));
|
| 52 |
+
$this->addColumn('refunded_qty', array(
|
| 53 |
+
'header' => Mage::helper('reports')->__('Quantity Ordered'),
|
| 54 |
+
'width' => '80px',
|
| 55 |
+
'align' => 'right',
|
| 56 |
+
'index' => 'refunded',
|
| 57 |
+
'total' => 'sum',
|
| 58 |
+
'type' => 'number'
|
| 59 |
+
));
|
| 60 |
+
|
| 61 |
+
return parent::_prepareColumns();
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
public function getGridUrl()
|
| 65 |
+
{
|
| 66 |
+
return $this->getUrl('*/*/grid', array('_current' => true));
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
}
|
app/code/community/Vtrio/CustomReports/Helper/Data.php
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Vtrio_CustomReports_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
public function getNewstoreids()
|
| 7 |
+
{
|
| 8 |
+
$object = new Vtrio_CustomReports_Block_Report_Custom;
|
| 9 |
+
$storeidarr = $object->Storeparam();
|
| 10 |
+
|
| 11 |
+
return $storeidarr;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
public function exportReportToCSV($reportArr,$report_period)
|
| 15 |
+
{
|
| 16 |
+
|
| 17 |
+
$headers = array('Period', 'Product Name', 'SKU', 'Total Price', 'Quantity Ordered');
|
| 18 |
+
|
| 19 |
+
$fp = fopen('php://output', 'w');
|
| 20 |
+
if ($fp && $reportArr) {
|
| 21 |
+
//echo "in";
|
| 22 |
+
header('Content-Type: text/csv');
|
| 23 |
+
header('Content-Disposition: attachment; filename="custom_report.csv"');
|
| 24 |
+
header('Pragma: no-cache');
|
| 25 |
+
header('Expires: 0');
|
| 26 |
+
fputcsv($fp, $headers);
|
| 27 |
+
|
| 28 |
+
foreach ($reportArr as $arr_row) {
|
| 29 |
+
$values = array();
|
| 30 |
+
|
| 31 |
+
$totalQty = $totalQty+$arr_row['qty_ordered'];
|
| 32 |
+
$totalPrice = $totalPrice+$arr_row['price'];
|
| 33 |
+
if($report_period == 'month'){
|
| 34 |
+
$dateVal1 = explode("-",$arr_row['created_at']);
|
| 35 |
+
$createdDate = $dateVal1[1]."/".$dateVal1[0];
|
| 36 |
+
}else if($report_period == 'year'){
|
| 37 |
+
$dateVal1 = explode("-",$arr_row['created_at']);
|
| 38 |
+
$createdDate = $dateVal1[0];
|
| 39 |
+
}else{
|
| 40 |
+
$date = date_create($arr_row['created_at']);
|
| 41 |
+
$createdDate = date_format($date,"M d, Y");
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
array_push($values,$createdDate,$arr_row['name'],$arr_row['sku'],number_format($arr_row['price'], 2, '.', ''),number_format($arr_row['qty_ordered'], 2, '.', ''));
|
| 45 |
+
fputcsv($fp, $values);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
$values = array();
|
| 49 |
+
array_push($values,'','','','','');
|
| 50 |
+
fputcsv($fp, $values);
|
| 51 |
+
$values = array();
|
| 52 |
+
array_push($values,'','Total','',number_format($totalPrice, 2, '.', ''),number_format($totalQty, 2, '.', ''));
|
| 53 |
+
fputcsv($fp, $values);
|
| 54 |
+
|
| 55 |
+
die;
|
| 56 |
+
}
|
| 57 |
+
else {
|
| 58 |
+
echo "no result";
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
public function nestedSubCategory($subcatId,$space,$selectedId = null)
|
| 63 |
+
{
|
| 64 |
+
$children = Mage::getModel('catalog/category')->getCategories($subcatId);
|
| 65 |
+
$helper = Mage::helper('customreports');
|
| 66 |
+
$spaceVal = "";
|
| 67 |
+
if(count($children)>0){
|
| 68 |
+
for($i=1;$i<=$space;$i++){
|
| 69 |
+
$spaceVal .= " ";
|
| 70 |
+
}
|
| 71 |
+
foreach ($children as $subCategory) {
|
| 72 |
+
$selectedSubCategory = ($selectedId == $subCategory->getId())?'selected = true':'';
|
| 73 |
+
$id = $subCategory->getId();
|
| 74 |
+
$name = $subCategory->getName();
|
| 75 |
+
$option .= "<option value='$id' $selectedSubCategory>$spaceVal $name</option>";
|
| 76 |
+
$option .= $helper->nestedSubCategory($id,$space+3,$selectedId);
|
| 77 |
+
}
|
| 78 |
+
}else{
|
| 79 |
+
return $option;
|
| 80 |
+
}
|
| 81 |
+
return $option;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
public function paginationCtrl($catId,$subCatId,$from,$to,$report_period,$store_ids,$order_statuses,$limit,$page){
|
| 85 |
+
|
| 86 |
+
$model = Mage::getModel('customreports/collection');
|
| 87 |
+
$reportArrCount = $model->getReportCount($catId,$subCatId,$from,$to,$report_period,$store_ids,$order_statuses);
|
| 88 |
+
foreach ($reportArrCount as $reportArrCountVal) {
|
| 89 |
+
$reportCount = $reportArrCountVal['totalCount'];
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
$limitConf = array('20','30','50','100');
|
| 93 |
+
|
| 94 |
+
$targetpage = Mage::helper('core/url')->getCurrentUrl();
|
| 95 |
+
$stages = 1;
|
| 96 |
+
|
| 97 |
+
if($page){
|
| 98 |
+
$start = ($page - 1) * $limit;
|
| 99 |
+
}else{
|
| 100 |
+
$start = 0;
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
// Initial page num setup
|
| 104 |
+
if ($page == 0){
|
| 105 |
+
$page = 1;
|
| 106 |
+
}
|
| 107 |
+
$prev = $page - 1;
|
| 108 |
+
$next = $page + 1;
|
| 109 |
+
$lastpage = ceil($reportCount/$limit);
|
| 110 |
+
$LastPagem1 = $lastpage - 1;
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
$paginate = "<div class='vtrioCustPagination'>";
|
| 114 |
+
if($lastpage > 1){
|
| 115 |
+
// Previous
|
| 116 |
+
if ($page > 1){
|
| 117 |
+
$paginate .= "<a href='#' onclick='setPage($prev)'>previous</a>";
|
| 118 |
+
}else{
|
| 119 |
+
$paginate .= "<span class='disabled'>previous</span>";
|
| 120 |
+
}
|
| 121 |
+
// Pages
|
| 122 |
+
if ($lastpage < 7 + ($stages * 2)){ // Not enough pages to breaking it up
|
| 123 |
+
for ($counter = 1; $counter <= $lastpage; $counter++){
|
| 124 |
+
if ($counter == $page){
|
| 125 |
+
$paginate .= "<span class='current'>$counter</span>";
|
| 126 |
+
}else{
|
| 127 |
+
$paginate .= "<a href='#' onclick='setPage($counter)'>$counter</a>";
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
}else if($lastpage > 5 + ($stages * 2)){ // Enough pages to hide a few?
|
| 131 |
+
// Beginning only hide later pages
|
| 132 |
+
if($page < 1 + ($stages * 2)){
|
| 133 |
+
for ($counter = 1; $counter < 4 + ($stages * 2); $counter++){
|
| 134 |
+
if ($counter == $page){
|
| 135 |
+
$paginate .= "<span class='current'>$counter</span>";
|
| 136 |
+
}else{
|
| 137 |
+
$paginate .= "<a href='#' onclick='setPage($counter)'>$counter</a>";
|
| 138 |
+
}
|
| 139 |
+
}
|
| 140 |
+
$paginate .= "...";
|
| 141 |
+
$paginate .= "<a href='#' onclick='setPage($LastPagem)'>$LastPagem1</a>";
|
| 142 |
+
$paginate .= "<a href='#' onclick='setPage($lastpage)'>$lastpage</a>";
|
| 143 |
+
}else if($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) {// Middle hide some front and some back
|
| 144 |
+
|
| 145 |
+
$paginate .= "<a href='#' onclick='setPage(1)'>1</a>";
|
| 146 |
+
$paginate .= "<a href='#' onclick='setPage(2)'>2</a>";
|
| 147 |
+
$paginate .= "...";
|
| 148 |
+
for ($counter = $page - $stages; $counter <= $page + $stages; $counter++){
|
| 149 |
+
if ($counter == $page){
|
| 150 |
+
$paginate .= "<span class='current'>$counter</span>";
|
| 151 |
+
}else{
|
| 152 |
+
$paginate .= "<a href='#' onclick='setPage($counter)'>$counter</a>";
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
$paginate .= "...";
|
| 156 |
+
$paginate .= "<a href='#' onclick='setPage($LastPagem)'>$LastPagem1</a>";
|
| 157 |
+
$paginate .= "<a href='#' onclick='setPage($lastpage)'>$lastpage</a>";
|
| 158 |
+
}else{// End only hide early pages
|
| 159 |
+
$paginate .= "<a href='#' onclick='setPage(1)'>1</a>";
|
| 160 |
+
$paginate .= "<a href='#' onclick='setPage(2)'>2</a>";
|
| 161 |
+
$paginate .= "...";
|
| 162 |
+
for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++){
|
| 163 |
+
if ($counter == $page){
|
| 164 |
+
$paginate.= "<span class='current'>$counter</span>";
|
| 165 |
+
}else{
|
| 166 |
+
$paginate.= "<a href='#' onclick='setPage($counter)'>$counter</a>";
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
// Next
|
| 172 |
+
if ($page < $counter - 1){
|
| 173 |
+
$paginate .= "<a href='#' onclick='setPage($next)'>next</a>";
|
| 174 |
+
}else{
|
| 175 |
+
$paginate .= "<span class='disabled'>next</span>";
|
| 176 |
+
}
|
| 177 |
+
$viewPerPage = " View <select name='limit' onchange='getPaginationLimit(this)'>";
|
| 178 |
+
foreach($limitConf as $limits){
|
| 179 |
+
$selected = ($limits == $limit)?'selected=true':'';
|
| 180 |
+
$viewPerPage .= "<option value='$limits' $selected>$limits</option>";
|
| 181 |
+
}
|
| 182 |
+
$viewPerPage .= "</select> per page ";
|
| 183 |
+
|
| 184 |
+
$paginate .= $viewPerPage ." | ";
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
if($reportCount){
|
| 188 |
+
$paginate .= " Total ".$reportCount." records found </div>";
|
| 189 |
+
}else{
|
| 190 |
+
//$paginate .= " No records found. </div>";
|
| 191 |
+
$paginate .= "</div>";
|
| 192 |
+
}
|
| 193 |
+
|
| 194 |
+
$returnVal = array();
|
| 195 |
+
$returnVal['start'] = $start;
|
| 196 |
+
$returnVal['reportCount'] = $reportCount;
|
| 197 |
+
$returnVal['paginationLink'] = $paginate;
|
| 198 |
+
|
| 199 |
+
return $returnVal;
|
| 200 |
+
}
|
| 201 |
+
}
|
app/code/community/Vtrio/CustomReports/Model/Collection.php
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Vtrio_CustomReports_Model_Collection extends Mage_Core_Model_Abstract
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
protected function _construct()
|
| 7 |
+
{
|
| 8 |
+
parent::_construct();
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
public function getReport($catId,$subCatId,$from,$to,$report_period,$store_id,$order_statuses,$start,$limit){
|
| 12 |
+
|
| 13 |
+
$reportArr = array();
|
| 14 |
+
|
| 15 |
+
if($from && $to){
|
| 16 |
+
|
| 17 |
+
$fromExp = explode('/',$from);
|
| 18 |
+
$toExp = explode('/',$to);
|
| 19 |
+
|
| 20 |
+
if(!empty($order_statuses)){
|
| 21 |
+
$status = " and sfo.status in (";
|
| 22 |
+
for($i = 0;$i<count($order_statuses);$i++){
|
| 23 |
+
|
| 24 |
+
if($i==count($order_statuses)-1){
|
| 25 |
+
$status .= "'".$order_statuses[$i]."')";
|
| 26 |
+
}else{
|
| 27 |
+
$status .= "'".$order_statuses[$i]."',";
|
| 28 |
+
}
|
| 29 |
+
}
|
| 30 |
+
}else{
|
| 31 |
+
$status = "";
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
$fromDate = $fromExp[2]."-".$fromExp[0]."-".$fromExp[1]." 00:00:00";
|
| 35 |
+
$toDate = $toExp[2]."-".$toExp[0]."-".$toExp[1]." 23:59:00";
|
| 36 |
+
|
| 37 |
+
$store_id = (trim($store_id))?" and sfoi.store_id='$store_id'":'';
|
| 38 |
+
$catalog_category_table= Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
|
| 39 |
+
if($catId){
|
| 40 |
+
$category = " left join $catalog_category_table as ccp on ccp.product_id=sfoi.product_id ";
|
| 41 |
+
if($subCatId){
|
| 42 |
+
$categoryWhere = (trim($subCatId))?" and ccp.category_id='$subCatId'":'';
|
| 43 |
+
}else{
|
| 44 |
+
$categoryWhere = (trim($catId))?" and ccp.category_id='$catId'":'';
|
| 45 |
+
}
|
| 46 |
+
}else{
|
| 47 |
+
$category = "";
|
| 48 |
+
$categoryWhere = "";
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
$sale_flat_table= Mage::getSingleton('core/resource')->getTableName('sales_flat_order_item');
|
| 53 |
+
$sales_flat_order_table = Mage::getSingleton('core/resource')->getTableName('sales_flat_order');
|
| 54 |
+
|
| 55 |
+
$sql = "SELECT sfoi.created_at, sfoi.name, sfoi.sku, sfoi.price, sfoi.qty_ordered FROM $sale_flat_table as sfoi
|
| 56 |
+
left join $sales_flat_order_table as sfo on sfo.entity_id=sfoi.order_id
|
| 57 |
+
$category
|
| 58 |
+
WHERE sfoi.created_at between '$fromDate' and '$toDate' $store_id $categoryWhere $status and sfoi.price >0 and sfoi.base_price >0
|
| 59 |
+
order by sfoi.created_at LIMIT $start, $limit";
|
| 60 |
+
|
| 61 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 62 |
+
$reportArr = $connection->fetchAll($sql);
|
| 63 |
+
}
|
| 64 |
+
return $reportArr;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
public function gridColSpan($gridVal,$period){
|
| 68 |
+
|
| 69 |
+
$colSpanArr = array();
|
| 70 |
+
$dateValOld = "";
|
| 71 |
+
$i=0;
|
| 72 |
+
$totalCount = 0;
|
| 73 |
+
|
| 74 |
+
if($period == 'month'){
|
| 75 |
+
foreach($gridVal as $val){
|
| 76 |
+
$dateVal1 = explode("-",$val['created_at']);
|
| 77 |
+
$dateVal = $dateVal1[1]."/".$dateVal1[0];
|
| 78 |
+
if($dateVal != $dateValOld && $i>1){
|
| 79 |
+
array_push($colSpanArr,$i);
|
| 80 |
+
$totalCount = $totalCount+$i;
|
| 81 |
+
$i=0;
|
| 82 |
+
}
|
| 83 |
+
$dateValOld = $dateVal;
|
| 84 |
+
$i++;
|
| 85 |
+
}
|
| 86 |
+
if(!empty($colSpanArr)){
|
| 87 |
+
array_push($colSpanArr,count($gridVal)-$totalCount);
|
| 88 |
+
}else if(!empty($gridVal) && empty($colSpanArr)){
|
| 89 |
+
array_push($colSpanArr,count($gridVal));
|
| 90 |
+
}
|
| 91 |
+
}else if($period == 'year'){
|
| 92 |
+
foreach($gridVal as $val){
|
| 93 |
+
$dateVal = explode("-",$val['created_at']);
|
| 94 |
+
if($dateVal[0] != $dateValOld && $i>1){
|
| 95 |
+
array_push($colSpanArr,$i);
|
| 96 |
+
$totalCount = $totalCount+$i;
|
| 97 |
+
$i=0;
|
| 98 |
+
}
|
| 99 |
+
$dateValOld = $dateVal[0];
|
| 100 |
+
$i++;
|
| 101 |
+
}
|
| 102 |
+
if(!empty($colSpanArr)){
|
| 103 |
+
array_push($colSpanArr,count($gridVal)-$totalCount);
|
| 104 |
+
}else if(!empty($gridVal) && empty($colSpanArr)){
|
| 105 |
+
array_push($colSpanArr,count($gridVal));
|
| 106 |
+
}
|
| 107 |
+
}else{
|
| 108 |
+
foreach($gridVal as $val){
|
| 109 |
+
$dateVal = explode(" ",$val['created_at']);
|
| 110 |
+
if($dateVal[0] != $dateValOld && $i>1){
|
| 111 |
+
array_push($colSpanArr,$i);
|
| 112 |
+
$totalCount = $totalCount+$i;
|
| 113 |
+
$i=0;
|
| 114 |
+
}
|
| 115 |
+
$dateValOld = $dateVal[0];
|
| 116 |
+
$i++;
|
| 117 |
+
}
|
| 118 |
+
if(!empty($colSpanArr)){
|
| 119 |
+
array_push($colSpanArr,count($gridVal)-$totalCount);
|
| 120 |
+
}else if(!empty($gridVal) && empty($colSpanArr)){
|
| 121 |
+
array_push($colSpanArr,count($gridVal));
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
return $colSpanArr;
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
function getOrderStatus(){
|
| 129 |
+
$sales_order_status = Mage::getSingleton('core/resource')->getTableName('sales_order_status');
|
| 130 |
+
$sql = "SELECT status, label FROM $sales_order_status order by label asc";
|
| 131 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 132 |
+
$statusArr = $connection->fetchAll($sql);
|
| 133 |
+
return $statusArr;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
public function getReportCSV($catId,$subCatId,$from,$to,$report_period,$store_id,$order_statuses){
|
| 137 |
+
|
| 138 |
+
$reportArr = array();
|
| 139 |
+
|
| 140 |
+
if($from && $to){
|
| 141 |
+
|
| 142 |
+
$fromExp = explode('/',$from);
|
| 143 |
+
$toExp = explode('/',$to);
|
| 144 |
+
|
| 145 |
+
if(!empty($order_statuses)){
|
| 146 |
+
$status = " and sfo.status in (";
|
| 147 |
+
for($i = 0;$i<count($order_statuses);$i++){
|
| 148 |
+
|
| 149 |
+
if($i==count($order_statuses)-1){
|
| 150 |
+
$status .= "'".$order_statuses[$i]."')";
|
| 151 |
+
}else{
|
| 152 |
+
$status .= "'".$order_statuses[$i]."',";
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
}else{
|
| 156 |
+
$status = "";
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
$fromDate = $fromExp[2]."-".$fromExp[0]."-".$fromExp[1]." 00:00:00";
|
| 160 |
+
$toDate = $toExp[2]."-".$toExp[0]."-".$toExp[1]." 23:59:00";
|
| 161 |
+
|
| 162 |
+
$store_id = (trim($store_id))?" and sfoi.store_id='$store_id'":'';
|
| 163 |
+
$catalog_category_table= Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
|
| 164 |
+
if($catId){
|
| 165 |
+
$category = " left join $catalog_category_table as ccp on ccp.product_id=sfoi.product_id ";
|
| 166 |
+
if($subCatId){
|
| 167 |
+
$categoryWhere = (trim($subCatId))?" and ccp.category_id='$subCatId'":'';
|
| 168 |
+
}else{
|
| 169 |
+
$categoryWhere = (trim($catId))?" and ccp.category_id='$catId'":'';
|
| 170 |
+
}
|
| 171 |
+
}else{
|
| 172 |
+
$category = "";
|
| 173 |
+
$categoryWhere = "";
|
| 174 |
+
}
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
$sale_flat_table= Mage::getSingleton('core/resource')->getTableName('sales_flat_order_item');
|
| 178 |
+
$sales_flat_order_table = Mage::getSingleton('core/resource')->getTableName('sales_flat_order');
|
| 179 |
+
|
| 180 |
+
$sql = "SELECT sfoi.created_at as date, sfoi.name, sfoi.sku, sfoi.price, sfoi.qty_ordered FROM $sale_flat_table as sfoi
|
| 181 |
+
left join $sales_flat_order_table as sfo on sfo.entity_id=sfoi.order_id
|
| 182 |
+
$category
|
| 183 |
+
WHERE sfoi.created_at between '$fromDate' and '$toDate' $store_id $categoryWhere $status and sfoi.price >0 and sfoi.base_price >0
|
| 184 |
+
order by sfoi.created_at";
|
| 185 |
+
|
| 186 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 187 |
+
$reportArr = $connection->fetchAll($sql);
|
| 188 |
+
}
|
| 189 |
+
return $reportArr;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
public function getReportCount($catId,$subCatId,$from,$to,$report_period,$store_id,$order_statuses){
|
| 193 |
+
|
| 194 |
+
$reportArr = array();
|
| 195 |
+
|
| 196 |
+
if($from && $to){
|
| 197 |
+
|
| 198 |
+
$fromExp = explode('/',$from);
|
| 199 |
+
$toExp = explode('/',$to);
|
| 200 |
+
|
| 201 |
+
if(!empty($order_statuses)){
|
| 202 |
+
$status = " and sfo.status in (";
|
| 203 |
+
for($i = 0;$i<count($order_statuses);$i++){
|
| 204 |
+
|
| 205 |
+
if($i==count($order_statuses)-1){
|
| 206 |
+
$status .= "'".$order_statuses[$i]."')";
|
| 207 |
+
}else{
|
| 208 |
+
$status .= "'".$order_statuses[$i]."',";
|
| 209 |
+
}
|
| 210 |
+
}
|
| 211 |
+
}else{
|
| 212 |
+
$status = "";
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
$fromDate = $fromExp[2]."-".$fromExp[0]."-".$fromExp[1]." 00:00:00";
|
| 216 |
+
$toDate = $toExp[2]."-".$toExp[0]."-".$toExp[1]." 23:59:00";
|
| 217 |
+
|
| 218 |
+
$store_id = (trim($store_id))?" and sfoi.store_id='$store_id'":'';
|
| 219 |
+
$catalog_category_table= Mage::getSingleton('core/resource')->getTableName('catalog_category_product');
|
| 220 |
+
if($catId){
|
| 221 |
+
$category = " left join $catalog_category_table as ccp on ccp.product_id=sfoi.product_id ";
|
| 222 |
+
if($subCatId){
|
| 223 |
+
$categoryWhere = (trim($subCatId))?" and ccp.category_id='$subCatId'":'';
|
| 224 |
+
}else{
|
| 225 |
+
$categoryWhere = (trim($catId))?" and ccp.category_id='$catId'":'';
|
| 226 |
+
}
|
| 227 |
+
}else{
|
| 228 |
+
$category = "";
|
| 229 |
+
$categoryWhere = "";
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
$sale_flat_table= Mage::getSingleton('core/resource')->getTableName('sales_flat_order_item');
|
| 234 |
+
$sales_flat_order_table = Mage::getSingleton('core/resource')->getTableName('sales_flat_order');
|
| 235 |
+
|
| 236 |
+
$sql = "SELECT count(*) as totalCount FROM $sale_flat_table as sfoi
|
| 237 |
+
left join $sales_flat_order_table as sfo on sfo.entity_id=sfoi.order_id
|
| 238 |
+
$category
|
| 239 |
+
WHERE sfoi.created_at between '$fromDate' and '$toDate' $store_id $categoryWhere $status and sfoi.price >0 and sfoi.base_price >0
|
| 240 |
+
order by sfoi.created_at";
|
| 241 |
+
|
| 242 |
+
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
|
| 243 |
+
$reportArr = $connection->fetchAll($sql);
|
| 244 |
+
}
|
| 245 |
+
return $reportArr;
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
}
|
app/code/community/Vtrio/CustomReports/controllers/Report/IndexController.php
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Vtrio_CustomReports_Report_IndexController extends Mage_Adminhtml_Controller_Action
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
protected function _isAllowed()
|
| 7 |
+
{
|
| 8 |
+
$act = $this->getRequest()->getActionName();
|
| 9 |
+
if (!$act)
|
| 10 |
+
$act = 'default';
|
| 11 |
+
switch ($act) {
|
| 12 |
+
case 'default':
|
| 13 |
+
break;
|
| 14 |
+
default:
|
| 15 |
+
return Mage::getSingleton('admin/session')->isAllowed('report/customreport');
|
| 16 |
+
break;
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
public function _initAction()
|
| 21 |
+
{
|
| 22 |
+
$act = $this->getRequest()->getActionName();
|
| 23 |
+
if (!$act)
|
| 24 |
+
$act = 'default';
|
| 25 |
+
if ($act == 'default')
|
| 26 |
+
{
|
| 27 |
+
$this->loadLayout()
|
| 28 |
+
->_addBreadcrumb(Mage::helper('customreports')->__('Reports'), Mage::helper('customreports')->__('Reports'));
|
| 29 |
+
}else{
|
| 30 |
+
$this->loadLayout()
|
| 31 |
+
->_addBreadcrumb(Mage::helper('customreports')->__('Reports'), Mage::helper('customreports')->__('Reports'));
|
| 32 |
+
}
|
| 33 |
+
return $this;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
public function customReportAction()
|
| 38 |
+
{
|
| 39 |
+
$this->_title($this->__('Custom Reports'));
|
| 40 |
+
$this->_initAction()
|
| 41 |
+
->_setActiveMenu('report/customreport')
|
| 42 |
+
->_addBreadcrumb(Mage::helper('customreports')->__('Custom Report'), Mage::helper('customreports')->__('Custom Report'))
|
| 43 |
+
->_addContent($this->getLayout()->createBlock('customreports/report_custom'))
|
| 44 |
+
->renderLayout();
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
public function gridAction()
|
| 48 |
+
{
|
| 49 |
+
$this->loadLayout();
|
| 50 |
+
$this->renderLayout();
|
| 51 |
+
$this->getResponse()->setBody(
|
| 52 |
+
$this->getLayout()->createBlock('customreports/report_custom_grid')->toHtml()
|
| 53 |
+
);
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
public function getsubcategoryAction()
|
| 57 |
+
{
|
| 58 |
+
$catId = $this->getRequest()->getParam('catId');
|
| 59 |
+
$helper = Mage::helper('customreports');
|
| 60 |
+
$children = Mage::getModel('catalog/category')->getCategories($catId);
|
| 61 |
+
?>
|
| 62 |
+
<select class=" select" title="Period" name="subcategory" id="subcategory">
|
| 63 |
+
<option value="">----------------------Please Select----------------------</option>
|
| 64 |
+
<?php
|
| 65 |
+
foreach ($children as $subCategory) {
|
| 66 |
+
$selectedSubCategory = ($subCatId == $subCategory->getId())?'selected = true':'';
|
| 67 |
+
$id = $subCategory->getId();
|
| 68 |
+
$name = $subCategory->getName();
|
| 69 |
+
$option .="<option value='$id' $selectedSubCategory >$name</option>";
|
| 70 |
+
$option .= $helper->nestedSubCategory($id,3);
|
| 71 |
+
}
|
| 72 |
+
echo $option;
|
| 73 |
+
?>
|
| 74 |
+
</select>
|
| 75 |
+
<?php
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
public function csv_exportAction(){
|
| 79 |
+
|
| 80 |
+
$catId = $this->getRequest()->getParam('catId');
|
| 81 |
+
$subCatId = $this->getRequest()->getParam('subCatId');
|
| 82 |
+
$from = $this->getRequest()->getParam('from');
|
| 83 |
+
$to = $this->getRequest()->getParam('to');
|
| 84 |
+
$report_period = $this->getRequest()->getParam('period');
|
| 85 |
+
$store_ids = $this->getRequest()->getParam('store_id');
|
| 86 |
+
$order_statuses= $this->getRequest()->getParam('order_statuses');
|
| 87 |
+
|
| 88 |
+
$model = Mage::getModel('customreports/collection');
|
| 89 |
+
$reportArr = $model->getReportCSV($catId,$subCatId,$from,$to,$report_period,$store_ids,$order_statuses);
|
| 90 |
+
|
| 91 |
+
$helper = Mage::helper('customreports');
|
| 92 |
+
$returnResult = $helper->exportReportToCSV($reportArr,$report_period);
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
}
|
app/code/community/Vtrio/CustomReports/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<config>
|
| 2 |
+
<menu>
|
| 3 |
+
<report>
|
| 4 |
+
<title>Reports</title>
|
| 5 |
+
<sort_order>80</sort_order>
|
| 6 |
+
<children>
|
| 7 |
+
<customreport>
|
| 8 |
+
<title>Custom Reports</title>
|
| 9 |
+
<action>customreports/report_index/customreport</action>
|
| 10 |
+
<sort_order>10</sort_order>
|
| 11 |
+
</customreport>
|
| 12 |
+
</children>
|
| 13 |
+
</report>
|
| 14 |
+
</menu>
|
| 15 |
+
</config>
|
app/code/community/Vtrio/CustomReports/etc/config.xml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Vtrio_CustomReports>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</Vtrio_CustomReports>
|
| 7 |
+
</modules>
|
| 8 |
+
<global>
|
| 9 |
+
<blocks>
|
| 10 |
+
<customreports>
|
| 11 |
+
<class>Vtrio_CustomReports_Block</class>
|
| 12 |
+
</customreports>
|
| 13 |
+
</blocks>
|
| 14 |
+
<helpers>
|
| 15 |
+
<customreports>
|
| 16 |
+
<class>Vtrio_CustomReports_Helper</class>
|
| 17 |
+
</customreports>
|
| 18 |
+
</helpers>
|
| 19 |
+
<models>
|
| 20 |
+
<customreports>
|
| 21 |
+
<class>Vtrio_CustomReports_Model</class>
|
| 22 |
+
</customreports>
|
| 23 |
+
</models>
|
| 24 |
+
</global>
|
| 25 |
+
<admin>
|
| 26 |
+
<routers>
|
| 27 |
+
<customreports>
|
| 28 |
+
<use>admin</use>
|
| 29 |
+
<args>
|
| 30 |
+
<module>Vtrio_CustomReports</module>
|
| 31 |
+
<frontName>customreports</frontName>
|
| 32 |
+
</args>
|
| 33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
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<link rel="stylesheet" type="text/css" href="<?php echo $this->getSkinUrl('vtriocustomreport/pagination.css');?>" />
|
| 2 |
+
<?php
|
| 3 |
+
if($this->getRequest()->getParams()){
|
| 4 |
+
$key = ($this->getRequest()->getParam('key'))?$this->getRequest()->getParam('key'):'';
|
| 5 |
+
$catId = ($this->getRequest()->getParam('category'))?$this->getRequest()->getParam('category'):'';
|
| 6 |
+
$subCatId = ($this->getRequest()->getParam('subcategory'))?$this->getRequest()->getParam('subcategory'):'';
|
| 7 |
+
$from = ($this->getRequest()->getParam('from'))?$this->getRequest()->getParam('from'):'';
|
| 8 |
+
$to = ($this->getRequest()->getParam('to'))?$this->getRequest()->getParam('to'):'';
|
| 9 |
+
$report_period = ($this->getRequest()->getParam('report_period'))?$this->getRequest()->getParam('report_period'):'';
|
| 10 |
+
$store_ids = ($this->getRequest()->getParam('store_ids'))?$this->getRequest()->getParam('store_ids'):'';
|
| 11 |
+
$website1 = ($this->getRequest()->getParam('website'))?$this->getRequest()->getParam('website'):'';
|
| 12 |
+
$website2 = ($this->getRequest()->getParam('store'))?$this->getRequest()->getParam('store'):'';
|
| 13 |
+
$website3 = ($this->getRequest()->getParam('group'))?$this->getRequest()->getParam('group'):'';
|
| 14 |
+
$export = ($this->getRequest()->getParam('export'))?$this->getRequest()->getParam('export'):'';
|
| 15 |
+
$showOrderStatus = ($this->getRequest()->getParam('show_order_statuses'))?$this->getRequest()->getParam('show_order_statuses'):'';
|
| 16 |
+
if($showOrderStatus == '1'){
|
| 17 |
+
$order_statuses= ($this->getRequest()->getParam('order_statuses'))?$this->getRequest()->getParam('order_statuses'):'';
|
| 18 |
+
}else{
|
| 19 |
+
$order_statuses= "";
|
| 20 |
+
}
|
| 21 |
+
if(trim($website1)){
|
| 22 |
+
$website = $website1;
|
| 23 |
+
}else if($website2){
|
| 24 |
+
$website = $website2;
|
| 25 |
+
}else{
|
| 26 |
+
$website = $website3;
|
| 27 |
+
}
|
| 28 |
+
$page = ($this->getRequest()->getParam('page'))?$this->getRequest()->getParam('page'):'';
|
| 29 |
+
$limit = ($this->getRequest()->getParam('limit'))?$this->getRequest()->getParam('limit'):20;
|
| 30 |
+
}
|
| 31 |
+
$helper = Mage::helper('customreports');
|
| 32 |
+
$paginationArr = $helper->paginationCtrl($catId,$subCatId,$from,$to,$report_period,$store_ids,$order_statuses,$limit,$page);
|
| 33 |
+
$start = $paginationArr['start'];
|
| 34 |
+
$limit = ($paginationArr['limit'])?$paginationArr['limit']:$limit;
|
| 35 |
+
$pagination = $paginationArr['paginationLink'];
|
| 36 |
+
$model = Mage::getModel('customreports/collection');
|
| 37 |
+
$reportArr = $model->getReport($catId,$subCatId,$from,$to,$report_period,$store_ids,$order_statuses,$start,$limit);
|
| 38 |
+
$gridColSpan = $model->gridColSpan($reportArr,$report_period);
|
| 39 |
+
$orderStatus = $model->getOrderStatus();
|
| 40 |
+
?>
|
| 41 |
+
<?php echo $this->getStoreSwitcherHtml() ?>
|
| 42 |
+
<div class="entry-edit">
|
| 43 |
+
<form method="post" action="<?php echo Mage::helper('core/url')->getCurrentUrl();?>" id="filter_form">
|
| 44 |
+
<div></div>
|
| 45 |
+
<div class="entry-edit-head">
|
| 46 |
+
<h4 class="icon-head head-edit-form fieldset-legend">Filter</h4>
|
| 47 |
+
<div class="form-buttons"></div>
|
| 48 |
+
</div>
|
| 49 |
+
<div id="sales_report_base_fieldset" class="fieldset ">
|
| 50 |
+
<div class="hor-scroll">
|
| 51 |
+
<table cellspacing="0" class="form-list">
|
| 52 |
+
<tbody>
|
| 53 |
+
<tr>
|
| 54 |
+
<td class="hidden" colspan="2">
|
| 55 |
+
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
| 56 |
+
<input type="hidden" value="<?php echo $website;?>" name="store_ids" id="sales_report_store_ids">
|
| 57 |
+
<input type="hidden" value="<?php echo $limit;?>" name="limit" id="limit">
|
| 58 |
+
<input type="hidden" value="<?php echo $page;?>" name="page" id="page">
|
| 59 |
+
</td>
|
| 60 |
+
</tr>
|
| 61 |
+
<tr>
|
| 62 |
+
<td class="label"><label for="sales_report_period_type">Category</label></td>
|
| 63 |
+
<td class="value">
|
| 64 |
+
<select class=" select" title="Period" name="category" id="category" onchange="categoryChange(this)">
|
| 65 |
+
<option value="">----------------------Please Select----------------------</option>
|
| 66 |
+
<?php
|
| 67 |
+
$category = Mage::getModel('catalog/category');
|
| 68 |
+
$tree = $category->getTreeModel();
|
| 69 |
+
$tree->load();
|
| 70 |
+
$ids = $tree->getCollection()->getAllIds();
|
| 71 |
+
if ($ids){
|
| 72 |
+
foreach ($ids as $id){
|
| 73 |
+
$cat = Mage::getModel('catalog/category');
|
| 74 |
+
$cat->load($id);
|
| 75 |
+
if($cat->getLevel()==2 && $cat->getIsActive()==1){
|
| 76 |
+
$selected = ($catId == $cat->getId())?'selected = true':'';
|
| 77 |
+
?>
|
| 78 |
+
<option value=<?php echo $cat->getId();?> <?php echo $selected;?>><?php echo $cat->getName();?></option>
|
| 79 |
+
<?php }
|
| 80 |
+
}
|
| 81 |
+
}?>
|
| 82 |
+
</select>
|
| 83 |
+
</td>
|
| 84 |
+
</tr>
|
| 85 |
+
<tr>
|
| 86 |
+
<td class="label"><label for="sales_report_period_type">Sub-Category</label></td>
|
| 87 |
+
<td class="value">
|
| 88 |
+
<div id="getSubCategory">
|
| 89 |
+
<select class=" select" title="Period" name="subcategory" id="subcategory">
|
| 90 |
+
<option value="">----------------------Please Select----------------------</option>
|
| 91 |
+
<?php
|
| 92 |
+
$catId = $this->getRequest()->getParam('category');
|
| 93 |
+
$children = Mage::getModel('catalog/category')->getCategories($catId);
|
| 94 |
+
$helper = Mage::helper('customreports');
|
| 95 |
+
foreach ($children as $subCategory) {
|
| 96 |
+
$selectedSubCategory = ($subCatId == $subCategory->getId())?'selected = true':'';
|
| 97 |
+
$id = $subCategory->getId();
|
| 98 |
+
$name = $subCategory->getName();
|
| 99 |
+
$option .= "<option value='$id' $selectedSubCategory>$name</option>";
|
| 100 |
+
$option .= $helper->nestedSubCategory($id,3,$subCatId);
|
| 101 |
+
}
|
| 102 |
+
echo $option;
|
| 103 |
+
?>
|
| 104 |
+
</select>
|
| 105 |
+
</div>
|
| 106 |
+
</td>
|
| 107 |
+
</tr>
|
| 108 |
+
<tr>
|
| 109 |
+
<td class="label"><label for="sales_report_show_order_statuses">Order Status</label></td>
|
| 110 |
+
<td class="value">
|
| 111 |
+
<select class=" select" name="show_order_statuses" id="sales_report_show_order_statuses" onChange="getStatus()">
|
| 112 |
+
<option selected="selected" value="0" <?php echo ($showOrderStatus == '0')?'selected=true':'';?>>Any</option>
|
| 113 |
+
<option value="1" <?php echo ($showOrderStatus == '1')?'selected=true':'';?>>Specified</option>
|
| 114 |
+
</select>
|
| 115 |
+
<p id="note_show_order_statuses" class="note"><span>Applies to Any of the Specified Order Statuses</span></p>
|
| 116 |
+
</td>
|
| 117 |
+
</tr>
|
| 118 |
+
<tr style="<?php echo ($showOrderStatus == '0' || $showOrderStatus == '')?'display:none':'';?>" id="orderStatus">
|
| 119 |
+
<td class="label"></td>
|
| 120 |
+
<td class="value">
|
| 121 |
+
<select multiple="multiple" class=" select multiselect" size="10" name="order_statuses[]" id="sales_report_order_statuses">
|
| 122 |
+
<?php
|
| 123 |
+
foreach ($orderStatus as $orderStatus_row) {
|
| 124 |
+
$statusName = $orderStatus_row['status'];
|
| 125 |
+
$statuslabel = $orderStatus_row['label'];
|
| 126 |
+
$selected = (in_array($statusName, $order_statuses))?'selected=true':'';
|
| 127 |
+
|
| 128 |
+
?>
|
| 129 |
+
<option value="<?php echo $statusName;?>" <?php echo $selected;?>><?php echo $statuslabel;?></option>
|
| 130 |
+
<?php } ?>
|
| 131 |
+
</select>
|
| 132 |
+
</td>
|
| 133 |
+
</tr>
|
| 134 |
+
<tr>
|
| 135 |
+
<td class="label"><label for="sales_report_from">From <span class="required">*</span></label></td>
|
| 136 |
+
<td class="value">
|
| 137 |
+
<input type="text" style="width:110px !important;" class=" required-entry input-text" title="From" value="<?php echo $from;?>" id="sales_report_from" name="from"> <img style="" title="Select Date" id="sales_report_from_trig" class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>/skin/adminhtml/default/default/images/grid-cal.gif">
|
| 138 |
+
<div id="period_date_from_advaice"></div>
|
| 139 |
+
<script type="text/javascript">
|
| 140 |
+
//<![CDATA[
|
| 141 |
+
Calendar.setup({
|
| 142 |
+
inputField: "sales_report_from",
|
| 143 |
+
ifFormat: "%m/%e/%Y",
|
| 144 |
+
showsTime: false,
|
| 145 |
+
button: "sales_report_from_trig",
|
| 146 |
+
align: "Bl",
|
| 147 |
+
singleClick : true
|
| 148 |
+
});
|
| 149 |
+
//]]>
|
| 150 |
+
</script>
|
| 151 |
+
</td>
|
| 152 |
+
</tr>
|
| 153 |
+
<tr>
|
| 154 |
+
<td class="label"><label for="sales_report_to">To <span class="required">*</span></label></td>
|
| 155 |
+
<td class="value">
|
| 156 |
+
<input type="text" style="width:110px !important;" class=" required-entry input-text" title="To" value="<?php echo $to;?>" id="sales_report_to" name="to"> <img style="" title="Select Date" id="sales_report_to_trig" class="v-middle" alt="" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);?>skin/adminhtml/default/default/images/grid-cal.gif">
|
| 157 |
+
<div id="period_date_to_advaice"></div>
|
| 158 |
+
<script type="text/javascript">
|
| 159 |
+
//<![CDATA[
|
| 160 |
+
Calendar.setup({
|
| 161 |
+
inputField: "sales_report_to",
|
| 162 |
+
ifFormat: "%m/%e/%Y",
|
| 163 |
+
showsTime: false,
|
| 164 |
+
button: "sales_report_to_trig",
|
| 165 |
+
align: "Bl",
|
| 166 |
+
singleClick : true
|
| 167 |
+
});
|
| 168 |
+
//]]>
|
| 169 |
+
</script>
|
| 170 |
+
</td>
|
| 171 |
+
</tr>
|
| 172 |
+
<tr>
|
| 173 |
+
<td class="label"><label for="sales_report_to">Period</label></td>
|
| 174 |
+
<td class="value">
|
| 175 |
+
<select name="report_period" id="report_period" class="select">
|
| 176 |
+
<option value="day" <?php echo ($report_period == 'day')?'selected="true"':'';?>>Day</option>
|
| 177 |
+
<option value="month" <?php echo ($report_period == 'month')?'selected="true"':'';?>>Month</option>
|
| 178 |
+
<option value="year" <?php echo ($report_period == 'year')?'selected="true"':'';?>>Year</option>
|
| 179 |
+
</td>
|
| 180 |
+
</tr>
|
| 181 |
+
</tbody>
|
| 182 |
+
</table>
|
| 183 |
+
</div>
|
| 184 |
+
</div>
|
| 185 |
+
<table cellspacing="0" class="actions">
|
| 186 |
+
<tr>
|
| 187 |
+
<td>
|
| 188 |
+
<?php echo $pagination;?>
|
| 189 |
+
</td>
|
| 190 |
+
<td class=" a-right">
|
| 191 |
+
<img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/> <?php echo $this->__('Export to:') ?>
|
| 192 |
+
<select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
|
| 193 |
+
<option value="csv">CSV</option>
|
| 194 |
+
</select>
|
| 195 |
+
<button style="" onclick="doExport()" class="scalable task" type="button" title="Export" id="export">Export</button>
|
| 196 |
+
</td>
|
| 197 |
+
</tr>
|
| 198 |
+
</table>
|
| 199 |
+
</form>
|
| 200 |
+
</div>
|
| 201 |
+
<!-- ----------------------- Grid ---------------------- --->
|
| 202 |
+
<div class="grid">
|
| 203 |
+
<table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
|
| 204 |
+
<col/>
|
| 205 |
+
<?php foreach ($this->getColumns() as $_column): ?>
|
| 206 |
+
<col <?php echo $_column->getHtmlProperty() ?>/>
|
| 207 |
+
<?php endforeach; ?>
|
| 208 |
+
<thead>
|
| 209 |
+
<tr class="headings">
|
| 210 |
+
<th class="no-link" style="width:100px"><span class="no-br"><?php echo $this->getPeriodText() ?></span></th>
|
| 211 |
+
<?php foreach ($this->getColumns() as $_column): ?>
|
| 212 |
+
<th <?php echo $_column->getHeaderHtmlProperty() ?>><span class="no-br"><?php echo $_column->getHeaderHtml() ?></span></th>
|
| 213 |
+
<?php endforeach; ?>
|
| 214 |
+
</tr>
|
| 215 |
+
</thead>
|
| 216 |
+
<?php if(count($reportArr) == 0):?>
|
| 217 |
+
<tbody>
|
| 218 |
+
<tr class="even">
|
| 219 |
+
<td colspan="5" class="empty-text a-center">No records found.</td>
|
| 220 |
+
</tr>
|
| 221 |
+
</tbody>
|
| 222 |
+
<?php else: ?>
|
| 223 |
+
<tbody>
|
| 224 |
+
<?php
|
| 225 |
+
$totalQty = 0;
|
| 226 |
+
$totalPrice = 0;
|
| 227 |
+
$i = 0;
|
| 228 |
+
$j = 0;
|
| 229 |
+
$k = 0;
|
| 230 |
+
foreach ($reportArr as $arr_row) {
|
| 231 |
+
$totalQty = $totalQty+$arr_row['qty_ordered'];
|
| 232 |
+
$totalPrice = $totalPrice+$arr_row['price'];
|
| 233 |
+
if($report_period == 'month'){
|
| 234 |
+
$dateVal1 = explode("-",$arr_row['created_at']);
|
| 235 |
+
$createdDate = $dateVal1[1]."/".$dateVal1[0];
|
| 236 |
+
}else if($report_period == 'year'){
|
| 237 |
+
$dateVal1 = explode("-",$arr_row['created_at']);
|
| 238 |
+
$createdDate = $dateVal1[0];
|
| 239 |
+
}else{
|
| 240 |
+
$date = date_create($arr_row['created_at']);
|
| 241 |
+
$createdDate = date_format($date,"M d, Y");
|
| 242 |
+
}
|
| 243 |
+
if($gridColSpan[$k] == $i){
|
| 244 |
+
$i = 0;$k++;
|
| 245 |
+
}
|
| 246 |
+
if($i == 0){ ?>
|
| 247 |
+
<tr title="#" class="pointer">
|
| 248 |
+
<td class=" " rowspan="<?php echo $gridColSpan[$k];?>"><span class="nobr"><?php echo $createdDate;?></span></td>
|
| 249 |
+
<td class=" "><?php echo $arr_row['name'];?></td>
|
| 250 |
+
<td class=" a-right "><?php echo $arr_row['sku'];?></td>
|
| 251 |
+
<td class=" a-right "><?php echo number_format($arr_row['price'], 2, '.', '');?></td>
|
| 252 |
+
<td class=" a-right last"><?php echo number_format($arr_row['qty_ordered'], 2, '.', '');?></td>
|
| 253 |
+
</tr>
|
| 254 |
+
<?php }else{ ?>
|
| 255 |
+
<tr class="">
|
| 256 |
+
<td class=" "><?php echo $arr_row['name'];?></td>
|
| 257 |
+
<td class=" a-right "><?php echo $arr_row['sku'];?></td>
|
| 258 |
+
<td class=" a-right "><?php echo number_format($arr_row['price'], 2, '.', '');?></td>
|
| 259 |
+
<td class=" a-right last"><?php echo number_format($arr_row['qty_ordered'], 2, '.', '');?></td>
|
| 260 |
+
</tr/>
|
| 261 |
+
<?php
|
| 262 |
+
}
|
| 263 |
+
$i++;
|
| 264 |
+
}
|
| 265 |
+
?>
|
| 266 |
+
</tbody>
|
| 267 |
+
<tfoot>
|
| 268 |
+
<tr class="totals">
|
| 269 |
+
<th class="">Total </th>
|
| 270 |
+
<th class=""> </th>
|
| 271 |
+
<th class=" a-right"> </th>
|
| 272 |
+
<th class=" a-right"><?php echo number_format($totalPrice, 2, '.', '');?> </th>
|
| 273 |
+
<th class=" a-right"><?php echo number_format($totalQty, 2, '.', '');?> </th>
|
| 274 |
+
</tr>
|
| 275 |
+
</tfoot>
|
| 276 |
+
<?php endif; ?>
|
| 277 |
+
</table>
|
| 278 |
+
</div>
|
| 279 |
+
<script type="text/javascript">
|
| 280 |
+
function filterFormSubmit() {
|
| 281 |
+
var filters = $$('#sales_report_from', '#sales_report_to');
|
| 282 |
+
var elements = [];
|
| 283 |
+
for(var i in filters){
|
| 284 |
+
if(filters[i].value && filters[i].value.length && !filters[i].disabled) elements.push(filters[i]);
|
| 285 |
+
}
|
| 286 |
+
var validator = new Validation('filter_form');
|
| 287 |
+
if (validator.validate()) {
|
| 288 |
+
document.getElementById("export").value= '';
|
| 289 |
+
document.getElementById("page").value= '';
|
| 290 |
+
document.forms["filter_form"].submit();
|
| 291 |
+
}
|
| 292 |
+
}
|
| 293 |
+
function categoryChange(cat){
|
| 294 |
+
var catId = cat.value;
|
| 295 |
+
var newArrivals = "";
|
| 296 |
+
$url = '<?php echo $this->getUrl("customreports/report_index/getsubcategory");?>?catId='+catId;
|
| 297 |
+
new Ajax.Request($url, {
|
| 298 |
+
onSuccess: function(response) {
|
| 299 |
+
console.log(response);
|
| 300 |
+
document.getElementById('getSubCategory').innerHTML = response.responseText;
|
| 301 |
+
}
|
| 302 |
+
});
|
| 303 |
+
}
|
| 304 |
+
function doExport(){
|
| 305 |
+
var exportType = document.getElementById("customReport_export").value;
|
| 306 |
+
$parm = '?period=<?php echo $report_period;?>&catId=<?php echo $catId;?>&subCatId=<?php echo $subCatId;?>&from=<?php echo $from;?>&to=<?php echo $to;?>&store_id=<?php echo $store_id;?>&order_statuses=<?php echo $order_statuses;?>';
|
| 307 |
+
$url = '<?php echo $this->getUrl("customreports/report_index/csv_export");?>'+$parm;
|
| 308 |
+
document.location.href= $url;
|
| 309 |
+
}
|
| 310 |
+
function getStatus(){
|
| 311 |
+
if(document.getElementById("sales_report_show_order_statuses").value == '1'){
|
| 312 |
+
document.getElementById("orderStatus").style.display='';
|
| 313 |
+
}else{
|
| 314 |
+
document.getElementById("orderStatus").style.display="none";
|
| 315 |
+
}
|
| 316 |
+
}
|
| 317 |
+
function getPaginationLimit(val){
|
| 318 |
+
var limit = val.value;
|
| 319 |
+
document.getElementById("limit").value= limit;
|
| 320 |
+
document.forms["filter_form"].submit();
|
| 321 |
+
}
|
| 322 |
+
function setPage(page){
|
| 323 |
+
document.getElementById("page").value= page;
|
| 324 |
+
document.forms["filter_form"].submit();
|
| 325 |
+
}
|
| 326 |
+
</script>
|
app/etc/modules/Vtrio_CustomReports.xml
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Vtrio_CustomReports>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
<version>0.1.0</version>
|
| 8 |
+
</Vtrio_CustomReports>
|
| 9 |
+
</modules>
|
| 10 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Vtrio</name>
|
| 4 |
+
<version>0.1.0</version>
|
| 5 |
+
<stability>devel</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">MITL</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>VReport is a module which will help users to generate sales report in a more user friendly way. User could run reports based on Category ,Sub-Category and Time.</summary>
|
| 10 |
+
<description>VReport is a module which will help users to generate sales report in a more user friendly way. User could run reports based on Category ,Sub-Category and Time.
|
| 11 |
+

|
| 12 |
+
· Using the filter user could choose which category needs to have a search and report done. The drop down box is comprehensive and lists down all the Product Main Categories. So reports could be generated in detail, like which product category has been ordered from which date to which date and how many orders are in what statuses.
|
| 13 |
+
Sub Category – Lists down each Category’s division and is even more widespread. This search enables the user to get reports for each sub category under each product. This gives a better understanding of things due to its detailed listing.</description>
|
| 14 |
+
<notes>First development release</notes>
|
| 15 |
+
<authors><author><name>Developer</name><user>Developer</user><email>dev@vtrio.com</email></author></authors>
|
| 16 |
+
<date>2016-02-10</date>
|
| 17 |
+
<time>09:00:32</time>
|
| 18 |
+
<contents><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="vtriocustomreport"><file name="pagination.css" hash="3e61bea82df74a73e3b00c1952aa9770"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="vtrio"><dir name="customreports"><file name="gridproduct.phtml" hash="8ada844139e34c37e508157191cd9bea"/></dir></dir></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Vtrio_CustomReports.xml" hash="e89d1e1daf11b114edc43d860abd7ec4"/></dir></dir><dir name="code"><dir name="community"><dir name="Vtrio"><dir name="CustomReports"><dir name="Block"><dir name="Report"><dir name="Custom"><file name="Grid.php" hash="97be1eeaff2eabf3ed16dd4214a3abf9"/></dir><file name="Custom.php" hash="53ca9fae5564ba0c877c1a8e6e89e5e1"/></dir></dir><dir name="Helper"><file name="Data.php" hash="1361f3ea2073be4db3fa0e4790692bb6"/></dir><dir name="Model"><file name="Collection.php" hash="7e61f5a05a43590303a6070f1c3c2f04"/></dir><dir name="controllers"><dir name="Report"><file name="IndexController.php" hash="1afc4f670300dfe40466ebe75c182420"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="08112c6bf1a058fce42ee7a8f87b34c5"/><file name="config.xml" hash="f7a5e3b1a491346cb80627c250c72ce5"/></dir></dir></dir></dir></dir></dir></target></contents>
|
| 19 |
+
<compatible/>
|
| 20 |
+
<dependencies><required><php><min>5.3.0</min><max>5.6.14</max></php></required></dependencies>
|
| 21 |
+
</package>
|
skin/adminhtml/default/default/vtriocustomreport/pagination.css
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.vtrioCustPagination { font-family:Arial, Helvetica, sans-serif;padding: 3px; margin: 3px;}
|
| 2 |
+
.vtrioCustPagination a { padding:2px 5px 2px 5px; margin:2px; border:1px solid #999; text-decoration:none; color: #666;}
|
| 3 |
+
.vtrioCustPagination a:hover, .paginate a:active { border: 1px solid #999; color: #000;}
|
| 4 |
+
.vtrioCustPagination span.current { margin: 2px; padding: 2px 5px 2px 5px; border: 1px solid #999; font-weight: bold; background-color: #999; color: #FFF;}
|
| 5 |
+
.vtrioCustPagination span.disabled { padding:2px 5px 2px 5px; margin:2px; border:1px solid #eee; color:#DDD;}
|
