Skip to content

Commit

Permalink
Version 1.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Kountret Spyrou committed Jun 18, 2021
1 parent e0dfeb4 commit 15cf482
Show file tree
Hide file tree
Showing 109 changed files with 5,101 additions and 1,035 deletions.
23 changes: 23 additions & 0 deletions Block/Adminhtml/DocumentType/Edit/BackButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Mv\Megaventory\Block\Adminhtml\DocumentType\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class BackButton extends GenericButton implements ButtonProviderInterface
{
public function getButtonData()
{
return [
'label' => __('Back'),
'on_click' => sprintf("location.href = '%s';", $this->getBackUrl()),
'class' => 'back',
'sort_order' => 10
];
}

public function getBackUrl()
{
return $this->getUrl('*/*/');
}
}
36 changes: 36 additions & 0 deletions Block/Adminhtml/DocumentType/Edit/GenericButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Mv\Megaventory\Block\Adminhtml\DocumentType\Edit;

class GenericButton
{
/**
* Url Builder
*
* @var \Magento\Framework\UrlInterface
*/
protected $urlBuilder;

/**
* Constructor
*
* @param \Magento\Backend\Block\Widget\Context $context
*/
public function __construct(
\Magento\Backend\Block\Widget\Context $context
) {
$this->urlBuilder = $context->getUrlBuilder();
}

/**
* Generate url by route and parameters
*
* @param string $route
* @param array $params
* @return string
*/
public function getUrl($route = '', $params = [])
{
return $this->urlBuilder->getUrl($route, $params);
}
}
21 changes: 21 additions & 0 deletions Block/Adminhtml/DocumentType/Edit/SaveButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Mv\Megaventory\Block\Adminhtml\DocumentType\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class SaveButton extends GenericButton implements ButtonProviderInterface
{
public function getButtonData()
{
return [
'label' => __('Save'),
'data_attribute' => [
'mage-init' => ['button' => ['event' => 'save']],
'form-role' => 'save',
],
'sort_order' => 90,
'class' => 'save primary'
];
}
}
45 changes: 45 additions & 0 deletions Block/Adminhtml/DocumentType/GenericButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Mv\Megaventory\Block\Adminhtml\DocumentType;

use Magento\Framework\App\Config\ScopeConfigInterface;

class GenericButton
{
/**
* Url Builder
*
* @var \Magento\Framework\UrlInterface
*/
protected $urlBuilder;

protected $scopeConfig;

/**
* Constructor
*
* @param \Magento\Backend\Block\Widget\Context $context
*/
public function __construct(
\Magento\Backend\Block\Widget\Context $context
) {
$this->scopeConfig = $context->getScopeConfig();
$this->urlBuilder = $context->getUrlBuilder();
}

/**
* Generate url by route and parameters
*
* @param string $route
* @param array $params
* @return string
*/
public function getUrl($route = '', $params = [])
{
return $this->urlBuilder->getUrl($route, $params);
}

public function shouldDisplayButton(){
return (null !== $this->scopeConfig->getValue('megaventory/general/synctimestamp'));
}
}
23 changes: 23 additions & 0 deletions Block/Adminhtml/InventoryAdjustment/Edit/BackButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Mv\Megaventory\Block\Adminhtml\InventoryAdjustment\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class BackButton extends GenericButton implements ButtonProviderInterface
{
public function getButtonData()
{
return [
'label' => __('Back'),
'on_click' => sprintf("location.href = '%s';", $this->getBackUrl()),
'class' => 'back',
'sort_order' => 10
];
}

public function getBackUrl()
{
return $this->getUrl('*/index/index') . '#locations';
}
}
49 changes: 49 additions & 0 deletions Block/Adminhtml/InventoryAdjustment/Edit/GenericButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

namespace Mv\Megaventory\Block\Adminhtml\InventoryAdjustment\Edit;

use Magento\Framework\App\RequestInterface;

class GenericButton
{
/**
* Url Builder
*
* @var \Magento\Framework\UrlInterface
*/
protected $urlBuilder;


protected $request;

/**
* Constructor
*
* @param \Magento\Backend\Block\Widget\Context $context
*/
public function __construct(
\Magento\Backend\Block\Widget\Context $context,
RequestInterface $requestInterface
) {
$this->urlBuilder = $context->getUrlBuilder();
$this->request = $requestInterface;
}

/**
* Generate url by route and parameters
*
* @param string $route
* @param array $params
* @return string
*/
public function getUrl($route = '', $params = [])
{
return $this->urlBuilder->getUrl($route, $params);
}

public function getId()
{
$id = $this->request->getParam('id',null);
return $id;
}
}
21 changes: 21 additions & 0 deletions Block/Adminhtml/InventoryAdjustment/Edit/SaveButton.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Mv\Megaventory\Block\Adminhtml\InventoryAdjustment\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class SaveButton extends GenericButton implements ButtonProviderInterface
{
public function getButtonData()
{
return [
'label' => __('Save'),
'data_attribute' => [
'mage-init' => ['button' => ['event' => 'save']],
'form-role' => 'save',
],
'sort_order' => 90,
'class' => 'save primary'
];
}
}
50 changes: 50 additions & 0 deletions Block/Adminhtml/InventoryAdjustment/Edit/SourceRemove.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

namespace Mv\Megaventory\Block\Adminhtml\InventoryAdjustment\Edit;

use Magento\Framework\App\RequestInterface;
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;

class SourceRemove extends GenericButton implements ButtonProviderInterface
{
protected $_inventoryResource;
protected $_inventoryFactory;

public function __construct(
\Magento\Backend\Block\Widget\Context $context,
RequestInterface $requestInterface,
\Mv\Megaventory\Model\InventoriesFactory $inventoriesFactory,
\Mv\Megaventory\Model\ResourceModel\Inventories $inventoriesResource
) {
parent::__construct($context, $requestInterface);
$this->_inventoryFactory = $inventoriesFactory;
$this->_inventoryResource = $inventoriesResource;
}

public function getButtonData()
{
$data = [];
if ($this->getId() && $this->shouldDisplay()) {
$data = [
'label' => __('Remove Inventory Source Association'),
'class' => 'action-secondary',
'on_click' => 'deleteConfirm(\''
. __('This will also disable this inventory location until an inventory source is assigned again. Are you sure?')
. '\', \'' . $this->getRemovalUrl() . '\')',
'sort_order' => 20,
];
}
return $data;
}

public function getRemovalUrl()
{
return $this->getUrl('megaventory/inventory/unassigninventorysource', ['id' => $this->getId()]);
}

private function shouldDisplay(){
$inventory = $this->_inventoryFactory->create();
$this->_inventoryResource->load($inventory, $this->getId());
return ($inventory->getStockSourceCode() !== null);
}
}
7 changes: 7 additions & 0 deletions Block/Adminhtml/LogHeader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

namespace Mv\Megaventory\Block\Adminhtml;

class LogHeader extends \Magento\Backend\Block\Template{
protected $_template = 'log_header.phtml';
}
10 changes: 10 additions & 0 deletions Block/Adminhtml/ProcessUpdates.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Mv\Megaventory\Block\Adminhtml;

class ProcessUpdates extends \Magento\Backend\Block\Template{
protected $_template = 'pull_updates.phtml';
public function getUpdateUrl(){
return $this->getUrl('megaventory/updates/process');
}
}
Loading

0 comments on commit 15cf482

Please sign in to comment.