1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27:
28: class Mage_Adminhtml_Block_System_Config_Form_Fieldset_Order_Statuses
29: extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
30: {
31: protected $_dummyElement;
32: protected $_fieldRenderer;
33: protected $_values;
34:
35: public function render(Varien_Data_Form_Element_Abstract $element)
36: {
37: $html = '';
38:
39: $statuses = Mage::getResourceModel('sales/order_status_collection')->load()->toOptionHash();
40:
41: foreach ($statuses as $id => $status) {
42: $html.= $this->_getFieldHtml($element, $id, $status);
43: }
44:
45:
46: return $html;
47: }
48:
49: protected function _getDummyElement()
50: {
51: if (empty($this->_dummyElement)) {
52: $this->_dummyElement = new Varien_Object(array('show_in_default'=>1, 'show_in_website'=>1));
53: }
54: return $this->_dummyElement;
55: }
56:
57: protected function _getFieldRenderer()
58: {
59: if (empty($this->_fieldRenderer)) {
60: $this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
61: }
62: return $this->_fieldRenderer;
63: }
64:
65: protected function _getFieldHtml($fieldset, $id, $status)
66: {
67: $configData = $this->getConfigData();
68: $path = 'sales/order_statuses/status_'.$id;
69: $data = isset($configData[$path]) ? $configData[$path] : array();
70:
71: $e = $this->_getDummyElement();
72:
73: $field = $fieldset->addField($id, 'text',
74: array(
75: 'name' => 'groups[order_statuses][fields][status_'.$id.'][value]',
76: 'label' => $status,
77: 'value' => isset($data['value']) ? $data['value'] : $status,
78: 'default_value' => isset($data['default_value']) ? $data['default_value'] : '',
79: 'old_value' => isset($data['old_value']) ? $data['old_value'] : '',
80: 'inherit' => isset($data['inherit']) ? $data['inherit'] : '',
81: 'can_use_default_value' => $this->getForm()->canUseDefaultValue($e),
82: 'can_use_website_value' => $this->getForm()->canUseWebsiteValue($e),
83: ))->setRenderer($this->_getFieldRenderer());
84:
85: return $field->toHtml();
86: }
87:
88: }
89: