I am using custom module to getting tax report. It is working fine on demo site.
Below is the etc/config.xml:
<?xml version="1.0" ?>
<config>
<modules>
<DS_News>
<version>0.0.1</version>
</DS_News>
</modules>
<frontend>
<layout>
<updates>
<dsnews>
<file>ds_news.xml</file>
</dsnews>
</updates>
</layout>
<routers>
<dsnews><!-- Название узла dsnews, расположенного в секции config/frontend/routers/, может быть любым; единственное требование — это уникальность названия среди других роутеров системы-->
<use>standard</use>
<args>
<module>DS_News</module>
<frontName>news</frontName>
</args>
</dsnews>
</routers>
</frontend>
<global>
<blocks>
<dsnews>
<class>DS_News_Block</class>
</dsnews>
</blocks>
<helpers>
<dsnews>
<class>DS_News_Helper</class>
</dsnews>
</helpers>
<models>
<dsnews>
<class>DS_News_Model</class>
<resourceModel>dsnews_resource</resourceModel>
</dsnews>
<dsnews_resource>
<class>DS_News_Model_Resource</class>
<entities>
<table_news>
<table>ds_news_entities</table>
</table_news>
</entities>
</dsnews_resource>
</models>
<resources>
<dsnews_setup>
<setup>
<module>DS_News</module>
</setup>
</dsnews_setup>
</resources>
</global>
<adminhtml>
<menu>
<dsnews module="dsnews">
<title>Tax Report</title>
<sort_order>123</sort_order>
<action>dsnews_admin/adminhtml_news</action>
</dsnews>
</menu>
</adminhtml>
<admin>
<routers>
<dsnews_admin>
<use>admin</use>
<args>
<module>DS_News</module>
<frontName>dsnews_admin</frontName>
</args>
</dsnews_admin>
</routers>
</admin>
</config>
I have tried to do die in controller but it is not working. And other side the same code is working fine on demo site.
Controller code: DS/News/controllers/Adminhtml/NewsController.php
<?php
class DS_News_Adminhtml_NewsController extends Mage_Adminhtml_Controller_Action
{
public function indexAction()
{
die('testing DS news extension');
$id = (int) $this->getRequest()->getParam('id');
$model = Mage::getModel('dsnews/news');
if ($data = Mage::getSingleton('adminhtml/session')->getFormData()) {
$model->setData($data)->setId($id);
} else {
$model->load($id);
}
Mage::register('current_news', $model);
$this->loadLayout()->_setActiveMenu('dsnews');
$this->_addLeft($this->getLayout()->createBlock('dsnews/adminhtml_news_edit_tabs'));
$this->_addContent($this->getLayout()->createBlock('dsnews/adminhtml_news_edit'));
$this->renderLayout();
}
public function newAction()
{
$this->_forward('edit');
}
public function editAction()
{
$id = (int) $this->getRequest()->getParam('id');
$model = Mage::getModel('dsnews/news');
if ($data = Mage::getSingleton('adminhtml/session')->getFormData()) {
$model->setData($data)->setId($id);
} else {
$model->load($id);
}
Mage::register('current_news', $model);
$this->loadLayout()->_setActiveMenu('dsnews');
$this->_addLeft($this->getLayout()->createBlock('dsnews/adminhtml_news_edit_tabs'));
$this->_addContent($this->getLayout()->createBlock('dsnews/adminhtml_news_edit'));
$this->renderLayout();
}
public function saveAction()
{
if ($data = $this->getRequest()->getPost()) {
try {
$model = Mage::getModel('dsnews/news');
$model->setData($data)->setId($this->getRequest()->getParam('id'));
if (!$model->getCreated()) {
$model->setCreated(now());
}
$model->save();
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('News was saved successfully'));
Mage::getSingleton('adminhtml/session')->setFormData(false);
$this->_redirect('*/*/');
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')->setFormData($data);
$this->_redirect('*/*/edit', array(
'id' => $this->getRequest()->getParam('id')
));
}
return;
}
Mage::getSingleton('adminhtml/session')->addError($this->__('Unable to find item to save'));
$this->_redirect('*/*/');
}
public function deleteAction()
{
if ($id = $this->getRequest()->getParam('id')) {
try {
Mage::getModel('dsnews/news')->setId($id)->delete();
Mage::getSingleton('adminhtml/session')->addSuccess($this->__('News was deleted successfully'));
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
$this->_redirect('*/*/edit', array('id' => $id));
}
}
$this->_redirect('*/*/');
}
public function massDeleteAction()
{
$news = $this->getRequest()->getParam('news', null);
if (is_array($news) && sizeof($news) > 0) {
try {
foreach ($news as $id) {
Mage::getModel('dsnews/news')->setId($id)->delete();
}
$this->_getSession()->addSuccess($this->__('Total of %d news have been deleted', sizeof($news)));
} catch (Exception $e) {
$this->_getSession()->addError($e->getMessage());
}
} else {
$this->_getSession()->addError($this->__('Please select news'));
}
$this->_redirect('*/*');
}
protected function _initAction()
{
$this->loadLayout()->_setActiveMenu('wreport/daily')
->_addBreadcrumb('wreport Manager','wreport Manager');
return $this;
}
public function exportAction()
{
$date = $this->getRequest()->getPost();
if ($date['created'] && $date['created1']) {
$fromDate = date('Y-m-d H:i:s', strtotime($date['created']));
$toDate = date('Y-m-d H:i:s', strtotime($date['created1']));
$orders = Mage::getResourceModel('sales/order_grid_collection')
->addAttributeToFilter('created_at', array('from' => $fromDate, 'to' => $toDate));
$dataOrders = $orders->getData();
$arrayOrders = array();
foreach ($dataOrders as $order) {
/*var_dump($order)/*['customer_firstname'] . ' ' . $order['customer_lastname'].'<br>';
echo $order['created_at'].' '.$order['updated_at'].'<br>';
echo '---------------------<br>';*/
$ordermeth = Mage::getModel('sales/order')->load($order['entity_id']);
if (is_object($ordermeth->getShippingAddress())) {
$regionOrders = $ordermeth->getShippingAddress()->getRegion();
$curierName = $ordermeth->getShippingMethod();
}
$items = $ordermeth->getAllItems();
$taxName = array();
$qty = array();
foreach ($items as $item) {
$order = Mage::getModel('sales/order')->loadByIncrementId($order['increment_id']);
//var_dump($order);exit();
foreach ($order->getTracksCollection() as $_track){
$trackingNumber = $_track->getNumber();
$titleTracking = $_track->getTitle();
}
$qtyProductInOrder = number_format($order['qty_ordered'], 0, '.', '');
$qtyOrder = number_format($item->getQtyOrdered(), 0, '.', '');
// foreach(
for ($i=1;$i <= $qtyOrder;$i++) {
$arrayOrder = array();
$productId = $item->getProductId();
$_product = Mage::getModel('catalog/product')->load($productId);
$taxClassId = $_product->getTaxClassId();
$taxClass = Mage::getModel('tax/class')->load($taxClassId);
$taxClassName = $taxClass->getClassName();
preg_match_all('/\-(.+)\%/', $taxClassName, $hsnRate);
$hsnRate = $hsnRate[1][0];
$hsnRate = $hsnRate / 100;
$hsn = $_product->getAttributeText('hsn');
array_push($taxName, $taxClass);
if ($order->hasInvoices()) {
$invIncrementIDs = array();
foreach ($order->getInvoiceCollection() as $inv) {
$arrayOrder['invoice'] = $inv->getIncrementId();
}
}
/*echo '<pre>';*/
//var_dump($order);exit();
//$arrayOrder[]
$arrayOrder['hsn_rate'] = ' ';
$statusOrder = $order['status'];
$orderNo = $order['increment_id'];
$arrayOrder['shipping_amount'] = $order['shipping_amount'];
$arrayOrder['shipping_withouttax'] = number_format(($order['shipping_amount'] / 1.05), 2, '.', '');
$arrayOrder['shipping_rate'] = 0.05;
$arrayOrder['shipping_hsn'] = 996531;
$arrayOrder['status'] = $order['status'];
$arrayOrder['increment_id'] = $orderNo;
//$arrayOrder['created_at'] = substr($order['created_at'], 0, 10);
$arrayOrder['created_at'] = $order['created_at'];
$arrayOrder['customer'] = $order['customer_firstname'] . ' ' . $order['customer_lastname'];
$arrayOrder['tracking'] = $trackingNumber ? $trackingNumber : ' ';
$arrayOrder['titleTracking'] = $titleTracking ? $titleTracking : ' ';
$arrayOrder['state'] = $regionOrders ? $regionOrders : 'India';
$arrayOrder['tax_amount'] = $order['base_grand_total'];
$arrayOrder['hsn'] = $hsn ? $hsn : ' ';
$arrayOrder['hsn_rate'] = $hsnRate ? $hsnRate : ' ';
$arrayOrder['hsn_total'] = number_format((($item->getOriginalPrice() - $item->getDiscountAmount()) / (1 + $arrayOrder['hsn_rate'])), 2, '.', '');
$arrayOrder['price'] = $_product->getPrice();
$arrayOrder['special_price'] = $_product->getSpecialPrice();
$arrayOrder['percent'] = 100 - number_format(($_product->getSpecialPrice() /$_product->getPrice() * 100), 2, '.', '');
$arrayOrder['shipping_description'] = $order['shipping_description'];
$arrayOrder['item_count'] = $order['total_item_count'];
$arrayOrder['item_count1'] = number_format($order['total_qty_ordered'], 0, '.', '');
//$sumTax = $arrayOrder['hsn_total'] * $arrayOrder['hsn_rate'];
$sumTax = $item->getTaxAmount();
if ($arrayOrder['state'] == 'Maharashtra') {
switch ($arrayOrder['hsn_rate']) {
case 0.05:
$arrayOrder['CGST-2.5%'] = $sumTax / 2;
$arrayOrder['SGST-2.5%'] = $sumTax / 2;
break;
case 0.03:
$arrayOrder['CGST-1.5%'] = $sumTax / 2;
$arrayOrder['SGST-1.5%'] = $sumTax / 2;
break;
case 0.12:
$arrayOrder['CGST-6%'] = $sumTax / 2;
$arrayOrder['SGST-6%'] = $sumTax / 2;
break;
case 0.18:
$arrayOrder['CGST-9%'] = $sumTax / 2;
$arrayOrder['SGST-9%'] = $sumTax / 2;
break;
case 0.28:
$arrayOrder['CGST-14%'] = $sumTax / 2;
$arrayOrder['SGST-14%'] = $sumTax / 2;
break;
}
} else {
switch ($arrayOrder['hsn_rate']) {
case 0.03:
$arrayOrder['IGST-3%'] = $sumTax;
break;
case 0.05:
$arrayOrder['IGST-5%'] = $sumTax;
break;
case 0.12:
$arrayOrder['IGST-12%'] = $sumTax;
break;
case 0.18:
$arrayOrder['IGST-18%'] = $sumTax;
break;
case 0.28:
$arrayOrder['IGST-28%'] = $sumTax;
break;
}
}
$shippingSum = $arrayOrder['shipping_amount'] - $arrayOrder['shipping_withouttax'];
if ($arrayOrder['state'] == 'Maharashtra') {
switch ($arrayOrder['shipping_rate']) {
case 0.05:
$arrayOrder['SCGST-2.5%'] = $shippingSum / 2;
$arrayOrder['SSGST-2.5%'] = $shippingSum / 2;
break;
case 0.03:
$arrayOrder['SCGST-1.5%'] = $shippingSum / 2;
$arrayOrder['SSGST-1.5%'] = $shippingSum / 2;
break;
case 0.12:
$arrayOrder['SCGST-6%'] = $shippingSum / 2;
$arrayOrder['SSGST-6%'] = $shippingSum / 2;
break;
case 0.18:
$arrayOrder['SCGST-9%'] = $shippingSum / 2;
$arrayOrder['SSGST-9%'] = $shippingSum / 2;
break;
case 0.28:
$arrayOrder['SCGST-14%'] = $shippingSum / 2;
$arrayOrder['SSGST-14%'] = $shippingSum / 2;
break;
}
} else {
switch ($arrayOrder['shipping_rate']) {
case 0.03:
$arrayOrder['SIGST-3%'] = $shippingSum;
break;
case 0.05:
$arrayOrder['SIGST-5%'] = $shippingSum;
break;
case 0.12:
$arrayOrder['SIGST-12%'] = $shippingSum;
break;
case 0.18:
$arrayOrder['SIGST-18%'] = $shippingSum;
break;
case 0.28:
$arrayOrder['SIGST-28%'] = $shippingSum;
break;
}
}
if ($statusOrder == 'canceled') {
$arrayOrder['hsn'] = 0;
$arrayOrder['hsn_rate'] = 0;
$arrayOrder['hsn_total'] = 0;
$arrayOrder['CGST-0%'] = 0;
$arrayOrder['SGST-0%'] = 0;
$arrayOrder['CGST-1.5%'] = 0;
$arrayOrder['SGST-1.5%'] = 0;
$arrayOrder['CGST-2.5%'] = 0;
$arrayOrder['SGST-2.5%'] = 0;
$arrayOrder['CGST-6%'] = 0;
$arrayOrder['SGST-6%'] = 0;
$arrayOrder['CGST-9%'] = 0;
$arrayOrder['SGST-9%'] = 0;
$arrayOrder['CGST-14%'] = 0;
$arrayOrder['SGST-14%'] = 0;
$arrayOrder['IGST-3%'] = 0;
$arrayOrder['IGST-5%'] = 0;
$arrayOrder['IGST-12%'] = 0;
$arrayOrder['IGST-18%'] = 0;
$arrayOrder['IGST-28%'] = 0;
}
if($arrayOrder['hsn'] == 4014){
$arrayOrder['hsn_rate'] = 0;
}
array_push($arrayOrders, $arrayOrder);
} // for End
}
}
//exit();
$csv = '';
$headerTax = array('Date', 'Order No','Invoice', 'Order Status', 'Customer Name', 'Tracking No', 'Curier Name', 'State','Order Amount Total', 'HSN', 'HSN GST Rate %', 'HSN Total in Invoice', 'CGST@0%', 'SGST@0%', '[email protected]%', '[email protected]%', '[email protected]%', '[email protected]%', 'CGST@6%', 'SGST@6%', 'CGST@9%', 'SGST@9%', 'CGST@14%', 'SGST@14%', 'IGST@3%', 'IGST@5%', 'IGST@12%', 'IGST@18%', 'IGST@28%');
$csv .= implode(",", $headerTax) . "\n";
$i = 0;
foreach ($arrayOrders as $arrayTaxes) {
$arrayTaxes['CGST-0%'] = $arrayTaxes['CGST-0%'] ? $arrayTaxes['CGST-0%'] : ' ';
$arrayTaxes['SGST-0%'] = $arrayTaxes['SGST-0%'] ? $arrayTaxes['SGST-0%'] : ' ';
$arrayTaxes['CGST-1.5%'] = $arrayTaxes['CGST-1.5%'] ? $arrayTaxes['CGST-1.5%'] : ' ';
$arrayTaxes['SGST-1.5%'] = $arrayTaxes['SGST-1.5%'] ? $arrayTaxes['SGST-1.5%'] : ' ';
$arrayTaxes['CGST-2.5%'] = $arrayTaxes['CGST-2.5%'] ? $arrayTaxes['CGST-2.5%'] : ' ';
$arrayTaxes['SGST-2.5%'] = $arrayTaxes['SGST-2.5%'] ? $arrayTaxes['SGST-2.5%'] : ' ';
$arrayTaxes['CGST-6%'] = $arrayTaxes['CGST-6%'] ? $arrayTaxes['CGST-6%'] : ' ';
$arrayTaxes['SGST-6%'] = $arrayTaxes['SGST-6%'] ? $arrayTaxes['SGST-6%'] : ' ';
$arrayTaxes['CGST-9%'] = $arrayTaxes['CGST-9%'] ? $arrayTaxes['CGST-9%'] : ' ';
$arrayTaxes['SGST-9%'] = $arrayTaxes['SGST-9%'] ? $arrayTaxes['SGST-9%'] : ' ';
$arrayTaxes['CGST-14%'] = $arrayTaxes['CGST-14%'] ? $arrayTaxes['CGST-14%'] : ' ';
$arrayTaxes['SGST-14%'] = $arrayTaxes['SGST-14%'] ? $arrayTaxes['SGST-14%'] : ' ';
$arrayTaxes['IGST-3%'] = $arrayTaxes['IGST-3%'] ? $arrayTaxes['IGST-3%'] : ' ';
$arrayTaxes['IGST-5%'] = $arrayTaxes['IGST-5%'] ? $arrayTaxes['IGST-5%'] : ' ';
$arrayTaxes['IGST-12%'] = $arrayTaxes['IGST-12%'] ? $arrayTaxes['IGST-12%'] : ' ';
$arrayTaxes['IGST-18%'] = $arrayTaxes['IGST-18%'] ? $arrayTaxes['IGST-18%'] : ' ';
$arrayTaxes['IGST-28%'] = $arrayTaxes['IGST-28%'] ? $arrayTaxes['IGST-28%'] : ' ';
if(strpos($arrayTaxes['customer'],',')){
$arrayTaxes['customer'] = str_replace(',',' ',$arrayTaxes['customer']);
}
$arrayTaxes['SCGST-0%'] = $arrayTaxes['SCGST-0%'] ? $arrayTaxes['SCGST-0%'] : ' ';
$arrayTaxes['SSGST-0%'] = $arrayTaxes['SSGST-0%'] ? $arrayTaxes['SSGST-0%'] : ' ';
$arrayTaxes['SCGST-1.5%'] = $arrayTaxes['SCGST-1.5%'] ? $arrayTaxes['SCGST-1.5%'] : ' ';
$arrayTaxes['SSGST-1.5%'] = $arrayTaxes['SSGST-1.5%'] ? $arrayTaxes['SSGST-1.5%'] : ' ';
$arrayTaxes['SCGST-2.5%'] = $arrayTaxes['SCGST-2.5%'] ? $arrayTaxes['SCGST-2.5%'] : ' ';
$arrayTaxes['SSGST-2.5%'] = $arrayTaxes['SSGST-2.5%'] ? $arrayTaxes['SSGST-2.5%'] : ' ';
$arrayTaxes['SCGST-6%'] = $arrayTaxes['SCGST-6%'] ? $arrayTaxes['SCGST-6%'] : ' ';
$arrayTaxes['SSGST-6%'] = $arrayTaxes['SSGST-6%'] ? $arrayTaxes['SSGST-6%'] : ' ';
$arrayTaxes['SCGST-9%'] = $arrayTaxes['SCGST-9%'] ? $arrayTaxes['SCGST-9%'] : ' ';
$arrayTaxes['SSGST-9%'] = $arrayTaxes['SSGST-9%'] ? $arrayTaxes['SSGST-9%'] : ' ';
$arrayTaxes['SCGST-14%'] = $arrayTaxes['SCGST-14%'] ? $arrayTaxes['SCGST-14%'] : ' ';
$arrayTaxes['SSGST-14%'] = $arrayTaxes['SSGST-14%'] ? $arrayTaxes['SSGST-14%'] : ' ';
$arrayTaxes['SIGST-3%'] = $arrayTaxes['SIGST-3%'] ? $arrayTaxes['SIGST-3%'] : ' ';
$arrayTaxes['SIGST-5%'] = $arrayTaxes['SIGST-5%'] ? $arrayTaxes['SIGST-5%'] : ' ';
$arrayTaxes['SIGST-12%'] = $arrayTaxes['SIGST-12%'] ? $arrayTaxes['SIGST-12%'] : ' ';
$arrayTaxes['SIGST-18%'] = $arrayTaxes['SIGST-18%'] ? $arrayTaxes['SIGST-18%'] : ' ';
$arrayTaxes['SIGST-28%'] = $arrayTaxes['SIGST-28%'] ? $arrayTaxes['SIGST-28%'] : ' ';
if ($arrayTaxes['shipping_amount'] == 69.0000) {
$list = array($arrayTaxes['created_at'], $arrayTaxes['increment_id'],$arrayTaxes['invoice'], $arrayTaxes['status'], $arrayTaxes['customer'], $arrayTaxes['tracking'] , $arrayTaxes['titleTracking'], $arrayTaxes['state'], $arrayTaxes['tax_amount'], $arrayTaxes['hsn'], $arrayTaxes['hsn_rate'], $arrayTaxes['hsn_total'], $arrayTaxes['CGST-0%'], $arrayTaxes['SGST-0%'], $arrayTaxes['CGST-1.5%'], $arrayTaxes['SGST-1.5%'], $arrayTaxes['CGST-2.5%'], $arrayTaxes['SGST-2.5%'],
$arrayTaxes['CGST-6%'], $arrayTaxes['SGST-6%'], $arrayTaxes['CGST-9%'], $arrayTaxes['SGST-9%'],
$arrayTaxes['CGST-14%'], $arrayTaxes['SGST-14%'], $arrayTaxes['IGST-3%'], $arrayTaxes['IGST-5%'], $arrayTaxes['IGST-12%'], $arrayTaxes['IGST-18%'], $arrayTaxes['IGST-28%']);
$csv .= implode(",", $list) . "\n";
++$i;
if ($arrayTaxes['item_count1'] == $i) {
$shipping = array($arrayTaxes['created_at'], $arrayTaxes['increment_id'],$arrayTaxes['invoice'], $arrayTaxes['status'], $arrayTaxes['customer'], $arrayTaxes['tracking'] , $arrayTaxes['titleTracking'], $arrayTaxes['state'], $arrayTaxes['tax_amount'], $arrayTaxes['shipping_hsn'], $arrayTaxes['shipping_rate'], $arrayTaxes['shipping_amount'], $arrayTaxes['SCGST-0%'], $arrayTaxes['SSGST-0%'], $arrayTaxes['SCGST-1.5%'], $arrayTaxes['SSGST-1.5%'], $arrayTaxes['SCGST-2.5%'], $arrayTaxes['SSGST-2.5%'],
$arrayTaxes['SCGST-6%'], $arrayTaxes['SSGST-6%'], $arrayTaxes['SCGST-9%'], $arrayTaxes['SSGST-9%'],
$arrayTaxes['SCGST-14%'], $arrayTaxes['SSGST-14%'], $arrayTaxes['SIGST-3%'], $arrayTaxes['SIGST-5%'], $arrayTaxes['SIGST-12%'], $arrayTaxes['SIGST-18%'], $arrayTaxes['SIGST-28%']);
$csv .= implode(",", $shipping) . "\n";
$i = 0;
}
} else {
$list = array($arrayTaxes['created_at'], $arrayTaxes['increment_id'],$arrayTaxes['invoice'], $arrayTaxes['status'], $arrayTaxes['customer'], $arrayTaxes['tracking'], $arrayTaxes['titleTracking'] , $arrayTaxes['state'], $arrayTaxes['tax_amount'], $arrayTaxes['hsn'], $arrayTaxes['hsn_rate'], $arrayTaxes['hsn_total'], $arrayTaxes['CGST-0%'], $arrayTaxes['SGST-0%'], $arrayTaxes['CGST-1.5%'], $arrayTaxes['SGST-1.5%'], $arrayTaxes['CGST-2.5%'], $arrayTaxes['SGST-2.5%'],
$arrayTaxes['CGST-6%'], $arrayTaxes['SGST-6%'], $arrayTaxes['CGST-9%'], $arrayTaxes['SGST-9%'],
$arrayTaxes['CGST-14%'], $arrayTaxes['SGST-14%'], $arrayTaxes['IGST-3%'], $arrayTaxes['IGST-5%'], $arrayTaxes['IGST-12%'], $arrayTaxes['IGST-18%'], $arrayTaxes['IGST-28%']);
$csv .= implode(",", $list) . "\n";
}
}
$fileName = 'SellerReport.csv';
$this->_prepareDownloadResponse($fileName, $csv);
//Mage::getSingleton('adminhtml/session')->addError($this->__('Unable to find item to save'));
//$this->_redirect('*/*/');
}
}
}
Can anyone suggest what's going wrong?