ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Api;
interface CreateProductInterface
{
/**
* Returns greeting message to user
*
* @api
* @return mixed
*/
public function createProduct();
}
@@ -0,0 +1,33 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Api;
interface CreateShipmentInterface
{
/**
* Returns greeting message to user
*
* @api
* @return mixed
*/
public function createNewShipment();
}
+33
View File
@@ -0,0 +1,33 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Api;
interface OrderUpdateInterface
{
/**
* Returns greeting message to user
*
* @api
* @return mixed
*/
public function getOrderUpdate();
}
@@ -0,0 +1,33 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Api;
interface UpdateInvoicePdfInterface
{
/**
* Returns greeting message to user
*
* @api
* @return mixed
*/
public function updateInvoicePdf();
}
+145
View File
@@ -0,0 +1,145 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Block\Adminhtml;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\FileSystemException;
use Caratlane\NetSuite\Helper\IntegrationConstants;
use Magento\Framework\Filesystem\Glob;
class Logviewer extends \Magento\Backend\Block\Template
{
/**
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
*/
protected $timezone;
/**
* @var \Magento\Framework\App\Request\Http
*/
protected $request;
/**
* @var \Magento\Framework\Filesystem\Driver\File
*/
protected $driverFile;
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone,
\Magento\Framework\App\Request\Http $request,
\Magento\Framework\Filesystem\Driver\File $driverFile
) {
parent::__construct($context);
$this->timezone = $timezone;
$this->request = $request;
$this->driverFile = $driverFile;
}
public function getDates()
{
$days = IntegrationConstants::CLEAR_LOG_DAYS;
$count = 0;
$dateArr = [];
$dateBefore = date('d-m-Y', strtotime($this->timezone->date()->format('d-m-Y H:i:s')));
do {
$dateArr[] = [
'date' => $dateBefore,
'selected' => ($dateBefore == $this->request->getParam('date'))? true : false
];
$dateBefore = date('d-m-Y', strtotime($dateBefore . ' -1 days'));
$count++;
} while ($count < $days);
return $dateArr;
}
public function getLogs()
{
$logsArr = [];
$logfile = '';
$date = date('d-m-Y', strtotime($this->timezone->date()->format('d-m-Y H:i:s')));
if ($this->request->getParam('date') != "") {
$date = $this->request->getParam('date');
}
if ($this->request->getParam('logfile') != "") {
$logfile = $this->request->getParam('logfile');
}
$logdir = DirectoryList::VAR_DIR.IntegrationConstants::NETSUITE_LOG_DIR;
$files = Glob::glob(BP.'/'. $logdir.$date.'/'."*", GLOB_BRACE);
foreach ($files as $file) {
if ($this->driverFile->isFile($file)) {
$logsArr[] = [
'log' => basename($file),
'selected' => ($logfile == basename($file))? true : false
];
}
}
return $logsArr;
}
public function getDownloadLogsUrl()
{
$downloadUrl = '';
$logfile = '';
$date = date('d-m-Y', strtotime($this->timezone->date()->format('d-m-Y H:i:s')));
if ($this->request->getParam('date') != "") {
$date = $this->request->getParam('date');
}
if ($this->request->getParam('logfile') != "") {
$logfile = $this->request->getParam('logfile');
}
$downloadUrl = $this->getUrl('caratlane/logviewer/downloadlogs', ['date' => $date, 'logfile' => $logfile]);
return $downloadUrl;
}
public function getClearLogsUrl()
{
$downloadUrl = '';
$logfile = '';
$date = date('d-m-Y', strtotime($this->timezone->date()->format('d-m-Y H:i:s')));
if ($this->request->getParam('date') != "") {
$date = $this->request->getParam('date');
}
if ($this->request->getParam('logfile') != "") {
$logfile = $this->request->getParam('logfile');
}
$downloadUrl = $this->getUrl('caratlane/logviewer/clearlogs', ['date' => $date, 'logfile' => $logfile]);
return $downloadUrl;
}
public function getLogFileContent()
{
$contents = '';
$logsArr = [];
$logfile = '';
$date = date('d-m-Y', strtotime($this->timezone->date()->format('d-m-Y H:i:s')));
if ($this->request->getParam('date') != "") {
$date = $this->request->getParam('date');
}
if ($this->request->getParam('logfile') != "") {
$logfile = $this->request->getParam('logfile');
}
$file = BP . '/' . DirectoryList::VAR_DIR . IntegrationConstants::NETSUITE_LOG_DIR . $date .'/'.$logfile;
if ($this->driverFile->isExists($file)) {
try {
$contents = nl2br($this->driverFile->fileGetContents($file));
} catch (FileSystemException $e) {
$contents = 'Error: '. $e->getMessage();
}
}
return $contents;
}
}
@@ -0,0 +1,96 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\Logviewer;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Filesystem\DirectoryList;
use Caratlane\NetSuite\Helper\IntegrationConstants;
class ClearLogs extends \Magento\Backend\App\Action
{
const MENU_ID = 'Caratlane_NetSuite::log';
/**
* @var \Magento\Framework\App\Response\Http\FileFactory
*/
protected $fileFactory;
/**
* @var \Magento\Framework\Filesystem\Driver\File
*/
protected $fileDriver;
/**
* @var \Magento\Framework\Filesystem
*/
protected $fileSystem;
/**
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
*/
protected $timezone;
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\App\Response\Http\FileFactory $fileFactory,
\Magento\Framework\Filesystem\Driver\File $fileDriver,
\Magento\Framework\Filesystem $fileSystem,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone
) {
$this->fileFactory = $fileFactory;
$this->fileDriver = $fileDriver;
$this->fileSystem = $fileSystem;
$this->timezone = $timezone;
parent::__construct($context);
}
public function execute()
{
$contents = '';
$today = $this->timezone->date()->format('d-m-Y');
$date = $this->getRequest()->getParam('date');
$logfile = $this->getRequest()->getParam('logfile');
if ($date == "") {
$date = $today;
}
if ($logfile == '') {
$this->messageManager->addErrorMessage(__('Please select log first and try again!'));
$this->_redirect('caratlane/logviewer/index');
return;
}
$filePath = IntegrationConstants::NETSUITE_LOG_DIR.$date.'/'.$logfile;
$varDir = $this->fileSystem->getDirectoryRead(DirectoryList::VAR_DIR);
$fileAbsolutePath = $varDir->getAbsolutePath($filePath);
if ($this->fileDriver->isExists($fileAbsolutePath)) {
$f = $this->fileDriver->fileOpen($fileAbsolutePath, "r+");
if ($f !== false) {
ftruncate($f, 0);
$this->fileDriver->fileClose($f);
}
$this->messageManager->addSuccessMessage(__('Logfile cleaned successfully.'));
$this->_redirect('caratlane/logviewer/index');
} else {
$this->messageManager->addErrorMessage(__('Log file not exist!'));
$this->_redirect('caratlane/logviewer/index');
return;
}
}
/**
* @return bool
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed(static::MENU_ID);
}
}
@@ -0,0 +1,95 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\Logviewer;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\Filesystem\DirectoryList;
use Caratlane\NetSuite\Helper\IntegrationConstants;
/**
* DownloadLogs log from controller
*/
class DownloadLogs extends \Magento\Backend\App\Action
{
const MENU_ID = 'Caratlane_NetSuite::log';
/**
* @var \Magento\Framework\App\Response\Http\FileFactory
*/
protected $fileFactory;
/**
* @var \Magento\Framework\Filesystem\Driver\File
*/
protected $fileDriver;
/**
* @var \Magento\Framework\Filesystem
*/
protected $fileSystem;
/**
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
*/
protected $timezone;
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\App\Response\Http\FileFactory $fileFactory,
\Magento\Framework\Filesystem\Driver\File $fileDriver,
\Magento\Framework\Filesystem $fileSystem,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $timezone
) {
$this->fileFactory = $fileFactory;
$this->fileDriver = $fileDriver;
$this->fileSystem = $fileSystem;
$this->timezone = $timezone;
parent::__construct($context);
}
public function execute()
{
$today = $this->timezone->date()->format('d-m-Y');
$date = $this->getRequest()->getParam('date');
$logfile = $this->getRequest()->getParam('logfile');
if ($date == "") {
$date = $today;
}
if ($logfile == '') {
$this->messageManager->addErrorMessage(__('Please select log first and try again!'));
$this->_redirect('caratlane/logviewer/index');
return;
}
$filePath = IntegrationConstants::NETSUITE_LOG_DIR.$date.'/'.$logfile;
$varDir = $this->fileSystem->getDirectoryRead(DirectoryList::VAR_DIR);
$fileAbsolutePath = $varDir->getAbsolutePath($filePath);
if ($this->fileDriver->isExists($fileAbsolutePath)) {
$content['type'] = 'filename';
$content['value'] = $fileAbsolutePath;
$content['rm'] = 0;
return $this->fileFactory->create($logfile, $content, DirectoryList::VAR_DIR);
} else {
$this->messageManager->addErrorMessage(__('Log file not exist!'));
$this->_redirect('caratlane/logviewer/index');
return;
}
}
/**
* @return bool
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed(static::MENU_ID);
}
}
@@ -0,0 +1,55 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\Logviewer;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;
/**
* Class Index from controller
*/
class Index extends Action implements HttpGetActionInterface
{
const MENU_ID = 'Caratlane_NetSuite::log';
/**
* @var PageFactory
*/
protected $resultPageFactory;
/**
* Index constructor.
*
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
}
/**
* Load the page defined in view/adminhtml/layout/caratlane_logviewer_index.xml
*
* @return Page
*/
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu(static::MENU_ID);
$resultPage->getConfig()->getTitle()->prepend(__('Debug Log Viewer'));
return $resultPage;
}
}
@@ -0,0 +1,58 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
/**
* Class ClearHistory from controller
*/
class ClearHistory extends \Magento\Backend\App\Action
{
const MENU_ID = 'Caratlane_NetSuite::log';
protected $resultPageFactory;
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Caratlane\NetSuite\Model\NetSuiteFactory $masterlogsFactory
) {
$this->resultPageFactory = $resultPageFactory;
$this->masterlogsFactory = $masterlogsFactory;
parent::__construct($context);
}
public function execute()
{
$model = $this->masterlogsFactory->create();
if (!count($model->getCollection()->getData())) {
$this->messageManager->addErrorMessage(__('There is no records to delete.'));
$this->_redirect('caratlane/netsuite/index');
return;
}
if (count($model->getCollection()->getData())) {
$connection = $model->getCollection()->getConnection();
$tableName = $model->getCollection()->getMainTable();
$connection->truncateTable($tableName);
}
$this->messageManager->addSuccessMessage(__('History has been removed successfully.'));
$this->_redirect('caratlane/netsuite/index');
}
/**
* @return bool
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed(static::MENU_ID);
}
}
@@ -0,0 +1,67 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
/**
* Class ClearTrackOrderHistory
*/
class ClearOrderstatusHistory extends \Magento\Backend\App\Action
{
const MENU_ID = 'Caratlane_NetSuite::orderupdate';
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $resultPageFactory;
/**
* @var \Caratlane\NetSuite\Model\NetSuiteOrdersUpdateFactory
*/
protected $netSuiteOrdersUpdate;
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Caratlane\NetSuite\Model\NetSuiteOrdersUpdateFactory $netSuiteOrdersUpdate
) {
$this->resultPageFactory = $resultPageFactory;
$this->netSuiteOrdersUpdate = $netSuiteOrdersUpdate;
parent::__construct($context);
}
public function execute()
{
$model = $this->netSuiteOrdersUpdate->create();
if (!count($model->getCollection()->getData())) {
$this->messageManager->addErrorMessage(__('There is no records to delete.'));
$this->_redirect('caratlane/netsuite/orderupdate');
return;
}
if (count($model->getCollection()->getData())) {
$connection = $model->getCollection()->getConnection();
$tableName = $model->getCollection()->getMainTable();
$connection->truncateTable($tableName);
}
$this->messageManager->addSuccessMessage(__('History has been removed successfully.'));
$this->_redirect('caratlane/netsuite/orderupdate');
}
/**
* @return bool
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed(static::MENU_ID);
}
}
@@ -0,0 +1,67 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
/**
* Class ClearShipmentHistory from controller
*/
class ClearShipmentHistory extends \Magento\Backend\App\Action
{
const MENU_ID = 'Caratlane_NetSuite::createshipment';
/**
* @var \Magento\Framework\View\Result\PageFactory
*/
protected $resultPageFactory;
/**
* @var \Caratlane\NetSuite\Model\NetsuiteShipmentsFactory
*/
protected $netsuiteShipments;
public function __construct(
\Magento\Backend\App\Action\Context $context,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
\Caratlane\NetSuite\Model\NetsuiteShipmentsFactory $netsuiteShipments
) {
$this->resultPageFactory = $resultPageFactory;
$this->netsuiteShipments = $netsuiteShipments;
parent::__construct($context);
}
public function execute()
{
$model = $this->netsuiteShipments->create();
if (!count($model->getCollection()->getData())) {
$this->messageManager->addErrorMessage(__('There is no records to delete.'));
$this->_redirect('caratlane/netsuite/createshipments');
return;
}
if (count($model->getCollection()->getData())) {
$connection = $model->getCollection()->getConnection();
$tableName = $model->getCollection()->getMainTable();
$connection->truncateTable($tableName);
}
$this->messageManager->addSuccessMessage(__('History has been removed successfully.'));
$this->_redirect('caratlane/netsuite/createshipments');
}
/**
* @return bool
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed(static::MENU_ID);
}
}
@@ -0,0 +1,68 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;
class CreateShipments extends Action implements HttpGetActionInterface
{
const MENU_ID = 'Caratlane_NetSuite::createshipment';
/**
* @var PageFactory
*/
protected $resultPageFactory;
/**
* Index constructor.
*
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
}
/**
* Load the page defined in view/adminhtml/layout/netsuite_logviewer_index.xml
*
* @return Page
*/
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu(static::MENU_ID);
$resultPage->getConfig()->getTitle()->prepend(__('Shipment Logs'));
return $resultPage;
}
}
@@ -0,0 +1,74 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
use Caratlane\NetSuite\Model\NetsuiteShipments;
/**
* Class CreateShippmentView from controller
*/
class CreateShippmentView extends \Magento\Backend\App\Action
{
const MENU_ID = 'Caratlane_NetSuite::createshipment';
/**
* @var Caratlane\NetSuite\Model\NetsuiteShipments
*/
protected $netsuiteShipments;
/**
* @var PageFactory
*/
protected $resultPageFactory = false;
/**
* Index constructor.
*
* @param \Magento\Backend\App\Action\Context $context
* @param NetsuiteShipments $netsuiteShipments
* @param PageFactory $resultPageFactory
*/
public function __construct(
NetsuiteShipments $netsuiteShipments,
\Magento\Backend\App\Action\Context $context
) {
$this->netsuiteShipments = $netsuiteShipments;
parent::__construct($context);
}
/**
* Load the page defined in view/adminhtml/layout/netsuit_logviewer_index.xml
*
* @return Page
*/
public function execute()
{
$entity_id = $this->getRequest()->getParam('entity_id');
if ($entity_id > 0) {
$model = $this->netsuiteShipments->load($entity_id);
if ($model) {
$resJson = $model->getData('json_data');
header('Content-Type: application/json');
http_response_code(200);
exit($resJson);
}
}
$this->messageManager->addErrorMessage(__('No record found!'));
$this->_redirect('caratlane/netsuite/createshipments');
}
/**
* Allow modules
* @return Int
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Caratlane_NetSuite::createshipment');
}
}
@@ -0,0 +1,56 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;
class Index extends Action implements HttpGetActionInterface
{
const MENU_ID = 'Caratlane_NetSuite::log';
/**
* @var PageFactory
*/
protected $resultPageFactory;
/**
* Index constructor.
*
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
}
/**
* Load the page defined in view/adminhtml/layout/caratlane_netswite_index.xml
*
* @return Page
*/
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu(static::MENU_ID);
$resultPage->getConfig()->getTitle()->prepend(__('NetSuite: Orders Logs'));
return $resultPage;
}
public function pushOrders($ordersJsonData)
{
$this->helper->pushCurlData($ordersJsonData);
}
}
@@ -0,0 +1,55 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Backend\App\Action\Context;
use Magento\Ui\Component\MassAction\Filter;
use Caratlane\NetSuite\Model\ResourceModel\NetSuite\CollectionFactory;
/**
* Class MassDelete from controller
*/
class MassDelete extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
const MENU_ID = 'Caratlane_NetSuite::log';
/**
* @param Context $context
* @param Filter $filter
* @param CollectionFactory $collectionFactory
*/
public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory)
{
$this->filter = $filter;
$this->collectionFactory = $collectionFactory;
parent::__construct($context);
}
/**
* Execute action
*
* @return \Magento\Backend\Model\View\Result\Redirect
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
public function execute()
{
$collection = $this->filter->getCollection($this->collectionFactory->create());
$collectionSize = $collection->getSize();
foreach ($collection as $page) {
$page->delete();
}
$this->messageManager->addSuccessMessage(__('A total of %1 record(s) have been deleted.', $collectionSize));
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
return $resultRedirect->setPath('*/*/');
}
}
@@ -0,0 +1,68 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;
class OrderUpdate extends Action implements HttpGetActionInterface
{
const MENU_ID = 'Caratlane_NetSuite::orderupdate';
/**
* @var PageFactory
*/
protected $resultPageFactory;
/**
* Index constructor.
*
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
}
/**
* Load the page defined in view/adminhtml/layout/netsuite_logviewer_index.xml
*
* @return Page
*/
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu(static::MENU_ID);
$resultPage->getConfig()->getTitle()->prepend(__('Order Update Logs'));
return $resultPage;
}
}
@@ -0,0 +1,53 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Backend\App\Action\Context;
use Magento\Ui\Component\MassAction\Filter;
use Caratlane\NetSuite\Model\ResourceModel\NetSuiteOrdersUpdate\CollectionFactory;
/**
* Class OrderUpdateMassDelete from controller
*/
class OrderupdateMassDelete extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
const MENU_ID = 'Caratlane_NetSuite::orderupdate';
/**
* @param Context $context
* @param Filter $filter
* @param CollectionFactory $collectionFactory
*/
public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory)
{
$this->filter = $filter;
$this->collectionFactory = $collectionFactory;
parent::__construct($context);
}
/**
* Execute action
*
* @return \Magento\Backend\Model\View\Result\Redirect
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
public function execute()
{
$collection = $this->filter->getCollection($this->collectionFactory->create());
$collectionSize = $collection->getSize();
foreach ($collection as $page) {
$page->delete();
}
$this->messageManager->addSuccessMessage(__('A total of %1 record(s) have been deleted.', $collectionSize));
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$this->_redirect('caratlane/netsuite/orderupdate');
}
}
@@ -0,0 +1,65 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
/**
* Class ViewJson
*/
class ResponseView extends \Magento\Backend\App\Action
{
const MENU_ID = 'Caratlane_NetSuite::log';
/**
* @var PageFactory
*/
protected $resultPageFactory = false;
/**
* Index constructor.
*
* @param \Magento\Backend\App\Action\Context $context
* @param PageFactory $resultPageFactory
*/
/*public function __construct(
\Magento\Backend\App\Action\Context $context
) {
parent::__construct($context);
}*/
/**
* Load the page to view response in json format
*
* @return Page
*/
public function execute()
{
$entity_id = $this->getRequest()->getParam('entity_id');
if ($entity_id > 0) {
$model = $this->_objectManager->create(\Caratlane\NetSuite\Model\NetSuite::class)->load($entity_id);
if ($model) {
$resJson = $model->getData('response_info');
header('Content-Type: application/json');
http_response_code(200);
exit($resJson);
}
}
$this->messageManager->addErrorMessage(__('No record found!'));
$this->_redirect('caratlane/netsuite/index');
}
/**
* Allow modules
* @return Int
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Caratlane_NetSuite::log');
}
}
@@ -0,0 +1,53 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Backend\App\Action\Context;
use Magento\Ui\Component\MassAction\Filter;
use Caratlane\NetSuite\Model\ResourceModel\NetsuiteShipments\CollectionFactory;
/**
* Class ShipmentMassDelete from controller
*/
class ShipmentMassDelete extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
const MENU_ID = 'Caratlane_NetSuite::createshipment';
/**
* @param Context $context
* @param Filter $filter
* @param CollectionFactory $collectionFactory
*/
public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory)
{
$this->filter = $filter;
$this->collectionFactory = $collectionFactory;
parent::__construct($context);
}
/**
* Execute action
*
* @return \Magento\Backend\Model\View\Result\Redirect
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
public function execute()
{
$collection = $this->filter->getCollection($this->collectionFactory->create());
$collectionSize = $collection->getSize();
foreach ($collection as $page) {
$page->delete();
}
$this->messageManager->addSuccessMessage(__('A total of %1 record(s) have been deleted.', $collectionSize));
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$this->_redirect('caratlane/netsuite/createshipments');
}
}
@@ -0,0 +1,53 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Framework\Controller\ResultFactory;
use Magento\Backend\App\Action\Context;
use Magento\Ui\Component\MassAction\Filter;
use Caratlane\NetSuite\Model\ResourceModel\NetsuiteUpdateinvoicepdf\CollectionFactory;
/**
* Class ShipmentMassDelete from controller
*/
class UpdateinvoiceMassDelete extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
const MENU_ID = 'Caratlane_NetSuite::updateinvoicepdf';
/**
* @param Context $context
* @param Filter $filter
* @param CollectionFactory $collectionFactory
*/
public function __construct(Context $context, Filter $filter, CollectionFactory $collectionFactory)
{
$this->filter = $filter;
$this->collectionFactory = $collectionFactory;
parent::__construct($context);
}
/**
* Execute action
*
* @return \Magento\Backend\Model\View\Result\Redirect
* @throws \Magento\Framework\Exception\LocalizedException|\Exception
*/
public function execute()
{
$collection = $this->filter->getCollection($this->collectionFactory->create());
$collectionSize = $collection->getSize();
foreach ($collection as $page) {
$page->delete();
}
$this->messageManager->addSuccessMessage(__('A total of %1 record(s) have been deleted.', $collectionSize));
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$this->_redirect('caratlane/netsuite/updateinvoicepdf');
}
}
@@ -0,0 +1,68 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\View\Result\Page;
use Magento\Framework\View\Result\PageFactory;
class Updateinvoicepdf extends Action implements HttpGetActionInterface
{
const MENU_ID = 'Caratlane_NetSuite::updateinvoicepdf';
/**
* @var PageFactory
*/
protected $resultPageFactory;
/**
* Index constructor.
*
* @param Context $context
* @param PageFactory $resultPageFactory
*/
public function __construct(
Context $context,
PageFactory $resultPageFactory
) {
parent::__construct($context);
$this->resultPageFactory = $resultPageFactory;
}
/**
* Load the page defined in view/adminhtml/layout/netsuite_logviewer_index.xml
*
* @return Page
*/
public function execute()
{
$resultPage = $this->resultPageFactory->create();
$resultPage->setActiveMenu(static::MENU_ID);
$resultPage->getConfig()->getTitle()->prepend(__('Update Invoice PDF'));
return $resultPage;
}
}
@@ -0,0 +1,74 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
use Caratlane\NetSuite\Model\NetsuiteUpdateinvoicepdf;
/**
* Class CreateShippmentView
*/
class Updateinvoicepdfview extends \Magento\Backend\App\Action
{
const MENU_ID = 'Caratlane_NetSuite::updateinvoicepdf';
/**
* @var Caratlane\NetSuite\Model\NetsuiteUpdateinvoicepdf
*/
protected $netsuiteUpdateinvoicepdf;
/**
* @var PageFactory
*/
protected $resultPageFactory = false;
/**
* Index constructor.
*
* @param \Magento\Backend\App\Action\Context $context
* @param NetsuiteUpdateinvoicepdf $netsuiteUpdateinvoicepdf
* @param PageFactory $resultPageFactory
*/
public function __construct(
NetsuiteUpdateinvoicepdf $netsuiteUpdateinvoicepdf,
\Magento\Backend\App\Action\Context $context
) {
$this->netsuiteUpdateinvoicepdf = $netsuiteUpdateinvoicepdf;
parent::__construct($context);
}
/**
* Load the page defined in view/adminhtml/layout/netsuit_logviewer_index.xml
*
* @return Page
*/
public function execute()
{
$entity_id = $this->getRequest()->getParam('entity_id');
if ($entity_id > 0) {
$model = $this->netsuiteUpdateinvoicepdf->load($entity_id);
if ($model) {
$resJson = $model->getData('json_data');
header('Content-Type: application/json');
http_response_code(200);
exit($resJson);
}
}
$this->messageManager->addErrorMessage(__('No record found!'));
$this->_redirect('caratlane/netsuite/updateinvoicepdf');
}
/**
* Allow modules
* @return Int
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Caratlane_NetSuite::updateinvoicepdf');
}
}
@@ -0,0 +1,69 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\NetSuite;
use Magento\Backend\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
/**
* Class ViewJson
*/
class View extends \Magento\Backend\App\Action
{
const MENU_ID = 'Caratlane_NetSuite::log';
/**
* @var PageFactory
*/
protected $resultPageFactory = false;
/**
* Index constructor.
*
* @param \Magento\Backend\App\Action\Context $context
* @param PageFactory $resultPageFactory
*/
/*public function __construct(
\Magento\Backend\App\Action\Context $context
) {
parent::__construct($context);
}*/
/**
* Load the page defined in json form
*
* @return Page
*/
public function execute()
{
$entity_id = $this->getRequest()->getParam('entity_id');
if ($entity_id > 0) {
$model = $this->_objectManager->create(\Caratlane\NetSuite\Model\NetSuite::class)->load($entity_id);
if ($model) {
$resJson = $model->getData('request_info');
header('Content-Type: application/json');
http_response_code(200);
exit($resJson);
}
}
$this->messageManager->addErrorMessage(__('No record found!'));
$this->_redirect('caratlane/netsuite/index');
}
/**
* Allow modules
*
* @return Int
*/
protected function _isAllowed()
{
return $this->_authorization->isAllowed('Caratlane_NetSuite::log');
}
}
@@ -0,0 +1,76 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Controller\Adminhtml\Order;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
use Magento\Backend\App\Action\Context;
use Magento\Ui\Component\MassAction\Filter;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
use Magento\Sales\Api\OrderManagementInterface;
class PushNetSuite extends \Magento\Sales\Controller\Adminhtml\Order\AbstractMassAction
{
/**
* @var OrderManagementInterface
*/
protected $orderManagement;
/**
* @param Context $context
* @param Filter $filter
* @param CollectionFactory $collectionFactory
* @param OrderManagementInterface $orderManagement
* @param \Caratlane\NetSuite\Model\NetSuiteFactory $netsuitefactory
*/
public function __construct(
Context $context,
Filter $filter,
CollectionFactory $collectionFactory,
\Caratlane\NetSuite\Model\NetSuiteFactory $netsuitefactory
) {
parent::__construct($context, $filter);
$this->collectionFactory = $collectionFactory;
$this->netsuitefactory = $netsuitefactory;
}
/**
* Hold selected orders
*
* @param AbstractCollection $collection
* @return \Magento\Backend\Model\View\Result\Redirect
*/
protected function massAction(AbstractCollection $collection)
{
$countOrder = 0;
foreach ($collection->getItems() as $order) {
if (!$order->getEntityId()) {
continue;
}
$order->setNetsuiteMaxAttempt(0);
$order->setPushToNetsuite(0);
$order->setNetsuiteCreatedAt(null);
$order->setNetsuiteId(null);
$order->save();
$countOrder++;
}
$countNonPushOrder = $collection->count() - $countOrder;
if ($countNonPushOrder && $countOrder) {
$this->messageManager->addError(__('%1 order(s) were not pushed to NetSuite.', $countNonPushOrder));
} elseif ($countNonPushOrder) {
$this->messageManager->addError(__('No order(s) were reset to NetSuite.'));
}
if ($countOrder) {
$this->messageManager->addSuccess(__('Reset %1 order(s) for NetSuite orders.', $countOrder));
}
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath($this->getComponentRefererUrl());
return $resultRedirect;
}
}
+137
View File
@@ -0,0 +1,137 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Cron;
use Caratlane\NetSuite\Helper\Data as Helper;
use Caratlane\NetSuite\Logger\Logger;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Filesystem\Glob;
class ClearLogs
{
/**
* @var \Magento\Framework\Filesystem\Driver\File
*/
protected $fileDriver;
/**
* @var Helper
*/
protected $helper;
/**
* @var Logger $logger
*/
protected $logger;
/**
* @var TimezoneInterface
*/
protected $timezone;
/**
* @var ResourceConnection $resourceConnection
*/
protected $resourceConnection;
/**
* @param Helper $helper
* @param Logger $logger
*/
public function __construct(
Helper $helper,
Logger $logger,
TimezoneInterface $timezone,
\Magento\Framework\App\Response\Http\FileFactory $fileFactory,
ResourceConnection $resourceConnection
) {
$this->helper = $helper;
$this->logger = $logger;
$this->timezone = $timezone;
$this->fileFactory = $fileFactory;
$this->resConn = $resourceConnection;
}
public function execute()
{
$days = \Caratlane\NetSuite\Helper\IntegrationConstants::CLEAR_LOG_DAYS;
if ($days > 0) {
$curdate = $this->timezone->date()->format('d-m-Y H:i:s');
$dateBefore = date('d-m-Y', strtotime($curdate . ' -' . $days . 'days'));
$currentdate = $this->timezone->date()->format('Y-m-d H:i:s');
$dateTimeBefore = date('Y-m-d H:i:s', strtotime($currentdate . ' -' . $days . 'days'));
$connection = $this->resConn->getConnection(\Magento\Framework\App\ResourceConnection::DEFAULT_CONNECTION);
$connection->delete(
$connection->getTableName(\Caratlane\NetSuite\Helper\IntegrationConstants::TBL_MASTER_LOGS),
[
'created_at <= ?' => $dateTimeBefore,
'status = ?' => '1'
]
);
$this->deleteMagentoLogs($days);
$this->removeNetSuiteLogDir($dateBefore);
}
}
private function removeNetSuiteLogDir($dateBefore)
{
$count = 0;
do {
$this->deleteDirectory(BP . '/' . DirectoryList::VAR_DIR . '/netsuite/' . $dateBefore);
$this->deleteDirectory(BP . '/' . DirectoryList::VAR_DIR . '/netsuite/' . $dateBefore);
$dateBefore = date('d-m-Y', strtotime($dateBefore . ' -1 days'));
$count++;
} while ($count < 10);
}
private function deleteMagentoLogs($days)
{
$files = Glob::glob(BP . '/' . DirectoryList::VAR_DIR . '/netsuite/'."*.{log,gz}", GLOB_BRACE);
$now = time();
foreach ($files as $file) {
if ($this->fileFactory->isFile($file)) {
if ($now - filemtime($file) >= 60 * 60 * 24 * $days) {
$this->fileFactory->deleteFile($file);
}
}
}
}
private function deleteDirectory($dir)
{
if (!$this->fileFactory->isExists($dir)) {
return true;
}
if (!$this->fileFactory->isDirectory($dir)) {
return $this->fileFactory->deleteDirectory($dir);
}
foreach (scandir($dir) as $item) {
if ($item == '.' || $item == '..') {
continue;
}
if (!$this->deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
return false;
}
}
return $this->fileFactory->deleteDirectory($dir);
}
}
+49
View File
@@ -0,0 +1,49 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Cron;
class PushSalesOrder
{
/**
* @var helper
*/
private $helper;
/**
* helper helper.
* @param \Caratlane\NetSuite\Helper\Data $helper
*/
public function __construct(\Caratlane\NetSuite\Helper\Data $helper)
{
$this->helper = $helper;
}
/**
* Execute cron method
*/
public function execute()
{
if ($this->helper->getNetSuiteIsEnabled() && $this->helper->getNetSuiteOrderPushEnabled()) {
$orderCollection = $this->helper->getOrderCollection();
// if ($orderCollection) {
$this->pushOrders($orderCollection);
// }
}
return true;
}
/**
* call curl method to push order
*/
public function pushOrders($ordersJsonData)
{
$this->helper->pushCurlData($ordersJsonData);
}
}
+607
View File
@@ -0,0 +1,607 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Store\Model\ScopeInterface;
class Data extends AbstractHelper
{
const XML_PATH_NETSUITE_ENABLE = 'netsuite/general/enable';
const XML_PATH_OAUTH_ORDER_PUSH_ENABLE = 'netsuite/cronScheduled/enable';
const XML_PATH_NETSUITE_COUNT_FROM = 'netsuite/cronScheduled/netsuite_count_from';
const XML_PATH_NETSUITE_MAX_ATTEMPT = 'netsuite/cronScheduled/netsuite_max_attempt';
const XML_PATH_TRACK_SHIPMENT_ENABLE = 'netsuite/setTrackShipmentsFrequency/enable';
const XML_PATH_CREATE_SHIPMENT_ENABLE = 'netsuite/setCreateShipmentsFrequency/enable';
const XML_PATH_ORDER_UPDATE_ENABLE = 'netsuite/setOrdersUpdateFrequency/enable';
const XML_PATH_UPDATE_INVOICEPDF_ENABLE = 'netsuite/setUpdateInvoicepdfFrequency/enable';
const ORDER_STATUS = 'pending';
/**
* @var storeManager
*/
protected $storeManager;
/**
* @var scopeConfig
*/
protected $scopeConfig;
/**
* @var orderCollectionFactory
*/
protected $orderCollectionFactory;
/**
* @var date
*/
protected $_date;
/**
* @var customerFactory
*/
protected $customerFactory;
/**
* @var curl
*/
public $curl;
/**
* @var \Caratlane\NetSuite\Logger\Logger
*/
protected $_logger;
/**
* @var netSuiteFactory
*/
protected $netSuiteFactory;
/**
* @var messageFactory
*/
protected $messageFactory;
/**
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $date
* @param \Magento\Customer\Model\CustomerFactory $customerFactory
* @param \Magento\Framework\HTTP\Client\Curl $curl
* @param \Caratlane\NetSuite\Logger\Logger $logger
* @param \Caratlane\NetSuite\Model\NetSuiteFactory $netSuiteFactory
* @param \Caratlane\NetSuite\Model\Oauth $oauth
* @param \Magento\Sales\Api\Data\TransactionSearchResultInterfaceFactory $transactions
* @param \Magento\GiftMessage\Model\MessageFactory $messageFactory
* @param \Magento\Directory\Model\CountryFactory $countryFactory
**/
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory,
\Magento\Framework\Stdlib\DateTime\DateTime $date,
\Magento\Customer\Model\CustomerFactory $customerFactory,
\Magento\Framework\HTTP\Client\Curl $curl,
\Caratlane\NetSuite\Logger\Logger $logger,
\Caratlane\NetSuite\Model\NetSuiteFactory $netSuiteFactory,
\Caratlane\NetSuite\Model\Oauth $oauth,
\Magento\Sales\Api\Data\TransactionSearchResultInterfaceFactory $transactions,
\Magento\GiftMessage\Model\MessageFactory $messageFactory,
// \StripeIntegration\Payments\Helper\Generic $helper,
// \StripeIntegration\Payments\Helper\Api $api,
\Magento\Directory\Model\CountryFactory $countryFactory,
\Magento\Catalog\Api\ProductRepositoryInterface $productRepository
) {
$this->store_manager = $storeManager;
$this->scope_config = $scopeConfig;
$this->orderCollectionFactory = $orderCollectionFactory;
$this->_date = $date;
$this->customerFactory = $customerFactory;
$this->curl = $curl;
$this->_logger = $logger;
$this->netSuiteFactory = $netSuiteFactory;
$this->oauth = $oauth;
$this->transactions = $transactions;
$this->messageFactory = $messageFactory;
// $this->helper = $helper;
// $this->api = $api;
$this->_countryFactory = $countryFactory;
$this->productRepository = $productRepository;
}
/**
* Get NetSuite API URL
*
* @return string
*/
public function getApiUrl()
{
return $this->getConfigValue(self::XML_PATH_NETSUITE_API_URL);
}
/**
* Get NetSuite
*
* @return Int
*/
public function getNetSuiteIsEnabled()
{
return $this->getConfigValue(self::XML_PATH_NETSUITE_ENABLE);
}
/**
* Get NetSuite Order push enable
*
* @return Int
*/
public function getNetSuiteOrderPushEnabled()
{
return $this->getConfigValue(self::XML_PATH_OAUTH_ORDER_PUSH_ENABLE);
}
/**
* Get NetSuite create shipment enable
*
* @return Int
*/
public function getNetsuiteCreateShipmentEnabled()
{
return $this->getConfigValue(self::XML_PATH_CREATE_SHIPMENT_ENABLE);
}
/**
* Get NetSuite track shipment enable
*
* @return Int
*/
public function getNetsuiteTrackSHipmentEnabled()
{
return $this->getConfigValue(self::XML_PATH_TRACK_SHIPMENT_ENABLE);
}
/**
* Get NetSuite track Order enable
*
* @return Int
*/
public function getNetsuiteOrdersUpdateEnabled()
{
return $this->getConfigValue(self::XML_PATH_ORDER_UPDATE_ENABLE);
}
/**
* Get NetSuite track Order enable
*
* @return Int
*/
public function getNetsuiteUpdateInvoicepdfEnabled()
{
return $this->getConfigValue(self::XML_PATH_UPDATE_INVOICEPDF_ENABLE);
}
/**
* Get XML_PATH_NETSUITE_MAX_ATTEMPT
*
* @return int
*/
public function getNetSuiteMaxAttempt()
{
return $this->getConfigValue(self::XML_PATH_NETSUITE_MAX_ATTEMPT);
}
/**
* Get calculate date for order fatch
*
* @return date time
*/
public function getNetSuiteCountFromDate()
{
$dayes = $this->getConfigValue(self::XML_PATH_NETSUITE_COUNT_FROM);
$currenctDate = $this->_date->date('Y-m-d H:i:s');
return $this->_date->date('Y-m-d H:i:s', (strtotime('-'.$dayes.' day', strtotime($currenctDate))));
}
/**
* Get calculate date for order fatch
*
* @return date time
*/
public function getCurrentDate()
{
return $this->_date->date('Y-m-d H:i:s');
}
/**
* Get NetSuite Config value
*
* @return string
*/
public function getConfigValue($path)
{
$store = $this->getStoreId();
$config_data = $this->scope_config->getValue($path, ScopeInterface::SCOPE_STORE, $store);
return $config_data;
}
/**
* Get store id
* @return int
*/
public function getStoreId()
{
return $this->store_manager->getStore()->getStoreId();
}
/**
* Get order collection
* @return Collection
*/
public function getOrderCollection()
{
$collection = $this->orderCollectionFactory->create();
$metSuiteMaxAttempt = $this->getNetSuiteMaxAttempt();
$startDate = $this->getNetSuiteCountFromDate();
$endDate = $this->_date->date('Y-m-d H:i:s');
$collection->addAttributeToFilter('created_at', ['from'=>$startDate, 'to'=>$endDate]);
$collection->getSelect()->where('(push_to_netsuite!=1 or `netsuite_id` IS NULL) and netsuite_max_attempt < '.$metSuiteMaxAttempt .' and status="'. self::ORDER_STATUS .'"');
return $collection;
}
/**
* set curl data push data
*/
public function pushCurlData($collection)
{
$ordersDetails = [];
foreach ($collection as $order) {
$ordersDetails['Customer_Details'] = $this->setCustomerDetails($order);
$ordersDetails['Order_Details'] = $this->setOrderDetails($order);
$jsonData = json_encode($ordersDetails);
$this->curl($jsonData, $order);
}
}
/**
* set customer detail in array
*
* @return array
*/
public function setCustomerDetails($order)
{
$customer = $this->customerFactory->create()->load($order->getCustomerId());
$shippingAdd = $order->getShippingAddress();
$billingAdd = $order->getBillingAddress();
$billingStreet = $billingAdd->getStreet();
$shippingStreet = $shippingAdd->getStreet();
$billingStreet2 = isset($billingStreet[1])?$billingStreet[1]:'';
$shippingStreet2 = isset($shippingStreet[1])?$shippingStreet[1]:'';
return ['CL_Magento_Id'=>$order->getCustomerId(),
'CL_Customer_FName'=>$order->getCustomerFirstname(),
'CL_Customer_LName'=>$order->getCustomerLastname(),
'CL_Customer_Email'=>$order->getCustomerEmail(),
'CL_Customer_Mobile_No'=>$billingAdd['telephone'],
'CL_Netsuite_ID'=>$customer->getNetsuiteId(),
'CL_Billingaddress'=>[
[
'CL_Billing_isdefault'=>true,
'CL_Billing_Addr_Line_1'=>$billingStreet[0],
'CL_Billing_Addr_Line_2'=>$billingStreet2,
'CL_Billing_Pincode'=>$billingAdd->getPostcode(),
'CL_Billing_City'=>$billingAdd->getCity(),
'CL_Billing_State'=>$billingAdd->getRegion(),
'CL_Billing_Country'=>$this->getCountryName($billingAdd->getCountryId())
]
]
,
'CL_Shippingaddress'=>[
[
'CL_Shipping_isdefault'=>true,
'CL_Shipping_Addr_Line_1'=>$shippingStreet[0],
'CL_Shipping_Addr_Line_2'=>$shippingStreet2,
'CL_Shipping_Pincode'=>$shippingAdd->getPostcode(),
'CL_Shipping_City'=>$shippingAdd->getCity(),
'CL_Shipping_State'=>$shippingAdd->getRegion(),
'CL_Shipping_Country'=>$this->getCountryName($shippingAdd->getCountryId())
]
]
];
}
/**
* set order detail in array
* @return array
*/
public function setOrderDetails($order)
{
$items = $this->getOrderItems($order);
$payment = $order->getPayment();
$method = $payment->getMethodInstance();
$methodTitle = $method->getTitle();
$methodcode = $method->getCode();
$message = '';
if ($order->getGiftMessageId()) {
$message = $this->messageFactory->create()->load($order->getGiftMessageId())->getMessage();
}
$paymentMethodType = 'Cash';
$cardTypeId = '';
if ($methodcode=='stripe_payments') {
$paymentMethodType = 'Stripe';
$cardTypeId = $this->getBrand($payment); /// card type id
} elseif ($methodcode=='paypal_express') {
$paymentMethodType = 'Paypal';
$cardTypeId = 'Paypal';
}
$transactionId = $payment->getLastTransId()?$payment->getLastTransId():'';
$shippingAmount = (float)$order->getShippingAmount();
return [
"CL_Order_date"=>$this->_date->date('j-F-Y', strtotime($order->getCreatedAt())),
"CL_Magento_Order_ID"=>$order->getIncrementId(), //order increment id
"CL_Freight_Charges"=> $shippingAmount, //static zero
"CL_Freight_Charges_Tax"=> 0, //static zero
"CL_Freight_Rate_Tax"=> 0, //static zero
"CL_Customer_Pays"=>$order->getGrandTotal(), //Order grand total
"CL_Payment_Method"=>$paymentMethodType,//$methodTitle, //Need to define mapping
"CL_UTR_Number"=>$transactionId, //keep blank
"CL_Payment_amount"=>$order->getGrandTotal(), //Order grand total
"CL_NS_Coupon_Discount"=>abs($order->getDiscountAmount()), //coupon discount total
"CL_Total_Tax"=> $order->getTaxAmount(),
"CL_Card_Type"=>$cardTypeId,
"CL_Source_From"=>'Magento',
"CL_NS_Gift_Message"=>$message, //gift msg need to pass here
//"CL_Expected_Delivery_date"=>$order->getCreatedAt(), //gift msg need to pass here
"CL_NS_Items"=> $items
];
}
/**
* get order items
*
* @return array
*/
public function getOrderItems($order)
{
$items = $order->getAllVisibleItems();
$orderItems = [];
foreach ($items as $item) {
$fromdate = $item->getDeliveryFromDate();
$deliveryFromDate = $fromdate?$this->_date->date('j-F-Y', strtotime($fromdate)):'';
$todate = $item->getDeliveryToDate();
$deliveryToDate = $todate?$this->_date->date('j-F-Y', strtotime($todate)):'';
$itemsProduct = $this->loadMyProduct($item->getSku());
$orderItems[] = [
"CL_NS_SKU"=> $item->getSku(), //product simple sku
"CL_NS_ID" => $itemsProduct->getNetsuiteId(),
"CL_NS_Qty" => $item->getQtyOrdered(), //ordered qty
"CL_NS_Selling_Price" =>$item->getOriginalPrice(),
"CL_NS_Strike_Discount" => $item->getOriginalPrice() - $item->getPrice(),
//original price - final price = discount
'CL_Expected_Delivery_From_Date'=>$deliveryFromDate,
'CL_Expected_Delivery_To_Date'=>$deliveryToDate
];
}
return $orderItems;
}
/*
*get product
* @return string
*/
public function loadMyProduct($sku)
{
return $this->productRepository->get($sku);
}
/**
* spush order detail to netsuite
*
*/
public function curl($jsonData, $order)
{
$url = $this->oauth->getApiUrl().'?script='.$this->oauth->getScript().'&deploy=1';
$oauthCredentials = $this->oauth->getOauthParams();
$requestData = $jsonData;
$this->_logger->writeLog('Request: '.$requestData);
try {
$this->curl->addHeader("Content-Type", "application/json");
$this->curl->addHeader("Authorization", $oauthCredentials);
$this->curl->addHeader("Cookie", "NS_ROUTING_VERSION=LAGGING");
$this->curl->post($url, $jsonData);
$response = $this->curl->getBody();
$this->_logger->writeLog('Response: '.$response);
$response = json_decode($response, true);
$this->updatedOrdersCustomerAndNetSuite($requestData, $response, $order);
} catch (\Exception $e) {
$this->_logger->writeLog("error: ". $e->getMessage(), 'error');
}
}
/**
* update order and customer table and create net entry sales_order table
*
*/
public function updatedOrdersCustomerAndNetSuite($requestData, $response, $order)
{
$cutomerRes = isset($response[0])?$response[0]:'';
$orderRes = isset($response[1])?$response[1]:'';
$cMessage = '';
$oMessage = '';
$cNsCustId= '';
$oMagentoId='';
$oStatus = false;
$cStatus = false;
$oNSSalesOrderID='';
$status = false;
if (!empty($cutomerRes)) {
$cOStatus = $cutomerRes['Customer_Response'][0]['Status'];
if ($cOStatus=='Success') {
$cStatus = true;
}
$cMessage = $cutomerRes['Customer_Response'][0]['Message'];
$cNsCustId = $cutomerRes['Customer_Response'][0]['NS_CustID'];
}
if (!empty($orderRes)) {
$oOStatus = $orderRes['Order_Response'][0]['Status'];
if ($oOStatus=='Success') {
$oStatus = true;
}
$oMessage = $orderRes['Order_Response'][0]['Message'];
$oMagentoId = $orderRes['Order_Response'][0]['Magento_ID'];
$oNSSalesOrderID = $orderRes['Order_Response'][0]['NS_SalesOrderID'];
}
if ($oStatus && $cStatus) {
$status = true;
}
/************************* update order and customer table *****************************/
try {
$netSuite = $status?1:0;
$status =$status?1:0;
$order->setPushToNetsuite($netSuite);
$message = $cMessage.', '.$oMessage;
$order->setNetsuiteId($oNSSalesOrderID);
$customer = $this->customerFactory->create()->load($order->getCustomerId());
$customer->setNetsuiteId($cNsCustId)->save();
$maxAttempt = $order->getNetsuiteMaxAttempt() + 1;
$order->setNetsuiteMaxAttempt($maxAttempt);
$order->setNetsuiteCreatedAt($this->getCurrentDate());
$order->save();
/********************* sales grid ***********************/
} catch (exception $e) {
$this->_logger->writeLog("error: ". $e->getMessage(), 'error');
}
/************************* Log entry on netsuite_orders *****************************/
$netSuiteModel = $this->netSuiteFactory->create();
try {
$netSuiteModel->setOrderId($order->getIncrementId());
$netSuiteModel->setNsOrderId($oNSSalesOrderID);
$netSuiteModel->setCustomerId($order->getCustomerId());
$netSuiteModel->setNsCustomerId($cNsCustId);
$netSuiteModel->setRequestInfo($requestData);
$netSuiteModel->setResponseInfo(json_encode($response));
$netSuiteModel->setMessages(trim($message));
$netSuiteModel->setStatus($status);
$netSuiteModel->setCreatedAt($this->getCurrentDate());
$netSuiteModel->save();
} catch (exception $e) {
$this->_logger->writeLog("error: ". $e->getMessage(), 'error');
}
}
/*
*get card type
* return @string
*/
public function getBrand($payment)
{
$card = $this->getCard($payment);
if (empty($card)) {
return null;
}
// return $this->helper->cardType($card->brand);
return 'visa';
}
/*
*get card type
* return @string
*/
public function getCard($payment)
{
$charge = $this->getCharge($payment);
if (empty($charge)) {
return null;
}
if (!empty($charge->source)) {
if (isset($charge->source->object) && $charge->source->object == 'card') {
return $charge->source;
}
if (isset($charge->source->type) && $charge->source->type == 'three_d_secure') {
$cardId = $charge->source->three_d_secure->card;
if (isset($this->cards[$cardId])) {
return $this->cards[$cardId];
}
$card = new \stdClass();
$card = $charge->source->three_d_secure;
$this->cards[$cardId] = $card;
return $this->cards[$cardId];
}
}
// Payment Methods API
if (!empty($charge->payment_method_details->card)) {
return $charge->payment_method_details->card;
}
// Sources API
if (!empty($charge->source->card)) {
return $charge->source->card;
}
return null;
}
/*
*get card type
* return @string
*/
public function getCharge($payment)
{
return $this->charge = $this->retrieveCharge($payment->getLastTransId());
}
/*
*get card type
* return @string
*/
public function retrieveCharge($chargeId)
{
try {
return '';
// $token = $this->helper->cleanToken($chargeId);
// return $this->api->retrieveCharge($token);
} catch (\Exception $e) {
return false;
}
}
/**
* get country name
* return @string
*/
public function getCountryName($countryCode)
{
$country = $this->_countryFactory->create()->loadByCode($countryCode);
return $country->getName();
}
}
@@ -0,0 +1,18 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Helper;
/**
* Constants for this module scope
*/
class IntegrationConstants
{
const CLEAR_LOG_DAYS = 5;
const NETSUITE_LOG_DIR = "/netsuite/";
const TBL_MASTER_LOGS = "netsuite_orders";
}
+129
View File
@@ -0,0 +1,129 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem\Driver\File;
use Magento\Framework\Filesystem;
use Caratlane\NetSuite\Model\NetSuiteConstants;
class Logger extends AbstractHelper
{
/**
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
*/
protected $timezone;
/**
* @var \Magento\Framework\Filesystem\Driver\File
*/
protected $_fileDriver;
/**
* @var Filesystem
*/
protected $file;
/**
* @var WriteInterface
*/
protected $newDirectory;
protected $logger;
public function __construct(
Context $context,
TimezoneInterface $timezone,
File $fileDriver,
Filesystem $file
) {
$this->timezone = $timezone;
$this->_fileDriver = $fileDriver;
$this->newDirectory = $file->getDirectoryWrite(DirectoryList::VAR_DIR);
parent::__construct($context);
}
public function writeLog($message, $type = 'info', $name = 'netsuite')
{
if (!$this->logger) {
$this->initLog($name);
}
switch ($type) {
case 'info':
$this->logger->info($message);
break;
case 'warn':
$this->logger->warn($message);
break;
case 'error':
$this->logger->err($message);
break;
default:
$this->logger->info($message);
break;
}
}
public function initLog($name = 'netsuite')
{
$today = $this->timezone->date()->format('d-m-Y');
$logPath = BP . '/var'. NetSuiteConstants::NETSUITE_LOG_DIR . $today;
if (!$this->isFileExist($logPath)) {
$this->createDirectory($logPath);
}
$writer = new \Laminas\Log\Writer\Stream($logPath . '/' . $name . '.log');
$this->logger = new \Laminas\Log\Logger();
$this->logger->addWriter($writer);
return $this->logger;
}
public function isFileExist($fileName)
{
return $this->_fileDriver->isExists($fileName);
}
/**
* Create new folder
*
* @return bool
* @throws LocalizedException
*/
public function createDirectory($directoryName)
{
$newDirectory = false;
try {
$newDirectory = $this->newDirectory->create($directoryName);
} catch (FileSystemException $e) {
return false;
}
return $newDirectory;
}
}
+120
View File
@@ -0,0 +1,120 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Logger;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem\Driver\File;
use Magento\Framework\Filesystem;
use Caratlane\NetSuite\Helper\IntegrationConstants;
use Magento\Framework\Filesystem\Io\File as IoFile;
class Logger
{
/**
* @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface
*/
protected $timezone;
/**
* @var \Magento\Framework\Filesystem\Driver\File
*/
protected $_fileDriver;
/**
* @var Filesystem
*/
protected $file;
/**
* @var WriteInterface
*/
protected $newDirectory;
/**
* @var IoFile
*/
protected $ioFile;
/**
* @var WriteInterface
*/
protected $logger;
public function __construct(
TimezoneInterface $timezone,
File $fileDriver,
Filesystem $file,
IoFile $ioFile
) {
$this->timezone = $timezone;
$this->_fileDriver = $fileDriver;
$this->ioFile = $ioFile;
$this->newDirectory = $file->getDirectoryWrite(DirectoryList::VAR_DIR);
}
public function writeLog($message, $type = 'info', $name = 'netsuite')
{
if (!$this->logger) {
$this->initLog($name);
}
switch ($type) {
case 'info':
$this->logger->info($message);
break;
case 'warn':
$this->logger->warn($message);
break;
case 'error':
$this->logger->err($message);
break;
default:
$this->logger->info($message);
break;
}
}
public function initLog($name = 'netsuite')
{
$today = $this->timezone->date()->format('d-m-Y');
$logPath = BP . '/var'.IntegrationConstants::NETSUITE_LOG_DIR . $today;
if (!$this->isFileExist($logPath)) {
$this->createDirectory($logPath);
}
$writer = new \Laminas\Log\Writer\Stream($logPath . '/' . $name . '.log');
$this->logger = new \Laminas\Log\Logger();
$this->logger->addWriter($writer);
return $this->logger;
}
public function isFileExist($fileName)
{
return $this->_fileDriver->isExists($fileName);
}
/**
* Create new folder
* @return bool
* @throws LocalizedException
*/
public function createDirectory($directoryName)
{
$newDirectory = false;
try {
$newDirectory = $this->ioFile->mkdir($directoryName, 0775);
// $newDirectory = $this->newDirectory->create($directoryName);
} catch (FileSystemException $e) {
return false;
}
return $newDirectory;
}
}
@@ -0,0 +1,76 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Model\Config\Attribute\Source;
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
use Magento\Eav\Model\Entity\Attribute\Source\SourceInterface;
use Magento\Framework\Data\OptionSourceInterface;
/**
* Product status functionality model
*
* @api
* @since 100.0.2
*/
class Status extends AbstractSource implements SourceInterface, OptionSourceInterface
{
/**#@+
* Product Status values
*/
const STATUS_SUCCESS = 1;
const STATUS_FAILED = 0;
/**#@-*/
/**
* Retrieve Visible Status Ids
*
* @return int[]
*/
public function getVisibleStatusIds()
{
return [self::STATUS_SUCCESS];
}
/**
* Retrieve Saleable Status Ids
* Default Product Enable status
*
* @return int[]
*/
public function getSaleableStatusIds()
{
return [self::STATUS_SUCCESS];
}
/**
* Retrieve option array
*
* @return string[]
*/
public function getOptionArray()
{
return [self::STATUS_SUCCESS => __('Success'), self::STATUS_FAILED => __('Failed')];
}
/**
* Retrieve option array with empty value
*
* @return string[]
*/
public function getAllOptions()
{
$result = [];
foreach (self::getOptionArray() as $index => $value) {
$result[] = ['value' => $index, 'label' => $value];
}
return $result;
}
}
+75
View File
@@ -0,0 +1,75 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Model\Config;
class CronConfig extends \Magento\Framework\App\Config\Value
{
const CRON_STRING_PATH = 'crontab/default/jobs/caratlane_netsuite_cron_job/schedule/cron_expr';
const CRON_MODEL_PATH = 'crontab/default/jobs/caratlane_netsuite_cron_job/run/model';
protected $_configValueFactory;
protected $_runModelPath = '';
public function __construct(
\Magento\Framework\Model\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\App\Config\ScopeConfigInterface $config,
\Magento\Framework\App\Cache\TypeListInterface $cacheTypeList,
\Magento\Framework\App\Config\ValueFactory $configValueFactory,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
$runModelPath = '',
array $data = []
) {
$this->_runModelPath = $runModelPath;
$this->_configValueFactory = $configValueFactory;
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
}
public function afterSave()
{
$time = $this->getData('netsuite/cronScheduled/fields/time/value');
$frequency = $this->getData('netsuite/cronScheduled/fields/frequency/value');
$t1 = isset($time[1])?$time[1]:0;
$t2 = isset($time[0])?$time[0]:0;
$cronExprArray = [
(int)($t1),
(int)($t2),
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_MONTHLY ? '1' : '*',
'*',
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_WEEKLY ? '1' : '*',
];
$cronExprString = join(' ', $cronExprArray);
try {
$this->_configValueFactory->create()->load(
self::CRON_STRING_PATH,
'path'
)->setValue(
$cronExprString
)->setPath(
self::CRON_STRING_PATH
)->save();
$this->_configValueFactory->create()->load(
self::CRON_MODEL_PATH,
'path'
)->setValue(
$this->_runModelPath
)->setPath(
self::CRON_MODEL_PATH
)->save();
} catch (\Exception $e) {
//throw new \Exception(__('We can\'t save the cron expression.'));
$e->getMessage();
}
return parent::afterSave();
}
}
+33
View File
@@ -0,0 +1,33 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Model;
class NetSuite extends \Magento\Framework\Model\AbstractModel implements \Magento\Framework\DataObject\IdentityInterface
{
const CACHE_TAG = 'netsuite_order_log';
protected $_cacheTag = 'netsuite_order_log';
protected $_eventPrefix = 'netsuite_order_log';
protected function _construct()
{
$this->_init(\Caratlane\NetSuite\Model\ResourceModel\NetSuite::class);
}
public function getIdentities()
{
return [self::CACHE_TAG . '_' . $this->getId()];
}
public function getDefaultValues()
{
$values = [];
return $values;
}
}
+54
View File
@@ -0,0 +1,54 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model;
class NetSuiteConstants
{
const NETSUITE_TRACK_SHIPMENT_LOG_FILENAME = 'track_shipment';
const NETSUITE_TRACK_ORDER_LOG_FILENAME = 'track_order';
const NETSUITE_ORDER_UPODATE_LOG_FILENAME = 'order_update';
const NETSUITE_CREATE_SHIPMENT_LOG_FILENAME = 'create_shipment';
const NETSUITE_CREATE_UPDATEPDF_LOG_FILENAME = 'update_invoicepdf';
const NETSUITE_LOG_DIR = '/netsuite/';
const NETSUITE_DEFAULT_ERROR_CODE = 'false';
const NETSUITE_DEFAULT_SUCCESS_CODE = 'true';
const NETSUITE_DEFAULT_STATUS = 'pending';
const NETSUITE_EMPTY_MESSAGE = 'The request data is empty or invalid.';
const NETSUITE_SUCCESS_MESSAGE = 'Data saved successfully. Import process will be start soon.';
const NETSUITE_MIGRATION_STATUS = 'success';
const NETSUITE_MIGRATION_FAILED_STATUS = 'failed';
const NETSUITE_MIGRATION_SUCCESS_MESSAGE = 'Shipment data inserted successfully.';
const NETSUITE_MIGRATION_ORDER_INDERTED_SUCCESS_MESSAGE = 'Order update data inserted successfully.';
const NETSUITE_MIGRATION_SHIPMENT_SUCCESS_MESSAGE = 'Shipment created successfully.';
const NETSUITE_MIGRATION_SHIPMENT_UPDATE_SUCCESS_MESSAGE = 'Shipment status update successfully.';
const NETSUITE_MIGRATION_ORDER_SUCCESS_MESSAGE = 'Order status update successfully.';
const NETSUITE_MIGRATE_CREATE_SHIPMENT_LOG_FILENAME = 'create_shipment_process';
const NETSUITE_MIGRATE_TRACK_SHIPMENT_LOG_FILENAME = 'track_shipment_process';
const NETSUITE_MIGRATE_TRACK_ORDER_LOG_FILENAME = 'order_update_process';
const NETSUITE_TRACKING_CODE = 'custom';
const NETSUITE_DISABLE_MESSAGE = 'This feature has been disable. Please contact to service provider.';
const CAN_NOT_CANCEL_ORDER = 'Can not canceled order due invoice or shipment has been created';
const CAN_NOT_HOLDED_ORDER = 'Can not hold order due invoice or shipment has been created';
const NETSUITE_CANCEL_MESSAGE = 'Order has been canceled successfully';
const NETSUITE_ORDER_NOT_FOUND = 'Order not found';
const STATUS_ARRAY_LIST = ['canceled','holded','shipped','delivered'];
}
+35
View File
@@ -0,0 +1,35 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model;
use Magento\Framework\Model\AbstractModel;
class NetSuiteOrdersUpdate extends AbstractModel
{
/**
* Define resource model
*/
protected function _construct()
{
$this->_init(\Caratlane\NetSuite\Model\ResourceModel\NetSuiteOrdersUpdate::class);
}
}
+35
View File
@@ -0,0 +1,35 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model;
use Magento\Framework\Model\AbstractModel;
class NetsuiteShipments extends AbstractModel
{
/**
* Define resource model
*/
protected function _construct()
{
$this->_init(\Caratlane\NetSuite\Model\ResourceModel\NetsuiteShipments::class);
}
}
@@ -0,0 +1,35 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model;
use Magento\Framework\Model\AbstractModel;
class NetsuiteUpdateinvoicepdf extends AbstractModel
{
/**
* Define resource model
*/
protected function _construct()
{
$this->_init(\Caratlane\NetSuite\Model\ResourceModel\NetsuiteUpdateinvoicepdf::class);
}
}
+200
View File
@@ -0,0 +1,200 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Model;
use Magento\Store\Model\ScopeInterface;
class Oauth
{
const SIGNATURE_METHOD_HMACSHA256 = 'HMAC-SHA256';
const OAUTH_SCRIPT = 'netsuite/apidetail/script';//'694';
const OAUTH_VERSION = '1.0';
const NONCE_STRING = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
const XML_PATH_OAUTH_REALM = 'netsuite/apidetail/oauth_realm';
const XML_PATH_OAUTH_CONSUMER_KEY = 'netsuite/apidetail/oauth_consumer_key';
const XML_PATH_OAUTH_CONSUMER_SECRET = 'netsuite/apidetail/oauth_consumer_secret';
const XML_PATH_OAUTH_TOKEN = 'netsuite/apidetail/oauth_token';
const XML_PATH_OAUTH_TOKEN_SECRET = 'netsuite/apidetail/oauth_token_secret';
const XML_PATH_OAUTH_URL = 'netsuite/cronScheduled/api_url';
/**
* @var storeManager
*/
protected $storeManager;
/**
* @var scopeConfig
*/
protected $scopeConfig;
/**
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
**/
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
) {
$this->scopeConfig = $scopeConfig;
$this->storeManager = $storeManager;
}
/*
* consumer key
* @return string
*/
public function getConsumerKey()
{
return $this->getConfigValue(self::XML_PATH_OAUTH_CONSUMER_KEY);
}
/*
* consumer Secret
* @return string
*/
public function getConsumerSecret()
{
return $this->getConfigValue(self::XML_PATH_OAUTH_CONSUMER_SECRET);
}
/*
* Token access key
* @return string
*/
public function getToken()
{
return $this->getConfigValue(self::XML_PATH_OAUTH_TOKEN);
}
/*
* Token Secret
* @return string
*/
public function getTokenSecret()
{
return $this->getConfigValue(self::XML_PATH_OAUTH_TOKEN_SECRET);
}
/*
* Token Secreat
* @return string
*/
public function getRealm()
{
return $this->getConfigValue(self::XML_PATH_OAUTH_REALM);
}
/*
* Token script
* @return string
*/
public function getScript()
{
return $this->getConfigValue(self::OAUTH_SCRIPT);
}
/*
* Token Secreat
* @return string
*/
public function getApiUrl()
{
return $this->getConfigValue(self::XML_PATH_OAUTH_URL);
}
/*
* Calculate header for request
* @return string
*/
public function getOauthParams()
{
$time = time();
$nonce = rawurlencode($this->generateNonceString(11));
$oauthparams = $this->getParamObject($nonce, $time);
$baseString = $this->createBaseString($oauthparams);
$signature = $this->getSignature('sha256', $baseString);
return $headerValue = $this->buildAuthorizationHeader($nonce, $time, $signature);
}
/*
* Calculate signature for request
* @return string
*/
public function getSignature($algo, $baseString)
{
$key = rawurlencode($this->getConsumerSecret()) . '&' . rawurlencode($this->getTokenSecret());
return rawurlencode(base64_encode(hash_hmac($algo, $baseString, $key, true)));
}
/**
* Builds the Authorization header for a request
* @return array
*/
private function buildAuthorizationHeader($nonce, $time, $signature)
{
return 'OAuth realm="'.$this->getRealm().'", oauth_consumer_key="'.$this->getConsumerKey().'",oauth_nonce="'.$nonce.'",oauth_signature_method="HMAC-SHA256",oauth_timestamp="'.$time.'",oauth_token="'.$this->getToken().'",oauth_version="1.0",oauth_signature="'.$signature.'"';
}
/**
* Creates the Signature Base String.
* The Signature Base String is a consistent reproducible concatenation of
* the request elements into a single string. The string is used as an
* input in hashing or signing algorithms.
* @return string Returns the base string
*/
private function createBaseString($params)
{
$url = $this->getApiUrl();
$query = http_build_query($params, '', '&', PHP_QUERY_RFC3986);
return strtoupper('POST')
. '&' . rawurlencode($url)
. '&' . rawurlencode($query);
}
/*
* generating nonce value
* @return string
*/
public function generateNonceString($length = 11)
{
$characters = self::NONCE_STRING;
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
/*
* generating param value
* @return array
*/
public function getParamObject($nonce, $time)
{
return [
'deploy'=>1,
"oauth_consumer_key"=> $this->getConsumerKey(),
"oauth_nonce"=> $nonce,
"oauth_signature_method"=>self::SIGNATURE_METHOD_HMACSHA256,
"oauth_timestamp"=> $time,
"oauth_token"=>$this->getToken(),
"oauth_version"=> self::OAUTH_VERSION,
'script'=> $this->getScript()
];
}
/*
* get config value
* return string
*/
public function getConfigValue($path)
{
$store = $this->storeManager->getStore()->getStoreId();
$config_data = $this->scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE, $store);
return $config_data;
}
}
+226
View File
@@ -0,0 +1,226 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model\Order;
use Magento\Framework\Webapi\Rest\Request;
use Caratlane\NetSuite\Api\OrderUpdateInterface;
use Caratlane\NetSuite\Model\NetSuiteOrdersUpdateFactory;
use Caratlane\NetSuite\Model\NetSuiteConstants;
use Caratlane\NetSuite\Helper\Logger;
use Caratlane\NetSuite\Helper\Data;
use Magento\Framework\App\ResourceConnection;
use Magento\Sales\Api\Data\OrderInterface;
class OrderUpdate implements OrderUpdateInterface
{
/**
* @var \Magento\Framework\App\ResourceConnection
*/
private $resource;
/**
* @var \Magento\Sales\Api\Data\OrderInterface
*/
private $orderInterface;
/**
* @var \Caratlane\NetSuite\Helper\Logger
*/
protected $logger;
/**
* @var \Magento\Framework\Webapi\Rest\Request
*/
private $request;
/**
* @var \Caratlane\NetSuite\Model\NetSuiteOrdersUpdateFactory
*/
private $netSuiteOrdersUpdate;
/**
* @var \Caratlane\NetSuite\Helper\Data
*/
private $helper;
/**
* @param ResourceConnection $resource
* @param OrderInterface $orderInterface
* @param Data $helper
* @param Logger $logger
* @param Request $request
* @param NetSuiteOrdersUpdateFactory $netSuiteOrdersUpdate
*/
public function __construct(
Data $helper,
Logger $logger,
Request $request,
ResourceConnection $resource,
OrderInterface $orderInterface,
NetSuiteOrdersUpdateFactory $netSuiteOrdersUpdate
) {
$this->logger = $logger;
$this->helper = $helper;
$this->request = $request;
$this->resource = $resource;
$this->orderInterface = $orderInterface;
$this->netSuiteOrdersUpdate = $netSuiteOrdersUpdate;
}
public function getOrderUpdate()
{
$responseData = [];
$responseData['success'] = NetSuiteConstants::NETSUITE_DEFAULT_ERROR_CODE;
$responseData['message'] = NetSuiteConstants::NETSUITE_DISABLE_MESSAGE;
if ($this->helper->getNetSuiteIsEnabled() && $this->helper->getNetsuiteOrdersUpdateEnabled()) {
$responseData['message'] = NetSuiteConstants::NETSUITE_EMPTY_MESSAGE;
$postData = $this->request->getBodyParams();
$this->logger->initLog(NetSuiteConstants::NETSUITE_ORDER_UPODATE_LOG_FILENAME);
$this->logger->writeLog('----------------------------');
$this->logger->writeLog('Order Update Started');
$this->logger->writeLog('----------------------------');
$this->logger->writeLog('');
try {
if (!empty($postData)) {
if ($postData['ns_order_id']) {
$this->logger->writeLog('Magento Order Id: '.$postData['magento_order_id']);
if (!$postData['ns_order_id'] || !$postData['magento_order_id'] || !$postData['order_status']) {
$this->logger->writeLog('Please add required fields');
$responseData['success'] = false;
$responseData['message'] = "Please add required fields";
return [$responseData];
}
$incrementOrderId = $this->getOrderId($postData['magento_order_id']);
if ($incrementOrderId != "") {
$jsondata = json_encode($postData);
$netSuiteOrderUpdateModel = $this->netSuiteOrdersUpdate->create();
$netSuiteOrderUpdateModel->setMagentoOrderId($postData['magento_order_id']);
$netSuiteOrderUpdateModel->setNetsuiteOrderId($postData['ns_order_id']);
$netSuiteOrderUpdateModel->setNetsuiteOrderStatus($postData['order_status']);
$netSuiteOrderUpdateModel->setStatus("completed");
$netSuiteOrderUpdateModel->setJsonData($jsondata);
$orderstatusmsg = NetSuiteConstants::NETSUITE_MIGRATION_ORDER_INDERTED_SUCCESS_MESSAGE;
$netSuiteOrderUpdateModel->setMessages($orderstatusmsg);
$netSuiteOrderUpdateModel->save();
//update data for shipment table
$connection = $this->resource->getConnection();
$data = [];
$data['netsuite_order_status'] = $postData['order_status'];
$where = ['increment_id = ?' => $postData['magento_order_id']];
/* update sales_shipment_grid */
$tableName = $connection->getTableName("sales_order_grid");
$connection->update($tableName, $data, $where);
/* update sales_shipment */
$tableName = $connection->getTableName("sales_order");
$connection->update($tableName, $data, $where);
$this->logger->writeLog('Order Status: '.$postData['order_status']);
/* update sales_order_item */
$orderId = $this->getOrderId($postData['magento_order_id']);
$itemarray = $postData['items'];
$this->updateOrderItem($itemarray, $orderId);
$this->logger->writeLog('Order updated successfully');
$responseData['success'] = true;
$responseData['message'] = "Order updated successfully";
$responseData['magento_order_id'] = $postData['magento_order_id'];
} else {
$this->logger->writeLog('Order id not found in system ='.$postData['magento_order_id']);
$responseData['success'] = false;
$responseData['message'] = "Order id not found in system";
}
} else {
$this->logger->writeLog('ns_order_id field can\'t be empty');
$responseData['success'] = false;
$responseData['message'] = "ns_order_id field can't be empty";
}
} else {
$this->logger->writeLog('Order Update Data Not Found');
}
} catch (Exception $e) {
$this->logger->writeLog('Exception: '.$e->getMessage());
$responseData['success'] = false;
$responseData['message'] = 'Exception : '.$e->getMessage();
}
$this->logger->writeLog('');
$this->logger->writeLog('----------------------------');
$this->logger->writeLog('Order Update Stopped');
$this->logger->writeLog('----------------------------');
}
return [$responseData];
}
private function updateOrderItem($itemarray, $orderId)
{
if (!empty($itemarray)) {
foreach ($itemarray as $key => $orderitem) {
$dataitem = [];
$itemconnection = $this->resource->getConnection();
$dataitem['qty_shipped'] = $orderitem['qty_shipped'];
$dataitem['qty_canceled'] = $orderitem['qty_cancelled'];
$dataitem['qty_refunded'] = $orderitem['qty_refunded'];
$dataitem['qty_delivered'] = $orderitem['qty_delivered'];
$dataitem['netsuite_item_status'] = $orderitem['item_status'];
$itemwhere = ['order_id = ?' => (int)$orderId,'sku = ?' => $orderitem['item_sku']];
$itemtableName = $itemconnection->getTableName("sales_order_item");
$itemconnection->update($itemtableName, $dataitem, $itemwhere);
$this->logger->writeLog('Order Item Sku: '.$orderitem['item_sku']);
$this->logger->writeLog('Order Item Status: '.$orderitem['item_status']);
}
}
}
public function getOrderId(string $incrementOrderId)
{
$orderId = 0;
try {
$orderInfo = $this->orderInterface->loadByIncrementId($incrementOrderId);
$orderId = $orderInfo->getId();
return $orderId;
} catch (Exception $e) {
return $orderId;
}
}
}
@@ -0,0 +1,106 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Model\Order\Payment\State;
use Magento\Framework\App\ObjectManager;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\Data\OrderPaymentInterface;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\StatusResolver;
/**
* Process order state and status after capture operation.
*/
class CaptureCommand extends \Magento\Sales\Model\Order\Payment\State\CaptureCommand
{
/**
* @var StatusResolver
*/
private $statusResolver;
/**
* @param StatusResolver|null $statusResolver
*/
public function __construct(StatusResolver $statusResolver = null)
{
parent::__construct($statusResolver);
$this->statusResolver = $statusResolver
? : ObjectManager::getInstance()->get(StatusResolver::class);
}
/**
* Run command.
*
* @param OrderPaymentInterface $payment
* @param string|float $amount
* @param OrderInterface $order
* @return \Magento\Framework\Phrase
*/
public function execute(OrderPaymentInterface $payment, $amount, OrderInterface $order)
{
$state = Order::STATE_NEW;
$status = null;
$message = 'Captured amount of %1 online.';
if ($payment->getIsTransactionPending()) {
$state = Order::STATE_PAYMENT_REVIEW;
$message = 'An amount of %1 will be captured after being approved at the payment gateway.';
}
if ($payment->getIsFraudDetected()) {
$state = Order::STATE_PAYMENT_REVIEW;
$status = Order::STATUS_FRAUD;
$message .= ' Order is suspended as its capturing amount %1 is suspected to be fraudulent.';
}
$message = $this->getNotificationMessage($payment) ?? $message;
if (!isset($status)) {
$status = $this->statusResolver->getOrderStatusByState($order, $state);
}
$order->setState($state);
$order->setStatus($status);
return __($message, $order->getBaseCurrency()->formatTxt($amount));
}
/**
* Sets order state and status.
*
* @param Order $order
* @param string $status
* @param string $state
* @return void
* @deprecated 100.1.9 Replaced by a StatusResolver class call.
*/
protected function setOrderStateAndStatus(Order $order, $status, $state)
{
if (!$status) {
$status = $order->getConfig()->getStateDefaultStatus($state);
}
$order->setState($state)->setStatus($status);
}
/**
* Returns payment notification message.
*
* @param OrderPaymentInterface $payment
* @return string|null
*/
private function getNotificationMessage(OrderPaymentInterface $payment): ?string
{
$extensionAttributes = $payment->getExtensionAttributes();
if ($extensionAttributes && $extensionAttributes->getNotificationMessage()) {
return $extensionAttributes->getNotificationMessage();
}
return null;
}
}
+155
View File
@@ -0,0 +1,155 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model\Product;
use Magento\Framework\Webapi\Rest\Request;
use Caratlane\NetSuite\Api\CreateProductInterface;
use Caratlane\NetSuite\Model\NetsuiteUpdateinvoicepdfFactory;
use Caratlane\NetSuite\Model\NetSuiteConstants;
use Caratlane\NetSuite\Helper\Logger;
use Caratlane\NetSuite\Helper\Data;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\App\ResourceConnection;
use Magento\Sales\Model\Order\Shipment;
class CreateProduct implements CreateProductInterface
{
/**
* @var \Magento\Framework\App\ResourceConnection
*/
private $resource;
/**
* @var \Magento\Sales\Model\Order\Shipment
*/
private $ordershipment;
/**
* @var \Caratlane\NetSuite\Helper\Logger
*/
protected $logger;
/**
* @var \Caratlane\NetSuite\Model\NetsuiteUpdateinvoicepdfFactory
*/
private $netsuiteupdateinvoicepdf;
/**
* @var \Magento\Framework\Serialize\Serializer\Json
*/
private $json;
/**
* @var \Caratlane\NetSuite\Helper\Data
*/
private $helper;
/**
* @var \Magento\Framework\Webapi\Rest\Request
*/
private $request;
/**
* @param ResourceConnection $resource
* @param Shipment $ordershipment
* @param Data $helper
* @param Json $json
* @param Logger $logger
* @param NetsuiteUpdateinvoicepdfFactory $netsuiteupdateinvoicepdf
* @param Request $request
*/
public function __construct(
Request $request,
ResourceConnection $resource,
Shipment $ordershipment,
Data $helper,
Json $json,
Logger $logger,
NetsuiteUpdateinvoicepdfFactory $netsuiteupdateinvoicepdf
) {
$this->request = $request;
$this->resource = $resource;
$this->ordershipment = $ordershipment;
$this->helper = $helper;
$this->json = $json;
$this->logger = $logger;
$this->netsuiteupdateinvoicepdf = $netsuiteupdateinvoicepdf;
}
public function createProduct()
{
if ($this->helper->getNetSuiteIsEnabled()) {
$this->logger->initLog(NetSuiteConstants::NETSUITE_CREATE_UPDATEPDF_LOG_FILENAME);
$this->logger->writeLog('----------------------------');
$this->logger->writeLog('Create Product Started');
$this->logger->writeLog('----------------------------');
$this->logger->writeLog('');
$postData = $this->request->getBodyParams();
try {
if ($postData['sku']) {
$this->logger->writeLog('Product Sku: '.$postData['sku']);
if (!$postData['sku'] || !$postData['name'] || !$postData['price']) {
$this->logger->writeLog('Please add required fields');
$responseData['success'] = false;
$responseData['message'] = "Please add required fields";
return [$responseData];
}
} else {
$this->logger->writeLog('Sku field can\'t be empty');
$responseData['success'] = false;
$responseData['message'] = "Sku field can't be empty";
}
} catch (Exception $e) {
$responseData['success'] = false;
$responseData['message'] = 'Exception : '.$e->getMessage();
$this->logger->writeLog('Exception: '.$e->getMessage());
}
$this->logger->writeLog('');
$this->logger->writeLog('----------------------------');
$this->logger->writeLog('Create Product Stopped');
$this->logger->writeLog('----------------------------');
}
return [$responseData];
}
public function getordershipment(string $incrementshipId)
{
$shipId = 0;
try {
$shipment = $this->ordershipment->loadByIncrementId($incrementshipId);
$shipId = $shipment->getId();
return $shipId;
} catch (Exception $e) {
return $shipId;
}
}
}
@@ -0,0 +1,22 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Model\ResourceModel;
class NetSuite extends \Magento\Framework\Model\ResourceModel\Db\AbstractDb
{
/*public function __construct(
\Magento\Framework\Model\ResourceModel\Db\Context $context
) {
parent::__construct($context);
}*/
protected function _construct()
{
$this->_init('netsuite_orders', 'entity_id'); //entity_id : Primary key of your database table
}
}
@@ -0,0 +1,28 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Model\ResourceModel\NetSuite;
class Collection extends \Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection
{
protected $_idFieldName = 'entity_id';
protected $_eventPrefix = 'netsuite_order_log_collection';
protected $_eventObject = 'netsuite_order_collection';
/**
* Define resource model
*
* @return void
*/
protected function _construct()
{
$this->_init(
\Caratlane\NetSuite\Model\NetSuite::class,
\Caratlane\NetSuite\Model\ResourceModel\NetSuite::class
);
}
}
@@ -0,0 +1,35 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model\ResourceModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class NetSuiteOrdersUpdate extends AbstractDb
{
/**
* Define main table
*/
protected function _construct()
{
$this->_init('netsuite_order_update', 'entity_id');
}
}
@@ -0,0 +1,38 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model\ResourceModel\NetSuiteOrdersUpdate;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class Collection extends AbstractCollection
{
/**
* Define model & resource model
*/
protected function _construct()
{
$this->_init(
\Caratlane\NetSuite\Model\NetSuiteOrdersUpdate::class,
\Caratlane\NetSuite\Model\ResourceModel\NetSuiteOrdersUpdate::class
);
}
}
@@ -0,0 +1,35 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model\ResourceModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class NetsuiteShipments extends AbstractDb
{
/**
* Define main table
*/
protected function _construct()
{
$this->_init('netsuite_shipments', 'entity_id');
}
}
@@ -0,0 +1,38 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model\ResourceModel\NetsuiteShipments;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class Collection extends AbstractCollection
{
/**
* Define model & resource model
*/
protected function _construct()
{
$this->_init(
\Caratlane\NetSuite\Model\NetsuiteShipments::class,
\Caratlane\NetSuite\Model\ResourceModel\NetsuiteShipments::class
);
}
}
@@ -0,0 +1,35 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model\ResourceModel;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
class NetsuiteUpdateinvoicepdf extends AbstractDb
{
/**
* Define main table
*/
protected function _construct()
{
$this->_init('netsuite_invoice_pdf', 'entity_id');
}
}
@@ -0,0 +1,38 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model\ResourceModel\NetsuiteUpdateinvoicepdf;
use Magento\Framework\Model\ResourceModel\Db\Collection\AbstractCollection;
class Collection extends AbstractCollection
{
/**
* Define model & resource model
*/
protected function _construct()
{
$this->_init(
\Caratlane\NetSuite\Model\NetsuiteUpdateinvoicepdf::class,
\Caratlane\NetSuite\Model\ResourceModel\NetsuiteUpdateinvoicepdf::class
);
}
}
@@ -0,0 +1,519 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model\Shipment;
use Magento\Framework\Webapi\Rest\Request;
use Caratlane\NetSuite\Api\CreateShipmentInterface;
use Caratlane\NetSuite\Model\NetsuiteShipmentsFactory;
use Caratlane\NetSuite\Model\NetSuiteConstants;
use Caratlane\NetSuite\Helper\Logger;
use Caratlane\NetSuite\Helper\Data;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Framework\App\ResourceConnection;
use Magento\Sales\Model\Service\InvoiceService;
use Magento\Framework\DB\Transaction;
use Magento\Sales\Model\Order\Email\Sender\InvoiceSender;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Shipping\Model\ShipmentNotifier;
use Magento\Sales\Model\Convert\Order;
use Magento\Sales\Model\Order\Shipment\TrackFactory;
use Magento\Framework\Serialize\Serializer\Json;
class CreateShipment implements CreateShipmentInterface
{
/**
* @var \Magento\Sales\Model\Order\Shipment\TrackFactory
*/
private $trackFactory;
/**
* @var \Magento\Framework\App\ResourceConnection
*/
private $resource;
/**
* @var \Magento\Sales\Model\Convert\Order
*/
private $convertOrder;
/**
* @var \Magento\Shipping\Model\ShipmentNotifier
*/
private $shipmentNotifier;
/**
* @var \Magento\Sales\Api\Data\OrderInterface
*/
private $orderInterface;
/**
* @var \Magento\Sales\Api\OrderRepositoryInterface
*/
private $orderRepository;
/**
* @var \Magento\Sales\Model\Service\InvoiceService
*/
private $invoiceService;
/**
* @var \Magento\Framework\DB\Transaction
*/
private $transaction;
/**
* @var \Magento\Sales\Model\Order\Email\Sender\InvoiceSender
*/
private $invoiceSender;
/**
* @var \Caratlane\NetSuite\Helper\Logger
*/
protected $logger;
/**
* @var \Caratlane\NetSuite\Model\NetsuiteShipmentsFactory
*/
private $netsuiteShipments;
/**
* @var \Magento\Framework\Serialize\Serializer\Json
*/
private $json;
/**
* @var \Caratlane\NetSuite\Helper\Data
*/
private $helper;
/**
* @var \Magento\Framework\Webapi\Rest\Request
*/
private $request;
/**
* @param TrackFactory $trackFactory
* @param ResourceConnection $resource
* @param Data $helper
* @param Json $json
* @param Order $convertOrder
* @param ShipmentNotifier $shipmentNotifier
* @param OrderInterface $orderInterface
* @param OrderRepositoryInterface $orderRepository
* @param InvoiceService $invoiceService
* @param InvoiceSender $invoiceSender
* @param Transaction $transaction
* @param Logger $logger
* @param NetsuiteShipmentsFactory $netsuiteShipments
* @param Request $request
*/
public function __construct(
Request $request,
ResourceConnection $resource,
Data $helper,
Json $json,
TrackFactory $trackFactory,
Order $convertOrder,
ShipmentNotifier $shipmentNotifier,
OrderRepositoryInterface $orderRepository,
InvoiceService $invoiceService,
InvoiceSender $invoiceSender,
Transaction $transaction,
OrderInterface $orderInterface,
Logger $logger,
NetsuiteShipmentsFactory $netsuiteShipments
) {
$this->request = $request;
$this->resource = $resource;
$this->helper = $helper;
$this->json = $json;
$this->trackFactory = $trackFactory;
$this->convertOrder = $convertOrder;
$this->shipmentNotifier = $shipmentNotifier;
$this->orderRepository = $orderRepository;
$this->invoiceService = $invoiceService;
$this->transaction = $transaction;
$this->invoiceSender = $invoiceSender;
$this->orderInterface = $orderInterface;
$this->logger = $logger;
$this->netsuiteShipments = $netsuiteShipments;
}
public function createNewShipment()
{
$responseData = [];
$responseData['success'] = NetSuiteConstants::NETSUITE_DEFAULT_ERROR_CODE;
$responseData['message'] = NetSuiteConstants::NETSUITE_DISABLE_MESSAGE;
if ($this->helper->getNetSuiteIsEnabled() && $this->helper->getNetsuiteCreateShipmentEnabled()) {
$this->logger->initLog(NetSuiteConstants::NETSUITE_CREATE_SHIPMENT_LOG_FILENAME);
$this->logger->writeLog('----------------------------');
$this->logger->writeLog('Create Shipment Started');
$this->logger->writeLog('----------------------------');
$this->logger->writeLog('');
$postData = $this->request->getBodyParams();
try {
if ($postData['ns_fulfillment_id']) {
$postDataarray = [];
$postDataarray['ns_fulfillment_id'] = $postData['ns_fulfillment_id'];
$postDataarray['ns_fulfillment_number'] = $postData['ns_fulfillment_number'];
$postDataarray['ns_order_id'] = $postData['ns_order_id'];
$postDataarray['magento_order_id'] = $postData['magento_order_id'];
$postDataarray['tracking_number'] = $postData['tracking_number'];
$postDataarray['shipping_carrier'] = $postData['shipping_carrier'];
$postDataarray['shipped_date'] = $postData['shipped_date'];
$postDataarray['delivery_status'] = $postData['delivery_status'];
foreach ($postDataarray as $key => $postvalue) {
if ($postvalue == "") {
$this->logger->writeLog('Please add required fields');
$responseData['success'] = false;
$responseData['message'] = "Please add required fields";
return [$responseData];
}
}
$incrementOrderId = $this->getOrderId($postData['magento_order_id']);
//echo $incrementOrderId; exit();
if ($incrementOrderId != "") {
$this->logger->writeLog('Magento Order Id: '.$postData['magento_order_id']);
$jsonData = $this->json->serialize($postData);
$order = $this->orderRepository->get($incrementOrderId);
if (!$order->canShip()) {
//Shipment have already created
$this->logger->writeLog('Shipment already created Or Not create a shipment');
$responseData['success'] = false;
$responseData['message'] = "Shipment already created Or Not create a shipment";
$netsuiteShipmentsModel = $this->netsuiteShipments->create();
$netsuiteShipmentsModel->setMagentoOrderId($postData['magento_order_id']);
$netsuiteShipmentsModel->setNetsuiteOrderId($postData['ns_order_id']);
$netsuiteShipmentsModel->setFulfillmentId($postData['ns_fulfillment_id']);
$netsuiteShipmentsModel->setFulfillmentNumber($postData['ns_fulfillment_number']);
$netsuiteShipmentsModel->setTrackingNumber($postData['tracking_number']);
$netsuiteShipmentsModel->setShippingCarrier($postData['shipping_carrier']);
$netsuiteShipmentsModel->setShippedDate($postData['shipped_date']);
$netsuiteShipmentsModel->setDeliveryStatus($postData['delivery_status']);
$netsuiteShipmentsModel->setStatus("failed");
$jsonData = $this->json->serialize($postData);
$netsuiteShipmentsModel->setJsonData($jsonData);
$netsuiteShipmentsModel->setMessages("Shipment already created Or Not create a shipment");
$netsuiteShipmentsModel->save();
} else {
$shipmentdata = $this->getCreateShipmentByOrderId($incrementOrderId, $jsonData);
$resposeShipmentflag = '';
$resposeShipmentflag = $this->updateNetsuiteShipments($shipmentdata, $postData);
if ($resposeShipmentflag) {
$shipids = explode(":", $shipmentdata);
$incrementId = $shipids[0];
$shipmentId = $shipids[1];
$responseData['success'] = true;
$responseData['message'] = "Shipment created successfully!";
$responseData['magento_shipment_id'] = $shipmentId;
$responseData['magento_shipment_no'] = $incrementId;
} else {
$responseData['success'] = false;
$responseData['message'] = "Not create shipment";
}
}
} else {
$this->logger->writeLog('Order id not found in system ='.$postData['magento_order_id']);
$responseData['success'] = false;
$responseData['message'] = "Order id not found in system";
}
} else {
$this->logger->writeLog('ns_fulfillment_id field can\'t be empty');
$responseData['success'] = false;
$responseData['message'] = "ns_fulfillment_id field can't be empty";
}
} catch (Exception $e) {
$responseData['success'] = false;
$responseData['message'] = 'Exception : '.$e->getMessage();
$this->logger->writeLog('Exception: '.$e->getMessage());
}
$this->logger->writeLog('');
$this->logger->writeLog('----------------------------');
$this->logger->writeLog('Create Shipment Stopped');
$this->logger->writeLog('----------------------------');
}
return [$responseData];
}
private function updateNetsuiteShipments($shipmentdata, $postData)
{
$shipids = explode(":", $shipmentdata);
if ($shipids[0]) {
$incrementId = $shipids[0];
$shipmentId = $shipids[1];
$netsuiteShipmentsModel = $this->netsuiteShipments->create();
$netsuiteShipmentsModel->setMagentoOrderId($postData['magento_order_id']);
$netsuiteShipmentsModel->setNetsuiteOrderId($postData['ns_order_id']);
$netsuiteShipmentsModel->setFulfillmentId($postData['ns_fulfillment_id']);
$netsuiteShipmentsModel->setFulfillmentNumber($postData['ns_fulfillment_number']);
$netsuiteShipmentsModel->setTrackingNumber($postData['tracking_number']);
$netsuiteShipmentsModel->setShippingCarrier($postData['shipping_carrier']);
$netsuiteShipmentsModel->setShippedDate($postData['shipped_date']);
$netsuiteShipmentsModel->setShipmentId($incrementId);
$netsuiteShipmentsModel->setDeliveryStatus($postData['delivery_status']);
$netsuiteShipmentsModel->setStatus(NetSuiteConstants::NETSUITE_MIGRATION_STATUS);
$jsonData = $this->json->serialize($postData);
$netsuiteShipmentsModel->setJsonData($jsonData);
$shipsuccessmsg = NetSuiteConstants::NETSUITE_MIGRATION_SHIPMENT_SUCCESS_MESSAGE;
$netsuiteShipmentsModel->setMessages($shipsuccessmsg);
$netsuiteShipmentsModel->save();
$this->logger->writeLog('Shipment Id: '.$incrementId);
$this->logger->writeLog('Shipment created successfully');
return true;
} else {
$netsuiteShipmentsModel = $this->netsuiteShipments->create();
$netsuiteShipmentsModel->setMagentoOrderId($postData['magento_order_id']);
$netsuiteShipmentsModel->setNetsuiteOrderId($postData['ns_order_id']);
$netsuiteShipmentsModel->setFulfillmentId($postData['ns_fulfillment_id']);
$netsuiteShipmentsModel->setFulfillmentNumber($postData['ns_fulfillment_number']);
$netsuiteShipmentsModel->setTrackingNumber($postData['tracking_number']);
$netsuiteShipmentsModel->setShippingCarrier($postData['shipping_carrier']);
$netsuiteShipmentsModel->setShippedDate($postData['shipped_date']);
$netsuiteShipmentsModel->setDeliveryStatus($postData['delivery_status']);
$netsuiteShipmentsModel->setStatus("failed");
$jsonData = $this->json->serialize($postData);
$netsuiteShipmentsModel->setJsonData($jsonData);
$netsuiteShipmentsModel->setMessages("Cannot create shipment");
$netsuiteShipmentsModel->save();
$m_oid = $postData['magento_order_id'];
$logmsg = 'Cannot create shipment for Order increment id: ='.$m_oid;
$this->logger->writeLog($logmsg);
return false;
}
}
public function getCreateInvoiceByOrderId($orderId, $jsonData)
{
$order = $this->orderRepository->get($orderId);
if ($order->canInvoice()) {
$this->logger->initLog(NetSuiteConstants::NETSUITE_CREATE_SHIPMENT_LOG_FILENAME);
try {
$invoice = $this->invoiceService->prepareInvoice($order);
$invoice->register();
$invoice->save();
$transactionSave = $this->transaction->addObject($invoice)
->addObject($invoice->getOrder());
$transactionSave->save();
$this->invoiceSender->send($invoice);
$invoiceId = $invoice->getId();
$this->updateInvoiceCustomDetails($invoiceId, $jsonData);
//Send Invoice mail to customer
$order->addStatusHistoryComment(
__('Notified customer about invoice creation #%1.', $invoice->getId())
)
->setIsCustomerNotified(false)
->save();
$this->logger->writeLog('Invoice created successfully');
} catch (Exception $e) {
$this->logger->writeLog('Invoice not created');
}
}
}
public function getCustomShipQty($jsonData, $sku)
{
//$jsonData = (object)$this->json->unserialize($jsonData);
$jsonData = $this->json->unserialize($jsonData);
if (!empty($jsonData['items'])) {
foreach ($jsonData['items'] as $itesmData) {
$itesmData = (object)$itesmData;
if ($itesmData->item_sku == $sku) {
return $itesmData->item_qty;
}
}
}
return $itesmData = 0;
}
public function updateShipmentCustomDetails($shipmentId, $jsonData)
{
//$jsonData = (object)$this->json->unserialize($jsonData);
$jsonData = $this->json->unserialize($jsonData);
$connection = $this->resource->getConnection();
$data['ns_fulfillment_id'] = $jsonData['ns_fulfillment_id'];
$data['ns_fulfillment_number'] = $jsonData['ns_fulfillment_number'];
$data['ns_tracking_number'] = $jsonData['tracking_number'];
$data['ns_delivery_status'] = $jsonData['delivery_status'];
$data['ns_shipping_carrier'] = $jsonData['shipping_carrier'];
$data['ns_shipped_date'] = date("Y-m-d h:i:sa");
$where = ['entity_id = ?' => (int)$shipmentId];
/* update sales_shipment_grid */
$tableName = $connection->getTableName("sales_shipment_grid");
$connection->update($tableName, $data, $where);
/* update sales_shipment */
$tableName = $connection->getTableName("sales_shipment");
$connection->update($tableName, $data, $where);
/* update sales_shipment_item */
$itemarray = $jsonData['items'];
if (!empty($itemarray)) {
foreach ($itemarray as $key => $shipitem) {
$dataitem = [];
$itemconnection = $this->resource->getConnection();
$dataitem['ns_expected_delivery_from_date'] = $shipitem['expected_delivery_from_date'];
$dataitem['ns_expected_delivery_to_date'] = $shipitem['expected_delivery_to_date'];
$dataitem['ns_serial_no'] = $shipitem['serial_no'];
$dataitem['ns_certificate'] = $shipitem['certificate'];
$itemwhere = ['parent_id = ?' => (int)$shipmentId,'sku = ?' => $shipitem['item_sku']];
$itemtableName = $itemconnection->getTableName("sales_shipment_item");
$itemconnection->update($itemtableName, $dataitem, $itemwhere);
$this->logger->writeLog('Shipment Item Sku: '.$shipitem['item_sku']);
$this->logger->writeLog('Shipment Item Qty: '.$shipitem['item_qty']);
}
}
}
public function updateInvoiceCustomDetails($invoiceId, $jsonData)
{
$jsonData = (object)$this->json->unserialize($jsonData);
$connection = $this->resource->getConnection();
$data['ns_fulfillment_id'] = $jsonData->fulfillment_id;
$data['ns_fulfillment_number'] = $jsonData->fulfillment_number;
$where = ['entity_id = ?' => (int)$invoiceId];
/* update sales_invoice_grid */
$tableName = $connection->getTableName("sales_invoice_grid");
$connection->update($tableName, $data, $where);
/* update sales_invoice */
$tableName = $connection->getTableName("sales_invoice");
$connection->update($tableName, $data, $where);
}
public function getCreateShipmentByOrderId($orderId, $jsonData)
{
$order = $this->orderRepository->get($orderId);
// check if it's possible to ship the items
if ($order->canShip()) {
$this->logger->initLog(NetSuiteConstants::NETSUITE_CREATE_SHIPMENT_LOG_FILENAME);
$shipment = $this->convertOrder->toShipment($order);
foreach ($order->getAllItems() as $orderItem) {
// Check if the order item has Quantity to ship or is virtual
if (!$orderItem->getQtyToShip() || $orderItem->getIsVirtual()) {
continue;
}
$getshipCustomQty = $this->getCustomShipQty($jsonData, $orderItem->getSku());
$qtyShipped = $orderItem->getQtyToShip();
if (($getshipCustomQty > 0 ) && ($getshipCustomQty <= $qtyShipped )) {
// Create Shipment Item with Quantity
$shipmentItem = $this->convertOrder->itemToShipmentItem($orderItem)->setQty($getshipCustomQty);
// Add Shipment Item to Shipment
$shipment->addItem($shipmentItem);
}
}
$track = $this->setOrderTrackFactoryData($jsonData);
$shipment->addTrack($track);
// Register Shipment
$shipment->register();
$shipment->getOrder()->setIsInProcess(true);
try {
$shipment->getExtensionAttributes()->setSourceCode('default');
// Save created Shipment and Order
$shipment->save();
$shipmentId = $shipment->getId();
$incrementId = $shipment->getIncrementId();
$shipment->getOrder()->save();
// send shipping confirmation e-mail to customer
$this->shipmentNotifier->notify($shipment);
$this->updateShipmentCustomDetails($shipmentId, $jsonData);
return $incrementId.':'.$shipmentId;
} catch (\Exception $e) {
$this->logger->writeLog($e->getMessage());
$this->logger->writeLog('Fail to created Shipment');
}
}
}
public function setOrderTrackFactoryData($jsonData)
{
//$jsonData = (object)$this->json->unserialize($jsonData);
$jsonData = $this->json->unserialize($jsonData);
$track = $this->trackFactory->create();
$track->setTrackNumber($jsonData['tracking_number']);
$track->setCarrierCode(NetSuiteConstants::NETSUITE_TRACKING_CODE);
$track->setTitle($jsonData['shipping_carrier']);
return $track;
}
public function getOrderId(string $incrementOrderId)
{
$orderId = 0;
try {
$orderInfo = $this->orderInterface->loadByIncrementId($incrementOrderId);
$orderId = $orderInfo->getId();
return $orderId;
} catch (Exception $e) {
return $orderId;
}
}
}
+207
View File
@@ -0,0 +1,207 @@
<?php
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
namespace Caratlane\NetSuite\Model\Shipment;
use Magento\Framework\Webapi\Rest\Request;
use Caratlane\NetSuite\Api\UpdateInvoicePdfInterface;
use Caratlane\NetSuite\Model\NetsuiteUpdateinvoicepdfFactory;
use Caratlane\NetSuite\Model\NetSuiteConstants;
use Caratlane\NetSuite\Helper\Logger;
use Caratlane\NetSuite\Helper\Data;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\App\ResourceConnection;
use Magento\Sales\Model\Order\Shipment;
class UpdatePdf implements UpdateInvoicePdfInterface
{
/**
* @var \Magento\Framework\App\ResourceConnection
*/
private $resource;
/**
* @var \Magento\Sales\Model\Order\Shipment
*/
private $ordershipment;
/**
* @var \Caratlane\NetSuite\Helper\Logger
*/
protected $logger;
/**
* @var \Caratlane\NetSuite\Model\NetsuiteUpdateinvoicepdfFactory
*/
private $netsuiteupdateinvoicepdf;
/**
* @var \Magento\Framework\Serialize\Serializer\Json
*/
private $json;
/**
* @var \Caratlane\NetSuite\Helper\Data
*/
private $helper;
/**
* @var \Magento\Framework\Webapi\Rest\Request
*/
private $request;
/**
* @param ResourceConnection $resource
* @param Shipment $ordershipment
* @param Data $helper
* @param Json $json
* @param Logger $logger
* @param NetsuiteUpdateinvoicepdfFactory $netsuiteupdateinvoicepdf
* @param Request $request
*/
public function __construct(
Request $request,
ResourceConnection $resource,
Shipment $ordershipment,
Data $helper,
Json $json,
Logger $logger,
NetsuiteUpdateinvoicepdfFactory $netsuiteupdateinvoicepdf
) {
$this->request = $request;
$this->resource = $resource;
$this->ordershipment = $ordershipment;
$this->helper = $helper;
$this->json = $json;
$this->logger = $logger;
$this->netsuiteupdateinvoicepdf = $netsuiteupdateinvoicepdf;
}
public function updateInvoicePdf()
{
$responseData = [];
$responseData['success'] = NetSuiteConstants::NETSUITE_DEFAULT_ERROR_CODE;
$responseData['message'] = NetSuiteConstants::NETSUITE_DISABLE_MESSAGE;
if ($this->helper->getNetSuiteIsEnabled() && $this->helper->getNetsuiteUpdateInvoicepdfEnabled()) {
$this->logger->initLog(NetSuiteConstants::NETSUITE_CREATE_UPDATEPDF_LOG_FILENAME);
$this->logger->writeLog('----------------------------');
$this->logger->writeLog('Update invoice pdf Started');
$this->logger->writeLog('----------------------------');
$this->logger->writeLog('');
$postData = $this->request->getBodyParams();
try {
if ($postData['magento_shipment_id']) {
$this->logger->writeLog('Magento Shipment Id: '.$postData['magento_shipment_id']);
$postDataarray = [];
$postDataarray['ns_fulfillment_id'] = $postData['ns_fulfillment_id'];
$postDataarray['ns_fulfillment_number'] = $postData['ns_fulfillment_number'];
$postDataarray['magento_shipment_id'] = $postData['magento_shipment_id'];
$postDataarray['invoice_url'] = $postData['invoice_url'];
foreach ($postDataarray as $key => $postvalue) {
if ($postvalue == "") {
$this->logger->writeLog('Please add required fields');
$responseData['success'] = false;
$responseData['message'] = "Please add required fields";
return [$responseData];
}
}
$getshipmentid = $this->getordershipment($postData['magento_shipment_id']);
if ($getshipmentid != "") {
$netsuiteShipmentsModel = $this->netsuiteupdateinvoicepdf->create();
$netsuiteShipmentsModel->setMagentoShipmentId($postData['magento_shipment_id']);
$netsuiteShipmentsModel->setFulfillmentId($postData['ns_fulfillment_id']);
$netsuiteShipmentsModel->setFulfillmentNumber($postData['ns_fulfillment_number']);
$netsuiteShipmentsModel->setInvoiceUrl($postData['invoice_url']);
$netsuiteShipmentsModel->setStatus("completed");
$jsonData = $this->json->serialize($postData);
$netsuiteShipmentsModel->setJsonData($jsonData);
$netsuiteShipmentsModel->setMessages("Update Invoice PDF successfully.");
$netsuiteShipmentsModel->save();
//update data for shipment table
$connection = $this->resource->getConnection();
$data = [];
$data['ns_invoice_url'] = $postData['invoice_url'];
$where = ['increment_id = ?' => $postData['magento_shipment_id']];
/* update sales_shipment_grid */
$tableName = $connection->getTableName("sales_shipment_grid");
$connection->update($tableName, $data, $where);
/* update sales_shipment */
$tableName = $connection->getTableName("sales_shipment");
$connection->update($tableName, $data, $where);
$this->logger->writeLog('Invoice URL updated successfully');
$responseData['success'] = true;
$responseData['message'] = "Invoice URL updated successfully";
$responseData['magento_shipment_id'] = $postData['magento_shipment_id'];
} else {
$this->logger->writeLog('Shipment id not found in system ='.$postData['magento_shipment_id']);
$responseData['success'] = false;
$responseData['message'] = "Shipment id not found in system";
}
} else {
$this->logger->writeLog('magento_shipment_id field can\'t be empty');
$responseData['success'] = false;
$responseData['message'] = "magento_shipment_id field can't be empty";
}
} catch (Exception $e) {
$responseData['success'] = false;
$responseData['message'] = 'Exception : '.$e->getMessage();
$this->logger->writeLog('Exception: '.$e->getMessage());
}
$this->logger->writeLog('');
$this->logger->writeLog('----------------------------');
$this->logger->writeLog('Update invoice pdf Stopped');
$this->logger->writeLog('----------------------------');
}
return [$responseData];
}
public function getordershipment(string $incrementshipId)
{
$shipId = 0;
try {
$shipment = $this->ordershipment->loadByIncrementId($incrementshipId);
$shipId = $shipment->getId();
return $shipId;
} catch (Exception $e) {
return $shipId;
}
}
}
@@ -0,0 +1,83 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Ui\Component\Listing\Column;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
class ViewAction extends \Magento\Ui\Component\Listing\Columns\Column
{
/**
* @var UrlInterface
*/
protected $urlBuilder;
/**
* Constructor
*
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param UrlInterface $urlBuilder
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
UrlInterface $urlBuilder,
\Magento\Sales\Api\Data\OrderInterface $orderInterface,
array $components = [],
array $data = []
) {
$this->urlBuilder = $urlBuilder;
$this->orderInterface = $orderInterface;
parent::__construct($context, $uiComponentFactory, $components, $data);
}
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
if (isset($item['order_id'])) {
$order = $this->orderInterface->loadByIncrementId($item['order_id']);
$url = $this->urlBuilder->getUrl('sales/order/view', ['order_id' => $order->getId()]);
$link = '<a href="' . $url . '" target="_blank">' . $item['order_id'] . '</a>';
$item['order_id'] = $link;
}
if (isset($item['customer_id'])) {
$url = $this->urlBuilder->getUrl('customer/index/edit/id', ['customer_id' => $item['customer_id']]);
$link = '<a href="' . $url . '" target="_blank">' . $item['customer_id'] . '</a>';
$item['customer_id'] = $link;
}
if (isset($item['request_info'])) {
$url = $this->urlBuilder->getUrl('caratlane/netsuite/view/id', ['entity_id' => $item['entity_id']]);
$link = '<a href="' . $url . '" target="_blank">' . __('View') . '</a>';
$item['request_info'] = $link;
}
if (isset($item['json_data'])) {
$iid = $item['entity_id'];
$url = $this->urlBuilder->getUrl('caratlane/netsuite/createshippmentview/id', ['entity_id'=>$iid]);
$link = '<a href="' . $url . '" target="_blank">' . __('View') . '</a>';
$item['json_data'] = $link;
}
if (isset($item['response_info'])) {
$itemid = $item['entity_id'];
$url = $this->urlBuilder->getUrl('caratlane/netsuite/responseview/id', ['entity_id' => $itemid]);
$link = '<a href="' . $url . '" target="_blank">' . __('View') . '</a>';
$item['response_info'] = $link;
}
}
}
return $dataSource;
}
}
@@ -0,0 +1,68 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Ui\Component\Listing\Column;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
class ViewInvoiceUrl extends \Magento\Ui\Component\Listing\Columns\Column
{
/**
* @var UrlInterface
*/
protected $urlBuilder;
/**
* Constructor
*
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param UrlInterface $urlBuilder
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
UrlInterface $urlBuilder,
\Magento\Sales\Api\Data\OrderInterface $orderInterface,
array $components = [],
array $data = []
) {
$this->urlBuilder = $urlBuilder;
$this->orderInterface = $orderInterface;
parent::__construct($context, $uiComponentFactory, $components, $data);
}
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
if (isset($item['invoice_url'])) {
if (!empty($item['invoice_url'])) {
$url = $item['invoice_url'];
$link = '<a href="' . $url . '" target="_blank">' . __('View') . '</a>';
$item['invoice_url'] = $link;
}
}
if (isset($item['ns_invoice_url'])) {
if (!empty($item['ns_invoice_url'])) {
$url = $item['ns_invoice_url'];
$link = '<a href="' . $url . '" target="_blank">' . __('View') . '</a>';
$item['ns_invoice_url'] = $link;
}
}
}
}
return $dataSource;
}
}
@@ -0,0 +1,68 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Ui\Component\Listing\Column;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
class ViewInvoiceupdateUrl extends \Magento\Ui\Component\Listing\Columns\Column
{
/**
* @var UrlInterface
*/
protected $urlBuilder;
/**
* Constructor
*
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param UrlInterface $urlBuilder
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
UrlInterface $urlBuilder,
\Magento\Sales\Api\Data\OrderInterface $orderInterface,
array $components = [],
array $data = []
) {
$this->urlBuilder = $urlBuilder;
$this->orderInterface = $orderInterface;
parent::__construct($context, $uiComponentFactory, $components, $data);
}
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
if (isset($item['invoice_url'])) {
if (!empty($item['invoice_url'])) {
$url = $item['invoice_url'];
$link = '<a href="' . $url . '" target="_blank">' . __('View') . '</a>';
$item['invoice_url'] = $link;
}
}
if (isset($item['ns_invoice_url'])) {
if (!empty($item['ns_invoice_url'])) {
$url = $item['ns_invoice_url'];
$link = '<a href="' . $url . '" target="_blank">' . __('View') . '</a>';
$item['ns_invoice_url'] = $link;
}
}
}
}
return $dataSource;
}
}
@@ -0,0 +1,82 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Ui\Component\Listing\Column;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
class ViewShipment extends \Magento\Ui\Component\Listing\Columns\Column
{
/**
* @var UrlInterface
*/
protected $urlBuilder;
/**
* Constructor
*
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param UrlInterface $urlBuilder
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
UrlInterface $urlBuilder,
\Magento\Sales\Api\Data\OrderInterface $orderInterface,
array $components = [],
array $data = []
) {
$this->urlBuilder = $urlBuilder;
$this->orderInterface = $orderInterface;
parent::__construct($context, $uiComponentFactory, $components, $data);
}
public function getOrderId(string $incrementOrderId)
{
$orderId = 0;
try {
$orderInfo = $this->orderInterface->loadByIncrementId($incrementOrderId);
$orderId = $orderInfo->getId();
return $orderId;
} catch (Exception $e) {
return $orderId;
}
}
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
if (isset($item['magento_order_id'])) {
if (!empty($item['magento_order_id'])) {
$orderId = $this->getOrderId($item['magento_order_id']);
if ($orderId>0) {
$url = $this->urlBuilder->getUrl('sales/order/view/order_id/'.$orderId);
$link = '<a href="' . $url . '" target="_blank">' . $item['magento_order_id'] . '</a>';
$item['magento_order_id'] = $link;
}
}
}
if (isset($item['shipment_id'])) {
if ($item['shipment_id']>0) {
$url = $this->urlBuilder->getUrl('sales/shipment/view/shipment_id/'.$item['shipment_id']);
$link = '<a href="' . $url . '" target="_blank">' . $item['shipment_id'] . '</a>';
$item['shipment_id'] = $link;
}
}
}
}
return $dataSource;
}
}
@@ -0,0 +1,59 @@
<?php
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
namespace Caratlane\NetSuite\Ui\Component\Listing\Column;
use Magento\Framework\UrlInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
class ViewupdateinvoiceAction extends \Magento\Ui\Component\Listing\Columns\Column
{
/**
* @var UrlInterface
*/
protected $urlBuilder;
/**
* Constructor
*
* @param ContextInterface $context
* @param UiComponentFactory $uiComponentFactory
* @param UrlInterface $urlBuilder
* @param array $components
* @param array $data
*/
public function __construct(
ContextInterface $context,
UiComponentFactory $uiComponentFactory,
UrlInterface $urlBuilder,
\Magento\Sales\Api\Data\OrderInterface $orderInterface,
array $components = [],
array $data = []
) {
$this->urlBuilder = $urlBuilder;
$this->orderInterface = $orderInterface;
parent::__construct($context, $uiComponentFactory, $components, $data);
}
public function prepareDataSource(array $dataSource)
{
if (isset($dataSource['data']['items'])) {
foreach ($dataSource['data']['items'] as & $item) {
if (isset($item['json_data'])) {
$id = $item['entity_id'];
$url = $this->urlBuilder->getUrl('caratlane/netsuite/updateinvoicepdfview/id', ['entity_id'=>$id]);
$link = '<a href="' . $url . '" target="_blank">' . __('View') . '</a>';
$item['json_data'] = $link;
}
}
}
return $dataSource;
}
}
+27
View File
@@ -0,0 +1,27 @@
<?xml version="1.0"?>
<!--
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
<resource id="Caratlane_NetSuite::netsuite" title="NetSuite" sortOrder="10" >
<resource id="Caratlane_NetSuite::monitoring" title="Monitoring" sortOrder="50" >
<resource id="Caratlane_NetSuite::log" title="Orders Logs" sortOrder="100" />
<resource id="Caratlane_NetSuite::logview" title="Debug Log Viewer" sortOrder="100" />
</resource>
<resource id="Caratlane_NetSuite::settings" title="Settings" sortOrder="150">
<resource id="Caratlane_NetSuite::config" title="Configuration" sortOrder="10" />
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<!--
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
<menu>
<add id="Caratlane_NetSuite::netsuite" title="NetSuite" translate="title" module="Caratlane_NetSuite" sortOrder="60" resource="Caratlane_NetSuite::netsuite"/>
<add id="Caratlane_NetSuite::monitoring" title="Monitoring" translate="title" module="Caratlane_NetSuite" sortOrder="10" parent="Caratlane_NetSuite::netsuite" resource="Caratlane_NetSuite::netsuite"/>
<add id="Caratlane_NetSuite::log" title="Orders Logs" module="Caratlane_NetSuite" sortOrder="20" parent="Caratlane_NetSuite::monitoring" action="caratlane/netsuite/index/" resource="Caratlane_NetSuite::log"/>
<add id="Caratlane_NetSuite::createshipment" title="Shipment Logs" module="Caratlane_NetSuite" sortOrder="30" parent="Caratlane_NetSuite::monitoring" action="caratlane/netsuite/createshipments/" resource="Caratlane_NetSuite::createshipment"/>
<add id="Caratlane_NetSuite::orderupdate" title="Order Update Logs" module="Caratlane_NetSuite" sortOrder="31" parent="Caratlane_NetSuite::monitoring" action="caratlane/netsuite/orderupdate/" resource="Caratlane_NetSuite::orderupdate"/>
<add id="Caratlane_NetSuite::updateinvoicepdf" title="Update Invoice PDF" module="Caratlane_NetSuite" sortOrder="32" parent="Caratlane_NetSuite::monitoring" action="caratlane/netsuite/updateinvoicepdf/" resource="Caratlane_NetSuite::updateinvoicepdf"/>
<add id="Caratlane_NetSuite::logview" title="Debug Log Viewer" module="Caratlane_NetSuite" sortOrder="60" parent="Caratlane_NetSuite::monitoring" action="caratlane/logviewer/index" resource="Caratlane_NetSuite::logview"/>
<add id="Caratlane_NetSuite::settings" title="Settings" translate="title" module="Caratlane_NetSuite" sortOrder="80" parent="Caratlane_NetSuite::netsuite" resource="Caratlane_NetSuite::netsuite"/>
<add id="Caratlane_NetSuite::config" title="Configuration" module="Caratlane_NetSuite" sortOrder="10" parent="Caratlane_NetSuite::settings" action="adminhtml/system_config/edit/section/netsuite" resource="Caratlane_NetSuite::config"/>
</menu>
</config>
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<!--
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="admin">
<route id="caratlane" frontName="caratlane">
<module name="Caratlane_NetSuite"/>
</route>
</router>
</config>
+118
View File
@@ -0,0 +1,118 @@
<?xml version="1.0"?>
<!--
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="caratlane" translate="label" sortOrder="400">
<label>Caratlane</label>
</tab>
<section id="netsuite" translate="label" type="button" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<label>NetSuite</label>
<tab>caratlane</tab>
<resource>Caratlane_NetSuite::config</resource>
<group id="general" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1">
<label>General</label>
<field id="enable" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>
<group id="apidetail" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>API details</label>
<field id="oauth_realm" translate="label comment" sortOrder="2" type="text" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>OAuth Realm</label>
</field>
<field id="oauth_consumer_key" translate="label comment" sortOrder="2" type="text" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>OAuth Consumer Key</label>
</field>
<field id="oauth_consumer_secret" translate="label comment" sortOrder="2" type="text" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>OAuth Consumer Secret</label>
</field>
<field id="oauth_token" translate="label comment" sortOrder="2" type="text" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>OAuth Token</label>
</field>
<field id="oauth_token_secret" translate="label comment" sortOrder="2" type="text" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>OAuth Secret</label>
</field>
<field id="script" translate="label comment" sortOrder="2" type="text" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Script</label>
</field>
</group>
<group id="cronScheduled" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Push Orders</label>
<field id="enable" translate="label" type="select" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="api_url" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>API Url Key</label>
</field>
<field id="netsuite_count_from" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
<label>NetSuite Count From Days</label>
<comment>Order collection from last dayes</comment>
</field>
<field id="netsuite_max_attempt" translate="label" type="text" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
<label>NetSuite Max Attempt</label>
<comment>Order re-schedule Max fail to push</comment>
</field>
<field id="frequency" translate="label" type="select" sortOrder="4" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Frequency</label>
<source_model>Magento\Cron\Model\Config\Source\Frequency</source_model>
<backend_model>Caratlane\NetSuite\Model\Config\CronConfig</backend_model>
</field>
<field id="time" translate="label comment" sortOrder="5" type="time" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Start Time</label>
</field>
</group>
<group id="setCreateShipmentsFrequency" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Create Shipments</label>
<field id="enable" translate="label" type="select" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>
<group id="setOrdersUpdateFrequency" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Orders Update</label>
<field id="enable" translate="label" type="select" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>
<group id="setUpdateInvoicepdfFrequency" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1"
showInStore="1">
<label>Update Inovice PDF</label>
<field id="enable" translate="label" type="select" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Enable</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>
</section>
</system>
</config>
+35
View File
@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<!--
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
<netsuite>
<general>
<enable>1</enable>
</general>
<cronScheduled>
<enable>1</enable>
<netsuite_count_from>30</netsuite_count_from>
<api_url>https://7076539-sb1.restlets.api.netsuite.com/app/site/hosting/restlet.nl</api_url>
<netsuite_max_attempt>5</netsuite_max_attempt>
</cronScheduled>
<setCreateShipmentsFrequency>
<enable>1</enable>
<createshipmentfrequency>* * * * *</createshipmentfrequency>
</setCreateShipmentsFrequency>
<setTrackShipmentsFrequency>
<enable>1</enable>
<trackshipmentfrequency>* * * * *</trackshipmentfrequency>
</setTrackShipmentsFrequency>
<setTrackOrdersFrequency>
<enable>1</enable>
<trackorderfrequency>* * * * *</trackorderfrequency>
</setTrackOrdersFrequency>
</netsuite>
</default>
</config>
+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<!--
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/cron_groups.xsd">
<group id="netsuite_push_orders">
<schedule_generate_every>1</schedule_generate_every>
<schedule_ahead_for>4</schedule_ahead_for>
<schedule_lifetime>2</schedule_lifetime>
<history_cleanup_every>10</history_cleanup_every>
<history_success_lifetime>60</history_success_lifetime>
<history_failure_lifetime>600</history_failure_lifetime>
<use_separate_process>1</use_separate_process>
</group>
<group id="netsuite_clear_logs">
<schedule_generate_every>1</schedule_generate_every>
<schedule_ahead_for>4</schedule_ahead_for>
<schedule_lifetime>2</schedule_lifetime>
<history_cleanup_every>10</history_cleanup_every>
<history_success_lifetime>60</history_success_lifetime>
<history_failure_lifetime>600</history_failure_lifetime>
<use_separate_process>1</use_separate_process>
</group>
</config>
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<!--
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
<!-- <group id="netsuite_push_orders">
<job instance="Caratlane\NetSuite\Cron\PushSalesOrder" method="execute" name="netsuite_push_orders">
<schedule>* * * * *</schedule>
</job>
</group>
<group id="netsuite_clear_logs">
<job instance="Caratlane\NetSuite\Cron\ClearLogs" method="execute" name="netsuite_logs_clear">
<schedule>0 */12 * * *</schedule>
</job>
</group> -->
</config>
+131
View File
@@ -0,0 +1,131 @@
<?xml version="1.0"?>
<!--
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
-->
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
<table name="netsuite_shipments" resource="default" engine="innodb" comment="NetSuite Shipments">
<column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
<column xsi:type="varchar" name="magento_order_id" nullable="false" length="30" comment="Increment ID"/>
<column xsi:type="varchar" name="netsuite_order_id" nullable="false" length="30" comment="NetSuite Order ID"/>
<column xsi:type="varchar" name="fulfillment_id" nullable="false" length="30" comment="Fulfillment ID" />
<column xsi:type="varchar" name="fulfillment_number" nullable="false" length="30" comment="NetSuite Fulfillment Number"/>
<column xsi:type="varchar" name="tracking_number" nullable="false" length="30" comment="NetSuite Tracking Number"/>
<column xsi:type="varchar" name="shipping_carrier" nullable="false" length="30" comment="NetSuite Shipping Carrier"/>
<column xsi:type="varchar" name="shipped_date" nullable="false" length="30" comment="NetSuite Shipped Date"/>
<column xsi:type="varchar" name="shipment_id" nullable="false" length="30" comment="Shipment Id"/>
<column xsi:type="varchar" name="delivery_status" nullable="false" length="30" comment="NetSuite Delivery Status"/>
<column xsi:type="text" name="invoice_url" nullable="false" comment="NetSuite Invoice Url"/>
<column xsi:type="varchar" name="status" nullable="false" length="30" comment="Status"/>
<column xsi:type="text" name="json_data" nullable="false" comment="Json Data"/>
<column xsi:type="text" name="messages" nullable="true" comment="Messages"/>
<column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="entity_id"/>
</constraint>
</table>
<table name="netsuite_orders" resource="default" engine="innodb" comment="NetSuite log table">
<column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
<column xsi:type="varchar" name="order_id" length="255" nullable="false" comment="Order ID"/>
<column xsi:type="varchar" name="ns_order_id" length="11" nullable="false" comment="NS Order ID"/>
<column xsi:type="int" name="customer_id" unsigned="false" nullable="false" comment="Customer ID"/>
<column xsi:type="int" name="ns_customer_id" nullable="false" identity="false" comment="NS Customer ID"/>
<column xsi:type="text" name="request_info" nullable="false" comment="Request JSON"/>
<column xsi:type="text" name="response_info" nullable="false" comment="Response JSON"/>
<column xsi:type="varchar" name="status" length="255" nullable="false" comment="Status"/>
<column xsi:type="text" name="messages" nullable="false" comment="Messages"/>
<column xsi:type="datetime" name="created_at" on_update="false" nullable="true" comment="Created At "/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="entity_id"/>
</constraint>
<index referenceId="SALES_ORDER_ENTITY_ID" indexType="btree">
<column name="order_id"/>
</index>
<index referenceId="CUSTOMER_ENTITY_ENTITY_ID" indexType="btree">
<column name="customer_id"/>
</index>
</table>
<table name="sales_order">
<column xsi:type="varchar" name="netsuite_id" nullable="true" length="50" comment="NetSuite ID" />
<column xsi:type="int" name="netsuite_max_attempt" default="0" nullable="true" comment="NetSuite Max Attempt" />
<column xsi:type="smallint" name="push_to_netsuite" default="0" nullable="true" comment="Push To NetSuite status" />
<column xsi:type="datetime" name="netsuite_created_at" on_update="false" nullable="true" comment="NetSuite Created At"/>
<column xsi:type="varchar" name="netsuite_order_status" nullable="true" length="100" comment="NetSuite Order Status" />
</table>
<table name="sales_order_grid">
<column xsi:type="varchar" name="netsuite_id" nullable="true" length="50" comment="NetSuite ID" />
<column xsi:type="int" name="netsuite_max_attempt" default="0" nullable="true" comment="NetSuite Max Attempt" />
<column xsi:type="smallint" name="push_to_netsuite" default="0" nullable="true" comment="Push To NetSuite status" />
<column xsi:type="datetime" name="netsuite_created_at" on_update="false" nullable="true" comment="NetSuite Created At"/>
<column xsi:type="varchar" name="netsuite_order_status" nullable="true" length="100" comment="NetSuite Order Status" />
</table>
<table name="sales_invoice" resource="default" engine="innodb" comment="Sales Orders">
<column xsi:type="varchar" name="ns_fulfillment_id" nullable="false" length="30" comment="NetSuite Fulfillment ID" disabled="true"/>
<column xsi:type="varchar" name="ns_fulfillment_number" nullable="true" comment="NetSuite Fulfillment Number" disabled="true"/>
<column xsi:type="text" name="ns_invoice_url" nullable="false" comment="NetSuite Invoice Url" disabled="true"/>
</table>
<table name="sales_invoice_grid" resource="default" engine="innodb" comment="Sales Orders">
<column xsi:type="varchar" name="ns_fulfillment_id" nullable="false" length="30" comment="NetSuite Fulfillment ID" disabled="true"/>
<column xsi:type="varchar" name="ns_fulfillment_number" nullable="true" comment="NetSuite Fulfillment Number" disabled="true"/>
<column xsi:type="text" name="ns_invoice_url" nullable="false" comment="NetSuite Invoice Url" disabled="true"/>
</table>
<table name="sales_shipment" resource="default" engine="innodb" comment="Sales Orders">
<column xsi:type="varchar" name="ns_fulfillment_id" nullable="false" length="30" comment="NetSuite Fulfillment ID"/>
<column xsi:type="varchar" name="ns_fulfillment_number" nullable="true" comment="NetSuite Fulfillment Number"/>
<column xsi:type="varchar" name="ns_tracking_number" nullable="false" length="30" comment="Netsuite Tracking Number"/>
<column xsi:type="varchar" name="ns_shipping_carrier" nullable="false" length="30" comment="Netsuite Shipping Carrier"/>
<column xsi:type="varchar" name="ns_shipped_date" nullable="false" length="30" comment="Netsuite Shipped Date"/>
<column xsi:type="varchar" name="ns_delivery_status" nullable="false" length="30" comment="Netsuite Delivery Status"/>
<column xsi:type="text" name="ns_invoice_url" nullable="false" comment="Netsuite Invoice Url"/>
</table>
<table name="sales_shipment_grid" resource="default" engine="innodb" comment="Sales Orders">
<column xsi:type="varchar" name="ns_fulfillment_id" nullable="false" length="30" comment="NetSuite Fulfillment ID"/>
<column xsi:type="varchar" name="ns_fulfillment_number" nullable="true" comment="NetSuite Fulfillment Number"/>
<column xsi:type="varchar" name="ns_tracking_number" nullable="false" length="30" comment="Netsuite Tracking Number"/>
<column xsi:type="varchar" name="ns_shipping_carrier" nullable="false" length="30" comment="Netsuite Shipping Carrier"/>
<column xsi:type="varchar" name="ns_shipped_date" nullable="false" length="30" comment="Netsuite Shipped Date"/>
<column xsi:type="varchar" name="ns_delivery_status" nullable="false" length="30" comment="Netsuite Delivery Status"/>
<column xsi:type="text" name="ns_invoice_url" nullable="false" comment="Netsuite Invoice Url"/>
</table>
<table name="sales_shipment_item" resource="default" engine="innodb" comment="Sales Orders Item">
<column xsi:type="varchar" name="ns_expected_delivery_from_date" nullable="false" length="255" comment="Expected Delivery From Date"/>
<column xsi:type="varchar" name="ns_expected_delivery_to_date" nullable="false" length="255" comment="Expected Delivery To Date"/>
<column xsi:type="varchar" name="ns_serial_no" nullable="false" length="255" comment="Serial No"/>
<column xsi:type="varchar" name="ns_certificate" nullable="false" length="255" comment="Certificate"/>
</table>
<table name="netsuite_invoice_pdf" resource="default" engine="innodb" comment="NetSuite Invoice Pdf">
<column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
<column xsi:type="varchar" name="magento_shipment_id" nullable="false" length="255" comment="Shipment ID"/>
<column xsi:type="varchar" name="fulfillment_id" nullable="false" length="255" comment="Fulfillment ID" />
<column xsi:type="varchar" name="fulfillment_number" nullable="false" length="255" comment="NetSuite Fulfillment Number"/>
<column xsi:type="text" name="invoice_url" nullable="false" comment="NetSuite Invoice Url"/>
<column xsi:type="varchar" name="status" nullable="false" length="30" comment="Status"/>
<column xsi:type="text" name="json_data" nullable="false" comment="Json Data"/>
<column xsi:type="text" name="messages" nullable="true" comment="Messages"/>
<column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="entity_id"/>
</constraint>
</table>
<table name="netsuite_order_update" resource="default" engine="innodb" comment="NetSuite Orders Update">
<column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="true" comment="Entity ID"/>
<column xsi:type="varchar" name="magento_order_id" nullable="false" length="255" comment="Increment ID"/>
<column xsi:type="varchar" name="netsuite_order_id" nullable="false" length="255" comment="NetSuite Order ID"/>
<column xsi:type="varchar" name="netsuite_order_status" nullable="false" length="100" comment="NetSuite Order Status"/>
<column xsi:type="varchar" name="status" nullable="false" length="100" comment="Status"/>
<column xsi:type="text" name="json_data" nullable="false" comment="Json Data"/>
<column xsi:type="text" name="messages" nullable="true" comment="Messages"/>
<column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="CURRENT_TIMESTAMP" comment="Created At"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="entity_id"/>
</constraint>
</table>
<table name="sales_order_item">
<column xsi:type="varchar" name="qty_delivered" nullable="true" length="100" comment="Qty Delivered" />
<column xsi:type="varchar" name="netsuite_item_status" nullable="true" length="100" comment="NetSuite Item Status" />
</table>
</schema>
+174
View File
@@ -0,0 +1,174 @@
{
"netsuite_shipments": {
"column": {
"entity_id": true,
"magento_order_id": true,
"netsuite_order_id": true,
"fulfillment_id": true,
"fulfillment_number": true,
"tracking_number": true,
"shipping_carrier": true,
"shipped_date": true,
"shipment_id": true,
"delivery_status": true,
"invoice_url": true,
"status": true,
"json_data": true,
"messages": true,
"created_at": true
},
"constraint": {
"PRIMARY": true
}
},
"netsuite_track_orders": {
"column": {
"entity_id": true,
"magento_order_id": true,
"netsuite_order_id": true,
"order_status": true,
"status": true,
"json_data": true,
"messages": true,
"created_at": true
},
"constraint": {
"PRIMARY": true
}
},
"netsuite_track_shipments": {
"column": {
"entity_id": true,
"fulfillment_id": true,
"fulfillment_number": true,
"delivery_status": true,
"status": true,
"json_data": true,
"messages": true,
"created_at": true
},
"constraint": {
"PRIMARY": true
}
},
"netsuite_orders": {
"column": {
"entity_id": true,
"order_id": true,
"ns_order_id": true,
"customer_id": true,
"ns_customer_id": true,
"request_info": true,
"response_info": true,
"status": true,
"messages": true,
"created_at": true
},
"index": {
"NETSUITE_ORDERS_ORDER_ID": true,
"NETSUITE_ORDERS_CUSTOMER_ID": true
},
"constraint": {
"PRIMARY": true
}
},
"sales_order": {
"column": {
"netsuite_id": true,
"netsuite_max_attempt": true,
"push_to_netsuite": true,
"netsuite_created_at": true,
"netsuite_order_status": true
}
},
"sales_order_grid": {
"column": {
"netsuite_id": true,
"netsuite_max_attempt": true,
"push_to_netsuite": true,
"netsuite_created_at": true,
"netsuite_order_status": true
}
},
"sales_invoice_grid": {
"column": {
"ns_fulfillment_id": true,
"ns_fulfillment_number": true,
"ns_invoice_url": true
}
},
"sales_shipment": {
"column": {
"ns_fulfillment_id": true,
"ns_fulfillment_number": true,
"ns_tracking_number": true,
"ns_shipping_carrier": true,
"ns_shipped_date": true,
"ns_delivery_status": true,
"ns_invoice_url": true
}
},
"sales_shipment_grid": {
"column": {
"ns_fulfillment_id": true,
"ns_fulfillment_number": true,
"ns_tracking_number": true,
"ns_shipping_carrier": true,
"ns_shipped_date": true,
"ns_delivery_status": true,
"ns_invoice_url": true
}
},
"sales_invoice": {
"column": {
"ns_fulfillment_id": true,
"ns_fulfillment_number": true,
"ns_invoice_url": true
}
},
"sales_shipment_item": {
"column": {
"ns_expected_delivery_from_date": true,
"ns_expected_delivery_to_date": true,
"ns_serial_no": true,
"ns_certificate": true
}
},
"netsuite_invoice_pdf": {
"column": {
"entity_id": true,
"magento_shipment_id": true,
"fulfillment_id": true,
"fulfillment_number": true,
"invoice_url": true,
"status": true,
"json_data": true,
"messages": true,
"created_at": true
},
"constraint": {
"PRIMARY": true
}
},
"netsuite_order_update": {
"column": {
"entity_id": true,
"magento_order_id": true,
"netsuite_order_id": true,
"netsuite_order_status": true,
"status": true,
"json_data": true,
"messages": true,
"created_at": true
},
"constraint": {
"PRIMARY": true
}
},
"sales_order_item": {
"column": {
"qty_delivered": true,
"netsuite_item_status": true
}
}
}
+107
View File
@@ -0,0 +1,107 @@
<?xml version="1.0"?>
<!--
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
<preference for="Caratlane\NetSuite\Api\CreateShipmentInterface" type="Caratlane\NetSuite\Model\Shipment\CreateShipment" />
<preference for="Caratlane\NetSuite\Api\UpdateInvoicePdfInterface" type="Caratlane\NetSuite\Model\Shipment\UpdatePdf" />
<preference for="Caratlane\NetSuite\Api\CreateProductInterface" type="Caratlane\NetSuite\Model\Product\CreateProduct" />
<preference for="Caratlane\NetSuite\Api\OrderUpdateInterface" type="Caratlane\NetSuite\Model\Order\OrderUpdate" />
<preference for="Magento\Sales\Model\Order\Payment\State\CaptureCommand" type="Caratlane\NetSuite\Model\Order\Payment\State\CaptureCommand" />
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="netSuite_create_shipments_listing_data_source" xsi:type="string">Caratlane\NetSuite\Model\ResourceModel\NetsuiteShipments\Grid\Collection</item>
</argument>
</arguments>
</type>
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="netSuite_updateinvoicepdf_listing_data_source" xsi:type="string">Caratlane\NetSuite\Model\ResourceModel\NetsuiteUpdateinvoicepdf\Grid\Collection</item>
</argument>
</arguments>
</type>
<virtualType name="Caratlane\NetSuite\Model\ResourceModel\NetsuiteShipments\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">netsuite_shipments</argument>
<argument name="resourceModel" xsi:type="string">Caratlane\NetSuite\Model\ResourceModel\NetsuiteShipments</argument>
</arguments>
</virtualType>
<virtualType name="Caratlane\NetSuite\Model\ResourceModel\NetsuiteUpdateinvoicepdf\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">netsuite_invoice_pdf</argument>
<argument name="resourceModel" xsi:type="string">Caratlane\NetSuite\Model\ResourceModel\NetsuiteUpdateinvoicepdf</argument>
</arguments>
</virtualType>
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="netSuite_trackshipments_listing_data_source" xsi:type="string">Caratlane\NetSuite\Model\ResourceModel\NetSuiteTrackShipments\Grid\Collection</item>
</argument>
</arguments>
</type>
<virtualType name="Caratlane\NetSuite\Model\ResourceModel\NetSuiteTrackShipments\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">netsuite_track_shipments</argument>
<argument name="resourceModel" xsi:type="string">Caratlane\NetSuite\Model\ResourceModel\NetSuiteTrackShipments</argument>
</arguments>
</virtualType>
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="netSuite_orderupdate_listing_data_source" xsi:type="string">Caratlane\NetSuite\Model\ResourceModel\NetSuiteOrdersUpdate\Grid\Collection</item>
</argument>
</arguments>
</type>
<virtualType name="Caratlane\NetSuite\Model\ResourceModel\NetSuiteOrdersUpdate\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">netsuite_order_update</argument>
<argument name="resourceModel" xsi:type="string">Caratlane\NetSuite\Model\ResourceModel\NetSuiteOrdersUpdate</argument>
</arguments>
</virtualType>
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
<arguments>
<argument name="collections" xsi:type="array">
<item name="netsuite_order_log_listing_data_source" xsi:type="string">Caratlane\NetSuite\Model\ResourceModel\NetSuite\Grid\Collection</item>
</argument>
</arguments>
</type>
<virtualType name="Caratlane\NetSuite\Model\ResourceModel\NetSuite\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
<arguments>
<argument name="mainTable" xsi:type="string">netsuite_orders</argument>
<argument name="resourceModel" xsi:type="string">Caratlane\NetSuite\Model\ResourceModel\NetSuite</argument>
</arguments>
</virtualType>
<virtualType name="Magento\Sales\Model\ResourceModel\Order\Grid" type="Magento\Sales\Model\ResourceModel\Grid">
<arguments>
<argument name="columns" xsi:type="array">
<item name="netsuite_id" xsi:type="string">sales_order.netsuite_id</item>
<item name="netsuite_max_attempt" xsi:type="string">sales_order.netsuite_max_attempt</item>
<item name="push_to_netsuite" xsi:type="string">sales_order.push_to_netsuite</item>
<item name="netsuite_created_at" xsi:type="string">sales_order.netsuite_created_at</item>
<item name="netsuite_order_status" xsi:type="string">sales_order.netsuite_order_status</item>
</argument>
</arguments>
</virtualType>
<virtualType name="Magento\Sales\Model\ResourceModel\Order\Shipment\Grid" type="Magento\Sales\Model\ResourceModel\Grid">
<arguments>
<argument name="columns" xsi:type="array">
<item name="ns_fulfillment_id" xsi:type="string">sales_shipment.ns_fulfillment_id</item>
<item name="ns_fulfillment_number" xsi:type="string">sales_shipment.ns_fulfillment_number</item>
<item name="ns_tracking_number" xsi:type="string">sales_shipment.ns_tracking_number</item>
<item name="ns_shipping_carrier" xsi:type="string">sales_shipment.ns_shipping_carrier</item>
<item name="ns_shipped_date" xsi:type="string">sales_shipment.ns_shipped_date</item>
<item name="ns_delivery_status" xsi:type="string">sales_shipment.ns_delivery_status</item>
<item name="ns_invoice_url" xsi:type="string">sales_shipment.ns_invoice_url</item>
</argument>
</arguments>
</virtualType>
</config>
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<!--
/**
* Module declaration file
*
* @author 18th Digitech <mailto:info@18thdigitech.com>
* @package Caratlane_NetSuite
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Caratlane_NetSuite" setup_version="1.0.0">
<sequence>
<module name="Magento_Sales"/>
<module name="Magento_Quote"/>
<module name="Magento_Checkout"/>
</sequence>
</module>
</config>
+48
View File
@@ -0,0 +1,48 @@
<?xml version="1.0"?>
<!--
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
-->
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
<route url="/V1/nsapi/create-shipment" method="POST">
<service class="Caratlane\NetSuite\Api\CreateShipmentInterface" method="createNewShipment"/>
<resources>
<resource ref="Magento_Sales::sales"/>
</resources>
</route>
<route url="/V1/nsapi/order-update" method="POST">
<service class="Caratlane\NetSuite\Api\OrderUpdateInterface" method="getOrderUpdate"/>
<resources>
<resource ref="Magento_Sales::sales"/>
</resources>
</route>
<route url="/V1/nsapi/update-invoice-pdf" method="POST">
<service class="Caratlane\NetSuite\Api\UpdateInvoicePdfInterface" method="updateInvoicePdf"/>
<resources>
<resource ref="Magento_Sales::sales"/>
</resources>
</route>
<route url="/V1/nsapi/create-product" method="POST">
<service class="Caratlane\NetSuite\Api\CreateProductInterface" method="createProduct"/>
<resources>
<resource ref="Magento_Sales::sales"/>
</resources>
</route>
</routes>
+12
View File
@@ -0,0 +1,12 @@
<?php declare(strict_types=1);
/**
*@author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Caratlane_NetSuite',
__DIR__
);
@@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!--
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<referenceBlock name="page.title">
<action method="setPageTitle">
<argument name="title" xsi:type="string">Debug Log Viewer</argument>
</action>
</referenceBlock>
<body>
<referenceContainer name="content">
<block class="Caratlane\NetSuite\Block\Adminhtml\Logviewer" template="Caratlane_NetSuite::log_viewer.phtml" cacheable="false"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<!--
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>
<referenceContainer name="content">
<uiComponent name="netSuite_create_shipments_listing"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<!--
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>
<referenceContainer name="content">
<uiComponent name="netsuite_order_log_listing"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<!--
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>
<referenceContainer name="content">
<uiComponent name="netSuite_orderupdate_listing"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<!--
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>
<referenceContainer name="content">
<uiComponent name="netSuite_trackshipments_listing"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<!--
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
<update handle="styles"/>
<body>
<referenceContainer name="content">
<uiComponent name="netSuite_updateinvoicepdf_listing"/>
</referenceContainer>
</body>
</page>
@@ -0,0 +1,105 @@
<?php
$dates = $block->getDates();
$logs = $block->getLogs();
?>
<div id="logviewer">
<form method ="get">
<h3><?= $block->escapeHtml(__('Default log location')); ?>: netsuite/</h3>
<div class="filters">
<div class="select_date logviewer-cols">
<label for="date"><strong><?= $block->escapeHtml(__('Date')); ?>:</strong></label>
<select class="date" id="date" name="date" onchange="this.form.submit()">
<?php foreach ($dates as $date) { ?>
<?php if ($date['selected']) { $selected = "selected";
} else { $selected = ""; } ?>
<option value="<?= $block->escapeHtml($date['date']) ?>" <?= $block->escapeHtml($selected); ?>>
<?= $block->escapeHtml($date['date']) ?>
</option>
<?php } ?>
</select>
</div>
<div class="select_logs logviewer-cols">
<label for="logfile"><strong><?= $block->escapeHtml(__('Log')); ?>:</strong></label>
<select class="logfile" id="logfile" name="logfile" onchange="this.form.submit()">
<option value=""><?= $block->escapeHtml(__('--select log--')); ?></option>
<?php foreach ($logs as $log) { ?>
<?php if ($log['selected']) { $selected = "selected";
} else { $selected = ""; } ?>
<option value="<?= $block->escapeHtml($log['log']) ?>" <?= $block->escapeHtml($selected); ?>>
<?= $block->escapeHtml($log['log']) ?>
</option>
<?php } ?>
</select>
</div>
<div class="action-buttons logviewer-cols">
<button id="refresh-logs" type="button" class="action- scalable primary" onclick ="this.form.submit()">
<span><?= $block->escapeHtml(__('Refresh Logs')); ?></span>
</button>
<button id="clear-logs" type="button" class="action- scalable primary">
<span><?= $block->escapeHtml(__('Clear Logs')); ?></span>
</button>
<button id="download-logs" type="button" class="action- scalable primary">
<span><?= $block->escapeHtml(__('Download Logs')); ?></span>
</button>
</div>
</div>
<div style="border: 4px solid #dfdfdf; overflow: hidden; height: 700px; padding: 2px; clear: both; margin-top: 20px;">
<div id="log_data" class="qb_log" style="width:100%;height:690px;overflow:scroll;margin:0;
padding:3px;background:#111111;color:white;
font:normal 12px Lucida Console, Courier New, serif;">
<?= $block->escapeHtml($block->getLogFileContent()); ?>
</div>
</div>
</form>
</div>
<script>
require([
'jquery',
'Magento_Ui/js/modal/confirm'
],
function($, confirmation) {
$('#download-logs').on('click', function (e){
e.preventDefault();
confirmation({
title: 'Alert',
content: 'Do you want to download log file?',
actions: {
confirm: function () {
location.href = "<?= $block->escapeHtml($block->getDownloadLogsUrl()); ?>";
},
cancel: function () {
return false;
}
}
});
});
$('#clear-logs').on('click', function (e){
e.preventDefault();
confirmation({
title: 'Alert',
content: 'Do you want to clear log file?',
actions: {
confirm: function () {
location.href = "<?= $block->escapeHtml($block->getClearLogsUrl()); ?>";
},
cancel: function () {
return false;
}
}
});
});
});
</script>
<style>
.logviewer-cols{
display: inline-block;
margin-right: 30px;
}
#logviewer select{
padding: 5px 15px;
min-width: 200px;
}
button#refresh-logs, button#clear-logs {
margin-right: 30px;
}
</style>
@@ -0,0 +1,302 @@
<?xml version="1.0"?>
<!--
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
-->
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">netSuite_create_shipments_listing.netSuite_create_shipments_listing_data_source</item>
<item name="deps" xsi:type="string">netSuite_create_shipments_listing.netSuite_create_shipments_listing_data_source</item>
</item>
<item name="spinner" xsi:type="string">spinner_columns</item>
<item name="buttons" xsi:type="array">
<item name="viewlogs" xsi:type="array">
<item name="name" xsi:type="string">viewlogs</item>
<item name="label" xsi:type="string">View Logs</item>
<item name="class" xsi:type="string">primary</item>
<item name="url" xsi:type="string">caratlane/logviewer/index</item>
</item>
<item name="clearshipmenthistory" xsi:type="array">
<item name="name" xsi:type="string">clearhistory</item>
<item name="label" xsi:type="string">Clear History</item>
<item name="class" xsi:type="string">primary</item>
<item name="url" xsi:type="string">caratlane/netsuite/clearshipmenthistory</item>
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Delete Image(s)</item>
<item name="message" xsi:type="string" translate="true">Are you sure you want to delete selected items?</item>
</item>
</item>
</item>
</argument>
<dataSource name="nameOfDataSource">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider</argument>
<argument name="name" xsi:type="string">netSuite_create_shipments_listing_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">entity_id</argument>
<argument name="requestFieldName" xsi:type="string">id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
<item name="update_url" xsi:type="url" path="mui/index/render"/>
<item name="storageConfig" xsi:type="array">
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</item>
</argument>
</argument>
</dataSource>
<container name="listing_top">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/grid/toolbar</item>
</item>
</argument>
<massaction name="listing_massaction">
<argument name="data" xsi:type="array">
<item name="data" xsi:type="array">
<item name="selectProvider" xsi:type="string">netSuite_create_shipments_listing.netSuite_create_shipments_listing.spinner_columns.ids</item>
<item name="displayArea" xsi:type="string">bottom</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/tree-massactions</item>
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</argument>
<action name="delete">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="type" xsi:type="string">delete</item>
<item name="label" xsi:type="string" translate="true">Delete</item>
<item name="url" xsi:type="url" path="*/*/shipmentmassdelete"/>
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Delete Image(s)</item>
<item name="message" xsi:type="string" translate="true">Are you sure you want to delete selected items?</item>
</item>
</item>
</argument>
</action>
</massaction>
<filters name="listing_filters">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="templates" xsi:type="array">
<item name="filters" xsi:type="array">
<item name="select" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</item>
<item name="template" xsi:type="string">ui/grid/filters/elements/ui-select</item>
</item>
</item>
</item>
</item>
</argument>
</filters>
<bookmark name="bookmarks" />
<component name="columns_controls" />
<exportButton name="export_button" />
<paging name="listing_paging" />
</container>
<columns name="spinner_columns">
<selectionsColumn name="ids">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="resizeEnabled" xsi:type="boolean">false</item>
<item name="resizeDefaultWidth" xsi:type="string">55</item>
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</argument>
</selectionsColumn>
<column name="entity_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">textRange</item>
<item name="sorting" xsi:type="string">asc</item>
<item name="label" xsi:type="string" translate="true">ID</item>
</item>
</argument>
</column>
<column name="magento_order_id" class="Caratlane\NetSuite\Ui\Component\Listing\Column\ViewShipment">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="sorting" xsi:type="string">false</item>
<item name="label" xsi:type="string" translate="true">Order Id</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
</item>
</argument>
</column>
<column name="netsuite_order_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">NS Order Id</item>
</item>
</argument>
</column>
<column name="fulfillment_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Fulfillment ID</item>
</item>
</argument>
</column>
<column name="fulfillment_number">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Fulfillment Number</item>
</item>
</argument>
</column>
<column name="tracking_number">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Tracking Number</item>
</item>
</argument>
</column>
<column name="shipping_carrier">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Shipping Carrier</item>
</item>
</argument>
</column>
<column name="delivery_status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Delivery Status</item>
</item>
</argument>
</column>
<column name="shipped_date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Shipped Date</item>
</item>
</argument>
</column>
<column name="status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Status</item>
</item>
</argument>
</column>
<column name="json_data" class="Caratlane\NetSuite\Ui\Component\Listing\Column\ViewAction">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">false</item>
<item name="sorting" xsi:type="string">false</item>
<item name="label" xsi:type="string" translate="true">Request Info</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
</item>
</argument>
</column>
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
<item name="dataType" xsi:type="string">date</item>
<item name="label" xsi:type="string" translate="true">Created</item>
</item>
</argument>
</column>
<column name="shipment_id" class="Caratlane\NetSuite\Ui\Component\Listing\Column\ViewShipment">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="sorting" xsi:type="string">false</item>
<item name="label" xsi:type="string" translate="true">Magento Shipment ID</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
</item>
</argument>
</column>
<column name="messages">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Messages</item>
</item>
</argument>
</column>
</columns>
</listing>
@@ -0,0 +1,211 @@
<?xml version="1.0"?>
<!--
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
-->
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">netSuite_orderupdate_listing.netSuite_orderupdate_listing_data_source</item>
<item name="deps" xsi:type="string">netSuite_orderupdate_listing.netSuite_orderupdate_listing_data_source</item>
</item>
<item name="spinner" xsi:type="string">spinner_columns</item>
<item name="buttons" xsi:type="array">
<item name="viewlogs" xsi:type="array">
<item name="name" xsi:type="string">viewlogs</item>
<item name="label" xsi:type="string">View Logs</item>
<item name="class" xsi:type="string">primary</item>
<item name="url" xsi:type="string">caratlane/logviewer/index</item>
</item>
<item name="clearshipmenthistory" xsi:type="array">
<item name="name" xsi:type="string">clearhistory</item>
<item name="label" xsi:type="string">Clear History</item>
<item name="class" xsi:type="string">primary</item>
<item name="url" xsi:type="string">caratlane/netsuite/clearorderstatushistory</item>
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Delete Image(s)</item>
<item name="message" xsi:type="string" translate="true">Are you sure you want to delete selected items?</item>
</item>
</item>
</item>
</argument>
<dataSource name="nameOfDataSource">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider</argument>
<argument name="name" xsi:type="string">netSuite_orderupdate_listing_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">entity_id</argument>
<argument name="requestFieldName" xsi:type="string">id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
<item name="update_url" xsi:type="url" path="mui/index/render"/>
<item name="storageConfig" xsi:type="array">
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</item>
</argument>
</argument>
</dataSource>
<container name="listing_top">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/grid/toolbar</item>
</item>
</argument>
<massaction name="listing_massaction">
<argument name="data" xsi:type="array">
<item name="data" xsi:type="array">
<item name="selectProvider" xsi:type="string">netSuite_orderupdate_listing.netSuite_orderupdate_listing.spinner_columns.ids</item>
<item name="displayArea" xsi:type="string">bottom</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/tree-massactions</item>
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</argument>
<action name="delete">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="type" xsi:type="string">delete</item>
<item name="label" xsi:type="string" translate="true">Delete</item>
<item name="url" xsi:type="url" path="caratlane/netsuite/orderupdatemassdelete"/>
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Delete Image(s)</item>
<item name="message" xsi:type="string" translate="true">Are you sure you want to delete selected items?</item>
</item>
</item>
</argument>
</action>
</massaction>
<filters name="listing_filters">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="templates" xsi:type="array">
<item name="filters" xsi:type="array">
<item name="select" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</item>
<item name="template" xsi:type="string">ui/grid/filters/elements/ui-select</item>
</item>
</item>
</item>
</item>
</argument>
</filters>
<bookmark name="bookmarks" />
<component name="columns_controls" />
<exportButton name="export_button" />
<paging name="listing_paging" />
</container>
<columns name="spinner_columns">
<selectionsColumn name="ids">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="resizeEnabled" xsi:type="boolean">false</item>
<item name="resizeDefaultWidth" xsi:type="string">55</item>
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</argument>
</selectionsColumn>
<column name="entity_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">textRange</item>
<item name="sorting" xsi:type="string">asc</item>
<item name="label" xsi:type="string" translate="true">ID</item>
</item>
</argument>
</column>
<column name="magento_order_id" class="Caratlane\NetSuite\Ui\Component\Listing\Column\ViewShipment">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="sorting" xsi:type="string">false</item>
<item name="label" xsi:type="string" translate="true">Magento Order ID</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
</item>
</argument>
</column>
<column name="netsuite_order_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">NetSuite Order ID</item>
</item>
</argument>
</column>
<column name="netsuite_order_status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Order Status</item>
</item>
</argument>
</column>
<column name="status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Status</item>
</item>
</argument>
</column>
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
<item name="dataType" xsi:type="string">date</item>
<item name="label" xsi:type="string" translate="true">Created</item>
</item>
</argument>
</column>
<column name="messages">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Messages</item>
</item>
</argument>
</column>
</columns>
</listing>
@@ -0,0 +1,214 @@
<?xml version="1.0"?>
<!--
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
-->
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">netSuite_trackshipments_listing.netSuite_trackshipments_listing_data_source</item>
<item name="deps" xsi:type="string">netSuite_trackshipments_listing.netSuite_trackshipments_listing_data_source</item>
</item>
<item name="spinner" xsi:type="string">spinner_columns</item>
<item name="buttons" xsi:type="array">
<item name="viewlogs" xsi:type="array">
<item name="name" xsi:type="string">viewlogs</item>
<item name="label" xsi:type="string">View Logs</item>
<item name="class" xsi:type="string">primary</item>
<item name="url" xsi:type="string">caratlane/logviewer/index</item>
</item>
<item name="clearshipmenthistory" xsi:type="array">
<item name="name" xsi:type="string">clearhistory</item>
<item name="label" xsi:type="string">Clear History</item>
<item name="class" xsi:type="string">primary</item>
<item name="url" xsi:type="string">caratlane/netsuite/cleartrackshipmentshistory</item>
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Delete Image(s)</item>
<item name="message" xsi:type="string" translate="true">Are you sure you want to delete selected items?</item>
</item>
</item>
</item>
</argument>
<dataSource name="nameOfDataSource">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider</argument>
<argument name="name" xsi:type="string">netSuite_trackshipments_listing_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">entity_id</argument>
<argument name="requestFieldName" xsi:type="string">id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
<item name="update_url" xsi:type="url" path="mui/index/render"/>
<item name="storageConfig" xsi:type="array">
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</item>
</argument>
</argument>
</dataSource>
<container name="listing_top">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/grid/toolbar</item>
</item>
</argument>
<massaction name="listing_massaction">
<argument name="data" xsi:type="array">
<item name="data" xsi:type="array">
<item name="selectProvider" xsi:type="string">netSuite_trackshipments_listing.netSuite_trackshipments_listing.spinner_columns.ids</item>
<item name="displayArea" xsi:type="string">bottom</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/tree-massactions</item>
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</argument>
<action name="delete">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="type" xsi:type="string">delete</item>
<item name="label" xsi:type="string" translate="true">Delete</item>
<item name="url" xsi:type="url" path="caratlane/netsuite/trackshipmentsmassdelete"/>
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Delete Image(s)</item>
<item name="message" xsi:type="string" translate="true">Are you sure you want to delete selected items?</item>
</item>
</item>
</argument>
</action>
</massaction>
<filters name="listing_filters">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="templates" xsi:type="array">
<item name="filters" xsi:type="array">
<item name="select" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</item>
<item name="template" xsi:type="string">ui/grid/filters/elements/ui-select</item>
</item>
</item>
</item>
</item>
</argument>
</filters>
<bookmark name="bookmarks" />
<component name="columns_controls" />
<exportButton name="export_button" />
<paging name="listing_paging" />
</container>
<columns name="spinner_columns">
<selectionsColumn name="ids">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="resizeEnabled" xsi:type="boolean">false</item>
<item name="resizeDefaultWidth" xsi:type="string">55</item>
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</argument>
</selectionsColumn>
<column name="entity_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">textRange</item>
<item name="sorting" xsi:type="string">asc</item>
<item name="label" xsi:type="string" translate="true">ID</item>
</item>
</argument>
</column>
<column name="fulfillment_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Fulfillment ID</item>
</item>
</argument>
</column>
<column name="fulfillment_number">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Fulfillment Number</item>
</item>
</argument>
</column>
<column name="delivery_status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Delivery Status</item>
</item>
</argument>
</column>
<column name="status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Status</item>
</item>
</argument>
</column>
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
<item name="dataType" xsi:type="string">date</item>
<item name="label" xsi:type="string" translate="true">Created</item>
</item>
</argument>
</column>
<column name="messages">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Messages</item>
</item>
</argument>
</column>
</columns>
</listing>
@@ -0,0 +1,219 @@
<?xml version="1.0"?>
<!--
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
-->
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">netSuite_updateinvoicepdf_listing.netSuite_updateinvoicepdf_listing_data_source</item>
<item name="deps" xsi:type="string">netSuite_updateinvoicepdf_listing.netSuite_updateinvoicepdf_listing_data_source</item>
</item>
<item name="spinner" xsi:type="string">spinner_columns</item>
</argument>
<dataSource name="nameOfDataSource">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider</argument>
<argument name="name" xsi:type="string">netSuite_updateinvoicepdf_listing_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">entity_id</argument>
<argument name="requestFieldName" xsi:type="string">id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
<item name="update_url" xsi:type="url" path="mui/index/render"/>
<item name="storageConfig" xsi:type="array">
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</item>
</argument>
</argument>
</dataSource>
<container name="listing_top">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/grid/toolbar</item>
</item>
</argument>
<massaction name="listing_massaction">
<argument name="data" xsi:type="array">
<item name="data" xsi:type="array">
<item name="selectProvider" xsi:type="string">netSuite_updateinvoicepdf_listing.netSuite_updateinvoicepdf_listing.spinner_columns.ids</item>
<item name="displayArea" xsi:type="string">bottom</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/tree-massactions</item>
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</argument>
<action name="delete">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="type" xsi:type="string">delete</item>
<item name="label" xsi:type="string" translate="true">Delete</item>
<item name="url" xsi:type="url" path="*/*/updateinvoicemassdelete"/>
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Delete Image(s)</item>
<item name="message" xsi:type="string" translate="true">Are you sure you want to delete selected items?</item>
</item>
</item>
</argument>
</action>
</massaction>
<filters name="listing_filters">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="templates" xsi:type="array">
<item name="filters" xsi:type="array">
<item name="select" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</item>
<item name="template" xsi:type="string">ui/grid/filters/elements/ui-select</item>
</item>
</item>
</item>
</item>
</argument>
</filters>
<bookmark name="bookmarks" />
<component name="columns_controls" />
<exportButton name="export_button" />
<paging name="listing_paging" />
</container>
<columns name="spinner_columns">
<selectionsColumn name="ids">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="resizeEnabled" xsi:type="boolean">false</item>
<item name="resizeDefaultWidth" xsi:type="string">55</item>
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</argument>
</selectionsColumn>
<column name="entity_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">textRange</item>
<item name="sorting" xsi:type="string">asc</item>
<item name="label" xsi:type="string" translate="true">ID</item>
</item>
</argument>
</column>
<column name="magento_shipment_id" class="Caratlane\NetSuite\Ui\Component\Listing\Column\ViewShipment">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="sorting" xsi:type="string">false</item>
<item name="label" xsi:type="string" translate="true">Magento Shipment Id</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
</item>
</argument>
</column>
<column name="fulfillment_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Fulfillment ID</item>
</item>
</argument>
</column>
<column name="fulfillment_number">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Fulfillment Number</item>
</item>
</argument>
</column>
<column name="status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Status</item>
</item>
</argument>
</column>
<column name="json_data" class="Caratlane\NetSuite\Ui\Component\Listing\Column\ViewupdateinvoiceAction">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">false</item>
<item name="sorting" xsi:type="string">false</item>
<item name="label" xsi:type="string" translate="true">Request Info</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
</item>
</argument>
</column>
<column name="invoice_url" class="Caratlane\NetSuite\Ui\Component\Listing\Column\ViewInvoiceupdateUrl">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">false</item>
<item name="sorting" xsi:type="string">false</item>
<item name="label" xsi:type="string" translate="true">Invoice URL</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
</item>
</argument>
</column>
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
<item name="dataType" xsi:type="string">date</item>
<item name="label" xsi:type="string" translate="true">Created</item>
</item>
</argument>
</column>
<column name="messages">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="editor" xsi:type="array">
<item name="editorType" xsi:type="string">text</item>
<item name="validation" xsi:type="array">
<item name="required-entry" xsi:type="boolean">true</item>
</item>
</item>
<item name="label" xsi:type="string" translate="true">Messages</item>
</item>
</argument>
</column>
</columns>
</listing>
@@ -0,0 +1,202 @@
<?xml version="1.0"?>
<!--
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
-->
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<argument name="data" xsi:type="array">
<item name="js_config" xsi:type="array">
<item name="provider" xsi:type="string">netsuite_order_log_listing.netsuite_order_log_listing_data_source</item>
<item name="deps" xsi:type="string">netsuite_order_log_listing.netsuite_order_log_listing_data_source</item>
</item>
<item name="spinner" xsi:type="string">spinner_columns</item>
<item name="buttons" xsi:type="array">
<item name="viewlogs" xsi:type="array">
<item name="name" xsi:type="string">viewlogs</item>
<item name="label" xsi:type="string">View Logs</item>
<item name="class" xsi:type="string">primary</item>
<item name="url" xsi:type="string">caratlane/logviewer/index</item>
</item>
<item name="clearhistory" xsi:type="array">
<item name="name" xsi:type="string">clearhistory</item>
<item name="label" xsi:type="string">Clear History</item>
<item name="class" xsi:type="string">primary</item>
<item name="url" xsi:type="string">caratlane/netsuite/clearhistory</item>
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Delete Image(s)</item>
<item name="message" xsi:type="string" translate="true">Are you sure you want to delete selected items?</item>
</item>
</item>
</item>
</argument>
<dataSource name="nameOfDataSource">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">Magento\Framework\View\Element\UiComponent\DataProvider\DataProvider</argument>
<argument name="name" xsi:type="string">netsuite_order_log_listing_data_source</argument>
<argument name="primaryFieldName" xsi:type="string">entity_id</argument>
<argument name="requestFieldName" xsi:type="string">id</argument>
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
<item name="update_url" xsi:type="url" path="mui/index/render"/>
<item name="storageConfig" xsi:type="array">
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</item>
</argument>
</argument>
</dataSource>
<container name="listing_top">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="template" xsi:type="string">ui/grid/toolbar</item>
</item>
</argument>
<massaction name="listing_massaction">
<argument name="data" xsi:type="array">
<item name="data" xsi:type="array">
<item name="selectProvider" xsi:type="string">netsuite_order_log_listing.netsuite_order_log_listing.spinner_columns.ids</item>
<item name="displayArea" xsi:type="string">bottom</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/tree-massactions</item>
<item name="indexField" xsi:type="string">entity_id</item>
</item>
</argument>
<action name="delete">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="type" xsi:type="string">delete</item>
<item name="label" xsi:type="string" translate="true">Delete</item>
<item name="url" xsi:type="url" path="*/*/massDelete"/>
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Delete Image(s)</item>
<item name="message" xsi:type="string" translate="true">Are you sure you want to delete selected items?</item>
</item>
</item>
</argument>
</action>
</massaction>
<filters name="listing_filters">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="templates" xsi:type="array">
<item name="filters" xsi:type="array">
<item name="select" xsi:type="array">
<item name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</item>
<item name="template" xsi:type="string">ui/grid/filters/elements/ui-select</item>
</item>
</item>
</item>
</item>
</argument>
</filters>
<bookmark name="bookmarks" />
<component name="columns_controls" />
<exportButton name="export_button" />
<paging name="listing_paging" />
</container>
<columns name="spinner_columns">
<selectionsColumn name="ids" sortOrder="0">
<settings>
<indexField>entity_id</indexField>
</settings>
</selectionsColumn>
<column name="entity_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">textRange</item>
<item name="sorting" xsi:type="string">desc</item>
<item name="label" xsi:type="string" translate="true">ID</item>
</item>
</argument>
</column>
<column name="order_id" class="Caratlane\NetSuite\Ui\Component\Listing\Column\ViewAction">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="sorting" xsi:type="string">desc</item>
<item name="label" xsi:type="string" translate="true">Order Id</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
</item>
</argument>
</column>
<column name="ns_order_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">textRange</item>
<item name="sorting" xsi:type="string">desc</item>
<item name="label" xsi:type="string" translate="true">NS Order Id</item>
</item>
</argument>
</column>
<column name="customer_id" class="Caratlane\NetSuite\Ui\Component\Listing\Column\ViewAction">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">textRange</item>
<item name="sorting" xsi:type="string">desc</item>
<item name="label" xsi:type="string" translate="true">Customer Id</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
</item>
</argument>
</column>
<column name="ns_customer_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">textRange</item>
<item name="sorting" xsi:type="string">desc</item>
<item name="label" xsi:type="string" translate="true">NS Customer Id</item>
</item>
</argument>
</column>
<column name="messages">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="sorting" xsi:type="string">desc</item>
<item name="label" xsi:type="string" translate="true">Messages</item>
</item>
</argument>
</column>
<column name="created_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
<item name="dataType" xsi:type="string">date</item>
<item name="label" xsi:type="string" translate="true">Created</item>
</item>
</argument>
</column>
<column name="status" component="Magento_Ui/js/grid/columns/select" sortOrder="50">
<settings>
<options class="Caratlane\NetSuite\Model\Config\Attribute\Source\Status"/>
<filter>select</filter>
<dataType>select</dataType>
<label translate="true">Status</label>
</settings>
</column>
<column name="request_info" class="Caratlane\NetSuite\Ui\Component\Listing\Column\ViewAction">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">false</item>
<item name="sorting" xsi:type="string">false</item>
<item name="label" xsi:type="string" translate="true">Request Info</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
</item>
</argument>
</column>
<column name="response_info" class="Caratlane\NetSuite\Ui\Component\Listing\Column\ViewAction">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">false</item>
<item name="sorting" xsi:type="string">false</item>
<item name="label" xsi:type="string" translate="true">Response Info</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
</item>
</argument>
</column>
</columns>
</listing>
@@ -0,0 +1,75 @@
<?xml version="1.0"?>
<!--
/**
* @author 18th DigiTech Team
* @copyright Copyright (c) 2020 18th DigiTech (https://www.18thdigitech.com)
* @package Caratlane_NetSuite
*/
-->
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<listingToolbar name="listing_top">
<massaction name="listing_massaction">
<action name="push_to_netsuite">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="type" xsi:type="string">resubmit_to_netsuite</item>
<item name="label" xsi:type="string" translate="true">Resubmit to NetSuite</item>
<item name="url" xsi:type="url" path="caratlane/order/pushnetsuite"/>
<item name="confirm" xsi:type="array">
<item name="title" xsi:type="string" translate="true">Push Order(s) to NetSuite</item>
<item name="message" xsi:type="string" translate="true">Are you sure to reset to NetSuite selected items?</item>
</item>
</item>
</argument>
</action>
</massaction>
</listingToolbar>
<columns name="sales_order_columns">
<column name="netsuite_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">textRange</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
<item name="label" xsi:type="string" translate="true">NetSuiteId</item>
</item>
</argument>
</column>
<column name="netsuite_max_attempt">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
<item name="label" xsi:type="string" translate="true">NetsuiteMaxAttempt</item>
</item>
</argument>
</column>
<column name="push_to_netsuite">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
<item name="label" xsi:type="string" translate="true">PushToNetSuite</item>
</item>
</argument>
</column>
<column name="netsuite_created_at" class="Magento\Ui\Component\Listing\Columns\Date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">dateRange</item>
<item name="component" xsi:type="string">Magento_Ui/js/grid/columns/date</item>
<item name="dataType" xsi:type="string">date</item>
<item name="label" xsi:type="string" translate="true">Netsuite CreatedAt</item>
</item>
</argument>
</column>
<column name="netsuite_order_status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
<item name="label" xsi:type="string" translate="true">NetsuiteOrderStatus</item>
</item>
</argument>
</column>
</columns>
</listing>
@@ -0,0 +1,85 @@
<?xml version="1.0"?>
<!--
/**
* Caratlane
*
* NOTICE OF LICENSE
*
* This source file is subject to the Caratlane.com license that is
* available through the world-wide-web at this URL:
* https://www.Caratlane.com/LICENSE.txt
*
* DISCLAIMER
*
* Do not edit or add to any file if you wish to upgrade this extension
* version in the future.
*
* @category Caratlane
* @package Caratlane_NetSuite
* @copyright Copyright (c) Caratlane (https://www.Caratlane.com/)
* @license https://www.Caratlane.com/LICENSE.txt
*/
-->
<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
<columns name="sales_order_shipment_columns">
<column name="ns_fulfillment_id">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Fulfillment ID</item>
</item>
</argument>
</column>
<column name="ns_fulfillment_number">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Fulfillment Number</item>
</item>
</argument>
</column>
<column name="ns_tracking_number">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Tracking Number</item>
</item>
</argument>
</column>
<column name="ns_shipping_carrier">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Shipping Carrier</item>
</item>
</argument>
</column><column name="ns_shipped_date">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Shipping Date</item>
</item>
</argument>
</column>
<column name="ns_delivery_status">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">text</item>
<item name="label" xsi:type="string" translate="true">Delivery Status</item>
</item>
</argument>
</column>
<column name="ns_invoice_url" class="Caratlane\NetSuite\Ui\Component\Listing\Column\ViewInvoiceUrl">
<argument name="data" xsi:type="array">
<item name="config" xsi:type="array">
<item name="filter" xsi:type="string">false</item>
<item name="sorting" xsi:type="string">false</item>
<item name="label" xsi:type="string" translate="true">Invoice URL</item>
<item name="bodyTmpl" xsi:type="string">ui/grid/cells/html</item>
</item>
</argument>
</column>
</columns>
</listing>