diff --git a/Api/Data/Staff/RoleInterface.php b/Api/Data/Staff/RoleInterface.php index d95e223..8ce884f 100644 --- a/Api/Data/Staff/RoleInterface.php +++ b/Api/Data/Staff/RoleInterface.php @@ -96,5 +96,4 @@ public function getMaximumDiscountPercent(); * @return $this */ public function setMaximumDiscountPercent($discount); - } diff --git a/Api/Event/DispatchServiceInterface.php b/Api/Event/DispatchServiceInterface.php index a9fb00e..bf3852a 100644 --- a/Api/Event/DispatchServiceInterface.php +++ b/Api/Event/DispatchServiceInterface.php @@ -2,7 +2,8 @@ namespace Magestore\Appadmin\Api\Event; -interface DispatchServiceInterface { +interface DispatchServiceInterface +{ const EVENT_NAME_FORCE_SIGN_OUT = 'magestore_webpos_force_sign_out'; const EVENT_NAME_FORCE_CHANGE_POS = 'magestore_webpos_force_change_pos'; @@ -28,4 +29,4 @@ public function dispatchEventForceSignOut($staffId, $posId = null); * @return bool */ public function dispatchEventForceChangePos($staffId, $posId); -} \ No newline at end of file +} diff --git a/Api/Staff/RuleRepositoryInterface.php b/Api/Staff/RuleRepositoryInterface.php index 81f2045..0a0f9f3 100644 --- a/Api/Staff/RuleRepositoryInterface.php +++ b/Api/Staff/RuleRepositoryInterface.php @@ -14,4 +14,4 @@ interface RuleRepositoryInterface * @return bool */ public function isAllowPermission($aclResource, $staffId); -} \ No newline at end of file +} diff --git a/Api/Staff/StaffRepositoryInterface.php b/Api/Staff/StaffRepositoryInterface.php index 4f375ab..4c3d94a 100644 --- a/Api/Staff/StaffRepositoryInterface.php +++ b/Api/Staff/StaffRepositoryInterface.php @@ -68,5 +68,4 @@ public function deleteById($staffId); * @return \Magestore\Appadmin\Api\Data\Staff\StaffInterface[] */ public function getAllStaff(); - } diff --git a/Block/Adminhtml/Staff/Role/Edit.php b/Block/Adminhtml/Staff/Role/Edit.php index 1a86e46..72a25a7 100644 --- a/Block/Adminhtml/Staff/Role/Edit.php +++ b/Block/Adminhtml/Staff/Role/Edit.php @@ -5,6 +5,7 @@ */ namespace Magestore\Appadmin\Block\Adminhtml\Staff\Role; + /** * Class Edit * @package Magestore\Appadmin\Block\Adminhtml\Staff\Role @@ -46,16 +47,15 @@ protected function _construct() $this->buttonList->update('delete', 'label', __('Delete')); $this->buttonList->add( 'saveandcontinue', - array( + [ 'label' => __('Save and Continue Edit'), 'class' => 'save', - 'data_attribute' => array( - 'mage-init' => array('button' => array('event' => 'saveAndContinueEdit', 'target' => '#edit_form')) - ) - ), + 'data_attribute' => [ + 'mage-init' => ['button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form']] + ] + ], -100 ); - } /** diff --git a/Block/Adminhtml/Staff/Role/Edit/Form.php b/Block/Adminhtml/Staff/Role/Edit/Form.php index 9eb6b20..7dc624b 100644 --- a/Block/Adminhtml/Staff/Role/Edit/Form.php +++ b/Block/Adminhtml/Staff/Role/Edit/Form.php @@ -19,14 +19,14 @@ class Form extends \Magento\Backend\Block\Widget\Form\Generic protected function _prepareForm() { $form = $this->_formFactory->create( - array( - 'data' => array( + [ + 'data' => [ 'id' => 'edit_form', 'action' => $this->getUrl('*/*/save', ['store' => $this->getRequest()->getParam('store')]), 'method' => 'post', 'enctype' => 'multipart/form-data' - ) - ) + ] + ] ); $form->setUseContainer(true); $this->setForm($form); diff --git a/Block/Adminhtml/Staff/Role/Edit/Tab/Form.php b/Block/Adminhtml/Staff/Role/Edit/Tab/Form.php index 0ccb07b..2b55a49 100644 --- a/Block/Adminhtml/Staff/Role/Edit/Tab/Form.php +++ b/Block/Adminhtml/Staff/Role/Edit/Tab/Form.php @@ -10,8 +10,7 @@ * Class Form * @package Magestore\Giftwrap\Block\Adminhtml\Staff\Role\Edit\Tab */ -class Form extends \Magento\Backend\Block\Widget\Form\Generic - implements \Magento\Backend\Block\Widget\Tab\TabInterface +class Form extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface { protected $_objectManager; @@ -21,9 +20,8 @@ public function __construct( \Magento\Framework\Registry $registry, \Magento\Framework\Data\FormFactory $formFactory, \Magento\Framework\ObjectManagerInterface $objectManager, - array $data = array() - ) - { + array $data = [] + ) { $this->_objectManager = $objectManager; parent::__construct($context, $registry, $formFactory, $data); } @@ -31,7 +29,8 @@ public function __construct( /** * @throws \Magento\Framework\Exception\LocalizedException */ - protected function _prepareLayout() { + protected function _prepareLayout() + { $this->getLayout()->getBlock('page.title')->setPageTitle($this->getPageTitle()); } @@ -47,28 +46,28 @@ protected function _prepareForm() $form = $this->_formFactory->create(); $form->setHtmlIdPrefix('page_'); - $fieldset = $form->addFieldset('base_fieldset', array('legend' => __('Role Information'))); + $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Role Information')]); if ($model->getRoleId()) { - $fieldset->addField('role_id', 'hidden', array('name' => 'role_id','value' => $model->getRoleId())); + $fieldset->addField('role_id', 'hidden', ['name' => 'role_id','value' => $model->getRoleId()]); } - $fieldset->addField('name', 'text', array( + $fieldset->addField('name', 'text', [ 'label' => __('Role Name'), 'class' => 'required-entry', 'required' => true, 'maxlength' => 127, 'name' => 'name', 'disabled' => false, - )); + ]); - $fieldset->addField('description', 'textarea', array( + $fieldset->addField('description', 'textarea', [ 'label' => __('Description'), 'name' => 'description', 'maxlength' => 255, 'disabled' => false, - )); + ]); $form->setValues($model->getData()); $this->setForm($form); @@ -78,16 +77,20 @@ protected function _prepareForm() /** * @return mixed */ - public function getRole() { + public function getRole() + { return $this->_coreRegistry->registry('current_role'); } /** * @return \Magento\Framework\Phrase */ - public function getPageTitle() { - return $this->getRole()->getId() ? __("Edit Role %1", - $this->escapeHtml($this->getRole()->getDisplayName())) : __('New Role'); + public function getPageTitle() + { + return $this->getRole()->getId() ? __( + "Edit Role %1", + $this->escapeHtml($this->getRole()->getDisplayName()) + ) : __('New Role'); } /** @@ -122,6 +125,4 @@ public function isHidden() { return false; } - - } diff --git a/Block/Adminhtml/Staff/Role/Edit/Tab/Permission.php b/Block/Adminhtml/Staff/Role/Edit/Tab/Permission.php index 73e5aef..ccdc363 100644 --- a/Block/Adminhtml/Staff/Role/Edit/Tab/Permission.php +++ b/Block/Adminhtml/Staff/Role/Edit/Tab/Permission.php @@ -244,4 +244,3 @@ function ($node) { return isset($configResource['children']) ? $configResource['children'] : []; } } - diff --git a/Block/Adminhtml/Staff/Role/Edit/Tab/Permission/Discount.php b/Block/Adminhtml/Staff/Role/Edit/Tab/Permission/Discount.php index 19ce1c1..bda545e 100644 --- a/Block/Adminhtml/Staff/Role/Edit/Tab/Permission/Discount.php +++ b/Block/Adminhtml/Staff/Role/Edit/Tab/Permission/Discount.php @@ -27,7 +27,8 @@ public function _construct() * Get discount value * @return float */ - public function getMaxDiscountPercent(){ + public function getMaxDiscountPercent() + { $rid = $this->_request->getParam('id', false); return $this->_webposAclRetriever->getMaxDiscountPercentByRole($rid); } diff --git a/Block/Adminhtml/Staff/Role/Edit/Tab/Staff.php b/Block/Adminhtml/Staff/Role/Edit/Tab/Staff.php index f9a93c2..dc84eb9 100644 --- a/Block/Adminhtml/Staff/Role/Edit/Tab/Staff.php +++ b/Block/Adminhtml/Staff/Role/Edit/Tab/Staff.php @@ -5,11 +5,13 @@ */ namespace Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit\Tab; + /** * Class Staff * @package Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit\Tab */ -class Staff extends \Magento\Backend\Block\Widget\Grid\Extended { +class Staff extends \Magento\Backend\Block\Widget\Grid\Extended +{ /** * @var \Magestore\Appadmin\Model\ResourceModel\Staff\Staff\CollectionFactory @@ -27,9 +29,8 @@ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Backend\Helper\Data $backendHelper, \Magestore\Appadmin\Model\ResourceModel\Staff\Staff\CollectionFactory $staffCollectionFactory, - array $data = array() - ) - { + array $data = [] + ) { $this->_staffCollectionFactory = $staffCollectionFactory; parent::__construct($context, $backendHelper, $data); } @@ -37,7 +38,8 @@ public function __construct( /** * */ - public function _construct() { + public function _construct() + { parent::_construct(); $this->setId('staff_grid'); $this->setDefaultSort('staff_id'); @@ -45,14 +47,15 @@ public function _construct() { $this->setSaveParametersInSession(false); $this->setUseAjax(true); if ($this->getRequest()->getParam('id')) { - $this->setDefaultFilter(array('in_staff' => 1)); + $this->setDefaultFilter(['in_staff' => 1]); } } /** * @return $this */ - protected function _prepareCollection() { + protected function _prepareCollection() + { $collection = $this->_staffCollectionFactory->create(); $roleId = (int)$this->getRequest()->getParam('id'); $collection->addFieldToFilter('role_id', $roleId); @@ -65,39 +68,40 @@ protected function _prepareCollection() { * @return $this * @throws \Exception */ - protected function _prepareColumns() { - $this->addColumn('staff_id', array( + protected function _prepareColumns() + { + $this->addColumn('staff_id', [ 'header' => __('ID'), 'width' => '50px', 'index' => 'staff_id', 'type' => 'number', - )); + ]); - $this->addColumn('username', array( + $this->addColumn('username', [ 'header' => __('User Name'), 'index' => 'username' - )); + ]); - $this->addColumn('staff_name', array( + $this->addColumn('staff_name', [ 'header' => __('Display Name'), 'index' => 'name' - )); + ]); - $this->addColumn('email', array( + $this->addColumn('email', [ 'header' => __('Email'), 'index' => 'email' - )); + ]); - $this->addColumn('status', array( + $this->addColumn('status', [ 'header' => __('Status'), 'index' => 'status', 'type' => 'options', - 'options' => array( + 'options' => [ 1 => 'Enable', 2 => 'Disable', - ), + ], - )); + ]); return parent::_prepareColumns(); } @@ -105,16 +109,18 @@ protected function _prepareColumns() { /** * @return mixed|string */ - public function getGridUrl() { + public function getGridUrl() + { return $this->getData('grid_url') ? $this->getData('grid_url') : - $this->getUrl('*/*/staffgrid', array('_current' => true, 'id' => $this->getRequest()->getParam('id'))); + $this->getUrl('*/*/staffgrid', ['_current' => true, 'id' => $this->getRequest()->getParam('id')]); } /** * @param \Magento\Framework\DataObject $row * @return string */ - public function getRowUrl($row) { + public function getRowUrl($row) + { return ''; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Staff/Role/Edit/Tabs.php b/Block/Adminhtml/Staff/Role/Edit/Tabs.php index 82f33d2..d4ccb30 100644 --- a/Block/Adminhtml/Staff/Role/Edit/Tabs.php +++ b/Block/Adminhtml/Staff/Role/Edit/Tabs.php @@ -5,6 +5,7 @@ */ namespace Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit; + /** * Class Tabs * @package Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit @@ -41,7 +42,7 @@ protected function _beforeToHtml() ] ); $permissionBlock = $this->getLayout()->createBlock('Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit\Tab\Permission'); - $permissionBlock->addChild('block_discount_percent','Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit\Tab\Permission\Discount'); + $permissionBlock->addChild('block_discount_percent', 'Magestore\Appadmin\Block\Adminhtml\Staff\Role\Edit\Tab\Permission\Discount'); $this->addTab( 'webpos_permission', [ @@ -58,11 +59,10 @@ protected function _beforeToHtml() 'label' => __('Staff List'), 'title' => __('Staff List'), 'class' => 'ajax', - 'url' => $this->getUrl('*/*/staff', array('_current' => true, 'id' => $this->getRequest()->getParam('id'))) + 'url' => $this->getUrl('*/*/staff', ['_current' => true, 'id' => $this->getRequest()->getParam('id')]) ] ); return parent::_beforeToHtml(); } - } diff --git a/Block/Adminhtml/Staff/Staff/Edit/Buttons/Back.php b/Block/Adminhtml/Staff/Staff/Edit/Buttons/Back.php index d961dd2..5c21dec 100644 --- a/Block/Adminhtml/Staff/Staff/Edit/Buttons/Back.php +++ b/Block/Adminhtml/Staff/Staff/Edit/Buttons/Back.php @@ -6,7 +6,8 @@ namespace Magestore\Appadmin\Block\Adminhtml\Staff\Staff\Edit\Buttons; -class Back extends Generic { +class Back extends Generic +{ /** * @return array */ @@ -19,4 +20,4 @@ public function getButtonData() 'sort_order' => 10 ]; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Staff/Staff/Edit/Buttons/Delete.php b/Block/Adminhtml/Staff/Staff/Edit/Buttons/Delete.php index 0807bd9..5be7c24 100644 --- a/Block/Adminhtml/Staff/Staff/Edit/Buttons/Delete.php +++ b/Block/Adminhtml/Staff/Staff/Edit/Buttons/Delete.php @@ -6,7 +6,8 @@ namespace Magestore\Appadmin\Block\Adminhtml\Staff\Staff\Edit\Buttons; -class Delete extends Generic { +class Delete extends Generic +{ /** * @return array */ @@ -16,7 +17,7 @@ public function getButtonData() return []; } - if(!$this->authorization->isAllowed('Magestore_Appadmin::manageStaffs')) { + if (!$this->authorization->isAllowed('Magestore_Appadmin::manageStaffs')) { return []; } @@ -32,4 +33,4 @@ public function getButtonData() 'sort_order' => 20 ]; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Staff/Staff/Edit/Buttons/Reset.php b/Block/Adminhtml/Staff/Staff/Edit/Buttons/Reset.php index e3a06f4..0902d46 100644 --- a/Block/Adminhtml/Staff/Staff/Edit/Buttons/Reset.php +++ b/Block/Adminhtml/Staff/Staff/Edit/Buttons/Reset.php @@ -6,7 +6,8 @@ namespace Magestore\Appadmin\Block\Adminhtml\Staff\Staff\Edit\Buttons; -class Reset extends Generic { +class Reset extends Generic +{ /** * @return array */ @@ -18,4 +19,4 @@ public function getButtonData() 'sort_order' => 15 ]; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Staff/Staff/Edit/Buttons/Save.php b/Block/Adminhtml/Staff/Staff/Edit/Buttons/Save.php index 09299fb..14bf669 100644 --- a/Block/Adminhtml/Staff/Staff/Edit/Buttons/Save.php +++ b/Block/Adminhtml/Staff/Staff/Edit/Buttons/Save.php @@ -5,13 +5,15 @@ */ namespace Magestore\Appadmin\Block\Adminhtml\Staff\Staff\Edit\Buttons; -class Save extends Generic { + +class Save extends Generic +{ /** * @return array */ public function getButtonData() { - if(!$this->authorization->isAllowed('Magestore_Appadmin::manageStaffs')) { + if (!$this->authorization->isAllowed('Magestore_Appadmin::manageStaffs')) { return []; } @@ -36,4 +38,4 @@ public function getButtonData() 'sort_order' => 40, ]; } -} \ No newline at end of file +} diff --git a/Block/Adminhtml/Staff/Staff/Edit/Buttons/SaveAndContinue.php b/Block/Adminhtml/Staff/Staff/Edit/Buttons/SaveAndContinue.php index ab1631d..98383f8 100644 --- a/Block/Adminhtml/Staff/Staff/Edit/Buttons/SaveAndContinue.php +++ b/Block/Adminhtml/Staff/Staff/Edit/Buttons/SaveAndContinue.php @@ -6,13 +6,14 @@ namespace Magestore\Appadmin\Block\Adminhtml\Staff\Staff\Edit\Buttons; -class SaveAndContinue extends Generic { +class SaveAndContinue extends Generic +{ /** * @return array */ public function getButtonData() { - if(!$this->authorization->isAllowed('Magestore_Appadmin::staffs')) { + if (!$this->authorization->isAllowed('Magestore_Appadmin::staffs')) { return []; } @@ -41,4 +42,4 @@ public function getButtonData() ], ]; } -} \ No newline at end of file +} diff --git a/Controller/Adminhtml/Staff/Role.php b/Controller/Adminhtml/Staff/Role.php index 09b15eb..288bd91 100644 --- a/Controller/Adminhtml/Staff/Role.php +++ b/Controller/Adminhtml/Staff/Role.php @@ -6,6 +6,7 @@ */ namespace Magestore\Appadmin\Controller\Adminhtml\Staff; + /** * class \Magestore\Appadmin\Controller\Adminhtml\Staff\Role * @@ -117,5 +118,4 @@ protected function _isAllowed() { return $this->_authorization->isAllowed('Magestore_Appadmin::roles'); } - -} \ No newline at end of file +} diff --git a/Controller/Adminhtml/Staff/Role/Edit.php b/Controller/Adminhtml/Staff/Role/Edit.php index 1f3e803..77f89f9 100644 --- a/Controller/Adminhtml/Staff/Role/Edit.php +++ b/Controller/Adminhtml/Staff/Role/Edit.php @@ -54,5 +54,4 @@ public function execute() $resultPage->getConfig()->getTitle()->prepend($pageTitle); return $resultPage; } - } diff --git a/Controller/Adminhtml/Staff/Role/Index.php b/Controller/Adminhtml/Staff/Role/Index.php index 6625f4e..5a654fa 100644 --- a/Controller/Adminhtml/Staff/Role/Index.php +++ b/Controller/Adminhtml/Staff/Role/Index.php @@ -6,6 +6,7 @@ */ namespace Magestore\Appadmin\Controller\Adminhtml\Staff\Role; + /** * class \Magestore\Appadmin\Controller\Adminhtml\Staff\Role\Index * @@ -31,4 +32,4 @@ public function execute() $resultPage->getConfig()->getTitle()->prepend(__('Role')); return $resultPage; } -} \ No newline at end of file +} diff --git a/Controller/Adminhtml/Staff/Role/InlineEdit.php b/Controller/Adminhtml/Staff/Role/InlineEdit.php index 6761739..70528e4 100644 --- a/Controller/Adminhtml/Staff/Role/InlineEdit.php +++ b/Controller/Adminhtml/Staff/Role/InlineEdit.php @@ -57,8 +57,7 @@ public function __construct( \Magestore\Appadmin\Api\Data\Staff\RoleInterfaceFactory $roleInterfaceFactory, \Magestore\Appadmin\Api\Staff\RoleRepositoryInterface $roleRepository, \Psr\Log\LoggerInterface $logger - ) - { + ) { $this->resultJsonFactory = $resultJsonFactory; $this->dataObjectHelper = $dataObjectHelper; $this->roleInterfaceFactory = $roleInterfaceFactory; @@ -125,5 +124,4 @@ protected function isErrorExists() { return (bool)$this->getMessageManager()->getMessages(true)->getCount(); } - } diff --git a/Controller/Adminhtml/Staff/Role/MassDelete.php b/Controller/Adminhtml/Staff/Role/MassDelete.php index 0a4a96f..1c615a1 100644 --- a/Controller/Adminhtml/Staff/Role/MassDelete.php +++ b/Controller/Adminhtml/Staff/Role/MassDelete.php @@ -66,5 +66,4 @@ protected function massAction(Collection $collection) return $resultRedirect; } - } diff --git a/Controller/Adminhtml/Staff/Role/Save.php b/Controller/Adminhtml/Staff/Role/Save.php index 948fe13..0c63760 100644 --- a/Controller/Adminhtml/Staff/Role/Save.php +++ b/Controller/Adminhtml/Staff/Role/Save.php @@ -48,9 +48,9 @@ public function execute() try { $role->save(); $roleId = $role->getRoleId(); - $resources = array(); + $resources = []; if (isset($data['all']) && $data['all']) { - $resources = array('Magestore_Appadmin::all'); + $resources = ['Magestore_Appadmin::all']; } else { if (isset($data['resource'])) { $resources = $data['resource']; @@ -67,7 +67,7 @@ public function execute() // check if resource change and not have permission to use pos $checkPermissionCheckout = false; foreach ($resources as $resource) { - if(in_array($resource, ['Magestore_Appadmin::all', 'Magestore_Webpos::manage_pos'])) { + if (in_array($resource, ['Magestore_Appadmin::all', 'Magestore_Webpos::manage_pos'])) { $checkPermissionCheckout = true; } $authorizeRuleCollection = $this->_objectManager->create('Magestore\Appadmin\Model\Staff\AuthorizationRule'); @@ -77,7 +77,7 @@ public function execute() } // dispatch event to force sign out - if(!$checkPermissionCheckout) { + if (!$checkPermissionCheckout) { $staffs = $this->staffRepository->getByRoleId($role->getRoleId()); foreach ($staffs as $staff) { $this->dispatchService->dispatchEventForceSignOut($staff->getStaffId()); @@ -100,6 +100,5 @@ public function execute() return $resultRedirect->setPath('*/*/edit', ['id' => $roleId]); } return $resultRedirect->setPath('*/*/'); - } } diff --git a/Controller/Adminhtml/Staff/Staff.php b/Controller/Adminhtml/Staff/Staff.php index 9cc4d7f..f0ba683 100644 --- a/Controller/Adminhtml/Staff/Staff.php +++ b/Controller/Adminhtml/Staff/Staff.php @@ -5,6 +5,7 @@ * See COPYING.txt for license details. */ namespace Magestore\Appadmin\Controller\Adminhtml\Staff; + /** * class \Magestore\Webpos\Controller\Adminhtml\Staff\Staff * @@ -73,4 +74,4 @@ protected function _isAllowed() { return $this->_authorization->isAllowed('Magestore_Appadmin::manageStaffs'); } -} \ No newline at end of file +} diff --git a/Controller/Adminhtml/Staff/Staff/Edit.php b/Controller/Adminhtml/Staff/Staff/Edit.php index 68eb8ee..d86de51 100644 --- a/Controller/Adminhtml/Staff/Staff/Edit.php +++ b/Controller/Adminhtml/Staff/Staff/Edit.php @@ -43,5 +43,4 @@ public function execute() $resultPage->getConfig()->getTitle()->prepend($pageTitle); return $resultPage; } - } diff --git a/Controller/Adminhtml/Staff/Staff/Index.php b/Controller/Adminhtml/Staff/Staff/Index.php index e2a42c1..cb67827 100644 --- a/Controller/Adminhtml/Staff/Staff/Index.php +++ b/Controller/Adminhtml/Staff/Staff/Index.php @@ -5,6 +5,7 @@ * See COPYING.txt for license details. */ namespace Magestore\Appadmin\Controller\Adminhtml\Staff\Staff; + /** * class \Magestore\Appadmin\Controller\Adminhtml\Staff\Staff\Index * @@ -31,4 +32,4 @@ public function execute() $resultPage->getConfig()->getTitle()->prepend(__('Staff')); return $resultPage; } -} \ No newline at end of file +} diff --git a/Controller/Adminhtml/Staff/Staff/InlineEdit.php b/Controller/Adminhtml/Staff/Staff/InlineEdit.php index 0eb7a51..4b26cc6 100644 --- a/Controller/Adminhtml/Staff/Staff/InlineEdit.php +++ b/Controller/Adminhtml/Staff/Staff/InlineEdit.php @@ -119,5 +119,4 @@ protected function isErrorExists() { return (bool)$this->getMessageManager()->getMessages(true)->getCount(); } - } diff --git a/Controller/Adminhtml/Staff/Staff/MassDelete.php b/Controller/Adminhtml/Staff/Staff/MassDelete.php index 8c4b24a..a628cea 100644 --- a/Controller/Adminhtml/Staff/Staff/MassDelete.php +++ b/Controller/Adminhtml/Staff/Staff/MassDelete.php @@ -67,5 +67,4 @@ protected function massAction(Collection $collection) return $resultRedirect; } - } diff --git a/Controller/Adminhtml/Staff/Staff/Save.php b/Controller/Adminhtml/Staff/Staff/Save.php index 929e0bc..b4fb043 100644 --- a/Controller/Adminhtml/Staff/Staff/Save.php +++ b/Controller/Adminhtml/Staff/Staff/Save.php @@ -47,7 +47,7 @@ public function execute() $username = $data['username']; if ($username) { $findUsernameExist = $this->staffInterfaceFactory->create()->load($username, 'username'); - if ($findUsernameExist->getId() && $findUsernameExist->getId() != $modelId) { + if ($findUsernameExist->getId() && $findUsernameExist->getId() != $modelId) { $this->messageManager->addErrorMessage(__('Username already exists.', $username)); return $resultRedirect->setPath('*/*/edit', ['id' => $this->getRequest()->getParam('staff_id')]); } @@ -83,7 +83,7 @@ public function execute() foreach ($result as $message) { $this->messageManager->addErrorMessage($message); } - $this->_redirect('*/*/edit', array('_current' => true)); + $this->_redirect('*/*/edit', ['_current' => true]); return $resultRedirect->setPath('*/*/'); } try { @@ -98,4 +98,4 @@ public function execute() } return $resultRedirect->setPath('*/*/'); } -} \ No newline at end of file +} diff --git a/Model/Event/DispatchService.php b/Model/Event/DispatchService.php index e1674ce..9758f51 100644 --- a/Model/Event/DispatchService.php +++ b/Model/Event/DispatchService.php @@ -30,7 +30,8 @@ public function __construct( /** * @inheritdoc */ - public function dispatchEventForceSignOut($staffId, $posId = null){ + public function dispatchEventForceSignOut($staffId, $posId = null) + { $this->eventManager->dispatch(self::EVENT_NAME_FORCE_SIGN_OUT, ['staff_id' => $staffId, 'pos_id' => $posId]); return true; } @@ -38,8 +39,9 @@ public function dispatchEventForceSignOut($staffId, $posId = null){ /** * @inheritdoc */ - public function dispatchEventForceChangePos($staffId, $posId){ + public function dispatchEventForceChangePos($staffId, $posId) + { $this->eventManager->dispatch(self::EVENT_NAME_FORCE_CHANGE_POS, ['staff_id' => $staffId, 'pos_id' => $posId]); return true; } -} \ No newline at end of file +} diff --git a/Model/ResourceModel/Staff/AuthorizationRule.php b/Model/ResourceModel/Staff/AuthorizationRule.php index 188e559..8d3b274 100644 --- a/Model/ResourceModel/Staff/AuthorizationRule.php +++ b/Model/ResourceModel/Staff/AuthorizationRule.php @@ -5,6 +5,7 @@ * See COPYING.txt for license details. */ namespace Magestore\Appadmin\Model\ResourceModel\Staff; + /** * class \Magestore\Appadmin\Model\ResourceModel\Staff\AuthorizationRule * @@ -27,4 +28,4 @@ protected function _construct() { $this->_init('webpos_authorization_rule', 'rule_id'); } -} \ No newline at end of file +} diff --git a/Model/ResourceModel/Staff/AuthorizationRule/Collection.php b/Model/ResourceModel/Staff/AuthorizationRule/Collection.php index e09fec5..31cafff 100644 --- a/Model/ResourceModel/Staff/AuthorizationRule/Collection.php +++ b/Model/ResourceModel/Staff/AuthorizationRule/Collection.php @@ -33,8 +33,10 @@ class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\Ab */ protected function _construct() { - $this->_init('Magestore\Appadmin\Model\Staff\AuthorizationRule', - 'Magestore\Appadmin\Model\ResourceModel\Staff\AuthorizationRule'); + $this->_init( + 'Magestore\Appadmin\Model\Staff\AuthorizationRule', + 'Magestore\Appadmin\Model\ResourceModel\Staff\AuthorizationRule' + ); } public function getByRoles($roleId) @@ -42,5 +44,4 @@ public function getByRoles($roleId) $this->addFieldToFilter('role_id', (int)$roleId); return $this; } - -} \ No newline at end of file +} diff --git a/Model/ResourceModel/Staff/Role.php b/Model/ResourceModel/Staff/Role.php index b98f7f6..df16339 100644 --- a/Model/ResourceModel/Staff/Role.php +++ b/Model/ResourceModel/Staff/Role.php @@ -8,6 +8,7 @@ namespace Magestore\Appadmin\Model\ResourceModel\Staff; use Magento\Framework\Exception\LocalizedException; + /** * Class Role * @package Magestore\Appadmin\Model\ResourceModel\Staff @@ -53,4 +54,4 @@ protected function checkRoleNameExist(\Magento\Framework\Model\AbstractModel $ob } return $this; } -} \ No newline at end of file +} diff --git a/Model/ResourceModel/Staff/Role/Collection.php b/Model/ResourceModel/Staff/Role/Collection.php index c1d66f9..72de244 100644 --- a/Model/ResourceModel/Staff/Role/Collection.php +++ b/Model/ResourceModel/Staff/Role/Collection.php @@ -28,4 +28,4 @@ protected function _construct() { $this->_init('Magestore\Appadmin\Model\Staff\Role', 'Magestore\Appadmin\Model\ResourceModel\Staff\Role'); } -} \ No newline at end of file +} diff --git a/Model/ResourceModel/Staff/Role/Grid/Collection.php b/Model/ResourceModel/Staff/Role/Grid/Collection.php index 15d3e09..aa8838f 100644 --- a/Model/ResourceModel/Staff/Role/Grid/Collection.php +++ b/Model/ResourceModel/Staff/Role/Grid/Collection.php @@ -19,4 +19,4 @@ class Collection extends SearchResult { -} \ No newline at end of file +} diff --git a/Model/ResourceModel/Staff/Staff.php b/Model/ResourceModel/Staff/Staff.php index 40437dc..73391b4 100644 --- a/Model/ResourceModel/Staff/Staff.php +++ b/Model/ResourceModel/Staff/Staff.php @@ -26,5 +26,4 @@ protected function _construct() { $this->_init('webpos_staff', 'staff_id'); } - } diff --git a/Model/ResourceModel/Staff/Staff/Collection.php b/Model/ResourceModel/Staff/Staff/Collection.php index 890f1ae..0ce3505 100644 --- a/Model/ResourceModel/Staff/Staff/Collection.php +++ b/Model/ResourceModel/Staff/Staff/Collection.php @@ -11,8 +11,7 @@ * Class Collection * @package Magestore\Appadmin\Model\ResourceModel\Staff\Staff */ -class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection - implements \Magestore\Appadmin\Api\Data\Staff\StaffSearchResultsInterface +class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection implements \Magestore\Appadmin\Api\Data\Staff\StaffSearchResultsInterface { /** * @@ -95,4 +94,4 @@ public function setItems(array $items = null) } return $this; } -} \ No newline at end of file +} diff --git a/Model/ResourceModel/Staff/Staff/Grid/Collection.php b/Model/ResourceModel/Staff/Staff/Grid/Collection.php index 9d91ec4..330de1f 100644 --- a/Model/ResourceModel/Staff/Staff/Grid/Collection.php +++ b/Model/ResourceModel/Staff/Staff/Grid/Collection.php @@ -62,8 +62,7 @@ public function __construct( \Magestore\Appadmin\Model\Source\Adminhtml\Role $role, \Magestore\Webpos\Model\Source\Adminhtml\Location $location, \Magento\Framework\App\RequestInterface $request - ) - { + ) { $this->role = $role; $this->location = $location; $this->request = $request; @@ -75,10 +74,10 @@ public function getData() { $data = parent::getData(); if (($this->request->getActionName() == 'gridToCsv') || ($this->request->getActionName() == 'gridToXml')) { - $options = array( + $options = [ self::STATUS_ENABLED => __('Enabled'), self::STATUS_DISABLED => __('Disabled') - ); + ]; $locationOptions = $this->location->getOptionArray(); $roleOptions = $this->role->getOptionArray(); foreach ($data as &$item) { @@ -87,7 +86,7 @@ public function getData() } if ($item['location_ids']) { $locationArray = explode(',', $item['location_ids']); - $locationNameArray = array(); + $locationNameArray = []; foreach ($locationArray as $locationId) { if (isset($locationOptions[$locationId])) { $locationName = $locationOptions[$locationId]; @@ -108,4 +107,4 @@ public function getData() } return $data; } -} \ No newline at end of file +} diff --git a/Model/Source/Adminhtml/Role.php b/Model/Source/Adminhtml/Role.php index 7349b8e..b13dc67 100644 --- a/Model/Source/Adminhtml/Role.php +++ b/Model/Source/Adminhtml/Role.php @@ -5,6 +5,7 @@ */ namespace Magestore\Appadmin\Model\Source\Adminhtml; + /** * Class Role * @package Magestore\Appadmin\Model\Source\Adminhtml @@ -22,7 +23,7 @@ class Role implements \Magento\Framework\Option\ArrayInterface */ public function __construct( \Magestore\Appadmin\Api\Staff\RoleRepositoryInterface $roleRepository - ){ + ) { $this->roleRepository = $roleRepository; } @@ -53,5 +54,4 @@ public function getOptionArray() } return $allRoleArray; } - -} \ No newline at end of file +} diff --git a/Model/Source/Adminhtml/Status.php b/Model/Source/Adminhtml/Status.php index 740cf59..616d03e 100644 --- a/Model/Source/Adminhtml/Status.php +++ b/Model/Source/Adminhtml/Status.php @@ -8,12 +8,12 @@ /** * class \Magestore\Appadmin\Model\Source\Adminhtml\Status - * + * * Status source model * Methods: * getOptionArray * toOptionArray - * + * * @category Magestore * @package Magestore_Appadmin * @module Appadmin @@ -48,5 +48,4 @@ public static function getOptionArray() { return [self::STATUS_ENABLED => __('Enabled'), self::STATUS_DISABLED => __('Disabled')]; } - -} \ No newline at end of file +} diff --git a/Model/Staff/AuthorizationRule.php b/Model/Staff/AuthorizationRule.php index a78012d..f8b7c53 100644 --- a/Model/Staff/AuthorizationRule.php +++ b/Model/Staff/AuthorizationRule.php @@ -5,6 +5,7 @@ */ namespace Magestore\Appadmin\Model\Staff; + /** * Class AuthorizationRule * @package Magestore\Webpos\Model\Staff @@ -36,4 +37,4 @@ protected function _construct() { $this->_init('Magestore\Appadmin\Model\ResourceModel\Staff\AuthorizationRule'); } -} \ No newline at end of file +} diff --git a/Model/Staff/Role.php b/Model/Staff/Role.php index 714efad..4eb7d26 100644 --- a/Model/Staff/Role.php +++ b/Model/Staff/Role.php @@ -69,12 +69,13 @@ public function beforeDelete() * get location list for form select element * return array */ - public function getValuesForForm(){ + public function getValuesForForm() + { $collection = $this->getCollection(); - $options = array(); - if($collection->getSize() > 0){ - foreach ($collection as $role){ - $options[] = array('value' => $role->getId(), 'label' => $role->getData('display_name')); + $options = []; + if ($collection->getSize() > 0) { + foreach ($collection as $role) { + $options[] = ['value' => $role->getId(), 'label' => $role->getData('display_name')]; } } return $options; @@ -83,8 +84,9 @@ public function getValuesForForm(){ /** * @return array */ - public function getHashOption() { - $options = array(); + public function getHashOption() + { + $options = []; $collection = $this->getCollection(); foreach ($collection as $role) { $options[$role->getId()] = $role['display_name']; @@ -123,7 +125,8 @@ public function setRoleId($roleId) * @api * @return string|null */ - public function getName() { + public function getName() + { return $this->getData(self::NAME); } @@ -134,7 +137,8 @@ public function getName() { * @param string $name * @return $this */ - public function setName($name) { + public function setName($name) + { $this->setData(self::NAME, $name); return $this; } @@ -144,7 +148,8 @@ public function setName($name) { * @api * @return string|null */ - public function getDescription() { + public function getDescription() + { return $this->getData(self::DESCRIPTION); } @@ -155,7 +160,8 @@ public function getDescription() { * @param string $description * @return $this */ - public function setDescription($description) { + public function setDescription($description) + { $this->setData(self::DESCRIPTION, $description); return $this; } @@ -166,7 +172,8 @@ public function setDescription($description) { * @api * @return string|null */ - public function getMaximumDiscountPercent() { + public function getMaximumDiscountPercent() + { return $this->getData(self::DESCRIPTION); } @@ -177,8 +184,9 @@ public function getMaximumDiscountPercent() { * @param string $discount * @return $this */ - public function setMaximumDiscountPercent($discount) { + public function setMaximumDiscountPercent($discount) + { $this->setData(self::DESCRIPTION, $discount); return $this; } -} \ No newline at end of file +} diff --git a/Model/Staff/RoleManagement.php b/Model/Staff/RoleManagement.php index bfb745c..2a2fead 100644 --- a/Model/Staff/RoleManagement.php +++ b/Model/Staff/RoleManagement.php @@ -13,4 +13,4 @@ class RoleManagement implements \Magestore\Appadmin\Api\Staff\RoleManagementInterface { -} \ No newline at end of file +} diff --git a/Model/Staff/RoleRepository.php b/Model/Staff/RoleRepository.php index e1b52d2..80a99c4 100644 --- a/Model/Staff/RoleRepository.php +++ b/Model/Staff/RoleRepository.php @@ -38,8 +38,7 @@ public function __construct( \Magestore\Appadmin\Model\ResourceModel\Staff\Role $roleResource, \Magestore\Appadmin\Model\ResourceModel\Staff\Role\CollectionFactory $roleCollectionFactory, \Magestore\Appadmin\Api\Data\Staff\RoleSearchResultsInterfaceFactory $roleSearchResultsInterfaceFactory - ) - { + ) { $this->roleFactory = $roleFactory; $this->roleResource = $roleResource; $this->roleSearchResults = $roleSearchResultsInterfaceFactory; @@ -144,5 +143,4 @@ public function getAllRole() $collection = $this->roleCollectionFactory->create(); return $collection; } - -} \ No newline at end of file +} diff --git a/Model/Staff/RuleRepository.php b/Model/Staff/RuleRepository.php index 78e0447..a33d6ae 100644 --- a/Model/Staff/RuleRepository.php +++ b/Model/Staff/RuleRepository.php @@ -32,7 +32,8 @@ public function __construct( /** * @inheritdoc */ - public function isAllowPermission($aclResource, $staffId){ + public function isAllowPermission($aclResource, $staffId) + { $permissions = $this->getAllPermissionByStaffId($staffId); if (in_array('Magestore_Appadmin::all', $permissions) || in_array($aclResource, $permissions)) { return true; @@ -45,9 +46,10 @@ public function isAllowPermission($aclResource, $staffId){ * @return array * @throws \Magento\Framework\Exception\LocalizedException */ - protected function getAllPermissionByStaffId($staffId) { + protected function getAllPermissionByStaffId($staffId) + { $staffModel = $this->staffRepository->getById($staffId); - $resourceAccess = array(); + $resourceAccess = []; if ($staffModel->getId()) { $roleId = $staffModel->getRoleId(); $resourceAccess = $this->getAllPermissionByRoleId($roleId); @@ -59,12 +61,13 @@ protected function getAllPermissionByStaffId($staffId) { * @param int $roleId * @return array */ - protected function getAllPermissionByRoleId($roleId) { - $resourceAccess = array(); + protected function getAllPermissionByRoleId($roleId) + { + $resourceAccess = []; $authorizationCollection = $this->collectionFactory->create()->addFieldToFilter('role_id', $roleId); foreach ($authorizationCollection as $resource) { $resourceAccess[] = $resource->getResourceId(); } return $resourceAccess; } -} \ No newline at end of file +} diff --git a/Model/Staff/Staff.php b/Model/Staff/Staff.php index 2005da2..4c2982b 100644 --- a/Model/Staff/Staff.php +++ b/Model/Staff/Staff.php @@ -6,6 +6,7 @@ */ namespace Magestore\Appadmin\Model\Staff; + use Magestore\Appadmin\Api\Data\Staff\StaffInterface; /** @@ -96,13 +97,14 @@ public function getEncodedPassword($password) * @return $this * @throws \Magento\Framework\Exception\LocalizedException */ - public function beforeSave() { + public function beforeSave() + { $data = []; if ($this->getNewPassword()) { $data['password'] = $this->getEncodedPassword($this->getNewPassword()); // dispatch event force sign out when change password - if(!$this->isObjectNew()) { + if (!$this->isObjectNew()) { $this->dispatchService->dispatchEventForceSignOut($this->getStaffId()); } } elseif ($this->getPassword() && !$this->getId() && !$this->getNotEncode()) { @@ -111,7 +113,7 @@ public function beforeSave() { $this->addData($data); // set data object before save - if(!$this->isObjectNew()) { + if (!$this->isObjectNew()) { $currentObject = $this->staffRepository->getById($this->getStaffId()); $this->currentData = $currentObject->getData(); } @@ -121,22 +123,22 @@ public function beforeSave() { public function afterSave() { - if(!$this->isObjectNew()) { + if (!$this->isObjectNew()) { // dispatch event force sign out when not have permission // or disable staff - if((!$this->ruleRepository->isAllowPermission('Magestore_Webpos::manage_pos', $this->getStaffId()) + if ((!$this->ruleRepository->isAllowPermission('Magestore_Webpos::manage_pos', $this->getStaffId()) || $this->getStatus() == \Magestore\Appadmin\Model\Source\Adminhtml\Status::STATUS_DISABLED)) { $this->dispatchService->dispatchEventForceSignOut($this->getStaffId()); } // dispatch event force change pos when remove some location assigned - if($this->hasDataChangeForField('location_ids')) { + if ($this->hasDataChangeForField('location_ids')) { // get list location id which has been deleted $oldLocationIds = explode(',', $this->currentData['location_ids']); $newLocationIds = explode(',', $this->getData('location_ids')); $locationDeleted = []; foreach ($oldLocationIds as $locationId) { - if(!in_array($locationId, $newLocationIds)) { + if (!in_array($locationId, $newLocationIds)) { $locationDeleted[] = $locationId; } } @@ -147,14 +149,15 @@ public function afterSave() return parent::afterSave(); } - protected function forceChangePosForStaff($locationDeleted) { + protected function forceChangePosForStaff($locationDeleted) + { foreach ($locationDeleted as $locationId) { /** @var \Magestore\Webpos\Model\ResourceModel\Location\Location $resourceLocation */ $resourceLocation = $this->locationResource; $select = $resourceLocation->getConnection()->select(); $select->from(['e' => $resourceLocation->getMainTable()]); $select->join( - array('pos' => $resourceLocation->getTable('webpos_pos')), + ['pos' => $resourceLocation->getTable('webpos_pos')], 'pos.location_id = e.' . $resourceLocation->getIdFieldName(), [] ); @@ -177,18 +180,21 @@ public function beforeDelete() } // check if data has change for field - protected function hasDataChangeForField($fieldName) { + protected function hasDataChangeForField($fieldName) + { return !($this->currentData[$fieldName] == $this->getData($fieldName)); } /** * */ - public function loadByUsername($username) { + public function loadByUsername($username) + { $staffCollection = $this->staffCollectionFactory->create()->addFieldToFilter(self::USER_NAME, $username) - ->addFieldToFilter(self::STATUS,self::STATUS_ENABLED); - if ($id = $staffCollection->getFirstItem()->getId()) + ->addFieldToFilter(self::STATUS, self::STATUS_ENABLED); + if ($id = $staffCollection->getFirstItem()->getId()) { $this->staffResource->load($this, $id); + } return $this; } @@ -198,7 +204,8 @@ public function loadByUsername($username) { * @return $this|bool * @throws \Exception */ - public function authenticate($username, $password) { + public function authenticate($username, $password) + { $this->loadByUsername($username); if (!$this->validatePassword($password)) { return false; @@ -209,8 +216,9 @@ public function authenticate($username, $password) { /** * @return array|bool */ - public function validate() { - $errors = array(); + public function validate() + { + $errors = []; if ($this->hasNewPassword()) { if (strlen($this->getNewPassword()) < self::MIN_PASSWORD_LENGTH) { $errors[] = __('Password must be at least of %1 characters.', self::MIN_PASSWORD_LENGTH); @@ -239,10 +247,12 @@ public function validate() { * @return bool * @throws \Exception */ - public function validatePassword($password) { + public function validatePassword($password) + { $hash = $this->getPassword(); - if (!$hash) + if (!$hash) { return false; + } return $this->encryptor->validateHash($password, $hash); } /** @@ -275,7 +285,8 @@ public function setStaffId($staffId) * @api * @return string|null */ - public function getUsername() { + public function getUsername() + { return $this->getData(self::USER_NAME); } @@ -286,7 +297,8 @@ public function getUsername() { * @param string $username * @return $this */ - public function setUsername($username) { + public function setUsername($username) + { $this->setData(self::USER_NAME, $username); return $this; } @@ -296,7 +308,8 @@ public function setUsername($username) { * @api * @return string|null */ - public function getPassword() { + public function getPassword() + { return $this->getData(self::PASSWORD); } @@ -307,7 +320,8 @@ public function getPassword() { * @param string $password * @return $this */ - public function setPassword($password) { + public function setPassword($password) + { $this->setData(self::PASSWORD, $password); return $this; } @@ -318,7 +332,8 @@ public function setPassword($password) { * @api * @return string|null */ - public function getName() { + public function getName() + { return $this->getData(self::NAME); } @@ -329,7 +344,8 @@ public function getName() { * @param string $name * @return $this */ - public function setName($name) { + public function setName($name) + { $this->setData(self::NAME, $name); return $this; } @@ -339,7 +355,8 @@ public function setName($name) { * @api * @return string|null */ - public function getEmail() { + public function getEmail() + { return $this->getData(self::EMAIL); } @@ -350,7 +367,8 @@ public function getEmail() { * @param string $email * @return $this */ - public function setEmail($email) { + public function setEmail($email) + { $this->setData(self::EMAIL, $email); return $this; } @@ -360,7 +378,8 @@ public function setEmail($email) { * @api * @return string|null */ - public function getCustomerGroups() { + public function getCustomerGroups() + { return $this->getData(self::CUSTOMER_GROUPS); } @@ -371,7 +390,8 @@ public function getCustomerGroups() { * @param string $customerGroups * @return $this */ - public function setCustomerGroups($customerGroups) { + public function setCustomerGroups($customerGroups) + { $this->setData(self::CUSTOMER_GROUPS, $customerGroups); return $this; } @@ -381,7 +401,8 @@ public function setCustomerGroups($customerGroups) { * @api * @return string|null */ - public function getLocationIds() { + public function getLocationIds() + { return $this->getData(self::LOCATION_IDS); } @@ -392,7 +413,8 @@ public function getLocationIds() { * @param string $locationIds * @return $this */ - public function setLocationIds($locationIds) { + public function setLocationIds($locationIds) + { $this->setData(self::LOCATION_IDS, $locationIds); return $this; } @@ -402,7 +424,8 @@ public function setLocationIds($locationIds) { * @api * @return string|null */ - public function getRoleId() { + public function getRoleId() + { return $this->getData(self::ROLE_ID); } @@ -413,7 +436,8 @@ public function getRoleId() { * @param string $roleId * @return $this */ - public function setRoleId($roleId) { + public function setRoleId($roleId) + { $this->setData(self::ROLE_ID, $roleId); return $this; } @@ -423,7 +447,8 @@ public function setRoleId($roleId) { * @api * @return string|null */ - public function getStatus() { + public function getStatus() + { return $this->getData(self::STATUS); } @@ -434,7 +459,8 @@ public function getStatus() { * @param string $status * @return $this */ - public function setStatus($status) { + public function setStatus($status) + { $this->setData(self::STATUS, $status); return $this; } @@ -445,7 +471,8 @@ public function setStatus($status) { * @api * @return string|null */ - public function getPosIds() { + public function getPosIds() + { return $this->getData(self::POS_IDS); } @@ -456,7 +483,8 @@ public function getPosIds() { * @param string $posIds * @return $this */ - public function setPosIds($posIds) { + public function setPosIds($posIds) + { $this->setData(self::POS_IDS, $posIds); return $this; } @@ -464,12 +492,13 @@ public function setPosIds($posIds) { /** * @return bool */ - public function userExists() { + public function userExists() + { $username = $this->getUsername(); - $check = $this->staffCollectionFactory->create()->addFieldToFilter(self::USER_NAME,$username); + $check = $this->staffCollectionFactory->create()->addFieldToFilter(self::USER_NAME, $username); if ($check->getFirstItem()->getId() && $this->getId() != $check->getFirstItem()->getId()) { return true; } return false; } -} \ No newline at end of file +} diff --git a/Model/Staff/StaffRepository.php b/Model/Staff/StaffRepository.php index f77defb..58ebb74 100644 --- a/Model/Staff/StaffRepository.php +++ b/Model/Staff/StaffRepository.php @@ -5,6 +5,7 @@ */ namespace Magestore\Appadmin\Model\Staff; + /** * Class StaffManagement * @package Magestore\Appadmin\Model\Staff @@ -36,7 +37,7 @@ public function __construct( \Magestore\Appadmin\Model\ResourceModel\Staff\Staff $staffResource, \Magestore\Appadmin\Model\ResourceModel\Staff\Staff\CollectionFactory $staffCollectionFactory, \Magestore\Appadmin\Api\Data\Staff\StaffSearchResultsInterfaceFactory $staffSearchResultsInterfaceFactory - ){ + ) { $this->staffFactory = $staffFactory; $this->staffResource = $staffResource; $this->staffSearchResults = $staffSearchResultsInterfaceFactory; @@ -46,7 +47,8 @@ public function __construct( /** * {@inheritdoc} */ - public function save(\Magestore\Appadmin\Api\Data\Staff\StaffInterface $staff) { + public function save(\Magestore\Appadmin\Api\Data\Staff\StaffInterface $staff) + { try { /* @var \Magestore\Appadmin\Model\Staff\Staff $staff */ /* @var \Magestore\Appadmin\Model\Staff\Staff $staffModel */ @@ -60,7 +62,8 @@ public function save(\Magestore\Appadmin\Api\Data\Staff\StaffInterface $staff) { /** * {@inheritdoc} */ - public function getById($staffId) { + public function getById($staffId) + { $staff = $this->staffFactory->create(); $this->staffResource->load($staff, $staffId); if (!$staff->getId()) { @@ -74,7 +77,8 @@ public function getById($staffId) { /** * {@inheritdoc} */ - public function getByRoleId($roleId) { + public function getByRoleId($roleId) + { $collection = $this->staffCollectionFactory->create(); $collection->addFieldToFilter('role_id', $roleId); return $collection; @@ -83,7 +87,8 @@ public function getByRoleId($roleId) { /** * {@inheritdoc} */ - public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) { + public function getList(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria) + { $collection = $this->staffCollectionFactory->create(); //Add filters from root filter group to the collection /** @var FilterGroup $group */ @@ -142,10 +147,10 @@ public function deleteById($staffId) /** * {@inheritdoc} */ - public function getAllStaff(){ + public function getAllStaff() + { /** @var \Magestore\Appadmin\Model\ResourceModel\Staff\Staff\Collection $collection */ $collection = $this->staffCollectionFactory->create(); return $collection; } - -} \ No newline at end of file +} diff --git a/Setup/InstallData.php b/Setup/InstallData.php index 71a92a7..c9a0b48 100644 --- a/Setup/InstallData.php +++ b/Setup/InstallData.php @@ -6,7 +6,6 @@ namespace Magestore\Appadmin\Setup; - use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; @@ -68,8 +67,7 @@ public function __construct( \Magestore\Appadmin\Model\Staff\StaffFactory $staffFactory, \Magestore\Webpos\Model\ResourceModel\Location\Location\CollectionFactory $locationCollectionFactory, \Magento\Framework\Module\Manager $moduleManager - ) - { + ) { $this->_userCollectionFactory = $userCollectionFactory; $this->_roleFactory = $roleFactory; $this->_authorizationRuleFactory = $authorizationRuleFactory; @@ -88,15 +86,15 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface /* * Setup Role Data */ - $roleData = array( + $roleData = [ 'name' => 'Cashier' - ); + ]; $role = $this->_roleFactory->create()->setData($roleData)->save(); - $authorizeRule = array( + $authorizeRule = [ 'role_id' => $role->getId(), 'resource_id' => self::DEFAULT_RESOURCE_ACCESS - ); + ]; $this->_authorizationRuleFactory->create()->setData($authorizeRule)->save(); /* @@ -115,7 +113,7 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface } } if ($userModel->getId()) { - $staffData = array( + $staffData = [ 'role_id' => $role->getId(), 'username' => $userModel->getUsername(), 'password' => $userModel->getPassword(), @@ -124,10 +122,10 @@ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface 'location_ids' => $locationId, 'not_encode' => self::NOT_ENCODE_PASSWORD, 'status' => self::IS_ACTIVE - ); + ]; $this->_staffFactory->create()->setData($staffData)->save(); } $setup->endSetup(); } -} \ No newline at end of file +} diff --git a/Setup/InstallSchema.php b/Setup/InstallSchema.php index 0fc3301..dc738f4 100644 --- a/Setup/InstallSchema.php +++ b/Setup/InstallSchema.php @@ -164,4 +164,4 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con $installer->endSetup(); return $this; } -} \ No newline at end of file +} diff --git a/Setup/UpgradeSchema.php b/Setup/UpgradeSchema.php index cd908cf..417316f 100644 --- a/Setup/UpgradeSchema.php +++ b/Setup/UpgradeSchema.php @@ -26,25 +26,25 @@ public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $con $setup->getTable('webpos_authorization_role'), 'description', 'description', - array( + [ 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 'nullable' => false, 'length' => \Magento\Framework\DB\Ddl\Table::MAX_TEXT_SIZE, 'comment' => 'description' - ) + ] ); } if (version_compare($context->getVersion(), '1.0.0.1', '<')) { $setup->getConnection()->addColumn( $setup->getTable('webpos_authorization_role'), 'max_discount_percent', - array( + [ 'type' => \Magento\Framework\DB\Ddl\Table::TYPE_FLOAT, 'nullable' => true, 'comment' => 'Maximum discount percent' - ) + ] ); } $setup->endSetup(); } -} \ No newline at end of file +} diff --git a/Ui/Component/Listing/Column/Role.php b/Ui/Component/Listing/Column/Role.php index f5c8bec..ec2377d 100644 --- a/Ui/Component/Listing/Column/Role.php +++ b/Ui/Component/Listing/Column/Role.php @@ -76,4 +76,4 @@ public function getOptions() } return $res; } -} \ No newline at end of file +} diff --git a/Ui/Component/Listing/Column/RoleActions.php b/Ui/Component/Listing/Column/RoleActions.php index 662bc5b..65f1277 100644 --- a/Ui/Component/Listing/Column/RoleActions.php +++ b/Ui/Component/Listing/Column/RoleActions.php @@ -69,7 +69,6 @@ public function prepareDataSource(array $dataSource) 'href' => $this->_urlBuilder->getUrl($this->_editUrl, ['id' => $item['role_id']]), 'label' => __('Edit') ]; - } } } diff --git a/Ui/Component/Listing/Column/Status.php b/Ui/Component/Listing/Column/Status.php index bf0129c..da6b882 100644 --- a/Ui/Component/Listing/Column/Status.php +++ b/Ui/Component/Listing/Column/Status.php @@ -10,11 +10,11 @@ /** * class \Magestore\Webpos\Ui\Component\Listing\Column\Status - * + * * Web POS Status Actions * Methods: * toOptionArray - * + * * @category Magestore * @package Magestore\Webpos\Ui\Component\Listing\Column * @module Webpos @@ -31,7 +31,7 @@ class Status implements OptionSourceInterface */ const STATUS_DISABLED = 2; /** - * + * * @return array */ public function toOptionArray() diff --git a/Ui/DataProvider/Form/Modifier/AbstractModifier.php b/Ui/DataProvider/Form/Modifier/AbstractModifier.php index 23909fd..d11db70 100644 --- a/Ui/DataProvider/Form/Modifier/AbstractModifier.php +++ b/Ui/DataProvider/Form/Modifier/AbstractModifier.php @@ -103,7 +103,8 @@ public function modifyData(array $data) * @param array $meta * @return array */ - public function modifyMeta(array $meta){ + public function modifyMeta(array $meta) + { return $meta; } @@ -112,7 +113,8 @@ public function modifyMeta(array $meta){ * * @return bool */ - public function getVisible(){ + public function getVisible() + { return $this->visible; } @@ -121,7 +123,8 @@ public function getVisible(){ * * @return bool */ - public function getOpened(){ + public function getOpened() + { return $this->opened; } @@ -130,7 +133,8 @@ public function getOpened(){ * * @return int */ - public function getSortOrder(){ + public function getSortOrder() + { return $this->sortOrder; } @@ -138,7 +142,8 @@ public function getSortOrder(){ * @param $field * @return array */ - public function setDefaultValue($field, $value){ + public function setDefaultValue($field, $value) + { $field['arguments']['data']['config']['default'] = $value; return $field; } @@ -154,7 +159,8 @@ public function setDefaultValue($field, $value){ * @param bool $disable * @return array */ - public function addFormField($label, $dataType , $formElement, $sortOrder, $validation = [], $defaultValue = null, $notice = '', $disable = false){ + public function addFormField($label, $dataType, $formElement, $sortOrder, $validation = [], $defaultValue = null, $notice = '', $disable = false) + { $field = [ 'arguments' => [ 'data' => [ @@ -172,8 +178,9 @@ public function addFormField($label, $dataType , $formElement, $sortOrder, $vali ], ], ]; - if($defaultValue) + if ($defaultValue) { $field = $this->setDefaultValue($field, $defaultValue); + } return $field; } @@ -187,7 +194,8 @@ public function addFormField($label, $dataType , $formElement, $sortOrder, $vali * @param bool $disabled * @return array */ - public function addFormFieldText($label, $formElement, $sortOrder, $validation = [], $defaultValue = null, $notice = '', $disabled = false){ + public function addFormFieldText($label, $formElement, $sortOrder, $validation = [], $defaultValue = null, $notice = '', $disabled = false) + { return $this->addFormField($label, 'text', $formElement, $sortOrder, $validation, $defaultValue, $notice, $disabled); } @@ -202,7 +210,8 @@ public function addFormFieldText($label, $formElement, $sortOrder, $validation = * @param string $classes * @return array */ - public function addFormFieldPassword($label, $formElement, $sortOrder, $validation , $classes = '', $defaultValue = null, $notice = '', $disabled = false){ + public function addFormFieldPassword($label, $formElement, $sortOrder, $validation, $classes = '', $defaultValue = null, $notice = '', $disabled = false) + { $field = [ 'arguments' => [ 'data' => [ @@ -233,7 +242,8 @@ public function addFormFieldPassword($label, $formElement, $sortOrder, $validati * @param string $notice * @return array */ - public function addFormFieldDate($label, $sortOrder, $validation = [], $defaultValue = null, $notice = ''){ + public function addFormFieldDate($label, $sortOrder, $validation = [], $defaultValue = null, $notice = '') + { return $this->addFormField($label, 'date', 'date', $sortOrder, $validation, $defaultValue, $notice); } @@ -245,7 +255,8 @@ public function addFormFieldDate($label, $sortOrder, $validation = [], $defaultV * @param string $notice * @return array */ - public function addFormFieldTextArea($label, $sortOrder, $validation = [], $defaultValue = null, $notice = ''){ + public function addFormFieldTextArea($label, $sortOrder, $validation = [], $defaultValue = null, $notice = '') + { return $this->addFormField($label, 'text', 'textarea', $sortOrder, $validation, $defaultValue, $notice); } @@ -258,7 +269,12 @@ public function addFormFieldTextArea($label, $sortOrder, $validation = [], $defa * @return array */ public function addFormFieldWysiwygArea( - $label, $sortOrder, $validation = [], $defaultValue = null, $notice = ''){ + $label, + $sortOrder, + $validation = [], + $defaultValue = null, + $notice = '' + ) { $field = [ 'arguments' => [ 'data' => [ @@ -276,12 +292,14 @@ public function addFormFieldWysiwygArea( ], ], ]; - if($defaultValue) + if ($defaultValue) { $field = $this->setDefaultValue($field, $defaultValue); + } return $field; } - public function addSwitcherConfig($field, $switcherConfig){ + public function addSwitcherConfig($field, $switcherConfig) + { $field['arguments']['data']['config']['switcherConfig'] = [ 'enabled' => true, 'rules' => $switcherConfig @@ -317,10 +335,10 @@ public function addFormFieldCheckbox($label, $sortOrder, $default = '', $notice ], ], ]; - if($switcherConfig){ + if ($switcherConfig) { $field = $this->addSwitcherConfig($field, $switcherConfig); } - if($default){ + if ($default) { $field = $this->setDefaultValue($field, $default); } return $field; @@ -338,8 +356,15 @@ public function addFormFieldCheckbox($label, $sortOrder, $default = '', $notice * @return array */ public function addFormFieldSelect( - $label, $options = [], $sortOrder, $validation = [], $defaultValue = null, $notice = '', $switcherConfig = null, $disabled = false - ){ + $label, + $options = [], + $sortOrder, + $validation = [], + $defaultValue = null, + $notice = '', + $switcherConfig = null, + $disabled = false + ) { $field = [ 'arguments' => [ 'data' => [ @@ -357,10 +382,12 @@ public function addFormFieldSelect( ], ], ]; - if($defaultValue) + if ($defaultValue) { $field = $this->setDefaultValue($field, $defaultValue); - if($switcherConfig) + } + if ($switcherConfig) { $field = $this->addSwitcherConfig($field, $switcherConfig); + } return $field; } @@ -376,8 +403,15 @@ public function addFormFieldSelect( * @return array */ public function addFormFieldMultiSelect( - $label, $options = [], $sortOrder, $validation = [], $defaultValue = null, $notice = '', $switcherConfig = null, $disabled = false - ){ + $label, + $options = [], + $sortOrder, + $validation = [], + $defaultValue = null, + $notice = '', + $switcherConfig = null, + $disabled = false + ) { $field = [ 'arguments' => [ 'data' => [ @@ -395,8 +429,9 @@ public function addFormFieldMultiSelect( ], ], ]; - if($defaultValue) + if ($defaultValue) { $field = $this->setDefaultValue($field, $defaultValue); + } return $field; } @@ -407,7 +442,8 @@ public function addFormFieldMultiSelect( * @param string $block * @return array */ - public function addHtmlContentContainer($containerName = '', $block = ''){ + public function addHtmlContentContainer($containerName = '', $block = '') + { return [ 'arguments' => [ 'data' => [ @@ -443,7 +479,8 @@ public function addHtmlContentContainer($containerName = '', $block = ''){ * @param string|null $redirectUrl * @return array */ - public function addButton($buttonTitle = '', $actions = [], $redirectUrl = null){ + public function addButton($buttonTitle = '', $actions = [], $redirectUrl = null) + { $button = [ 'arguments' => [ 'data' => [ @@ -457,8 +494,9 @@ public function addButton($buttonTitle = '', $actions = [], $redirectUrl = null) ], ], ]; - if($redirectUrl) + if ($redirectUrl) { $button['arguments']['data']['config']['redirectUrl'] = $redirectUrl; + } return $button; } @@ -502,7 +540,8 @@ public function getTextColumn($dataScope, $fit, $label, $sortOrder) * @param array $validation * @return array */ - public function getInputNumberColumn($dataScope, $fit, $label, $sortOrder, $validation = []){ + public function getInputNumberColumn($dataScope, $fit, $label, $sortOrder, $validation = []) + { return [ 'arguments' => [ 'data' => [ @@ -521,4 +560,4 @@ public function getInputNumberColumn($dataScope, $fit, $label, $sortOrder, $vali ], ]; } -} \ No newline at end of file +} diff --git a/Ui/DataProvider/Staff/Form/Modifier/AbstractModifier.php b/Ui/DataProvider/Staff/Form/Modifier/AbstractModifier.php index a755b64..3409bb0 100644 --- a/Ui/DataProvider/Staff/Form/Modifier/AbstractModifier.php +++ b/Ui/DataProvider/Staff/Form/Modifier/AbstractModifier.php @@ -25,9 +25,11 @@ class AbstractModifier extends \Magestore\Appadmin\Ui\DataProvider\Form\Modifier /** * @return \Magestore\Appadmin\Model\Staff\Staff|mixed */ - public function getCurrentStaff() { - if (!$this->currentStaff) + public function getCurrentStaff() + { + if (!$this->currentStaff) { $this->currentStaff = $this->registry->registry('current_staff'); + } return $this->currentStaff; } -} \ No newline at end of file +} diff --git a/Ui/DataProvider/Staff/Form/Modifier/General.php b/Ui/DataProvider/Staff/Form/Modifier/General.php index 6d102fc..a5db097 100644 --- a/Ui/DataProvider/Staff/Form/Modifier/General.php +++ b/Ui/DataProvider/Staff/Form/Modifier/General.php @@ -76,8 +76,7 @@ public function __construct( \Magestore\Webpos\Model\Source\Adminhtml\Location $location, \Magestore\Webpos\Model\Source\Adminhtml\Pos $pos, \Magestore\Appadmin\Model\Source\Adminhtml\Role $role - ) - { + ) { parent::__construct($objectManager, $registry, $request, $urlBuilder); $this->optionStoreView = $optionStoreView; $this->customerGroup = $customerGroup; @@ -188,7 +187,7 @@ protected function getGeneralChildren() if (!$this->request->getParam('id')) { $children['password']['arguments']['data']['config']['validation']['required-entry'] = true; $children['password_confirmation']['arguments']['data']['config']['validation']['required-entry'] = true; - }else{ + } else { $children['password']['arguments']['data']['config']['label'] = __("New Password"); } return $children; @@ -214,4 +213,4 @@ protected function getStoreViews() { return $this->optionStoreView->toOptionArray(); } -} \ No newline at end of file +} diff --git a/Ui/DataProvider/Staff/Form/Staff.php b/Ui/DataProvider/Staff/Form/Staff.php index c9196b5..1b2d93f 100644 --- a/Ui/DataProvider/Staff/Form/Staff.php +++ b/Ui/DataProvider/Staff/Form/Staff.php @@ -10,7 +10,8 @@ use Magestore\Appadmin\Model\ResourceModel\Staff\Staff\CollectionFactory; use Magestore\Appadmin\Model\ResourceModel\Staff\Staff\Collection; -class Staff extends \Magento\Ui\DataProvider\AbstractDataProvider { +class Staff extends \Magento\Ui\DataProvider\AbstractDataProvider +{ /** * @var \Magento\Framework\Registry @@ -60,7 +61,7 @@ public function __construct( public function getData() { $staff = $this->_coreRegistry->registry('current_staff'); - if($staff && $staff->getId()){ + if ($staff && $staff->getId()) { $data = $staff->getData(); // if ($data['pos_ids']) { @@ -98,4 +99,4 @@ public function getMeta() return $meta; } -} \ No newline at end of file +}