Files
2017-11-14 15:04:59 +01:00

61 lines
1.8 KiB
PHP

<?php
namespace Wowow\Devis\Block\Adminhtml;
class ItemDevis extends \Magento\Backend\Block\Template
{
protected $_template = 'totals.phtml';
public function __construct(
\Magento\Backend\Block\Template\Context $context, array $data = []
) {
parent::__construct($context,$data);
}
protected function _toHtml() {
return parent::_toHtml();
}
public function getTotal($id)
{
$objectManager = $this->getObjectManager();
$devisModel = $objectManager->create('\Wowow\Devis\Model\ItemDevis');
$devisItemCollection = $devisModel->getCollection()->addFieldToFilter('devis_id',$id);
$total = 0;
foreach($devisItemCollection as $item){
$total += $item->getPrixUnit()*$item->getQty();
}
return $total;
}
public function getCustomer($id)
{
$objectManager = $this->getObjectManager();
$devisModel = $objectManager->create('\Wowow\Devis\Model\Devis');
$devis = $devisModel->load($id);
$customerId = $devis->getCustomerId();
$customerModel = $this->getObjectManager()->create('\Magento\Customer\Model\Customer');
return $customerModel->load($customerId);
}
public function getObjectManager()
{
return \Magento\Framework\App\ObjectManager::getInstance();
}
public function getAdresse($id)
{
$customer = $this->getCustomer($id);
return $customer->getAddresses();
}
public function getCountryHtml($countryCode)
{
$objectManager = $this->getObjectManager();
$countryModel = $objectManager->create('\Magento\Directory\Model\CountryFactory');
$country = $countryModel->create()->loadByCode($countryCode);
return $country->getName();
}
}