Tentura_Statusdescription - Version 0.1.0

Version Notes

First version of extension

Download this release

Release Info

Developer Tentura Team
Extension Tentura_Statusdescription
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/Tentura/Statusdescription/.DS_Store ADDED
Binary file
app/code/community/Tentura/Statusdescription/Block/Adminhtml/Sales/Order/Status/Edit/Form.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tentura_Statusdescription_Block_Adminhtml_Sales_Order_Status_Edit_Form extends Tentura_Statusdescription_Block_Adminhtml_Sales_Order_Status_New_Form
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('new_order_status');
9
+ }
10
+
11
+ /**
12
+ * Modify structure of new status form
13
+ *
14
+ * @return Mage_Adminhtml_Block_Widget_Form
15
+ */
16
+ protected function _prepareForm()
17
+ {
18
+ parent::_prepareForm();
19
+ $form = $this->getForm();
20
+ $form->getElement('base_fieldset')->removeField('is_new');
21
+ $form->getElement('base_fieldset')->removeField('status');
22
+ $form->setAction(
23
+ $this->getUrl('*/sales_order_status/save', array('status'=>$this->getRequest()->getParam('status')))
24
+ );
25
+ return $this;
26
+ }
27
+ }
app/code/community/Tentura/Statusdescription/Block/Adminhtml/Sales/Order/Status/New/Form.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Tentura_Statusdescription_Block_Adminhtml_Sales_Order_Status_New_Form extends Mage_Adminhtml_Block_Sales_Order_Status_New_Form
3
+ {
4
+
5
+ /**
6
+ * Prepare form fields and structure
7
+ *
8
+ * @return Mage_Adminhtml_Block_Widget_Form
9
+ */
10
+ protected function _prepareForm()
11
+ {
12
+
13
+ $model = Mage::registry('current_status');
14
+ $labels = $model ? $model->getStoreLabels() : array();
15
+
16
+ $form = new Varien_Data_Form(array(
17
+ 'id' => 'edit_form',
18
+ 'action' => $this->getData('action'),
19
+ 'method' => 'post'
20
+ ));
21
+
22
+ $fieldset = $form->addFieldset('base_fieldset', array(
23
+ 'legend' => Mage::helper('sales')->__('Order Status Information')
24
+ ));
25
+
26
+ $fieldset->addField('is_new', 'hidden', array('name' => 'is_new', 'value' => 1));
27
+
28
+ $fieldset->addField('status', 'text',
29
+ array(
30
+ 'name' => 'status',
31
+ 'label' => Mage::helper('sales')->__('Status Code'),
32
+ 'class' => 'required-entry',
33
+ 'required' => true,
34
+ )
35
+ );
36
+
37
+ $fieldset->addField('label', 'text',
38
+ array(
39
+ 'name' => 'label',
40
+ 'label' => Mage::helper('sales')->__('Status Label'),
41
+ 'class' => 'required-entry',
42
+ 'required' => true,
43
+ )
44
+ );
45
+
46
+ $fieldset->addField('description', 'textarea',
47
+ array(
48
+ 'name' => 'description',
49
+ 'label' => Mage::helper('sales')->__('Description'),
50
+ 'class' => '',
51
+ 'required' => false,
52
+ )
53
+ );
54
+
55
+
56
+ $fieldset = $form->addFieldset('store_labels_fieldset', array(
57
+ 'legend' => Mage::helper('sales')->__('Store View Specific Labels'),
58
+ 'table_class' => 'form-list stores-tree',
59
+ ));
60
+
61
+ foreach (Mage::app()->getWebsites() as $website) {
62
+ $fieldset->addField("w_{$website->getId()}_label", 'note', array(
63
+ 'label' => $website->getName(),
64
+ 'fieldset_html_class' => 'website',
65
+ ));
66
+ foreach ($website->getGroups() as $group) {
67
+ $stores = $group->getStores();
68
+ if (count($stores) == 0) {
69
+ continue;
70
+ }
71
+ $fieldset->addField("sg_{$group->getId()}_label", 'note', array(
72
+ 'label' => $group->getName(),
73
+ 'fieldset_html_class' => 'store-group',
74
+ ));
75
+ foreach ($stores as $store) {
76
+ $fieldset->addField("store_label_{$store->getId()}", 'text', array(
77
+ 'name' => 'store_labels['.$store->getId().']',
78
+ 'required' => false,
79
+ 'label' => $store->getName(),
80
+ 'value' => isset($labels[$store->getId()]) ? $labels[$store->getId()] : '',
81
+ 'fieldset_html_class' => 'store',
82
+ ));
83
+ }
84
+ }
85
+ }
86
+
87
+ if ($model) {
88
+ $form->addValues($model->getData());
89
+ }
90
+ $form->setAction($this->getUrl('*/sales_order_status/save'));
91
+ $form->setUseContainer(true);
92
+ $this->setForm($form);
93
+
94
+ // return parent::_prepareForm();
95
+ }
96
+ }
app/code/community/Tentura/Statusdescription/Controller/Observer.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tentura_Statusdescription_Controller_Observer
4
+ {
5
+ //Event: adminhtml_controller_action_predispatch_start
6
+ public function overrideTheme()
7
+ {
8
+ Mage::getDesign()->setArea('adminhtml')
9
+ ->setTheme((string)Mage::getStoreConfig('design/admin/theme'));
10
+ }
11
+ }
app/code/community/Tentura/Statusdescription/controllers/.DS_Store ADDED
Binary file
app/code/community/Tentura/Statusdescription/controllers/Adminhtml/StatusController.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Tentura_Statusdescription_Adminhtml_StatusController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ function getAction(){
6
+
7
+ $status = $this->getRequest()->getParam('id');
8
+ $status = Mage::getModel('sales/order_status')->load($status);
9
+ echo $status->getDescription();
10
+
11
+ }
12
+
13
+ }
14
+
app/code/community/Tentura/Statusdescription/controllers/Sales/OrderController.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ include_once("Mage/Adminhtml/controllers/Sales/OrderController.php");
3
+ class Tentura_Statusdescription_Sales_OrderController extends Mage_Adminhtml_Sales_OrderController
4
+ {
5
+
6
+ /**
7
+ * Add order comment action
8
+ */
9
+ public function addCommentAction()
10
+ {
11
+ if ($order = $this->_initOrder()) {
12
+ try {
13
+ $response = false;
14
+ $data = $this->getRequest()->getPost('history');
15
+ $notify = isset($data['is_customer_notified']) ? $data['is_customer_notified'] : false;
16
+ $visible = isset($data['is_visible_on_front']) ? $data['is_visible_on_front'] : false;
17
+
18
+ $comment = $data['comment'];
19
+
20
+ preg_match_all('/{{[0-9a-zA-Z_.,]*}}/', $comment, $matches);
21
+ foreach ($matches as $match){
22
+ foreach ($match as $value){
23
+ $codeValue = $order->getData(str_replace('}}','',str_replace('{{','',$value)));
24
+ if ( $codeValue ){
25
+ $comment = str_replace($value, $codeValue, $comment);
26
+ }
27
+ }
28
+ }
29
+
30
+ $order->addStatusHistoryComment($comment, $data['status'])
31
+ ->setIsVisibleOnFront($visible)
32
+ ->setIsCustomerNotified($notify);
33
+
34
+ $comment = trim(strip_tags($comment));
35
+
36
+ $order->save();
37
+
38
+ $order->sendOrderUpdateEmail($notify, nl2br($comment));
39
+
40
+ $this->loadLayout('empty');
41
+ $this->renderLayout();
42
+ }
43
+ catch (Mage_Core_Exception $e) {
44
+ $response = array(
45
+ 'error' => true,
46
+ 'message' => $e->getMessage(),
47
+ );
48
+ }
49
+ catch (Exception $e) {
50
+ $response = array(
51
+ 'error' => true,
52
+ 'message' => $this->__('Cannot add order history.')
53
+ );
54
+ }
55
+ if (is_array($response)) {
56
+ $response = Mage::helper('core')->jsonEncode($response);
57
+ $this->getResponse()->setBody($response);
58
+ }
59
+ }
60
+ }
61
+
62
+ }
app/code/community/Tentura/Statusdescription/etc/config.xml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Tentura_Statusdescription>
5
+ <version>0.1.0</version>
6
+ </Tentura_Statusdescription>
7
+ </modules>
8
+ <admin>
9
+ <routers>
10
+ <adminhtml>
11
+ <args>
12
+ <modules>
13
+ <Tentura_Statusdescription before="Mage_Adminhtml">Tentura_Statusdescription</Tentura_Statusdescription>
14
+ </modules>
15
+ </args>
16
+ </adminhtml>
17
+ <statusdescription>
18
+ <use>admin</use>
19
+ <args>
20
+ <module>Tentura_Statusdescription</module>
21
+ <frontName>statusdescription</frontName>
22
+ </args>
23
+ </statusdescription>
24
+ </routers>
25
+ </admin>
26
+ <default>
27
+ <design>
28
+ <admin>
29
+ <theme>custom</theme>
30
+ </admin>
31
+ </design>
32
+ </default>
33
+ <global>
34
+ <events>
35
+ <adminhtml_controller_action_predispatch_start>
36
+ <observers>
37
+ <statusdescription_observer>
38
+ <type>singleton</type>
39
+ <class>Tentura_Statusdescription_Controller_Observer</class>
40
+ <method>overrideTheme</method>
41
+ </statusdescription_observer>
42
+ </observers>
43
+ </adminhtml_controller_action_predispatch_start>
44
+ </events>
45
+ <models>
46
+ <statusdescriptioncontroller>
47
+ <class>Tentura_Statusdescription_Controller</class>
48
+ </statusdescriptioncontroller>
49
+ <statusdescription>
50
+ <class>Tentura_Statusdescription_Model</class>
51
+ <resourceModel>statusdescription_mysql4</resourceModel>
52
+ </statusdescription>
53
+ <statusdescription_mysql4>
54
+ <class>Tentura_Statusdescription_Model_Mysql4</class>
55
+ </statusdescription_mysql4>
56
+ </models>
57
+ <resources>
58
+ <statusdescription_setup>
59
+ <setup>
60
+ <module>Tentura_Statusdescription</module>
61
+ </setup>
62
+ <connection>
63
+ <use>core_setup</use>
64
+ </connection>
65
+ </statusdescription_setup>
66
+ <statusdescription_write>
67
+ <connection>
68
+ <use>core_write</use>
69
+ </connection>
70
+ </statusdescription_write>
71
+ <statusdescription_read>
72
+ <connection>
73
+ <use>core_read</use>
74
+ </connection>
75
+ </statusdescription_read>
76
+ </resources>
77
+ <blocks>
78
+ <statusdescription>
79
+ <class>Tentura_Statusdescription_Block</class>
80
+ </statusdescription>
81
+ <adminhtml>
82
+ <rewrite>
83
+ <sales_order_status_new_form>Tentura_Statusdescription_Block_Adminhtml_Sales_Order_Status_New_Form</sales_order_status_new_form>
84
+ <sales_order_status_edit_form>Tentura_Statusdescription_Block_Adminhtml_Sales_Order_Status_Edit_Form</sales_order_status_edit_form>
85
+ </rewrite>
86
+ </adminhtml>
87
+ </blocks>
88
+ <helpers>
89
+ <statusdescription>
90
+ <class>Tentura_Statusdescription_Helper</class>
91
+ </statusdescription>
92
+ </helpers>
93
+ </global>
94
+ </config>
app/code/community/Tentura/Statusdescription/etc/system.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <design>
5
+ <groups>
6
+ <admin translate="label">
7
+ <label>Admin Theme</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>1</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <fields>
12
+ <theme translate="label comment">
13
+ <label>Admin theme name</label>
14
+ <comment>Override default admin theme.</comment>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>1</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ </theme>
19
+ </fields>
20
+ </admin>
21
+ </groups>
22
+ </design>
23
+ </sections>
24
+ </config>
app/code/community/Tentura/Statusdescription/sql/statusdescription_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run(" ALTER TABLE {$this->getTable('sales_order_status')} ADD `description` TEXT NOT NULL; ");
8
+
9
+ $installer->endSetup();
app/design/adminhtml/default/custom/template/sales/order/view/history.phtml ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div id="order_history_block">
3
+ <?php if ($this->canAddComment()):?>
4
+ <div id="history_form" class="order-history-form">
5
+ <div><?php echo Mage::helper('sales')->__('Add Order Comments') ?></div>
6
+ <span class="field-row">
7
+ <label class="normal" for="history_status"><?php echo Mage::helper('sales')->__('Status') ?></label><br/>
8
+ <select name="history[status]" class="select" id="history_status" onchange="historyStatus()">
9
+ <?php foreach ($this->getStatuses() as $_code=>$_label): ?>
10
+ <option value="<?php echo $_code ?>"<?php if($_code==$this->getOrder()->getStatus()): ?> selected="selected"<?php endif; ?>><?php echo $_label ?></option>
11
+ <?php endforeach; ?>
12
+ </select>
13
+ </span>
14
+ <span class="field-row">
15
+ <label class="normal" for="history_comment"><?php echo Mage::helper('sales')->__('Comment') ?></label>
16
+ <textarea name="history[comment]" rows="3" cols="5" style="height:6em; width:99%;" id="history_comment"></textarea>
17
+ </span>
18
+ <div class="f-left">
19
+ <?php if ($this->canSendCommentEmail()): ?>
20
+ <input name="history[is_customer_notified]" type="checkbox" id="history_notify" value="1" /><label class="normal" for="history_notify"> <?php echo Mage::helper('sales')->__('Notify Customer by Email') ?></label><br />
21
+ <?php endif; ?>
22
+ <input name="history[is_visible_on_front]" type="checkbox" id="history_visible" value="1" /><label class="normal" for="history_visible"> <?php echo Mage::helper('sales')->__('Visible on Frontend') ?></label>
23
+ </div>
24
+ <div class="f-right">
25
+ <?php echo $this->getChildHtml('submit_button') ?>
26
+ </div>
27
+ <div class="clear"></div>
28
+ </div>
29
+ <div class="divider"></div>
30
+ <?php endif;?>
31
+ <ul class="note-list">
32
+ <?php foreach ($this->getOrder()->getStatusHistoryCollection(true) as $_item): ?>
33
+ <li>
34
+ <strong><?php echo $this->helper('core')->formatDate($_item->getCreatedAtDate(), 'medium') ?></strong>
35
+ <?php echo $this->helper('core')->formatTime($_item->getCreatedAtDate(), 'medium') ?><span class="separator">|</span><strong><?php echo $_item->getStatusLabel() ?></strong><br/><small><?php echo $this->helper('sales')->__('Customer') ?>
36
+ <strong class="subdue">
37
+ <?php if ($this->isCustomerNotificationNotApplicable($_item)): ?>
38
+ <?php echo $this->helper('sales')->__('Notification Not Applicable') ?>
39
+ <?php elseif ($_item->getIsCustomerNotified()): ?>
40
+ <?php echo $this->helper('sales')->__('Notified') ?>
41
+ <img src="<?php echo $this->getSkinUrl('images/ico_success.gif') ?>" width="16" height="16" alt="" />
42
+ <?php else: ?>
43
+ <?php echo $this->helper('sales')->__('Not Notified') ?>
44
+ <?php endif; ?>
45
+ </strong></small>
46
+ <?php if ($_item->getComment()): ?>
47
+ <br/><?php echo $this->escapeHtml($_item->getComment(), array('b','br','strong','i','u')) ?>
48
+ <?php endif; ?>
49
+ </li>
50
+ <?php endforeach; ?>
51
+ </ul>
52
+ <script type="text/javascript">
53
+ if($('order_status'))$('order_status').update('<?php echo $this->getOrder()->getStatusLabel() ?>');
54
+ </script>
55
+ </div>
56
+ <script>
57
+ function historyStatus(){
58
+
59
+ if ($("history_status").value){
60
+ var url = '<?php echo $this->getUrl("statusdescription/adminhtml_status/get")?>id/' + $("history_status").value;
61
+ new Ajax.Request(url, {
62
+ method: 'post',
63
+ onSuccess: function(transport) {
64
+ $("history_comment").innerHTML = transport.responseText;
65
+ // editData = transport.responseText.evalJSON(true);
66
+ }
67
+ });
68
+
69
+ }
70
+
71
+ }
72
+ </script>
app/etc/modules/Tentura_Statusdescription.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Tentura_Statusdescription>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Tentura_Statusdescription>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Tentura_Statusdescription</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>GNU General Public License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Extension will give you possibility add descriptions to Order Statuses.</summary>
10
+ <description>In Magento existed possibility to change order status inside of order, and add some custom text, for notify customer about new status.&#xD;
11
+ &#xD;
12
+ Our extension will give you a way, pre-define texts for this messages.&#xD;
13
+ This will allow you to save a lot of time, and do not write same messages to users again and again.&#xD;
14
+ &#xD;
15
+ Also extension allow you to user order variables, which will be automatically replaced to values. (For example: {{customer_lastname}}, {{customer_firstname}}, and so on.)&#xD;
16
+ &#xD;
17
+ </description>
18
+ <notes>First version of extension</notes>
19
+ <authors><author><name>Tentura Team</name><user>tentura</user><email>info@tentura.eu</email></author></authors>
20
+ <date>2012-10-13</date>
21
+ <time>18:31:12</time>
22
+ <contents><target name="magecommunity"><dir name="Tentura"><dir name="Statusdescription"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><dir name="Status"><dir name="Edit"><file name="Form.php" hash="f43924371c725860b1ef93533cf6edf3"/></dir><dir name="New"><file name="Form.php" hash="6a471990483c47461ea812d08587ad27"/></dir></dir></dir></dir></dir></dir><dir name="Controller"><file name="Observer.php" hash="30bd933ae9836a4040042e211c7830e4"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="StatusController.php" hash="938131c85be3fe9d59f044c9d7c8bcaf"/></dir><dir name="Sales"><file name="OrderController.php" hash="4ba422055169568e85aaf1fa80980435"/></dir><file name=".DS_Store" hash="e4c60e8f0e5d9209a00801f997909fe7"/></dir><dir name="etc"><file name="config.xml" hash="8eb39555fc09e0ed1aaf873bb581e3c7"/><file name="system.xml" hash="21639a971010a9eec8470d2f6e28cf4a"/></dir><dir name="sql"><dir name="statusdescription_setup"><file name="mysql4-install-0.1.0.php" hash="4d27ad6ab07d6d2169a5c61c674ffac8"/></dir></dir><file name=".DS_Store" hash="26e932f1219a37599354d6d142605cd8"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="custom"><dir name="template"><dir name="sales"><dir name="order"><dir name="view"><file name="history.phtml" hash="3245451a60703ad4a0bc6339eb7f118d"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Tentura_Statusdescription.xml" hash="79291b30cead219989d18597d6a04e86"/></dir></target></contents>
23
+ <compatible/>
24
+ <dependencies><required><php><min>5.2.13</min><max>5.4.7</max></php></required></dependencies>
25
+ </package>