Amm_Request - Version 1.0.0.1

Version Notes

Development

Download this release

Release Info

Developer Alexey
Extension Amm_Request
Version 1.0.0.1
Comparing to
See all releases


Version 1.0.0.1

app/code/community/Amm/Request/Block/Adminhtml/Edit.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Request_Block_Adminhtml_Edit extends Mage_Adminhtml_Block_Widget_Form_Container{
3
+ public function __construct()
4
+ {
5
+ $this->_objectId = 'id';
6
+ $this->_controller = 'adminhtml';
7
+ $this->_blockGroup = 'request';
8
+ $this->_mode = 'edit';
9
+ $this->_updateButton('save', 'label','save');
10
+ $this->_updateButton('delete', 'label', 'delete');
11
+ parent::__construct();
12
+ $this->_removeButton('reset');
13
+
14
+ if( $this->getRequest()->getParam($this->_objectId) ) {
15
+ $requestData = Mage::getModel('request/request')->load($this->getRequest()->getParam($this->_objectId));
16
+ Mage::register('request_edit', $requestData);
17
+ }
18
+ }
19
+
20
+ public function getHeaderText()
21
+ {
22
+ return 'Edit';
23
+ }
24
+ }
app/code/community/Amm/Request/Block/Adminhtml/Edit/Form.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Request_Block_Adminhtml_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('request_edit');
8
+ }
9
+
10
+ protected function _prepareForm()
11
+ {
12
+ if (Mage::getSingleton('adminhtml/session')->getRequestData())
13
+ {
14
+ $data = Mage::getSingleton('adminhtml/session')->getRequestData();
15
+ Mage::getSingleton('adminhtml/session')->getRequestData(null);
16
+ }
17
+ elseif (Mage::registry('request_data'))
18
+ {
19
+ $data = Mage::registry('request_data')->getData();
20
+ }
21
+ else
22
+ {
23
+ $data = array();
24
+ }
25
+
26
+ $form = new Varien_Data_Form(
27
+ array(
28
+ 'id' => 'edit_form',
29
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))
30
+ ),
31
+ 'method' => 'post',
32
+ )
33
+ );
34
+ $form->setUseContainer(true);
35
+ $this->setForm($form);
36
+
37
+ $fieldset = $form->addFieldset('request_edit', array(
38
+ 'legend' =>Mage::helper('request')->__('Request Information'),
39
+ 'style' => 'width:100%;',
40
+ ));
41
+
42
+ $fieldset->addField('theme', 'text', array(
43
+ 'label' => Mage::helper('request')->__('theme'),
44
+ 'style' => 'width:500px;',
45
+ 'required' => true,
46
+ 'name' => 'theme',
47
+ ));
48
+
49
+ $fieldset->addField('message', 'editor', array(
50
+ 'label' => Mage::helper('request')->__('Message'),
51
+ 'style' => 'width:500px; height:200px;',
52
+ 'required' => true,
53
+ 'name' => 'message',
54
+ ));
55
+
56
+ $fieldset->addField('answer', 'editor', array(
57
+ 'label' => Mage::helper('request')->__('Answer'),
58
+ 'style' => 'width:500px; height:100px;',
59
+ 'required' => true,
60
+ 'name' => 'answer',
61
+ ));
62
+
63
+ $fieldset->addField('flag_new_message', 'select', array(
64
+ 'label' => Mage::helper('request')->__('Status'),
65
+ 'name' => 'flag_new_message',
66
+ 'values' => array(
67
+ array(
68
+ 'value' => 1,
69
+ 'label' => Mage::helper('request')->__('New'),
70
+ ),
71
+
72
+ array(
73
+ 'value' => 0,
74
+ 'label' => Mage::helper('request')->__('Done'),
75
+ ),
76
+ ),
77
+ ));
78
+
79
+ $form->setValues($data);
80
+
81
+ return parent::_prepareForm();
82
+ }
83
+ }
app/code/community/Amm/Request/Block/Adminhtml/Grid.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Request_Block_Adminhtml_Grid extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ //where is the controller
7
+ $this->_controller = 'adminhtml_request';
8
+ $this->_blockGroup = 'request';
9
+ //text in the admin header
10
+ $this->_headerText = "All Customer's Requests";
11
+ //value of the add button
12
+ //$this->_addButtonLabel = 'Add a contact';
13
+ parent::__construct();
14
+ $this->_removeButton('add');
15
+ }
16
+ }
app/code/community/Amm/Request/Block/Adminhtml/Request/Grid.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Request_Block_Adminhtml_Request_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('request_grid');
8
+ $this->setDefaultSort('id');
9
+ $this->setDefaultDir('DESC');
10
+ $this->setSaveParametersInSession(true);
11
+ }
12
+ protected function _prepareCollection()
13
+ {
14
+ $collection = Mage::getModel('request/request')->getCollection()->setOrder('dcreate','desc');
15
+
16
+ $resource = Mage::getSingleton('core/resource');
17
+
18
+ $collection->getSelect()
19
+ ->join( array('ce1' => $resource->getTableName('customer_entity')), 'ce1.entity_id=main_table.id_customer', array('email' => 'email'))
20
+ ->join( array('ce2' => $resource->getTableName('customer_entity_varchar')), 'ce2.entity_id=main_table.id_customer AND ce2.attribute_id=5', array('buyer_first_name' => 'value'))
21
+ ->join( array('ce3' => $resource->getTableName('customer_entity_varchar')), 'ce3.entity_id=main_table.id_customer AND ce3.attribute_id=7', array('buyer_last_name' => 'value'));
22
+
23
+ $this->setCollection($collection);
24
+ return parent::_prepareCollection();
25
+ }
26
+ protected function _prepareColumns()
27
+ {
28
+ $this->addColumn('First Name',
29
+ array(
30
+ 'header' => 'First Name',
31
+ 'align' =>'left',
32
+ 'filter' => false,
33
+ 'index' => 'buyer_first_name',
34
+ ));
35
+ $this->addColumn('Last Name',
36
+ array(
37
+ 'header' => 'Last Name',
38
+ 'align' =>'left',
39
+ 'filter' => false,
40
+ 'index' => 'buyer_last_name',
41
+ ));
42
+ $this->addColumn('Email',
43
+ array(
44
+ 'header' => 'Email',
45
+ 'align' =>'left',
46
+ 'index' => 'email',
47
+ ));
48
+ $this->addColumn('Theme', array(
49
+ 'header' => 'Theme',
50
+ 'align' =>'left',
51
+ 'index' => 'theme',
52
+ ));
53
+ $this->addColumn('Created', array(
54
+ 'header' => 'Created',
55
+ 'align' =>'left',
56
+ 'index' => 'dcreate',
57
+ ));
58
+ $this->addColumn('Answered', array(
59
+ 'header' => 'Answered',
60
+ 'align' =>'left',
61
+ 'filter' => false,
62
+ 'index' => 'danswer',
63
+ ));
64
+ $this->addColumn('Status', array(
65
+ 'header' => 'Status',
66
+ 'align' =>'left',
67
+ 'filter' => false,
68
+ 'index' => 'flag_new_message',
69
+ 'type' => 'options',
70
+ 'options' => array('0' => 'ready', '1' => 'new'),
71
+ ));
72
+ return parent::_prepareColumns();
73
+ }
74
+ public function getRowUrl($row)
75
+ {
76
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
77
+ }
78
+ }
app/code/community/Amm/Request/Block/Monblock.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Request_Block_Monblock extends Mage_Core_Block_Template
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+
8
+ $session = $this->_getSession()->toArray();
9
+
10
+ $column = 'id_customer';
11
+ $value = $session['id'];
12
+
13
+ $collection = Mage::getModel('request/request')->getCollection()->addFilter($column,$value)->setOrder('dcreate','desc');
14
+
15
+ $this->setCollection($collection);
16
+ }
17
+
18
+ protected function _getSession()
19
+ {
20
+ return Mage::getSingleton('customer/session');
21
+ }
22
+
23
+ protected function _prepareLayout()
24
+ {
25
+ parent::_prepareLayout();
26
+
27
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'custom.pager');
28
+ $pager->setAvailableLimit(array(5=>5,10=>10,20=>20,'all'=>'all'));
29
+ $pager->setCollection($this->getCollection());
30
+ $this->setChild('pager', $pager);
31
+ $this->getCollection()->load();
32
+ return $this;
33
+ }
34
+
35
+ public function getPagerHtml()
36
+ {
37
+ return $this->getChildHtml('pager');
38
+ }
39
+
40
+
41
+ public function showblock()
42
+ {
43
+
44
+ $return = '';
45
+ $collection = $this->getCollection();
46
+
47
+ if($collection->getSize()){
48
+ $return = $this->getPagerHtml().'
49
+ <div class="request_table">
50
+ <table>
51
+ <tr>
52
+ <th style="width:100px;">Created</th>
53
+ <th>Theme</th>
54
+ <th style="width:50px;">Status</th>
55
+ </tr>';
56
+ foreach($collection as $data){
57
+ $return .= '<tr class="clicktagtr" onclick="fshowtr('.$data->getData('id').');return false;">
58
+ <td style="width:100px;">'.$data->getData('dcreate').'</td>
59
+ <td>'.$data->getData('theme').'</td>
60
+ <td style="width:50px;">'.($data->getData('flag_new_message')==1?'[ <span class="request_new">new</span> ]':'[ ready ]').'</td>
61
+ </tr>
62
+ <tr id="showtr'.$data->getData('id').'" style="display:none;">
63
+ <td colspan="3">
64
+ <p><strong>Message</strong></p>
65
+ <p>'.$data->getData('message').'</p>
66
+ <p><strong>Answer</strong></p>
67
+ <p>'.$data->getData('answer').'</p>
68
+ <p>&nbsp;</p>
69
+ </td>
70
+ </tr>';
71
+ }
72
+ $return .= '</table>
73
+ '.$this->getPagerHtml().'
74
+ <p>&nbsp;</p>
75
+ </div>';
76
+ }
77
+
78
+ return $return;
79
+ }
80
+
81
+
82
+ }
app/code/community/Amm/Request/Helper/Data.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Amm_Request_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
7
+
app/code/community/Amm/Request/Model/Mysql4/Request.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Request_Model_Mysql4_Request extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('request/request', 'id');
7
+ }
8
+ }
app/code/community/Amm/Request/Model/Mysql4/Request/Collection.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Request_Model_Mysql4_Request_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('request/request');
8
+ }
9
+ }
app/code/community/Amm/Request/Model/Mysql4/Setup.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+
3
+ class Amm_Request_Model_Mysql4_Setup extends Mage_Core_Model_Resource_Setup {
4
+ }
app/code/community/Amm/Request/Model/Request.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Request_Model_Request extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('request/request');
8
+ }
9
+ }
app/code/community/Amm/Request/controllers/Adminhtml/IndexController.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Amm_Request_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+
5
+ protected function _initAction()
6
+ {
7
+ $this->loadLayout()->_setActiveMenu('adminhtml/adminhtml')->_addBreadcrumb('request Manager','request Manager');
8
+ return $this;
9
+ }
10
+
11
+ public function indexAction()
12
+ {
13
+ $this->_initAction()->renderLayout();
14
+ }
15
+
16
+ public function editAction()
17
+ {
18
+ $id = $this->getRequest()->getParam('id', null);
19
+ $model = Mage::getModel('request/request');
20
+ if ($id) {
21
+ $model->load((int) $id);
22
+ if ($model->getId()) {
23
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
24
+ if ($data) {
25
+ $model->setData($data)->setId($id);
26
+ }
27
+ } else {
28
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('request')->__('Request does not exist'));
29
+ $this->_redirect('*/*/');
30
+ }
31
+ }
32
+ Mage::register('request_data', $model);
33
+
34
+ $this->_initAction();
35
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
36
+ $this->renderLayout();
37
+ }
38
+
39
+ public function newAction()
40
+ {
41
+ $this->_forward('edit');
42
+ }
43
+
44
+ public function saveAction()
45
+ {
46
+ if ($this->getRequest()->getPost())
47
+ {
48
+ try {
49
+ $postData = $this->getRequest()->getPost();
50
+ $postData['danswer']=date('Y-m-d H:i');
51
+ if($postData['answer']!=''){ $postData['flag_new_message']=0; }
52
+
53
+ // var_dump($postData);
54
+
55
+ $testModel = Mage::getModel('request/request');
56
+ if( $this->getRequest()->getParam('id') <= 0 )
57
+ $testModel->setCreatedTime(Mage::getSingleton('core/date')->gmtDate());
58
+ $testModel->addData($postData)->setUpdateTime(Mage::getSingleton('core/date')->gmtDate())->setId($this->getRequest()->getParam('id'))->save();
59
+ Mage::getSingleton('adminhtml/session')->addSuccess('successfully saved');
60
+ Mage::getSingleton('adminhtml/session')->setrequestData(false);
61
+ $this->_redirect('*/*/');
62
+ return;
63
+ } catch (Exception $e){
64
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
65
+ Mage::getSingleton('adminhtml/session')->setrequestData($this->getRequest()->getPost());
66
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
67
+ return;
68
+ }
69
+ }
70
+
71
+ $this->_redirect('*/*/');
72
+ }
73
+
74
+ public function deleteAction()
75
+ {
76
+ if($this->getRequest()->getParam('id') > 0)
77
+ {
78
+ try
79
+ {
80
+ $testModel = Mage::getModel('request/request');
81
+ $testModel->setId($this->getRequest()->getParam('id'))->delete();
82
+ Mage::getSingleton('adminhtml/session')->addSuccess('successfully deleted');
83
+ $this->_redirect('*/*/');
84
+ }
85
+ catch (Exception $e)
86
+ {
87
+ Mage::getSingleton('adminhtml/session')
88
+ ->addError($e->getMessage());
89
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
90
+ }
91
+ }
92
+ $this->_redirect('*/*/');
93
+ }
94
+
95
+ }
app/code/community/Amm/Request/controllers/IndexController.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Catalog
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ class Amm_Request_IndexController extends Mage_Core_Controller_Front_Action
28
+ {
29
+ /**
30
+ * Index action
31
+ */
32
+
33
+ protected function _getSession()
34
+ {
35
+ return Mage::getSingleton('customer/session');
36
+ }
37
+
38
+ public function indexAction()
39
+ {
40
+ $session = $this->_getSession();
41
+ if(!$session->isLoggedIn()){
42
+ $this->_redirectUrl(Mage::helper('customer')->getLoginUrl());
43
+ }else{
44
+
45
+ $this->loadLayout();
46
+
47
+ $navigationBlock = $this->getLayout()->getBlock('customer_account_navigation');
48
+ if ($navigationBlock) {
49
+ $navigationBlock->setActive('request');
50
+ }
51
+
52
+ $this->renderLayout();
53
+
54
+ }
55
+ }
56
+
57
+ public function addAction()
58
+ {
59
+ $session = $this->_getSession()->toArray();
60
+ $theme = mb_substr(strip_tags(''.$this->getRequest()->getPost('form_MR_theme')),0,100,'utf-8');
61
+ $message = strip_tags(''.$this->getRequest()->getPost('form_MR_message'));
62
+ $date_now = date("Y-m-d H:i");
63
+
64
+ if(isset($theme) && $theme!='' && isset($message) && $message!=''){
65
+ $form_save = Mage::getModel('request/request');
66
+ $form_save->setData('id_customer', $session['id']);
67
+ $form_save->setData('theme', $theme);
68
+ $form_save->setData('message', $message);
69
+ $form_save->setData('dcreate', $date_now);
70
+ $form_save->setData('flag_new_message', 1);
71
+ $form_save->save();
72
+ }
73
+
74
+ $this->_redirectUrl(Mage::getBaseUrl().'request/');
75
+ }
76
+
77
+ }
app/code/community/Amm/Request/etc/config.xml ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Amm_Request>
5
+ <version>0.0.1</version>
6
+ </Amm_Request>
7
+ </modules>
8
+
9
+ <frontend>
10
+ <routers>
11
+ <request>
12
+ <use>standard</use>
13
+ <args>
14
+ <module>Amm_Request</module>
15
+ <frontName>request</frontName>
16
+ </args>
17
+ </request>
18
+ </routers>
19
+ <layout>
20
+ <updates>
21
+ <request>
22
+ <file>request.xml</file>
23
+ </request>
24
+ </updates>
25
+ </layout>
26
+ </frontend>
27
+
28
+ <admin>
29
+ <routers>
30
+ <request>
31
+ <use>admin</use>
32
+ <args>
33
+ <module>Amm_Request</module>
34
+ <frontName>request</frontName>
35
+ </args>
36
+ </request>
37
+ </routers>
38
+ </admin>
39
+
40
+ <adminhtml>
41
+ <layout>
42
+ <updates>
43
+ <request>
44
+ <file>request.xml</file>
45
+ </request>
46
+ </updates>
47
+ </layout>
48
+ <menu>
49
+ <adminhtml translate="title" module="adminhtml">
50
+ <title>Additional modules</title>
51
+ <sort_order>100</sort_order>
52
+ <children>
53
+ <requestindex translate="title" module="adminhtml">
54
+ <title>Requests</title>
55
+ <action>request/adminhtml_index</action>
56
+ <sort_order>10</sort_order>
57
+ </requestindex>
58
+ </children>
59
+ </adminhtml>
60
+ </menu>
61
+ </adminhtml>
62
+
63
+ <global>
64
+ <blocks>
65
+ <request>
66
+ <class>Amm_Request_Block</class>
67
+ </request>
68
+ </blocks>
69
+ <helpers>
70
+ <request>
71
+ <class>Amm_Request_Helper</class>
72
+ </request>
73
+ </helpers>
74
+ <models>
75
+ <request>
76
+ <class>Amm_Request_Model</class>
77
+ <resourceModel>request_mysql4</resourceModel>
78
+ </request>
79
+ <request_mysql4>
80
+ <class>Amm_Request_Model_Mysql4</class>
81
+ <entities>
82
+ <request>
83
+ <table>amm_request</table>
84
+ </request>
85
+ </entities>
86
+ </request_mysql4>
87
+ </models>
88
+ <!-- allow the plugin to read and write -->
89
+ <resources>
90
+
91
+ <request_setup>
92
+ <setup>
93
+ <module>Amm_Request</module>
94
+ <class>Amm_Request_Model_Mysql4_Setup</class>
95
+ </setup>
96
+ </request_setup>
97
+
98
+ <!-- connection to write -->
99
+ <request_write>
100
+ <connection>
101
+ <use>core_write</use>
102
+ </connection>
103
+ </request_write>
104
+ <!-- connection to read -->
105
+ <request_read>
106
+ <connection>
107
+ <use>core_read</use>
108
+ </connection>
109
+ </request_read>
110
+ </resources>
111
+ </global>
112
+ </config>
app/code/community/Amm/Request/sql/request_setup/mysql4-install-0.0.1.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ //echo $installer->getTable('amm_request'); die();
8
+
9
+ $table = $installer->getConnection()->newTable($installer->getTable('amm_request'))
10
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
11
+ 'unsigned' => true,
12
+ 'nullable' => false,
13
+ 'primary' => true,
14
+ 'identity' => true,
15
+ ), 'ID')
16
+ ->addColumn('id_customer', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
17
+ 'unsigned' => true,
18
+ 'nullable' => true,
19
+ ), 'ID Customer')
20
+ ->addColumn('theme', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
21
+ 'nullable' => false,
22
+ ), 'Theme')
23
+ ->addColumn('message', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
24
+ 'nullable' => true,
25
+ ), 'Message')
26
+ ->addColumn('answer', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
27
+ 'nullable' => true,
28
+ ), 'Answer')
29
+ ->addColumn('dcreate', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
30
+ ), 'Dcreate')
31
+ ->addColumn('danswer', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
32
+ ), 'Danswer')
33
+ ->addColumn('flag_new_message', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
34
+ 'unsigned' => true,
35
+ 'nullable' => true,
36
+ ), 'Flag message')
37
+ ->addColumn('flag_new_answer', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
38
+ 'unsigned' => true,
39
+ 'nullable' => true,
40
+ ), 'Flag answer')
41
+ ->setComment('amm_request table');
42
+ $installer->getConnection()->createTable($table);
43
+
44
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/request.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <layout version="0.0.1">
3
+ <request_adminhtml_index_index>
4
+ <reference name="content">
5
+ <block type="request/adminhtml_grid" name="request_grid" />
6
+ </reference>
7
+ </request_adminhtml_index_index>
8
+
9
+ <request_adminhtml_index_edit>
10
+ <reference name="content">
11
+ <block type="request/adminhtml_edit" name="request_edit" />
12
+ </reference>
13
+ </request_adminhtml_index_edit>
14
+ </layout>
app/design/frontend/base/default/layout/request.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <layout version="0.1.0">
2
+ <default>
3
+ <reference name="content">
4
+ </reference>
5
+ </default>
6
+
7
+ <customer_account>
8
+ <reference name="customer_account_navigation">
9
+ <action method="addLink" translate="label" module="request"><name>request</name><path>request</path><label>My Requests</label></action>
10
+ </reference>
11
+ </customer_account>
12
+
13
+
14
+ <request_index_index>
15
+ <remove name="right"/>
16
+
17
+ <update handle="customer_account"/>
18
+
19
+ <reference name="root">
20
+ <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
21
+ </reference>
22
+
23
+ <reference name="content">
24
+ <block type="request/monblock" name="show_monblock" template="request/show.phtml" />
25
+ </reference>
26
+ </request_index_index>
27
+ </layout>
app/design/frontend/base/default/template/request/show.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div>
2
+ <h2><?php echo $this->__('My Requests') ?></h2>
3
+
4
+ <?php echo $this->showblock(); ?>
5
+
6
+ <h3><?php echo $this->__('Add new request') ?></h3>
7
+
8
+ <form action="<?php echo Mage::getUrl('request/index/add') ?>" method="post" name="formaddrequest">
9
+ <p><strong>Theme ( up to 100 characters )</strong><br /><input type="text" name="form_MR_theme" value="" style="width:95%" /></p>
10
+ <p><strong>Message</strong><br /><textarea name="form_MR_message" style="width:95%" rows="10"></textarea></p>
11
+ <p><input type="submit" name="form_MR_submit" value="Add" /></p>
12
+ </form>
13
+
14
+ </div>
15
+
16
+
17
+ <style type="text/css">
18
+ .request_table td, .request_table th{
19
+ padding:3px;
20
+ }
21
+ .request_table th{
22
+ font-weight:bold;
23
+ }
24
+ .request_table table{
25
+ width:100%;
26
+ }
27
+ .request_new{
28
+ color:#ff0000;
29
+ }
30
+ .clicktagtr{
31
+ cursor:pointer;
32
+ }
33
+ </style>
34
+
35
+ <script>
36
+ function fshowtr(id){
37
+ if(document.getElementById("showtr"+id)){
38
+ if(document.getElementById("showtr"+id).style.display=="none"){
39
+ document.getElementById("showtr"+id).style.display="table-row";
40
+ }else{
41
+ document.getElementById("showtr"+id).style.display="none";
42
+ }
43
+ }else{
44
+ document.getElementById("showtr"+id).style.display="table-row";
45
+ }
46
+ }
47
+ </script>
app/etc/modules/Amm_Request.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <Amm_Request>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Amm_Request>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Amm_Request</name>
4
+ <version>1.0.0.1</version>
5
+ <stability>stable</stability>
6
+ <license>GNU</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Request</summary>
10
+ <description>Request</description>
11
+ <notes>Development</notes>
12
+ <authors><author><name>Alexey</name><user>softaliance</user><email>softaliancecom@gmail.com</email></author></authors>
13
+ <date>2013-03-13</date>
14
+ <time>15:01:14</time>
15
+ <contents><target name="magecommunity"><dir name="Amm"><dir name="Request"><dir name="Block"><dir name="Adminhtml"><dir name="Edit"><file name="Form.php" hash="713e0e664a51119f422fda57c38bd3b0"/></dir><file name="Edit.php" hash="d581e4ecc9b56130dbc59444056712d6"/><file name="Grid.php" hash="39b572c4aec2d9bb13d90024b02caefa"/><dir name="Request"><file name="Grid.php" hash="cf0a82addda6416e336185fda7b0197a"/></dir></dir><file name="Monblock.php" hash="76d9dcf27ee7c9ca689276e162f7e3fa"/></dir><dir name="Helper"><file name="Data.php" hash="0859583f89bbdf4c63c222b88974ef08"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Request"><file name="Collection.php" hash="241f41408674e25498db84a957e49d49"/></dir><file name="Request.php" hash="4a6e1a14f68db2aed0799905ad65085e"/><file name="Setup.php" hash="5add7efe4b3a5a24c982be2503c4b2fc"/></dir><file name="Request.php" hash="e52cdc5fe7aae85b2803202b355aea1c"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="5c330701173d6a43eebde16097047bdd"/></dir><file name="IndexController.php" hash="c707a241f5632c225f03a85b91ec68f8"/></dir><dir name="etc"><file name="config.xml" hash="34b467a0dca9e6bfefa8105ee962d1d2"/></dir><dir name="sql"><dir name="request_setup"><file name="mysql4-install-0.0.1.php" hash="7d2079694df152f349fc59dbae3fb2d6"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="request.xml" hash="dcd2a5c07ceedd42f4587e80908c956b"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="request.xml" hash="c91a8ac9ed4d6e0b659c5da67e0ec36e"/></dir><dir name="template"><dir name="request"><file name="show.phtml" hash="db2f6d15004b787a58591445054280e1"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Amm_Request.xml" hash="28a3be64b71486ce99e8809034b65643"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>5.3.99</max></php></required></dependencies>
18
+ </package>