diff --git a/.env b/.env index c1072e27..52b71559 100755 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ # NETWORK -APP_PORT=81 +APP_PORT=8000 APP_URL=http://apac.host:${APP_PORT} # MYSQL diff --git a/.sh/compile b/.sh/compile index 23af668a..9d3c3334 100755 --- a/.sh/compile +++ b/.sh/compile @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh bin/magento cache:clean bin/magento cache:flush diff --git a/.sh/install b/.sh/install index a09463ac..4f870e39 100755 --- a/.sh/install +++ b/.sh/install @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh source "$PWD/.env" diff --git a/.sh/refresh b/.sh/refresh new file mode 100755 index 00000000..c8815967 --- /dev/null +++ b/.sh/refresh @@ -0,0 +1,6 @@ +#!/bin/sh + +bin/magento setup:upgrade +bin/magento setup:static-content:deploy -f +bin/magento cache:flush +chmod 777 -R generated/ var/ diff --git a/.sh/set-base-url b/.sh/set-base-url index c633e9c6..802f73d7 100755 --- a/.sh/set-base-url +++ b/.sh/set-base-url @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh source "$PWD/.env" diff --git a/app/code/IpSupply/AssetRecovery/Block/Form.php b/app/code/IpSupply/AssetRecovery/Block/Form.php new file mode 100755 index 00000000..24f6fb7b --- /dev/null +++ b/app/code/IpSupply/AssetRecovery/Block/Form.php @@ -0,0 +1,11 @@ +pageFactory = $pageFactory; + $this->messageManager = $messageManager; + $this->resultFactory = $context->getResultFactory(); + $this->inlineTranslation = $inlineTranslation; + $this->escaper = $escaper; + $this->transportBuilder = $transportBuilder; + $this->logger = $helperContext->getLogger(); + parent::__construct($context); + } + + + public function execute() + { + $page = $this->resultFactory->create(ResultFactory::TYPE_PAGE); + $data = $this->getRequest()->getPostValue(); + if (!empty($data)) { + if (!array_key_exists("name", $data)) { + $this->messageManager->addError(__("The field name is invalid")); + } else if (!array_key_exists("company_name", $data)) { + $this->messageManager->addError(__("The field company name is invalid")); + } else if (!array_key_exists("email", $data)) { + $this->messageManager->addError(__("The field email is invalid")); + } else if (!array_key_exists("phone", $data)) { + $this->messageManager->addError(__("The field phone is invalid")); + } else if (!array_key_exists("date", $data)) { + $this->messageManager->addError(__("The field date is invalid")); + } else if (!array_key_exists("items", $data)) { + $this->messageManager->addError(__("The field items is invalid")); + }else { + $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); + $scopeConfig = $objectManager->create('\Magento\Framework\App\Config\ScopeConfigInterface'); + $email_contact = $scopeConfig->getValue('trans_email/ident_general/email',\Magento\Store\Model\ScopeInterface::SCOPE_STORE); + $customerSession = $objectManager->create('Magento\Customer\Model\Session'); + try { + $this->inlineTranslation->suspend(); + $sender = [ + 'name' => $this->escaper->escapeHtml($data["name"]), + 'email' => $this->escaper->escapeHtml($data["email"]), + ]; + $transport = $this->transportBuilder + ->setTemplateIdentifier('email_asset_recovery_template') + ->setTemplateOptions( + [ + 'area' => \Magento\Framework\App\Area::AREA_FRONTEND, + 'store' => \Magento\Store\Model\Store::DEFAULT_STORE_ID, + ] + ) + ->setTemplateVars([ + 'name' => $data["name"], + 'email' => $data["email"], + 'company_name' => $data["company_name"], + 'phone' => $data["phone"], + 'date' => $data["date"], + 'items' => nl2br($data["items"]), + + ]) + ->setFrom($sender) + ->addTo($email_contact) + ->getTransport(); + $transport->sendMessage(); + $this->inlineTranslation->resume(); + $this->messageManager->addSuccess(__("Thanks you. We'll respond to you very soon.")); + } catch (\Exception $e) { + $this->logger->debug($e->getMessage()); + } + } + + } + return $page; + + } + +} diff --git a/app/code/IpSupply/AssetRecovery/composer.json b/app/code/IpSupply/AssetRecovery/composer.json new file mode 100755 index 00000000..d318d47e --- /dev/null +++ b/app/code/IpSupply/AssetRecovery/composer.json @@ -0,0 +1,27 @@ +{ + "name": "ipsupply/assetrecovery", + "description": "Asset Recovery form", + "require": { + "php": "~7.1.3||~7.2.0", + "lib-libxml": "*", + "magento/framework": "102.0.*", + "magento/module-backend": "101.0.*", + "magento/module-media-storage": "100.3.*", + "magento/module-store": "101.0.*", + "magento/module-ui": "101.1.*" + }, + "type": "magento2-module", + "version": "100.3.0", + "license": [ + "OSL-3.0", + "AFL-3.0" + ], + "autoload": { + "files": [ + "registration.php" + ], + "psr-4": { + "IpSupply\\AssetRecovery\\": "" + } + } +} diff --git a/app/code/IpSupply/AssetRecovery/etc/email_templates.xml b/app/code/IpSupply/AssetRecovery/etc/email_templates.xml new file mode 100755 index 00000000..23b52c11 --- /dev/null +++ b/app/code/IpSupply/AssetRecovery/etc/email_templates.xml @@ -0,0 +1,4 @@ + + +