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_XmlConnect_Block_Customer_Storecredit extends Mage_Core_Block_Template
35: {
36: 37: 38: 39: 40:
41: protected function _toHtml()
42: {
43:
44: $xmlModel = Mage::getModel('xmlconnect/simplexml_element', '<store_credits_info></store_credits_info>');
45:
46: $accountBalance = $this->getLayout()
47: ->addBlock('enterprise_customerbalance/account_balance', 'account_balance');
48:
49: $xmlModel->addCustomChild('balance', null, array(
50: 'label' => $this->__('Your current balance is:'),
51: 'value' => $accountBalance->getBalance(),
52: 'formatted_value' => Mage::helper('core')->currency($accountBalance->getBalance(), true, false)
53: ));
54:
55: $accountHistory = $this->getLayout()
56: ->addBlock('enterprise_customerbalance/account_history', 'account_history');
57:
58: if ($accountHistory->canShow() && $accountHistory->getEvents() && count($accountHistory->getEvents())) {
59: $balanceHistory = $xmlModel->addCustomChild('balance_history', null, array(
60: 'label' => $this->__('Balance History'),
61: 'action_label' => $this->__('Action'),
62: 'balance_change_label' => $this->__('Balance Change'),
63: 'balance_label' => $this->__('Balance'),
64: 'date_label' => $this->__('Date')
65: ));
66:
67: foreach ($accountHistory->getEvents() as $event) {
68: $item = $balanceHistory->addCustomChild('item');
69: $item->addCustomChild('action', null, array(
70: 'value' => $accountHistory->getActionLabel($event->getAction())
71: ));
72:
73: $item->addCustomChild('balance_change', null, array(
74: 'value' => Mage::helper('core')->currency($event->getBalanceDelta(), true, false)
75: ));
76:
77: $item->addCustomChild('balance', null, array(
78: 'value' => Mage::helper('core')->currency($event->getBalanceAmount(), true, false)
79: ));
80:
81: $item->addCustomChild('date', null, array(
82: 'value' => Mage::helper('core')->formatDate($event->getUpdatedAt(), 'short', true)
83: ));
84: }
85: }
86:
87: return $xmlModel->asNiceXml();
88: }
89: }
90: