Briel_ReviewPlus - Version 0.9.0

Version Notes

Stable version, fully functional on our website.

Download this release

Release Info

Developer Velica Onel
Extension Briel_ReviewPlus
Version 0.9.0
Comparing to
See all releases


Version 0.9.0

Files changed (38) hide show
  1. app/code/community/Briel/ReviewPlus/Block/Adminhtml/Clientlog.php +20 -0
  2. app/code/community/Briel/ReviewPlus/Block/Adminhtml/Clientlog/Grid.php +121 -0
  3. app/code/community/Briel/ReviewPlus/Block/Adminhtml/Clientlog/Renderer/Orderid.php +12 -0
  4. app/code/community/Briel/ReviewPlus/Block/Adminhtml/Clientlog/Renderer/Sendtime.php +10 -0
  5. app/code/community/Briel/ReviewPlus/Block/Adminhtml/Clientlog/Renderer/Status.php +14 -0
  6. app/code/community/Briel/ReviewPlus/Block/Adminhtml/Ordertab.php +31 -0
  7. app/code/community/Briel/ReviewPlus/Block/Adminhtml/Reviews.php +20 -0
  8. app/code/community/Briel/ReviewPlus/Block/Adminhtml/Reviews/Grid.php +95 -0
  9. app/code/community/Briel/ReviewPlus/Block/Adminhtml/Reviews/Renderer/Rating.php +13 -0
  10. app/code/community/Briel/ReviewPlus/Block/Review.php +6 -0
  11. app/code/community/Briel/ReviewPlus/Helper/Data.php +6 -0
  12. app/code/community/Briel/ReviewPlus/Model/Clientlog.php +10 -0
  13. app/code/community/Briel/ReviewPlus/Model/Mysql4/Setup.php +6 -0
  14. app/code/community/Briel/ReviewPlus/Model/Observer.php +131 -0
  15. app/code/community/Briel/ReviewPlus/Model/Resource/Clientlog.php +9 -0
  16. app/code/community/Briel/ReviewPlus/Model/Resource/Clientlog/Collection.php +10 -0
  17. app/code/community/Briel/ReviewPlus/Model/Resource/Reviews.php +9 -0
  18. app/code/community/Briel/ReviewPlus/Model/Resource/Reviews/Collection.php +10 -0
  19. app/code/community/Briel/ReviewPlus/Model/Reviews.php +10 -0
  20. app/code/community/Briel/ReviewPlus/controllers/Adminhtml/ClientlogController.php +91 -0
  21. app/code/community/Briel/ReviewPlus/controllers/Adminhtml/OrdertabController.php +27 -0
  22. app/code/community/Briel/ReviewPlus/controllers/Adminhtml/ReviewsController.php +98 -0
  23. app/code/community/Briel/ReviewPlus/controllers/IndexController.php +62 -0
  24. app/code/community/Briel/ReviewPlus/etc/config.xml +189 -0
  25. app/code/community/Briel/ReviewPlus/etc/system.xml +102 -0
  26. app/code/community/Briel/ReviewPlus/sql/briel_reviewplus_setup/mysql4-install-0.9.0.php +35 -0
  27. app/design/adminhtml/default/default/layout/briel_reviewplus.xml +25 -0
  28. app/design/adminhtml/default/default/template/briel_reviewplus/ordertab.phtml +84 -0
  29. app/design/frontend/base/default/layout/briel_reviewplus.xml +17 -0
  30. app/design/frontend/base/default/template/briel_reviewplus/review.phtml +165 -0
  31. app/etc/modules/Briel_ReviewPlus.xml +10 -0
  32. app/locale/en_US/template/email/reviewplus_email.html +36 -0
  33. package.xml +24 -0
  34. skin/frontend/base/default/images/reviewplus_email_template/1-star.jpg +0 -0
  35. skin/frontend/base/default/images/reviewplus_email_template/2-stars.jpg +0 -0
  36. skin/frontend/base/default/images/reviewplus_email_template/3-stars.jpg +0 -0
  37. skin/frontend/base/default/images/reviewplus_email_template/4-stars.jpg +0 -0
  38. skin/frontend/base/default/images/reviewplus_email_template/5-stars.jpg +0 -0
app/code/community/Briel/ReviewPlus/Block/Adminhtml/Clientlog.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Block_Adminhtml_Clientlog extends Mage_Adminhtml_Block_Widget_Grid_Container {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->_controller = 'adminhtml_clientlog';
8
+ $this->_blockGroup = 'reviewplus';
9
+ $this->_headerText = Mage::helper('reviewplus')->__('Customer log');
10
+ $this->removeButton('add');
11
+ }
12
+
13
+ protected function _prepareLayout() {
14
+ $this->setChild( 'grid',
15
+ $this->getLayout()->createBlock( $this->_blockGroup.'/' . $this->_controller . '_grid',
16
+ $this->_controller . '.grid')->setSaveParametersInSession(true));
17
+ return parent::_prepareLayout();
18
+ }
19
+ }
20
+ ?>
app/code/community/Briel/ReviewPlus/Block/Adminhtml/Clientlog/Grid.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Block_Adminhtml_Clientlog_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('clientlog');
8
+ $this->setDefaultSort('id');
9
+ $this->setDefaultDir('desc');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+
13
+ public function getRowUrl($row) {
14
+ // return $this->getUrl('reviewplus/edit/index', array('id' => $row->getId()));
15
+ }
16
+
17
+ protected function _prepareCollection() {
18
+ $collection = Mage::getModel('reviewplus/clientlog')->getCollection();
19
+ $this->setCollection($collection);
20
+ return parent::_prepareCollection();
21
+ }
22
+
23
+ protected function _prepareColumns() {
24
+
25
+ $this->addColumn('id', array(
26
+ 'header' => Mage::helper('reviewplus')->__('ID'),
27
+ 'align' =>'right',
28
+ 'width' =>'50px',
29
+ 'index' =>'id',
30
+ ));
31
+
32
+ $this->addColumn('order_id', array(
33
+ 'header' => Mage::helper('reviewplus')->__('Order Increment ID'),
34
+ 'align' =>'right',
35
+ 'width' =>'100px',
36
+ 'index' =>'order_id',
37
+ 'renderer' =>'Briel_ReviewPlus_Block_Adminhtml_Clientlog_Renderer_Orderid',
38
+ ));
39
+
40
+ $this->addColumn('customer_name', array(
41
+ 'header' => Mage::helper('reviewplus')->__('Customer Name'),
42
+ 'align' =>'left',
43
+ 'index' =>'customer_name',
44
+ 'width' =>'250px',
45
+ ));
46
+
47
+ $this->addColumn('customer_email', array(
48
+ 'header' => Mage::helper('reviewplus')->__('Customer Email'),
49
+ 'align' =>'left',
50
+ 'index' =>'customer_email',
51
+ 'width' =>'250px',
52
+ ));
53
+
54
+ $this->addColumn('ordered_products', array(
55
+ 'header' => Mage::helper('reviewplus')->__('Ordered Product(s)'),
56
+ 'align' =>'left',
57
+ 'index' =>'ordered_products',
58
+ ));
59
+
60
+ $this->addColumn('send_time', array(
61
+ 'header' => Mage::helper('reviewplus')->__('Send Time'),
62
+ 'align' =>'left',
63
+ 'index' =>'send_time',
64
+ 'type' =>'datetime',
65
+ 'width' =>'150px',
66
+ 'renderer' =>'Briel_ReviewPlus_Block_Adminhtml_Clientlog_Renderer_Sendtime',
67
+ 'filter_condition_callback' => array($this, '_datetimeFilter'),
68
+ ));
69
+
70
+ $this->addColumn('status', array(
71
+ 'header' => Mage::helper('reviewplus')->__('Status'),
72
+ 'align' =>'left',
73
+ 'index' =>'status',
74
+ 'width' =>'70px',
75
+ 'renderer' =>'Briel_ReviewPlus_Block_Adminhtml_Clientlog_Renderer_Status',
76
+ 'type' =>'options',
77
+ 'options' => array('0' => 'Not sent', '1' => 'Sent'),
78
+ ));
79
+
80
+ return parent::_prepareColumns();
81
+ }
82
+
83
+ protected function _prepareMassaction() {
84
+ $this->setMassactionIdField('id');
85
+ $this->getMassactionBlock()->setFormFieldName('clientlog_id');
86
+ $this->getMassactionBlock()->addItem('delete', array(
87
+ 'label'=> Mage::helper('reviewplus')->__('Delete'),
88
+ 'url' => $this->getUrl('*/*/massdelete', array('' => '')),
89
+ 'confirm' => Mage::helper('reviewplus')->__('Are you sure?')
90
+ ));
91
+ $this->getMassactionBlock()->addItem('send', array(
92
+ 'label'=> Mage::helper('reviewplus')->__('Send followup email'),
93
+ 'url' => $this->getUrl('*/*/masssend', array('' => '')),
94
+ 'confirm' => Mage::helper('reviewplus')->__('Send followup email?')
95
+ ));
96
+ return $this;
97
+ }
98
+
99
+ protected function _datetimeFilter($collection, $column) {
100
+ if (!$value = $column->getFilter()->getValue()) {
101
+ return $this;
102
+ }
103
+ if (empty($value['from'])) {
104
+ $to = $value['to']->getTimestamp();
105
+ $month = date('n', $to);
106
+ $day = date('j', $to);
107
+ $year = date('Y', $to);
108
+ $from = mktime(0, 0, 0, $month, $day, $year);
109
+ $this->getCollection()->addFieldToFilter('send_time', array('from' => $from, 'to' => $to));
110
+ return $this;
111
+ } else if (empty($value['to'])) {
112
+ $from = $value['from']->getTimestamp();
113
+ $this->getCollection()->addFieldToFilter('send_time', array('from' => $from, 'to' => time()));
114
+ return $this;
115
+ } else {
116
+ $this->getCollection()->addFieldToFilter('send_time', array('from' => $from, 'to' => $to));
117
+ return $this;
118
+ }
119
+ }
120
+ }
121
+ ?>
app/code/community/Briel/ReviewPlus/Block/Adminhtml/Clientlog/Renderer/Orderid.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Block_Adminhtml_Clientlog_Renderer_Orderid extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ $value = $row->getData($this->getColumn()->getIndex());
7
+ $order_db = Mage::getModel('sales/order')->load($value);
8
+ $increment_id = $order_db->getIncrementId();
9
+ return $increment_id;
10
+ }
11
+ }
12
+ ?>
app/code/community/Briel/ReviewPlus/Block/Adminhtml/Clientlog/Renderer/Sendtime.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Block_Adminhtml_Clientlog_Renderer_Sendtime extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ $value = $row->getData($this->getColumn()->getIndex());
7
+ return date('F j, Y', $value);
8
+ }
9
+ }
10
+ ?>
app/code/community/Briel/ReviewPlus/Block/Adminhtml/Clientlog/Renderer/Status.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Block_Adminhtml_Clientlog_Renderer_Status extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ $value = $row->getData($this->getColumn()->getIndex());
7
+ if ($value == 1) {
8
+ return '<div style="text-align:center; font-weight:bold; color:green;">Sent</div>';
9
+ } else {
10
+ return '<div style="text-align:center; font-weight:bold; color:red;">Not sent</div>';
11
+ }
12
+ }
13
+ }
14
+ ?>
app/code/community/Briel/ReviewPlus/Block/Adminhtml/Ordertab.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Briel_ReviewPlus_Block_Adminhtml_Ordertab extends Mage_Adminhtml_Block_Template implements Mage_Adminhtml_Block_Widget_Tab_Interface {
3
+
4
+ protected $_chat = null;
5
+
6
+ protected function _construct() {
7
+ parent::_construct();
8
+ $this->setTemplate('briel_reviewplus/ordertab.phtml');
9
+ }
10
+
11
+ public function getTabLabel() {
12
+ return $this->__('ReviewPlus');
13
+ }
14
+
15
+ public function getTabTitle() {
16
+ return $this->__('ReviewPlus');
17
+ }
18
+
19
+ public function canShowTab() {
20
+ return true;
21
+ }
22
+
23
+ public function isHidden() {
24
+ return false;
25
+ }
26
+
27
+ public function getOrder(){
28
+ return Mage::registry('current_order');
29
+ }
30
+ }
31
+ ?>
app/code/community/Briel/ReviewPlus/Block/Adminhtml/Reviews.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Block_Adminhtml_Reviews extends Mage_Adminhtml_Block_Widget_Grid_Container {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->_controller = 'adminhtml_reviews';
8
+ $this->_blockGroup = 'reviewplus';
9
+ $this->_headerText = Mage::helper('reviewplus')->__('Product Reviews');
10
+ $this->removeButton('add');
11
+ }
12
+
13
+ protected function _prepareLayout() {
14
+ $this->setChild( 'grid',
15
+ $this->getLayout()->createBlock( $this->_blockGroup.'/' . $this->_controller . '_grid',
16
+ $this->_controller . '.grid')->setSaveParametersInSession(true));
17
+ return parent::_prepareLayout();
18
+ }
19
+ }
20
+ ?>
app/code/community/Briel/ReviewPlus/Block/Adminhtml/Reviews/Grid.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Block_Adminhtml_Reviews_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('product_reviews');
8
+ $this->setDefaultSort('id');
9
+ $this->setDefaultDir('desc');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+
13
+ public function getRowUrl($row) {
14
+ // return $this->getUrl('reviewplus/edit/index', array('id' => $row->getId()));
15
+ }
16
+
17
+ protected function _prepareCollection() {
18
+ $collection = Mage::getModel('reviewplus/reviews')->getCollection();
19
+ $this->setCollection($collection);
20
+ return parent::_prepareCollection();
21
+ }
22
+
23
+ protected function _prepareColumns() {
24
+ $this->addColumn('id', array(
25
+ 'header' => Mage::helper('reviewplus')->__('ID'),
26
+ 'align' =>'right',
27
+ 'width' =>'50px',
28
+ 'index' =>'id',
29
+ ));
30
+
31
+ $this->addColumn('customer_name', array(
32
+ 'header' => Mage::helper('reviewplus')->__('Customer Name'),
33
+ 'align' =>'left',
34
+ 'index' =>'customer_name',
35
+ 'width' =>'200px',
36
+ ));
37
+
38
+ $this->addColumn('customer_email', array(
39
+ 'header' => Mage::helper('reviewplus')->__('Customer Email'),
40
+ 'align' =>'left',
41
+ 'index' =>'customer_email',
42
+ 'width' =>'200px',
43
+ ));
44
+
45
+ $this->addColumn('product_sku', array(
46
+ 'header' => Mage::helper('reviewplus')->__('Ordered Product(s)'),
47
+ 'align' =>'left',
48
+ 'index' =>'product_sku',
49
+ ));
50
+
51
+ $this->addColumn('product_review', array(
52
+ 'header' => Mage::helper('reviewplus')->__('Review'),
53
+ 'align' =>'left',
54
+ 'index' =>'product_review',
55
+ ));
56
+
57
+ $this->addColumn('product_rating', array(
58
+ 'header' => Mage::helper('reviewplus')->__('Rating'),
59
+ 'align' =>'left',
60
+ 'index' =>'product_rating',
61
+ 'width' =>'70px;',
62
+ 'renderer' =>'Briel_ReviewPlus_Block_Adminhtml_Reviews_Renderer_Rating',
63
+ 'type' =>'options',
64
+ 'options' => array('1' => '1 Star', '2' => '2 Stars', '3' => '3 Stars', '4' => '4 Stars', '5' => '5 Stars'),
65
+ ));
66
+
67
+ $this->addColumn('review_status', array(
68
+ 'header' => Mage::helper('reviewplus')->__('Review status'),
69
+ 'align' =>'left',
70
+ 'index' =>'review_status',
71
+ 'width' =>'120px',
72
+ 'type' =>'options',
73
+ 'options' => array('approved' => 'Approved', 'pending' => 'Pending'),
74
+ ));
75
+
76
+ return parent::_prepareColumns();
77
+ }
78
+
79
+ protected function _prepareMassaction() {
80
+ $this->setMassactionIdField('id');
81
+ $this->getMassactionBlock()->setFormFieldName('review_id');
82
+ $this->getMassactionBlock()->addItem('delete', array(
83
+ 'label' => Mage::helper('reviewplus')->__('Delete'),
84
+ 'url' => $this->getUrl('*/*/massdelete', array('' => '')),
85
+ 'confirm' => Mage::helper('reviewplus')->__('Are you sure?')
86
+ ));
87
+ $this->getMassActionBlock()->addItem('approve', array(
88
+ 'label' => Mage::helper('reviewplus')->__('Approve'),
89
+ 'url' => $this->getUrl('*/*/massapprove', array('' => '')),
90
+ 'confirm' => Mage::helper('reviewplus')->__('Approve ratings?')
91
+ ));
92
+ return $this;
93
+ }
94
+ }
95
+ ?>
app/code/community/Briel/ReviewPlus/Block/Adminhtml/Reviews/Renderer/Rating.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Block_Adminhtml_Reviews_Renderer_Rating extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
4
+
5
+ public function render(Varien_Object $row) {
6
+ $value = (int)$row->getData($this->getColumn()->getIndex());
7
+ if ($value == 1) {
8
+ return '<strong style="color:#F89400;">'.$value.'</strong> star';
9
+ } else {
10
+ return '<strong style="color:#F89400;">'.$value.'</strong> stars';
11
+ }
12
+ }
13
+ }
app/code/community/Briel/ReviewPlus/Block/Review.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Block_Review extends Mage_Core_Block_Template {
4
+
5
+ }
6
+ ?>
app/code/community/Briel/ReviewPlus/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Helper_Data extends Mage_Core_Helper_Data {
4
+
5
+ }
6
+ ?>
app/code/community/Briel/ReviewPlus/Model/Clientlog.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Model_Clientlog extends Mage_Core_Model_Abstract {
4
+
5
+ protected function _construct() {
6
+ parent::_construct();
7
+ $this->_init('reviewplus/clientlog');
8
+ }
9
+ }
10
+ ?>
app/code/community/Briel/ReviewPlus/Model/Mysql4/Setup.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Model_Mysql4_Setup extends Mage_Core_Model_Resource_Setup {
4
+
5
+ }
6
+ ?>
app/code/community/Briel/ReviewPlus/Model/Observer.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Model_Observer {
4
+
5
+ public function logClients($observer) {
6
+ // set timezone
7
+ date_default_timezone_set(Mage::getStoreConfig('general/locale/timezone', Mage::app()->getStore()));
8
+ // retrieve ORDER ID and STATUS from event dispatch
9
+ $order_id = $observer->getEvent()->getOrder()->getId();
10
+ $order_status = $observer->getEvent()->getOrder()->getStatus();
11
+
12
+ // IF ReviewPlus is enabled, start logging
13
+ $reviewplus_enable = Mage::getStoreConfig('reviewplus_options/reviewplus_config/enable_disable', Mage::app()->getStore());
14
+ if ($reviewplus_enable == 1) {
15
+ // IF order_status is Complete, log user, else skip
16
+ $config_statuses = Mage::getStoreConfig('reviewplus_options/reviewplus_config/select_status', Mage::app()->getStore());
17
+ $config_statuses_arr = explode(',', $config_statuses);
18
+ foreach($config_statuses_arr as $config_status) {
19
+ if ($order_status == $config_status) {
20
+ // get order data
21
+ $order = Mage::getModel('sales/order')->load($order_id);
22
+ $increment_id = $order->getIncrementId();
23
+ $customer_name = $order->getCustomerName();
24
+ $customer_email = $order->getCustomerEmail();
25
+ $ordered_products_collection = $order->getAllItems();
26
+ $ordered_products = array();
27
+ foreach($ordered_products_collection as $ordered_prod) {
28
+ $ordered_products[] = $ordered_prod->getSku();
29
+ }
30
+ $ordered_products = implode(", ", $ordered_products);
31
+ // if collection is empty LOG new data
32
+ $clientlog_collection = Mage::getModel('reviewplus/clientlog')->getCollection();
33
+ $clientlog_collection->addFieldToFilter('order_id', $order_id);
34
+ if (count($clientlog_collection) == 0) {
35
+ // instance new model and write user data
36
+ $clientlog_db = Mage::getModel('reviewplus/clientlog');
37
+ $clientlog_db->setData('enable', 1)->save();
38
+ $clientlog_db->setData('order_id', $order_id)->save();
39
+ $clientlog_db->setData('customer_name', $customer_name)->save();
40
+ $clientlog_db->setData('customer_email', $customer_email)->save();
41
+ $clientlog_db->setData('ordered_products', $ordered_products)->save();
42
+ $clientlog_db->setData('status', 0)->save();
43
+ // calculate send time and save timestamp
44
+ $days_delay_config = Mage::getStoreConfig('reviewplus_options/reviewplus_config/days_delay', Mage::app()->getStore());
45
+ $days_delay = (24 * 60 * 60) * (int)$days_delay_config;
46
+ $timestamp = time() + $days_delay;
47
+ $clientlog_db->setData('send_time', $timestamp)->save();
48
+ } // end collection count IF
49
+ } // end of STATUS IF
50
+ } // end of STATUSES FOREACH
51
+ } // end of IF ENABLED
52
+ } // end of method
53
+
54
+
55
+ public function sendFollowupEmail() {
56
+ // set timezone
57
+ date_default_timezone_set(Mage::getStoreConfig('general/locale/timezone', Mage::app()->getStore()));
58
+ // Mage::log('sendFollowupEmail method is being triggered');
59
+ // get a collection of contacts based on due date: today
60
+ $current_time = time();
61
+ $emails_per_cron = Mage::getStoreConfig('reviewplus_options/reviewplus_config/mails_per_cron', Mage::app()->getStore());
62
+ $clientlog_collection = Mage::getModel('reviewplus/clientlog')->getCollection();
63
+ $clientlog_collection->addFieldToFilter('status', 0)
64
+ ->addFieldToFilter('send_time', array('lteq' => $current_time))
65
+ ->getSelect()
66
+ ->limit((int)$emails_per_cron);
67
+
68
+ if (count($clientlog_collection) == 0) {
69
+ // do nothing, means there are no due clients
70
+ } else {
71
+ foreach ($clientlog_collection as $val) {
72
+ $clientlog_db = Mage::getModel('reviewplus/clientlog')->load($val->getId());
73
+ $send_time = $clientlog_db->getData('send_time');
74
+ $order_id = $clientlog_db->getData('order_id');
75
+ $customer_name = $clientlog_db->getData('customer_name');
76
+ $customer_email = $clientlog_db->getData('customer_email');
77
+ $ordered_products = $clientlog_db->getData('ordered_products');
78
+ $status = $clientlog_db->getData('status');
79
+ // use HOUR from config for when to start sending mails
80
+ $cron_hour = Mage::getStoreConfig('reviewplus_options/reviewplus_config/cron_hour', Mage::app()->getStore());
81
+ if (date('G', time()) >= $cron_hour) {
82
+ // get current ORDER status
83
+ $sales_order_db = Mage::getModel('sales/order')->load($order_id);
84
+ $order_status = $sales_order_db->getStatus();
85
+ $order_increment_id = $sales_order_db->getIncrementId();
86
+ // check IF STATUS == complete ? send mail : don't send
87
+ $config_statuses = Mage::getStoreConfig('reviewplus_options/reviewplus_config/select_status', Mage::app()->getStore());
88
+ $config_statuses_arr = explode(',', $config_statuses);
89
+ foreach($config_statuses_arr as $config_status) {
90
+ if ($order_status == $config_status) {
91
+ $salt = "Magento extension created by Briel Software";
92
+ $hash = md5($customer_name.$order_id.$salt);
93
+ $review_page_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).'reviewplus/index/index'.'/?oid='.$order_id.'&hash='.$hash;
94
+ // get sender data from Store Sales Rep.
95
+ $sender_name = Mage::getStoreConfig('trans_email/ident_sales/name');
96
+ $sender_email = Mage::getStoreConfig('trans_email/ident_sales/email');
97
+ // get template ID
98
+ $email_template_id = Mage::getStoreConfig('reviewplus_options/reviewplus_config/email_template', Mage::app()->getStore()->getId());
99
+ $email_template_vars = array();
100
+ $email_template_vars['namevar'] = $customer_name;
101
+ $email_template_vars['review_page_url'] = $review_page_url;
102
+ $email_template_vars['order_increment_id'] = $order_increment_id;
103
+ // ordered product(s) name
104
+ $ordered_products_arr = explode(", ", $ordered_products);
105
+ $purchased_products = '';
106
+ foreach($ordered_products_arr as $purchased_prod_sku) {
107
+ $prod_loaded = Mage::getModel('catalog/product')->loadByAttribute('sku', trim($purchased_prod_sku));
108
+ $purchased_prod_name = $prod_loaded->getName();
109
+ $purchased_products .= "<span>".$purchased_prod_name."</span><br />";
110
+ }
111
+ $email_template_vars['purchased_products'] = $purchased_products;
112
+ // get Store ID
113
+ $store_id = Mage::app()->getStore()->getId();
114
+ // set status as SENT on followup entry
115
+ $clientlog_db->setData('status', 1)->save();
116
+ // send transactional, will not send if template has no subject
117
+ $mail = Mage::getModel('core/email_template');
118
+ $config_bcc = Mage::getStoreConfig('reviewplus_options/reviewplus_config/bcc_email', Mage::app()->getStore()->getId());
119
+ $config_bcc_exploded = explode(',', $config_bcc);
120
+ $mail->addBcc($config_bcc_exploded);
121
+ $mail->sendTransactional($email_template_id, array('name' => $sender_name, 'email' => $sender_email), $customer_email, $customer_name, $email_template_vars, $store_id);
122
+ // Mage::log('mail sent successfully');
123
+ } // end of STATUS IF
124
+ } // end of STATUSES FOREACH
125
+ } // end of HOUR IF
126
+ } // end of COLLECTION FOREACH
127
+ } // end of COLLECTION COUNT ELSE
128
+ } // end of sendFollowupEmail() method
129
+
130
+ } // end of class
131
+ ?>
app/code/community/Briel/ReviewPlus/Model/Resource/Clientlog.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Model_Resource_Clientlog extends Mage_Core_Model_Resource_Db_Abstract {
4
+
5
+ protected function _construct() {
6
+ $this->_init('reviewplus/clientlog', 'id');
7
+ }
8
+ }
9
+ ?>
app/code/community/Briel/ReviewPlus/Model/Resource/Clientlog/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Model_Resource_Clientlog_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('reviewplus/clientlog');
8
+ }
9
+ }
10
+ ?>
app/code/community/Briel/ReviewPlus/Model/Resource/Reviews.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Model_Resource_Reviews extends Mage_Core_Model_Resource_Db_Abstract {
4
+
5
+ protected function _construct() {
6
+ $this->_init('reviewplus/reviews', 'id');
7
+ }
8
+ }
9
+ ?>
app/code/community/Briel/ReviewPlus/Model/Resource/Reviews/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Model_Resource_Reviews_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('reviewplus/reviews');
8
+ }
9
+ }
10
+ ?>
app/code/community/Briel/ReviewPlus/Model/Reviews.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Model_Reviews extends Mage_Core_Model_Abstract {
4
+
5
+ protected function _construct() {
6
+ parent::_construct();
7
+ $this->_init('reviewplus/reviews');
8
+ }
9
+ }
10
+ ?>
app/code/community/Briel/ReviewPlus/controllers/Adminhtml/ClientlogController.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Adminhtml_ClientlogController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ public function indexAction() {
6
+ $this->loadLayout();
7
+ $this->renderLayout();
8
+ }
9
+
10
+ public function massdeleteAction() {
11
+ $post = $this->getRequest()->getPost();
12
+ $clientlog_ids = $post['clientlog_id'];
13
+ if (!is_array($clientlog_ids)) {
14
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reviewplus')->__('Please select at least one entry.'));
15
+ } else {
16
+ try {
17
+ foreach($clientlog_ids as $id) {
18
+ Mage::getModel('reviewplus/clientlog')->load($id)->delete();
19
+ }
20
+ $success_msg = $this->__('Entries deleted successfully.');
21
+ Mage::getSingleton('adminhtml/session')->addSuccess($success_msg);
22
+ } catch (Exception $e) {
23
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
24
+ }
25
+ }
26
+ $this->_redirect('*/*/index');
27
+ }
28
+
29
+ public function masssendAction() {
30
+ $post = $this->getRequest()->getPost();
31
+ $clientlog_ids = $post['clientlog_id'];
32
+ if (!is_array($clientlog_ids)) {
33
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reviewplus')->__('Please select at least one entry.'));
34
+ } else {
35
+ try {
36
+ foreach($clientlog_ids as $id) {
37
+ $clientlog_db = Mage::getModel('reviewplus/clientlog')->load($id);
38
+ $order_id = $clientlog_db->getData('order_id');
39
+ $customer_name = $clientlog_db->getData('customer_name');
40
+ $customer_email = $clientlog_db->getData('customer_email');
41
+ $status = $clientlog_db->getData('status');
42
+ $order_increment_id = Mage::getModel('sales/order')->load($order_id)->getIncrementId();
43
+ if ($status == 0) {
44
+ // create hash and url for email template
45
+ $salt = "Magento extension created by Briel Software";
46
+ $hash = md5($customer_name.$order_id.$salt);
47
+ $review_page_url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB).'reviewplus/index/index'.'/?oid='.$order_id.'&hash='.$hash;
48
+ // get sender data from Store Sales Rep.
49
+ $sender_name = Mage::getStoreConfig('trans_email/ident_sales/name');
50
+ $sender_email = Mage::getStoreConfig('trans_email/ident_sales/email');
51
+ // get template ID and complete email variables
52
+ $email_template_id = Mage::getStoreConfig('reviewplus_options/reviewplus_config/email_template', Mage::app()->getStore()->getId());
53
+ $email_template_vars = array();
54
+ $email_template_vars['namevar'] = $customer_name;
55
+ $email_template_vars['review_page_url'] = $review_page_url;
56
+ $email_template_vars['order_increment_id'] = $order_increment_id;
57
+ // get ordered products and send to email as variable
58
+ $ordered_products = $clientlog_db->getData('ordered_products');
59
+ $ordered_products_arr = explode(", ", $ordered_products);
60
+ $purchased_products = '';
61
+ foreach($ordered_products_arr as $purchased_prod_sku) {
62
+ $prod_loaded = Mage::getModel('catalog/product')->loadByAttribute('sku', trim($purchased_prod_sku));
63
+ $purchased_prod_name = $prod_loaded->getName();
64
+ $purchased_products .= "<span>".$purchased_prod_name."</span><br />";
65
+ }
66
+ $email_template_vars['purchased_products'] = $purchased_products;
67
+ // get Store ID
68
+ $store_id = Mage::app()->getStore()->getId();
69
+ // set status as SENT on followup entry
70
+ $clientlog_db->setData('status', 1)->save();
71
+ // send transactional, will not send if template has no subject
72
+ $mail = Mage::getModel('core/email_template');
73
+ $config_bcc = Mage::getStoreConfig('reviewplus_options/reviewplus_config/bcc_email', Mage::app()->getStore()->getId());
74
+ $config_bcc_exploded = explode(',', $config_bcc);
75
+ $mail->addBcc($config_bcc_exploded);
76
+ $mail->sendTransactional($email_template_id, array('name' => $sender_name, 'email' => $sender_email), $customer_email, $customer_name, $email_template_vars, $store_id);
77
+ $success_msg = $this->__('Followup emails has been sent for entry #'.$id);
78
+ Mage::getSingleton('adminhtml/session')->addSuccess($success_msg);
79
+ } else {
80
+ $error_msg = $this->__('Entry #'.$id." already sent.");
81
+ Mage::getSingleton('adminhtml/session')->addError($error_msg);
82
+ }
83
+ }
84
+ } catch (Exception $e) {
85
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
86
+ }
87
+ $this->_redirect('*/*/index');
88
+ }
89
+ }
90
+ }
91
+ ?>
app/code/community/Briel/ReviewPlus/controllers/Adminhtml/OrdertabController.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Adminhtml_OrdertabController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ public function lognowAction() {
6
+ $post = $this->getRequest()->getPost();
7
+ try {
8
+ $clientlog_db = Mage::getModel('reviewplus/clientlog');
9
+ $clientlog_db->setData('enable', 1)->save();
10
+ $clientlog_db->setData('order_id', $post['reviewplus-lognow']['order_id'])->save();
11
+ $clientlog_db->setData('customer_name', $post['reviewplus-lognow']['customer_name'])->save();
12
+ $clientlog_db->setData('customer_email', $post['reviewplus-lognow']['customer_email'])->save();
13
+ $clientlog_db->setData('ordered_products', $post['reviewplus-lognow']['ordered_products'])->save();
14
+ $clientlog_db->setData('send_time', time())->save();
15
+ $clientlog_db->setData('status', 0)->save();
16
+ // success message
17
+ $success_msg = $this->__('Order successfully logged. The client will receive a product review followup email as per extension settings.');
18
+ Mage::getSingleton('adminhtml/session')->addSuccess($success_msg);
19
+ } catch (Exception $ex) {
20
+ $session = Mage::getSingleton('core/session');
21
+ $session->addError($this->__('Unable to log order.'));
22
+ }
23
+ $this->_redirect('adminhtml/sales_order/view' , array('order_id' => $post['reviewplus-lognow']['order_id']));
24
+ }
25
+
26
+ }
27
+ ?>
app/code/community/Briel/ReviewPlus/controllers/Adminhtml/ReviewsController.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_Adminhtml_ReviewsController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ public function indexAction() {
6
+ $this->loadLayout();
7
+ $this->renderLayout();
8
+ }
9
+
10
+ public function massdeleteAction() {
11
+ $post = $this->getRequest()->getPost();
12
+ $review_ids = $post['review_id'];
13
+ if (!is_array($review_ids)) {
14
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reviewplus')->__('Please select at least one entry.'));
15
+ } else {
16
+ try {
17
+ foreach($review_ids as $id) {
18
+ Mage::getModel('reviewplus/reviews')->load($id)->delete();
19
+ }
20
+ $success_msg = $this->__('Entries deleted successfully.');
21
+ Mage::getSingleton('adminhtml/session')->addSuccess($success_msg);
22
+ } catch (Exception $e) {
23
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
24
+ }
25
+ }
26
+ $this->_redirect('*/*/index');
27
+ }
28
+
29
+ public function massapproveAction() {
30
+ $post = $this->getRequest()->getPost();
31
+ $review_ids = $post['review_id'];
32
+ if (!is_array($review_ids)) {
33
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('reviewplus')->__('Please select at least one entry.'));
34
+ } else {
35
+ try {
36
+ foreach($review_ids as $id) {
37
+ // compile review data array
38
+ $reviewplus_reviews_db = Mage::getModel('reviewplus/reviews')->load($id);
39
+ $nickname = $reviewplus_reviews_db->getData('customer_name');
40
+ $detail = $reviewplus_reviews_db->getData('product_review');
41
+ $rtng = $reviewplus_reviews_db->getData('product_rating');
42
+ $sku = $reviewplus_reviews_db->getData('product_sku');
43
+ $store_id = $reviewplus_reviews_db->getData('store_id');
44
+ $review_status = $reviewplus_reviews_db->getData('review_status');
45
+ if ($review_status == 'approved') {
46
+ $error_msg = $this->__('Review #'.$id.' already approved.');
47
+ Mage::getSingleton('adminhtml/session')->addError($error_msg);
48
+ } else {
49
+ $product_id = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku)->getId();
50
+ $reviewplus_reviews_db->setData('review_status', 'approved')->save();
51
+ // get active RATING options
52
+ $rating_collection = Mage::getModel('rating/rating')
53
+ ->getResourceCollection()
54
+ ->addEntityFilter('product')
55
+ ->setPositionOrder()
56
+ ->addRatingPerStoreName(Mage::app()->getStore()->getId())
57
+ ->setStoreFilter(Mage::app()->getStore()->getId())
58
+ ->load()
59
+ ->addOptionToItems();
60
+ $rating = array();
61
+ foreach($rating_collection as $rating_option) {
62
+ $rating[$rating_option->getId()] = $rtng;
63
+ }
64
+ $review_data = array(
65
+ 'ratings' => $rating,
66
+ 'validate_rating' => '',
67
+ 'nickname' => $nickname,
68
+ 'title' => '',
69
+ 'detail' => $detail
70
+ );
71
+ $review_db = Mage::getModel('review/review')->setData($review_data);
72
+ $review_db->setEntityId($review_db->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE))
73
+ ->setEntityPkValue($product_id)
74
+ ->setStatusId(Mage_Review_Model_Review::STATUS_APPROVED)
75
+ ->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
76
+ ->setStoreId($store_id)
77
+ ->setStores(array($store_id))
78
+ ->save();
79
+ foreach ($rating as $rating_id => $option_id) {
80
+ Mage::getModel('rating/rating')->setRatingId($rating_id)
81
+ ->setReviewId($review_db->getId())
82
+ ->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
83
+ ->addOptionVote($option_id, $product_id);
84
+ }
85
+ $review_db->aggregate();
86
+ $success_msg = $this->__('Review #'.$id.' approved successfully.');
87
+ Mage::getSingleton('adminhtml/session')->addSuccess($success_msg);
88
+ }
89
+ }
90
+ } catch (Exception $e) {
91
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
92
+ }
93
+ }
94
+ $this->_redirect('*/*/index');
95
+ } // end of moethod
96
+
97
+ } // end of class
98
+ ?>
app/code/community/Briel/ReviewPlus/controllers/IndexController.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Briel_ReviewPlus_IndexController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function indexAction() {
6
+ $this->loadLayout();
7
+ $this->renderLayout();
8
+ }
9
+
10
+ public function rateAction() {
11
+ $post = $this->getRequest()->getPost();
12
+ $skus = $post['sku'];
13
+ foreach($skus as $sku) {
14
+ // write details to REVIEWPLUS_REVIEWS table
15
+ $reviews_db = Mage::getModel('reviewplus/reviews')->load($post['rating-id'][$sku]);
16
+ $reviews_db->setData('product_review', $post['detail'][$sku])->save();
17
+ } // end sku FOREACH
18
+ $this->_redirect('/');
19
+ } // end of method
20
+
21
+
22
+ /*public function oldrateAction() {
23
+ $post = $this->getRequest()->getPost();
24
+ $skus = $post['sku'];
25
+ foreach($skus as $sku) {
26
+ // write data to REVIEWPLUS_REVIEWS table
27
+ $reviews_db = Mage::getModel('reviewplus/reviews')->load($post['rating-id'][$sku]);
28
+ $reviews_db->setData('product_review', $post['detail'][$sku])->save();
29
+ // shape $rating into acceptable form
30
+ $rating = array("1" => $post['rating'][$sku], "2" => $post['rating'][$sku], "3" => $post['rating'][$sku]);
31
+ // write data to MAGENTO REVIEWS table; will appear on product reviews grid for approval
32
+ $review_data = array('ratings' => array("1" => $post['rating'][$sku], "2" => $post['rating'][$sku], "3" => $post['rating'][$sku]), 'validate_rating' => '', 'nickname' => $post['nickname'][$sku], 'title' => $post['title'][$sku], 'detail' => $post['detail'][$sku]);
33
+ if (!empty($review_data)) {
34
+ $review_db = Mage::getModel('review/review')->setData($review_data);
35
+ $validate = $review_db->validate();
36
+ if ($validate === true) {
37
+ try {
38
+ $review_db->setEntityId($review_db->getEntityIdByCode(Mage_Review_Model_Review::ENTITY_PRODUCT_CODE))
39
+ ->setEntityPkValue($post['product-id'][$sku])
40
+ ->setStatusId(Mage_Review_Model_Review::STATUS_PENDING)
41
+ ->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
42
+ ->setStoreId(Mage::app()->getStore()->getId())
43
+ ->setStores(array(Mage::app()->getStore()->getId()))
44
+ ->save();
45
+ foreach ($rating as $rating_id => $option_id) {
46
+ Mage::getModel('rating/rating')->setRatingId($rating_id)
47
+ ->setReviewId($review_db->getId())
48
+ ->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId())
49
+ ->addOptionVote($option_id, $post['product-id'][$sku]);
50
+ }
51
+ $review_db->aggregate();
52
+ } catch (Exception $e) {
53
+ $session = Mage::getSingleton('core/session');
54
+ $session->addError($this->__('Unable to post the review.'));
55
+ }
56
+ }
57
+ }
58
+ }
59
+ $this->_redirect('');
60
+ }*/
61
+ }
62
+ ?>
app/code/community/Briel/ReviewPlus/etc/config.xml ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Briel_ReviewPlus>
6
+ <version>0.9.0</version>
7
+ </Briel_ReviewPlus>
8
+ </modules>
9
+ <admin>
10
+ <routers> <!--ADMIN-CONTROLLER-->
11
+ <adminhtml>
12
+ <args>
13
+ <modules>
14
+ <reviewplus before="Mage_Adminhtml">Briel_ReviewPlus_Adminhtml</reviewplus>
15
+ </modules>
16
+ </args>
17
+ </adminhtml>
18
+ </routers>
19
+ </admin>
20
+ <adminhtml>
21
+ <menu> <!--ADMIN-MENU-->
22
+ <reviewplus_menu translate="title" module="reviewplus">
23
+ <title>Briel ReviewPlus</title>
24
+ <sort_order>33</sort_order>
25
+ <children>
26
+ <reviewplus_submenu1 translate="title" module="reviewplus">
27
+ <title>Manage Customer Log</title>
28
+ <sort_order>10</sort_order>
29
+ <action>adminhtml/clientlog/index</action>
30
+ </reviewplus_submenu1>
31
+ <reviewplus_submenu2 translate="title" module="reviewplus">
32
+ <title>Product Reviews</title>
33
+ <sort_order>20</sort_order>
34
+ <action>adminhtml/reviews/index</action>
35
+ </reviewplus_submenu2>
36
+ <reviewplus_options translate="title" module="reviewplus">
37
+ <title>Settings</title>
38
+ <sort_order>30</sort_order>
39
+ <action>adminhtml/system_config/edit/section/reviewplus_options</action>
40
+ </reviewplus_options>
41
+ </children>
42
+ </reviewplus_menu>
43
+ </menu>
44
+ <layout> <!--ADMIN-LAYOUT-XML-->
45
+ <updates>
46
+ <reviewplus>
47
+ <file>briel_reviewplus.xml</file>
48
+ </reviewplus>
49
+ </updates>
50
+ </layout>
51
+ <acl> <!--ACL-->
52
+ <resources>
53
+ <admin>
54
+ <children>
55
+ <reviewplus_menu translate="title" module="reviewplus"> <!--ACL-FOR-MENU-ITEMS-->
56
+ <title>Briel ReviewPlus</title>
57
+ <sort_order>33</sort_order>
58
+ <children>
59
+ <reviewplus_submenu1>
60
+ <title>Manage Customer Log</title>
61
+ <sort_order>10</sort_order>
62
+ </reviewplus_submenu1>
63
+ <reviewplus_submenu2>
64
+ <title>Product Reviews</title>
65
+ <sort_order>20</sort_order>
66
+ </reviewplus_submenu2>
67
+ <reviewplus_options>
68
+ <title>Settings</title>
69
+ <sort_order>30</sort_order>
70
+ </reviewplus_options>
71
+ </children>
72
+ </reviewplus_menu>
73
+ <system> <!-- ACL-FOR-SYSTEM-CONFIG-XML-->
74
+ <children>
75
+ <config>
76
+ <children>
77
+ <reviewplus_options translate="title" module="reviewplus">
78
+ <title>Briel ReviewPlus</title>
79
+ <sort_order>33</sort_order>
80
+ </reviewplus_options>
81
+ </children>
82
+ </config>
83
+ </children>
84
+ </system>
85
+ </children>
86
+ </admin>
87
+ </resources>
88
+ </acl>
89
+ </adminhtml>
90
+ <frontend>
91
+ <routers> <!--FRONTEND-CONTROLLERS-->
92
+ <reviewplus>
93
+ <use>standard</use>
94
+ <args>
95
+ <module>Briel_ReviewPlus</module>
96
+ <frontName>reviewplus</frontName>
97
+ </args>
98
+ </reviewplus>
99
+ </routers>
100
+ <layout> <!--FRONTEND-LAYOUT-XML-->
101
+ <updates>
102
+ <reviewplus>
103
+ <file>briel_reviewplus.xml</file>
104
+ </reviewplus>
105
+ </updates>
106
+ </layout>
107
+ </frontend>
108
+ <global>
109
+ <resources> <!--SETUP-SQL-->
110
+ <briel_reviewplus_setup>
111
+ <setup>
112
+ <module>Briel_ReviewPlus</module>
113
+ <class>Briel_ReviewPlus_Model_Mysql4_Setup</class>
114
+ </setup>
115
+ <connection>
116
+ <use>core_setup</use>
117
+ </connection>
118
+ </briel_reviewplus_setup>
119
+ <briel_reviewplus_write>
120
+ <connection>
121
+ <use>core_write</use>
122
+ </connection>
123
+ </briel_reviewplus_write>
124
+ <briel_reviewplus_read>
125
+ <connection>
126
+ <use>core_read</use>
127
+ </connection>
128
+ </briel_reviewplus_read>
129
+ </resources>
130
+ <models> <!--MODELS-and-RESOURCE-MODELS-->
131
+ <reviewplus>
132
+ <class>Briel_ReviewPlus_Model</class>
133
+ <resourceModel>reviewplus_resource</resourceModel>
134
+ </reviewplus>
135
+ <reviewplus_resource>
136
+ <class>Briel_ReviewPlus_Model_Resource</class>
137
+ <entities>
138
+ <clientlog>
139
+ <table>reviewplus_clientlog</table>
140
+ </clientlog>
141
+ <reviews>
142
+ <table>reviewplus_reviews</table>
143
+ </reviews>
144
+ </entities>
145
+ </reviewplus_resource>
146
+ </models>
147
+ <helpers> <!--HELPER-->
148
+ <reviewplus>
149
+ <class>Briel_ReviewPlus_Helper</class>
150
+ </reviewplus>
151
+ </helpers>
152
+ <blocks> <!--BLOCKS-->
153
+ <reviewplus>
154
+ <class>Briel_ReviewPlus_Block</class>
155
+ </reviewplus>
156
+ </blocks>
157
+ <events> <!--EVENT-OBSERVER-->
158
+ <sales_order_save_after>
159
+ <observers>
160
+ <reviewplus>
161
+ <class>reviewplus/observer</class>
162
+ <method>logClients</method>
163
+ </reviewplus>
164
+ </observers>
165
+ </sales_order_save_after>
166
+ </events>
167
+ <template> <!--EMAIL-TEMPLATE-->
168
+ <email>
169
+ <reviewplus_options_reviewplus_config_email_template>
170
+ <label>ReviewPlus Email Template</label>
171
+ <file>reviewplus_email.html</file>
172
+ <type>html</type>
173
+ </reviewplus_options_reviewplus_config_email_template>
174
+ </email>
175
+ </template>
176
+ </global>
177
+ <crontab> <!--EMAIL-CRONJOB-->
178
+ <jobs>
179
+ <briel_reviewplus>
180
+ <schedule>
181
+ <cron_expr>0,5,10,15,20,25,30,35,40,45,50,55 * * * *</cron_expr>
182
+ </schedule>
183
+ <run>
184
+ <model>reviewplus/observer::sendFollowupEmail</model>
185
+ </run>
186
+ </briel_reviewplus>
187
+ </jobs>
188
+ </crontab>
189
+ </config>
app/code/community/Briel/ReviewPlus/etc/system.xml ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+
3
+ <config>
4
+ <tabs>
5
+ <reviewplus translate="label" module="reviewplus">
6
+ <label>Briel ReviewPlus</label>
7
+ <sort_order>15</sort_order>
8
+ </reviewplus>
9
+ </tabs>
10
+ <sections>
11
+ <reviewplus_options translate="label" module="reviewplus">
12
+ <label>Briel ReviewPlus</label>
13
+ <tab>reviewplus</tab>
14
+ <frontend_type>text</frontend_type>
15
+ <sort_order>1</sort_order>
16
+ <show_in_default>1</show_in_default>
17
+ <show_in_website>1</show_in_website>
18
+ <show_in_store>1</show_in_store>
19
+ <groups>
20
+ <reviewplus_config translate="label" module="reviewplus">
21
+ <label>ReviewPlus Configuration</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>10</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <enable_disable translate="label">
29
+ <label>Enable</label>
30
+ <comment>Enable or disable ReviewPlus</comment>
31
+ <frontend_type>select</frontend_type>
32
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
33
+ <sort_order>10</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ </enable_disable>
38
+ <days_delay translate="label">
39
+ <label>Followup Email Days Delay</label>
40
+ <comment>In days, send followup email after these many days after order has reached the status selected below. Give value of zero (0) for no delay.</comment>
41
+ <frontend_type>text</frontend_type>
42
+ <validate>validate-number</validate>
43
+ <sort_order>20</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ </days_delay>
48
+ <cron_hour translate="label">
49
+ <label>Start hour</label>
50
+ <comment>In hours, the starting hour for email sending start. EXAMPLE: 0 - 23</comment>
51
+ <frontend_type>text</frontend_type>
52
+ <validate>validate-number</validate>
53
+ <sort_order>30</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>1</show_in_store>
57
+ </cron_hour>
58
+ <mails_per_cron translate="label">
59
+ <label>Emails per cron</label>
60
+ <comment>Sets the number of emails sent per Cronjob. EXAMPLE: 7 - will send 7 emails per cron.</comment>
61
+ <frontend_type>text</frontend_type>
62
+ <validate>validate-number</validate>
63
+ <sort_order>40</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</show_in_store>
67
+ </mails_per_cron>
68
+ <bcc_email translate="label">
69
+ <label>Bcc</label>
70
+ <comment>BCC email address. You can write multiple, separated by comma.</comment>
71
+ <frontend_type>text</frontend_type>
72
+ <sort_order>50</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </bcc_email>
77
+ <email_template translate="label">
78
+ <label>Email Template</label>
79
+ <comment>Choose a template that will be used as your followup email.</comment>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>adminhtml/system_config_source_email_template</source_model>
82
+ <sort_order>60</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ </email_template>
87
+ <select_status>
88
+ <label>Select Order Status</label>
89
+ <comment>CTRL + Click to select multiple statuses. Choose which status an order has to be in to get logged by the extension.</comment>
90
+ <frontend_type>multiselect</frontend_type>
91
+ <source_model>adminhtml/system_config_source_order_status</source_model>
92
+ <sort_order>70</sort_order>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ </select_status>
97
+ </fields>
98
+ </reviewplus_config>
99
+ </groups>
100
+ </reviewplus_options>
101
+ </sections>
102
+ </config>
app/code/community/Briel/ReviewPlus/sql/briel_reviewplus_setup/mysql4-install-0.9.0.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ $installer->run("
6
+ -- DROP TABLE IF EXISTS {$this->getTable('reviewplus_clientlog')};
7
+ CREATE TABLE IF NOT EXISTS {$this->getTable('reviewplus_clientlog')} (
8
+ `id` int(12) unsigned NOT NULL auto_increment,
9
+ `enable` tinyint(1) NOT NULL ,
10
+ `order_id` int(12) NOT NULL ,
11
+ `customer_name` varchar(255) NOT NULL ,
12
+ `customer_email` varchar(255) NOT NULL ,
13
+ `ordered_products` varchar(255) NOT NULL ,
14
+ `send_time` int(16) NOT NULL ,
15
+ `status` tinyint(1) NOT NULL ,
16
+ PRIMARY KEY(`id`)
17
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
18
+
19
+ -- DROP TABLE IF EXISTS {$this->getTable('reviewplus_reviews')};
20
+ CREATE TABLE IF NOT EXISTS {$this->getTable('reviewplus_reviews')} (
21
+ `id` int(12) unsigned NOT NULL auto_increment,
22
+ `order_id` int(12) NOT NULL ,
23
+ `product_sku` varchar(255) NOT NULL ,
24
+ `customer_name` varchar(255) NOT NULL ,
25
+ `customer_email` varchar(255) NULL ,
26
+ `product_rating` tinyint(1) NOT NULL ,
27
+ `product_review` text NOT NULL ,
28
+ `review_status` varchar(100) NOT NULL ,
29
+ `store_id` int(3) NOT NULL ,
30
+ PRIMARY KEY(`id`)
31
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
32
+ ");
33
+
34
+ $installer->endSetup();
35
+ ?>
app/design/adminhtml/default/default/layout/briel_reviewplus.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+
3
+ <layout>
4
+ <adminhtml_reviews_index>
5
+ <reference name="content">
6
+ <block type="reviewplus/adminhtml_reviews" name="reviews" />
7
+ </reference>
8
+ <reference name="head">
9
+ <action method="setTitle" translate="title"><title>Product Reviews / Briel ReviewPlus</title></action>
10
+ </reference>
11
+ </adminhtml_reviews_index>
12
+ <adminhtml_clientlog_index>
13
+ <reference name="content">
14
+ <block type="reviewplus/adminhtml_clientlog" name="clientlog" />
15
+ </reference>
16
+ <reference name="head">
17
+ <action method="setTitle" translate="title"><title>Customer log / Briel ReviewPlus</title></action>
18
+ </reference>
19
+ </adminhtml_clientlog_index>
20
+ <adminhtml_sales_order_view>
21
+ <reference name="sales_order_tabs">
22
+ <action method="addTab"><name>ordertab</name><block>reviewplus/adminhtml_ordertab</block></action>
23
+ </reference>
24
+ </adminhtml_sales_order_view>
25
+ </layout>
app/design/adminhtml/default/default/template/briel_reviewplus/ordertab.phtml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // instance order object and get order info
3
+ $order = $this->getOrder();
4
+ $order_id = $order->getId();
5
+ $order_status = $order->getStatus();
6
+ $customer_name = $order->getCustomerName();
7
+ $customer_email = $order->getCustomerEmail();
8
+ $ordered_products_collection = $order->getAllItems();
9
+ $ordered_products = array();
10
+ foreach($ordered_products_collection as $ordered_prod) {
11
+ $ordered_products[] = $ordered_prod->getSku();
12
+ }
13
+ $ordered_products = implode(", ", $ordered_products);
14
+ // instance clientlog model and load current order
15
+ $clientlog_coll = Mage::getModel('reviewplus/clientlog')->getCollection()->addFieldToFilter('order_id', $order_id);
16
+ if (count($clientlog_coll) == 1) {
17
+ foreach($clientlog_coll as $entry) {
18
+ $clientlog_db = Mage::getModel('reviewplus/clientlog')->load($entry->getId());
19
+ $status = $clientlog_db->getData('status');
20
+ $send_time = $clientlog_db->getData('send_time');
21
+ }
22
+ } else {
23
+ $send_time = 'undefined';
24
+ $status = '';
25
+ }
26
+ ?>
27
+ <div class="box-left">
28
+ <div class="entry-edit">
29
+ <div class="entry-edit-head">
30
+ <h4><?php echo $this->__('ReviewPlus Followup Email Status'); ?></h4>
31
+ </div>
32
+ <div class="fieldset">
33
+ <table class="form-list" cellspacing="0">
34
+ <tbody>
35
+ <tr>
36
+ <td class="label"><?php echo $this->__('ReviewPlus Followup email'); ?></td>
37
+ <td class="value"><?php if ($status == 1) { echo "<strong style='color:green;'>Sent</strong>"; } else { echo "<strong style='color:red;'>Not sent</strong>"; } ?></td>
38
+ </tr>
39
+ <tr>
40
+ <td class="label"><?php echo $this->__('Send time'); ?></td>
41
+ <td class="value"><?php if ($send_time == 'undefined') { echo "<strong>-</strong>"; } else { echo "<strong>".date('d M Y', $send_time)."</strong>"; } ?></td>
42
+ </tr>
43
+ <?php
44
+ // check IF clientlog status is 0 && extensions is enabled && current order status is among allowed list from extension config
45
+ $reviewplus_enable = Mage::getStoreConfig('reviewplus_options/reviewplus_config/enable_disable', Mage::app()->getStore());
46
+ $config_statuses = Mage::getStoreConfig('reviewplus_options/reviewplus_config/select_status', Mage::app()->getStore());
47
+ $config_statuses_arr = explode(',', $config_statuses);
48
+ // if all true, show LOG NOW button
49
+ if ($status == 0 && $reviewplus_enable == 1 && in_array($order_status, $config_statuses_arr) == true) {
50
+ // if order is logged already, do not show button
51
+ if (count($clientlog_coll) == 1) {
52
+ // do nothing
53
+ } else {
54
+ ?>
55
+ <tr>
56
+ <td class="label"><?php echo $this->__('Log order'); ?></td>
57
+ <td class="value">
58
+ <form id="reviewplus-lognow-form" name="reviewplus-lognow-form" action="<?php echo $this->getUrl('adminhtml/ordertab/lognow'); ?>" method="post">
59
+ <input type="hidden" name="form_key" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
60
+ <input type="hidden" name="reviewplus-lognow[order_id]" value="<?php echo $order_id; ?>">
61
+ <input type="hidden" name="reviewplus-lognow[customer_name]" value="<?php echo $customer_name; ?>">
62
+ <input type="hidden" name="reviewplus-lognow[customer_email]" value="<?php echo $customer_email; ?>">
63
+ <input type="hidden" name="reviewplus-lognow[ordered_products]" value="<?php echo $ordered_products ?>">
64
+ <button title="<?php echo $this->__('Log now'); ?>" class="scalable" type="button" onclick="lognowConfirm();"><span><span><?php echo $this->__('Log now'); ?></span></span></button>
65
+ </form>
66
+ <script type="text/javascript">
67
+ var lognow = new varienForm('reviewplus-lognow-form');
68
+ function lognowConfirm() {
69
+ var answer = confirm('Log order?');
70
+ if (answer == true) {
71
+ lognow.submit();
72
+ } else {
73
+ // do nothing
74
+ }
75
+ }
76
+ </script>
77
+ </td>
78
+ </tr>
79
+ <?php }} ?>
80
+ </tbody>
81
+ </table>
82
+ </div>
83
+ </div>
84
+ </div>
app/design/frontend/base/default/layout/briel_reviewplus.xml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+
3
+ <layout version="0.1.0">
4
+ <reviewplus_index_index>
5
+ <reference name="content">
6
+ <block type="reviewplus/review" name="review" template="briel_reviewplus/review.phtml" />
7
+ </reference>
8
+ <reference name="root">
9
+ <action method="setTemplate">
10
+ <template>page/1column.phtml</template>
11
+ </action>
12
+ </reference>
13
+ <reference name="head">
14
+ <action method="setTitle" translate="title"><title>Briel ReviewPlus</title></action>
15
+ </reference>
16
+ </reviewplus_index_index>
17
+ </layout>
app/design/frontend/base/default/template/briel_reviewplus/review.phtml ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // get parameters
3
+ $get = $this->getRequest()->getParams();
4
+ $order_id = $get['oid'];
5
+ $get_hash = $get['hash'];
6
+ $rtng = (int)$get['rtng'];
7
+ // retrieve order data
8
+ $order = Mage::getModel('sales/order')->load($order_id);
9
+ $increment_id = $order->getIncrementId();
10
+ $nickname = $order->getCustomerName();
11
+ $customer_email = $order->getCustomerEmail();
12
+ $items = $order->getAllItems();
13
+ // check hash for security reasons
14
+ $salt = "Magento extension created by Briel Software";
15
+ $check_hash = md5($nickname.$order_id.$salt);
16
+ if ($get_hash == $check_hash) {
17
+ // assemble an array of skus from order details
18
+ $product_skus = array();
19
+ foreach ($items as $item_id => $item) {
20
+ $sku = $item->getSku();
21
+ array_push($product_skus, trim($sku));
22
+ }
23
+ // get collections for IF cases
24
+ $reviews_collection = Mage::getModel('reviewplus/reviews')->getCollection()->addFieldToFilter('order_id', $order_id);
25
+ foreach ($reviews_collection as $value) {
26
+ $detail_contents = Mage::getModel('reviewplus/reviews')->load($value->getId())->getData('product_review');
27
+ $review_status = Mage::getModel('reviewplus/reviews')->load($value->getId())->getData('review_status');
28
+ }
29
+ $clientlog_collection = Mage::getModel('reviewplus/clientlog')->getCollection()->addFieldToFilter('order_id', $order_id);
30
+ ?>
31
+ <div class="reviewplus-wrapper">
32
+ <?php if (count($reviews_collection) == 0) { ?>
33
+ <form name="review_form" action="<?php echo $this->getUrl('reviewplus/index/rate') ?>" method="post">
34
+ <table class="data-table">
35
+ <thead>
36
+ <tr>
37
+ <th width="35%" style="padding:10px 20px;"><p style="font-size:14px; margin:0; padding:0;"><?php echo $this->__('Product review for order #').$increment_id; ?></p></th>
38
+ <th width="65%"></th>
39
+ </tr>
40
+ </thead>
41
+ <tbody>
42
+ <?php foreach($product_skus as $val) {
43
+ // get PRODUCT ID by sku
44
+ $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $val);
45
+ $product_id = $product->getId();
46
+ // write data to REVIEWPLUS REVIEWS table
47
+ $reviewplus_reviews_db = Mage::getModel('reviewplus/reviews');
48
+ $reviewplus_reviews_db->setData('order_id', $order_id)->save();
49
+ $reviewplus_reviews_db->setData('product_sku', $val)->save();
50
+ $reviewplus_reviews_db->setData('customer_name', $nickname)->save();
51
+ $reviewplus_reviews_db->setData('customer_email', $customer_email)->save();
52
+ $reviewplus_reviews_db->setData('product_rating', $rtng)->save();
53
+ $reviewplus_reviews_db->setData('product_review', '')->save();
54
+ $reviewplus_reviews_db->setData('review_status', 'pending')->save();
55
+ $reviewplus_reviews_db->setData('store_id', Mage::app()->getStore()->getId())->save();
56
+ $reviewplus_reviews_id = $reviewplus_reviews_db->getId();
57
+ ?>
58
+ <tr>
59
+ <td style="padding:20px;">
60
+ <div class="form-list" style="margin-bottom:10px;">
61
+ <label><?php echo $product->getName(); ?></label>
62
+ </div>
63
+ <br />
64
+ <div class="product-image">
65
+ <img src="<?php echo $product->getSmallImageUrl(); ?>" alt="<?php echo $val; ?>" style="width:100px; height:100px;" />
66
+ </div>
67
+ </td>
68
+ <td style="padding:20px;">
69
+ <input type="hidden" name="sku[<?php echo $val; ?>]" value="<?php echo $val; ?>">
70
+ <input type="hidden" name="nickname[<?php echo $val; ?>]" value="<?php echo $nickname; ?>">
71
+ <input type="hidden" name="rating[<?php echo $val; ?>]" value="<?php echo $rtng; ?>">
72
+ <input type="hidden" name="rating-id[<?php echo $val; ?>]" value="<?php echo $reviewplus_reviews_id; ?>">
73
+ <div class="form-list">
74
+ <label class="required" for=""><em> *</em><?php echo $this->__('Review'); ?></label>
75
+ <div class="input-box">
76
+ <textarea name="detail[<?php echo $val; ?>]" class="required-entry" style="width:400px; height:120px;"></textarea>
77
+ </div>
78
+ </div>
79
+ </td>
80
+ </tr>
81
+ <?php } // end FOREACH ?>
82
+ </tbody>
83
+ <tfoot>
84
+ <tr>
85
+ <td style="border-top:1px solid #BEBCB7;"></td>
86
+ <td style="border-top:1px solid #BEBCB7; padding:10px 20px; text-align:right; vertical-align:middle;">
87
+ <button id="review-submit-btn" onclick="review_form.submit();" class="button" type="button" title="<?php echo $this->__('Submit'); ?>"><span><span><?php echo $this->__('Submit'); ?></span></span></button>
88
+ </td>
89
+ </tr>
90
+ </tfoot>
91
+ </table>
92
+ </form>
93
+ <?php } else if (count($reviews_collection) == count($product_skus) && strlen($detail_contents) == 0 && $review_status == 'pending') { ?>
94
+ <form name="review_form" action="<?php echo $this->getUrl('reviewplus/index/rate') ?>" method="post">
95
+ <table class="data-table">
96
+ <thead>
97
+ <tr>
98
+ <th width="35%" style="padding:10px 20px;"><p style="font-size:14px; margin:0; padding:0;"><?php echo $this->__('Product review for order #').$increment_id; ?></p></th>
99
+ <th width="65%"></th>
100
+ </tr>
101
+ </thead>
102
+ <tbody>
103
+ <?php foreach($product_skus as $val) {
104
+ $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $val);
105
+ $product_id = $product->getId();
106
+ $reviewplus_reviews_coll = Mage::getModel('reviewplus/reviews')->getCollection();
107
+ $reviewplus_reviews_coll->addFieldToFilter('order_id', $order_id)->addFieldToFilter('product_sku', $val);
108
+ foreach ($reviewplus_reviews_coll as $reviewplus_reviews_entry) {
109
+ $reviewplus_reviews_id = $reviewplus_reviews_entry->getId();
110
+ }
111
+ ?>
112
+ <tr>
113
+ <td style="padding:20px;">
114
+ <div class="form-list" style="margin-bottom:10px;">
115
+ <label><?php echo $product->getName(); ?></label>
116
+ </div>
117
+ <br />
118
+ <div class="product-image">
119
+ <img src="<?php echo $product->getSmallImageUrl(); ?>" alt="<?php echo $val; ?>" style="width:100px; height:100px;" />
120
+ </div>
121
+ </td>
122
+ <td style="padding:20px;">
123
+ <input type="hidden" name="sku[<?php echo $val; ?>]" value="<?php echo $val; ?>">
124
+ <input type="hidden" name="nickname[<?php echo $val; ?>]" value="<?php echo $nickname; ?>">
125
+ <input type="hidden" name="rating[<?php echo $val; ?>]" value="<?php echo $rtng; ?>">
126
+ <input type="hidden" name="rating-id[<?php echo $val; ?>]" value="<?php echo $reviewplus_reviews_id; ?>">
127
+ <div class="form-list">
128
+ <label class="required" for=""><em> *</em><?php echo $this->__('Review'); ?></label>
129
+ <div class="input-box">
130
+ <textarea name="detail[<?php echo $val; ?>]" class="required-entry" style="width:400px; height:120px;"></textarea>
131
+ </div>
132
+ </div>
133
+ </td>
134
+ </tr>
135
+ <?php } // end FOREACH ?>
136
+ </tbody>
137
+ <tfoot>
138
+ <tr>
139
+ <td style="border-top:1px solid #BEBCB7;"></td>
140
+ <td style="border-top:1px solid #BEBCB7; padding:10px 20px; text-align:right; vertical-align:middle;">
141
+ <button id="review-submit-btn" onclick="review_form.submit();" class="button" type="button" title="<?php echo $this->__('Submit'); ?>"><span><span><?php echo $this->__('Submit'); ?></span></span></button>
142
+ </td>
143
+ </tr>
144
+ </tfoot>
145
+ </table>
146
+ </form>
147
+ <?php } else if (count($reviews_collection) == count($product_skus) && strlen($detail_contents) == 0 && $review_status == 'approved') { ?>
148
+ <ul class="messages">
149
+ <li class="success-msg"><ul><li><span><?php echo $this->__('Thank you for reviewing our product(s)!'); ?></span></li></ul></li>
150
+ </ul>
151
+ <?php } else if (count($reviews_collection) == count($product_skus) && strlen($detail_contents) >= 2) { ?>
152
+ <ul class="messages">
153
+ <li class="success-msg"><ul><li><span><?php echo $this->__('Thank you for reviewing our product(s)!'); ?></span></li></ul></li>
154
+ </ul>
155
+ <?php } // end of collection IF ELSE IF ?>
156
+ </div>
157
+ <script type="text/javascript">
158
+ review_form = new VarienForm('review_form', false);
159
+ </script>
160
+
161
+ <?php } else { ?>
162
+ <ul class="messages">
163
+ <li class="error-msg"><ul><li><span><?php echo $this->__('You do not have the proper security token to view this page.'); ?></span></li></ul></li>
164
+ </ul>
165
+ <?php } // end HASH check IF ELSE ?>
app/etc/modules/Briel_ReviewPlus.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8" ?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Briel_ReviewPlus>
6
+ <active>true</active>
7
+ <codePool>community</codePool>
8
+ </Briel_ReviewPlus>
9
+ </modules>
10
+ </config>
app/locale/en_US/template/email/reviewplus_email.html ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
2
+ <div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
3
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
4
+ <tr>
5
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
6
+ <table cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0; background-color:#FFFFFF;">
7
+ <tr>
8
+ <td valign="top">
9
+ <a href="{{store url=""}}" style="color:#1E7EC8;"><img src="{{var logo_url}}" alt="{{var logo_alt}}" border="0"/></a>
10
+ </td>
11
+ </tr>
12
+ <tr>
13
+ <td valign="top">
14
+ <h1 style="font-size:21px; font-weight:normal; line-height:22px; margin:0;">Dear {{var namevar}},</h1>
15
+ <h3 style="font-size:16px; font-weight:normal; line-height:16px; margin:0 0 10px 0;">Thank you for choosing us!</h3>
16
+ <p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin-bottom:10px; padding:13px 18px; background:#F9F9F9;">Please take the time to give a short review for the product(s) you've recently purchased from our store.<p>
17
+ <p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin-bottom:10px; padding:13px 18px; background:#F9F9F9;"><span style="font-weight:bold;">Ordered product(s): </span><br />{{var purchased_products}}</p>
18
+ <p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin:0; padding:13px 18px; background:#F9F9F9;">How satisfied are you with the product(s) you've bought?</p>
19
+ <ul style="border:1px solid #E0E0E0;list-style:none; font-size:12px; line-height:16px; margin-top:0; margin-bottom:20px; padding-top:10px; padding-bottom:20px; background:#F9F9F9;">
20
+ <li style="list-style:none;"><a href="{{var review_page_url}}&rtng=5"><img src="{{config path='web/unsecure/base_url'}}/skin/frontend/base/default/images/reviewplus_email_template/5-stars.jpg" alt="Very satisfied" /></a></li>
21
+ <li style="list-style:none;"><a href="{{var review_page_url}}&rtng=4"><img src="{{config path='web/unsecure/base_url'}}/skin/frontend/base/default/images/reviewplus_email_template/4-stars.jpg" alt="Satisfied" /></a></li>
22
+ <li style="list-style:none;"><a href="{{var review_page_url}}&rtng=3"><img src="{{config path='web/unsecure/base_url'}}/skin/frontend/base/default/images/reviewplus_email_template/3-stars.jpg" alt="Neutral" /></a></li>
23
+ <li style="list-style:none;"><a href="{{var review_page_url}}&rtng=2"><img src="{{config path='web/unsecure/base_url'}}/skin/frontend/base/default/images/reviewplus_email_template/2-stars.jpg" alt="Unsatisfied" /></a></li>
24
+ <li style="list-style:none;"><a href="{{var review_page_url}}&rtng=1"><img src="{{config path='web/unsecure/base_url'}}/skin/frontend/base/default/images/reviewplus_email_template/1-star.jpg" alt="Very unsatisfied" /></a></li>
25
+ </ul>
26
+ </td>
27
+ </tr>
28
+ <tr>
29
+ <td align="center" style="background:#EAEAEA; text-align:center;"><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var namevar}}</strong></p></td>
30
+ </tr>
31
+ </table>
32
+ </td>
33
+ </tr>
34
+ </table>
35
+ </div>
36
+ </body>
package.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Briel_ReviewPlus</name>
4
+ <version>0.9.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl.html">GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>ReviewPlus will help boost the amount of reviews you receive for your products by sending a review notification email to customers.</summary>
10
+ <description>Once enabled and configured, the extension will start logging orders and as per user defined settings will start sending review notification emails.&lt;br /&gt;&#xD;
11
+ &#xD;
12
+ In order for this to work properly, make sure both cron and email sending are configured and working on your server. And please define a transactional email based on our template.&lt;br /&gt;&#xD;
13
+ &#xD;
14
+ Additionally, you can log individual orders via the ReviewPlus tab on Sales/Order/View page. There are also two customer grids, one for managing customers, and another for managing reviews.&lt;br /&gt;&#xD;
15
+ &#xD;
16
+ Once received, reviews can be approved from the Product Reviews grid and will appear on your site.</description>
17
+ <notes>Stable version, fully functional on our website.</notes>
18
+ <authors><author><name>Onel Velica</name><user>mage_briel</user><email>mage@briel.ro</email></author></authors>
19
+ <date>2013-04-30</date>
20
+ <time>18:21:05</time>
21
+ <contents><target name="magecommunity"><dir name="Briel"><dir name="ReviewPlus"><dir name="Block"><dir name="Adminhtml"><dir name="Clientlog"><file name="Grid.php" hash="c716d1abd289271e7768d973bbdf9c20"/><dir name="Renderer"><file name="Orderid.php" hash="d827cb94ef34cd3dd3fba167cd4b1501"/><file name="Sendtime.php" hash="5c6965be08be0856b9ae7be49be5c2d4"/><file name="Status.php" hash="0ae75b2f2740f047f3b2d07d8a80a507"/></dir></dir><file name="Clientlog.php" hash="54d09a42d11006f2425fb4c7227e6f0f"/><file name="Ordertab.php" hash="043b4df77ecf8311b56dd26722621d3a"/><dir name="Reviews"><file name="Grid.php" hash="77d93f579ed2e87d2ffbc9c9015f761c"/><dir name="Renderer"><file name="Rating.php" hash="34d9b45c8012d393bbad8361b55863c0"/></dir></dir><file name="Reviews.php" hash="57fc9e182ae5221c9fb2f4485a047dae"/></dir><file name="Review.php" hash="6b181bd14a05633e49c81758c2eeab57"/></dir><dir name="Helper"><file name="Data.php" hash="b6d18df74629c1499a1880fb9347a39e"/></dir><dir name="Model"><file name="Clientlog.php" hash="3d9d0b2896f596eed7c8b94e0ba8b457"/><dir name="Mysql4"><file name="Setup.php" hash="7afa5ad62c814dd2509791476354bd16"/></dir><file name="Observer.php" hash="e4d1aa55df34b499d4708ab372e1ba19"/><dir name="Resource"><dir name="Clientlog"><file name="Collection.php" hash="2b4a6adbe1faebcae17a8b6e2007a346"/></dir><file name="Clientlog.php" hash="b2570fccc223172f2194153a495c3034"/><dir name="Reviews"><file name="Collection.php" hash="a821396365da812545a22c1030076fad"/></dir><file name="Reviews.php" hash="b3c0b995486a6f0da43693998fb4bf58"/></dir><file name="Reviews.php" hash="bcd36606992998de00a52db4cf121e6a"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ClientlogController.php" hash="95b97a615c71b43f083d017d375ee05a"/><file name="OrdertabController.php" hash="52828b442e388679546455143dc0c374"/><file name="ReviewsController.php" hash="9e066cb473dd13640bcdfa051ce4dcc6"/></dir><file name="IndexController.php" hash="3ba73988c86e2c9831670ab26462afaa"/></dir><dir name="etc"><file name="config.xml" hash="b9c9bf607662563b74651423a34ead23"/><file name="system.xml" hash="0ff9e22bc9d29fd49c11b78e8f525682"/></dir><dir name="sql"><dir name="briel_reviewplus_setup"><file name="mysql4-install-0.9.0.php" hash="4b7d1693622586b1ffbf0c71d874d75a"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Briel_ReviewPlus.xml" hash="896cf8c524bc7cca77b68a94e9747f7b"/></dir></target><target name="magedesign"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="briel_reviewplus.xml" hash="20ec754748d22432060acae114be3937"/></dir><dir name="template"><dir name="briel_reviewplus"><file name="ordertab.phtml" hash="a586e49fa33021262b9579bb07cbb8b1"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="briel_reviewplus.xml" hash="5de4dbf6075c40c147da6c42c61ccf9b"/></dir><dir name="template"><dir name="briel_reviewplus"><file name="review.phtml" hash="2ea263fdac247bf7943ee54d99935e5e"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="en_US"><dir name="template"><dir name="email"><file name="reviewplus_email.html" hash="257c8947787cd00c1d3d1cc86b8c66fe"/></dir></dir></dir></dir></target><target name="mageskin"><dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="reviewplus_email_template"><file name="1-star.jpg" hash="3d6fbc36d97bde7d10cfe2ca1a86f89f"/><file name="2-stars.jpg" hash="311c7e4d5cb9af3badaa45436d28ad24"/><file name="3-stars.jpg" hash="859affa52072d9c6809c4dbd5f70d70a"/><file name="4-stars.jpg" hash="307572d5b17dbc2e4c6d201ac5c53e2a"/><file name="5-stars.jpg" hash="dbce095164d7af04b0950f5cf2a84e3b"/></dir></dir></dir></dir></dir></dir></target></contents>
22
+ <compatible/>
23
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
24
+ </package>
skin/frontend/base/default/images/reviewplus_email_template/1-star.jpg ADDED
Binary file
skin/frontend/base/default/images/reviewplus_email_template/2-stars.jpg ADDED
Binary file
skin/frontend/base/default/images/reviewplus_email_template/3-stars.jpg ADDED
Binary file
skin/frontend/base/default/images/reviewplus_email_template/4-stars.jpg ADDED
Binary file
skin/frontend/base/default/images/reviewplus_email_template/5-stars.jpg ADDED
Binary file