contacts_grid - Version 1.0.0

Version Notes

Contact Us data will be saved and can be viewed from admin grid.

Inquiry can also be respond from this grid.

Respond Email will be send to contacting person directly from detail page of this grid.

Different status of Inquiry is discriminated with different colored status on grid.

Multiple Mark As Read and multiple Delete option is available in mass action.

Download this release

Release Info

Developer Akhilesh Yadav
Extension contacts_grid
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Buzzzaky/Contactsgrid/Block/Adminhtml/Contactsgrid.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Buzzzaky_Contactsgrid_Block_Adminhtml_Contactsgrid extends Mage_Adminhtml_Block_Widget_Grid_Container{
5
+
6
+ public function __construct()
7
+ {
8
+
9
+ $this->_controller = "adminhtml_contactsgrid";
10
+ $this->_blockGroup = "contactsgrid";
11
+ $this->_headerText = Mage::helper("contactsgrid")->__("List Of All Contact Us Comments.");
12
+ parent::__construct();
13
+ $this->_removeButton('add');
14
+ }
15
+
16
+ }
app/code/community/Buzzzaky/Contactsgrid/Block/Adminhtml/Contactsgrid/Edit.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Buzzzaky_Contactsgrid_Block_Adminhtml_Contactsgrid_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
4
+
5
+ public function __construct() {
6
+
7
+ parent::__construct();
8
+ $this->_objectId = "id";
9
+ $this->_blockGroup = "contactsgrid";
10
+ $this->_controller = "adminhtml_contactsgrid";
11
+ $this->_updateButton("save", "label", Mage::helper("contactsgrid")->__("Reply comment"));
12
+ $this->_updateButton("delete", "label", Mage::helper("contactsgrid")->__("Delete Comment"));
13
+ if ((int)Mage::registry("contactsgrid_data")->getStatus() === Buzzzaky_Contactsgrid_Model_Contactsgrid::STATUS_REPLIED) {
14
+ $this->_removeButton(save);
15
+ }
16
+ }
17
+
18
+ public function getHeaderText() {
19
+ if (Mage::registry("contactsgrid_data") && Mage::registry("contactsgrid_data")->getId()) {
20
+ return Mage::helper("contactsgrid")->__("Details of Contact Us item '%s'", $this->htmlEscape(Mage::registry("contactsgrid_data")->getId()));
21
+ }
22
+ }
23
+
24
+ }
app/code/community/Buzzzaky/Contactsgrid/Block/Adminhtml/Contactsgrid/Edit/Form.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Buzzzaky_Contactsgrid_Block_Adminhtml_Contactsgrid_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+ $form = new Varien_Data_Form(array(
7
+ "id" => "edit_form",
8
+ "action" => $this->getUrl("*/*/save", array("id" => $this->getRequest()->getParam("id"))),
9
+ "method" => "post",
10
+ "enctype" => "multipart/form-data",
11
+ )
12
+ );
13
+ $form->setUseContainer(true);
14
+ $this->setForm($form);
15
+ return parent::_prepareForm();
16
+ }
17
+
18
+ }
app/code/community/Buzzzaky/Contactsgrid/Block/Adminhtml/Contactsgrid/Edit/Tab/Form.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Buzzzaky_Contactsgrid_Block_Adminhtml_Contactsgrid_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+
7
+ $form = new Varien_Data_Form();
8
+ $this->setForm($form);
9
+ $fieldset = $form->addFieldset("contactsgrid_form", array("legend" => Mage::helper("contactsgrid")->__("Contact Us information")));
10
+
11
+ $fieldset->addField("name", "label", array(
12
+ "label" => Mage::helper("contactsgrid")->__("Name"),
13
+ "name" => "name",
14
+ "readonly" => true,
15
+ ));
16
+
17
+ $fieldset->addField("email", "label", array(
18
+ "label" => Mage::helper("contactsgrid")->__("Email"),
19
+ "name" => "email",
20
+ "readonly" => true,
21
+ ));
22
+
23
+ $fieldset->addField("telephone", "label", array(
24
+ "label" => Mage::helper("contactsgrid")->__("Telephone"),
25
+ "name" => "telephone",
26
+ "readonly" => true,
27
+ ));
28
+
29
+ $fieldset->addField("comment", "label", array(
30
+ "label" => Mage::helper("contactsgrid")->__("Comment"),
31
+ "name" => "comment",
32
+ "readonly" => true,
33
+ ));
34
+
35
+ $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config');
36
+ $fieldset->addField('reply', 'editor', array(
37
+ 'name' => 'reply',
38
+ 'label' => Mage::helper('contactsgrid')->__('Reply to comment'),
39
+ 'title' => Mage::helper('contactsgrid')->__('Reply to comment'),
40
+ 'style' => 'height: 500px;',
41
+ 'wysiwyg' => true,
42
+ 'required' => TRUE,
43
+ 'config' => $wysiwygConfig
44
+ ));
45
+ $fieldset->addField('id', 'hidden', array(
46
+ 'name' => 'id',
47
+ ));
48
+ if (Mage::getSingleton("adminhtml/session")->getContactsgridData()) {
49
+ $form->setValues(Mage::getSingleton("adminhtml/session")->getContactsgridData());
50
+ Mage::getSingleton("adminhtml/session")->setContactsgridData(null);
51
+ } elseif (Mage::registry("contactsgrid_data")) {
52
+ $form->setValues(Mage::registry("contactsgrid_data")->getData());
53
+ }
54
+ return parent::_prepareForm();
55
+ }
56
+
57
+ }
app/code/community/Buzzzaky/Contactsgrid/Block/Adminhtml/Contactsgrid/Edit/Tabs.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Buzzzaky_Contactsgrid_Block_Adminhtml_Contactsgrid_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
3
+ {
4
+ /**
5
+ * Load Wysiwyg on demand and Prepare layout
6
+ */
7
+ protected function _prepareLayout() {
8
+ parent::_prepareLayout();
9
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
10
+ $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
11
+ }
12
+ }
13
+ public function __construct()
14
+ {
15
+ parent::__construct();
16
+ $this->setId("contactsgrid_tabs");
17
+ $this->setDestElementId("edit_form");
18
+ }
19
+ protected function _beforeToHtml()
20
+ {
21
+ $this->addTab("form_section", array(
22
+ "label" => Mage::helper("contactsgrid")->__("Contact Us information"),
23
+ "title" => Mage::helper("contactsgrid")->__("Contact Us information"),
24
+ "content" => $this->getLayout()->createBlock("contactsgrid/adminhtml_contactsgrid_edit_tab_form")->toHtml(),
25
+ ));
26
+ return parent::_beforeToHtml();
27
+ }
28
+
29
+ }
app/code/community/Buzzzaky/Contactsgrid/Block/Adminhtml/Contactsgrid/Grid.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Buzzzaky_Contactsgrid_Block_Adminhtml_Contactsgrid_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId("contactsgridGrid");
8
+ $this->setDefaultSort("id");
9
+ $this->setDefaultDir("DESC");
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+
13
+ protected function _prepareCollection() {
14
+ $collection = Mage::getModel("contactsgrid/contactsgrid")->getCollection();
15
+ $this->setCollection($collection);
16
+ return parent::_prepareCollection();
17
+ }
18
+
19
+ protected function _prepareColumns() {
20
+ $this->addColumn("status", array(
21
+ "header" => Mage::helper("contactsgrid")->__("Status"),
22
+ "index" => "status",
23
+ 'type' => 'options',
24
+ "width" => "100px",
25
+ "options" => array(
26
+ Buzzzaky_Contactsgrid_Model_Contactsgrid::STATUS_READ => 'Read',
27
+ Buzzzaky_Contactsgrid_Model_Contactsgrid::STATUS_UNREAD => 'Unread',
28
+ Buzzzaky_Contactsgrid_Model_Contactsgrid::STATUS_REPLIED => 'Replied'
29
+ ),
30
+ 'frame_callback' => array($this, 'decorateStatus')
31
+ ));
32
+ $this->addColumn("id", array(
33
+ "header" => Mage::helper("contactsgrid")->__("ID"),
34
+ "align" => "right",
35
+ "width" => "50px",
36
+ "type" => "number",
37
+ "index" => "id",
38
+ ));
39
+
40
+ $this->addColumn("name", array(
41
+ "header" => Mage::helper("contactsgrid")->__("Name"),
42
+ "index" => "name",
43
+ ));
44
+ $this->addColumn("email", array(
45
+ "header" => Mage::helper("contactsgrid")->__("Email"),
46
+ "index" => "email",
47
+ ));
48
+ $this->addColumn("telephone", array(
49
+ "header" => Mage::helper("contactsgrid")->__("Telephone"),
50
+ "index" => "telephone",
51
+ ));
52
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
53
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
54
+
55
+ return parent::_prepareColumns();
56
+ }
57
+ /**
58
+ * Decorate status column values
59
+ *
60
+ * @return string
61
+ */
62
+ public function decorateStatus($value, $row, $column, $isExport)
63
+ {
64
+ if (!$row->getStatus()) {
65
+ $cell = '<span class="grid-severity-critical"><span>'.$value.'</span></span>';
66
+ } else {
67
+ if ((int)$row->getStatus() === Buzzzaky_Contactsgrid_Model_Contactsgrid::STATUS_REPLIED) {
68
+ $cell = '<span class="grid-severity-notice"><span>'.$value.'</span></span>';
69
+ } else {
70
+ $cell = '<span class="grid-severity-minor"><span>'.$value.'</span></span>';
71
+ }
72
+ }
73
+ return $cell;
74
+ }
75
+
76
+ public function getRowUrl($row) {
77
+ return $this->getUrl("*/*/edit", array("id" => $row->getId()));
78
+ }
79
+
80
+ protected function _prepareMassaction() {
81
+ $this->setMassactionIdField('id');
82
+ $this->getMassactionBlock()->setFormFieldName('ids');
83
+ $this->getMassactionBlock()->setUseSelectAll(true);
84
+ $this->getMassactionBlock()->addItem('remove_contactsgrid', array(
85
+ 'label' => Mage::helper('contactsgrid')->__('Remove Contactsgrid'),
86
+ 'url' => $this->getUrl('*/adminhtml_contactsgrid/massRemove'),
87
+ 'confirm' => Mage::helper('contactsgrid')->__('Are you sure?')
88
+ ));
89
+ $this->getMassactionBlock()->addItem('mark_read_contacts', array(
90
+ 'label' => Mage::helper('contactsgrid')->__('Mark All Read'),
91
+ 'url' => $this->getUrl('*/adminhtml_contactsgrid/readAll'),
92
+ 'confirm' => Mage::helper('contactsgrid')->__('Are you sure?')
93
+ ));
94
+ return $this;
95
+ }
96
+
97
+ }
app/code/community/Buzzzaky/Contactsgrid/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Buzzzaky_Contactsgrid_Helper_Data extends Mage_Core_Helper_Abstract {
3
+
4
+ }
app/code/community/Buzzzaky/Contactsgrid/Model/Contactsgrid.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Buzzzaky_Contactsgrid_Model_Contactsgrid extends Mage_Core_Model_Abstract
4
+ {
5
+ const STATUS_UNREAD = 0;
6
+ const STATUS_READ = 1;
7
+ const STATUS_REPLIED = 2;
8
+
9
+ protected function _construct(){
10
+
11
+ $this->_init("contactsgrid/contactsgrid");
12
+
13
+ }
14
+
15
+ }
16
+
app/code/community/Buzzzaky/Contactsgrid/Model/Mysql4/Contactsgrid.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Buzzzaky_Contactsgrid_Model_Mysql4_Contactsgrid extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ protected function _construct()
5
+ {
6
+ $this->_init("contactsgrid/contactsgrid", "id");
7
+ }
8
+ }
app/code/community/Buzzzaky/Contactsgrid/Model/Mysql4/Contactsgrid/Collection.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Buzzzaky_Contactsgrid_Model_Mysql4_Contactsgrid_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+
5
+ public function _construct(){
6
+ $this->_init("contactsgrid/contactsgrid");
7
+ }
8
+
9
+
10
+
11
+ }
12
+
app/code/community/Buzzzaky/Contactsgrid/controllers/Adminhtml/ContactsgridController.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Buzzzaky_Contactsgrid_Adminhtml_ContactsgridController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ protected function _initAction() {
6
+ $this->loadLayout()->_setActiveMenu("contactsgrid/contactsgrid")->_addBreadcrumb(Mage::helper("adminhtml")->__("Contactsgrid Manager"), Mage::helper("adminhtml")->__("Contactsgrid Manager"));
7
+ return $this;
8
+ }
9
+
10
+ public function indexAction() {
11
+ $this->_title($this->__("Contactsgrid"));
12
+ $this->_title($this->__("Manager Contact Us Grid"));
13
+
14
+ $this->_initAction();
15
+ $this->renderLayout();
16
+ }
17
+
18
+ public function editAction() {
19
+ $this->_title($this->__("Contact Us Grid"));
20
+ $id = $this->getRequest()->getParam("id");
21
+ $model = Mage::getModel("contactsgrid/contactsgrid")->load($id);
22
+ if ($model->getId()) {
23
+ Mage::register("contactsgrid_data", $model);
24
+ $this->loadLayout();
25
+ $this->_setActiveMenu("contactsgrid/contactsgrid");
26
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Contactsgrid Manager"), Mage::helper("adminhtml")->__("Contactsgrid Manager"));
27
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Contactsgrid Description"), Mage::helper("adminhtml")->__("Contactsgrid Description"));
28
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
29
+ $this->_addContent($this->getLayout()->createBlock("contactsgrid/adminhtml_contactsgrid_edit"))->_addLeft($this->getLayout()->createBlock("contactsgrid/adminhtml_contactsgrid_edit_tabs"));
30
+ if (!$model->getStatus())
31
+ $model->setStatus(Buzzzaky_Contactsgrid_Model_Contactsgrid::STATUS_READ);
32
+ $model->save();
33
+ $this->renderLayout();
34
+ } else {
35
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("contactsgrid")->__("Item does not exist."));
36
+ $this->_redirect("*/*/");
37
+ }
38
+ }
39
+
40
+ public function saveAction() {
41
+ $post_data = $this->getRequest()->getPost();
42
+ $model = Mage::getModel("contactsgrid/contactsgrid");
43
+ $collection = $model->getCollection()->addFieldToFilter('id', array('eq' => $post_data['id']))->getData();
44
+ if ($post_data) {
45
+ try {
46
+ $data = array();
47
+ $data['reply_date'] = time();
48
+ $data['reply'] = $post_data["reply"];
49
+ $data['status'] = Buzzzaky_Contactsgrid_Model_Contactsgrid::STATUS_REPLIED;
50
+ $model->load($post_data['id']);
51
+ $model->addData($data);
52
+ $model->save();
53
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::getStoreConfig('cntactsgrid/contactus/send_sucess_message'));
54
+ Mage::getSingleton("adminhtml/session")->setContactsgridData(false);
55
+ $this->sendReplyEmail($collection[0], $post_data["reply"]);
56
+ if ($this->getRequest()->getParam("back")) {
57
+ $this->_redirect("*/*/edit", array("id" => $model->getId()));
58
+ return;
59
+ }
60
+ $this->_redirect("*/*/");
61
+ return;
62
+ } catch (Exception $e) {
63
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
64
+ Mage::getSingleton("adminhtml/session")->setContactsgridData($this->getRequest()->getPost());
65
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
66
+ return;
67
+ }
68
+ }
69
+ $this->_redirect("*/*/");
70
+ }
71
+
72
+ public function sendReplyEmail($emailData, $reply) {
73
+ $commentHistory = '<p>...</p><p> On ' . Mage::helper('core')->formatDate($emailData['comment_date'], 'full', false)
74
+ . ' at ' . date('h:i A', $emailData['comment_date'])
75
+ . ', ' . $emailData['name'] . ' &lt' . $emailData['email'] . '&gt ' . ' wrote:</p>';
76
+ $html = $reply . $commentHistory . $emailData['comment'];
77
+ $mail = Mage::getModel('core/email');
78
+ $mail->setToName($emailData['name']);
79
+ $mail->setToEmail($emailData['email']);
80
+ $mail->setBody($html);
81
+ $mail->setSubject(Mage::getStoreConfig('cntactsgrid/contactus/subject'));
82
+ $mail->setFromEmail(Mage::getStoreConfig('cntactsgrid/contactus/sender_email'));
83
+ $mail->setFromName(Mage::getStoreConfig('cntactsgrid/contactus/sender_name'));
84
+ $mail->setType('html'); // YOu can use Html or text as Mail format
85
+ $mail->send();
86
+ }
87
+
88
+ public function deleteAction() {
89
+ if ($this->getRequest()->getParam("id") > 0) {
90
+ try {
91
+ $model = Mage::getModel("contactsgrid/contactsgrid");
92
+ $model->setId($this->getRequest()->getParam("id"))->delete();
93
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item was successfully deleted"));
94
+ $this->_redirect("*/*/");
95
+ } catch (Exception $e) {
96
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
97
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
98
+ }
99
+ }
100
+ $this->_redirect("*/*/");
101
+ }
102
+
103
+ public function massRemoveAction() {
104
+ try {
105
+ $ids = $this->getRequest()->getPost('ids', array());
106
+ foreach ($ids as $id) {
107
+ $model = Mage::getModel("contactsgrid/contactsgrid");
108
+ $model->setId($id)->delete();
109
+ }
110
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item(s) was successfully removed"));
111
+ } catch (Exception $e) {
112
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
113
+ }
114
+ $this->_redirect('*/*/');
115
+ }
116
+
117
+ public function readAllAction() {
118
+ try {
119
+ $ids = $this->getRequest()->getPost('ids', array());
120
+ foreach ($ids as $id) {
121
+ $model = Mage::getModel("contactsgrid/contactsgrid")->load($id);
122
+ if (!$model->getStatus())
123
+ $model->setStatus(Buzzzaky_Contactsgrid_Model_Contactsgrid::STATUS_READ);
124
+ $model->save();
125
+ }
126
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item(s) was successfully marked as read"));
127
+ } catch (Exception $e) {
128
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
129
+ }
130
+ $this->_redirect('*/*/');
131
+ }
132
+
133
+ /**
134
+ * Export order grid to CSV format
135
+ */
136
+ public function exportCsvAction() {
137
+ $fileName = 'contactsgrid.csv';
138
+ $grid = $this->getLayout()->createBlock('contactsgrid/adminhtml_contactsgrid_grid');
139
+ $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
140
+ }
141
+
142
+ /**
143
+ * Export order grid to Excel XML format
144
+ */
145
+ public function exportExcelAction() {
146
+ $fileName = 'contactsgrid.xml';
147
+ $grid = $this->getLayout()->createBlock('contactsgrid/adminhtml_contactsgrid_grid');
148
+ $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
149
+ }
150
+
151
+ }
app/code/community/Buzzzaky/Contactsgrid/controllers/Contacts/IndexController.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once "Mage/Contacts/controllers/IndexController.php";
4
+
5
+ class Buzzzaky_Contactsgrid_Contacts_IndexController extends Mage_Contacts_IndexController {
6
+
7
+ public function postAction() {
8
+ $post = $this->getRequest()->getPost();
9
+ if ($post) {
10
+ $translate = Mage::getSingleton('core/translate');
11
+ /* @var $translate Mage_Core_Model_Translate */
12
+ $translate->setTranslateInline(false);
13
+ try {
14
+ $postObject = new Varien_Object();
15
+ $postObject->setData($post);
16
+
17
+ $error = false;
18
+
19
+ if (!Zend_Validate::is(trim($post['name']), 'NotEmpty')) {
20
+ $error = true;
21
+ }
22
+
23
+ if (!Zend_Validate::is(trim($post['comment']), 'NotEmpty')) {
24
+ $error = true;
25
+ }
26
+
27
+ if (!Zend_Validate::is(trim($post['email']), 'EmailAddress')) {
28
+ $error = true;
29
+ }
30
+
31
+ if (Zend_Validate::is(trim($post['hideit']), 'NotEmpty')) {
32
+ $error = true;
33
+ }
34
+
35
+ if ($error) {
36
+ throw new Exception();
37
+ }
38
+ if (!Mage::getStoreConfig('cntactsgrid/contactus/stop_mailbox_emails')) :
39
+ $mailTemplate = Mage::getModel('core/email_template');
40
+ /* @var $mailTemplate Mage_Core_Model_Email_Template */
41
+ $mailTemplate->setDesignConfig(array('area' => 'frontend'))
42
+ ->setReplyTo($post['email'])
43
+ ->sendTransactional(
44
+ Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE), Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER), Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT), null, array('data' => $postObject)
45
+ );
46
+
47
+ if (!$mailTemplate->getSentSuccess()) {
48
+ throw new Exception();
49
+ }
50
+ endif;
51
+
52
+ $translate->setTranslateInline(true);
53
+
54
+ Mage::getSingleton('customer/session')->addSuccess(Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.'));
55
+ if (Mage::getStoreConfig('cntactsgrid/contactus/enable'))
56
+ $this->saveContactsDetails($post);
57
+
58
+ $this->_redirect('*/*/');
59
+
60
+ return;
61
+ } catch (Exception $e) {
62
+ $translate->setTranslateInline(true);
63
+
64
+ Mage::getSingleton('customer/session')->addError(Mage::helper('contacts')->__('Unable to submit your request. Please, try again later'));
65
+ $this->_redirect('*/*/');
66
+ return;
67
+ }
68
+ } else {
69
+ $this->_redirect('*/*/');
70
+ }
71
+ }
72
+
73
+ public function saveContactsDetails($data) {
74
+ $model = Mage::getModel('contactsgrid/contactsgrid');
75
+ try {
76
+ $model->addData($data);
77
+ $model->save();
78
+ return;
79
+ } catch (Exception $exc) {
80
+ return;
81
+ }
82
+ }
83
+
84
+ }
app/code/community/Buzzzaky/Contactsgrid/etc/adminhtml.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <admin>
6
+ <children>
7
+ <system>
8
+ <children>
9
+ <config>
10
+ <children>
11
+ <cntactsgrid translate="title" module="contactsgrid">
12
+ <title>Contact Us Section</title>
13
+ <sort_order>0</sort_order>
14
+ </cntactsgrid>
15
+ </children>
16
+ </config>
17
+ </children>
18
+ </system>
19
+ </children>
20
+ </admin>
21
+ </resources>
22
+ </acl>
23
+ </config>
app/code/community/Buzzzaky/Contactsgrid/etc/config.xml ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Buzzzaky_Contactsgrid>
5
+ <version>1.0.0</version>
6
+ </Buzzzaky_Contactsgrid>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <contactsgrid>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Buzzzaky_Contactsgrid</module>
14
+ <frontName>contactsgrid</frontName>
15
+ </args>
16
+ </contactsgrid>
17
+ </routers>
18
+ </frontend>
19
+ <global>
20
+ <rewrite ifconfig="cntactsgrid/contactus/enable">
21
+ <Buzzzaky_contactsgrid_contacts_indexcontroller>
22
+ <from><![CDATA[#^/contacts/index/#]]></from> <!-- Mage_Contacts_IndexController -->
23
+ <to>/contactsgrid/contacts_index/</to> <!-- Buzzzaky_Contactsgrid_Contacts_IndexController -->
24
+ </Buzzzaky_contactsgrid_contacts_indexcontroller>
25
+ </rewrite>
26
+ <helpers>
27
+ <contactsgrid>
28
+ <class>Buzzzaky_Contactsgrid_Helper</class>
29
+ </contactsgrid>
30
+ </helpers>
31
+ <blocks>
32
+ <contactsgrid>
33
+ <class>Buzzzaky_Contactsgrid_Block</class>
34
+ </contactsgrid>
35
+ </blocks>
36
+ <models>
37
+ <contactsgrid>
38
+ <class>Buzzzaky_Contactsgrid_Model</class>
39
+ <resourceModel>contactsgrid_mysql4</resourceModel>
40
+ </contactsgrid>
41
+ <contactsgrid_mysql4>
42
+ <class>Buzzzaky_Contactsgrid_Model_Mysql4</class>
43
+ <entities>
44
+ <contactsgrid>
45
+ <table>contacts_grid</table>
46
+ </contactsgrid>
47
+ </entities>
48
+ </contactsgrid_mysql4>
49
+ </models>
50
+ <resources>
51
+ <contactsgrid_setup>
52
+ <setup>
53
+ <module>Buzzzaky_Contactsgrid</module>
54
+ </setup>
55
+ <connection>
56
+ <use>core_setup</use>
57
+ </connection>
58
+ </contactsgrid_setup>
59
+ <contactsgrid_write>
60
+ <connection>
61
+ <use>core_write</use>
62
+ </connection>
63
+ </contactsgrid_write>
64
+ <contactsgrid_read>
65
+ <connection>
66
+ <use>core_read</use>
67
+ </connection>
68
+ </contactsgrid_read>
69
+ </resources>
70
+ </global>
71
+ <admin>
72
+ <routers>
73
+ <contactsgrid>
74
+ <use>admin</use>
75
+ <args>
76
+ <module>Buzzzaky_Contactsgrid</module>
77
+ <frontName>admin_contactsgrid</frontName>
78
+ </args>
79
+ </contactsgrid>
80
+ </routers>
81
+ </admin>
82
+ <adminhtml>
83
+ <menu>
84
+ <contactsgrid module="contactsgrid">
85
+ <title>Contact Us Grid</title>
86
+ <sort_order>100</sort_order>
87
+ <children>
88
+ <contactsgrid module="contactsgrid">
89
+ <title>Manage Contacts List</title>
90
+ <sort_order>0</sort_order>
91
+ <action>admin_contactsgrid/adminhtml_contactsgrid</action>
92
+ </contactsgrid>
93
+ </children>
94
+ </contactsgrid>
95
+ </menu>
96
+ <acl>
97
+ <resources>
98
+ <all>
99
+ <title>Allow Everything</title>
100
+ </all>
101
+ <admin>
102
+ <children>
103
+ <contactsgrid translate="title" module="contactsgrid">
104
+ <title>Contactsgrid</title>
105
+ <sort_order>1000</sort_order>
106
+ <children>
107
+ <contactsgrid translate="title">
108
+ <title>Manage Contactsgrid</title>
109
+ <sort_order>0</sort_order>
110
+ </contactsgrid>
111
+ </children>
112
+ </contactsgrid>
113
+ </children>
114
+ </admin>
115
+ </resources>
116
+ </acl>
117
+ <layout>
118
+ <updates>
119
+ <contactsgrid>
120
+ <file>contactsgrid.xml</file>
121
+ </contactsgrid>
122
+ </updates>
123
+ </layout>
124
+ </adminhtml>
125
+ </config>
app/code/community/Buzzzaky/Contactsgrid/etc/system.xml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <Buzzzaky translate="label" module="contactsgrid">
5
+ <label>Buzzzaky</label>
6
+ <sort_order>0</sort_order>
7
+ </Buzzzaky>
8
+ </tabs>
9
+ <sections>
10
+ <cntactsgrid translate="label" module="contactsgrid">
11
+ <label>Contact Us Grid</label>
12
+ <tab>Buzzzaky</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>0</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <contactus translate="label">
20
+ <label>Contact Us</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>0</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <enable translate="label">
28
+ <label>Enable / Disable</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>0</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </enable>
36
+ <stop_mailbox_emails translate="label">
37
+ <label>Stop emails on mailbox </label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>1</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ <comment>Default emails on mailbox can be disable.</comment>
45
+ </stop_mailbox_emails>
46
+ <subject translate="label">
47
+ <label>Reply Subject</label>
48
+ <frontend_type>text</frontend_type>
49
+ <sort_order>2</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ <comment>Subject for reply email.</comment>
54
+ </subject>
55
+ <sender_name translate="label">
56
+ <label>Reply Sender Name</label>
57
+ <frontend_type>text</frontend_type>
58
+ <sort_order>3</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ <comment>Enter reply sender name.</comment>
63
+ </sender_name>
64
+ <sender_email translate="label">
65
+ <label>Reply Sender Email</label>
66
+ <frontend_type>text</frontend_type>
67
+ <sort_order>4</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ <comment>Enter reply sender email.</comment>
72
+ </sender_email>
73
+ <send_sucess_message translate="label">
74
+ <label>Reply send success message.</label>
75
+ <frontend_type>text</frontend_type>
76
+ <sort_order>5</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ <comment>Enter email send success message to show on admin.</comment>
81
+ </send_sucess_message>
82
+ </fields>
83
+ </contactus>
84
+ </groups>
85
+ </cntactsgrid>
86
+ </sections>
87
+ </config>
app/code/community/Buzzzaky/Contactsgrid/sql/contactsgrid_setup/mysql4-install-1.0.1.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $installer->run("
7
+
8
+ CREATE TABLE IF NOT EXISTS `contacts_grid` (
9
+ `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
10
+ `name` varchar(255) NOT NULL DEFAULT '',
11
+ `email` varchar(255) NOT NULL DEFAULT '',
12
+ `telephone` varchar(20) NOT NULL DEFAULT '',
13
+ `comment` text,
14
+ `reply` text,
15
+ `comment_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
16
+ `reply_date` datetime NOT NULL,
17
+ `status` tinyint(4) NOT NULL,
18
+ PRIMARY KEY (`id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='ACL Asserts' AUTO_INCREMENT=11 ;
20
+ ");
21
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/contactsgrid.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <contactsgrid_adminhtml_contactsgrid_index>
4
+ <reference name="content">
5
+ <block type="contactsgrid/adminhtml_contactsgrid" name="contactsgrid" />
6
+ </reference>
7
+ </contactsgrid_adminhtml_contactsgrid_index>
8
+ </layout>
app/etc/modules/Buzzzaky_Contactsgrid.xml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Buzzzaky_Contactsgrid>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <version>1.0.0</version>
8
+ </Buzzzaky_Contactsgrid>
9
+ </modules>
10
+ </config>
package.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>contacts_grid</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Contact Us details saves in admin grid form. Admin can respond to customer from this grid directly. </summary>
10
+ <description>Contact Us data will be saved and can be viewed from admin grid. &#xD;
11
+ &#xD;
12
+ Inquiry can also be respond from this grid.&#xD;
13
+ &#xD;
14
+ Respond Email will be send to contacting person directly from detail page of this grid.&#xD;
15
+ &#xD;
16
+ Different status of Inquiry is discriminated with different colored status on grid. &#xD;
17
+ &#xD;
18
+ Multiple Mark As Read and multiple Delete option is available in mass action. </description>
19
+ <notes>Contact Us data will be saved and can be viewed from admin grid. &#xD;
20
+ &#xD;
21
+ Inquiry can also be respond from this grid.&#xD;
22
+ &#xD;
23
+ Respond Email will be send to contacting person directly from detail page of this grid.&#xD;
24
+ &#xD;
25
+ Different status of Inquiry is discriminated with different colored status on grid. &#xD;
26
+ &#xD;
27
+ Multiple Mark As Read and multiple Delete option is available in mass action. </notes>
28
+ <authors><author><name>Akhilesh Yadav</name><user>BuzzzAky</user><email>akhileshaky@gmail.com</email></author></authors>
29
+ <date>2016-07-12</date>
30
+ <time>13:38:43</time>
31
+ <contents><target name="mageetc"><dir name="modules"><file name="Buzzzaky_Contactsgrid.xml" hash="1e648f02a3ab874e8b9826a26453718d"/></dir></target><target name="magecommunity"><dir name="Buzzzaky"><dir name="Contactsgrid"><dir name="Block"><dir name="Adminhtml"><dir name="Contactsgrid"><dir name="Edit"><file name="Form.php" hash="7d3f604ecbff4927218a7f681173bffd"/><dir name="Tab"><file name="Form.php" hash="3ebb0dc62f3d6a7c8515a53135bea5b4"/></dir><file name="Tabs.php" hash="5ad911a8b5ea2c6c0a727c97ef226735"/></dir><file name="Edit.php" hash="e0fa5a7cd7722c7f6ce58d8ba6dfaa92"/><file name="Grid.php" hash="5337a34b834c70d4411ac4376a2e91dd"/></dir><file name="Contactsgrid.php" hash="a82ae3d396f61b19b3f5c4243d203fbd"/></dir></dir><dir name="Helper"><file name="Data.php" hash="3138b3d3de34dce1ebaf651d869be0b4"/></dir><dir name="Model"><file name="Contactsgrid.php" hash="05235de796ec06b9889b95f391c39efb"/><dir name="Mysql4"><dir name="Contactsgrid"><file name="Collection.php" hash="d731151b23f7819795636645dca62741"/></dir><file name="Contactsgrid.php" hash="b5a3568429a8d90a316dbd44a88c38ae"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="ContactsgridController.php" hash="cf1d6057f9e462962e8ba51b1d3d9072"/></dir><dir name="Contacts"><file name="IndexController.php" hash="3466851beecdb4decf605ec1b63f6779"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="3d5ae1bf513d2c12ca015f17b5d32d81"/><file name="config.xml" hash="dace33bcd2803896ea49f3ad81f4da8f"/><file name="system.xml" hash="e02896412e8e6be06098f1a092787039"/></dir><dir name="sql"><dir name="contactsgrid_setup"><file name="mysql4-install-1.0.1.php" hash="f5f58c7b25f25438e81f1df67982cba4"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="contactsgrid.xml" hash="25f774b092dfabdd26fdb2be70f402f1"/></dir></dir></dir></dir></target></contents>
32
+ <compatible/>
33
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
34
+ </package>