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: 29: 30: 31: 32: 33:
34: class Mage_Adminhtml_Block_Customer_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
35: {
36: public function __construct()
37: {
38: $this->_objectId = 'id';
39: $this->_controller = 'customer';
40:
41: if ($this->getCustomerId() &&
42: Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/create')) {
43: $this->_addButton('order', array(
44: 'label' => Mage::helper('customer')->__('Create Order'),
45: 'onclick' => 'setLocation(\'' . $this->getCreateOrderUrl() . '\')',
46: 'class' => 'add',
47: ), 0);
48: }
49:
50: parent::__construct();
51:
52: $this->_updateButton('save', 'label', Mage::helper('customer')->__('Save Customer'));
53: $this->_updateButton('delete', 'label', Mage::helper('customer')->__('Delete Customer'));
54:
55: if (Mage::registry('current_customer')->isReadonly()) {
56: $this->_removeButton('save');
57: $this->_removeButton('reset');
58: }
59:
60: if (!Mage::registry('current_customer')->isDeleteable()) {
61: $this->_removeButton('delete');
62: }
63: }
64:
65: public function getCreateOrderUrl()
66: {
67: return $this->getUrl('*/sales_order_create/start', array('customer_id' => $this->getCustomerId()));
68: }
69:
70: public function getCustomerId()
71: {
72: return Mage::registry('current_customer')->getId();
73: }
74:
75: public function ()
76: {
77: if (Mage::registry('current_customer')->getId()) {
78: return $this->htmlEscape(Mage::registry('current_customer')->getName());
79: }
80: else {
81: return Mage::helper('customer')->__('New Customer');
82: }
83: }
84:
85: 86: 87: 88: 89:
90: public function getFormHtml()
91: {
92: $html = parent::getFormHtml();
93: $html .= $this->getLayout()->createBlock('adminhtml/catalog_product_composite_configure')->toHtml();
94: return $html;
95: }
96:
97: public function getValidationUrl()
98: {
99: return $this->getUrl('*/*/validate', array('_current'=>true));
100: }
101:
102: protected function _prepareLayout()
103: {
104: if (!Mage::registry('current_customer')->isReadonly()) {
105: $this->_addButton('save_and_continue', array(
106: 'label' => Mage::helper('customer')->__('Save and Continue Edit'),
107: 'onclick' => 'saveAndContinueEdit(\''.$this->_getSaveAndContinueUrl().'\')',
108: 'class' => 'save'
109: ), 10);
110: }
111:
112: return parent::_prepareLayout();
113: }
114:
115: protected function _getSaveAndContinueUrl()
116: {
117: return $this->getUrl('*/*/save', array(
118: '_current' => true,
119: 'back' => 'edit',
120: 'tab' => '{{tab_id}}'
121: ));
122: }
123: }
124: