Version Notes
- Option is added to filter data by shipping date & order date
- Option is added for admin to assign 'custom sales report' from role resources
- A bug is fixed
Download this release
Release Info
Developer | CyberNetikz |
Extension | Cybernetikz_Salesreport |
Version | 0.1.3 |
Comparing to | |
See all releases |
Code changes from version 0.1.2 to 0.1.3
- app/code/local/Cybernetikz/Salesreport/controllers/Adminhtml/SalesController.php +66 -62
- app/code/local/Cybernetikz/Salesreport/etc/adminhtml.xml +13 -7
- app/code/local/Cybernetikz/Salesreport/etc/config.xml +2 -2
- app/design/adminhtml/default/default/template/salesreport/reportmanage.phtml +96 -82
- package.xml +7 -5
app/code/local/Cybernetikz/Salesreport/controllers/Adminhtml/SalesController.php
CHANGED
@@ -23,44 +23,53 @@ public function indexAction()
|
|
23 |
if ($data = $this->getRequest()->getPost()) {
|
24 |
|
25 |
$orserstatus = "";
|
26 |
-
|
27 |
-
/*====================== Start Code for magento Orders product =====================*/
|
28 |
-
//echo "<pre>";
|
29 |
$reportaddress = Mage::helper('salesreport')->getReportAddress();
|
30 |
$addtess_title = ($reportaddress=="billing")?"Billing":"Shipping";
|
31 |
$orders_csv_row ="Period,Order Id,Item Name,Qty,Unit Price,Row Total,$addtess_title Name,Email,Street Address,City,State,Postcode,Country";
|
32 |
$orders_csv_row.="\n";
|
33 |
|
34 |
-
$
|
35 |
-
|
36 |
-
|
37 |
-
$
|
|
|
38 |
$from_date = date('Y-m-d' . ' 00:00:00', strtotime($from));
|
|
|
39 |
|
|
|
|
|
|
|
40 |
|
41 |
if($_REQUEST['show_order_statuses']>0){
|
42 |
$orserstatus = $_REQUEST['order_statuses'];
|
43 |
-
$
|
44 |
-
->addAttributeToSelect('*')
|
45 |
-
->addFieldToFilter('created_at', array('from'=>$from_date, 'to'=>$to_date))
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
48 |
}else{
|
49 |
-
$
|
50 |
->addAttributeToSelect('*')
|
51 |
->addFieldToFilter('created_at', array('from'=>$from_date, 'to'=>$to_date))
|
|
|
52 |
->load();
|
53 |
}
|
54 |
-
|
55 |
$i=0;
|
56 |
-
foreach($
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
62 |
|
63 |
-
//Some
|
64 |
if($reportaddress=="billing"){
|
65 |
|
66 |
$country_id = utf8_decode($myOrder->getBillingAddress()->getCountryId());
|
@@ -69,13 +78,18 @@ public function indexAction()
|
|
69 |
$name = utf8_decode($myOrder->getBillingAddress()->getFirstname()." ".$myOrder->getBillingAddress()->getLastname());
|
70 |
|
71 |
$billingaddress = $myOrder->getBillingAddress()->getStreet();
|
72 |
-
$address =
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
-
$city=utf8_decode($myOrder->getBillingAddress()->getCity());
|
75 |
|
76 |
-
$region=utf8_decode($myOrder->getBillingAddress()->getRegion());
|
77 |
|
78 |
-
$postcode =utf8_decode($myOrder->getBillingAddress()->getPostcode());
|
79 |
|
80 |
}else{
|
81 |
|
@@ -84,18 +98,23 @@ public function indexAction()
|
|
84 |
|
85 |
$name = utf8_decode($myOrder->getShippingAddress()->getFirstname()." ".$myOrder->getShippingAddress()->getLastname());
|
86 |
|
87 |
-
$
|
88 |
-
$address =
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
-
$city=utf8_decode($myOrder->getShippingAddress()->getCity());
|
91 |
|
92 |
-
$region=utf8_decode($myOrder->getShippingAddress()->getRegion());
|
93 |
|
94 |
-
$postcode =utf8_decode($myOrder->getShippingAddress()->getPostcode());
|
95 |
}
|
96 |
|
97 |
$myOrder->loadByIncrementId($myOrder->getIncrementId());
|
98 |
-
|
99 |
$store = Mage::app()->getStore();
|
100 |
$items = $myOrder->getItemsCollection();
|
101 |
$ic=1;
|
@@ -111,7 +130,7 @@ public function indexAction()
|
|
111 |
endif;
|
112 |
|
113 |
if($item->getParentItemId() && round($item->getOriginalPrice())==0){
|
114 |
-
$parentitem = $
|
115 |
|
116 |
$originalprice = $parentitem->getOriginalPrice();
|
117 |
|
@@ -121,36 +140,26 @@ public function indexAction()
|
|
121 |
if(round($parentitem->getDiscountAmount())!=0){
|
122 |
$discountamount=$parentitem->getDiscountAmount();
|
123 |
$subtotal=($subtotal-$discountamount);
|
124 |
-
}
|
125 |
-
|
126 |
-
$subtotal = number_format($subtotal,2);
|
127 |
-
|
128 |
$eachitemdiscountamount = ($discountamount/$itemorderqty);
|
129 |
-
$discountamount = number_format($eachitemdiscountamount,2);
|
130 |
-
|
131 |
-
$taxpercent = $parentitem->getTaxPercent();
|
132 |
-
|
133 |
$eachitemvat = $vatamount_eachproduct/$itemorderqty;
|
134 |
$totalvatdisamount = $eachitemvat+$eachitemdiscountamount;
|
135 |
$net_price = round($originalprice-($totalvatdisamount),2);
|
136 |
}else{
|
137 |
-
$originalprice = $item->getOriginalPrice();
|
138 |
-
|
139 |
-
$subtotal = ($item->getOriginalPrice()*$itemorderqty);
|
140 |
-
|
141 |
$discountamount=0;
|
142 |
if(round($item->getDiscountAmount())!=0){
|
143 |
$discountamount=$item->getDiscountAmount();
|
144 |
$subtotal=($subtotal-$discountamount);
|
145 |
-
}
|
146 |
-
|
147 |
-
$subtotal = number_format($subtotal,2);
|
148 |
-
|
149 |
$eachitemdiscountamount = ($discountamount/$itemorderqty);
|
150 |
-
$discountamount = number_format($eachitemdiscountamount,2);
|
151 |
-
|
152 |
-
$taxpercent = $item->getTaxPercent();
|
153 |
-
|
154 |
$eachitemvat = $vatamount_eachproduct/$itemorderqty;
|
155 |
$totalvatdisamount = $eachitemvat+$eachitemdiscountamount;
|
156 |
$net_price = round($originalprice-($totalvatdisamount),2);
|
@@ -166,11 +175,8 @@ public function indexAction()
|
|
166 |
$customer_email=$myOrder->getCustomerEmail();
|
167 |
}
|
168 |
|
169 |
-
//echo $myOrder->getCreatedAt();
|
170 |
-
//exit;
|
171 |
$datarow = array(date("d/m/Y",strtotime($myOrder->getCreatedAt())), $myOrder->getIncrementId(), utf8_decode($item->getName()), $itemorderqty, utf8_decode($net_price),$subtotal,$name,$customer_email,$address,$city,$region,$postcode,$country);
|
172 |
-
|
173 |
-
//print_r($csvtitles);
|
174 |
$line = "";
|
175 |
$comma = "";
|
176 |
foreach($datarow as $titlename) {
|
@@ -184,12 +190,10 @@ public function indexAction()
|
|
184 |
|
185 |
}
|
186 |
}
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
$this->_sendUploadResponse($fileName, $orders_csv_row);
|
192 |
-
|
193 |
}
|
194 |
}
|
195 |
|
23 |
if ($data = $this->getRequest()->getPost()) {
|
24 |
|
25 |
$orserstatus = "";
|
|
|
|
|
|
|
26 |
$reportaddress = Mage::helper('salesreport')->getReportAddress();
|
27 |
$addtess_title = ($reportaddress=="billing")?"Billing":"Shipping";
|
28 |
$orders_csv_row ="Period,Order Id,Item Name,Qty,Unit Price,Row Total,$addtess_title Name,Email,Street Address,City,State,Postcode,Country";
|
29 |
$orders_csv_row.="\n";
|
30 |
|
31 |
+
$filter_type = $_REQUEST['filter_type'];
|
32 |
+
|
33 |
+
$from = $_REQUEST['from'];
|
34 |
+
$to = $_REQUEST['to'];
|
35 |
+
|
36 |
$from_date = date('Y-m-d' . ' 00:00:00', strtotime($from));
|
37 |
+
$to_date = date('Y-m-d' . ' 23:59:59', strtotime($to));
|
38 |
|
39 |
+
$filter_model = ($filter_type == 'shipping_date')
|
40 |
+
? 'sales/order_shipment_collection'
|
41 |
+
: 'sales/order_collection';
|
42 |
|
43 |
if($_REQUEST['show_order_statuses']>0){
|
44 |
$orserstatus = $_REQUEST['order_statuses'];
|
45 |
+
$_orderCollections = Mage::getResourceModel($filter_model);
|
46 |
+
$_orderCollections->addAttributeToSelect('*');
|
47 |
+
$_orderCollections->addFieldToFilter('created_at', array('from'=>$from_date, 'to'=>$to_date));
|
48 |
+
if($filter_type == 'order_date'){
|
49 |
+
$_orderCollections->addFieldToFilter('status', $orserstatus);
|
50 |
+
}
|
51 |
+
$_orderCollections->setOrder('created_at', 'desc');
|
52 |
+
$_orderCollections->load();
|
53 |
}else{
|
54 |
+
$_orderCollections = Mage::getResourceModel($filter_model)
|
55 |
->addAttributeToSelect('*')
|
56 |
->addFieldToFilter('created_at', array('from'=>$from_date, 'to'=>$to_date))
|
57 |
+
->setOrder('created_at', 'desc')
|
58 |
->load();
|
59 |
}
|
60 |
+
|
61 |
$i=0;
|
62 |
+
foreach($_orderCollections as $key=>$single_order) {
|
63 |
+
if(($filter_type == 'shipping_date')){
|
64 |
+
$_orderId = $single_order->getOrderId();
|
65 |
+
}else{
|
66 |
+
$_orderId = $single_order->getId();
|
67 |
+
}
|
68 |
+
|
69 |
+
$myOrder = Mage::getModel('sales/order');
|
70 |
+
$myOrder->load($_orderId);
|
71 |
|
72 |
+
//Some Random Fields
|
73 |
if($reportaddress=="billing"){
|
74 |
|
75 |
$country_id = utf8_decode($myOrder->getBillingAddress()->getCountryId());
|
78 |
$name = utf8_decode($myOrder->getBillingAddress()->getFirstname()." ".$myOrder->getBillingAddress()->getLastname());
|
79 |
|
80 |
$billingaddress = $myOrder->getBillingAddress()->getStreet();
|
81 |
+
$address = "";
|
82 |
+
$address[] = utf8_decode($billingaddress[0]);
|
83 |
+
if($billingaddress[1]){
|
84 |
+
$address[] = utf8_decode($billingaddress[1]);
|
85 |
+
}
|
86 |
+
$address = implode(", ",$address);
|
87 |
|
88 |
+
$city = utf8_decode($myOrder->getBillingAddress()->getCity());
|
89 |
|
90 |
+
$region = utf8_decode($myOrder->getBillingAddress()->getRegion());
|
91 |
|
92 |
+
$postcode = utf8_decode($myOrder->getBillingAddress()->getPostcode());
|
93 |
|
94 |
}else{
|
95 |
|
98 |
|
99 |
$name = utf8_decode($myOrder->getShippingAddress()->getFirstname()." ".$myOrder->getShippingAddress()->getLastname());
|
100 |
|
101 |
+
$shippingaddress = $myOrder->getShippingAddress()->getStreet();
|
102 |
+
$address = "";
|
103 |
+
$address[] = utf8_decode($shippingaddress[0]);
|
104 |
+
if($shippingaddress[1]){
|
105 |
+
$address[] = utf8_decode($shippingaddress[1]);
|
106 |
+
}
|
107 |
+
$address = implode(", ",$address);
|
108 |
|
109 |
+
$city = utf8_decode($myOrder->getShippingAddress()->getCity());
|
110 |
|
111 |
+
$region = utf8_decode($myOrder->getShippingAddress()->getRegion());
|
112 |
|
113 |
+
$postcode = utf8_decode($myOrder->getShippingAddress()->getPostcode());
|
114 |
}
|
115 |
|
116 |
$myOrder->loadByIncrementId($myOrder->getIncrementId());
|
117 |
+
|
118 |
$store = Mage::app()->getStore();
|
119 |
$items = $myOrder->getItemsCollection();
|
120 |
$ic=1;
|
130 |
endif;
|
131 |
|
132 |
if($item->getParentItemId() && round($item->getOriginalPrice())==0){
|
133 |
+
$parentitem = $myOrder->getItemById($item->getParentItemId());
|
134 |
|
135 |
$originalprice = $parentitem->getOriginalPrice();
|
136 |
|
140 |
if(round($parentitem->getDiscountAmount())!=0){
|
141 |
$discountamount=$parentitem->getDiscountAmount();
|
142 |
$subtotal=($subtotal-$discountamount);
|
143 |
+
}
|
144 |
+
$subtotal = number_format($subtotal,2);
|
|
|
|
|
145 |
$eachitemdiscountamount = ($discountamount/$itemorderqty);
|
146 |
+
$discountamount = number_format($eachitemdiscountamount,2);
|
147 |
+
$taxpercent = $parentitem->getTaxPercent();
|
|
|
|
|
148 |
$eachitemvat = $vatamount_eachproduct/$itemorderqty;
|
149 |
$totalvatdisamount = $eachitemvat+$eachitemdiscountamount;
|
150 |
$net_price = round($originalprice-($totalvatdisamount),2);
|
151 |
}else{
|
152 |
+
$originalprice = $item->getOriginalPrice();
|
153 |
+
$subtotal = ($item->getOriginalPrice()*$itemorderqty);
|
|
|
|
|
154 |
$discountamount=0;
|
155 |
if(round($item->getDiscountAmount())!=0){
|
156 |
$discountamount=$item->getDiscountAmount();
|
157 |
$subtotal=($subtotal-$discountamount);
|
158 |
+
}
|
159 |
+
$subtotal = number_format($subtotal,2);
|
|
|
|
|
160 |
$eachitemdiscountamount = ($discountamount/$itemorderqty);
|
161 |
+
$discountamount = number_format($eachitemdiscountamount,2);
|
162 |
+
$taxpercent = $item->getTaxPercent();
|
|
|
|
|
163 |
$eachitemvat = $vatamount_eachproduct/$itemorderqty;
|
164 |
$totalvatdisamount = $eachitemvat+$eachitemdiscountamount;
|
165 |
$net_price = round($originalprice-($totalvatdisamount),2);
|
175 |
$customer_email=$myOrder->getCustomerEmail();
|
176 |
}
|
177 |
|
|
|
|
|
178 |
$datarow = array(date("d/m/Y",strtotime($myOrder->getCreatedAt())), $myOrder->getIncrementId(), utf8_decode($item->getName()), $itemorderqty, utf8_decode($net_price),$subtotal,$name,$customer_email,$address,$city,$region,$postcode,$country);
|
179 |
+
|
|
|
180 |
$line = "";
|
181 |
$comma = "";
|
182 |
foreach($datarow as $titlename) {
|
190 |
|
191 |
}
|
192 |
}
|
193 |
+
|
194 |
+
$reportname = Mage::helper('salesreport')->getReportName();
|
195 |
+
$fileName = $reportname.'.csv';
|
196 |
+
$this->_sendUploadResponse($fileName, $orders_csv_row);
|
|
|
|
|
197 |
}
|
198 |
}
|
199 |
|
app/code/local/Cybernetikz/Salesreport/etc/adminhtml.xml
CHANGED
@@ -21,19 +21,25 @@
|
|
21 |
|
22 |
<acl>
|
23 |
<resources>
|
|
|
|
|
|
|
24 |
<admin>
|
25 |
<children>
|
26 |
-
<
|
27 |
-
<
|
28 |
-
<title
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
31 |
<system>
|
32 |
<children>
|
33 |
<config>
|
34 |
<children>
|
35 |
-
<salesreports translate="
|
36 |
-
<
|
37 |
<sort_order>500</sort_order>
|
38 |
</salesreports>
|
39 |
</children>
|
21 |
|
22 |
<acl>
|
23 |
<resources>
|
24 |
+
<all>
|
25 |
+
<title>Allow everything</title>
|
26 |
+
</all>
|
27 |
<admin>
|
28 |
<children>
|
29 |
+
<report>
|
30 |
+
<children>
|
31 |
+
<salesreport translate="title" module="salesreport">
|
32 |
+
<title>Custom Sales Reports</title>
|
33 |
+
<sort_order>60</sort_order>
|
34 |
+
</salesreport>
|
35 |
+
</children>
|
36 |
+
</report>
|
37 |
<system>
|
38 |
<children>
|
39 |
<config>
|
40 |
<children>
|
41 |
+
<salesreports translate="title" module="salesreport">
|
42 |
+
<title>Custom Sales Report Section</title>
|
43 |
<sort_order>500</sort_order>
|
44 |
</salesreports>
|
45 |
</children>
|
app/code/local/Cybernetikz/Salesreport/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Cybernetikz_Salesreport>
|
5 |
-
<version>0.1.
|
6 |
</Cybernetikz_Salesreport>
|
7 |
</modules>
|
8 |
|
@@ -44,7 +44,7 @@
|
|
44 |
<default>
|
45 |
<salesreports>
|
46 |
<reportsetting>
|
47 |
-
<report_name>
|
48 |
<report_address>shipping</report_address>
|
49 |
</reportsetting>
|
50 |
</salesreports>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Cybernetikz_Salesreport>
|
5 |
+
<version>0.1.3</version>
|
6 |
</Cybernetikz_Salesreport>
|
7 |
</modules>
|
8 |
|
44 |
<default>
|
45 |
<salesreports>
|
46 |
<reportsetting>
|
47 |
+
<report_name>CustomSalesReport</report_name>
|
48 |
<report_address>shipping</report_address>
|
49 |
</reportsetting>
|
50 |
</salesreports>
|
app/design/adminhtml/default/default/template/salesreport/reportmanage.phtml
CHANGED
@@ -7,46 +7,52 @@
|
|
7 |
$result_order = 0;
|
8 |
|
9 |
if(!empty($_REQUEST['from']) && !empty($_REQUEST['to'])){
|
10 |
-
/*====================== Start Code for Magento Orders Product =====================*/
|
11 |
-
//echo "<pre>";
|
12 |
-
$orders_row = array();
|
13 |
|
14 |
-
$
|
15 |
-
$
|
16 |
-
|
17 |
-
$
|
18 |
$from_date = date('Y-m-d' . ' 00:00:00', strtotime($from));
|
|
|
19 |
|
20 |
|
|
|
|
|
|
|
|
|
21 |
if($_REQUEST['show_order_statuses']>0){
|
22 |
$orserstatus = $_REQUEST['order_statuses'];
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
|
|
30 |
}else{
|
31 |
-
$
|
32 |
->addAttributeToSelect('*')
|
33 |
->addFieldToFilter('created_at', array('from'=>$from_date, 'to'=>$to_date))
|
|
|
34 |
->load();
|
35 |
}
|
36 |
|
37 |
-
$show_order_statuses
|
|
|
38 |
|
39 |
-
$result_order = $orders->count();
|
40 |
-
|
41 |
$i=0;
|
42 |
-
foreach($
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
48 |
|
49 |
-
//Some
|
50 |
$reportaddress = Mage::helper('salesreport')->getReportAddress();
|
51 |
if($reportaddress=="billing"){
|
52 |
|
@@ -56,13 +62,18 @@
|
|
56 |
$name = utf8_decode($myOrder->getBillingAddress()->getFirstname()." ".$myOrder->getBillingAddress()->getLastname());
|
57 |
|
58 |
$billingaddress = $myOrder->getBillingAddress()->getStreet();
|
59 |
-
$address =
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
-
$city=utf8_decode($myOrder->getBillingAddress()->getCity());
|
62 |
|
63 |
-
$region=utf8_decode($myOrder->getBillingAddress()->getRegion());
|
64 |
|
65 |
-
$postcode =utf8_decode($myOrder->getBillingAddress()->getPostcode());
|
66 |
|
67 |
}else{
|
68 |
|
@@ -71,24 +82,23 @@
|
|
71 |
|
72 |
$name = utf8_decode($myOrder->getShippingAddress()->getFirstname()." ".$myOrder->getShippingAddress()->getLastname());
|
73 |
|
74 |
-
$
|
75 |
-
$address =
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
-
$city=utf8_decode($myOrder->getShippingAddress()->getCity());
|
78 |
|
79 |
-
$region=utf8_decode($myOrder->getShippingAddress()->getRegion());
|
80 |
|
81 |
-
$postcode =utf8_decode($myOrder->getShippingAddress()->getPostcode());
|
82 |
}
|
83 |
|
84 |
$myOrder->loadByIncrementId($myOrder->getIncrementId());
|
85 |
-
|
86 |
-
//$store = Mage::app()->getStore();
|
87 |
-
//$orders=Mage::getModel('sales/mysql4_order_collection');
|
88 |
-
//$allIds=$orders->getAllIds();
|
89 |
-
//$order = Mage::getModel('sales/order')->load($thisId);
|
90 |
-
|
91 |
-
|
92 |
$items = $myOrder->getItemsCollection();
|
93 |
$ic=1;
|
94 |
$countitems=0;
|
@@ -101,18 +111,10 @@
|
|
101 |
else:
|
102 |
$itemorderqty = round($item->getQtyOrdered());
|
103 |
endif;
|
104 |
-
|
105 |
-
//Order Current Item
|
106 |
-
//$_helper = Mage::helper('catalog/output');
|
107 |
-
//$_product = Mage::getModel('catalog/product')->load($item->getProductId());
|
108 |
|
109 |
if($item->getParentItemId() && round($item->getOriginalPrice())==0){
|
110 |
-
$parentitem = $
|
111 |
-
//print_r($item->getData());
|
112 |
-
//print_r($parentitem->getData());
|
113 |
-
//exit;
|
114 |
$originalprice = $parentitem->getOriginalPrice();
|
115 |
-
|
116 |
$subtotal = ($parentitem->getOriginalPrice()*$itemorderqty);
|
117 |
|
118 |
$discountamount=0;
|
@@ -122,45 +124,31 @@
|
|
122 |
}
|
123 |
|
124 |
$subtotal = number_format($subtotal,2);
|
125 |
-
|
126 |
$eachitemdiscountamount = ($discountamount/$itemorderqty);
|
127 |
$discountamount = number_format($eachitemdiscountamount,2);
|
128 |
-
|
129 |
$taxpercent = $parentitem->getTaxPercent();
|
130 |
-
|
131 |
$eachitemvat = $vatamount_eachproduct/$itemorderqty;
|
132 |
$totalvatdisamount = $eachitemvat+$eachitemdiscountamount;
|
133 |
$net_price = round($originalprice-($totalvatdisamount),2);
|
134 |
|
135 |
}else{
|
136 |
-
$originalprice = $item->getOriginalPrice();
|
137 |
-
|
138 |
-
$subtotal = ($item->getOriginalPrice()*$itemorderqty);
|
139 |
-
|
140 |
$discountamount=0;
|
141 |
if(round($item->getDiscountAmount())!=0){
|
142 |
$discountamount=$item->getDiscountAmount();
|
143 |
$subtotal=($subtotal-$discountamount);
|
144 |
-
}
|
145 |
-
|
146 |
-
$subtotal = number_format($subtotal,2);
|
147 |
-
|
148 |
$eachitemdiscountamount = ($discountamount/$itemorderqty);
|
149 |
-
$discountamount = number_format($eachitemdiscountamount,2);
|
150 |
-
|
151 |
-
$taxpercent = $item->getTaxPercent();
|
152 |
-
|
153 |
$eachitemvat = $vatamount_eachproduct/$itemorderqty;
|
154 |
$totalvatdisamount = $eachitemvat+$eachitemdiscountamount;
|
155 |
$net_price = round($originalprice-($totalvatdisamount),2);
|
156 |
|
157 |
}
|
158 |
-
|
159 |
-
/*echo $originalprice."<br />";
|
160 |
-
echo $discountamount."<br />";
|
161 |
-
echo $subtotal;
|
162 |
-
exit;*/
|
163 |
-
|
164 |
$customer_email = "";
|
165 |
if($custoer_id = $myOrder->getCustomerId()){
|
166 |
$customer = Mage::getModel('customer/customer')->load($custoer_id);
|
@@ -171,7 +159,7 @@
|
|
171 |
$customer_email=$myOrder->getCustomerEmail();
|
172 |
}
|
173 |
|
174 |
-
$orders_row[] = array(date("d/
|
175 |
|
176 |
}
|
177 |
}
|
@@ -203,6 +191,14 @@
|
|
203 |
<div class="hor-scroll">
|
204 |
<table cellspacing="0" class="form-list">
|
205 |
<tbody>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
<tr>
|
207 |
<td class="label"><label for="sales_report_from">From <span class="required">*</span></label></td>
|
208 |
<td class="value"><input type="text" style="width:110px !important;" class=" required-entry input-text" title="From" value="<?php echo $from; ?>" id="sales_report_from" name="from" />
|
@@ -237,7 +233,7 @@
|
|
237 |
//]]>
|
238 |
</script></td>
|
239 |
</tr>
|
240 |
-
<tr
|
241 |
<td class="label"><label for="sales_report_show_order_statuses">Order Status</label></td>
|
242 |
<td class="value"><select class=" select" name="show_order_statuses" id="sales_report_show_order_statuses">
|
243 |
<option <?php echo ($show_order_statuses==0)?'selected="selected"':''; ?> value="0">Any</option>
|
@@ -245,7 +241,7 @@
|
|
245 |
</select>
|
246 |
<p id="note_show_order_statuses" class="note"><span>Applies to Any of the Specified Order Statuses</span></p></td>
|
247 |
</tr>
|
248 |
-
<tr id="" style="display: none;">
|
249 |
<td class="label"></td>
|
250 |
<td class="value">
|
251 |
<select multiple="multiple" class=" select multiselect" size="10" name="order_statuses[]" id="sales_report_order_statuses">
|
@@ -268,9 +264,23 @@
|
|
268 |
<script type="text/javascript">
|
269 |
//<![CDATA[
|
270 |
var filterFormSubmit = new varienForm('filter_form');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
271 |
//]]>
|
272 |
</script>
|
273 |
<script type="text/javascript"> new FormElementDependenceController({"sales_report_order_statuses":{"sales_report_show_order_statuses":"1"}}); </script>
|
|
|
|
|
|
|
274 |
</div>
|
275 |
|
276 |
<div>
|
@@ -284,12 +294,18 @@
|
|
284 |
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
285 |
<input type="hidden" value="<?php echo $from; ?>" id="sales_report_from" name="from" />
|
286 |
<input type="hidden" value="<?php echo $to; ?>" id="sales_report_to" name="to" />
|
287 |
-
<select name="
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
<option <?php echo ($show_order_statuses==0)?'selected="selected"':''; ?> value="0">Any</option>
|
289 |
<option <?php echo ($show_order_statuses==1)?'selected="selected"':''; ?> value="1">Specified</option>
|
290 |
</select>
|
291 |
-
|
292 |
-
<select multiple="multiple" name="order_statuses[]"
|
293 |
<option <?php if(in_array('pending',$orserstatus)){echo 'selected="selected"';}?> value="pending">Pending</option>
|
294 |
<option <?php if(in_array('processing',$orserstatus)){echo 'selected="selected"';}?> value="processing">Processing</option>
|
295 |
<option <?php if(in_array('holded',$orserstatus)){echo 'selected="selected"';}?> value="holded">On Hold</option>
|
@@ -299,7 +315,7 @@
|
|
299 |
<option <?php if(in_array('fraud',$orserstatus)){echo 'selected="selected"';}?> value="fraud">Suspected Fraud</option>
|
300 |
<option <?php if(in_array('payment_review',$orserstatus)){echo 'selected="selected"';}?> value="payment_review">Payment Review</option>
|
301 |
</select>
|
302 |
-
|
303 |
</form>
|
304 |
<script type="text/javascript">
|
305 |
//<![CDATA[
|
@@ -313,8 +329,6 @@
|
|
313 |
<option value="<?php echo $this->getUrl('*/*/exportCsv')?>">CSV</option>
|
314 |
</select>
|
315 |
<button onclick="csvFormSubmit.submit()" class="scalable task" type="button"><span>Export</span></button>
|
316 |
-
|
317 |
-
<?php /*?><button onclick="printResult()" class="scalable task" type="button"><span>Print</span></button><?php */?>
|
318 |
</td>
|
319 |
</tr>
|
320 |
</tbody>
|
@@ -364,7 +378,7 @@
|
|
364 |
echo "<tr>";
|
365 |
foreach($singlerows as $value){
|
366 |
?>
|
367 |
-
|
368 |
<?php
|
369 |
}
|
370 |
echo "</tr>";
|
@@ -384,4 +398,4 @@
|
|
384 |
</div>
|
385 |
</div>
|
386 |
</div>
|
387 |
-
</div>
|
7 |
$result_order = 0;
|
8 |
|
9 |
if(!empty($_REQUEST['from']) && !empty($_REQUEST['to'])){
|
|
|
|
|
|
|
10 |
|
11 |
+
$orders_row = array();
|
12 |
+
$filter_type = $_REQUEST['filter_type'];
|
13 |
+
$from = $_REQUEST['from'];
|
14 |
+
$to = $_REQUEST['to'];
|
15 |
$from_date = date('Y-m-d' . ' 00:00:00', strtotime($from));
|
16 |
+
$to_date = date('Y-m-d' . ' 23:59:59', strtotime($to));
|
17 |
|
18 |
|
19 |
+
$filter_model = ($filter_type == 'shipping_date')
|
20 |
+
? 'sales/order_shipment_collection'
|
21 |
+
: 'sales/order_collection';
|
22 |
+
|
23 |
if($_REQUEST['show_order_statuses']>0){
|
24 |
$orserstatus = $_REQUEST['order_statuses'];
|
25 |
+
$_orderCollections = Mage::getResourceModel($filter_model);
|
26 |
+
$_orderCollections->addAttributeToSelect('*');
|
27 |
+
$_orderCollections->addFieldToFilter('created_at', array('from'=>$from_date, 'to'=>$to_date));
|
28 |
+
if($filter_type == 'order_date'){
|
29 |
+
$_orderCollections->addFieldToFilter('status', $orserstatus);
|
30 |
+
}
|
31 |
+
$_orderCollections->setOrder('created_at', 'desc');
|
32 |
+
$_orderCollections->load();
|
33 |
}else{
|
34 |
+
$_orderCollections = Mage::getResourceModel($filter_model)
|
35 |
->addAttributeToSelect('*')
|
36 |
->addFieldToFilter('created_at', array('from'=>$from_date, 'to'=>$to_date))
|
37 |
+
->setOrder('created_at', 'desc')
|
38 |
->load();
|
39 |
}
|
40 |
|
41 |
+
$show_order_statuses = $_REQUEST['show_order_statuses'];
|
42 |
+
$result_order = $_orderCollections->count();
|
43 |
|
|
|
|
|
44 |
$i=0;
|
45 |
+
foreach($_orderCollections as $key=>$single_order) {
|
46 |
+
if(($filter_type == 'shipping_date')){
|
47 |
+
$_orderId = $single_order->getOrderId();
|
48 |
+
}else{
|
49 |
+
$_orderId = $single_order->getId();
|
50 |
+
}
|
51 |
+
|
52 |
+
$myOrder = Mage::getModel('sales/order');
|
53 |
+
$myOrder->load($_orderId);
|
54 |
|
55 |
+
//Some Random Fields
|
56 |
$reportaddress = Mage::helper('salesreport')->getReportAddress();
|
57 |
if($reportaddress=="billing"){
|
58 |
|
62 |
$name = utf8_decode($myOrder->getBillingAddress()->getFirstname()." ".$myOrder->getBillingAddress()->getLastname());
|
63 |
|
64 |
$billingaddress = $myOrder->getBillingAddress()->getStreet();
|
65 |
+
$address = "";
|
66 |
+
$address[] = utf8_decode($billingaddress[0]);
|
67 |
+
if($billingaddress[1]){
|
68 |
+
$address[] = utf8_decode($billingaddress[1]);
|
69 |
+
}
|
70 |
+
$address = implode(", ",$address);
|
71 |
|
72 |
+
$city = utf8_decode($myOrder->getBillingAddress()->getCity());
|
73 |
|
74 |
+
$region = utf8_decode($myOrder->getBillingAddress()->getRegion());
|
75 |
|
76 |
+
$postcode = utf8_decode($myOrder->getBillingAddress()->getPostcode());
|
77 |
|
78 |
}else{
|
79 |
|
82 |
|
83 |
$name = utf8_decode($myOrder->getShippingAddress()->getFirstname()." ".$myOrder->getShippingAddress()->getLastname());
|
84 |
|
85 |
+
$shippingaddress = $myOrder->getShippingAddress()->getStreet();
|
86 |
+
$address = "";
|
87 |
+
$address[] = utf8_decode($shippingaddress[0]);
|
88 |
+
if($shippingaddress[1]){
|
89 |
+
$address[] = utf8_decode($shippingaddress[1]);
|
90 |
+
}
|
91 |
+
$address = implode(", ",$address);
|
92 |
|
93 |
+
$city = utf8_decode($myOrder->getShippingAddress()->getCity());
|
94 |
|
95 |
+
$region = utf8_decode($myOrder->getShippingAddress()->getRegion());
|
96 |
|
97 |
+
$postcode = utf8_decode($myOrder->getShippingAddress()->getPostcode());
|
98 |
}
|
99 |
|
100 |
$myOrder->loadByIncrementId($myOrder->getIncrementId());
|
101 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
$items = $myOrder->getItemsCollection();
|
103 |
$ic=1;
|
104 |
$countitems=0;
|
111 |
else:
|
112 |
$itemorderqty = round($item->getQtyOrdered());
|
113 |
endif;
|
|
|
|
|
|
|
|
|
114 |
|
115 |
if($item->getParentItemId() && round($item->getOriginalPrice())==0){
|
116 |
+
$parentitem = $myOrder->getItemById($item->getParentItemId());
|
|
|
|
|
|
|
117 |
$originalprice = $parentitem->getOriginalPrice();
|
|
|
118 |
$subtotal = ($parentitem->getOriginalPrice()*$itemorderqty);
|
119 |
|
120 |
$discountamount=0;
|
124 |
}
|
125 |
|
126 |
$subtotal = number_format($subtotal,2);
|
|
|
127 |
$eachitemdiscountamount = ($discountamount/$itemorderqty);
|
128 |
$discountamount = number_format($eachitemdiscountamount,2);
|
|
|
129 |
$taxpercent = $parentitem->getTaxPercent();
|
|
|
130 |
$eachitemvat = $vatamount_eachproduct/$itemorderqty;
|
131 |
$totalvatdisamount = $eachitemvat+$eachitemdiscountamount;
|
132 |
$net_price = round($originalprice-($totalvatdisamount),2);
|
133 |
|
134 |
}else{
|
135 |
+
$originalprice = $item->getOriginalPrice();
|
136 |
+
$subtotal = ($item->getOriginalPrice()*$itemorderqty);
|
|
|
|
|
137 |
$discountamount=0;
|
138 |
if(round($item->getDiscountAmount())!=0){
|
139 |
$discountamount=$item->getDiscountAmount();
|
140 |
$subtotal=($subtotal-$discountamount);
|
141 |
+
}
|
142 |
+
$subtotal = number_format($subtotal,2);
|
|
|
|
|
143 |
$eachitemdiscountamount = ($discountamount/$itemorderqty);
|
144 |
+
$discountamount = number_format($eachitemdiscountamount,2);
|
145 |
+
$taxpercent = $item->getTaxPercent();
|
|
|
|
|
146 |
$eachitemvat = $vatamount_eachproduct/$itemorderqty;
|
147 |
$totalvatdisamount = $eachitemvat+$eachitemdiscountamount;
|
148 |
$net_price = round($originalprice-($totalvatdisamount),2);
|
149 |
|
150 |
}
|
151 |
+
|
|
|
|
|
|
|
|
|
|
|
152 |
$customer_email = "";
|
153 |
if($custoer_id = $myOrder->getCustomerId()){
|
154 |
$customer = Mage::getModel('customer/customer')->load($custoer_id);
|
159 |
$customer_email=$myOrder->getCustomerEmail();
|
160 |
}
|
161 |
|
162 |
+
$orders_row[] = array(date("m/d/Y",strtotime($myOrder->getCreatedAt())), $myOrder->getIncrementId(), utf8_decode($item->getName()), $itemorderqty, utf8_decode($net_price),$subtotal,$name,$customer_email,$address,$city,$region,$postcode,$country);
|
163 |
|
164 |
}
|
165 |
}
|
191 |
<div class="hor-scroll">
|
192 |
<table cellspacing="0" class="form-list">
|
193 |
<tbody>
|
194 |
+
<tr>
|
195 |
+
<td class="label"><label for="sales_report_filter_type">Filter By <span class="required">*</span></label></td>
|
196 |
+
<td class="value">
|
197 |
+
<select class="required-entry select" name="filter_type" id="sales_report_filter_type" onchange="changeStatusOption(this.value);">
|
198 |
+
<option <?php echo ($filter_type=="order_date")?'selected="selected"':''; ?> value="order_date">Order Date</option>
|
199 |
+
<option <?php echo ($filter_type=="shipping_date")?'selected="selected"':''; ?> value="shipping_date">Shipping Date</option>
|
200 |
+
</select>
|
201 |
+
</tr>
|
202 |
<tr>
|
203 |
<td class="label"><label for="sales_report_from">From <span class="required">*</span></label></td>
|
204 |
<td class="value"><input type="text" style="width:110px !important;" class=" required-entry input-text" title="From" value="<?php echo $from; ?>" id="sales_report_from" name="from" />
|
233 |
//]]>
|
234 |
</script></td>
|
235 |
</tr>
|
236 |
+
<tr id="hide_for_shipping_date" <?php echo ($filter_type=="shipping_date")?'class="no-display"':''; ?>>
|
237 |
<td class="label"><label for="sales_report_show_order_statuses">Order Status</label></td>
|
238 |
<td class="value"><select class=" select" name="show_order_statuses" id="sales_report_show_order_statuses">
|
239 |
<option <?php echo ($show_order_statuses==0)?'selected="selected"':''; ?> value="0">Any</option>
|
241 |
</select>
|
242 |
<p id="note_show_order_statuses" class="note"><span>Applies to Any of the Specified Order Statuses</span></p></td>
|
243 |
</tr>
|
244 |
+
<tr id="hide_status_for_shipping_date" style="display: none;">
|
245 |
<td class="label"></td>
|
246 |
<td class="value">
|
247 |
<select multiple="multiple" class=" select multiselect" size="10" name="order_statuses[]" id="sales_report_order_statuses">
|
264 |
<script type="text/javascript">
|
265 |
//<![CDATA[
|
266 |
var filterFormSubmit = new varienForm('filter_form');
|
267 |
+
function changeStatusOption(optionvalue){
|
268 |
+
var filter_date = document.getElementById("hide_for_shipping_date");
|
269 |
+
var hide_status_for_shipping_date = document.getElementById("hide_status_for_shipping_date");
|
270 |
+
if(optionvalue=="shipping_date"){
|
271 |
+
filter_date.className = "no-display";
|
272 |
+
hide_status_for_shipping_date.style.display = "none";
|
273 |
+
}
|
274 |
+
if(optionvalue=="order_date"){
|
275 |
+
filter_date.className = "";
|
276 |
+
}
|
277 |
+
}
|
278 |
//]]>
|
279 |
</script>
|
280 |
<script type="text/javascript"> new FormElementDependenceController({"sales_report_order_statuses":{"sales_report_show_order_statuses":"1"}}); </script>
|
281 |
+
<style type="text/css">
|
282 |
+
.no-display{display:none;}
|
283 |
+
</style>
|
284 |
</div>
|
285 |
|
286 |
<div>
|
294 |
<input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
|
295 |
<input type="hidden" value="<?php echo $from; ?>" id="sales_report_from" name="from" />
|
296 |
<input type="hidden" value="<?php echo $to; ?>" id="sales_report_to" name="to" />
|
297 |
+
<select name="filter_type" class="no-display">
|
298 |
+
<option <?php echo ($filter_type=="order_date")?'selected="selected"':''; ?> value="order_date">Order Date</option>
|
299 |
+
<option <?php echo ($filter_type=="shipping_date")?'selected="selected"':''; ?> value="shipping_date">Shipping Date</option>
|
300 |
+
</select>
|
301 |
+
|
302 |
+
<?php if(($filter_type=="order_date")){?>
|
303 |
+
<select name="show_order_statuses" class="no-display">
|
304 |
<option <?php echo ($show_order_statuses==0)?'selected="selected"':''; ?> value="0">Any</option>
|
305 |
<option <?php echo ($show_order_statuses==1)?'selected="selected"':''; ?> value="1">Specified</option>
|
306 |
</select>
|
307 |
+
|
308 |
+
<select multiple="multiple" name="order_statuses[]" class="no-display">
|
309 |
<option <?php if(in_array('pending',$orserstatus)){echo 'selected="selected"';}?> value="pending">Pending</option>
|
310 |
<option <?php if(in_array('processing',$orserstatus)){echo 'selected="selected"';}?> value="processing">Processing</option>
|
311 |
<option <?php if(in_array('holded',$orserstatus)){echo 'selected="selected"';}?> value="holded">On Hold</option>
|
315 |
<option <?php if(in_array('fraud',$orserstatus)){echo 'selected="selected"';}?> value="fraud">Suspected Fraud</option>
|
316 |
<option <?php if(in_array('payment_review',$orserstatus)){echo 'selected="selected"';}?> value="payment_review">Payment Review</option>
|
317 |
</select>
|
318 |
+
<?php } ?>
|
319 |
</form>
|
320 |
<script type="text/javascript">
|
321 |
//<![CDATA[
|
329 |
<option value="<?php echo $this->getUrl('*/*/exportCsv')?>">CSV</option>
|
330 |
</select>
|
331 |
<button onclick="csvFormSubmit.submit()" class="scalable task" type="button"><span>Export</span></button>
|
|
|
|
|
332 |
</td>
|
333 |
</tr>
|
334 |
</tbody>
|
378 |
echo "<tr>";
|
379 |
foreach($singlerows as $value){
|
380 |
?>
|
381 |
+
<td><?php echo $value;?></td>
|
382 |
<?php
|
383 |
}
|
384 |
echo "</tr>";
|
398 |
</div>
|
399 |
</div>
|
400 |
</div>
|
401 |
+
</div>
|
package.xml
CHANGED
@@ -1,18 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Cybernetikz_Salesreport</name>
|
4 |
-
<version>0.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Custom Reporting with Product and Billing/Shipping info. Easy searchable option by order date and status.</summary>
|
10 |
<description>Custom Reporting with Product and Billing/Shipping info. Easy searchable option by order date and status.</description>
|
11 |
-
<notes
|
|
|
|
|
12 |
<authors><author><name>CyberNetikz</name><user>CyberNetikz</user><email>admin@cybernetikz.com</email></author></authors>
|
13 |
-
<date>
|
14 |
-
<time>14:
|
15 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Cybernetikz_Salesreport.xml" hash="9f019cd8c8002124305625477cba472c"/></dir></target><target name="magelocal"><dir name="Cybernetikz"><dir name="Salesreport"><dir name="Helper"><file name="Data.php" hash="01219c696266e745ee0ed668291834ae"/></dir><dir name="Model"><file name="Address.php" hash="c577974ece6d53e50be92a66ff255369"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SalesController.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Cybernetikz_Salesreport</name>
|
4 |
+
<version>0.1.3</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Custom Reporting with Product and Billing/Shipping info. Easy searchable option by order date and status.</summary>
|
10 |
<description>Custom Reporting with Product and Billing/Shipping info. Easy searchable option by order date and status.</description>
|
11 |
+
<notes>- Option is added to filter data by shipping date & order date
|
12 |
+
- Option is added for admin to assign 'custom sales report' from role resources
|
13 |
+
- A bug is fixed</notes>
|
14 |
<authors><author><name>CyberNetikz</name><user>CyberNetikz</user><email>admin@cybernetikz.com</email></author></authors>
|
15 |
+
<date>2015-05-07</date>
|
16 |
+
<time>14:44:40</time>
|
17 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Cybernetikz_Salesreport.xml" hash="9f019cd8c8002124305625477cba472c"/></dir></target><target name="magelocal"><dir name="Cybernetikz"><dir name="Salesreport"><dir name="Helper"><file name="Data.php" hash="01219c696266e745ee0ed668291834ae"/></dir><dir name="Model"><file name="Address.php" hash="c577974ece6d53e50be92a66ff255369"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SalesController.php" hash="55fcc0b614a732ef4b8e51e70a029045"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="a04d144b314b0e5ba51f98fb34ff63e6"/><file name="config.xml" hash="fd7538e2892463fd3fe1d5a0c169cd70"/><file name="system.xml" hash="9319c372d05d6a2825f049ab3dc48662"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="salesreport.xml" hash="3bc3565551291ad72e0ba329c0d9913d"/></dir><dir name="template"><dir name="salesreport"><file name="reportmanage.phtml" hash="f147b2d4539247c7aff8b1186ed08e46"/></dir></dir></dir></dir></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|