Skip to content

Commit

Permalink
add Discount
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyraul committed Oct 25, 2017
1 parent 5fb0eb4 commit 7720d56
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 44 deletions.
62 changes: 31 additions & 31 deletions Block/Extensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,37 @@ class Extensions extends \Magento\Config\Block\System\Config\Form\Fieldset
* @var \Magento\Framework\Module\ModuleListInterface
*/
protected $_moduleList;

/**
* @var \Magento\Framework\View\LayoutFactory
*/
protected $_layoutFactory;

/**
* @var \Magento\Framework\Module\Dir\Reader
*/
protected $_moduleReader;

/**
* @var DecoderInterface
*/
protected $_jsonDecoder;

/**
* @var \Magento\Framework\Filesystem\Driver\File
*/
protected $_filesystem;

/**
* @var \Mygento\Base\Helper\Module
*/
protected $_moduleHelper;

/**
* @var \Magento\Store\Api\Data\StoreInterface
*/
protected $_store;

/**
*
* @param \Magento\Backend\Block\Context $context
Expand Down Expand Up @@ -79,7 +79,7 @@ public function __construct(
array $data = []
) {
parent::__construct($context, $authSession, $jsHelper, $data);

$this->_moduleList = $moduleList;
$this->_layoutFactory = $layoutFactory;
$this->_moduleReader = $moduleReader;
Expand All @@ -89,7 +89,7 @@ public function __construct(
$this->_store = $store;
$this->_scopeConfig = $context->getScopeConfig();
}

/**
* Render fieldset html
*
Expand All @@ -99,15 +99,15 @@ public function __construct(
public function render(AbstractElement $element)
{
$html = $this->_getHeaderHtml($element);

$site = 'https://www.mygento.net';
$email = '[email protected]';

if ($this->_store->getLocaleCode() == 'ru_RU') {
$site = 'https://www.mygento.ru';
$email = '[email protected]';
}

$ticketUrl = "mailto:[email protected]";
$url = __(
'Purchased extensions support is available through '
Expand All @@ -127,7 +127,7 @@ public function render(AbstractElement $element)
);
$tender = __('Tender offer can be checked '
. '<a href="https://www.mygento.ru/oferta" target="_blank">here</a>');

$html .= '<table class="mygento-info" cellspacing="0" cellpading="0">'
. '<tr class="mygento-info-line">';
$html .= '<tr><td>' . __('Support') . ':</td>' .
Expand All @@ -142,12 +142,12 @@ public function render(AbstractElement $element)
$site . '/services'
) . '</td></tr><tr class="mygento-info-line"></tr>';
$html .= '</table>';

$modules = $this->_moduleList->getNames();

$dispatchResult = new \Magento\Framework\DataObject($modules);
$modules = $dispatchResult->toArray();

$html .= '<h2>' . __('Installed Extensions') . '</h2>';
$html .= '<ul class="mygento-mod-list">';
sort($modules);
Expand All @@ -157,32 +157,32 @@ public function render(AbstractElement $element)
) {
continue;
}

$html .= $this->_getFieldHtml($element, $moduleName);
}
$html .= '</ul>';

$html .= $this->_getFooterHtml($element);

return $html;
}

/**
* @return \Magento\Framework\View\Element\BlockInterface
*/
protected function _getFieldRenderer()
{
if (empty($this->_fieldRenderer)) {
$layout = $this->_layoutFactory->create();

$this->_fieldRenderer = $layout->createBlock(
\Magento\Config\Block\System\Config\Form\Field::class
'Magento\Config\Block\System\Config\Form\Field'
);
}

return $this->_fieldRenderer;
}

/**
* Read info about extension from composer json file
* @param $moduleCode
Expand All @@ -193,13 +193,13 @@ protected function _getModuleInfo($moduleCode)
{
$dir = $this->_moduleReader->getModuleDir('', $moduleCode);
$file = $dir . DIRECTORY_SEPARATOR . 'composer.json';

$string = $this->_filesystem->fileGetContents($file);
$json = $this->_jsonDecoder->decode($string);

return $json;
}

/**
* @param $fieldset
* @param $moduleCode
Expand All @@ -214,22 +214,22 @@ protected function _getFieldHtml($fieldset, $moduleCode)
) {
return '';
}

$currentVer = $module['version'];
$moduleName = $module['description'];
$status = '<span class="mygento-icon-success"></span>';

// in case if module output disabled
if ($this->_scopeConfig->getValue('advanced/modules_disable_output/' . $moduleCode)) {
$status = __('Output disabled');
}

$field = $fieldset->addField($moduleCode, 'label', [
'name' => 'dummy',
'label' => $moduleName,
'value' => $currentVer,
])->setRenderer($this->_getFieldRenderer());

return '<li>' . $status . $field->toHtml() . '</li>';
}
}
12 changes: 6 additions & 6 deletions Helper/Discount.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public function __construct(\Mygento\Base\Helper\Data $baseHelper)
$this->generalHelper = $baseHelper;
}

/** Returns all items of the entity (order|invoice|creditmemo)
* with properly calculated discount and properly calculated Sum
*
* @param $entity Mage_Sales_Model_Order|Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo
/**
* @param mixed $entity
* @param string $taxValue
* @param string $taxAttributeCode Set it if info about tax is stored in product in certain attr
* @param string $taxAttributeCode
* @param string $shippingTaxValue
* @return array with calculated items and sum
* @param bool $spreadDiscOnAllUnits
* @return array|void
* @throws \Exception
*/
public function getRecalculated(
$entity,
Expand Down
1 change: 1 addition & 0 deletions Ui/Component/Listing/Actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function __construct(
$this->urlBuilder = $urlBuilder;
}


/**
* Prepare Data Source
*
Expand Down
9 changes: 3 additions & 6 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@
* @package Mygento_Base
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="mygento" translate="label" sortOrder="999999" class="mygento-tab">
<label>Mygento Extensions</label>
</tab>
<section id="mygento_base" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1"
showInStore="1">
<section id="mygento_base" translate="label" type="text" sortOrder="100" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Extensions and Support</label>
<tab>mygento</tab>
<resource>Mygento_Base::config</resource>
<group id="extensions" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="0"
showInStore="0">
<group id="extensions" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Extensions and Support</label>
<frontend_model>Mygento\Base\Block\Extensions</frontend_model>
</group>
Expand Down
15 changes: 14 additions & 1 deletion i18n/ru_RU.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,17 @@
"You can check all providable services on <a href=""%1"" target=""_blank"">our website</a>.","Со списком предоставляемых услуг вы можете ознакомиться <a href=""%1"" target=""_blank"">на нашем сайте</a>."
"You can hire us for any Magento extension customization and development.<br/>Write us to %1","Вы можете нанять нашу команду для любых работ с модулями Magento.<br/>Пишите нам на %1"
"Tender offer can be checked <a href=""https://www.mygento.ru/oferta"" target=""_blank"">here</a>","Ознакомиться с публичной офертой можно <a href=""https://www.mygento.ru/oferta"" target=""_blank"">здесь</a>"
"No usage","Не использовать"
"No usage","Не использовать"
"VAT Free","НДС не облагается"
"VAT18","НДС 18%"
"VAT10","НДС 10%"
"VAT0","НДС 0%"
"VAT110","расчетный НДС 10/110"
"VAT118","расчетный НДС 18/118"
"Tax","Отправка 54-ФЗ"
"Shipping Tax","Налог на доставку"
"Same tax for all products","Единая ставка НДС на все товары"
"Product Tax Attribute","Атрибут налога в товаре"
"Tax value for all products","Ставка НДС для всех товаров"
"Default Shipping name in receipt","Использовать системное название доставки в чеке"
"Shipping name in receipt","Наименование доставки в чеке"

0 comments on commit 7720d56

Please sign in to comment.