jah_dash - Version 0.1.0

Version Notes

This is stable realase

Download this release

Release Info

Developer Jose A Hernandez
Extension jah_dash
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (66) hide show
  1. app/code/community/Magjah/Customship/Block/Adminhtml/Ship/Shipmain.php +32 -0
  2. app/code/community/Magjah/Customship/Helper/Data.php +4 -0
  3. app/code/community/Magjah/Customship/Model/Carrier/Shipjah.php +90 -0
  4. app/code/community/Magjah/Customship/Model/Resource/Condition.php +15 -0
  5. app/code/community/Magjah/Customship/Model/Resource/Shiprules.php +8 -0
  6. app/code/community/Magjah/Customship/Model/Resource/Shiprules/Collection.php +10 -0
  7. app/code/community/Magjah/Customship/Model/Shiprules.php +10 -0
  8. app/code/community/Magjah/Customship/controllers/Adminhtml/ShipController.php +34 -0
  9. app/code/community/Magjah/Customship/controllers/IndexController.php +15 -0
  10. app/code/community/Magjah/Customship/etc/adminhtml.xml +33 -0
  11. app/code/community/Magjah/Customship/etc/config.xml +83 -0
  12. app/code/community/Magjah/Customship/etc/system.xml +110 -0
  13. app/code/community/Magjah/Customship/sql/magjah_customship_setup/install-0.1.0.php +44 -0
  14. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain.php +86 -0
  15. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Diagrams.php +70 -0
  16. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Graph.php +471 -0
  17. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer.php +28 -0
  18. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer/Accordion.php +86 -0
  19. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer/Grid.php +93 -0
  20. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer/Item.php +46 -0
  21. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer/Orders.php +44 -0
  22. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer/Render/Orders.php +16 -0
  23. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer/Render/Showbutton.php +10 -0
  24. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridorder.php +24 -0
  25. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridorder/Grid.php +93 -0
  26. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridorder/Item.php +96 -0
  27. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridorder/Render/Showbutton.php +10 -0
  28. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridproduct.php +24 -0
  29. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridproduct/Grid.php +119 -0
  30. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridproduct/Item.php +60 -0
  31. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridproduct/Media.php +85 -0
  32. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridproduct/Render/Showbutton.php +10 -0
  33. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Tab/Customers.php +69 -0
  34. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Tab/Customersorders.php +67 -0
  35. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Tab/Orders.php +67 -0
  36. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Tab/Products.php +67 -0
  37. app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Tab/Summary.php +80 -0
  38. app/code/community/Magjah/Dash/Helper/Dashboard/Customer.php +61 -0
  39. app/code/community/Magjah/Dash/Helper/Dashboard/CustomerOrder.php +57 -0
  40. app/code/community/Magjah/Dash/Helper/Dashboard/Diagrams.php +63 -0
  41. app/code/community/Magjah/Dash/Helper/Dashboard/Order.php +64 -0
  42. app/code/community/Magjah/Dash/Helper/Dashboard/Product.php +60 -0
  43. app/code/community/Magjah/Dash/Helper/Data.php +26 -0
  44. app/code/community/Magjah/Dash/Model/Resource/Customer.php +61 -0
  45. app/code/community/Magjah/Dash/Model/Resource/Customer/Collection.php +289 -0
  46. app/code/community/Magjah/Dash/Model/Resource/Customer/Order/Collection.php +200 -0
  47. app/code/community/Magjah/Dash/Model/Resource/Order.php +61 -0
  48. app/code/community/Magjah/Dash/Model/Resource/Order/Collection.php +78 -0
  49. app/code/community/Magjah/Dash/Model/Resource/Product.php +62 -0
  50. app/code/community/Magjah/Dash/Model/Resource/Product/Collection.php +290 -0
  51. app/code/community/Magjah/Dash/controllers/Adminhtml/Dashboard/IndexController.php +167 -0
  52. app/code/community/Magjah/Dash/etc/adminhtml.xml +45 -0
  53. app/code/community/Magjah/Dash/etc/config.xml +49 -0
  54. app/design/adminhtml/default/default/layout/dash.xml +9 -0
  55. app/design/adminhtml/default/default/template/dash/dashmain.phtml +121 -0
  56. app/design/adminhtml/default/default/template/dash/dashmain/graph.phtml +43 -0
  57. app/design/adminhtml/default/default/template/dash/dashmain/gridcustomer/item.phtml +66 -0
  58. app/design/adminhtml/default/default/template/dash/dashmain/gridcustomer/orders.phtml +26 -0
  59. app/design/adminhtml/default/default/template/dash/dashmain/gridorder/item.phtml +295 -0
  60. app/design/adminhtml/default/default/template/dash/dashmain/gridproduct/item.phtml +73 -0
  61. app/design/adminhtml/default/default/template/dash/dashmain/gridproduct/media.phtml +70 -0
  62. app/design/adminhtml/default/default/template/dash/dashmain/summary.phtml +70 -0
  63. app/etc/modules/Magjah_Dash.xml +12 -0
  64. js/dash/function.js +49 -0
  65. package.xml +19 -0
  66. skin/adminhtml/default/default/dash.css +10 -0
app/code/community/Magjah/Customship/Block/Adminhtml/Ship/Shipmain.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magjah_Customship_Block_Adminhtml_Ship_Shipmain extends Mage_Adminhtml_Block_Template
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_headerText = Mage::helper('magjah_customship')->__('Rules');
8
+ parent::__construct();
9
+ $this->setTemplate('magjah/ship/shipmain.phtml');
10
+ }
11
+
12
+ public function _beforeToHtml()
13
+ {
14
+ /* $this->setChild('gridcustomer', $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridcustomer', 'dash.gridcustomer'));
15
+ $this->setChild('gridorder', $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridorder', 'dash.gridorder'));
16
+ $this->setChild('gridproduct', $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridproduct', 'dash.gridproduct'));
17
+ if (Mage::getStoreConfig(self::XML_PATH_ENABLE_CHARTS)) {
18
+ $block = $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_diagrams');
19
+ } else {
20
+ $block = $this->getLayout()->createBlock('adminhtml/template')
21
+ ->setTemplate('dashboard/graph/disabled.phtml')
22
+ ->setConfigUrl($this->getUrl('adminhtml/system_config/edit', array('section'=>'admin')));
23
+ }
24
+ $this->setChild('diagrams', $block);
25
+ return $this;*/
26
+ }
27
+
28
+ public function getTotal(){
29
+ $collection = Mage::getSingleton('magjah_customship/shiprules')->getCollection();
30
+ return $collection->count();
31
+ }
32
+ }
app/code/community/Magjah/Customship/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Magjah_Customship_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/community/Magjah/Customship/Model/Carrier/Shipjah.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magjah_Customship_Model_Carrier_Shipjah extends Mage_Shipping_Model_Carrier_Abstract
4
+ implements Mage_Shipping_Model_Carrier_Interface
5
+ {
6
+ protected $_code = 'magjah_customship';
7
+
8
+ public function getAllowedMethods()
9
+ {
10
+ return array(
11
+ 'free' => 'Free delivery',
12
+ 'standard' => 'Standard delivery',
13
+ 'special' => 'Special delivery',
14
+ );
15
+ }
16
+
17
+ public function collectRates(Mage_Shipping_Model_Rate_Request $request)
18
+ {
19
+ if (!$this->getConfigData('active')) {
20
+ Mage::log('The '.$this->_code.' shipping method is not active.');
21
+ return false;
22
+ }
23
+ $result = Mage::getModel('shipping/rate_result');
24
+
25
+ // $items = Mage::getModel('checkout/session')->getQuote()->getAllItems();
26
+ $items = $request->getAllItems();
27
+ $totals = 0;
28
+ foreach ($items as $item) {
29
+ $totals += $item->getQty();
30
+ }
31
+
32
+ if($this->getConfigData('free_shipping_enable') && $request->getPackageValue() >= $this->getConfigData('free_shipping_subtotal')){
33
+ $result->append($this->_getFreeShip());
34
+ }
35
+
36
+ /* if ($totals >= $this->getConfigData('minimum_item_limit'))
37
+ $result->append($this->_getSpecialRate());
38
+ else
39
+ $result->append($this->_getStandardRate());
40
+ return $result;*/
41
+ }
42
+
43
+
44
+
45
+ protected function _getFreeShip(){
46
+ $method = Mage::getModel('shipping/rate_result_method');
47
+ $code = 'free';
48
+ $method->setCarrier($this->_code);
49
+ $method->setCarrierTitle($this->getConfigData('title'));
50
+ $method->setMethod($code);
51
+ $method->setMethodTitle('Free Shipping');
52
+ $method->setPrice(0.00);
53
+ return $method;
54
+
55
+ }
56
+
57
+ protected function _getSpecialRate(){
58
+
59
+ $method = Mage::getModel('shipping/rate_result_method');
60
+ $code = 'special';
61
+ $title = $this->getConfigData('over_minimum_title');
62
+ $price = $this->getConfigData('over_minimum_price');
63
+ $method->setCarrier($this->_code);
64
+ $method->setCarrierTitle($this->getConfigData('title'));
65
+ $method->setMethod($code);
66
+ $method->setMethodTitle($title);
67
+ $method->setPrice($price + $this->getConfigData('handling'));
68
+
69
+ return $method;
70
+
71
+ }
72
+
73
+
74
+ protected function _getStandardRate(){
75
+
76
+ $method = Mage::getModel('shipping/rate_result_method');
77
+ $code = 'standard';
78
+ $title = $this->getConfigData('under_minimum_title');
79
+ $price = $this->getConfigData('under_minimum_price');
80
+ $method->setCarrier($this->_code);
81
+ $method->setCarrierTitle($this->getConfigData('title'));
82
+ $method->setMethod($code);
83
+ $method->setMethodTitle($title);
84
+ $method->setPrice($price + $this->getConfigData('handling'));
85
+
86
+ return $method;
87
+
88
+ }
89
+
90
+ }
app/code/community/Magjah/Customship/Model/Resource/Condition.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magjah_Customship_Model_Resource_Condition extends Mage_Core_Model_Abstract
3
+ {
4
+
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value'=>0, 'label'=>Mage::helper('magjah_customship')->__('Weight vs. Destination')),
9
+ array('value'=>1, 'label'=>Mage::helper('magjah_customship')->__('Price vs. Destination')),
10
+ array('value'=>2, 'label'=>Mage::helper('magjah_customship')->__('Price and Weight vs. Destination')),
11
+ array('value'=>3, 'label'=>Mage::helper('magjah_customship')->__('Number of Items vs. Destination')),
12
+ );
13
+ }
14
+
15
+ }
app/code/community/Magjah/Customship/Model/Resource/Shiprules.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magjah_Customship_Model_Resource_Shiprules extends Mage_Core_Model_Resource_Db_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('magjah_customship/customship', 'id');
7
+ }
8
+ }
app/code/community/Magjah/Customship/Model/Resource/Shiprules/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magjah_Customship_Model_Resource_Shiprules_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('magjah_customship/shiprules');
9
+ }
10
+ }
app/code/community/Magjah/Customship/Model/Shiprules.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Magjah_Customship_Model_Shiprules extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('magjah_customship/shiprules');
8
+ }
9
+
10
+ }
app/code/community/Magjah/Customship/controllers/Adminhtml/ShipController.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: jhernandez
6
+ * Date: 10/20/14
7
+ * Time: 11:20 AM
8
+ */
9
+ class Magjah_Customship_Adminhtml_ShipController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+
12
+ /*
13
+ index - Shows the grid.
14
+ edit - Shows the edit/new form.
15
+ save - Saves the form data.
16
+ delete - Deletes the model.
17
+ new - Forwards on to the edit action*/
18
+
19
+
20
+ public function indexAction()
21
+ {
22
+ $this->_title($this->__('Shipping Rules'))
23
+ ->_title($this->__('Admin Shipping Rules'));
24
+ $this->loadLayout();
25
+ $this->_setActiveMenu('magjah/ship');
26
+ $this->_addContent(
27
+ $this->getLayout()->createBlock('magjah_customship/adminhtml_ship_shipmain')
28
+ );
29
+ $this->renderLayout();
30
+ }
31
+
32
+
33
+
34
+ }
app/code/community/Magjah/Customship/controllers/IndexController.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: jhernandez
5
+ * Date: 7/16/14
6
+ * Time: 2:24 PM
7
+ */
8
+
9
+ class Magjah_Customship_IndexController extends Mage_Core_Controller_Front_Action {
10
+
11
+ public function indexAction() {
12
+ die('joseeeeeeeeeeeeeeeeeeeee');
13
+ }
14
+
15
+ }
app/code/community/Magjah/Customship/etc/adminhtml.xml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <menu>
4
+ <magjah translate="title" module="magjah_customship">
5
+ <title>Magjah</title>
6
+ <sort_order>1000</sort_order>
7
+ <children>
8
+ <ship>
9
+ <title>Rules Shipping</title>
10
+ <sort_order>1</sort_order>
11
+ <action>adminhtml/ship</action>
12
+ </ship>
13
+ </children>
14
+ </magjah>
15
+ </menu>
16
+ <acl>
17
+ <resources>
18
+ <admin>
19
+ <children>
20
+ <magjah translate="title" module="magjah_customship">
21
+ <title>Top Level Ship</title>
22
+ <sort_order>1</sort_order>
23
+ <children>
24
+ <ship>
25
+ <title>Ship Rules</title>
26
+ </ship>
27
+ </children>
28
+ </magjah>
29
+ </children>
30
+ </admin>
31
+ </resources>
32
+ </acl>
33
+ </config>
app/code/community/Magjah/Customship/etc/config.xml ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Magjah_Customship>
4
+ <version>0.1.0</version>
5
+ </Magjah_Customship>
6
+ </modules>
7
+ <default>
8
+ <carriers>
9
+ <magjah_customship>
10
+ <model>magjah_customship/carrier_shipjah</model>
11
+ </magjah_customship>
12
+ </carriers>
13
+ </default>
14
+ <global>
15
+ <blocks>
16
+ <magjah_customship>
17
+ <class>Magjah_Customship_Block</class>
18
+ </magjah_customship>
19
+ </blocks>
20
+ <helpers>
21
+ <magjah_customship>
22
+ <class>Magjah_Customship_Helper</class>
23
+ </magjah_customship>
24
+ </helpers>
25
+ <models>
26
+ <magjah_customship>
27
+ <class>Magjah_Customship_Model</class>
28
+ <resourceModel>magjah_customship_resource</resourceModel>
29
+ </magjah_customship>
30
+ <magjah_customship_resource>
31
+ <class>Magjah_Customship_Model_Resource</class>
32
+ <entities>
33
+ <customship>
34
+ <table>magjah_customship</table>
35
+ </customship>
36
+ </entities>
37
+ </magjah_customship_resource>
38
+ </models>
39
+ <resources>
40
+ <magjah_customship_setup>
41
+ <setup>
42
+ <module>Magjah_Customship</module>
43
+ <class>Mage_Eav_Model_Entity_Setup</class>
44
+ </setup>
45
+ <connection>
46
+ <use>core_setup</use>
47
+ </connection>
48
+ </magjah_customship_setup>
49
+ <magjah_customship_write>
50
+ <connection>
51
+ <use>core_write</use>
52
+ </connection>
53
+ </magjah_customship_write>
54
+ <magjah_customship_read>
55
+ <connection>
56
+ <use>core_read</use>
57
+ </connection>
58
+ </magjah_customship_read>
59
+ </resources>
60
+ </global>
61
+ <frontend> <!-- Mage_Core_Model_App_Area you have all are for scope -->
62
+ <routers>
63
+ <magjahcustomship>
64
+ <use>standard</use>
65
+ <args>
66
+ <module>Magjah_Customship</module>
67
+ <frontName>magjahcustomship</frontName>
68
+ </args>
69
+ </magjahcustomship>
70
+ </routers>
71
+ </frontend>
72
+ <admin>
73
+ <routers>
74
+ <adminhtml>
75
+ <args>
76
+ <modules>
77
+ <magjah_customship before="Mage_Adminhtml">Magjah_Customship_Adminhtml</magjah_customship>
78
+ </modules>
79
+ </args>
80
+ </adminhtml>
81
+ </routers>
82
+ </admin>
83
+ </config>
app/code/community/Magjah/Customship/etc/system.xml ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <carriers>
5
+ <groups>
6
+ <magjah_customship translate="label" module="shipping">
7
+ <label>Custom Shipping in Magento Admin without csv</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>1</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <comment>
14
+ <![CDATA[
15
+ <div style="padding:20px;background-color:#fff;border:1px solid;">
16
+ This module was developed by <a href="http://www.magentocommerce.com/certification/directory/dev/33273/" target="_blank">Jose A Hernandez</a> - <b>Magento Developer PLus</b>.
17
+ <br/>You can create your shipping rules directly in the magento admin.
18
+ <br/>You have four type of condition for create your rules.
19
+ </div>
20
+ ]]>
21
+ </comment>
22
+ <fields>
23
+ <active translate="label">
24
+ <label>Enabled</label>
25
+ <frontend_type>select</frontend_type>
26
+ <source_model>adminhtml/system_config_source_yesno</source_model>
27
+ <sort_order>1</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>1</show_in_store>
31
+ </active>
32
+ <title translate="label">
33
+ <label>Title</label>
34
+ <frontend_type>text</frontend_type>
35
+ <sort_order>1</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ </title>
40
+ <free_shipping_enable translate="label">
41
+ <label>Free shipping with minimum order amount</label>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
44
+ <sort_order>2</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ </free_shipping_enable>
49
+ <free_shipping_subtotal translate="label">
50
+ <label>Minimum order amount for free shipping</label>
51
+ <frontend_type>text</frontend_type>
52
+ <sort_order>3</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ </free_shipping_subtotal>
57
+
58
+ <condition_type translate="label">
59
+ <label>Conditions Types</label>
60
+ <frontend_type>multiselect</frontend_type>
61
+ <source_model>magjah_customship/resource_condition</source_model>
62
+ <sort_order>4</sort_order>
63
+ <tooltip>
64
+ Once you change this and save you must create the rules for your shipping in ......
65
+ </tooltip>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ </condition_type>
70
+
71
+
72
+
73
+ <sallowspecific translate="label">
74
+ <label>Ship to applicable countries</label>
75
+ <frontend_type>select</frontend_type>
76
+ <sort_order>90</sort_order>
77
+ <frontend_class>shipping-applicable-country</frontend_class>
78
+ <source_model>adminhtml/system_config_source_shipping_allspecificcountries</source_model>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>1</show_in_store>
82
+ </sallowspecific>
83
+ <specificcountry translate="label">
84
+ <label>Ship to Specific countries</label>
85
+ <frontend_type>multiselect</frontend_type>
86
+ <sort_order>91</sort_order>
87
+ <source_model>adminhtml/system_config_source_country</source_model>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>1</show_in_store>
91
+ </specificcountry>
92
+
93
+ <showmethod translate="label">
94
+ <label>Show method if not applicable</label>
95
+ <frontend_type>select</frontend_type>
96
+ <sort_order>92</sort_order>
97
+ <source_model>adminhtml/system_config_source_yesno</source_model>
98
+ <show_in_default>1</show_in_default>
99
+ <show_in_website>1</show_in_website>
100
+ <show_in_store>1</show_in_store>
101
+ </showmethod>
102
+
103
+
104
+
105
+ </fields>
106
+ </magjah_customship>
107
+ </groups>
108
+ </carriers>
109
+ </sections>
110
+ </config>
app/code/community/Magjah/Customship/sql/magjah_customship_setup/install-0.1.0.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+ $connection = $installer->getConnection();
5
+ $connection->dropTable($this->getTable('magjah_customship/customship'));
6
+ $table = $installer->getConnection()
7
+ ->newTable($installer->getTable('magjah_customship/customship'))
8
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_BIGINT, 15, array(
9
+ 'identity' => true,
10
+ 'nullable' => false,
11
+ 'primary' => true,
12
+ ), 'id')
13
+ ->addColumn('website_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, NULL, array(
14
+ 'nullable' => false,
15
+ 'default' => 0
16
+ ), 'website_id')
17
+ ->addColumn('dest_country', Varien_Db_Ddl_Table::TYPE_TEXT, NULL, array(
18
+ 'nullable' => false,
19
+ 'default' => ''
20
+ ), 'dest_country')
21
+ ->addColumn('condition_title', Varien_Db_Ddl_Table::TYPE_TEXT, NULL, array(
22
+ 'nullable' => false,
23
+ 'default' => ''
24
+ ), 'condition_title')
25
+ ->addColumn('value_condition_f', Varien_Db_Ddl_Table::TYPE_DECIMAL,'12,4', array(
26
+ 'nullable' => false,
27
+ 'default' => 0.0000
28
+ ), 'value_condition_f')
29
+ ->addColumn('value_condition_t', Varien_Db_Ddl_Table::TYPE_DECIMAL,'12,4', array(
30
+ 'nullable' => false,
31
+ 'default' => 0.0000
32
+ ), 'value_condition_t')
33
+ ->addColumn('price', Varien_Db_Ddl_Table::TYPE_DECIMAL,'12,4', array(
34
+ 'nullable' => false,
35
+ 'default' => 0.0000
36
+ ), 'price')
37
+ ->addColumn('status', Varien_Db_Ddl_Table::TYPE_TEXT, NULL, array(
38
+ 'nullable' => false,
39
+ 'default' => ''
40
+ ), 'status')
41
+ ;
42
+ $installer->getConnection()->createTable($table);
43
+ $installer->endSetup();
44
+
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain extends Mage_Adminhtml_Block_Template
4
+ {
5
+ const XML_PATH_ENABLE_CHARTS = 'admin/dashboard/enable_charts';
6
+ public function __construct()
7
+ {
8
+ $this->_headerText = Mage::helper('magjah_dash')->__('Customer, Orders, Products');
9
+ parent::__construct();
10
+ $this->setTemplate('dash/dashmain.phtml');
11
+ }
12
+
13
+ public function _beforeToHtml()
14
+ {
15
+ $this->setChild('gridcustomer', $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridcustomer', 'dash.gridcustomer'));
16
+ $this->setChild('gridorder', $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridorder', 'dash.gridorder'));
17
+ $this->setChild('gridproduct', $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridproduct', 'dash.gridproduct'));
18
+ if (Mage::getStoreConfig(self::XML_PATH_ENABLE_CHARTS)) {
19
+ $block = $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_diagrams');
20
+ } else {
21
+ $block = $this->getLayout()->createBlock('adminhtml/template')
22
+ ->setTemplate('dashboard/graph/disabled.phtml')
23
+ ->setConfigUrl($this->getUrl('adminhtml/system_config/edit', array('section'=>'admin')));
24
+ }
25
+ $this->setChild('diagrams', $block);
26
+ return $this;
27
+ }
28
+
29
+ function bestSellers()
30
+ {
31
+ $storeId = (int) Mage::app()->getStore()->getId();
32
+ // Date
33
+ $date = new Zend_Date();
34
+ $toDate = $date->setDay(1)->getDate()->get('Y-MM-dd');
35
+ $fromDate = $date->subMonth(24)->getDate()->get('Y-MM-dd');
36
+
37
+ $collection = Mage::getResourceModel('catalog/product_collection')
38
+ ->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
39
+ ->addStoreFilter()
40
+ ->addUrlRewrite()
41
+ ->setPageSize(5);
42
+
43
+ $collection->getSelect()
44
+ ->joinLeft(
45
+ array('aggregation' => $collection->getResource()->getTable('sales/bestsellers_aggregated_monthly')),
46
+ "e.entity_id = aggregation.product_id AND aggregation.store_id={$storeId} AND aggregation.period BETWEEN '{$fromDate}' AND '{$toDate}'",
47
+ array('SUM(aggregation.qty_ordered) AS sold_quantity')
48
+ )
49
+ ->group('e.entity_id')
50
+ ->order(array('sold_quantity DESC', 'e.created_at'));
51
+ return $collection;
52
+ }
53
+
54
+ function bestCustomersOrder()
55
+ {
56
+ $collection = Mage::getResourceModel('reports/report_collection');
57
+
58
+ $date = new Zend_Date(mktime(0, 0, 0, 1, 1, 2001));
59
+ $data['report_from'] = $date->toString($this->getLocale()->getDateFormat('short'));
60
+ $date = new Zend_Date();
61
+ $data['report_to'] = $date->toString($this->getLocale()->getDateFormat('short'));
62
+ $collection->setPeriod($this->getFilter('report_period'));
63
+ $from = $this->getLocale()->date($data['report_from'], Zend_Date::DATE_SHORT, null, false);
64
+ $to = $this->getLocale()->date($data['report_to'], Zend_Date::DATE_SHORT, null, false);
65
+ $collection->setInterval($from, $to);
66
+
67
+ $storeIds = array_values(array_keys(Mage::app()->getStores()));
68
+ $collection->setStoreIds($storeIds);
69
+
70
+ $collection->setPageSize(4);
71
+ $collection->initReport('reports/customer_orders_collection');
72
+ return $collection;
73
+ }
74
+ /**
75
+ * Retrieve locale
76
+ *
77
+ * @return Mage_Core_Model_Locale
78
+ */
79
+ public function getLocale()
80
+ {
81
+ if (!$this->_locale) {
82
+ $this->_locale = Mage::app()->getLocale();
83
+ }
84
+ return $this->_locale;
85
+ }
86
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Diagrams.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard diagram tabs
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Diagrams extends Mage_Adminhtml_Block_Widget_Tabs
35
+ {
36
+ public function __construct()
37
+ {
38
+ parent::__construct();
39
+ $this->setId('diagram_tab');
40
+ $this->setDestElementId('diagram_tab_content');
41
+ $this->setTemplate('widget/tabshoriz.phtml');
42
+ }
43
+
44
+ protected function _prepareLayout()
45
+ {
46
+ $this->addTab('summary', array(
47
+ 'label' => $this->__('Summary'),
48
+ 'content' => $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_tab_summary')->toHtml(),
49
+ 'active' => true
50
+ ));
51
+ $this->addTab('orders', array(
52
+ 'label' => $this->__('Orders'),
53
+ 'content' => $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_tab_orders')->toHtml()
54
+ ));
55
+
56
+ $this->addTab('products', array(
57
+ 'label' => $this->__('Products'),
58
+ 'content' => $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_tab_products')->toHtml(),
59
+ ));
60
+ $this->addTab('customers', array(
61
+ 'label' => $this->__('Customers'),
62
+ 'content' => $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_tab_customers')->toHtml(),
63
+ ));
64
+ $this->addTab('customersorders', array(
65
+ 'label' => $this->__('Customers by orders'),
66
+ 'content' => $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_tab_customersorders')->toHtml(),
67
+ ));
68
+ return parent::_prepareLayout();
69
+ }
70
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Graph.php ADDED
@@ -0,0 +1,471 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard google chart block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Graph extends Mage_Adminhtml_Block_Dashboard_Abstract
35
+ {
36
+ /**
37
+ * Api URL
38
+ */
39
+ const API_URL = 'http://chart.apis.google.com/chart';
40
+
41
+ /**
42
+ * All series
43
+ *
44
+ * @var array
45
+ */
46
+ protected $_allSeries = array();
47
+
48
+ /**
49
+ * Axis labels
50
+ *
51
+ * @var array
52
+ */
53
+ protected $_axisLabels = array();
54
+
55
+ /**
56
+ * Axis maps
57
+ *
58
+ * @var array
59
+ */
60
+ protected $_axisMaps = array();
61
+
62
+ /**
63
+ * Data rows
64
+ *
65
+ * @var array
66
+ */
67
+ protected $_dataRows = array();
68
+
69
+ /**
70
+ * Simple encoding chars
71
+ *
72
+ * @var string
73
+ */
74
+ protected $_simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
75
+
76
+ /**
77
+ * Extended encoding chars
78
+ *
79
+ * @var string
80
+ */
81
+ protected $_extendedEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-.';
82
+
83
+ /**
84
+ * Chart width
85
+ *
86
+ * @var string
87
+ */
88
+ protected $_width = '587';
89
+
90
+ /**
91
+ * Chart height
92
+ *
93
+ * @var string
94
+ */
95
+ protected $_height = '300';
96
+
97
+ /**
98
+ * Google chart api data encoding
99
+ *
100
+ * @var string
101
+ */
102
+ protected $_encoding = 'e';
103
+
104
+ /**
105
+ * Html identifier
106
+ *
107
+ * @var string
108
+ */
109
+ protected $_htmlId = '';
110
+
111
+ /**
112
+ * Initialize object
113
+ *
114
+ */
115
+ public function __construct()
116
+ {
117
+ parent::__construct();
118
+ $this->setTemplate('dash/dashmain/graph.phtml');
119
+ }
120
+
121
+ /**
122
+ * Get tab template
123
+ *
124
+ * @return string
125
+ */
126
+ protected function _getTabTemplate()
127
+ {
128
+ return 'dash/dashmain/graph.phtml';
129
+ }
130
+
131
+ /**
132
+ * Set data rows
133
+ *
134
+ * @param mixed $rows
135
+ * @return void
136
+ */
137
+ public function setDataRows($rows)
138
+ {
139
+ $this->_dataRows = (array)$rows;
140
+ }
141
+
142
+ /**
143
+ * Add series
144
+ *
145
+ * @param string $seriesId
146
+ * @param array $options
147
+ * @return void
148
+ */
149
+ public function addSeries($seriesId, array $options)
150
+ {
151
+ $this->_allSeries[$seriesId] = $options;
152
+ }
153
+
154
+ /**
155
+ * Get series
156
+ *
157
+ * @param string $seriesId
158
+ * @return mixed
159
+ */
160
+ public function getSeries($seriesId)
161
+ {
162
+ if (isset($this->_allSeries[$seriesId])) {
163
+ return $this->_allSeries[$seriesId];
164
+ } else {
165
+ return false;
166
+ }
167
+ }
168
+
169
+ /**
170
+ * Get all series
171
+ *
172
+ * @return array
173
+ */
174
+ public function getAllSeries()
175
+ {
176
+ return $this->_allSeries;
177
+ }
178
+
179
+ /**
180
+ * Get chart url
181
+ *
182
+ * @param bool $directUrl
183
+ * @return string
184
+ */
185
+ public function getChartUrl($directUrl = true)
186
+ {
187
+ $params = array(
188
+ 'cht' => 'bvs',
189
+ 'chf' => 'bg,s,f4f4f4|c,lg,90,ffffff,0.1,ededed,0',
190
+ 'chm' => 'B,f4d4b2,0,50,1',
191
+ 'chco' =>'7F13F5|12B3C7|5379B3|1E9027|398BAC|67D7D9|13AFB4|4A3CFD|6D240C|2ABBA7'
192
+ );
193
+ $this->_allSeries = $this->getRowsData($this->_dataRows);
194
+
195
+ foreach ($this->_axisMaps as $axis => $attr) {
196
+ $this->setAxisLabels($axis, $this->getRowsData($attr, true));
197
+ }
198
+
199
+ //Google encoding values
200
+ if ($this->_encoding == "s") {
201
+ // simple encoding
202
+ $params['chd'] = "s:";
203
+ $dataDelimiter = "";
204
+ $dataSetdelimiter = ",";
205
+ $dataMissing = "_";
206
+ } else {
207
+ // extended encoding
208
+ $params['chd'] = "e:";
209
+ $dataDelimiter = "";
210
+ $dataSetdelimiter = ",";
211
+ $dataMissing = "__";
212
+ }
213
+
214
+ // process each string in the array, and find the max length
215
+ foreach ($this->getAllSeries() as $index => $serie) {
216
+ $localmaxlength[$index] = sizeof($serie);
217
+ $localmaxvalue[$index] = max($serie);
218
+ $localminvalue[$index] = min($serie);
219
+ }
220
+
221
+ if (is_numeric($this->_max)) {
222
+ $maxvalue = $this->_max;
223
+ } else {
224
+ $maxvalue = max($localmaxvalue);
225
+ }
226
+ if (is_numeric($this->_min)) {
227
+ $minvalue = $this->_min;
228
+ } else {
229
+ $minvalue = min($localminvalue);
230
+ }
231
+
232
+ // default values
233
+ $yrange = 0;
234
+ $yLabels = array();
235
+ $miny = 0;
236
+ $maxy = 0;
237
+ $yorigin = 0;
238
+
239
+ $maxlength = max($localmaxlength);
240
+ if ($minvalue >= 0 && $maxvalue >= 0) {
241
+ $miny = 0;
242
+ if ($maxvalue > 10) {
243
+ $p = pow(10, $this->_getPow($maxvalue));
244
+ $maxy = (ceil($maxvalue / $p)) * $p;
245
+ $yLabels = range($miny, $maxy, $p);
246
+ } else {
247
+ $maxy = ceil($maxvalue + 1);
248
+ $yLabels = range($miny, $maxy, 1);
249
+ }
250
+ $yrange = $maxy;
251
+ $yorigin = 0;
252
+ }
253
+
254
+ $chartdata = array();
255
+
256
+ foreach ($this->getAllSeries() as $index => $serie) {
257
+ $thisdataarray = $serie;
258
+ if ($this->_encoding == "s") {
259
+ // SIMPLE ENCODING
260
+ for ($j = 0; $j < sizeof($thisdataarray); $j++) {
261
+ $currentvalue = $thisdataarray[$j];
262
+ if (is_numeric($currentvalue)) {
263
+ $ylocation = round((strlen($this->_simpleEncoding) - 1) * ($yorigin + $currentvalue) / $yrange);
264
+ array_push($chartdata, substr($this->_simpleEncoding, $ylocation, 1) . $dataDelimiter);
265
+ } else {
266
+ array_push($chartdata, $dataMissing . $dataDelimiter);
267
+ }
268
+ }
269
+ // END SIMPLE ENCODING
270
+ } else {
271
+ // EXTENDED ENCODING
272
+ for ($j = 0; $j < sizeof($thisdataarray); $j++) {
273
+ $currentvalue = $thisdataarray[$j];
274
+ if (is_numeric($currentvalue)) {
275
+ if ($yrange) {
276
+ $ylocation = (4095 * ($yorigin + $currentvalue) / $yrange);
277
+ } else {
278
+ $ylocation = 0;
279
+ }
280
+ $firstchar = floor($ylocation / 64);
281
+ $secondchar = $ylocation % 64;
282
+ $mappedchar = substr($this->_extendedEncoding, $firstchar, 1)
283
+ . substr($this->_extendedEncoding, $secondchar, 1);
284
+ array_push($chartdata, $mappedchar . $dataDelimiter);
285
+ } else {
286
+ array_push($chartdata, $dataMissing . $dataDelimiter);
287
+ }
288
+ }
289
+ // ============= END EXTENDED ENCODING =============
290
+ }
291
+ array_push($chartdata, $dataSetdelimiter);
292
+ }
293
+ $buffer = implode('', $chartdata);
294
+
295
+ $buffer = rtrim($buffer, $dataSetdelimiter);
296
+ $buffer = rtrim($buffer, $dataDelimiter);
297
+ $buffer = str_replace(($dataDelimiter . $dataSetdelimiter), $dataSetdelimiter, $buffer);
298
+
299
+ $params['chd'] .= $buffer;
300
+
301
+ $valueBuffer = array();
302
+
303
+ if (sizeof($this->_axisLabels) > 0) {
304
+ $params['chxt'] = implode(',', array_keys($this->_axisLabels));
305
+ $indexid = 0;
306
+ foreach ($this->_axisLabels as $idx => $labels) {
307
+ if ($idx == 'x') {
308
+ /**
309
+ * Format date
310
+ */
311
+ foreach ($this->_axisLabels[$idx] as $_index => $_label) {
312
+ if ($_label != '') {
313
+ $this->_axisLabels['chdl'][$_index] = $_label;
314
+ } else {
315
+ $this->_axisLabels['chdl'][$_index] = '';
316
+ }
317
+ $this->_axisLabels[$idx][$_index] = '';
318
+
319
+ }
320
+
321
+ $tmpstring = implode('|', $this->_axisLabels[$idx]);
322
+
323
+ $valueBuffer[] = $indexid . ":|" . $tmpstring;
324
+ if (sizeof($this->_axisLabels[$idx]) > 1) {
325
+ $deltaX = 100 / (sizeof($this->_axisLabels[$idx]) - 1);
326
+ } else {
327
+ $deltaX = 100;
328
+ }
329
+ } else if ($idx == 'y') {
330
+ $valueBuffer[] = $indexid . ":|" . implode('|', $yLabels);
331
+ if (sizeof($yLabels) - 1) {
332
+ $deltaY = 100 / (sizeof($yLabels) - 1);
333
+ } else {
334
+ $deltaY = 100;
335
+ }
336
+ }
337
+ $indexid++;
338
+ }
339
+ $params['chxl'] = implode('|', $valueBuffer);
340
+ $params['chdl'] = implode('|', $this->_axisLabels['chdl']);
341
+ };
342
+
343
+ // chart size
344
+ $params['chs'] = $this->getWidth() . 'x' . $this->getHeight();
345
+
346
+ if (isset($deltaX) && isset($deltaY)) {
347
+ $params['chg'] = $deltaX . ',' . $deltaY . ',1,0';
348
+ }
349
+
350
+ // return the encoded data
351
+ if ($directUrl) {
352
+ $p = array();
353
+ foreach ($params as $name => $value) {
354
+ $p[] = $name . '=' . urlencode($value);
355
+ }
356
+ return self::API_URL . '?' . implode('&', $p);
357
+ } else {
358
+ $gaData = urlencode(base64_encode(serialize($params)));
359
+ $gaHash = Mage::helper('adminhtml/dashboard_data')->getChartDataHash($gaData);
360
+ $params = array('ga' => $gaData, 'h' => $gaHash);
361
+ return $this->getUrl('*/*/tunnel', array('_query' => $params));
362
+ }
363
+ }
364
+
365
+ /**
366
+ * Get rows data
367
+ *
368
+ * @param array $attributes
369
+ * @param bool $single
370
+ * @return array
371
+ */
372
+ protected function getRowsData($attributes, $single = false)
373
+ {
374
+ $items = $this->getCollection()->getItems();
375
+ $options = array();
376
+ foreach ($items as $item) {
377
+ if ($single) {
378
+ $options[] = $item->getData($attributes);
379
+ } else {
380
+ foreach ((array)$attributes as $attr) {
381
+ $options[$attr][] = $item->getData($attr);
382
+ }
383
+ }
384
+ }
385
+ return $options;
386
+ }
387
+
388
+ /**
389
+ * Set axis labels
390
+ *
391
+ * @param string $axis
392
+ * @param array $labels
393
+ * @return void
394
+ */
395
+ public function setAxisLabels($axis, $labels)
396
+ {
397
+ $this->_axisLabels[$axis] = $labels;
398
+ }
399
+
400
+ /**
401
+ * Set html id
402
+ *
403
+ * @param string $htmlId
404
+ * @return void
405
+ */
406
+ public function setHtmlId($htmlId)
407
+ {
408
+ $this->_htmlId = $htmlId;
409
+ }
410
+
411
+ /**
412
+ * Get html id
413
+ *
414
+ * @return string
415
+ */
416
+ public function getHtmlId()
417
+ {
418
+ return $this->_htmlId;
419
+ }
420
+
421
+ /**
422
+ * Return pow
423
+ *
424
+ * @param int $number
425
+ * @return int
426
+ */
427
+ protected function _getPow($number)
428
+ {
429
+ $pow = 0;
430
+ while ($number >= 10) {
431
+ $number = $number / 10;
432
+ $pow++;
433
+ }
434
+ return $pow;
435
+ }
436
+
437
+ /**
438
+ * Return chart width
439
+ *
440
+ * @return string
441
+ */
442
+ protected function getWidth()
443
+ {
444
+ return $this->_width;
445
+ }
446
+
447
+ /**
448
+ * Return chart height
449
+ *
450
+ * @return string
451
+ */
452
+ protected function getHeight()
453
+ {
454
+ return $this->_height;
455
+ }
456
+
457
+ /**
458
+ * Prepare chart data
459
+ *
460
+ * @return void
461
+ */
462
+ protected function _prepareData()
463
+ {
464
+ $availablePeriods = array_keys($this->helper('adminhtml/dashboard_data')->getDatePeriods());
465
+ $period = $this->getRequest()->getParam('period');
466
+
467
+ $this->getDataHelper()->setParam('period',
468
+ ($period && in_array($period, $availablePeriods)) ? $period : '7d'
469
+ );
470
+ }
471
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: jhernandez
5
+ * Date: 8/25/14
6
+ * Time: 6:49 PM
7
+ */
8
+
9
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridcustomer extends Mage_Adminhtml_Block_Widget_Grid_Container
10
+ {
11
+ public function __construct()
12
+ {
13
+ $this->_controller = 'adminhtml_dash_dashmain_gridcustomer';
14
+ $this->_blockGroup = 'magjah_dash';
15
+ $this->_headerText = '';
16
+ parent::__construct();
17
+ $this->_removeButton('add');
18
+ }
19
+ /**
20
+ * Get header HTML
21
+ *
22
+ * @return string
23
+ */
24
+ public function getHeaderHtml()
25
+ {
26
+ return '';
27
+ }
28
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer/Accordion.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml customer recent orders grid block
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridcustomer_Accordion extends Mage_Adminhtml_Block_Widget_Accordion
35
+ {
36
+ protected function _prepareLayout()
37
+ {
38
+ $customer = Mage::registry('current_customer');
39
+
40
+ $this->setId('customerViewAccordion');
41
+
42
+ $_orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id',$customer->getId());
43
+
44
+ $this->addItem('lastOrders', array(
45
+ 'title' => Mage::helper('customer')->__('Recent Orders (%d)',$_orders->count()),
46
+ 'ajax' => true,
47
+ 'content_url' => $this->getUrl('*/customer/lastOrders', array('_current' => true)),
48
+ ));
49
+
50
+ // add shopping cart block of each website
51
+ foreach (Mage::registry('current_customer')->getSharedWebsiteIds() as $websiteId) {
52
+ $website = Mage::app()->getWebsite($websiteId);
53
+
54
+ // count cart items
55
+ $cartItemsCount = Mage::getModel('sales/quote')
56
+ ->setWebsite($website)->loadByCustomer($customer)
57
+ ->getItemsCollection(false)
58
+ ->addFieldToFilter('parent_item_id', array('null' => true))
59
+ ->getSize();
60
+ // prepare title for cart
61
+ $title = Mage::helper('customer')->__('Shopping Cart - %d item(s)', $cartItemsCount);
62
+ if (count($customer->getSharedWebsiteIds()) > 1) {
63
+ $title = Mage::helper('customer')->__('Shopping Cart of %1$s - %2$d item(s)', $website->getName(), $cartItemsCount);
64
+ }
65
+
66
+ // add cart ajax accordion
67
+ $this->addItem('shopingCart' . $websiteId, array(
68
+ 'title' => $title,
69
+ 'ajax' => true,
70
+ 'content_url' => $this->getUrl('*/customer/viewCart', array('_current' => true, 'website_id' => $websiteId)),
71
+ ));
72
+ }
73
+
74
+ // count wishlist items
75
+ $wishlistCount = Mage::getModel('wishlist/item')->getCollection()
76
+ ->addCustomerIdFilter($customer->getId())
77
+ ->addStoreData()
78
+ ->getSize();
79
+ // add wishlist ajax accordion
80
+ $this->addItem('wishlist', array(
81
+ 'title' => Mage::helper('customer')->__('Wishlist - %d item(s)', $wishlistCount),
82
+ 'ajax' => true,
83
+ 'content_url' => $this->getUrl('*/customer/viewWishlist', array('_current' => true)),
84
+ ));
85
+ }
86
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer/Grid.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridcustomer_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('customerGrid');
9
+ $this->setUseAjax(true);
10
+ $this->setDefaultSort('entity_id');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getResourceModel('customer/customer_collection')
17
+ ->addNameToSelect()
18
+ ->addAttributeToSelect('is_active')
19
+ ->addAttributeToSelect('email')
20
+ ->addAttributeToSelect('created_at')
21
+ ->addAttributeToSelect('group_id')
22
+ ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
23
+ ;
24
+
25
+
26
+ $this->setCollection($collection);
27
+
28
+ return parent::_prepareCollection();
29
+ }
30
+
31
+ protected function _prepareColumns()
32
+ {
33
+ $helper = Mage::helper('magjah_dash');
34
+ $this->addColumn('entity_id', array(
35
+ 'header' => $helper->__('ID'),
36
+ 'width' => '5%',
37
+ 'index' => 'entity_id',
38
+ 'type' => 'number',
39
+ 'filter' => false
40
+ ));
41
+ $this->addColumn('name', array(
42
+ 'header' => $helper->__('Name'),
43
+ 'index' => 'name'
44
+ ));
45
+ $this->addColumn('email', array(
46
+ 'header' => $helper->__('Email'),
47
+ 'width' => '150',
48
+ 'index' => 'email'
49
+ ));
50
+
51
+ $this->addColumn('Telephone', array(
52
+ 'header' => $helper->__('Telephone'),
53
+ 'width' => '100',
54
+ 'index' => 'billing_telephone'
55
+ ));
56
+
57
+
58
+ $this->addColumn('Show button', array(
59
+ 'width' => '8%',
60
+ 'align' => 'center',
61
+ 'header' => $helper->__('Show'),
62
+ 'getter' => 'getId',
63
+ 'renderer' => 'Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridcustomer_Render_Showbutton',
64
+ 'type' => 'action',
65
+ 'filter' => false,
66
+ 'sortable' => false,
67
+ 'index' => 'stores',
68
+ 'is_system' => true,
69
+
70
+ ));
71
+ $this->addColumn('Orders', array(
72
+ 'width' => '8%',
73
+ 'align' => 'center',
74
+ 'header' => $helper->__('Order'),
75
+ 'getter' => 'getId',
76
+ 'renderer' => 'Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridcustomer_Render_Orders',
77
+ 'type' => 'action',
78
+ 'filter' => false,
79
+ 'sortable' => false,
80
+ 'index' => 'stores',
81
+ 'is_system' => true,
82
+
83
+ ));
84
+ return parent::_prepareColumns();
85
+ }
86
+
87
+ public function getGridUrl()
88
+ {
89
+ return $this->getUrl('*/*/gridcustomer', array('_current' => true));
90
+ }
91
+
92
+
93
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer/Item.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @category Mage
6
+ * @package Mage_Adminhtml
7
+ */
8
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridcustomer_Item extends Mage_Core_Block_Template
9
+ {
10
+ /**
11
+ * Current item instance
12
+ *
13
+ */
14
+ protected $_item;
15
+
16
+ function __construct()
17
+ {
18
+ parent::__construct();
19
+ $this->setTemplate('dash/dashmain/gridcustomer/item.phtml');
20
+ }
21
+
22
+ public function _beforeToHtml()
23
+ {
24
+ $this->setChild('customer_edit_tab_view', $this->getLayout()->createBlock('adminhtml/customer_edit_tab_view', 'dash.customer_edit_tab_view')->setTemplate('customer/tab/view.phtml'));
25
+ $this->setChild('customer_edit_tab_view_sales', $this->getLayout()->createBlock('adminhtml/customer_edit_tab_view_sales', 'dash.customer_edit_tab_view_sales')->setTemplate('customer/tab/view/sales.phtml'));
26
+ $this->setChild('dash_dashmain_gridcustomer_accordion', $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridcustomer_accordion', 'dash.dash_dashmain_gridcustomer_accordion'));
27
+
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * Retrieve current order model instance
33
+ *
34
+ * @return Mage_Customer_Model_Customer
35
+ */
36
+ public function getCustomer()
37
+ {
38
+ return Mage::registry('current_customer');
39
+ }
40
+
41
+ public function getSource()
42
+ {
43
+ return $this->getCostumer();
44
+ }
45
+ }
46
+
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer/Orders.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @category Mage
6
+ * @package Mage_Adminhtml
7
+ */
8
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridcustomer_Orders extends Mage_Core_Block_Template
9
+ {
10
+ /**
11
+ * Current item instance
12
+ *
13
+ */
14
+ protected $_item;
15
+
16
+ function __construct()
17
+ {
18
+ parent::__construct();
19
+ $this->setTemplate('dash/dashmain/gridcustomer/orders.phtml');
20
+ }
21
+
22
+ public function _beforeToHtml()
23
+ {
24
+ $this->setChild('dash_dashmain_gridcustomer_accordion', $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridcustomer_accordion', 'dash.dash_dashmain_gridcustomer_accordion'));
25
+
26
+ return $this;
27
+ }
28
+
29
+ /**
30
+ * Retrieve current order model instance
31
+ *
32
+ * @return Mage_Customer_Model_Customer
33
+ */
34
+ public function getCustomer()
35
+ {
36
+ return Mage::registry('current_customer');
37
+ }
38
+
39
+ public function getSource()
40
+ {
41
+ return $this->getCostumer();
42
+ }
43
+ }
44
+
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer/Render/Orders.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridcustomer_Render_Orders extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ {
5
+
6
+ public function render(Varien_Object $row)
7
+ {
8
+ $_orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id',$row->getId());
9
+ $_orderCnt = $_orders->count();
10
+ return "<button title='Show Orders' onclick=\"showUrlDetails('". $this->getUrl('*/*/customerOrders', array('_current'=> true,'id'=>$row->getId() ))."');\">" . $_orderCnt. "</button>";
11
+
12
+ }
13
+
14
+ }
15
+
16
+ ?>
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridcustomer/Render/Showbutton.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridcustomer_Render_Showbutton extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ $html = "<button title='Show' onclick=\"showUrlDetails('". $this->getUrl('*/*/customer', array('_current'=> true,'id'=>$row->getId() ))."');\">" . Mage::helper('magjah_dash')->__('Show') . "</button>";
7
+ return $html;
8
+ }
9
+
10
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridorder.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridorder extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_blockGroup = 'magjah_dash';
8
+ $this->_controller = 'adminhtml_dash_dashmain_gridorder';
9
+ $this->_headerText = '';
10
+
11
+ parent::__construct();
12
+ $this->_removeButton('add');
13
+ }
14
+
15
+ /**
16
+ * Get header HTML
17
+ *
18
+ * @return string
19
+ */
20
+ public function getHeaderHtml()
21
+ {
22
+ return '';
23
+ }
24
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridorder/Grid.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridorder_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('orderGrid');
9
+ $this->setDefaultSort('increment_id');
10
+ $this->setDefaultDir('DESC');
11
+ $this->setSaveParametersInSession(true);
12
+ $this->setUseAjax(true);
13
+ }
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = Mage::getResourceModel('sales/order_collection')
18
+ ->addExpressionFieldToSelect(
19
+ 'fullname',
20
+ 'CONCAT({{customer_firstname}}, \' \', {{customer_lastname}})',
21
+ array('customer_firstname' => 'main_table.customer_firstname', 'customer_lastname' => 'main_table.customer_lastname'))
22
+ ->addExpressionFieldToSelect(
23
+ 'products',
24
+ '(SELECT GROUP_CONCAT(\' \', x.name)
25
+ FROM sales_flat_order_item x
26
+ WHERE {{entity_id}} = x.order_id
27
+ AND x.product_type != \'configurable\')',
28
+ array('entity_id' => 'main_table.entity_id')
29
+ );
30
+
31
+ $this->setCollection($collection);
32
+ parent::_prepareCollection();
33
+ return $this;
34
+ }
35
+
36
+ protected function _prepareColumns()
37
+ {
38
+ $helper = Mage::helper('magjah_dash');
39
+ $currency = (string)Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE);
40
+
41
+ $this->addColumn('increment_id', array(
42
+ 'header' => $helper->__('Order #'),
43
+ 'index' => 'increment_id'
44
+ ));
45
+
46
+ $this->addColumn('products', array(
47
+ 'header' => $helper->__('Products Purchased'),
48
+ 'index' => 'products',
49
+ 'filter_index' => '(SELECT GROUP_CONCAT(\' \', x.name) FROM sales_flat_order_item x WHERE main_table.entity_id = x.order_id AND x.product_type != \'configurable\')'
50
+ ));
51
+
52
+ $this->addColumn('fullname', array(
53
+ 'header' => $helper->__('Name'),
54
+ 'index' => 'fullname',
55
+ 'filter_index' => 'CONCAT(customer_firstname, \' \', customer_lastname)'
56
+ ));
57
+
58
+
59
+ $this->addColumn('grand_total', array(
60
+ 'header' => $helper->__('Grand Total'),
61
+ 'index' => 'grand_total',
62
+ 'type' => 'currency',
63
+ 'currency_code' => $currency
64
+ ));
65
+
66
+ $this->addColumn('order_status', array(
67
+ 'header' => $helper->__('Status'),
68
+ 'index' => 'status',
69
+ 'type' => 'options',
70
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
71
+ ));
72
+ $this->addColumn('Show button', array(
73
+ 'width' => '8%',
74
+ 'align' => 'center',
75
+ 'header' => $helper->__('Show'),
76
+ 'getter' => 'getId',
77
+ 'renderer' => 'Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridorder_Render_Showbutton',
78
+ 'type' => 'action',
79
+ 'filter' => false,
80
+ 'sortable' => false,
81
+ 'index' => 'stores',
82
+ 'is_system' => true,
83
+
84
+ ));
85
+
86
+ return parent::_prepareColumns();
87
+ }
88
+
89
+ public function getGridUrl()
90
+ {
91
+ return $this->getUrl('*/*/gridorder', array('_current'=> true));
92
+ }
93
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridorder/Item.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @category Mage
6
+ * @package Mage_Adminhtml
7
+ */
8
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridorder_Item extends Mage_Core_Block_Template
9
+ {
10
+ /**
11
+ * Current item instance
12
+ *
13
+ */
14
+ protected $_item;
15
+
16
+ function __construct()
17
+ {
18
+ parent::__construct();
19
+ $this->setTemplate('dash/dashmain/gridorder/item.phtml');
20
+ }
21
+ public function _beforeToHtml()
22
+ {
23
+ $this->setChild('order_totals', $this->getLayout()->createBlock('adminhtml/sales_order_totals', 'dash.order_totals')->setTemplate('sales/order/totals.phtml'));
24
+
25
+ return $this;
26
+ }
27
+ /**
28
+ * Retrieve current order model instance
29
+ *
30
+ * @return Mage_Sales_Model_Order
31
+ */
32
+ public function getOrder()
33
+ {
34
+ return Mage::registry('current_order');
35
+ }
36
+ public function getPaymentHtml($order)
37
+ {
38
+ $this->setData('order', $order);
39
+
40
+ return $this->getChildHtml('payment_info');
41
+ }
42
+ public function getViewUrl($orderId)
43
+ {
44
+ return $this->getUrl('adminhtml/sales_order/view', array('_current'=>true, 'order_id' => $orderId));
45
+ }
46
+ public function getProccedUrl()
47
+ {
48
+ return $this->getUrl('adminhtml/sales_orderfraud/proceed', array('_current'=>true));
49
+ }
50
+ public function getItemsHtml()
51
+ {
52
+ return $this->getChildHtml('order_items');
53
+ }
54
+
55
+ public function displayPriceAttribute($code, $order) {
56
+ $this->setData('order', $order);
57
+ return $this->displayPrices(
58
+ $this->getPriceDataObject()->getData('base_'.$code),
59
+ $this->getPriceDataObject()->getData($code)
60
+ );
61
+
62
+ }
63
+ public function displayPrices($basePrice, $price, $strong = false, $separator = '<br/>')
64
+ {
65
+ if ($this->getOrder()->isCurrencyDifferent()) {
66
+ $res = '<strong>';
67
+ $res.= $this->getOrder()->formatBasePrice($basePrice);
68
+ $res.= '</strong>'.$separator;
69
+ $res.= '['.$this->getOrder()->formatPrice($price).']';
70
+ }
71
+ else {
72
+ $res = $this->getOrder()->formatPrice($price);
73
+ if ($strong) {
74
+ $res = '<strong>'.$res.'</strong>';
75
+ }
76
+ }
77
+ return $res;
78
+ }
79
+
80
+ public function getTotalBLock($order)
81
+ {
82
+ $this->setData('order', $order);
83
+ $totalsBlock = $this->getLayout()->getBlock('dash.order_totals');
84
+ $totalsBlock->setCacheKey(time().$order->getId());
85
+ $totalsBlock->setOrder($order);
86
+ $totalsBlock->setPriceDataObject($this->getSource());
87
+ $totalsBlock->_beforeToHtml();
88
+ $totalsBlock->setParentBlock($this);
89
+ return $totalsBlock;
90
+ }
91
+ public function getSource()
92
+ {
93
+ return $this->getOrder();
94
+ }
95
+ }
96
+
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridorder/Render/Showbutton.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridorder_Render_Showbutton extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ $html = "<button title='Show' onclick=\"showUrlDetails('". $this->getUrl('*/*/order', array('_current'=> true,'id'=>$row->getId() ))."');\">" . Mage::helper('magjah_dash')->__('Show') . "</button>";
7
+ return $html;
8
+ }
9
+
10
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridproduct.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridproduct extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_blockGroup = 'magjah_dash';
8
+ $this->_controller = 'adminhtml_dash_dashmain_gridproduct';
9
+ $this->_headerText = Mage::helper('magjah_dash')->__('Product');
10
+
11
+ parent::__construct();
12
+ $this->_removeButton('add');
13
+
14
+ }
15
+ /**
16
+ * Get header HTML
17
+ *
18
+ * @return string
19
+ */
20
+ public function getHeaderHtml()
21
+ {
22
+ return '';
23
+ }
24
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridproduct/Grid.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridproduct_Grid extends Mage_Adminhtml_Block_Catalog_Product_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('productGrid');
9
+ $this->setDefaultSort('increment_id');
10
+ $this->setDefaultDir('DESC');
11
+ $this->setSaveParametersInSession(true);
12
+ $this->setUseAjax(true);
13
+ }
14
+
15
+ protected function _prepareColumns()
16
+ {
17
+ $this->addColumn('entity_id',
18
+ array(
19
+ 'header' => Mage::helper('catalog')->__('ID'),
20
+ 'width' => '50px',
21
+ 'type' => 'number',
22
+ 'index' => 'entity_id',
23
+ 'filter' => false
24
+ ));
25
+ $this->addColumn('name',
26
+ array(
27
+ 'header' => Mage::helper('catalog')->__('Name'),
28
+ 'index' => 'name',
29
+ ));
30
+
31
+ $store = $this->_getStore();
32
+ if ($store->getId()) {
33
+ $this->addColumn('custom_name',
34
+ array(
35
+ 'header' => Mage::helper('catalog')->__('Name in %s', $store->getName()),
36
+ 'index' => 'custom_name',
37
+ ));
38
+ }
39
+
40
+ $this->addColumn('sku',
41
+ array(
42
+ 'header' => Mage::helper('catalog')->__('SKU'),
43
+ 'width' => '80px',
44
+ 'index' => 'sku',
45
+ ));
46
+
47
+ $store = $this->_getStore();
48
+ $this->addColumn('price',
49
+ array(
50
+ 'header' => Mage::helper('catalog')->__('Price'),
51
+ 'type' => 'price',
52
+ 'currency_code' => $store->getBaseCurrency()->getCode(),
53
+ 'index' => 'price',
54
+ ));
55
+
56
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
57
+ $this->addColumn('qty',
58
+ array(
59
+ 'header' => Mage::helper('catalog')->__('Qty'),
60
+ 'width' => '100px',
61
+ 'type' => 'number',
62
+ 'index' => 'qty',
63
+ ));
64
+ }
65
+
66
+
67
+ $this->addColumn('status',
68
+ array(
69
+ 'header' => Mage::helper('catalog')->__('Status'),
70
+ 'width' => '70px',
71
+ 'index' => 'status',
72
+ 'type' => 'options',
73
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
74
+ ));
75
+
76
+ $this->addColumn('Show button', array(
77
+ 'width' => '8%',
78
+ 'align' => 'center',
79
+ 'header' => Mage::helper('catalog')->__('Show'),
80
+ 'getter' => 'getId',
81
+ 'renderer' => 'Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridproduct_Render_Showbutton',
82
+ 'type' => 'action',
83
+ 'filter' => false,
84
+ 'sortable' => false,
85
+ 'index' => 'stores',
86
+ 'is_system' => true,
87
+
88
+ ));
89
+
90
+ $this->sortColumnsByOrder();
91
+ return $this;
92
+ }
93
+
94
+ /**
95
+ * Prepare grid massaction actions
96
+ *
97
+ * @return Mage_Adminhtml_Block_Widget_Grid
98
+ */
99
+ protected function _prepareMassaction()
100
+ {
101
+ return $this;
102
+ }
103
+
104
+ public function getGridUrl()
105
+ {
106
+ return $this->getUrl('*/*/gridproduct', array('_current' => true));
107
+ }
108
+
109
+ /**
110
+ * Return row url for js event handlers
111
+ *
112
+ * @param Mage_Catalog_Model_Product|Varien_Object
113
+ * @return string
114
+ */
115
+ public function getRowUrl($item)
116
+ {
117
+ return '#';
118
+ }
119
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridproduct/Item.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Adminhtml grid block
5
+ *
6
+ * @category Mage
7
+ * @package Mage_Adminhtml
8
+ */
9
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridproduct_Item extends Mage_Core_Block_Template
10
+ {
11
+ /**
12
+ * Current item instance
13
+ *
14
+ */
15
+ protected $_item;
16
+
17
+ function __construct()
18
+ {
19
+ parent::__construct();
20
+ $this->setTemplate('dash/dashmain/gridproduct/item.phtml');
21
+ }
22
+
23
+ public function _beforeToHtml()
24
+ {
25
+ $this->setChild('gridproduct_media', $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridproduct_media', 'dash.gridproduct_media'));
26
+
27
+ return $this;
28
+ }
29
+
30
+ /**
31
+ * Retrieve current order model instance
32
+ *
33
+ * @return Mage_Catalog_Model_Product
34
+ */
35
+ public function getProduct()
36
+ {
37
+ return Mage::registry('current_product');
38
+ }
39
+
40
+ public function getSource()
41
+ {
42
+ return $this->getCostumer();
43
+ }
44
+
45
+ public function getCategories($product = null)
46
+ {
47
+ if (!$product) {
48
+ $product = $this->getProduct();
49
+ }
50
+ $cats = $product->getCategoryIds();
51
+ $catText = array();
52
+ foreach ($cats as $category_id) {
53
+ $_cat = Mage::getModel('catalog/category')->load($category_id);
54
+ $catText[] = $_cat->getName();
55
+ }
56
+ return implode(', ', $catText);
57
+ }
58
+
59
+ }
60
+
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridproduct/Media.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Catalog
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Simple product data view
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Catalog
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridproduct_Media extends Mage_Catalog_Block_Product_View_Abstract
35
+ {
36
+
37
+ function __construct()
38
+ {
39
+ parent::__construct();
40
+ $this->setTemplate('dash/dashmain/gridproduct/media.phtml');
41
+ }
42
+ /**
43
+ * Flag, that defines whether gallery is disabled
44
+ *
45
+ * @var boolean
46
+ */
47
+ protected $_isGalleryDisabled;
48
+
49
+ /**
50
+ * Retrieve list of gallery images
51
+ *
52
+ * @return array|Varien_Data_Collection
53
+ */
54
+ public function getGalleryImages()
55
+ {
56
+ if ($this->_isGalleryDisabled) {
57
+ return array();
58
+ }
59
+ $collection = $this->getProduct()->getMediaGalleryImages();
60
+ return $collection;
61
+ }
62
+
63
+ /**
64
+ * Retrieve gallery url
65
+ *
66
+ * @param null|Varien_Object $image
67
+ * @return string
68
+ */
69
+ public function getGalleryUrl($image = null)
70
+ {
71
+ $params = array('id' => $this->getProduct()->getId());
72
+ if ($image) {
73
+ $params['image'] = $image->getValueId();
74
+ }
75
+ return $this->getUrl('catalog/product/gallery', $params);
76
+ }
77
+
78
+ /**
79
+ * Disable gallery
80
+ */
81
+ public function disableGallery()
82
+ {
83
+ $this->_isGalleryDisabled = true;
84
+ }
85
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Gridproduct/Render/Showbutton.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Gridproduct_Render_Showbutton extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ $html = "<button title='Show' onclick=\"showUrlDetails('". $this->getUrl('*/*/product', array('_current'=> true,'id'=>$row->getId() ))."');\">" . Mage::helper('magjah_dash')->__('Show') . "</button>";
7
+ return $html;
8
+ }
9
+
10
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Tab/Customers.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard order amounts diagram
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Tab_Customers extends Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Graph
36
+ {
37
+ /**
38
+ * Initialize object
39
+ *
40
+ * @return void
41
+ */
42
+ public function __construct()
43
+ {
44
+ $this->setHtmlId('customers');
45
+ parent::__construct();
46
+ }
47
+
48
+ /**
49
+ * Prepare chart data
50
+ *
51
+ * @return void
52
+ */
53
+ protected function _prepareData()
54
+ {
55
+ $this->setDataHelperName('magjah_dash/dashboard_customer');
56
+ $this->getDataHelper()->setParam('store', $this->getRequest()->getParam('store'));
57
+ $this->getDataHelper()->setParam('website', $this->getRequest()->getParam('website'));
58
+ $this->getDataHelper()->setParam('group', $this->getRequest()->getParam('group'));
59
+
60
+ $this->setDataRows('quantity');
61
+ $this->_axisMaps = array(
62
+ 'x' => 'range',
63
+ 'y' => 'quantity'
64
+ );
65
+
66
+ parent::_prepareData();
67
+ }
68
+ }
69
+
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Tab/Customersorders.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard order amounts diagram
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Tab_Customersorders extends Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Graph
36
+ {
37
+ /**
38
+ * Initialize object
39
+ */
40
+ public function __construct()
41
+ {
42
+ $this->setHtmlId('customers');
43
+ parent::__construct();
44
+ }
45
+
46
+ /**
47
+ * Prepare chart data
48
+ *
49
+ * @return void
50
+ */
51
+ protected function _prepareData()
52
+ {
53
+ $this->setDataHelperName('magjah_dash/dashboard_customerOrder');
54
+ $this->getDataHelper()->setParam('store', $this->getRequest()->getParam('store'));
55
+ $this->getDataHelper()->setParam('website', $this->getRequest()->getParam('website'));
56
+ $this->getDataHelper()->setParam('group', $this->getRequest()->getParam('group'));
57
+
58
+ $this->setDataRows('quantity');
59
+ $this->_axisMaps = array(
60
+ 'x' => 'name',
61
+ 'y' => 'quantity'
62
+ );
63
+
64
+ parent::_prepareData();
65
+ }
66
+ }
67
+
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Tab/Orders.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard orders diagram
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Tab_Orders extends Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Graph
36
+ {
37
+ /**
38
+ * Initialize object
39
+ */
40
+ public function __construct()
41
+ {
42
+ $this->setHtmlId('orders');
43
+ parent::__construct();
44
+ }
45
+
46
+ /**
47
+ * Prepare chart data
48
+ *
49
+ * @return void
50
+ */
51
+ protected function _prepareData()
52
+ {
53
+ //$this->setDataHelperName('adminhtml/dashboard_order');
54
+ $this->setDataHelperName('magjah_dash/dashboard_order');
55
+ $this->getDataHelper()->setParam('store', $this->getRequest()->getParam('store'));
56
+ $this->getDataHelper()->setParam('website', $this->getRequest()->getParam('website'));
57
+ $this->getDataHelper()->setParam('group', $this->getRequest()->getParam('group'));
58
+
59
+ $this->setDataRows('quantity');
60
+ $this->_axisMaps = array(
61
+ 'x' => 'range',
62
+ 'y' => 'quantity'
63
+ );
64
+
65
+ parent::_prepareData();
66
+ }
67
+ }
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Tab/Products.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard order amounts diagram
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+
35
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Tab_Products extends Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Graph
36
+ {
37
+ /**
38
+ * Initialize object
39
+ */
40
+ public function __construct()
41
+ {
42
+ $this->setHtmlId('products');
43
+ parent::__construct();
44
+ }
45
+
46
+ /**
47
+ * Prepare chart data
48
+ *
49
+ * @return void
50
+ */
51
+ protected function _prepareData()
52
+ {
53
+ $this->setDataHelperName('magjah_dash/dashboard_product');
54
+ $this->getDataHelper()->setParam('store', $this->getRequest()->getParam('store'));
55
+ $this->getDataHelper()->setParam('website', $this->getRequest()->getParam('website'));
56
+ $this->getDataHelper()->setParam('group', $this->getRequest()->getParam('group'));
57
+
58
+ $this->setDataRows('quantity');
59
+ $this->_axisMaps = array(
60
+ 'x' => 'range',
61
+ 'y' => 'quantity'
62
+ );
63
+
64
+ parent::_prepareData();
65
+ }
66
+ }
67
+
app/code/community/Magjah/Dash/Block/Adminhtml/Dash/Dashmain/Tab/Summary.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard orders diagram
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Magjah_Dash_Block_Adminhtml_Dash_Dashmain_Tab_Summary extends Mage_Adminhtml_Block_Template
35
+ {
36
+ /**
37
+ * Initialize object
38
+ *
39
+ */
40
+
41
+ public function __construct()
42
+ {
43
+ $this->setHtmlId('summary');
44
+ parent::__construct();
45
+ $this->setTemplate('dash/dashmain/summary.phtml');
46
+ }
47
+
48
+ public function getResumeCustomer()
49
+ {
50
+ $dataTotal = Mage::getResourceSingleton('magjah_dash/customer')->getTotalsByRange();
51
+ $dateStart = date("Y-m-d H:i:s",strtotime('6 days ago'));
52
+ $dataWeek = Mage::getResourceSingleton('magjah_dash/customer')->getTotalsByRange($dateStart);
53
+ $result['total'] = $dataTotal;
54
+ $result['week'] = $dataWeek;
55
+ $result['porcent'] = round($dataWeek * 100 / $dataTotal);
56
+ return $result;
57
+ }
58
+
59
+ public function getResumeProduct()
60
+ {
61
+ $dataTotal = Mage::getResourceSingleton('magjah_dash/product')->getTotalsByRange();
62
+ $dateStart = date("Y-m-d H:i:s",strtotime('6 days ago'));
63
+ $dataWeek = Mage::getResourceSingleton('magjah_dash/product')->getTotalsByRange($dateStart);
64
+ $result['total'] = $dataTotal;
65
+ $result['week'] = $dataWeek;
66
+ $result['porcent'] = round($dataWeek * 100 / $dataTotal);
67
+ return $result;
68
+ }
69
+
70
+ public function getResumeOrder()
71
+ {
72
+ $dataTotal = Mage::getResourceSingleton('magjah_dash/order')->getTotalsByRange();
73
+ $dateStart = date("Y-m-d H:i:s",strtotime('6 days ago'));
74
+ $dataWeek = Mage::getResourceSingleton('magjah_dash/order')->getTotalsByRange($dateStart);
75
+ $result['total'] = $dataTotal;
76
+ $result['week'] = $dataWeek;
77
+ $result['porcent'] = round($dataWeek * 100 / $dataTotal);
78
+ return $result;
79
+ }
80
+ }
app/code/community/Magjah/Dash/Helper/Dashboard/Customer.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard helper for orders
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Magjah_Dash_Helper_Dashboard_Customer extends Mage_Adminhtml_Helper_Dashboard_Abstract
35
+ {
36
+
37
+ protected function _initCollection()
38
+ {
39
+ $isFilter = $this->getParam('store') || $this->getParam('website') || $this->getParam('group');
40
+
41
+ $this->_collection = Mage::getResourceSingleton('magjah_dash/customer_collection')
42
+ ->prepareSummary($this->getParam('period'), 0, 0, $isFilter);
43
+
44
+ if ($this->getParam('store')) {
45
+ $this->_collection->addFieldToFilter('store_id', $this->getParam('store'));
46
+ } else if ($this->getParam('website')) {
47
+ $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
48
+ $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
49
+ } else if ($this->getParam('group')) {
50
+ $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
51
+ $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
52
+ }
53
+
54
+ $this->_collection->load();
55
+ if ($this->getParam('period') == '1m' and sizeof($this->_collection->getItems())>9)
56
+ $this->_collection->groupByDay();
57
+
58
+
59
+ }
60
+
61
+ }
app/code/community/Magjah/Dash/Helper/Dashboard/CustomerOrder.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard helper for orders
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Magjah_Dash_Helper_Dashboard_CustomerOrder extends Mage_Adminhtml_Helper_Dashboard_Abstract
35
+ {
36
+
37
+ protected function _initCollection()
38
+ {
39
+ $isFilter = $this->getParam('store') || $this->getParam('website') || $this->getParam('group');
40
+
41
+ $this->_collection = Mage::getResourceSingleton('magjah_dash/customer_order_collection')
42
+ ->prepareSummary($this->getParam('period'), 0, 0, $isFilter);
43
+
44
+ if ($this->getParam('store')) {
45
+ $this->_collection->addFieldToFilter('store_id', $this->getParam('store'));
46
+ } else if ($this->getParam('website')){
47
+ $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
48
+ $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
49
+ } else if ($this->getParam('group')){
50
+ $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
51
+ $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
52
+ }
53
+
54
+ $this->_collection->load();
55
+ }
56
+
57
+ }
app/code/community/Magjah/Dash/Helper/Dashboard/Diagrams.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard helper for Diagrams
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Magjah_Dash_Helper_Dashboard_Diagrams extends Mage_Adminhtml_Helper_Dashboard_Abstract
35
+ {
36
+
37
+ protected function _initCollection()
38
+ {
39
+ $isFilter = $this->getParam('store') || $this->getParam('website') || $this->getParam('group');
40
+
41
+ $this->_collection = Mage::getResourceSingleton('magjah_dash/customer_collection')
42
+ ->prepareSummary($this->getParam('period'), 0, 0, $isFilter);
43
+
44
+ if ($this->getParam('store')) {
45
+ $this->_collection->addFieldToFilter('store_id', $this->getParam('store'));
46
+ } else if ($this->getParam('website')){
47
+ $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
48
+ $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
49
+ } else if ($this->getParam('group')){
50
+ $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
51
+ $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
52
+ } elseif (!$this->_collection->isLive()) {
53
+ $this->_collection->addFieldToFilter('store_id',
54
+ array('eq' => Mage::app()->getStore(Mage_Core_Model_Store::ADMIN_CODE)->getId())
55
+ );
56
+ }
57
+
58
+
59
+
60
+ $this->_collection->load();
61
+ }
62
+
63
+ }
app/code/community/Magjah/Dash/Helper/Dashboard/Order.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard helper for orders
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Magjah_Dash_Helper_Dashboard_Order extends Mage_Adminhtml_Helper_Dashboard_Abstract
35
+ {
36
+
37
+ protected function _initCollection()
38
+ {
39
+ $isFilter = $this->getParam('store') || $this->getParam('website') || $this->getParam('group');
40
+
41
+ $this->_collection = Mage::getResourceSingleton('magjah_dash/order_collection');
42
+ $this->_collection->prepareSummary($this->getParam('period'), 0, 0, $isFilter);
43
+
44
+ if ($this->getParam('store')) {
45
+ $this->_collection->addFieldToFilter('store_id', $this->getParam('store'));
46
+ } else if ($this->getParam('website')){
47
+ $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
48
+ $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
49
+ } else if ($this->getParam('group')){
50
+ $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
51
+ $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
52
+ } elseif (!$this->_collection->isLive()) {
53
+ $this->_collection->addFieldToFilter('store_id',
54
+ array('eq' => Mage::app()->getStore(Mage_Core_Model_Store::ADMIN_CODE)->getId())
55
+ );
56
+ }
57
+
58
+ $this->_collection->load();
59
+ if ($this->getParam('period') == '1m' and sizeof($this->_collection->getItems())>9)
60
+ $this->_collection->groupByDay();
61
+
62
+ }
63
+
64
+ }
app/code/community/Magjah/Dash/Helper/Dashboard/Product.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Adminhtml
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Adminhtml dashboard helper for orders
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Adminhtml
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ class Magjah_Dash_Helper_Dashboard_Product extends Mage_Adminhtml_Helper_Dashboard_Abstract
35
+ {
36
+
37
+ protected function _initCollection()
38
+ {
39
+ $isFilter = $this->getParam('store') || $this->getParam('website') || $this->getParam('group');
40
+
41
+ $this->_collection = Mage::getResourceSingleton('magjah_dash/product_collection')
42
+ ->prepareSummary($this->getParam('period'), 0, 0, $isFilter);
43
+
44
+ if ($this->getParam('store')) {
45
+ $this->_collection->addFieldToFilter('store_id', $this->getParam('store'));
46
+ } else if ($this->getParam('website')){
47
+ $storeIds = Mage::app()->getWebsite($this->getParam('website'))->getStoreIds();
48
+ $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
49
+ } else if ($this->getParam('group')){
50
+ $storeIds = Mage::app()->getGroup($this->getParam('group'))->getStoreIds();
51
+ $this->_collection->addFieldToFilter('store_id', array('in' => implode(',', $storeIds)));
52
+ }
53
+
54
+ $this->_collection->load();
55
+ if ($this->getParam('period') == '1m' and sizeof($this->_collection->getItems())>9)
56
+ $this->_collection->groupByDay();
57
+
58
+ }
59
+
60
+ }
app/code/community/Magjah/Dash/Helper/Data.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Created by PhpStorm.
4
+ * User: jhernandez
5
+ * Date: 8/25/14
6
+ * Time: 6:29 PM
7
+ */
8
+
9
+
10
+ class Magjah_Dash_Helper_Data extends Mage_Core_Helper_Abstract
11
+ {
12
+ /**
13
+ * Prepare array with periods for dashboard graphs
14
+ *
15
+ * @return array
16
+ */
17
+ public function getDatePeriods()
18
+ {
19
+ return array(
20
+ '7d' => $this->__('Last 7 Days'),
21
+ '1m' => $this->__('Current Month'),
22
+ '1y' => $this->__('YTD'),
23
+ '2y' => $this->__('2YTD')
24
+ );
25
+ }
26
+ }
app/code/community/Magjah/Dash/Model/Resource/Customer.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Customer
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Customer entity resource model
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Customer
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Magjah_Dash_Model_Resource_Customer extends Mage_Eav_Model_Entity_Abstract
36
+ {
37
+ /**
38
+ * Resource initialization
39
+ */
40
+ public function __construct()
41
+ {
42
+ $this->setType('customer');
43
+ $this->setConnection('customer_read');
44
+ }
45
+
46
+ /**
47
+ * Check whether there are email duplicates of customers in global scope
48
+ *
49
+ * @return bool
50
+ */
51
+ public function getTotalsByRange($from=null)
52
+ {
53
+ $collection = Mage::getResourceModel('customer/customer_collection');
54
+ if ($from)
55
+ $collection->addAttributeToFilter('created_at', array(
56
+ 'from' => $from,
57
+ 'date' => true,
58
+ ));
59
+ return $collection->count();
60
+ }
61
+ }
app/code/community/Magjah/Dash/Model/Resource/Customer/Collection.php ADDED
@@ -0,0 +1,289 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Reports
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Reports orders collection
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Reports
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Magjah_Dash_Model_Resource_Customer_Collection extends Mage_Customer_Model_Resource_Customer_Collection
36
+ {
37
+
38
+ /**
39
+ * Prepare report summary
40
+ *
41
+ * @param string $range
42
+ * @param mixed $customStart
43
+ * @param mixed $customEnd
44
+ * @param int $isFilter
45
+ * @return Mage_Reports_Model_Resource_Order_Collection
46
+ */
47
+ public function prepareSummary($range, $customStart, $customEnd, $isFilter = 0)
48
+ {
49
+ return $this->_prepareSummaryLive($range, $customStart, $customEnd, $isFilter);
50
+ }
51
+
52
+ /**
53
+ * Prepare report summary from live data
54
+ *
55
+ * @param string $range
56
+ * @param mixed $customStart
57
+ * @param mixed $customEnd
58
+ * @param int $isFilter
59
+ * @return Mage_Reports_Model_Resource_Order_Collection
60
+ */
61
+ protected function _prepareSummaryLive($range, $customStart, $customEnd, $isFilter = 0)
62
+ {
63
+ /**
64
+ * Reset all columns, because result will group only by 'created_at' field
65
+ */
66
+ $this->getSelect()->reset(Zend_Db_Select::COLUMNS);
67
+
68
+ $dateRange = $this->getDateRange($range, $customStart, $customEnd);
69
+
70
+ $tzRangeOffsetExpression = $this->_getTZRangeOffsetExpression(
71
+ $range, 'updated_at', $dateRange['from'], $dateRange['to']
72
+ );
73
+
74
+ $this->getSelect()
75
+ ->columns(array(
76
+ 'quantity' => 'COUNT(e.entity_id)',
77
+ 'range' => $tzRangeOffsetExpression,
78
+ ))
79
+ ->order('range', Zend_Db_Select::SQL_ASC)
80
+ ->group($tzRangeOffsetExpression);
81
+
82
+ $this->addFieldToFilter('updated_at', $dateRange);
83
+
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * Prepare report summary from aggregated data
89
+ *
90
+ * @param string $range
91
+ * @param mixed $customStart
92
+ * @param mixed $customEnd
93
+ * @return Mage_Reports_Model_Resource_Order_Collection
94
+ */
95
+ protected function _prepareSummaryAggregated($range, $customStart, $customEnd)
96
+ {
97
+ $this->setMainTable('sales/order_aggregated_created');
98
+ /**
99
+ * Reset all columns, because result will group only by 'created_at' field
100
+ */
101
+ $this->getSelect()->reset(Zend_Db_Select::COLUMNS);
102
+ $rangePeriod = $this->_getRangeExpressionForAttribute($range, 'main_table.period');
103
+
104
+ $tableName = $this->getConnection()->quoteIdentifier('main_table.period');
105
+ $rangePeriod2 = str_replace($tableName, "MIN($tableName)", $rangePeriod);
106
+
107
+ $this->getSelect()->columns(array(
108
+ 'revenue' => 'SUM(main_table.total_revenue_amount)',
109
+ 'quantity' => 'SUM(main_table.orders_count)',
110
+ 'range' => $rangePeriod2,
111
+ ))
112
+ ->order('range')
113
+ ->group($rangePeriod);
114
+
115
+ $this->getSelect()->where(
116
+ $this->_getConditionSql('main_table.period', $this->getDateRange($range, $customStart, $customEnd))
117
+ );
118
+
119
+ $statuses = Mage::getSingleton('sales/config')
120
+ ->getOrderStatusesForState(Mage_Sales_Model_Order::STATE_CANCELED);
121
+
122
+ if (empty($statuses)) {
123
+ $statuses = array(0);
124
+ }
125
+ $this->addFieldToFilter('main_table.order_status', array('nin' => $statuses));
126
+
127
+ return $this;
128
+ }
129
+
130
+ /**
131
+ * Calculate From and To dates (or times) by given period
132
+ *
133
+ * @param string $range
134
+ * @param string $customStart
135
+ * @param string $customEnd
136
+ * @param boolean $returnObjects
137
+ * @return array
138
+ */
139
+ public function getDateRange($range, $customStart, $customEnd, $returnObjects = false)
140
+ {
141
+ $dateEnd = Mage::app()->getLocale()->date();
142
+ $dateStart = clone $dateEnd;
143
+
144
+ // go to the end of a day
145
+ $dateEnd->setHour(23);
146
+ $dateEnd->setMinute(59);
147
+ $dateEnd->setSecond(59);
148
+
149
+ $dateStart->setHour(0);
150
+ $dateStart->setMinute(0);
151
+ $dateStart->setSecond(0);
152
+
153
+ switch ($range) {
154
+ case '24h':
155
+ $dateEnd = Mage::app()->getLocale()->date();
156
+ $dateEnd->addHour(1);
157
+ $dateStart = clone $dateEnd;
158
+ $dateStart->subDay(1);
159
+ break;
160
+
161
+ case '7d':
162
+ // substract 6 days we need to include
163
+ // only today and not hte last one from range
164
+ $dateStart->subDay(6);
165
+ break;
166
+
167
+ case '1m':
168
+ $dateStart->setDay(Mage::getStoreConfig('reports/dashboard/mtd_start'));
169
+ break;
170
+
171
+ case 'custom':
172
+ $dateStart = $customStart ? $customStart : $dateEnd;
173
+ $dateEnd = $customEnd ? $customEnd : $dateEnd;
174
+ break;
175
+
176
+ case '1y':
177
+ case '2y':
178
+ $startMonthDay = explode(',', Mage::getStoreConfig('reports/dashboard/ytd_start'));
179
+ $startMonth = isset($startMonthDay[0]) ? (int)$startMonthDay[0] : 1;
180
+ $startDay = isset($startMonthDay[1]) ? (int)$startMonthDay[1] : 1;
181
+ $dateStart->setMonth($startMonth);
182
+ $dateStart->setDay($startDay);
183
+ if ($range == '2y') {
184
+ $dateStart->subYear(1);
185
+ }
186
+ break;
187
+ }
188
+
189
+ $dateStart->setTimezone('Etc/UTC');
190
+ $dateEnd->setTimezone('Etc/UTC');
191
+
192
+ if ($returnObjects) {
193
+ return array($dateStart, $dateEnd);
194
+ } else {
195
+ return array('from' => $dateStart, 'to' => $dateEnd, 'datetime' => true);
196
+ }
197
+ }
198
+
199
+ /**
200
+ * Retrieve query for attribute with timezone conversion
201
+ *
202
+ * @param string $range
203
+ * @param string $attribute
204
+ * @param mixed $from
205
+ * @param mixed $to
206
+ * @return string
207
+ */
208
+ protected function _getTZRangeOffsetExpression($range, $attribute, $from = null, $to = null)
209
+ {
210
+ return str_replace(
211
+ '{{attribute}}',
212
+ Mage::getResourceModel('reports/report_product_viewed')
213
+ ->getStoreTZOffsetQuery(array('source_table' => $this->getTable('reports/event')), $attribute, $from, $to),
214
+ $this->_getRangeExpression($range)
215
+ );
216
+ }
217
+
218
+ /**
219
+ * Get range expression
220
+ *
221
+ * @param string $range
222
+ * @return Zend_Db_Expr
223
+ */
224
+ protected function _getRangeExpression($range)
225
+ {
226
+ switch ($range) {
227
+ case '24h':
228
+ $expression = $this->getConnection()->getConcatSql(array(
229
+ $this->getConnection()->getDateFormatSql('{{attribute}}', '%Y-%m-%d %H:'),
230
+ $this->getConnection()->quote('00')
231
+ ));
232
+ break;
233
+ case '7d':
234
+ case '1m':
235
+ $expression = $this->getConnection()->getDateFormatSql('{{attribute}}', '%Y-%m-%d');
236
+ break;
237
+ case '1y':
238
+ case '2y':
239
+ case 'custom':
240
+ default:
241
+ $expression = $this->getConnection()->getDateFormatSql('{{attribute}}', '%Y-%m');
242
+ break;
243
+ }
244
+
245
+ return $expression;
246
+ }
247
+
248
+ function groupByDay()
249
+ {
250
+ $rangeDay = 4;
251
+ $rangeText = '';
252
+ $cont = 0;
253
+ $tmpV = null;
254
+
255
+ foreach ($this->_items as $k => $v) {
256
+ $date = DateTime::createFromFormat('Y-m-d', $v->getRange());
257
+ if ($rangeDay >= $date->format('d')) {
258
+ if ($rangeText == '')
259
+ $rangeText = $v->getRange();
260
+ $cont += $v->getQuantity();
261
+ unset($this->_items[$k]);
262
+ } elseif ($rangeText) {
263
+ if ($rangeText != $tmpV->getRange())
264
+ $rangeText .= ' to ' . $tmpV->getRange();
265
+ $result = clone $v;
266
+ $result->setQuantity($cont);
267
+ $result->setRange($rangeText);
268
+ $this->_items[$k] = $result;
269
+ do {
270
+ $rangeDay += 4;
271
+ } while ($rangeDay < $date->format('d'));
272
+ $rangeText = $v->getRange();
273
+ $cont = $v->getQuantity();
274
+ } else {
275
+ $rangeText = $v->getRange();
276
+ $cont += $v->getQuantity();
277
+ unset($this->_items[$k]);
278
+ }
279
+
280
+ $tmpV = $v;
281
+ }
282
+ if ($rangeText != $tmpV->getRange())
283
+ $rangeText .= ' to ' . $tmpV->getRange();
284
+ $result = clone $v;
285
+ $result->setQuantity($cont);
286
+ $result->setRange($rangeText);
287
+ $this->_items[$k+1] = $result;
288
+ }
289
+ }
app/code/community/Magjah/Dash/Model/Resource/Customer/Order/Collection.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Reports
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Reports orders collection
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Reports
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Magjah_Dash_Model_Resource_Customer_Order_Collection extends Mage_Customer_Model_Resource_Customer_Collection
36
+ {
37
+ /**
38
+ * Prepare report summary
39
+ *
40
+ * @param string $range
41
+ * @param mixed $customStart
42
+ * @param mixed $customEnd
43
+ * @param int $isFilter
44
+ * @return Mage_Reports_Model_Resource_Order_Collection
45
+ */
46
+ public function prepareSummary($range, $customStart, $customEnd, $isFilter = 0)
47
+ {
48
+ return $this->_prepareSummaryLive($range, $customStart, $customEnd, $isFilter);
49
+ }
50
+
51
+ /**
52
+ * Prepare report summary from live data
53
+ *
54
+ * @param string $range
55
+ * @param mixed $customStart
56
+ * @param mixed $customEnd
57
+ * @param int $isFilter
58
+ * @return Mage_Reports_Model_Resource_Order_Collection
59
+ */
60
+ protected function _prepareSummaryLive($range, $customStart, $customEnd, $isFilter = 0)
61
+ {
62
+ $this->getSelect()->reset(Zend_Db_Select::COLUMNS);
63
+
64
+ $dateRange = $this->getDateRange($range, $customStart, $customEnd);
65
+ $conditionSQl = $this->_getConditionSql('orders.created_at', $dateRange);
66
+ $this->getSelect()
67
+ ->columns(array(
68
+ 'quantity' => 'COUNT(orders.entity_id)'
69
+ ))
70
+ ->joinInner(array('orders' => $this->getTable('sales/order')),
71
+ "orders.customer_id = e.entity_id",
72
+ array('order_created_at' => 'created_at'))
73
+ ->order('quantity', Zend_Db_Select::SQL_DESC)
74
+ ->limit(10)
75
+ ->group('e.entity_id')
76
+ ->where($conditionSQl);
77
+
78
+ $this->addNameToSelect();
79
+
80
+ return $this;
81
+ }
82
+
83
+ /**
84
+ * Calculate From and To dates (or times) by given period
85
+ *
86
+ * @param string $range
87
+ * @param string $customStart
88
+ * @param string $customEnd
89
+ * @param boolean $returnObjects
90
+ * @return array
91
+ */
92
+ public function getDateRange($range, $customStart, $customEnd, $returnObjects = false)
93
+ {
94
+ $dateEnd = Mage::app()->getLocale()->date();
95
+ $dateStart = clone $dateEnd;
96
+
97
+ // go to the end of a day
98
+ $dateEnd->setHour(23);
99
+ $dateEnd->setMinute(59);
100
+ $dateEnd->setSecond(59);
101
+
102
+ $dateStart->setHour(0);
103
+ $dateStart->setMinute(0);
104
+ $dateStart->setSecond(0);
105
+
106
+ switch ($range) {
107
+ case '24h':
108
+ $dateEnd = Mage::app()->getLocale()->date();
109
+ $dateEnd->addHour(1);
110
+ $dateStart = clone $dateEnd;
111
+ $dateStart->subDay(1);
112
+ break;
113
+
114
+ case '7d':
115
+ // substract 6 days we need to include
116
+ // only today and not hte last one from range
117
+ $dateStart->subDay(6);
118
+ break;
119
+
120
+ case '1m':
121
+ $dateStart->setDay(Mage::getStoreConfig('reports/dashboard/mtd_start'));
122
+ break;
123
+
124
+ case 'custom':
125
+ $dateStart = $customStart ? $customStart : $dateEnd;
126
+ $dateEnd = $customEnd ? $customEnd : $dateEnd;
127
+ break;
128
+
129
+ case '1y':
130
+ case '2y':
131
+ $startMonthDay = explode(',', Mage::getStoreConfig('reports/dashboard/ytd_start'));
132
+ $startMonth = isset($startMonthDay[0]) ? (int)$startMonthDay[0] : 1;
133
+ $startDay = isset($startMonthDay[1]) ? (int)$startMonthDay[1] : 1;
134
+ $dateStart->setMonth($startMonth);
135
+ $dateStart->setDay($startDay);
136
+ if ($range == '2y') {
137
+ $dateStart->subYear(1);
138
+ }
139
+ break;
140
+ }
141
+
142
+ $dateStart->setTimezone('Etc/UTC');
143
+ $dateEnd->setTimezone('Etc/UTC');
144
+
145
+ if ($returnObjects) {
146
+ return array($dateStart, $dateEnd);
147
+ } else {
148
+ return array('from' => $dateStart, 'to' => $dateEnd, 'datetime' => true);
149
+ }
150
+ }
151
+
152
+ /**
153
+ * Retrieve query for attribute with timezone conversion
154
+ *
155
+ * @param string $range
156
+ * @param string $attribute
157
+ * @param mixed $from
158
+ * @param mixed $to
159
+ * @return string
160
+ */
161
+ protected function _getTZRangeOffsetExpression($range, $attribute, $from = null, $to = null)
162
+ {
163
+ return str_replace(
164
+ '{{attribute}}',
165
+ Mage::getResourceModel('reports/report_product_viewed')
166
+ ->getStoreTZOffsetQuery(array('source_table' => $this->getTable('reports/event')), $attribute, $from, $to),
167
+ $this->_getRangeExpression($range)
168
+ );
169
+ }
170
+
171
+ /**
172
+ * Get range expression
173
+ *
174
+ * @param string $range
175
+ * @return Zend_Db_Expr
176
+ */
177
+ protected function _getRangeExpression($range)
178
+ {
179
+ switch ($range) {
180
+ case '24h':
181
+ $expression = $this->getConnection()->getConcatSql(array(
182
+ $this->getConnection()->getDateFormatSql('{{attribute}}', '%Y-%m-%d %H:'),
183
+ $this->getConnection()->quote('00')
184
+ ));
185
+ break;
186
+ case '7d':
187
+ case '1m':
188
+ $expression = $this->getConnection()->getDateFormatSql('{{attribute}}', '%Y-%m-%d');
189
+ break;
190
+ case '1y':
191
+ case '2y':
192
+ case 'custom':
193
+ default:
194
+ $expression = $this->getConnection()->getDateFormatSql('{{attribute}}', '%Y-%m');
195
+ break;
196
+ }
197
+
198
+ return $expression;
199
+ }
200
+ }
app/code/community/Magjah/Dash/Model/Resource/Order.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Customer
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Customer entity resource model
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Customer
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Magjah_Dash_Model_Resource_Order extends Mage_Eav_Model_Entity_Abstract
36
+ {
37
+ /**
38
+ * Resource initialization
39
+ */
40
+ public function __construct()
41
+ {
42
+ $this->setType('order');
43
+ $this->setConnection('order_read');
44
+ }
45
+
46
+ /**
47
+ * Check whether there are email duplicates of customers in global scope
48
+ *
49
+ * @return bool
50
+ */
51
+ public function getTotalsByRange($from=null)
52
+ {
53
+ $collection = Mage::getResourceModel('sales/order_collection');
54
+ if ($from)
55
+ $collection->addAttributeToFilter('created_at', array(
56
+ 'from' => $from,
57
+ 'date' => true,
58
+ ));
59
+ return $collection->count();
60
+ }
61
+ }
app/code/community/Magjah/Dash/Model/Resource/Order/Collection.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Reports
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Reports orders collection
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Reports
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Magjah_Dash_Model_Resource_Order_Collection extends Mage_Reports_Model_Resource_Order_Collection
36
+ {
37
+ function groupByDay()
38
+ {
39
+ $rangeDay = 4;
40
+ $rangeText = '';
41
+ $cont = 0;
42
+ $tmpV = null;
43
+
44
+ foreach ($this->_items as $k => $v) {
45
+ $date = DateTime::createFromFormat('Y-m-d', $v->getRange());
46
+ if ($rangeDay >= $date->format('d')) {
47
+ if ($rangeText == '')
48
+ $rangeText = $v->getRange();
49
+ $cont += $v->getQuantity();
50
+ unset($this->_items[$k]);
51
+ } elseif ($rangeText) {
52
+ if ($rangeText != $tmpV->getRange())
53
+ $rangeText .= ' to ' . $tmpV->getRange();
54
+ $result = clone $v;
55
+ $result->setQuantity($cont);
56
+ $result->setRange($rangeText);
57
+ $this->_items[$k] = $result;
58
+ do {
59
+ $rangeDay += 4;
60
+ } while ($rangeDay < $date->format('d'));
61
+ $rangeText = $v->getRange();
62
+ $cont = $v->getQuantity();
63
+ } else {
64
+ $rangeText = $v->getRange();
65
+ $cont += $v->getQuantity();
66
+ unset($this->_items[$k]);
67
+ }
68
+
69
+ $tmpV = $v;
70
+ }
71
+ if ($rangeText != $tmpV->getRange())
72
+ $rangeText .= ' to ' . $tmpV->getRange();
73
+ $result = clone $v;
74
+ $result->setQuantity($cont);
75
+ $result->setRange($rangeText);
76
+ $this->_items[$k+1] = $result;
77
+ }
78
+ }
app/code/community/Magjah/Dash/Model/Resource/Product.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Customer
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Customer entity resource model
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Customer
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Magjah_Dash_Model_Resource_Product extends Mage_Eav_Model_Entity_Abstract
36
+ {
37
+ /**
38
+ * Resource initialization
39
+ */
40
+ public function __construct()
41
+ {
42
+ $this->setType('catalog_product');
43
+ $this->setConnection('catalog_product_read');
44
+ }
45
+
46
+ /**
47
+ * Check whether there are email duplicates of customers in global scope
48
+ *
49
+ * @return bool
50
+ */
51
+ public function getTotalsByRange($from = null)
52
+ {
53
+
54
+ $collection = Mage::getModel('catalog/product')->getCollection();
55
+ if ($from)
56
+ $collection->addAttributeToFilter('created_at', array(
57
+ 'from' => $from,
58
+ 'date' => true,
59
+ ));
60
+ return $collection->count();
61
+ }
62
+ }
app/code/community/Magjah/Dash/Model/Resource/Product/Collection.php ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Reports
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ /**
29
+ * Reports orders collection
30
+ *
31
+ * @category Mage
32
+ * @package Mage_Reports
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Magjah_Dash_Model_Resource_Product_Collection extends Mage_Catalog_Model_Resource_Product_Collection
36
+ {
37
+
38
+
39
+ /**
40
+ * Prepare report summary
41
+ *
42
+ * @param string $range
43
+ * @param mixed $customStart
44
+ * @param mixed $customEnd
45
+ * @param int $isFilter
46
+ * @return Mage_Reports_Model_Resource_Order_Collection
47
+ */
48
+ public function prepareSummary($range, $customStart, $customEnd, $isFilter = 0)
49
+ {
50
+ return $this->_prepareSummaryLive($range, $customStart, $customEnd, $isFilter);
51
+ }
52
+
53
+ /**
54
+ * Prepare report summary from live data
55
+ *
56
+ * @param string $range
57
+ * @param mixed $customStart
58
+ * @param mixed $customEnd
59
+ * @param int $isFilter
60
+ * @return Mage_Reports_Model_Resource_Order_Collection
61
+ */
62
+ protected function _prepareSummaryLive($range, $customStart, $customEnd, $isFilter = 0)
63
+ {
64
+ /**
65
+ * Reset all columns, because result will group only by 'created_at' field
66
+ */
67
+ $this->getSelect()->reset(Zend_Db_Select::COLUMNS);
68
+
69
+ $dateRange = $this->getDateRange($range, $customStart, $customEnd);
70
+
71
+ $tzRangeOffsetExpression = $this->_getTZRangeOffsetExpression(
72
+ $range, 'created_at', $dateRange['from'], $dateRange['to']
73
+ );
74
+
75
+ $this->getSelect()
76
+ ->columns(array(
77
+ 'quantity' => 'COUNT(e.entity_id)',
78
+ 'range' => $tzRangeOffsetExpression,
79
+ ))
80
+ ->order('range', Zend_Db_Select::SQL_ASC)
81
+ ->group($tzRangeOffsetExpression);
82
+
83
+ $this->addFieldToFilter('created_at', $dateRange);
84
+
85
+ return $this;
86
+ }
87
+
88
+ /**
89
+ * Prepare report summary from aggregated data
90
+ *
91
+ * @param string $range
92
+ * @param mixed $customStart
93
+ * @param mixed $customEnd
94
+ * @return Mage_Reports_Model_Resource_Order_Collection
95
+ */
96
+ protected function _prepareSummaryAggregated($range, $customStart, $customEnd)
97
+ {
98
+ $this->setMainTable('sales/order_aggregated_created');
99
+ /**
100
+ * Reset all columns, because result will group only by 'created_at' field
101
+ */
102
+ $this->getSelect()->reset(Zend_Db_Select::COLUMNS);
103
+ $rangePeriod = $this->_getRangeExpressionForAttribute($range, 'main_table.period');
104
+
105
+ $tableName = $this->getConnection()->quoteIdentifier('main_table.period');
106
+ $rangePeriod2 = str_replace($tableName, "MIN($tableName)", $rangePeriod);
107
+
108
+ $this->getSelect()->columns(array(
109
+ 'revenue' => 'SUM(main_table.total_revenue_amount)',
110
+ 'quantity' => 'SUM(main_table.orders_count)',
111
+ 'range' => $rangePeriod2,
112
+ ))
113
+ ->order('range')
114
+ ->group($rangePeriod);
115
+
116
+ $this->getSelect()->where(
117
+ $this->_getConditionSql('main_table.period', $this->getDateRange($range, $customStart, $customEnd))
118
+ );
119
+
120
+ $statuses = Mage::getSingleton('sales/config')
121
+ ->getOrderStatusesForState(Mage_Sales_Model_Order::STATE_CANCELED);
122
+
123
+ if (empty($statuses)) {
124
+ $statuses = array(0);
125
+ }
126
+ $this->addFieldToFilter('main_table.order_status', array('nin' => $statuses));
127
+
128
+ return $this;
129
+ }
130
+
131
+ /**
132
+ * Calculate From and To dates (or times) by given period
133
+ *
134
+ * @param string $range
135
+ * @param string $customStart
136
+ * @param string $customEnd
137
+ * @param boolean $returnObjects
138
+ * @return array
139
+ */
140
+ public function getDateRange($range, $customStart, $customEnd, $returnObjects = false)
141
+ {
142
+ $dateEnd = Mage::app()->getLocale()->date();
143
+ $dateStart = clone $dateEnd;
144
+
145
+ // go to the end of a day
146
+ $dateEnd->setHour(23);
147
+ $dateEnd->setMinute(59);
148
+ $dateEnd->setSecond(59);
149
+
150
+ $dateStart->setHour(0);
151
+ $dateStart->setMinute(0);
152
+ $dateStart->setSecond(0);
153
+
154
+ switch ($range) {
155
+ case '24h':
156
+ $dateEnd = Mage::app()->getLocale()->date();
157
+ $dateEnd->addHour(1);
158
+ $dateStart = clone $dateEnd;
159
+ $dateStart->subDay(1);
160
+ break;
161
+
162
+ case '7d':
163
+ // substract 6 days we need to include
164
+ // only today and not hte last one from range
165
+ $dateStart->subDay(6);
166
+ break;
167
+
168
+ case '1m':
169
+ $dateStart->setDay(Mage::getStoreConfig('reports/dashboard/mtd_start'));
170
+ break;
171
+
172
+ case 'custom':
173
+ $dateStart = $customStart ? $customStart : $dateEnd;
174
+ $dateEnd = $customEnd ? $customEnd : $dateEnd;
175
+ break;
176
+
177
+ case '1y':
178
+ case '2y':
179
+ $startMonthDay = explode(',', Mage::getStoreConfig('reports/dashboard/ytd_start'));
180
+ $startMonth = isset($startMonthDay[0]) ? (int)$startMonthDay[0] : 1;
181
+ $startDay = isset($startMonthDay[1]) ? (int)$startMonthDay[1] : 1;
182
+ $dateStart->setMonth($startMonth);
183
+ $dateStart->setDay($startDay);
184
+ if ($range == '2y') {
185
+ $dateStart->subYear(1);
186
+ }
187
+ break;
188
+ }
189
+
190
+ $dateStart->setTimezone('Etc/UTC');
191
+ $dateEnd->setTimezone('Etc/UTC');
192
+
193
+ if ($returnObjects) {
194
+ return array($dateStart, $dateEnd);
195
+ } else {
196
+ return array('from' => $dateStart, 'to' => $dateEnd, 'datetime' => true);
197
+ }
198
+ }
199
+
200
+ /**
201
+ * Retrieve query for attribute with timezone conversion
202
+ *
203
+ * @param string $range
204
+ * @param string $attribute
205
+ * @param mixed $from
206
+ * @param mixed $to
207
+ * @return string
208
+ */
209
+ protected function _getTZRangeOffsetExpression($range, $attribute, $from = null, $to = null)
210
+ {
211
+ return str_replace(
212
+ '{{attribute}}',
213
+ Mage::getResourceModel('reports/report_product_viewed')
214
+ ->getStoreTZOffsetQuery(array('source_table' => $this->getTable('reports/event')), $attribute, $from, $to),
215
+ $this->_getRangeExpression($range)
216
+ );
217
+ }
218
+
219
+ /**
220
+ * Get range expression
221
+ *
222
+ * @param string $range
223
+ * @return Zend_Db_Expr
224
+ */
225
+ protected function _getRangeExpression($range)
226
+ {
227
+ switch ($range) {
228
+ case '24h':
229
+ $expression = $this->getConnection()->getConcatSql(array(
230
+ $this->getConnection()->getDateFormatSql('{{attribute}}', '%Y-%m-%d %H:'),
231
+ $this->getConnection()->quote('00')
232
+ ));
233
+ break;
234
+ case '7d':
235
+ case '1m':
236
+ $expression = $this->getConnection()->getDateFormatSql('{{attribute}}', '%Y-%m-%d');
237
+ break;
238
+ case '1y':
239
+ case '2y':
240
+ case 'custom':
241
+ default:
242
+ $expression = $this->getConnection()->getDateFormatSql('{{attribute}}', '%Y-%m');
243
+ break;
244
+ }
245
+
246
+ return $expression;
247
+ }
248
+
249
+ function groupByDay()
250
+ {
251
+ $rangeDay = 4;
252
+ $rangeText = '';
253
+ $cont = 0;
254
+ $tmpV = null;
255
+
256
+ foreach ($this->_items as $k => $v) {
257
+ $date = DateTime::createFromFormat('Y-m-d', $v->getRange());
258
+ if ($rangeDay >= $date->format('d')) {
259
+ if ($rangeText == '')
260
+ $rangeText = $v->getRange();
261
+ $cont += $v->getQuantity();
262
+ unset($this->_items[$k]);
263
+ } elseif ($rangeText) {
264
+ if ($rangeText != $tmpV->getRange())
265
+ $rangeText .= ' to ' . $tmpV->getRange();
266
+ $result = clone $v;
267
+ $result->setQuantity($cont);
268
+ $result->setRange($rangeText);
269
+ $this->_items[$k] = $result;
270
+ do {
271
+ $rangeDay += 4;
272
+ } while ($rangeDay < $date->format('d'));
273
+ $rangeText = $v->getRange();
274
+ $cont = $v->getQuantity();
275
+ } else {
276
+ $rangeText = $v->getRange();
277
+ $cont += $v->getQuantity();
278
+ unset($this->_items[$k]);
279
+ }
280
+
281
+ $tmpV = $v;
282
+ }
283
+ if ($rangeText != $tmpV->getRange())
284
+ $rangeText .= ' to ' . $tmpV->getRange();
285
+ $result = clone $v;
286
+ $result->setQuantity($cont);
287
+ $result->setRange($rangeText);
288
+ $this->_items[$k+1] = $result;
289
+ }
290
+ }
app/code/community/Magjah/Dash/controllers/Adminhtml/Dashboard/IndexController.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Created by PhpStorm.
5
+ * User: jhernandez
6
+ * Date: 8/25/14
7
+ * Time: 6:22 PM
8
+ */
9
+ class Magjah_Dash_Adminhtml_DashBoard_IndexController extends Mage_Adminhtml_Controller_Action
10
+ {
11
+ protected $allcodes = array(
12
+ '0' => 'sales/report_order',
13
+ '1' => 'sales/report_bestsellers',
14
+ );
15
+ /* protected function _construct()
16
+ {
17
+ $this->setUsedModuleName('Magjah_Dash');
18
+ parent
19
+ }*/
20
+
21
+
22
+
23
+ public function indexAction()
24
+ {
25
+ try {
26
+ foreach ($this->allcodes as $collectionName) {
27
+ Mage::getResourceModel($collectionName)->aggregate();
28
+ }
29
+ } catch (Mage_Core_Exception $e) {
30
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
31
+ } catch (Exception $e) {
32
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Unable to refresh lifetime statistics.'));
33
+ Mage::logException($e);
34
+ }
35
+ $this->_title($this->__('Dash'))
36
+ ->_title($this->__('Customer Orders Product'));
37
+ $this->loadLayout();
38
+ $this->_setActiveMenu('magjah/dash');
39
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true)
40
+ ->setContainerCssClass('sales-orderfraud');
41
+
42
+ $this->_addContent(
43
+ $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain')
44
+ );
45
+ $this->renderLayout();
46
+ }
47
+
48
+ public function gridcustomerAction()
49
+ {
50
+ $this->getResponse()->setBody(
51
+ $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridcustomer_grid')->toHtml()
52
+ );
53
+ }
54
+
55
+ public function orderAction()
56
+ {
57
+ $this->_initOrder();
58
+ $this->getResponse()->setBody(
59
+ $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridorder_item')->toHtml()
60
+ )->setHeader('Content-type', ' text/html')->setHttpResponseCode(200);
61
+ }
62
+
63
+ public function customerAction()
64
+ {
65
+ $this->_initCustomer();
66
+ $this->getResponse()->setBody(
67
+ $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridcustomer_item')->toHtml()
68
+ )->setHeader('Content-type', ' text/html')->setHttpResponseCode(200);
69
+ }
70
+
71
+ public function customerOrdersAction()
72
+ {
73
+ $this->_initCustomer();
74
+ $this->getResponse()->setBody(
75
+ $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridcustomer_orders')->toHtml()
76
+ )->setHeader('Content-type', ' text/html')->setHttpResponseCode(200);
77
+ }
78
+
79
+ public function productAction()
80
+ {
81
+ $this->_initProduct();
82
+ $this->getResponse()->setBody(
83
+ $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridproduct_item')->toHtml()
84
+ )->setHeader('Content-type', ' text/html')->setHttpResponseCode(200);
85
+ }
86
+
87
+ /**
88
+ * Initialize order model instance
89
+ *
90
+ * @return Mage_Sales_Model_Order || false
91
+ */
92
+ protected function _initOrder()
93
+ {
94
+ $id = $this->getRequest()->getParam('id');
95
+ $order = Mage::getModel('sales/order')->load($id);
96
+
97
+ Mage::register('sales_order', $order);
98
+ Mage::register('current_order', $order);
99
+ return $order;
100
+ }
101
+
102
+ protected function _initCustomer($idFieldName = 'id')
103
+ {
104
+
105
+ $customerId = (int)$this->getRequest()->getParam($idFieldName);
106
+ $customer = Mage::getModel('customer/customer');
107
+
108
+ if ($customerId) {
109
+ $customer->load($customerId);
110
+ }
111
+
112
+ Mage::register('current_customer', $customer);
113
+ return $this;
114
+ }
115
+
116
+ protected function _initProduct($idFieldName = 'id')
117
+ {
118
+ $productId = (int)$this->getRequest()->getParam($idFieldName);
119
+ $product = Mage::getModel('catalog/product');
120
+
121
+ if ($productId) {
122
+ $product->load($productId);
123
+ }
124
+
125
+ Mage::register('current_product', $product);
126
+ Mage::register('product', $product);
127
+ return $this;
128
+ }
129
+
130
+ public function ajaxBlockAction()
131
+ {
132
+ $output = '';
133
+ $blockTab = $this->getRequest()->getParam('block');
134
+ if (in_array($blockTab, array('tab_orders', 'tab_amounts', 'tab_products', 'tab_customers','tab_customersorders','tab_productsorders'))) {
135
+ $output = $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_' . $blockTab)->toHtml();
136
+ }
137
+ $this->getResponse()->setBody($output);
138
+ return;
139
+ }
140
+
141
+ public function gridorderAction()
142
+ {
143
+ $this->getResponse()->setBody(
144
+ $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridorder_grid')->toHtml()
145
+ );
146
+ }
147
+
148
+ public function gridproductAction()
149
+ {
150
+ $this->getResponse()->setBody(
151
+ $this->getLayout()->createBlock('magjah_dash/adminhtml_dash_dashmain_gridproduct_grid')->toHtml()
152
+ );
153
+ }
154
+
155
+ /**
156
+ * Check the permission to run it
157
+ *
158
+ * @return boolean
159
+ */
160
+ protected function _isAllowed()
161
+ {
162
+ return Mage::getSingleton('admin/session')->isAllowed('magjah_dash/dash');
163
+ }
164
+
165
+ }
166
+
167
+ ?>
app/code/community/Magjah/Dash/etc/adminhtml.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <menu>
4
+ <magjah translate="title" module="magjah_dash">
5
+ <title>Magjah</title>
6
+ <sort_order>1000</sort_order>
7
+ <children>
8
+ <dash translate="title" module="magjah_dash">
9
+ <title>Customs Dashboard</title>
10
+ <action>adminhtml/dashboard_index</action>
11
+ <sort_order>50</sort_order>
12
+ </dash>
13
+ </children>
14
+ </magjah>
15
+ </menu>
16
+ <acl>
17
+ <resources>
18
+ <admin>
19
+ <children>
20
+ <magjah_dash translate="title" module="magjah_dash">
21
+ <title>Magjah</title>
22
+ <sort_order>65</sort_order>
23
+ <children>
24
+ <dash translate="title">
25
+ <title>Customs Dashboard</title>
26
+ <sort_order>0</sort_order>
27
+ </dash>
28
+ </children>
29
+ </magjah_dash>
30
+ <system>
31
+ <children>
32
+ <config>
33
+ <children>
34
+ <magjah_dash translate="title" module="magjah_dash">
35
+ <title>News Management</title>
36
+ </magjah_dash>
37
+ </children>
38
+ </config>
39
+ </children>
40
+ </system>
41
+ </children>
42
+ </admin>
43
+ </resources>
44
+ </acl>
45
+ </config>
app/code/community/Magjah/Dash/etc/config.xml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Magjah_Dash>
4
+ <version>0.1.0</version>
5
+ </Magjah_Dash>
6
+ </modules>
7
+ <global>
8
+ <helpers>
9
+ <magjah_dash>
10
+ <class>Magjah_Dash_Helper</class>
11
+ </magjah_dash>
12
+ </helpers>
13
+ <blocks>
14
+ <magjah_dash>
15
+ <class>Magjah_Dash_Block</class>
16
+ </magjah_dash>
17
+ </blocks>
18
+ <models>
19
+ <magjah_dash>
20
+ <class>Magjah_Dash_Model</class>
21
+ <resourceModel>magjah_dash_resource</resourceModel>
22
+ </magjah_dash>
23
+ <magjah_dash_resource>
24
+ <class>Magjah_Dash_Model_Resource</class>
25
+ </magjah_dash_resource>
26
+ </models>
27
+ </global>
28
+ <admin>
29
+ <routers>
30
+ <adminhtml>
31
+ <args>
32
+ <modules>
33
+ <magjah_dash before="Mage_Adminhtml">Magjah_Dash_Adminhtml</magjah_dash>
34
+ </modules>
35
+ </args>
36
+ </adminhtml>
37
+ </routers>
38
+ </admin>
39
+ <adminhtml>
40
+ <layout>
41
+ <updates>
42
+ <dash>
43
+ <file>dash.xml</file>
44
+ </dash>
45
+ </updates>
46
+ </layout>
47
+ </adminhtml>
48
+
49
+ </config>
app/design/adminhtml/default/default/layout/dash.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addCss"><name>dash.css</name></action>
6
+ <action method="addJs"><name>dash/function.js</name></action>
7
+ </reference>
8
+ </default>
9
+ </layout>
app/design/adminhtml/default/default/template/dash/dashmain.phtml ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (is_array($this->getChild('diagrams')->getTabsIds())) : ?>
2
+ <script type="text/javascript">
3
+ //<![CDATA[
4
+ function changeDiagramsPeriod(periodObj) {
5
+ periodParam = periodObj.value ? 'period/' + periodObj.value + '/' : '';
6
+ <?php foreach ($this->getChild('diagrams')->getTabsIds() as $tabId): ?>
7
+ <?php if ($tabId!='summary'):?>
8
+ ajaxBlockParam = 'block/tab_<?php echo $tabId ?>/';
9
+ ajaxBlockUrl = '<?php echo $this->getUrl('*/*/ajaxBlock', array('_current' => true, 'block' => '', 'period' => '')) ?>' + ajaxBlockParam + periodParam;
10
+ new Ajax.Request(ajaxBlockUrl, {
11
+ parameters: {isAjax: 'true', form_key: FORM_KEY},
12
+ onSuccess: function(transport) {
13
+ tabContentElementId = '<?php echo $this->getChild('diagrams')->getId() ?>_<?php echo $tabId ?>_content';
14
+ try {
15
+ if (transport.responseText.isJSON()) {
16
+ var response = transport.responseText.evalJSON()
17
+ if (response.error) {
18
+ alert(response.message);
19
+ }
20
+ if(response.ajaxExpired && response.ajaxRedirect) {
21
+ setLocation(response.ajaxRedirect);
22
+ }
23
+ } else {
24
+ $(tabContentElementId).update(transport.responseText);
25
+ }
26
+ }
27
+ catch (e) {
28
+ $(tabContentElementId).update(transport.responseText);
29
+ }
30
+ }
31
+ });
32
+ <?php endif;?>
33
+ <?php endforeach; ?>
34
+
35
+ }
36
+ //]]>
37
+ </script>
38
+ <?php endif; ?>
39
+ <div class="content-header">
40
+ <table cellspacing="0">
41
+ <tr>
42
+ <td>
43
+ <h3 class="icon-head head-online-visitors"><?php echo Mage::helper('magjah_dash')->__('Customer, Orders, Products') ?></h3>
44
+ </td>
45
+ </tr>
46
+ </table>
47
+ </div>
48
+ <div id="loading-mask" style="display:none">
49
+ <p class="loader" id="loading_mask_loader"><img src="<?php echo $this->getSkinUrl('images/ajax-loader-tr.gif') ?>"
50
+ alt="<?php echo Mage::helper('adminhtml')->__('Loading...') ?>"/><br/><?php echo Mage::helper('adminhtml')->__('Please wait...') ?>
51
+ </p>
52
+ </div>
53
+ <div class="entry-edit gridContainerLeft">
54
+ <div class="entry-edit">
55
+ <div class="entry-edit-head title">
56
+ <h4 class="icon-head head-account"><?php echo Mage::helper('sales')->__('Customers') ?></h4>
57
+ </div>
58
+ <div class="box">
59
+ <?php echo $this->getChildHtml('gridcustomer') ?>
60
+ </div>
61
+ </div>
62
+ <div class="entry-edit">
63
+ <div class="entry-edit-head title">
64
+ <h4 class="icon-head head-account"><?php echo Mage::helper('sales')->__('Orders') ?></h4>
65
+ </div>
66
+ <div class="box">
67
+ <?php echo $this->getChildHtml('gridorder') ?>
68
+ </div>
69
+ </div>
70
+ <div class="entry-edit">
71
+ <div class="entry-edit-head title">
72
+ <h4 class="icon-head head-account"><?php echo Mage::helper('sales')->__('Products') ?></h4>
73
+ </div>
74
+ <div class="box">
75
+ <?php echo $this->getChildHtml('gridproduct') ?>
76
+ <?php $topProductSellers = $this->bestSellers();
77
+ $cantBest = $topProductSellers->count();
78
+ ?>
79
+ <?php if ($cantBest): ?>
80
+ <div class="box best-selling">
81
+ <h3>Best Selling Products</h3>
82
+ <table border="0" cellspacing="2" style="text-align: center">
83
+ <tbody>
84
+ <?php $counter = 0;
85
+ foreach ($topProductSellers as $product):
86
+ if($product->getSold_quantity()){
87
+ ?>
88
+ <?php if ($counter % 2 == 0): ?>
89
+ <tr class="<?php echo $counter % 4 ? 'even' : 'odd'; ?>"><?php endif ?>
90
+ <td>
91
+ <span style="text-align: centert"><?php echo (int)$product->getSold_quantity()?> Sold</span><br />
92
+ <a href="#" onclick="showUrlDetails('<?php echo $this->getUrl('*/*/product', array('_current'=> true,'id'=>$product->getId() ))?>');"><img class="product-img"
93
+ src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(99); ?>"
94
+ alt="<?php echo $this->stripTags($this->getImageLabel($product, 'small_image'), null, true) ?>"
95
+ width="95" border="0"/></a>
96
+
97
+ <div class="product-description">
98
+ <p>
99
+ <a href="#" onclick="showUrlDetails('<?php echo $this->getUrl('*/*/product', array('_current'=> true,'id'=>$product->getId() ))?>');"><?php echo $this->stripTags($product->getName(), null, true); ?></a>
100
+ </p>
101
+ </div>
102
+ </td>
103
+ <?php if ($counter++ % 2): ?></tr><?php endif ;
104
+ }?>
105
+ <?php endforeach; ?>
106
+ </tbody>
107
+ </table>
108
+ </div>
109
+ <?php endif ?>
110
+ </div>
111
+ </div>
112
+ </div>
113
+
114
+ <div class="entry-edit gridContainerRight">
115
+ <div id="show-result">
116
+ <?php echo $this->getChildHtml('diagrams') ?>
117
+ <?php if (is_array($this->getChild('diagrams')->getTabsIds())) : ?>
118
+ <div id="diagram_tab_content"></div>
119
+ <?php endif; ?>
120
+ </div>
121
+ </div>
app/design/adminhtml/default/default/template/dash/dashmain/graph.phtml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <div style="margin:20px;">
28
+ <p class="switcher a-right" style="padding:5px 10px;"><?php echo $this->__('Select Range') ?>:
29
+ <select name="period" id="order_<?php echo $this->getHtmlId() ?>_period" onchange="changeDiagramsPeriod(this);">
30
+ <?php foreach ($this->helper('magjah_dash/data')->getDatePeriods() as $_value=>$_label): ?>
31
+ <?php if(in_array($_value, array('custom'))) continue; ?>
32
+ <option value="<?php echo $_value ?>" <?php if($this->getRequest()->getParam('period')==$_value): ?> selected="selected"<?php endif; ?>><?php echo $_label ?></option>
33
+ <?php endforeach; ?>
34
+ </select></p><br/>
35
+ <?php
36
+ $_containerStyle = "width:{$this->getWidth()}px;height:{$this->getHeight()}px; margin:0 auto;";
37
+ ?>
38
+ <?php if($this->getCount()): ?>
39
+ <p style="<?php echo $_containerStyle?>"><img src="<?php echo $this->getChartUrl(true) ?>" alt="chart" title="chart" /></p>
40
+ <?php else: ?>
41
+ <p class="a-center" style="<?php echo $_containerStyle?>"><?php echo $this->__('No Data Found') ?></p>
42
+ <?php endif; ?>
43
+ </div>
app/design/adminhtml/default/default/template/dash/dashmain/gridcustomer/item.phtml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category design_conns
16
+ * @package Mage_Conns
17
+ * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
19
+ */
20
+ ?>
21
+ <?php if ($_customer = $this->getCustomer()): ?>
22
+ <div class="entry-edit">
23
+ <div class="entry-edit-head">
24
+ <h4 class="icon-head head-customer-view"><?php echo Mage::helper('customer')->__('Account Information') ?></h4>
25
+ </div>
26
+ <fieldset>
27
+ <table cellspacing="2" class="box-left">
28
+ <tr>
29
+ <td><strong><?php echo $this->__('Prefix:') ?></strong></td>
30
+ <td><?php echo $_customer->getPrefix() ?></td>
31
+ </tr>
32
+ <tr>
33
+ <td><strong><?php echo $this->__('First Name:') ?></strong></td>
34
+ <td><?php echo $_customer->getFirstname() ?></td>
35
+ </tr>
36
+ <tr>
37
+ <td><strong><?php echo $this->__('Middle Name/Initial:') ?></strong></td>
38
+ <td><?php echo $_customer->getMiddlename() ?></td>
39
+ </tr>
40
+ <tr>
41
+ <td><strong><?php echo $this->__('Last Name:') ?></strong></td>
42
+ <td><?php echo $_customer->getLastname() ?></td>
43
+ </tr>
44
+ <tr>
45
+ <td><strong><?php echo $this->__('Suffix:') ?></strong></td>
46
+ <td><?php echo $_customer->getSuffix() ?></td>
47
+ </tr>
48
+ <tr>
49
+ <td><strong><?php echo $this->__('Email:') ?></strong></td>
50
+ <td><?php echo $_customer->getEmail() ?></td>
51
+ </tr>
52
+ <tr>
53
+ <td><strong><?php echo $this->__('Date Of Birth:') ?></strong></td>
54
+ <td><?php echo $_customer->getDob() ?></td>
55
+ </tr>
56
+ </table>
57
+ </fieldset>
58
+ </div>
59
+
60
+ <?php echo $this->getChildHtml('customer_edit_tab_view') ?>
61
+ <?php echo $this->getChildHtml('customer_edit_tab_view_sales') ?>
62
+ <?php echo $this->getChildHtml('dash_dashmain_gridcustomer_accordion') ?>
63
+ <?php elseif ($this->getEmptyText()): ?>
64
+ <div class="empty-text <?php echo $this->getEmptyTextClass() ?>"><?php echo $this->getEmptyText() ?></div>
65
+ <?php endif; ?>
66
+
app/design/adminhtml/default/default/template/dash/dashmain/gridcustomer/orders.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category design_conns
16
+ * @package Mage_Conns
17
+ * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
19
+ */
20
+ ?>
21
+ <?php if ($_customer = $this->getCustomer()): ?>
22
+ <?php echo $this->getChildHtml('dash_dashmain_gridcustomer_accordion') ?>
23
+ <?php elseif ($this->getEmptyText()): ?>
24
+ <div class="empty-text <?php echo $this->getEmptyTextClass() ?>"><?php echo $this->getEmptyText() ?></div>
25
+ <?php endif; ?>
26
+
app/design/adminhtml/default/default/template/dash/dashmain/gridorder/item.phtml ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category design_conns
16
+ * @package Mage_Conns
17
+ * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
18
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
19
+ */
20
+ ?>
21
+ <?php if($_order = $this->getOrder()): ?>
22
+
23
+ <?php $cnt=1 ?>
24
+
25
+
26
+
27
+ <div class="entry-edit" id="toporder-<?php echo $cnt ?>" style="margin:3px 0 20px 0;">
28
+ <?php if ($_order->getEmailSent()):
29
+ $_email=$this->__('Order confirmation email sent');
30
+ else:
31
+ $_email=$this->__('Order confirmation email not sent');
32
+ endif; ?>
33
+ <div class="entry-edit-head title">
34
+ <h4 class="icon-head head-account"><?php echo Mage::helper('sales')->__('Order # %s', $_order->getRealOrderId()) ?> (<?php echo $_email ?>)</h4>
35
+ </div>
36
+
37
+ <div class="box">
38
+
39
+ <div class="col3-set">
40
+
41
+ <?php /* @var $_order Mage_Sales_Model_Order */ ?>
42
+ <!--Order Information-->
43
+ <div class="entry-edit col-1">
44
+ <div class="entry-edit-head">
45
+ <h4 class="icon-head head-account">Order Information</h4>
46
+ </div>
47
+ <div class="fieldset">
48
+ <table cellspacing="0" class="form-list">
49
+ <tr>
50
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Conns Invoice Id') ?></label></td>
51
+ <td><strong><?php echo $_order->getConnsInvoiceId(); ?></strong></td>
52
+ </tr>
53
+ <tr>
54
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Date Ordered') ?></label></td>
55
+ <td><strong><?php echo $this->formatDate($_order->getCreatedAt(), 'medium', true) ?></strong></td>
56
+ </tr>
57
+ <tr>
58
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Shipping Method') ?></label></td>
59
+ <td>
60
+ <?php if ($_order->getTracksCollection()->count()) : ?>
61
+ <a href="#" id="linkId" onclick="popWin('<?php echo $this->helper('shipping')->getTrackingPopupUrlBySalesModel($_order->getId()) ?>','trackorder','width=800,height=600,resizable=yes,scrollbars=yes')" title="<?php echo $this->__('Track the order') ?>"><?php echo $this->__('Track the order') ?></a><br />
62
+ <?php endif; ?>
63
+ <?php if ($_order->getShippingDescription()): ?>
64
+ <strong><?php echo $_order->getShippingDescription() ?></strong>
65
+ <?php endif; ?>
66
+ </td>
67
+ </tr>
68
+ <tr>
69
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Payment Details') ?></label></td>
70
+ <td>
71
+ <?php echo $this->getPaymentHtml($_order) ?>
72
+ <div><?php echo Mage::helper('sales')->__('Order was placed using %s', $_order->getOrderCurrencyCode()) ?></div>
73
+ </td>
74
+ </tr>
75
+ <?php if($_order->getRelationParentId()): ?>
76
+ <tr>
77
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Link to the previous order') ?></label></td>
78
+ <td><a href="<?php echo $this->getViewUrl($_order->getRelationParentId()) ?>"><?php echo $_order->getRelationParentRealId() ?></a></td>
79
+ </tr>
80
+ <?php endif; ?>
81
+ </table>
82
+ </div>
83
+ </div>
84
+
85
+ <!--Account Information-->
86
+ <div class="entry-edit col-2">
87
+ <div class="entry-edit-head">
88
+ <h4 class="icon-head head-account"><?php echo Mage::helper('sales')->__('Account Information') ?></h4>
89
+ </div>
90
+ <div class="fieldset">
91
+ <div class="hor-scroll">
92
+ <table cellspacing="0" class="form-list">
93
+ <?php if ($_order->getCustomerId() > 0): ?>
94
+ <tr>
95
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Customer ID') ?></label></td>
96
+ <td><a href="<?php echo Mage::getUrl('adminhtml/customer/edit', array('id' => $_order->getCustomerId())) ?>"><strong><?php echo $this->htmlEscape($_order->getCustomerId()) ?></strong></a></td>
97
+ </tr>
98
+ <?php endif; ?>
99
+ <tr>
100
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Customer Name') ?></label></td>
101
+ <td><strong><?php echo $this->htmlEscape($_order->getCustomerName()) ?></strong></td>
102
+ </tr>
103
+ <tr>
104
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Email') ?></label></td>
105
+ <td><a href="mailto:<?php echo $_order->getCustomerEmail() ?>"><strong><?php echo $_order->getCustomerEmail() ?></strong></a></td>
106
+ </tr>
107
+ <tr>
108
+ <td class="label"><label><?php echo Mage::helper('sales')->__('IP address') ?></label></td>
109
+ <td><strong><?php echo $this->htmlEscape($_order->getRemoteIp()) ?></strong></td>
110
+ </tr>
111
+ <?php if ($_groupName=$this->getCustomerGroupName()) : ?>
112
+ <tr>
113
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Customer Group') ?></label></td>
114
+ <td><strong><?php echo $_groupName ?></strong></td>
115
+ </tr>
116
+ <?php endif; ?>
117
+ </table>
118
+ </div>
119
+ </div>
120
+ </div>
121
+
122
+ </div>
123
+ </div>
124
+ <!-- ===== END Status Block ===== -->
125
+
126
+ <div class="clear"></div>
127
+ </div><!-- //.col3-set -->
128
+
129
+ <!-- ===== Start Items Block ===== -->
130
+ <div class="items">
131
+ <div class="entry-edit">
132
+ <div class="entry-edit-head">
133
+ <h4 class="icon-head head-products"><?php echo Mage::helper('sales')->__('Items Ordered') ?></h4>
134
+ </div>
135
+ </div>
136
+ <div class="grid np">
137
+ <div class="hor-scroll">
138
+ <table cellspacing="0" class="data order-tables">
139
+ <col />
140
+ <col width="1" />
141
+ <col width="1" />
142
+ <col width="1" />
143
+ <col width="1" />
144
+ <col width="1" />
145
+ <col width="1" />
146
+ <col width="1" />
147
+ <col width="1" />
148
+ <thead>
149
+ <tr class="headings">
150
+ <th><?php echo $this->helper('sales')->__('Product') ?></th>
151
+ <th><?php echo $this->helper('sales')->__('SKU') ?></th>
152
+ <th><?php echo $this->helper('sales')->__('Original Price') ?></th>
153
+ <th><?php echo $this->helper('sales')->__('Price') ?></th>
154
+ <th><?php echo $this->helper('sales')->__('Qty') ?></th>
155
+ <th><?php echo $this->helper('sales')->__('Subtotal') ?></th>
156
+ <th><?php echo $this->helper('sales')->__('Tax Amount') ?></th>
157
+ <th><?php echo $this->helper('sales')->__('Discount Amount') ?></th>
158
+ <th class="last"><?php echo $this->helper('sales')->__('Row Total') ?></th>
159
+ </tr>
160
+ </thead>
161
+ <tbody>
162
+ <?php $_items = $_order->getItemsCollection() ?>
163
+ <?php $i=0;foreach ($_items as $_item):$i++ ?>
164
+ <?php /* @var $_item Mage_Sales_Model_Order_Item */ ?>
165
+ <?php $this->setPriceDataObject($_item) ?>
166
+ <tr class="<?php echo ($i%2==0)?'even':'odd' ?>">
167
+ <td class="name"><?php echo $_item->getName() ?></td>
168
+ <td><?php echo $_item->getSku() ?></td>
169
+ <td class="price"><?php echo $this->displayPriceAttribute('original_price', $_order) ?></td>
170
+ <td class="price"><?php echo $this->displayPriceAttribute('price', $_order) ?></td>
171
+ <td class="a-center"><?php echo $_item->getQtyOrdered()*1 ?></td>
172
+ <td class="price"><?php echo $this->displayPriceAttribute('row_total', $_order) ?></td>
173
+ <td class="price"><?php echo $this->displayPriceAttribute('tax_amount', $_order) ?></td>
174
+ <td class="price"><?php echo $this->displayPriceAttribute('discount_amount', $_order) ?></td>
175
+ <td class="last price">
176
+ <?php echo $this->displayPrices(
177
+ $_item->getBaseRowTotal()-$_item->getBaseDiscountAmount()+$_item->getBaseTaxAmount(),
178
+ $_item->getRowTotal()-$_item->getDiscountAmount()+$_item->getTaxAmount()
179
+ ) ?>
180
+ </td>
181
+ </tr>
182
+ <?php endforeach; ?>
183
+ </tbody>
184
+ </table>
185
+ </div>
186
+ </div>
187
+ </div>
188
+ <!-- ===== END Items Block ===== -->
189
+
190
+ <div class="col3-set">
191
+
192
+ <?php /* @var $_order Mage_Sales_Model_Order */ ?>
193
+ <!--Billing Address-->
194
+ <?php if($_order->getBillingAddress()):?>
195
+ <div class="entry-edit col-1">
196
+ <div class="entry-edit-head">
197
+ <h4 class="icon-head head-billing-address"><?php echo Mage::helper('sales')->__('Billing Address') ?></h4>
198
+ </div>
199
+ <div class="fieldset">
200
+ <div class="hor-scroll">
201
+ <address><?php echo $_order->getBillingAddress()->getFormated(true) ?></address>
202
+ </div>
203
+ </div>
204
+ </div>
205
+ <?php endif; ?>
206
+ <div class="entry-edit col-2">
207
+ <?php if ($_order->getShippingAddress()): ?>
208
+ <!--Shipping Address-->
209
+ <div class="entry-edit-head">
210
+ <h4 class="icon-head head-shipping-address"><?php echo Mage::helper('sales')->__('Shipping Address') ?></h4>
211
+ </div>
212
+ <div class="fieldset">
213
+ <div class="hor-scroll">
214
+ <address><?php echo $_order->getShippingAddress()->getFormated(true) ?></address>
215
+ </div>
216
+ </div>
217
+ <?php endif; ?>
218
+ </div>
219
+
220
+ <!-- ===== Start Totals Block ===== -->
221
+ <div class="entry-edit col-3">
222
+ <div class="entry-edit-head"><h4>Order Totals</h4></div>
223
+ <div class="order-totals">
224
+ <?php
225
+ $_source = $this->getSource();
226
+ $totlaBlock = $this->getTotalBLock($_order);
227
+
228
+ ?>
229
+ <table cellspacing="0" width="100%">
230
+ <col />
231
+ <col width="1" />
232
+ <?php $_totals = $totlaBlock->getTotals('')?>
233
+ <?php if ($_totals):?>
234
+ <tbody>
235
+ <?php foreach ($_totals as $_code => $_total): ?>
236
+ <?php if ($_total->getBlockName()): ?>
237
+ <?php echo $totlaBlock->getChildHtml($_total->getBlockName(), false); ?>
238
+ <?php else:?>
239
+ <tr class="<?php echo $_code?>">
240
+ <td <?php echo $totlaBlock->getLabelProperties()?> class="label">
241
+ <?php if ($_total->getStrong()):?>
242
+ <strong><?php echo $_total->getLabel()?></strong>
243
+ <?php else:?>
244
+ <?php echo $_total->getLabel()?>
245
+ <?php endif?>
246
+ </td>
247
+ <?php if ($_total->getStrong()):?>
248
+ <td <?php echo $totlaBlock->getValueProperties()?> class="emph">
249
+ <strong><?php echo $totlaBlock->formatValue($_total) ?></strong>
250
+ <?php else:?>
251
+ <td <?php echo $totlaBlock->getValueProperties()?>>
252
+ <?php echo $totlaBlock->formatValue($_total) ?>
253
+ <?php endif?>
254
+ </td>
255
+ </tr>
256
+ <?php endif?>
257
+ <?php endforeach?>
258
+ </tbody>
259
+ <?php endif?>
260
+
261
+ <?php $_totals = $totlaBlock->getTotals('footer')?>
262
+ <?php if ($_totals):?>
263
+ <tfoot>
264
+ <?php foreach ($totlaBlock->getTotals('footer') as $_code => $_total): ?>
265
+ <?php if ($_total->getBlockName()): ?>
266
+ <?php echo $totlaBlock->getChildHtml($_total->getBlockName(), false); ?>
267
+ <?php else:?>
268
+ <tr class="<?php echo $_code?>">
269
+ <td <?php echo $totlaBlock->getLabelProperties()?> class="label">
270
+ <strong><?php echo $_total->getLabel()?></strong>
271
+ </td>
272
+ <td <?php echo $totlaBlock->getValueProperties()?> class="emph">
273
+ <strong><?php echo $totlaBlock->formatValue($_total) ?></strong>
274
+ </td>
275
+ </tr>
276
+ <?php endif?>
277
+ <?php endforeach?>
278
+ </tfoot>
279
+ <?php endif?>
280
+ </table>
281
+ </div>
282
+ </div>
283
+ <!-- ===== END Totals Block ===== -->
284
+
285
+ <div class="clear"></div>
286
+ </div><!-- //.col3-set -->
287
+
288
+ </div><!-- //.box -->
289
+
290
+ </div>
291
+
292
+ <?php elseif ($this->getEmptyText()): ?>
293
+ <div class="empty-text <?php echo $this->getEmptyTextClass() ?>"><?php echo $this->getEmptyText() ?></div>
294
+ <?php endif; ?>
295
+
app/design/adminhtml/default/default/template/dash/dashmain/gridproduct/item.phtml ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if ($_product = $this->getProduct()):
2
+ $_helper = $this->helper('catalog/output');
3
+ $_taxHelper = $this->helper('tax');
4
+ $_coreHelper = $this->helper('core');
5
+ $_price = $_taxHelper->getPrice($_product, $_product->getPrice());
6
+ ?>
7
+
8
+ <div class="entry-edit" id="toporder" style="margin:3px 0 20px 0;">
9
+ <div class="entry-edit-head">
10
+ <h4 class="icon-head head-account">
11
+ Information1111 <?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h4>
12
+ </div>
13
+ <fieldset>
14
+ <div class="box-left"> <?php echo $this->getChildHtml('gridproduct_media') ?></div>
15
+ <table class="box-right" cellspacing="2">
16
+ <tr>
17
+ <td><strong><?php echo Mage::helper('catalog')->__('Name') ?></strong></td>
18
+ <td><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></td>
19
+ </tr>
20
+ <tr>
21
+ <td><strong><?php echo Mage::helper('catalog')->__('Description') ?></strong></td>
22
+ <td><?php echo $_helper->productAttribute($_product, $_product->getDescription(), 'description') ?></td>
23
+ </tr>
24
+ <tr>
25
+ <td><strong><?php echo Mage::helper('catalog')->__('SKU') ?></strong></td>
26
+ <td><?php echo $_helper->productAttribute($_product, $_product->getSKU(), 'SKU') ?></td>
27
+ </tr>
28
+ <tr>
29
+ <td><strong><?php echo Mage::helper('catalog')->__('Weight') ?></strong></td>
30
+ <td><?php echo $_helper->productAttribute($_product, $_product->getWeight(), 'Weight') ?></td>
31
+ </tr>
32
+ <tr>
33
+ <td><strong><?php echo Mage::helper('catalog')->__('Status') ?></strong></td>
34
+ <td><?php echo Mage_Catalog_Model_Product_Status::getOptionText($_product->getStatus()) ?></td>
35
+ </tr>
36
+ <tr>
37
+ <td><strong><?php echo Mage::helper('catalog')->__('URL Key') ?></strong></td>
38
+ <td><?php echo $_helper->productAttribute($_product, $_product->getUrl_key(), 'url_key') ?></td>
39
+ </tr>
40
+ <tr>
41
+ <td><strong><?php echo Mage::helper('catalog')->__('Visibility') ?></strong></td>
42
+ <td><?php echo Mage_Catalog_Model_Product_Visibility::getOptionText($_product->getVisibility()) ?></td>
43
+ </tr>
44
+ <tr>
45
+ <td><strong><?php echo Mage::helper('catalog')->__('Price') ?></strong></td>
46
+ <td><?php echo $_coreHelper->currency($_price, true, true) ?></td>
47
+ </tr>
48
+ <tr>
49
+ <td><strong><?php echo Mage::helper('catalog')->__('Availability') ?></strong></td>
50
+ <td><?php if ($_product->getIsInStock()): ?>
51
+ <p class="availability in-stock"><span><?php echo $this->__('In stock') ?></span></p>
52
+ <?php else: ?>
53
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span>
54
+ </p>
55
+ <?php endif; ?></td>
56
+ </tr>
57
+ <tr>
58
+ <td><strong><?php echo Mage::helper('catalog')->__('Qty') ?></strong></td>
59
+ <td><?php echo round($_product->getStockItem()->getQty(),0); ?></td>
60
+ </tr>
61
+ <tr>
62
+ <td><strong><?php echo Mage::helper('catalog')->__('Category') ?></strong></td>
63
+ <td><?php echo $this->getCategories(); ?></td>
64
+ </tr>
65
+ </table>
66
+
67
+ </fieldset>
68
+ <div class="clear"></div>
69
+ </div><!-- //.col3-set -->
70
+ <?php elseif ($this->getEmptyText()): ?>
71
+ <div class="empty-text <?php echo $this->getEmptyTextClass() ?>"><?php echo $this->getEmptyText() ?></div>
72
+ <?php endif; ?>
73
+
app/design/adminhtml/default/default/template/dash/dashmain/gridproduct/media.phtml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Product media data template
29
+ *
30
+ * @see Mage_Catalog_Block_Product_View_Media
31
+ */
32
+ ?>
33
+ <?php
34
+ $_product = $this->getProduct();
35
+ $_helper = $this->helper('catalog/output');
36
+ ?>
37
+ <?php if ($_product->getImage() != 'no_selection' && $_product->getImage()): ?>
38
+ <p class="product-image product-image-zoom">
39
+ <?php
40
+ $_img = '<img id="image" src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(265).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
41
+ echo $_helper->productAttribute($_product, $_img, 'image');
42
+ ?>
43
+ </p>
44
+ <script type="text/javascript">
45
+ //<![CDATA[
46
+ Event.observe(window, 'load', function() {
47
+ product_zoom = new Product.Zoom('image', 'track', 'handle', 'zoom_in', 'zoom_out', 'track_hint');
48
+ });
49
+ //]]>
50
+ </script>
51
+ <?php else: ?>
52
+ <p class="product-image">
53
+ <?php
54
+ $_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'image')->resize(265).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" />';
55
+ echo $_helper->productAttribute($_product, $_img, 'image');
56
+ ?>
57
+ </p>
58
+ <?php endif; ?>
59
+ <?php if (count($this->getGalleryImages()) > 0): ?>
60
+ <div class="more-views">
61
+ <h2><?php echo $this->__('More Views') ?></h2>
62
+ <ul>
63
+ <?php foreach ($this->getGalleryImages() as $_image): ?>
64
+ <li>
65
+ <a href="#" onclick="popWin('<?php echo $this->getGalleryUrl($_image) ?>', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize(56); ?>" width="56" height="56" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
66
+ </li>
67
+ <?php endforeach; ?>
68
+ </ul>
69
+ </div>
70
+ <?php endif; ?>
app/design/adminhtml/default/default/template/dash/dashmain/summary.phtml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $customerResult=$this->getResumeCustomer();?>
2
+ <?php $productResult=$this->getResumeProduct();?>
3
+ <?php $orderResult=$this->getResumeOrder();?>
4
+ <div class="entry-edit" id="toporder" style="margin:3px 0 20px 0;">
5
+ <table style="width: 100%">
6
+ <tr>
7
+ <td style="width: 33.33%">
8
+ <div class="entry-edit-head">
9
+ <h4 class="icon-head head-account">Customer</h4>
10
+ </div>
11
+ <fieldset>
12
+ <table cellspacing="2">
13
+ <tr>
14
+ <td><strong><?php echo Mage::helper('catalog')->__('Total') ?>:</strong></td>
15
+ <td class="box-right"><?php echo $customerResult['total']?></td>
16
+ <tr>
17
+ <td><strong><?php echo Mage::helper('catalog')->__('Total this week') ?>:</strong></td>
18
+ <td class="box-right"><?php echo $customerResult['week']?></td>
19
+ </tr>
20
+ <tr>
21
+ <td><strong><?php echo Mage::helper('catalog')->__('% this week with the total') ?>
22
+ :</strong></td>
23
+ <td class="box-right"><?php echo $customerResult['porcent']?>%</td>
24
+ </tr>
25
+ </table>
26
+ </fieldset>
27
+ </td>
28
+ <td>
29
+ <div class="entry-edit-head">
30
+ <h4 class="icon-head head-account">Order</h4>
31
+ </div>
32
+ <fieldset>
33
+ <table cellspacing="2">
34
+ <tr>
35
+ <td><strong><?php echo Mage::helper('catalog')->__('Total') ?>:</strong></td>
36
+ <td class="box-right"><?php echo $orderResult['total']?></td>
37
+ <tr>
38
+ <td><strong><?php echo Mage::helper('catalog')->__('Total this week') ?>:</strong></td>
39
+ <td class="box-right"><?php echo $orderResult['week']?></td>
40
+ </tr>
41
+ <tr>
42
+ <td><strong><?php echo Mage::helper('catalog')->__('% this week with the total') ?>:</strong></td>
43
+ <td class="box-right"><?php echo $orderResult['porcent']?>%</td>
44
+ </tr>
45
+ </table>
46
+ </fieldset>
47
+ </td>
48
+ <td>
49
+ <div class="entry-edit-head">
50
+ <h4 class="icon-head head-account">Product</h4>
51
+ </div>
52
+ <fieldset>
53
+ <table cellspacing="2">
54
+ <tr>
55
+ <td><strong><?php echo Mage::helper('catalog')->__('Total') ?>:</strong></td>
56
+ <td class="box-right"><?php echo $productResult['total']?></td>
57
+ <tr>
58
+ <td><strong><?php echo Mage::helper('catalog')->__('Total this week') ?>:</strong></td>
59
+ <td class="box-right"><?php echo $productResult['week']?></td>
60
+ </tr>
61
+ <tr>
62
+ <td><strong><?php echo Mage::helper('catalog')->__('% this week with the total') ?>
63
+ :</strong></td>
64
+ <td class="box-right"><?php echo $productResult['porcent']?>%</td>
65
+ </tr>
66
+ </table>
67
+ </fieldset>
68
+ </td>
69
+ </table>
70
+ </div>
app/etc/modules/Magjah_Dash.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magjah_Dash>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Magjah_Dash>
8
+ </modules>
9
+ </config>
10
+
11
+
12
+
js/dash/function.js ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function showDetailsOrder1111(obj) {
2
+ winCompare = new Window(
3
+ {
4
+ className: 'magento',
5
+ title: 'Show Details',
6
+ url: obj.href,
7
+ width: 720,
8
+ height: 500,
9
+ minimizable: false,
10
+ maximizable: false,
11
+ showEffectOptions: {
12
+ duration: 0.4
13
+ },
14
+ hideEffectOptions: {
15
+ duration: 0.4
16
+ }
17
+ });
18
+ winCompare.setZIndex(100);
19
+ winCompare.showCenter(true);
20
+ }
21
+ function showDetails(obj) {
22
+ new Ajax.Request(obj.href, {
23
+ method: 'get',
24
+ requestHeaders: {Accept: 'text/html'},
25
+ onSuccess: function (datos) {
26
+ $('show-result').update(datos.responseText)
27
+ }
28
+ });
29
+ }
30
+ function showUrlDetails(url) {
31
+ new Ajax.Request(url, {
32
+ method: 'get',
33
+ requestHeaders: {Accept: 'text/html'},
34
+ onSuccess: function (datos) {
35
+ $('show-result').update(datos.responseText)
36
+ }
37
+ });
38
+ }
39
+
40
+
41
+ function changeStatusCustomer(url) {
42
+ new Ajax.Request(url, {
43
+ method: 'get',
44
+ //requestHeaders: {Accept: 'text/html'},
45
+ onSuccess: function (datos) {
46
+ customerGridJsObject.doFilter()
47
+ }
48
+ });
49
+ }
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>jah_dash</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension provides a dashboard with the three main elements of your store.&#xD;
10
+ Customer, Product and orders.</summary>
11
+ <description>You can see all orders, products, customers, relationships of the three elements, Reported in the same place for Ajax refreshing content.</description>
12
+ <notes>This is stable realase</notes>
13
+ <authors><author><name>Jose A Hernandez</name><user>jalfredo1980</user><email>pepehernandez1980@gmail.com</email></author></authors>
14
+ <date>2015-03-09</date>
15
+ <time>21:20:01</time>
16
+ <contents><target name="magecommunity"><dir name="Magjah"><dir name="Customship"><dir name="Block"><dir name="Adminhtml"><dir name="Ship"><file name="Shipmain.php" hash="918f4a80703c3a2f93bc5727ea971cde"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="1918ea63a7483a53b8e2ebd60ac364aa"/></dir><dir name="Model"><dir name="Carrier"><file name="Shipjah.php" hash="bcdc3de8ada0e89a3fc39e9716d1e6db"/></dir><dir name="Resource"><file name="Condition.php" hash="c8dd528dc4390137f13698b3dc9be9c9"/><dir name="Shiprules"><file name="Collection.php" hash="9c83567975d15b6b06bbf27fded61fdf"/></dir><file name="Shiprules.php" hash="4286d48d41801758574515171261a037"/></dir><file name="Shiprules.php" hash="5abb3a31376e20020900460b05d6f0b2"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ShipController.php" hash="9f0218bcd6990ab4ec928b3f5c88eedb"/></dir><file name="IndexController.php" hash="2ae4c8fc56136ed578ae530fff9c4b59"/></dir><dir name="etc"><file name="adminhtml.xml" hash="098f5e0b7320dd336ec8d0a6471c0061"/><file name="config.xml" hash="f84f4c7112e286fb2d6e61ae5c404c35"/><file name="system.xml" hash="0142e2735ee346a95db5c60ada7b1f27"/></dir><dir name="sql"><dir name="magjah_customship_setup"><file name="install-0.1.0.php" hash="2570f2d809d686d9ea3fa41e48e4881a"/></dir></dir></dir><dir name="Dash"><dir name="Block"><dir name="Adminhtml"><dir name="Dash"><dir name="Dashmain"><file name="Diagrams.php" hash="527fb74b4ad8a078cf2662a948dd9e10"/><file name="Graph.php" hash="8f860766b215f4d7e00ed685d4859534"/><dir name="Gridcustomer"><file name="Accordion.php" hash="59b0c379ac85520e4f7f51a38163df05"/><file name="Grid.php" hash="0842539fcb0abc24a225c1ba406c379a"/><file name="Item.php" hash="fe8f8bf65d2acf46180d7ebf67a9200d"/><file name="Orders.php" hash="10ef4fbfe7c7a604be78f96af3749f45"/><dir name="Render"><file name="Orders.php" hash="5441136a7bec3bb399a57ae166b32a9d"/><file name="Showbutton.php" hash="785b8175add1746affe386aafc3ad0e5"/></dir></dir><file name="Gridcustomer.php" hash="42148285d3f551f780c9fad217336773"/><dir name="Gridorder"><file name="Grid.php" hash="556fab582cb4d8d337996e7aa5d28ef5"/><file name="Item.php" hash="a04b74db34687e7162df65377db5368f"/><dir name="Render"><file name="Showbutton.php" hash="a16a09d422864306d52fcc2755f8da66"/></dir></dir><file name="Gridorder.php" hash="2576b2c48ddbf79b0a3c07b00ed3a1b6"/><dir name="Gridproduct"><file name="Grid.php" hash="3e18eefd719a4e5a210228b6ca0bc9ca"/><file name="Item.php" hash="5f2f299393343c54b3fb13bccc12e004"/><file name="Media.php" hash="23564f4a80d6426e5d2bf37e413e5bb0"/><dir name="Render"><file name="Showbutton.php" hash="ff3ae8b4218ce66a2dcd0e1735902fb3"/></dir></dir><file name="Gridproduct.php" hash="b0dc3ebceeff1d70d1c78c01aa099c73"/><dir name="Tab"><file name="Customers.php" hash="dbb48850a28128f1a8699259bc6cffeb"/><file name="Customersorders.php" hash="03f6f25ba70da3c655eb993d81e97100"/><file name="Orders.php" hash="ed59ab903189753d6e78124c885d8652"/><file name="Products.php" hash="cd90290eeb7c88da242ae9e288e5ea3e"/><file name="Summary.php" hash="240f353dd9d1d6f8f5e44734cb05f586"/></dir></dir><file name="Dashmain.php" hash="4b299798b619edb39c031c1c49173b9c"/></dir></dir></dir><dir name="Helper"><dir name="Dashboard"><file name="Customer.php" hash="97222ace449fcfac349010456c78fac2"/><file name="CustomerOrder.php" hash="b8835517e7ba2e4f4152e9cf8209b8b5"/><file name="Diagrams.php" hash="6d11e88632a44c15823d94916f374e7d"/><file name="Order.php" hash="608c1c6f3a4b517785d18df2a9a54a35"/><file name="Product.php" hash="7b528cb0da0887d8a06a20c0e9033436"/></dir><file name="Data.php" hash="288abb1c21ed95caf1bf96382f1b1c40"/></dir><dir name="Model"><dir name="Resource"><dir name="Customer"><file name="Collection.php" hash="6878e6798bfe57dd22db7088508672dc"/><dir name="Order"><file name="Collection.php" hash="86eb78c6f5ab31c239c98a437a76f8cb"/></dir></dir><file name="Customer.php" hash="a7861054bdf70257f790a67562fc88f5"/><dir name="Order"><file name="Collection.php" hash="ec941bb6768f67cff5b6f0069f754d57"/></dir><file name="Order.php" hash="a5a62e550a0c7be9690d780604a066ba"/><dir name="Product"><file name="Collection.php" hash="a2b485b6dd3811db3b488730fd81999b"/></dir><file name="Product.php" hash="0b04388381c43621f278bc594b39a905"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Dashboard"><file name="IndexController.php" hash="a517ffc83951d330f0fc7869c2fe3913"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="74f90e1a1e2e3439a1c9f0c7528fa211"/><file name="config.xml" hash="61575a40dc3a6fc5d05fa27cefe86f09"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="dash.xml" hash="23199d236a870b524f5813d0e55623e2"/></dir><dir name="template"><dir name="dash"><dir name="dashmain"><file name="graph.phtml" hash="b16538929e31c0ea92f04d3e1c498305"/><dir name="gridcustomer"><file name="item.phtml" hash="394b55777c0c7a14005e2bfab7f935f0"/><file name="orders.phtml" hash="e3b9887475a0eae9ced1787871cd0352"/></dir><dir name="gridorder"><file name="item.phtml" hash="1674e509451fcd8428710ccb1dd3c7cd"/></dir><dir name="gridproduct"><file name="item.phtml" hash="30b1194e3e57c93da24ba0c488150e8b"/><file name="media.phtml" hash="e2cdd5b6e51c031b41a1763ab6cdc56e"/></dir><file name="summary.phtml" hash="0727a4d931b2e760efdeae6d37ca093c"/></dir><file name="dashmain.phtml" hash="09b05e7767163d4263aa3a36d9646dfb"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magjah_Dash.xml" hash="ec380694ed380a440aef29776eda9690"/></dir></target><target name="mageweb"><dir name="js"><dir name="dash"><file name="function.js" hash="bd6a9f3797fba881aa011a89d4afc843"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="dash.css" hash="57724f8f4906f79455b9adfb631f1ac4"/></dir></dir></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.1.0</min><max>5.4.27</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5</min><max>1.8.1.0</max></package></required></dependencies>
19
+ </package>
skin/adminhtml/default/default/dash.css ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ .gridContainerLeft{
2
+ float: left;
3
+ margin: 3px 0 20px;
4
+ width: 40%;
5
+ }
6
+ .gridContainerRight{
7
+ float: right;
8
+ margin: 3px 0 20px;
9
+ width: 59%;
10
+ }