diff --git a/Block/Adminhtml/Order/Charge/Tab/View.php b/Block/Adminhtml/Order/Charge/Tab/View.php index e016f2f4..19e878b6 100644 --- a/Block/Adminhtml/Order/Charge/Tab/View.php +++ b/Block/Adminhtml/Order/Charge/Tab/View.php @@ -2,79 +2,150 @@ namespace Pagarme\Pagarme\Block\Adminhtml\Order\Charge\Tab; +use Exception; +use Magento\Backend\Block\Template; +use Magento\Backend\Block\Template\Context; +use Magento\Backend\Block\Widget\Tab\TabInterface; +use Magento\Framework\Registry; +use Magento\Sales\Model\Order; +use Pagarme\Core\Kernel\Aggregates\Charge; +use Pagarme\Core\Kernel\Exceptions\InvalidParamException; use Pagarme\Pagarme\Concrete\Magento2CoreSetup; +use Pagarme\Pagarme\Helper\HtmlTableHelper; +use Pagarme\Pagarme\Service\Order\ChargeService; -use Pagarme\Core\Kernel\Repositories\ChargeRepository; -use Pagarme\Core\Kernel\Repositories\OrderRepository; -use Pagarme\Core\Kernel\ValueObjects\Id\OrderId; - -class View extends \Magento\Backend\Block\Template implements \Magento\Backend\Block\Widget\Tab\TabInterface +class View extends Template implements TabInterface { + // @codingStandardsIgnoreLine protected $_template = 'tab/view/order_charge.phtml'; /** - * View constructor. - * @param \Magento\Backend\Block\Template\Context $context - * @param \Magento\Framework\Registry $registry + * @var Registry + */ + private $registry; + + /** + * @var HtmlTableHelper + */ + private $htmlTableHelper; + + /** + * @var ChargeService + */ + private $chargeService; + + /** + * @param Context $context + * @param Registry $registry + * @param HtmlTableHelper $htmlTableHelper + * @param ChargeService $chargeService * @param array $data + * @throws Exception */ public function __construct( - \Magento\Backend\Block\Template\Context $context, - \Magento\Framework\Registry $registry, - array $data = [] + Context $context, + Registry $registry, + HtmlTableHelper $htmlTableHelper, + ChargeService $chargeService, + array $data = [] ) { Magento2CoreSetup::bootstrap(); - $this->_coreRegistry = $registry; + $this->registry = $registry; + $this->htmlTableHelper = $htmlTableHelper; + $this->chargeService = $chargeService; parent::__construct($context, $data); } /** - * Retrieve order model instance - * - * @return \Magento\Sales\Model\Order + * @return string + * @throws InvalidParamException */ - public function getOrder() + public function getChargesTableBody() { - return $this->_coreRegistry->registry('current_order'); + $tbody = ''; + + foreach ($this->getCharges() as $charge) { + $tbody .= '
- | - | - | - | - | + | = __('Charge ID') ?> | += __('Amount') ?> | += __('Paid Amount') ?> | += __('Canceled Amount') ?> | += __('Refunded Amount') ?> | += __('Status') ?> | - getCharges() as $charge) :?> - |
---|---|---|---|---|---|---|---|---|
getPagarmeId()->getValue();?> | -currency($charge->getAmount() / 100, true, false); ?> | -currency($charge->getPaidAmount() / 100, true, false);?> | -currency($charge->getCanceledAmount() / 100, true, false);?> | -currency($charge->getRefundedAmount() / 100, true, false);?> | -getStatus()->getStatus();?> | -- getCanceledAmount() <= 0) :?> - | - - | - -- - | -