ansh_custom_contact - Version 1.0.5

Version Notes

Stable version

Download this release

Release Info

Developer Ansh
Extension ansh_custom_contact
Version 1.0.5
Comparing to
See all releases


Version 1.0.5

Files changed (43) hide show
  1. app/code/local/Ansh/Customcontact/Block/Adminhtml/CustomContact.php~ +12 -0
  2. app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact.php +13 -0
  3. app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit.php +44 -0
  4. app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit.php~ +45 -0
  5. app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit/Form.php +19 -0
  6. app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit/Form.php~ +19 -0
  7. app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit/Tab/Form.php +63 -0
  8. app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit/Tab/Form.php~ +76 -0
  9. app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit/Tabs.php +22 -0
  10. app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit/Tabs.php~ +24 -0
  11. app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Grid.php +115 -0
  12. app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Grid.php~ +129 -0
  13. app/code/local/Ansh/Customcontact/Block/CustomContact.php~ +30 -0
  14. app/code/local/Ansh/Customcontact/Block/Customcontact.php +18 -0
  15. app/code/local/Ansh/Customcontact/Helper/Data.php +8 -0
  16. app/code/local/Ansh/Customcontact/Helper/Data.php~ +0 -0
  17. app/code/local/Ansh/Customcontact/Model/CustomContact.php~ +10 -0
  18. app/code/local/Ansh/Customcontact/Model/Customcontact.php +10 -0
  19. app/code/local/Ansh/Customcontact/Model/Mysql4/CustomContact.php~ +10 -0
  20. app/code/local/Ansh/Customcontact/Model/Mysql4/Customcontact.php +10 -0
  21. app/code/local/Ansh/Customcontact/Model/Mysql4/Customcontact/Collection.php +10 -0
  22. app/code/local/Ansh/Customcontact/Model/Mysql4/Customcontact/Collection.php~ +10 -0
  23. app/code/local/Ansh/Customcontact/Model/Options.php~ +0 -0
  24. app/code/local/Ansh/Customcontact/Model/Status.php +15 -0
  25. app/code/local/Ansh/Customcontact/Model/Status.php~ +15 -0
  26. app/code/local/Ansh/Customcontact/controllers/Adminhtml/CustomContactController.php~ +177 -0
  27. app/code/local/Ansh/Customcontact/controllers/Adminhtml/CustomcontactController.php +170 -0
  28. app/code/local/Ansh/Customcontact/controllers/IndexController.php +61 -0
  29. app/code/local/Ansh/Customcontact/controllers/IndexController.php~ +68 -0
  30. app/code/local/Ansh/Customcontact/etc/adminhtml.xml +35 -0
  31. app/code/local/Ansh/Customcontact/etc/config.xml +109 -0
  32. app/code/local/Ansh/Customcontact/etc/config.xml~ +0 -0
  33. app/code/local/Ansh/Customcontact/etc/system.xml +41 -0
  34. app/code/local/Ansh/Customcontact/etc/system.xml~ +82 -0
  35. app/code/local/Ansh/Customcontact/sql/customcontact_setup/mysql4-install-1.0.0.php +24 -0
  36. app/design/adminhtml/default/default/layout/customcontact.xml +8 -0
  37. app/design/frontend/base/default/layout/customcontact.xml +9 -0
  38. app/design/frontend/base/default/template/customcontact/customcontact.phtml +53 -0
  39. app/design/frontend/base/default/template/customcontact/customcontact.phtml~ +21 -0
  40. app/etc/modules/Ansh_Customcontact.xml +9 -0
  41. app/locale/en_US/template/email/customcontact_email_admin.html +12 -0
  42. app/locale/en_US/template/email/customcontact_email_customer.html +7 -0
  43. package.xml +18 -0
app/code/local/Ansh/Customcontact/Block/Adminhtml/CustomContact.php~ ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ansh_Customcontact_Block_Adminhtml_Customcontact extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_customcontact';
7
+ $this->_blockGroup = 'customcontact';
8
+ $this->_headerText = Mage::helper('customcontact')->__('Manage Contacts');
9
+ $this->_addButtonLabel = Mage::helper('customcontact')->__('Add New Contact');
10
+ parent::__construct();
11
+ }
12
+ }
app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Block_Adminhtml_Customcontact extends Mage_Adminhtml_Block_Widget_Grid_Container {
4
+
5
+ public function __construct() {
6
+ $this->_controller = 'adminhtml_customcontact';
7
+ $this->_blockGroup = 'customcontact';
8
+ $this->_headerText = Mage::helper('customcontact')->__('Manage Contacts');
9
+ $this->_addButtonLabel = Mage::helper('customcontact')->__('Add New Contact');
10
+ parent::__construct();
11
+ }
12
+
13
+ }
app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Block_Adminhtml_Customcontact_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+
8
+ $this->_objectId = 'id';
9
+ $this->_blockGroup = 'customcontact';
10
+ $this->_controller = 'adminhtml_customcontact';
11
+
12
+ $this->_updateButton('save', 'label', Mage::helper('customcontact')->__('Save Item'));
13
+ $this->_updateButton('delete', 'label', Mage::helper('customcontact')->__('Delete Item'));
14
+
15
+ $this->_addButton('saveandcontinue', array(
16
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
17
+ 'onclick' => 'saveAndContinueEdit()',
18
+ 'class' => 'save',
19
+ ), -100);
20
+
21
+ $this->_formScripts[] = "
22
+ function toggleEditor() {
23
+ if (tinyMCE.getInstanceById('customcontact_content') == null) {
24
+ tinyMCE.execCommand('mceAddControl', false, 'customcontact_content');
25
+ } else {
26
+ tinyMCE.execCommand('mceRemoveControl', false, 'customcontact_content');
27
+ }
28
+ }
29
+
30
+ function saveAndContinueEdit(){
31
+ editForm.submit($('edit_form').action+'back/edit/');
32
+ }
33
+ ";
34
+ }
35
+
36
+ public function getHeaderText() {
37
+ if (Mage::registry('customcontact_data') && Mage::registry('customcontact_data')->getId()) {
38
+ return Mage::helper('customcontact')->__("Edit Contact '%s'", $this->htmlEscape(Mage::registry('customcontact_data')->getName()));
39
+ } else {
40
+ return Mage::helper('customcontact')->__('Add Contact');
41
+ }
42
+ }
43
+
44
+ }
app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit.php~ ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Block_Adminhtml_Customcontact_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_objectId = 'id';
10
+ $this->_blockGroup = 'customcontact';
11
+ $this->_controller = 'adminhtml_customcontact';
12
+
13
+ $this->_updateButton('save', 'label', Mage::helper('customcontact')->__('Save Item'));
14
+ $this->_updateButton('delete', 'label', Mage::helper('customcontact')->__('Delete Item'));
15
+
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+
22
+ $this->_formScripts[] = "
23
+ function toggleEditor() {
24
+ if (tinyMCE.getInstanceById('customcontact_content') == null) {
25
+ tinyMCE.execCommand('mceAddControl', false, 'customcontact_content');
26
+ } else {
27
+ tinyMCE.execCommand('mceRemoveControl', false, 'customcontact_content');
28
+ }
29
+ }
30
+
31
+ function saveAndContinueEdit(){
32
+ editForm.submit($('edit_form').action+'back/edit/');
33
+ }
34
+ ";
35
+ }
36
+
37
+ public function getHeaderText()
38
+ {
39
+ if( Mage::registry('customcontact_data') && Mage::registry('customcontact_data')->getId() ) {
40
+ return Mage::helper('customcontact')->__("Edit Contact '%s'", $this->htmlEscape(Mage::registry('customcontact_data')->getName()));
41
+ } else {
42
+ return Mage::helper('customcontact')->__('Add Contact');
43
+ }
44
+ }
45
+ }
app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Block_Adminhtml_Customcontact_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
+
14
+ $form->setUseContainer(true);
15
+ $this->setForm($form);
16
+ return parent::_prepareForm();
17
+ }
18
+
19
+ }
app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit/Form.php~ ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_CustomContact_Block_Adminhtml_CustomContact_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ protected function _prepareForm()
6
+ {
7
+ $form = new Varien_Data_Form(array(
8
+ 'id' => 'edit_form',
9
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
10
+ 'method' => 'post',
11
+ 'enctype' => 'multipart/form-data'
12
+ )
13
+ );
14
+
15
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit/Tab/Form.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Block_Adminhtml_Customcontact_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {
4
+
5
+ protected function _prepareForm() {
6
+ $form = new Varien_Data_Form();
7
+ $this->setForm($form);
8
+ $fieldset = $form->addFieldset('customcontact_form', array('legend' => Mage::helper('customcontact')->__('Contact information')));
9
+
10
+ $fieldset->addField('name', 'text', array(
11
+ 'label' => Mage::helper('customcontact')->__('Name'),
12
+ 'class' => 'required-entry',
13
+ 'required' => true,
14
+ 'name' => 'name',
15
+ ));
16
+
17
+ $fieldset->addField('email', 'text', array(
18
+ 'label' => Mage::helper('customcontact')->__('Email'),
19
+ 'class' => 'required-entry validate-email',
20
+ 'required' => true,
21
+ 'name' => 'email',
22
+ ));
23
+
24
+ $fieldset->addField('mobile_number', 'text', array(
25
+ 'label' => Mage::helper('customcontact')->__('Mobile Number'),
26
+ 'class' => 'validate-phoneLax',
27
+ 'name' => 'mobile_number',
28
+ ));
29
+
30
+ $fieldset->addField('queries', 'textarea', array(
31
+ 'label' => Mage::helper('customcontact')->__('Query/Note'),
32
+ 'required' => true,
33
+ 'class' => 'required-entry',
34
+ 'style' => 'width:500px; height:150px;',
35
+ 'name' => 'queries',
36
+ ));
37
+
38
+
39
+ $fieldset->addField('status', 'select', array(
40
+ 'label' => Mage::helper('customcontact')->__('Status'),
41
+ 'name' => 'status',
42
+ 'values' => array(
43
+ array(
44
+ 'value' => 1,
45
+ 'label' => Mage::helper('customcontact')->__('Enabled'),
46
+ ),
47
+ array(
48
+ 'value' => 2,
49
+ 'label' => Mage::helper('customcontact')->__('Disabled'),
50
+ ),
51
+ ),
52
+ ));
53
+
54
+ if (Mage::getSingleton('adminhtml/session')->getCustomcontactData()) {
55
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getCustomcontactData());
56
+ Mage::getSingleton('adminhtml/session')->setCustomcontactData(null);
57
+ } elseif (Mage::registry('customcontact_data')) {
58
+ $form->setValues(Mage::registry('customcontact_data')->getData());
59
+ }
60
+ return parent::_prepareForm();
61
+ }
62
+
63
+ }
app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit/Tab/Form.php~ ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_CustomContact_Block_Adminhtml_CustomContact_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('customcontact_form', array('legend'=>Mage::helper('customcontact')->__('Contact information')));
10
+
11
+ $fieldset->addField('name', 'text', array(
12
+ 'label' => Mage::helper('customcontact')->__('Name'),
13
+ 'class' => 'required-entry',
14
+ 'required' => true,
15
+ 'name' => 'name',
16
+ ));
17
+
18
+ $fieldset->addField('email', 'text', array(
19
+ 'label' => Mage::helper('customcontact')->__('Email'),
20
+ 'class' => 'required-entry validate-email',
21
+ 'required' => true,
22
+ 'name' => 'email',
23
+ ));
24
+
25
+ $fieldset->addField('mobile_number', 'text', array(
26
+ 'label' => Mage::helper('customcontact')->__('Mobile Number'),
27
+ 'class' => 'validate-phoneLax',
28
+
29
+ 'name' => 'mobile_number',
30
+ ));
31
+
32
+ $fieldset->addField('queries', 'textarea', array(
33
+ 'label' => Mage::helper('customcontact')->__('Query/Note'),
34
+ 'required' => true,
35
+ 'class' => 'required-entry',
36
+ 'style' => 'width:500px; height:150px;',
37
+ 'name' => 'queries',
38
+ ));
39
+
40
+
41
+ $fieldset->addField('status', 'select', array(
42
+ 'label' => Mage::helper('customcontact')->__('Status'),
43
+ 'name' => 'status',
44
+ 'values' => array(
45
+ array(
46
+ 'value' => 1,
47
+ 'label' => Mage::helper('customcontact')->__('Enabled'),
48
+ ),
49
+
50
+ array(
51
+ 'value' => 2,
52
+ 'label' => Mage::helper('customcontact')->__('Disabled'),
53
+ ),
54
+ ),
55
+ ));
56
+
57
+
58
+ /*$fieldset->addField('content', 'editor', array(
59
+ 'name' => 'content',
60
+ 'label' => Mage::helper('customcontact')->__('Content'),
61
+ 'title' => Mage::helper('customcontact')->__('Content'),
62
+ 'style' => 'width:700px; height:500px;',
63
+ 'wysiwyg' => false,
64
+ 'required' => true,
65
+ ));*/
66
+
67
+ if ( Mage::getSingleton('adminhtml/session')->getCustomcontactData() )
68
+ {
69
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getCustomcontactData());
70
+ Mage::getSingleton('adminhtml/session')->setCustomcontactData(null);
71
+ } elseif ( Mage::registry('customcontact_data') ) {
72
+ $form->setValues(Mage::registry('customcontact_data')->getData());
73
+ }
74
+ return parent::_prepareForm();
75
+ }
76
+ }
app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit/Tabs.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Block_Adminhtml_Customcontact_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('customcontact_tabs');
8
+ $this->setDestElementId('edit_form');
9
+ $this->setTitle(Mage::helper('customcontact')->__('Contact Information'));
10
+ }
11
+
12
+ protected function _beforeToHtml() {
13
+ $this->addTab('form_section', array(
14
+ 'label' => Mage::helper('customcontact')->__('Contact Information'),
15
+ 'title' => Mage::helper('customcontact')->__('Contact Information'),
16
+ 'content' => $this->getLayout()->createBlock('customcontact/adminhtml_customcontact_edit_tab_form')->toHtml(),
17
+ ));
18
+
19
+ return parent::_beforeToHtml();
20
+ }
21
+
22
+ }
app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Edit/Tabs.php~ ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Block_Adminhtml_Customcontact_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('customcontact_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('customcontact')->__('Contact Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('customcontact')->__('Contact Information'),
18
+ 'title' => Mage::helper('customcontact')->__('Contact Information'),
19
+ 'content' => $this->getLayout()->createBlock('customcontact/adminhtml_customcontact_edit_tab_form')->toHtml(),
20
+ ));
21
+
22
+ return parent::_beforeToHtml();
23
+ }
24
+ }
app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Grid.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Block_Adminhtml_Customcontact_Grid extends Mage_Adminhtml_Block_Widget_Grid {
4
+
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->setId('customcontactGrid');
8
+ $this->setDefaultSort('id');
9
+ $this->setDefaultDir('DESC');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+
13
+ protected function _prepareCollection() {
14
+ $collection = Mage::getModel('customcontact/customcontact')->getCollection();
15
+ $this->setCollection($collection);
16
+ return parent::_prepareCollection();
17
+ }
18
+
19
+ protected function _prepareColumns() {
20
+ $this->addColumn('id', array(
21
+ 'header' => Mage::helper('customcontact')->__('ID'),
22
+ 'align' => 'right',
23
+ 'width' => '50px',
24
+ 'index' => 'id',
25
+ ));
26
+
27
+ $this->addColumn('title', array(
28
+ 'header' => Mage::helper('customcontact')->__('Name'),
29
+ 'align' => 'left',
30
+ 'index' => 'name',
31
+ ));
32
+
33
+ $this->addColumn('email', array(
34
+ 'header' => Mage::helper('customcontact')->__('Email'),
35
+ 'align' => 'left',
36
+ 'index' => 'email',
37
+ ));
38
+
39
+ $this->addColumn('mobile_number', array(
40
+ 'header' => Mage::helper('customcontact')->__('Mobile Number'),
41
+ 'align' => 'left',
42
+ 'index' => 'mobile_number',
43
+ ));
44
+
45
+ $this->addColumn('status', array(
46
+ 'header' => Mage::helper('customcontact')->__('Status'),
47
+ 'align' => 'left',
48
+ 'width' => '80px',
49
+ 'index' => 'status',
50
+ 'type' => 'options',
51
+ 'options' => array(
52
+ 1 => 'Enabled',
53
+ 2 => 'Disabled',
54
+ ),
55
+ ));
56
+
57
+ $this->addColumn('action', array(
58
+ 'header' => Mage::helper('customcontact')->__('Action'),
59
+ 'width' => '100',
60
+ 'type' => 'action',
61
+ 'getter' => 'getId',
62
+ 'actions' => array(
63
+ array(
64
+ 'caption' => Mage::helper('customcontact')->__('Edit'),
65
+ 'url' => array('base' => '*/*/edit'),
66
+ 'field' => 'id'
67
+ )
68
+ ),
69
+ 'filter' => false,
70
+ 'sortable' => false,
71
+ 'index' => 'stores',
72
+ 'is_system' => true,
73
+ ));
74
+
75
+ $this->addExportType('*/*/exportCsv', Mage::helper('customcontact')->__('CSV'));
76
+ $this->addExportType('*/*/exportXml', Mage::helper('customcontact')->__('XML'));
77
+ $this->addExportType('*/*/exportExcel', Mage::helper('customcontact')->__('EXCEL'));
78
+
79
+ return parent::_prepareColumns();
80
+ }
81
+
82
+ protected function _prepareMassaction() {
83
+ $this->setMassactionIdField('id');
84
+ $this->getMassactionBlock()->setFormFieldName('customcontact');
85
+
86
+ $this->getMassactionBlock()->addItem('delete', array(
87
+ 'label' => Mage::helper('customcontact')->__('Delete'),
88
+ 'url' => $this->getUrl('*/*/massDelete'),
89
+ 'confirm' => Mage::helper('customcontact')->__('Are you sure?')
90
+ ));
91
+
92
+ $statuses = Mage::getSingleton('customcontact/status')->getOptionArray();
93
+
94
+ array_unshift($statuses, array('label' => '', 'value' => ''));
95
+ $this->getMassactionBlock()->addItem('status', array(
96
+ 'label' => Mage::helper('customcontact')->__('Change status'),
97
+ 'url' => $this->getUrl('*/*/massStatus', array('_current' => true)),
98
+ 'additional' => array(
99
+ 'visibility' => array(
100
+ 'name' => 'status',
101
+ 'type' => 'select',
102
+ 'class' => 'required-entry',
103
+ 'label' => Mage::helper('customcontact')->__('Status'),
104
+ 'values' => $statuses
105
+ )
106
+ )
107
+ ));
108
+ return $this;
109
+ }
110
+
111
+ public function getRowUrl($row) {
112
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
113
+ }
114
+
115
+ }
app/code/local/Ansh/Customcontact/Block/Adminhtml/Customcontact/Grid.php~ ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Block_Adminhtml_Customcontact_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('customcontactGrid');
9
+ $this->setDefaultSort('customcontact_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ }
13
+
14
+ protected function _prepareCollection()
15
+ {
16
+ $collection = Mage::getModel('customcontact/customcontact')->getCollection();
17
+ $this->setCollection($collection);
18
+ return parent::_prepareCollection();
19
+ }
20
+
21
+ protected function _prepareColumns()
22
+ {
23
+ $this->addColumn('id', array(
24
+ 'header' => Mage::helper('customcontact')->__('ID'),
25
+ 'align' =>'right',
26
+ 'width' => '50px',
27
+ 'index' => 'id',
28
+ ));
29
+
30
+ $this->addColumn('title', array(
31
+ 'header' => Mage::helper('customcontact')->__('Name'),
32
+ 'align' =>'left',
33
+ 'index' => 'name',
34
+ ));
35
+
36
+ $this->addColumn('email', array(
37
+ 'header' => Mage::helper('customcontact')->__('Email'),
38
+ 'align' =>'left',
39
+ 'index' => 'email',
40
+ ));
41
+
42
+ $this->addColumn('mobile_number', array(
43
+ 'header' => Mage::helper('customcontact')->__('Mobile Number'),
44
+ 'align' =>'left',
45
+ 'index' => 'mobile_number',
46
+ ));
47
+
48
+ /*
49
+ $this->addColumn('content', array(
50
+ 'header' => Mage::helper('customcontact')->__('Item Content'),
51
+ 'width' => '150px',
52
+ 'index' => 'content',
53
+ ));
54
+ */
55
+
56
+ $this->addColumn('status', array(
57
+ 'header' => Mage::helper('customcontact')->__('Status'),
58
+ 'align' => 'left',
59
+ 'width' => '80px',
60
+ 'index' => 'status',
61
+ 'type' => 'options',
62
+ 'options' => array(
63
+ 1 => 'Enabled',
64
+ 2 => 'Disabled',
65
+ ),
66
+ ));
67
+
68
+ $this->addColumn('action',
69
+ array(
70
+ 'header' => Mage::helper('customcontact')->__('Action'),
71
+ 'width' => '100',
72
+ 'type' => 'action',
73
+ 'getter' => 'getId',
74
+ 'actions' => array(
75
+ array(
76
+ 'caption' => Mage::helper('customcontact')->__('Edit'),
77
+ 'url' => array('base'=> '*/*/edit'),
78
+ 'field' => 'id'
79
+ )
80
+ ),
81
+ 'filter' => false,
82
+ 'sortable' => false,
83
+ 'index' => 'stores',
84
+ 'is_system' => true,
85
+ ));
86
+
87
+ $this->addExportType('*/*/exportCsv', Mage::helper('customcontact')->__('CSV'));
88
+ $this->addExportType('*/*/exportXml', Mage::helper('customcontact')->__('XML'));
89
+ $this->addExportType('*/*/exportExcel', Mage::helper('customcontact')->__('EXCEL'));
90
+
91
+ return parent::_prepareColumns();
92
+ }
93
+
94
+ protected function _prepareMassaction()
95
+ {
96
+ $this->setMassactionIdField('id');
97
+ $this->getMassactionBlock()->setFormFieldName('customcontact');
98
+
99
+ $this->getMassactionBlock()->addItem('delete', array(
100
+ 'label' => Mage::helper('customcontact')->__('Delete'),
101
+ 'url' => $this->getUrl('*/*/massDelete'),
102
+ 'confirm' => Mage::helper('customcontact')->__('Are you sure?')
103
+ ));
104
+
105
+ $statuses = Mage::getSingleton('customcontact/status')->getOptionArray();
106
+
107
+ array_unshift($statuses, array('label'=>'', 'value'=>''));
108
+ $this->getMassactionBlock()->addItem('status', array(
109
+ 'label'=> Mage::helper('customcontact')->__('Change status'),
110
+ 'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
111
+ 'additional' => array(
112
+ 'visibility' => array(
113
+ 'name' => 'status',
114
+ 'type' => 'select',
115
+ 'class' => 'required-entry',
116
+ 'label' => Mage::helper('customcontact')->__('Status'),
117
+ 'values' => $statuses
118
+ )
119
+ )
120
+ ));
121
+ return $this;
122
+ }
123
+
124
+ public function getRowUrl($row)
125
+ {
126
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
127
+ }
128
+
129
+ }
app/code/local/Ansh/Customcontact/Block/CustomContact.php~ ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ansh_CustomContact_Block_CustomContact extends Mage_Core_Block_Template
3
+ {
4
+
5
+ protected $_Collection=null;
6
+ public function getCollection(){
7
+ if(is_null($this->_Collection)){
8
+ $this->_Collection=Mage::getModel('customcontact/customcontact')->getCollection();
9
+ }
10
+ return $this->_Collection;
11
+ }
12
+ public function getActionOfForm()
13
+ {
14
+ return $this->getUrl('customcontact/index/createContact');
15
+ }
16
+ /*
17
+ public function _prepareLayout()
18
+ {
19
+ return parent::_prepareLayout();
20
+ }
21
+
22
+ public function getCustomcontact()
23
+ {
24
+ if (!$this->hasData('customcontact')) {
25
+ $this->setData('customcontact', Mage::registry('customcontact'));
26
+ }
27
+ return $this->getData('customcontact');
28
+
29
+ } */
30
+ }
app/code/local/Ansh/Customcontact/Block/Customcontact.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Block_Customcontact extends Mage_Core_Block_Template {
4
+
5
+ protected $_Collection = null;
6
+
7
+ public function getCollection() {
8
+ if (is_null($this->_Collection)) {
9
+ $this->_Collection = Mage::getModel('customcontact/customcontact')->getCollection();
10
+ }
11
+ return $this->_Collection;
12
+ }
13
+
14
+ public function getActionOfForm() {
15
+ return $this->getUrl('customcontact/index/createContact');
16
+ }
17
+
18
+ }
app/code/local/Ansh/Customcontact/Helper/Data.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Sample Widget Helper
5
+ */
6
+ class Ansh_Customcontact_Helper_Data extends Mage_Core_Helper_Abstract {
7
+
8
+ }
app/code/local/Ansh/Customcontact/Helper/Data.php~ ADDED
File without changes
app/code/local/Ansh/Customcontact/Model/CustomContact.php~ ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_CustomContact_Model_CustomContact extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('customcontact/customcontact');
9
+ }
10
+ }
app/code/local/Ansh/Customcontact/Model/Customcontact.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Model_Customcontact extends Mage_Core_Model_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('customcontact/customcontact');
8
+ }
9
+
10
+ }
app/code/local/Ansh/Customcontact/Model/Mysql4/CustomContact.php~ ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Model_Mysql4_Customcontact extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that the id refers to the key field in your database table.
8
+ $this->_init('customcontact/customcontact', 'id');
9
+ }
10
+ }
app/code/local/Ansh/Customcontact/Model/Mysql4/Customcontact.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Model_Mysql4_Customcontact extends Mage_Core_Model_Mysql4_Abstract {
4
+
5
+ public function _construct() {
6
+ // Note that the id refers to the key field in your database table.
7
+ $this->_init('customcontact/customcontact', 'id');
8
+ }
9
+
10
+ }
app/code/local/Ansh/Customcontact/Model/Mysql4/Customcontact/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Model_Mysql4_Customcontact_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
4
+
5
+ public function _construct() {
6
+ parent::_construct();
7
+ $this->_init('customcontact/customcontact');
8
+ }
9
+
10
+ }
app/code/local/Ansh/Customcontact/Model/Mysql4/Customcontact/Collection.php~ ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Model_Mysql4_Customcontact_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('customcontact/customcontact');
9
+ }
10
+ }
app/code/local/Ansh/Customcontact/Model/Options.php~ ADDED
File without changes
app/code/local/Ansh/Customcontact/Model/Status.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Model_Status extends Varien_Object {
4
+
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray() {
9
+ return array(
10
+ self::STATUS_ENABLED => Mage::helper('customcontact')->__('Enabled'),
11
+ self::STATUS_DISABLED => Mage::helper('customcontact')->__('Disabled')
12
+ );
13
+ }
14
+
15
+ }
app/code/local/Ansh/Customcontact/Model/Status.php~ ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Model_Status extends Varien_Object
4
+ {
5
+ const STATUS_ENABLED = 1;
6
+ const STATUS_DISABLED = 2;
7
+
8
+ static public function getOptionArray()
9
+ {
10
+ return array(
11
+ self::STATUS_ENABLED => Mage::helper('customcontact')->__('Enabled'),
12
+ self::STATUS_DISABLED => Mage::helper('customcontact')->__('Disabled')
13
+ );
14
+ }
15
+ }
app/code/local/Ansh/Customcontact/controllers/Adminhtml/CustomContactController.php~ ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_CustomContact_Adminhtml_CustomContactController extends Mage_Adminhtml_Controller_action
4
+ {
5
+
6
+ protected function _initAction() {
7
+ $this->loadLayout()
8
+ ->_setActiveMenu('customcontact/items')
9
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+
19
+ public function editAction() {
20
+ $id = $this->getRequest()->getParam('id');
21
+ $model = Mage::getModel('customcontact/customcontact')->load($id);
22
+
23
+ if ($model->getId() || $id == 0) {
24
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
25
+ if (!empty($data)) {
26
+ $model->setData($data);
27
+ }
28
+
29
+ Mage::register('customcontact_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('customcontact/contacts');
33
+
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Contact Manager'), Mage::helper('adminhtml')->__('Contact Manager'));
35
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Contact News'), Mage::helper('adminhtml')->__('Contact News'));
36
+
37
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
38
+
39
+ $this->_addContent($this->getLayout()->createBlock('customcontact/adminhtml_customcontact_edit'))
40
+ ->_addLeft($this->getLayout()->createBlock('customcontact/adminhtml_customcontact_edit_tabs'));
41
+
42
+ $this->renderLayout();
43
+ } else {
44
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customcontact')->__('Contact does not exist'));
45
+ $this->_redirect('*/*/');
46
+ }
47
+ }
48
+
49
+ public function newAction() {
50
+ $this->_forward('edit');
51
+ }
52
+
53
+ public function saveAction() {
54
+
55
+ if ($data = $this->getRequest()->getPost()) {
56
+
57
+ $model = Mage::getModel('customcontact/customcontact');
58
+ $model->setData($data)
59
+ ->setId($this->getRequest()->getParam('id'));
60
+
61
+ try {
62
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
63
+ $model->setCreatedTime(now())
64
+ ->setUpdateTime(now());
65
+ } else {
66
+ $model->setUpdateTime(now());
67
+ }
68
+
69
+ $model->save();
70
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('customcontact')->__('Item was successfully saved'));
71
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
72
+
73
+ if ($this->getRequest()->getParam('back')) {
74
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
75
+ return;
76
+ }
77
+ $this->_redirect('*/*/');
78
+ return;
79
+ } catch (Exception $e) {
80
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
81
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
82
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
83
+ return;
84
+ }
85
+ }
86
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customcontact')->__('Unable to find contact to save'));
87
+ $this->_redirect('*/*/');
88
+ }
89
+
90
+ public function deleteAction() {
91
+ if( $this->getRequest()->getParam('id') > 0 ) {
92
+ try {
93
+ $model = Mage::getModel('customcontact/customcontact');
94
+
95
+ $model->setId($this->getRequest()->getParam('id'))
96
+ ->delete();
97
+
98
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Contact was successfully deleted'));
99
+ $this->_redirect('*/*/');
100
+ } catch (Exception $e) {
101
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
102
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
103
+ }
104
+ }
105
+ $this->_redirect('*/*/');
106
+ }
107
+
108
+ public function massDeleteAction() {
109
+ $customcontactIds = $this->getRequest()->getParam('customcontact');
110
+ if(!is_array($customcontactIds)) {
111
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select contact(s)'));
112
+ } else {
113
+ try {
114
+ foreach ($customcontactIds as $customcontactId) {
115
+ $customcontact = Mage::getModel('customcontact/customcontact')->load($customcontactId);
116
+ $customcontact->delete();
117
+ }
118
+ Mage::getSingleton('adminhtml/session')->addSuccess(
119
+ Mage::helper('adminhtml')->__(
120
+ 'Total of %d record(s) were successfully deleted', count($customcontactIds)
121
+ )
122
+ );
123
+ } catch (Exception $e) {
124
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
125
+ }
126
+ }
127
+ $this->_redirect('*/*/index');
128
+ }
129
+
130
+ public function massStatusAction()
131
+ {
132
+ $customcontactIds = $this->getRequest()->getParam('customcontact');
133
+ if(!is_array($customcontactIds)) {
134
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
135
+ } else {
136
+ try {
137
+ foreach ($customcontactIds as $customcontactId) {
138
+ $customcontact = Mage::getSingleton('customcontact/customcontact')
139
+ ->load($customcontactId)
140
+ ->setStatus($this->getRequest()->getParam('status'))
141
+ ->setIsMassupdate(true)
142
+ ->save();
143
+ }
144
+ $this->_getSession()->addSuccess(
145
+ $this->__('Total of %d record(s) were successfully updated', count($customcontactIds))
146
+ );
147
+ } catch (Exception $e) {
148
+ $this->_getSession()->addError($e->getMessage());
149
+ }
150
+ }
151
+ $this->_redirect('*/*/index');
152
+ }
153
+
154
+ public function exportCsvAction()
155
+ {
156
+ $fileName = 'customcontact.csv';
157
+ $content = $this->getLayout()->createBlock('ansh_customcontact_block_adminhtml_customcontact_grid');
158
+ $this->_prepareDownloadResponse($fileName, $content->getCsvFile());
159
+ }
160
+
161
+ public function exportXmlAction()
162
+ {
163
+ $fileName = 'customcontact.xml';
164
+ $content = $this->getLayout()->createBlock('ansh_customcontact_block_adminhtml_customcontact_grid');
165
+ //Mage::log($content->getXml());
166
+ //print_r($content->getXmlFile());die;
167
+ $this->_prepareDownloadResponse($fileName, $content->getXml());
168
+ }
169
+
170
+ public function exportExcelAction()
171
+ {
172
+ $fileName = 'customcontact.xls';
173
+ $content = $this->getLayout()->createBlock('ansh_customcontact_block_adminhtml_customcontact_grid');
174
+ //print_r($content->getXmlFile());die;
175
+ $this->_prepareDownloadResponse($fileName, $content->getExcelFile());
176
+ }
177
+ }
app/code/local/Ansh/Customcontact/controllers/Adminhtml/CustomcontactController.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_Adminhtml_CustomcontactController extends Mage_Adminhtml_Controller_action {
4
+
5
+ protected function _initAction() {
6
+ $this->loadLayout()
7
+ ->_setActiveMenu('customcontact/items')
8
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Custom Contacts'), Mage::helper('adminhtml')->__('Custom Contacts')
9
+ );
10
+
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ $this->_initAction()
16
+ ->renderLayout();
17
+ }
18
+
19
+ public function editAction() {
20
+ $id = $this->getRequest()->getParam('id');
21
+ $model = Mage::getModel('customcontact/customcontact')->load($id);
22
+
23
+ if ($model->getId() || $id == 0) {
24
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
25
+ if (!empty($data)) {
26
+ $model->setData($data);
27
+ }
28
+
29
+ Mage::register('customcontact_data', $model);
30
+
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('customcontact/items');
33
+
34
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Custom Contacts'), Mage::helper('adminhtml')->__('Custom Contacts'));
35
+
36
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
37
+
38
+ $this->_addContent($this->getLayout()->createBlock('customcontact/adminhtml_customcontact_edit'))
39
+ ->_addLeft($this->getLayout()->createBlock('customcontact/adminhtml_customcontact_edit_tabs'));
40
+
41
+ $this->renderLayout();
42
+ } else {
43
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customcontact')->__('Contact does not exist'));
44
+ $this->_redirect('*/*/');
45
+ }
46
+ }
47
+
48
+ public function newAction() {
49
+ $this->_forward('edit');
50
+ }
51
+
52
+ public function saveAction() {
53
+
54
+ if ($data = $this->getRequest()->getPost()) {
55
+
56
+ $model = Mage::getModel('customcontact/customcontact');
57
+ $model->setData($data)
58
+ ->setId($this->getRequest()->getParam('id'));
59
+
60
+ try {
61
+ if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
62
+ $model->setCreatedTime(now())
63
+ ->setUpdateTime(now());
64
+ } else {
65
+ $model->setUpdateTime(now());
66
+ }
67
+
68
+ $model->save();
69
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('customcontact')->__('Contact was successfully saved'));
70
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
71
+
72
+ if ($this->getRequest()->getParam('back')) {
73
+ $this->_redirect('*/*/edit', array('id' => $model->getId()));
74
+ return;
75
+ }
76
+ $this->_redirect('*/*/');
77
+ return;
78
+ } catch (Exception $e) {
79
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
80
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
81
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
82
+ return;
83
+ }
84
+ }
85
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('customcontact')->__('Unable to find contact to save'));
86
+ $this->_redirect('*/*/');
87
+ }
88
+
89
+ public function deleteAction() {
90
+ if ($this->getRequest()->getParam('id') > 0) {
91
+ try {
92
+ $model = Mage::getModel('customcontact/customcontact');
93
+
94
+ $model->setId($this->getRequest()->getParam('id'))
95
+ ->delete();
96
+
97
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Contact was successfully deleted'));
98
+ $this->_redirect('*/*/');
99
+ } catch (Exception $e) {
100
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
101
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
102
+ }
103
+ }
104
+ $this->_redirect('*/*/');
105
+ }
106
+
107
+ public function massDeleteAction() {
108
+ $customContactIds = $this->getRequest()->getParam('customcontact');
109
+ if (!is_array($customContactIds)) {
110
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select contact(s)'));
111
+ } else {
112
+ try {
113
+ foreach ($customContactIds as $customContactId) {
114
+ $customcontact = Mage::getModel('customcontact/customcontact')->load($customContactId);
115
+ $customcontact->delete();
116
+ }
117
+ Mage::getSingleton('adminhtml/session')->addSuccess(
118
+ Mage::helper('adminhtml')->__(
119
+ 'Total of %d record(s) were successfully deleted', count($customContactIds)
120
+ )
121
+ );
122
+ } catch (Exception $e) {
123
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
124
+ }
125
+ }
126
+ $this->_redirect('*/*/index');
127
+ }
128
+
129
+ public function massStatusAction() {
130
+ $customContactIds = $this->getRequest()->getParam('customcontact');
131
+ if (!is_array($customContactIds)) {
132
+ Mage::getSingleton('adminhtml/session')->addError($this->__('Please select item(s)'));
133
+ } else {
134
+ try {
135
+ foreach ($customContactIds as $customContactId) {
136
+ $customcontact = Mage::getSingleton('customcontact/customcontact')
137
+ ->load($customContactId)
138
+ ->setStatus($this->getRequest()->getParam('status'))
139
+ ->setIsMassupdate(true)
140
+ ->save();
141
+ }
142
+ $this->_getSession()->addSuccess(
143
+ $this->__('Total of %d record(s) were successfully updated', count($customContactIds))
144
+ );
145
+ } catch (Exception $e) {
146
+ $this->_getSession()->addError($e->getMessage());
147
+ }
148
+ }
149
+ $this->_redirect('*/*/index');
150
+ }
151
+
152
+ public function exportCsvAction() {
153
+ $fileName = 'customcontact.csv';
154
+ $content = $this->getLayout()->createBlock('ansh_customcontact_block_adminhtml_customcontact_grid');
155
+ $this->_prepareDownloadResponse($fileName, $content->getCsvFile());
156
+ }
157
+
158
+ public function exportXmlAction() {
159
+ $fileName = 'customcontact.xml';
160
+ $content = $this->getLayout()->createBlock('ansh_customcontact_block_adminhtml_customcontact_grid');
161
+ $this->_prepareDownloadResponse($fileName, $content->getXml());
162
+ }
163
+
164
+ public function exportExcelAction() {
165
+ $fileName = 'customcontact.xls';
166
+ $content = $this->getLayout()->createBlock('ansh_customcontact_block_adminhtml_customcontact_grid');
167
+ $this->_prepareDownloadResponse($fileName, $content->getExcelFile());
168
+ }
169
+
170
+ }
app/code/local/Ansh/Customcontact/controllers/IndexController.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ansh_Customcontact_IndexController extends Mage_Core_Controller_Front_Action {
4
+
5
+ public function indexAction() {
6
+ $this->loadLayout();
7
+ $this->renderLayout();
8
+ }
9
+
10
+ public function createContactAction() {
11
+
12
+ $data = array(
13
+ 'name' => $this->getRequest()->getParam('name'),
14
+ 'email' => $this->getRequest()->getParam('email'),
15
+ 'mobile_number' => $this->getRequest()->getParam('mobile_number'),
16
+ 'queries' => $this->getRequest()->getParam('queries'),
17
+ 'created_time' => strtotime('now'),
18
+ 'update_time' => strtotime('now')
19
+ );
20
+
21
+
22
+ Mage::getSingleton('customer/session')->setPostData($data);
23
+
24
+ $model = Mage::getModel('customcontact/customcontact')->setData($data); //addData
25
+ try {
26
+ $insertId = $model->save()->getId();
27
+ if ($insertId) {
28
+ $senderName = Mage::getStoreConfig('trans_email/ident_general/name');
29
+ $senderEmail = Mage::getStoreConfig('trans_email/ident_general/email');
30
+
31
+ //Send email to admin
32
+ $templateData = array(
33
+ 'mobile_number' => $data['mobile_number'],
34
+ 'queries' => $data['queries']
35
+ );
36
+ $adminTemplateId = 'customcontact_email_setting_email_admin_template';
37
+ $emailTo = Mage::getStoreConfig('trans_email/ident_general/email');
38
+ $adminEmailTemplate = Mage::getModel('core/email_template')->loadDefault($adminTemplateId);
39
+ $adminEmailTemplate->setSenderName($senderName);
40
+ $adminEmailTemplate->setSenderEmail($senderEmail);
41
+ $adminEmailTemplate->send($emailTo, $data, $templateData);
42
+
43
+ //Send email to customer
44
+ $customerTemplateId = 'customcontact_email_setting_email_customers_template';
45
+ $recepientEmail = $this->getRequest()->getParam('email');
46
+ $customerEmailTemplate = Mage::getModel('core/email_template')->loadDefault($customerTemplateId);
47
+ $customerEmailTemplate->setSenderName($senderName);
48
+ $customerEmailTemplate->setSenderEmail($senderEmail);
49
+ $customerEmailTemplate->send($recepientEmail, array('name' => $data['name']));
50
+ }
51
+ $successMessage = $this->__("Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us!!!");
52
+ Mage::getSingleton('core/session')->addSuccess($successMessage);
53
+ } catch (Exception $e) {
54
+ $errorMessage = $this->__($e->getMessage());
55
+ Mage::getSingleton('core/session')->addError($errorMessage);
56
+ }
57
+
58
+ $this->_redirect('customcontact/');
59
+ }
60
+
61
+ }
app/code/local/Ansh/Customcontact/controllers/IndexController.php~ ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ansh_CustomContact_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+
5
+ /*const XML_PATH_EMAIL_ADMIN_SENDER = 'customcontact/anshemail/email_admin_sender';
6
+ const XML_PATH_EMAIL_CUSTOMER_SENDER = 'customcontact/anshemail/email_customers_sender';
7
+ const XML_PATH_RECEPTION_EMAIL_ADMIN = 'customcontact/anshemail/recipient_admin_email';
8
+ const XML_PATH_EMAIL_ADMIN_TEMPLATE = 'customcontact/anshemail/email_admin_template';
9
+ const XML_PATH_EMAIL_CUSTOMER_TEMPLATE = 'customcontact/anshemail/email_customers_template';*/
10
+
11
+ public function indexAction()
12
+ {
13
+ $this->loadLayout();
14
+ $this->renderLayout();
15
+ }
16
+ public function createContactAction() {
17
+
18
+
19
+ $data = array(
20
+ 'name' => $this->getRequest()->getParam('name'),
21
+ 'email' => $this->getRequest()->getParam('email'),
22
+ 'mobile_number' => $this->getRequest()->getParam('mobile_number'),
23
+ 'queries' => $this->getRequest()->getParam('queries'),
24
+ 'created_time' => strtotime('now'),
25
+ 'update_time' => strtotime('now')
26
+ );
27
+
28
+
29
+ Mage::getSingleton('customer/session')->setMyData($data);
30
+
31
+ $model = Mage::getModel('customcontact/customcontact')->setData($data); //addData
32
+ try {
33
+ $insertId = $model->save()->getId();
34
+ if($insertId)
35
+ {
36
+ $sender_name = Mage::getStoreConfig('trans_email/ident_general/name');
37
+ $sender_email = Mage::getStoreConfig('trans_email/ident_general/email');
38
+
39
+ //Send email to admin
40
+ $template_id = 'customcontact_email_setting_email_admin_template';
41
+ $email_to = Mage::getStoreConfig('trans_email/ident_general/email');
42
+ $email_template = Mage::getModel('core/email_template')->loadDefault($template_id);
43
+ $email_template->setSenderName($sender_name);
44
+ $email_template->setSenderEmail($sender_email);
45
+ $email_template->send($email_to, $data);
46
+
47
+ //Send email to customer
48
+ $template_id = 'customcontact_email_setting_email_customers_template';
49
+ $email_to = $this->getRequest()->getParam('email');
50
+ $email_template = Mage::getModel('core/email_template')->loadDefault($template_id);
51
+ $email_template->setSenderName($sender_name);
52
+ $email_template->setSenderEmail($sender_email);
53
+ $email_template->send($email_to, $data);
54
+ }
55
+ $message1 = $this->__("Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us!!!");
56
+ Mage::getSingleton('core/session')->addSuccess($message1);
57
+
58
+ } catch (Exception $e) {
59
+ $message2 = $this->__($e->getMessage());
60
+ Mage::getSingleton('core/session')->addError($message2);
61
+
62
+ }
63
+
64
+ $this->_redirect('customcontact/');
65
+ }
66
+
67
+ }
68
+
app/code/local/Ansh/Customcontact/etc/adminhtml.xml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <customcontact module="customcontact">
5
+ <title>Ansh Custom Contact</title>
6
+ <sort_order>71</sort_order>
7
+ <children>
8
+ <items module="customcontact">
9
+ <title>Manage Contacts</title>
10
+ <sort_order>0</sort_order>
11
+ <action>customcontact/adminhtml_customcontact</action>
12
+ </items>
13
+ </children>
14
+ </customcontact>
15
+ </menu>
16
+ <acl>
17
+ <resources>
18
+ <admin>
19
+ <children>
20
+ <system>
21
+ <children>
22
+ <config>
23
+ <children>
24
+ <customcontact_options>
25
+ <title>Custom Configuration Section</title>
26
+ </customcontact_options>
27
+ </children>
28
+ </config>
29
+ </children>
30
+ </system>
31
+ </children>
32
+ </admin>
33
+ </resources>
34
+ </acl>
35
+ </config>
app/code/local/Ansh/Customcontact/etc/config.xml ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ansh_Customcontact>
5
+ <version>1.0.0</version>
6
+ </Ansh_Customcontact>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <customcontact>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Ansh_Customcontact</module>
14
+ <frontName>customcontact</frontName>
15
+ </args>
16
+ </customcontact>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <customcontact>
21
+ <file>customcontact.xml</file>
22
+ </customcontact>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <admin>
27
+ <routers>
28
+ <customcontact>
29
+ <use>admin</use>
30
+ <args>
31
+ <module>Ansh_Customcontact</module>
32
+ <frontName>customcontact</frontName>
33
+ </args>
34
+ </customcontact>
35
+ </routers>
36
+ </admin>
37
+ <adminhtml>
38
+ <layout>
39
+ <updates>
40
+ <customcontact>
41
+ <file>customcontact.xml</file>
42
+ </customcontact>
43
+ </updates>
44
+ </layout>
45
+ </adminhtml>
46
+ <global>
47
+ <helpers>
48
+ <customcontact>
49
+ <class>Ansh_Customcontact_Helper</class>
50
+ </customcontact>
51
+ </helpers>
52
+ <models>
53
+ <customcontact>
54
+ <class>Ansh_Customcontact_Model</class>
55
+ <resourceModel>customcontact_mysql4</resourceModel>
56
+ </customcontact>
57
+ <customcontact_mysql4>
58
+ <class>Ansh_Customcontact_Model_Mysql4</class>
59
+ <entities>
60
+ <customcontact>
61
+ <table>customcontact</table>
62
+ </customcontact>
63
+ </entities>
64
+ </customcontact_mysql4>
65
+ </models>
66
+ <resources>
67
+ <customcontact_setup>
68
+ <setup>
69
+ <module>Ansh_Customcontact</module>
70
+ </setup>
71
+ <connection>
72
+ <use>core_setup</use>
73
+ </connection>
74
+ </customcontact_setup>
75
+ <customcontact_write>
76
+ <connection>
77
+ <use>core_write</use>
78
+ </connection>
79
+ </customcontact_write>
80
+ <customcontact_read>
81
+ <connection>
82
+ <use>core_read</use>
83
+ </connection>
84
+ </customcontact_read>
85
+ </resources>
86
+ <blocks>
87
+ <customcontact>
88
+ <class>Ansh_Customcontact_Block</class>
89
+ </customcontact>
90
+ </blocks>
91
+ <template>
92
+ <email>
93
+ <!-- Unique template name that I can access to send email or to load email template-->
94
+ <customcontact_email_setting_email_admin_template translate="label" module="customcontact">
95
+ <label>Admin Customcontact email</label>
96
+ <file>customcontact_email_admin.html</file>
97
+ <type>html</type>
98
+ </customcontact_email_setting_email_admin_template>
99
+ <customcontact_email_setting_email_customers_template translate="label" module="customcontact">
100
+ <label>Email Customer Template</label>
101
+ <file>customcontact_email_customer.html</file>
102
+ <type>text</type>
103
+ </customcontact_email_setting_email_customers_template>
104
+ </email>
105
+ </template>
106
+
107
+ </global>
108
+
109
+ </config>
app/code/local/Ansh/Customcontact/etc/config.xml~ ADDED
File without changes
app/code/local/Ansh/Customcontact/etc/system.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <customcontact translate="label" module="customcontact">
5
+ <label>Ansh Custom Contact</label>
6
+ <sort_order>1</sort_order>
7
+ </customcontact>
8
+ </tabs>
9
+ <sections>
10
+ <customcontact_options translate="label" module="customcontact">
11
+ <label>Ansh Custom Contact Settings</label>
12
+ <tab>customcontact</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1</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
+ <general translate="label">
20
+ <label>General Settings</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>0</show_in_store>
26
+ <fields>
27
+ <enabled translate="label">
28
+ <label>Enable Custom Contact</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>1</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
+ </enabled>
36
+ </fields>
37
+ </general>
38
+ </groups>
39
+ </customcontact_options>
40
+ </sections>
41
+ </config>
app/code/local/Ansh/Customcontact/etc/system.xml~ ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <customconfig translate="label" module="customconfig">
5
+ <label>Custom Configuration Tab</label>
6
+ <sort_order>1</sort_order>
7
+ </customconfig>
8
+ </tabs>
9
+
10
+ <sections>
11
+ <customconfig_options translate="label" module="customconfig">
12
+ <label>Custom Configuration Settings</label>
13
+ <tab>customconfig</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
+ <section_one translate="label">
21
+ <label>Section One</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1</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
+ <custom_field_one>
29
+ <label>Custom Text Field</label>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>1</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
+ <comment>Example of text field.</comment>
36
+ </custom_field_one>
37
+ </fields>
38
+ </section_one>
39
+ <section_two translate="label">
40
+ <label>Section Two</label>
41
+ <frontend_type>text</frontend_type>
42
+ <sort_order>2</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ <fields>
47
+ <custom_field_two>
48
+ <label>Custom Select Field</label>
49
+ <frontend_type>select</frontend_type>
50
+ <source_model>customconfig/options</source_model>
51
+ <sort_order>1</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>1</show_in_store>
55
+ <comment>Example of select field.</comment>
56
+ </custom_field_two>
57
+ <custom_field_three>
58
+ <label>Custom Radio Field</label>
59
+ <frontend_type>radios</frontend_type>
60
+ <source_model>customconfig/options</source_model>
61
+ <sort_order>2</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ <comment>Example of radios field.</comment>
66
+ </custom_field_three>
67
+ <custom_field_four>
68
+ <label>Custom Multiselect Field</label>
69
+ <frontend_type>multiselect</frontend_type>
70
+ <source_model>customconfig/options</source_model>
71
+ <sort_order>3</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ <comment>Example of multiselect field.</comment>
76
+ </custom_field_four>
77
+ </fields>
78
+ </section_two>
79
+ </groups>
80
+ </customconfig_options>
81
+ </sections>
82
+ </config>
app/code/local/Ansh/Customcontact/sql/customcontact_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+ -- DROP TABLE IF EXISTS {$this->getTable('customcontact')};
9
+ CREATE TABLE {$this->getTable('customcontact')} (
10
+ `id` int(11) unsigned NOT NULL auto_increment COMMENT 'ID',
11
+ `name` varchar(255) NOT NULL COMMENT 'Customer Name',
12
+ `email` varchar(255) NOT NULL COMMENT 'Customer Email',
13
+ `mobile_number` varchar(255) NOT NULL COMMENT 'Customer Mobile Number',
14
+ `queries` text NOT NULL COMMENT 'Customer queries',
15
+ `status` smallint(6) NOT NULL default '1',
16
+ `created_time` datetime NULL,
17
+ `update_time` datetime NULL,
18
+ PRIMARY KEY (`id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20
+
21
+ ");
22
+
23
+
24
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/customcontact.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <customcontact_adminhtml_customcontact_index>
4
+ <reference name="content">
5
+ <block type="customcontact/adminhtml_customcontact" name="customcontact" />
6
+ </reference>
7
+ </customcontact_adminhtml_customcontact_index>
8
+ </layout>
app/design/frontend/base/default/layout/customcontact.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+
4
+ <customcontact_index_index>
5
+ <reference name="content">
6
+ <block type="customcontact/customcontact" name="customcontact" template="customcontact/customcontact.phtml" />
7
+ </reference>
8
+ </customcontact_index_index>
9
+ </layout>
app/design/frontend/base/default/template/customcontact/customcontact.phtml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if(Mage::getStoreConfig('customcontact_options/general/enabled') == 1):?>
2
+ <?php $postData = Mage::getSingleton('customer/session')->getPostData();?>
3
+ <div>
4
+ <form id="simple_contact_form" name="simple_contact_form" action="<?php echo $this->getActionOfForm()?>" method="post">
5
+ <fieldset>
6
+ <h4>Custom Contact Form</h4>
7
+ <ul>
8
+ <li>
9
+ <div class="field">
10
+ <label for="name" class="required"><em>*</em><?php echo Mage::helper('customcontact')->__('Name') ?></label>
11
+ <div class="input-box">
12
+ <input type="text" id="name" name="name" value="<?php echo $postData['name'];?>" title="<?php echo Mage::helper('customcontact')->__('Name') ?>" maxlength="255" class="input-text required-entry">
13
+ </div>
14
+ </div>
15
+
16
+ <div class="field">
17
+ <label for="email" class="required"><em>*</em><?php echo Mage::helper('customcontact')->__('Email') ?></label>
18
+ <div class="input-box">
19
+ <input type="email" autocapitalize="off" autocorrect="off" spellcheck="false" name="email" id="email" value="<?php echo $postData['email'];?>" title="<?php echo Mage::helper('customcontact')->__('Email') ?>" class="input-text validate-email required-entry">
20
+ </div>
21
+ </div>
22
+
23
+ <div class="field">
24
+ <label for="mobile_number"><?php echo Mage::helper('customcontact')->__('Mobile Number') ?></label>
25
+ <div class="input-box">
26
+ <input type="text" id="mobile_number" name="mobile_number" value="<?php echo $postData['mobile_number'];?>" title="<?php echo Mage::helper('customcontact')->__('Mobile Number') ?>" maxlength="255" class="input-text validate-phoneLax">
27
+ </div>
28
+ </div>
29
+
30
+ <div class="field">
31
+ <label for="queries" class="required"><em>*</em><?php echo Mage::helper('customcontact')->__('Query/Note') ?></label>
32
+ <div class="input-box">
33
+ <textarea name="queries" id="queries" title="<?php echo Mage::helper('customcontact')->__('Query/Note') ?>" style="height:100px;" cols="50" rows="3" class="required-entry"></textarea>
34
+ </div>
35
+ </div>
36
+
37
+ </li>
38
+ </ul>
39
+ </fieldset>
40
+ <div class="buttons-set">
41
+ <button title="Submit" class="button" type="submit"><span><span>Submit</span></span></button>
42
+ </div>
43
+ </form>
44
+ </div>
45
+ <script type="text/javascript">
46
+ //<![CDATA[
47
+ var contactForm= new VarienForm('simple_contact_form', true); //For validation
48
+
49
+ //]]>
50
+
51
+ </script>
52
+
53
+ <?php endif; ?>
app/design/frontend/base/default/template/customcontact/customcontact.phtml~ ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div>
2
+ <!--<form id="simple_contact_form" name="simple_contact_form" action="<?php echo $this->getUrl('mageworks-contact/') ?>index/sendemail" method="post"> -->
3
+ <form id="simple_contact_form" name="simple_contact_form" action="<?php echo $this->getActionOfForm()?>" method="post">
4
+ <fieldset>
5
+ <h4>Simple Custom Contact Form</h4>
6
+ <ul>
7
+ <li>
8
+ <div><label for="name">your name <span>*</span></label> <input name="name" id="name" title="Name" value="" type="text"> </div>
9
+ <div><label for="email">your email <span>*</span></label> <input name="email" id="email" title="Email" value="" type="text"> </div>
10
+ <div></div>
11
+ <!--<div> <label for="comment">comment</label>
12
+ <textarea name="comment" id="comment" title="Comment" style="height:100px;" cols="50" rows="3"></textarea>
13
+ </div>-->
14
+ </li>
15
+ </ul>
16
+ </fieldset>
17
+ <div><p>* Required Fields</p>
18
+ <button type="submit"><span>Submit</span></button>
19
+ </div>
20
+ </form>
21
+ </div>
app/etc/modules/Ansh_Customcontact.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ansh_Customcontact>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Ansh_Customcontact>
8
+ </modules>
9
+ </config>
app/locale/en_US/template/email/customcontact_email_admin.html ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--@subject Ansh Custom Contact Form@-->
2
+ <!--@subject Contact Form@-->
3
+ <!--@vars
4
+ {"var name":"Sender Name",
5
+ "var email":"Sender Email",
6
+ "var mobile_number":"Sender Mobile Number",
7
+ "var queries":"Queries"}
8
+ @-->
9
+ Name: {{var name}}
10
+ Email: {{var email}}
11
+ Mobile Number: {{var mobile_number}}
12
+ Queries: {{var queries}}
app/locale/en_US/template/email/customcontact_email_customer.html ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <!--@subject Ansh Custom Contact Form@-->
2
+ <!--@vars
3
+ {"var name":"Customer Name",
4
+ }
5
+ @-->
6
+ Dear {{var name}}
7
+ Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us!!!
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Ansh_Customcontact</name>
4
+ <version>1.0.5</version>
5
+ <stability>stable</stability>
6
+ <license uri="https://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Custom Contacts is a powerful and robust extension to integrate a contact form to your site with ease. </summary>
10
+ <description>Custom Contacts is a powerful and robust extension to integrate a contact form to your site with ease. </description>
11
+ <notes>Stable version</notes>
12
+ <authors><author><name>Ansh</name><user>MagentoAnshsystem</user><email>MagentoAnshsystem@gmail.com</email></author></authors>
13
+ <date>2016-03-17</date>
14
+ <time>07:06:35</time>
15
+ <contents><target name="magelocal"><dir name="Ansh"><dir name="Customcontact"><dir name="Block"><dir name="Adminhtml"><file name="CustomContact.php~" hash="1f436d7a5db8d25a1661a3eba5709a88"/><dir name="Customcontact"><dir name="Edit"><file name="Form.php" hash="badd5970d4107375ddf874bce1325ddf"/><file name="Form.php~" hash="ef62b0c551a82ffbd2fdb837683ef029"/><dir name="Tab"><file name="Form.php" hash="32df314925f28084465cb1d218fd53a1"/><file name="Form.php~" hash="087ac7bf18dd803a6f52634a80356e26"/></dir><file name="Tabs.php" hash="51da5aa31c93089c0cd8a7ba9d0863ac"/><file name="Tabs.php~" hash="35aa9c2bf15ff914ddeddaffed33caef"/></dir><file name="Edit.php" hash="f864c9daa5b7eba881848dfd9953928e"/><file name="Edit.php~" hash="9ae92c1abbb9f8a2a54c50c322c545bc"/><file name="Grid.php" hash="03931d7bc366cd15c4881b7ec8825c1b"/><file name="Grid.php~" hash="af938f71195fbd259c1a5c3cb5a7d019"/></dir><file name="Customcontact.php" hash="fc47285f9d5e9a7a5748b95d3c30bed0"/></dir><file name="CustomContact.php~" hash="38b7aea561689c6f6b153ce4a36b7fb8"/><file name="Customcontact.php" hash="5244cdeed395cfd3301195f7253641aa"/></dir><dir name="Helper"><file name="Data.php" hash="662c0f7a1005f56b4b59c89452220d1c"/><file name="Data.php~" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><dir name="Model"><file name="CustomContact.php~" hash="d02a44a3c301973e7777237e565473b1"/><file name="Customcontact.php" hash="bd66c6ac847efdc98d00e14aa7e83838"/><dir name="Mysql4"><file name="CustomContact.php~" hash="77a6508c6c81a9bb074538936484aca7"/><dir name="Customcontact"><file name="Collection.php" hash="d0f9fa97ce82a902382d0227d4c2e9c3"/><file name="Collection.php~" hash="f2f86e9dab6de6aa564ee4ebdc0afd9b"/></dir><file name="Customcontact.php" hash="b7ce1439153d4025c6310cc2e7c42f57"/></dir><file name="Options.php~" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="Status.php" hash="5a98b17a91107afaba38abd18ec300c3"/><file name="Status.php~" hash="1154238194e9113cce9d0c0806cbbbdb"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CustomContactController.php~" hash="18a8f365b0d13ac29ea09ec9423f4de7"/><file name="CustomcontactController.php" hash="99a04992fabfb77a8a43c3555f5aa795"/></dir><file name="IndexController.php" hash="234013f383e208a9ddef59338f3ab800"/><file name="IndexController.php~" hash="09760ba912d295bcd36f01001bd72516"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1b6290b0f26e64d3703010d7c2800827"/><file name="config.xml" hash="d45e936db5281f9fa063a99126190e65"/><file name="config.xml~" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="system.xml" hash="6bb5aaa05ea6845d2a3fc7cb9dd00d1f"/><file name="system.xml~" hash="b635b81815713ed02b93c0e96b8740a3"/></dir><dir name="sql"><dir name="customcontact_setup"><file name="mysql4-install-1.0.0.php" hash="b0e452f7eb849f0c9da0af3eaa46b9e5"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ansh_Customcontact.xml" hash="e64663204840d485f3f956866952e092"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="customcontact.xml" hash="74d8059ac6cb5aacf183a0b4b2625d34"/></dir><dir name="template"><dir name="customcontact"><file name="customcontact.phtml" hash="5926527add5a6aa70daefa166c3b32b9"/><file name="customcontact.phtml~" hash="307a144968d119e6d9695c3f98dd1136"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="customcontact.xml" hash="0ab43b13ffa8c6c767cb105db8aecb9e"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="customcontact_email_admin.html" hash="b22a28dec574d1f28dce691b9e7be786"/><file name="customcontact_email_customer.html" hash="e0a27daf0ee038e75e9442705c26ce8e"/></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.5.0</min><max>5.6.0</max></php></required></dependencies>
18
+ </package>