└── app └── code └── Magestore └── Company ├── etc ├── adminhtml │ ├── di.xml │ ├── routes.xml │ └── menu.xml ├── module.xml └── Adminhtml │ └── routes.xml ├── Controller └── Adminhtml │ ├── Staff │ ├── Index.php │ └── MassDelete.php │ ├── Staff.php │ └── AbstractAction.php ├── Model ├── ResourceModel │ ├── Staff.php │ └── Staff │ │ └── Collection.php └── Staff.php ├── registration.php ├── Block └── Adminhtml │ └── Staff.php ├── view └── adminhtml │ ├── layout │ └── companyadmin_staff_index.xml │ └── ui_component │ ├── company_staff_listing.xml │ └── company_staff_listing.xml~ ├── composer.json ├── Ui └── DataProvider │ └── StaffDataProvider.php ├── Setup └── InstallSchema.php └── Helper └── Data.php /app/code/Magestore/Company/etc/adminhtml/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/Controller/Adminhtml/Staff/Index.php: -------------------------------------------------------------------------------- 1 | _resultPageFactory->create(); 13 | 14 | return $resultPage; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/etc/Adminhtml/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/etc/adminhtml/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/Model/ResourceModel/Staff.php: -------------------------------------------------------------------------------- 1 | _init('magestore_company_staffs', 'staff_id'); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/Controller/Adminhtml/Staff.php: -------------------------------------------------------------------------------- 1 | _authorization->isAllowed('Magestore_Company::company_staff'); 13 | } 14 | } -------------------------------------------------------------------------------- /app/code/Magestore/Company/registration.php: -------------------------------------------------------------------------------- 1 | _controller = 'adminhtml_staff'; 16 | $this->_blockGroup = 'Magestore_Company'; 17 | $this->_headerText = __('Staff Listing'); 18 | 19 | parent::_construct(); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/Model/ResourceModel/Staff/Collection.php: -------------------------------------------------------------------------------- 1 | _init('Magestore\Company\Model\Staff', 'Magestore\Company\Model\ResourceModel\Staff'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/view/adminhtml/layout/companyadmin_staff_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Staff Listing 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/etc/adminhtml/menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magestore/module-company", 3 | "description": "N/A", 4 | "require": { 5 | "php": "~5.5.0|~5.6.0|~7.0.0" 6 | }, 7 | "type": "magento2-module", 8 | "license": [ 9 | "OSL-3.0", 10 | "AFL-3.0" 11 | ], 12 | "authors": [ 13 | { 14 | "name": "Steve Ngo", 15 | "email": "steve@magestore.com", 16 | "homepage": "https://www.magestore.com/", 17 | "role": "Developer" 18 | } 19 | ], 20 | "autoload": { 21 | "files": [ 22 | "registration.php" 23 | ], 24 | "psr-4": { 25 | "Magestore\\Company\\": "" 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /app/code/Magestore/Company/Controller/Adminhtml/Staff/MassDelete.php: -------------------------------------------------------------------------------- 1 | _massActionFilter->getCollection($this->_createMainCollection()); 14 | $collectionSize = $collection->getSize(); 15 | 16 | foreach ($collection as $item) { 17 | $item->delete(); 18 | } 19 | 20 | $this->messageManager->addSuccess(__('A total of %1 record(s) have been deleted.', $collectionSize)); 21 | 22 | /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */ 23 | $resultRedirect = $this->resultRedirectFactory->create(); 24 | 25 | return $resultRedirect->setPath('*/*/'); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/Ui/DataProvider/StaffDataProvider.php: -------------------------------------------------------------------------------- 1 | collection = $collectionFactory->create(); 34 | $this->addFieldStrategies = $addFieldStrategies; 35 | $this->addFilterStrategies = $addFilterStrategies; 36 | } 37 | 38 | 39 | 40 | } 41 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/Model/Staff.php: -------------------------------------------------------------------------------- 1 | _staffFactory = $staffFactory; 47 | 48 | 49 | $this->_storeManager = $storeManager; 50 | $this->_staffCollectionFactory = $staffCollectionFactory; 51 | 52 | $this->_monolog = $monolog; 53 | 54 | if ($storeViewId = $this->_storeManager->getStore()->getId()) { 55 | $this->_storeViewId = $storeViewId; 56 | } 57 | } 58 | 59 | 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/Setup/InstallSchema.php: -------------------------------------------------------------------------------- 1 | startSetup(); 19 | 20 | /* 21 | * Drop tables if exists 22 | */ 23 | $installer->getConnection()->dropTable($installer->getTable('magestore_company_staffs')); 24 | 25 | 26 | /* 27 | * Create table magestore_company_staffs 28 | */ 29 | $table = $installer->getConnection()->newTable( 30 | $installer->getTable('magestore_company_staffs') 31 | )->addColumn( 32 | 'staff_id', 33 | \Magento\Framework\DB\Ddl\Table::TYPE_INTEGER, 34 | 10, 35 | ['identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true], 36 | 'Staff ID' 37 | )->addColumn( 38 | 'staff_name', 39 | \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 40 | 255, 41 | ['nullable' => false, 'default' => ''], 42 | 'Staff Name' 43 | )->addColumn( 44 | 'staff_email', 45 | \Magento\Framework\DB\Ddl\Table::TYPE_TEXT, 46 | 255, 47 | ['nullable' => true], 48 | ' Staff Email' 49 | ); 50 | $installer->getConnection()->createTable($table); 51 | /* 52 | * End create table magestore_company_staffs 53 | */ 54 | 55 | 56 | 57 | $installer->endSetup(); 58 | } 59 | } -------------------------------------------------------------------------------- /app/code/Magestore/Company/Controller/Adminhtml/AbstractAction.php: -------------------------------------------------------------------------------- 1 | _coreRegistry = $coreRegistry; 51 | $this->_fileFactory = $fileFactory; 52 | $this->_storeManager = $storeManager; 53 | $this->_jsHelper = $jsHelper; 54 | 55 | $this->_resultPageFactory = $resultPageFactory; 56 | $this->_resultLayoutFactory = $resultLayoutFactory; 57 | $this->_resultForwardFactory = $resultForwardFactory; 58 | 59 | $this->_staffFactory = $staffFactory; 60 | 61 | $this->_staffCollectionFactory = $staffCollectionFactory; 62 | 63 | } 64 | 65 | 66 | protected function _getBackResultRedirect(\Magento\Framework\Controller\Result\Redirect $resultRedirect, $paramCrudId = null) 67 | { 68 | switch ($this->getRequest()->getParam('back')) { 69 | case 'edit': 70 | $resultRedirect->setPath( 71 | '*/*/edit', 72 | [ 73 | static::PARAM_CRUD_ID => $paramCrudId, 74 | '_current' => true, 75 | ] 76 | ); 77 | break; 78 | case 'new': 79 | $resultRedirect->setPath('*/*/new', ['_current' => true]); 80 | break; 81 | default: 82 | $resultRedirect->setPath('*/*/'); 83 | } 84 | 85 | return $resultRedirect; 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/Helper/Data.php: -------------------------------------------------------------------------------- 1 | _factory = $factory; 48 | $this->_converter = $converter; 49 | 50 | $this->_backendHelperJs = $backendHelperJs; 51 | $this->_backendSession = $backendSession; 52 | } 53 | 54 | 55 | public function getTreeSelectedValues() 56 | { 57 | 58 | $sessionData = $this->_getSessionData(); 59 | 60 | if ($sessionData) { 61 | return $this->_converter->toTreeArray( 62 | $this->_backendHelperJs->decodeGridSerializedInput($sessionData) 63 | ); 64 | } 65 | 66 | $entityType = $this->_getRequest()->getParam('entity_type'); 67 | $id = $this->_getRequest()->getParam('enitity_id'); 68 | 69 | /** @var \Magestore\Storelocator\Model\AbstractModelManageStores $model */ 70 | $model = $this->_factory->create($entityType)->load($id); 71 | 72 | 73 | 74 | 75 | $methodGetterId = $this->_getRequest()->getParam('method_getter_id'); 76 | 77 | /** @var \Magestore\Storelocator\Model\Store $store */ 78 | 79 | $ids = $model->runGetterMethod($methodGetterId); 80 | 81 | return $model->getId() ? $this->_converter->toTreeArray($ids) : []; 82 | } 83 | 84 | /** 85 | * Get session data. 86 | * 87 | * @return array 88 | */ 89 | protected function _getSessionData() 90 | { 91 | $serializedName = $this->_getRequest()->getParam('serialized_name'); 92 | if ($this->_sessionData === null) { 93 | $this->_sessionData = $this->_backendSession->getData($serializedName, true); 94 | } 95 | 96 | return $this->_sessionData; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/view/adminhtml/ui_component/company_staff_listing.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | company_staff_listing.company_staff_listing_data_source 12 | company_staff_listing.company_staff_listing_data_source 13 | 14 | company_staff_listing_columns 15 | 16 | 17 | 18 | 19 | 20 | company_staff_listing_data_source 21 | Magestore\Company\Ui\DataProvider\StaffDataProvider 22 | staff_id 23 | id 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Magento_Ui/js/grid/provider 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | ui/grid/toolbar 41 | 42 | 43 | 44 | 45 | 46 | Magento_Ui/js/grid/controls/bookmarks/bookmarks 47 | dataGridAcions 48 | 49 | 50 | 51 | company_staff_listing 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | dataGridFilters 64 | filters 65 | 66 | company_staff_listing.company_staff_listing.listing_top.bookmarks 67 | current.filters 68 | 69 | 70 | company_staff_listing.company_staff_listing.listing_top.listing_filters 71 | 72 | company_staff_listing.company_staff_listing.company_staff_listing_columns.${ $.index }:visible 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | staff_name 82 | Staff Name 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | staff_email 91 | Staff Email 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | company_staff_listing.company_staff_listing.listing_top.bookmarks 103 | current 104 | 105 | 106 | company_staff_listing.company_staff_listing.company_staff_listing_columns.ids 107 | true 108 | staff_id 109 | 110 | 111 | false 112 | 113 | 114 | 115 | 116 | company_staff_listing.company_staff_listing.company_staff_listing_columns_editor 117 | startEdit 118 | 119 | ${ $.$data.rowIndex } 120 | true 121 | 122 | 123 | 124 | company_staff_listing.company_staff_listing.company_staff_listing.listing_top.bookmarks 125 | columns.${ $.index } 126 | current.${ $.storageConfig.root } 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | false 135 | 55 136 | staff_id 137 | 138 | 139 | 140 | 141 | 142 | 143 | Magento_Ui/js/grid/columns/column 144 | ui/grid/cells/html 145 | true 146 | number 147 | left 148 | Staff ID 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | text 157 | 158 | true 159 | 160 | 161 | Magento_Ui/js/grid/columns/column 162 | text 163 | left 164 | Staff Name 165 | 166 | 167 | 168 | 169 | 170 | 171 | Magento_Ui/js/grid/columns/column 172 | ui/grid/cells/html 173 | text 174 | left 175 | Staff Email 176 | 177 | 178 | 179 | 180 | 181 | 182 | -------------------------------------------------------------------------------- /app/code/Magestore/Company/view/adminhtml/ui_component/company_staff_listing.xml~: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | company_staff_listing.company_staff_listing_data_source 12 | company_staff_listing.company_staff_listing_data_source 13 | 14 | company_staff_listing_columns 15 | 16 | 17 | add 18 | Add New Staff 19 | primary 20 | */*/new 21 | 22 | 23 | 24 | 25 | 26 | 27 | company_staff_listing_data_source 28 | Magestore\Company\Ui\DataProvider\StaffDataProvider 29 | staff_id 30 | id 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | Magento_Ui/js/grid/provider 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | ui/grid/toolbar 48 | 49 | 50 | 51 | 52 | 53 | Magento_Ui/js/grid/controls/bookmarks/bookmarks 54 | dataGridAcions 55 | 56 | 57 | 58 | company_staff_listing 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | company_staff_listing.company_staff_listing.company_staff_listing_columns 68 | 69 | Magento_Ui/js/grid/controls/columns 70 | dataGridActions 71 | 72 | 73 | 74 | 75 | 76 | 77 | dataGridActions 78 | 79 | 80 | csv 81 | CSV 82 | companyadmin/staff/exportCsv 83 | 84 | 85 | xml 86 | Excel XML 87 | companyadmin/staff/exportExcel 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | company_staff_listing.company_staff_listing.listing_top.bookmarks 103 | current 104 | 105 | 106 | company_staff_listing.company_staff_listing.company_staff_listing_columns.ids 107 | true 108 | staff_id 109 | 110 | 111 | false 112 | 113 | 114 | 115 | 116 | company_staff_listing.company_staff_listing.company_staff_listing_columns_editor 117 | startEdit 118 | 119 | ${ $.$data.rowIndex } 120 | true 121 | 122 | 123 | 124 | company_staff_listing.company_staff_listing.company_staff_listing.listing_top.bookmarks 125 | columns.${ $.index } 126 | current.${ $.storageConfig.root } 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | false 135 | 55 136 | staff_id 137 | 138 | 139 | 140 | 141 | 142 | 143 | Magento_Ui/js/grid/columns/column 144 | ui/grid/cells/html 145 | true 146 | number 147 | left 148 | Staff ID 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | text 157 | 158 | true 159 | 160 | 161 | Magento_Ui/js/grid/columns/column 162 | text 163 | left 164 | Staff Name 165 | 166 | 167 | 168 | 169 | 170 | 171 | Magento_Ui/js/grid/columns/column 172 | ui/grid/cells/html 173 | text 174 | left 175 | Staff Email 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | false 184 | staff_id 185 | left 186 | Action 187 | false 188 | false 189 | 190 | 191 | 192 | Edit 193 | companyadmin/employee/edit 194 | 195 | 196 | Delete 197 | companyadmin/employee/delete 198 | 199 | Delete "${ $.$data.staff_name }" 200 | Are you sure you wan\'t to delete a "${ $.$data.staff_name }" record? 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | --------------------------------------------------------------------------------