<?php
/**
 * 2007-2021 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@prestashop.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade PrestaShop to newer
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
 * @author    PrestaShop SA <contact@prestashop.com>
 * @copyright 2007-2021 PrestaShop SA
 * @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 *  International Registered Trademark & Property of PrestaShop SA
 */
if (!defined('_PS_VERSION_')) {
    exit;
}

require_once __DIR__ . '/vendor/autoload.php';

use PrestaShop\Module\AgileMultisellerPro\Entity\Sellerinfo;
use PrestaShop\Module\AgileMultisellerPro\Entity\SellerinfoCartCarrier;
use PrestaShop\Module\AgileMultisellerPro\Entity\SellerinfoCategory;
use PrestaShop\Module\AgileMultisellerPro\Entity\SellerinfoLang;
use PrestaShop\Module\AgileMultisellerPro\Entity\SellerinfoLocationCarrier;
use PrestaShop\Module\AgileMultisellerPro\Entity\SellerinfoShipping;
use PrestaShop\Module\AgileMultisellerPro\Form\Configuration\DataConfiguration;
use PrestaShop\Module\AgileMultisellerPro\Form\Configuration\Membership\DataConfiguration as MembershipDataConfiguration;
use PrestaShop\Module\AgileMultisellerPro\Helper\AgileHelper;
use PrestaShop\Module\AgileMultisellerPro\Helper\AgileHelperMembership;
use PrestaShop\Module\AgileMultisellerPro\Helper\AgileHelperSellerInfo;
use PrestaShop\Module\AgileMultisellerPro\Helper\AgileInstall;
use PrestaShop\Module\AgileMultisellerPro\Helper\AgileUninstall;
use PrestaShop\Module\AgileMultisellerPro\Helper\Email\SendEmail;
use PrestaShop\Module\AgileMultisellerPro\Hooks\AgileHooks;
use PrestaShop\PrestaShop\Adapter\SymfonyContainer;
use PrestaShop\PrestaShop\Core\Module\WidgetInterface;
use PrestaShopBundle\Entity\Lang;

class AgileMultiSellerPro extends Module implements WidgetInterface
{
    public function __construct()
    {
        $this->name = 'agilemultisellerpro';
        $this->author = 'SoftSprint';
        $this->version = '0.2.1';
        $this->ps_versions_compliancy = ['min' => '8.0.0', 'max' => _PS_VERSION_];
        $this->tab = 'front_office_features';

        $this->bootstrap = true;

        parent::__construct();

        $this->displayName = $this->trans('Agile Multi-Vendor Marketplace', [], 'Modules.Agilemultisellerpro.Module');
        $this->description = $this->trans('Transforms your store into “Amazon” - a marketplace with multiple sellers and their shops. Vendors can sell products and manage orders. Admin controls vendors and charges them fees. Powerful options for carriers, subscriptions, product import etc', [], 'Modules.Agilemultisellerpro.Module');
    }

    public function install()
    {
        $sqlInstaller = new PrestaShop\Module\AgileMultisellerPro\Sql\SqlInstaller();
        $result = parent::install()
            && $sqlInstaller->install()
            && (new AgileInstall($this))->processInstall();

        return $result;
    }

    public function uninstall()
    {
        return parent::uninstall()
            && (new AgileUninstall($this))->processUninstall();
    }

    public function enable($force_all = false)
    {
        return parent::enable($force_all);
    }

    public function hookActionFrontControllerSetMedia()
    {
        $this->context->controller->registerJavascript(
            'tools-js',
            '/js/tools.js',
            ['position' => 'bottom', 'priority' => 100]
        );

        $this->context->controller->registerJavascript(
            'ams-agile-global-js',
            '/modules/agilemultisellerpro/views/js/agile_global.js',
            ['position' => 'bottom', 'priority' => 100]
        );

        $this->context->controller->registerJavascript(
            'agile-common-js',
            '/modules/agilemultisellerpro/views/js/front/common.js',
            ['position' => 'bottom', 'priority' => 100]
        );

        Media::addJsDef([
            'base_dir_ssl' => $this->context->shop->getBaseURL(true, true),

            'AGILE_MS_CUSTOMER_SELLER' => (int) Configuration::get('AGILE_MS_CUSTOMER_SELLER'),
            'sellwithus_link' => ' | <a href="' .
                $this->context->link->getModuleLink('agilemultisellerpro', 'sellersignup', [], true) .
                '">' . $this->l('Seller Signup') . '</a>',
        ]);

        $php_self = $this->context->controller->php_self;

        if ('index' != $php_self) {
            $this->context->controller->registerStylesheet(
                'ams-agile-global-css',
                '/modules/agilemultisellerpro/views/css/agileglobal.css'
            );
            $this->context->controller->registerStylesheet(
                'ams-agile-full-css',
                '/modules/agilemultisellerpro/views/css/agilemultiseller.css'
            );
        }

        if ('product' == $php_self) {
            $this->context->controller->registerJavascript(
                'agile-makeoffer',
                '/modules/agilemultisellerpro/views/js/front/prodcut.makeoffer.js',
                ['position' => 'bottom', 'priority' => 100]
            );
        }

        if ($php_self == 'order') {
            $defaultIdCarrierReference = Configuration::get('AGILE_DEFAULT_CARRIER_REFERENCE_ID');

            $sellerDefaultCarrier = null;

            if ($defaultIdCarrierReference) {
                $sellerDefaultCarrier = new Carrier($defaultIdCarrierReference);
            }

            if (!$defaultIdCarrierReference || !Validate::isLoadedObject($sellerDefaultCarrier)) {
                $sellerDefaultCarrier = new Carrier(null, Configuration::get('PS_LANG_DEFAULT'));
                $sellerDefaultCarrier->name = 'DefaultSellerCarier';
                $sellerDefaultCarrier->delay = 'Set by seller';
                $sellerDefaultCarrier->is_free = true;
                $sellerDefaultCarrier->active = true;
                $sellerDefaultCarrier->deleted = true;

                $sellerDefaultCarrier->add();

                $sellerDefaultCarrier = new Carrier($sellerDefaultCarrier->id);

                $defaultIdCarrierReference = $sellerDefaultCarrier->id_reference;
                Configuration::updateValue('AGILE_DEFAULT_CARRIER_REFERENCE_ID', $defaultIdCarrierReference);
            }

            if (!$sellerDefaultCarrier->is_free || !$sellerDefaultCarrier->active) {
                $sellerDefaultCarrier->is_free = true;
                $sellerDefaultCarrier->active = true;

                $sellerDefaultCarrier->save();
            }

            $groups = Group::getGroups($this->context->language->id);

            $groupsIds = array_column($groups, 'id_group');

            $carrierGroups = $sellerDefaultCarrier->getGroups();

            $carrierGroupsIds = array_column($carrierGroups, 'id_group');

            foreach ($groupsIds as $groupId) {
                if (!in_array($groupId, $carrierGroupsIds)) {
                    $sellerDefaultCarrier->setGroups($groupsIds);

                    break;
                }
            }

            $zones = Zone::getZones();

            $zonesIds = array_column($zones, 'id_zone');

            $carrierZones = $sellerDefaultCarrier->getZones();

            $carrierZonesIds = array_column($carrierZones, 'id_zone');

            foreach ($zonesIds as $zoneId) {
                if (!in_array($zoneId, $carrierZonesIds)) {
                    $sellerDefaultCarrier->addZone($zoneId);
                }
            }

            $cariers = Carrier::getCarriers($this->context->language->id);

            foreach ($cariers as $carier) {
                $carriersIdsByIdReference[$carier['id_reference']] = $carier['id_carrier'];
            }

            if (
                Configuration::get(DataConfiguration::AGILE_MS_GMAP)
                && Configuration::get(DataConfiguration::AGILE_MS_GMAP_KEY)
            ) {
                $this->context->controller->registerJavascript(
                    'agile_gmap_class',
                    '/modules/agilemultisellerpro/views/js/agile.gmap.class.js',
                    ['position' => 'bottom', 'priority' => 100]
                );

                Media::addJsDef([
                    'agileGmapKey' => Configuration::get(DataConfiguration::AGILE_MS_GMAP_KEY),
                ]);
            }

            $entityManager = $this->get('doctrine.orm.entity_manager');
            $sellerinfoShippingRepository = $entityManager->getRepository(SellerinfoShipping::class);

            $cartproducts = $this->context->cart->getProducts(false);

            if (!empty($cartproducts)) {
                $id_zone = AgileHelper::getZoneID(
                    $this->context->cart->id_address_delivery,
                    $this->context->cart->id_customer
                );

                $shippingData = $sellerinfoShippingRepository->groupProductsBySellerAndCalculateShipping(
                    $cartproducts,
                    $id_zone,
                    $this->context->cart->id
                );

                $agileSellersLocation = [];
                $sellerinfoLocationCarrierRepository = $entityManager->getRepository(SellerinfoLocationCarrier::class);

                foreach ($shippingData as $idSellerinfo => $shipping) {
                    foreach ($shipping['carriers'] as $carrier) {
                        if (isset($carrier['available']) && $carrier['available'] == true) {
                            // Location
                            $id_reference = (int) $carrier['adminCarrier']->id_reference;
                            $agileSellersLocation[$idSellerinfo][$id_reference] =
                                $sellerinfoLocationCarrierRepository->getArray(
                                    $idSellerinfo,
                                    $id_reference,
                                    true,
                                    false
                                )
                            ;
                        }
                    }
                }

                Media::addJsDef([
                    'agileSellersLocation' => $agileSellersLocation,
                    'selectLocationText' => $this->trans('Please select shipping location:', [], 'Modules.Agilemultisellerpro.Shipping'),
                ]);
            }

            $this->context->controller->registerStylesheet(
                'ams-agile-shipping-order',
                '/modules/agilemultisellerpro/views/css/front/shipping.order.css'
            );

            $this->context->controller->registerJavascript(
                'agile_sellershippingcheckout',
                '/modules/agilemultisellerpro/views/js/sellershippingcheckout.js',
                ['position' => 'bottom', 'priority' => 100]
            );

            Media::addJsDef([
                'ajaxShippingUrl' => $this->context->link->getModuleLink(
                    'agilemultisellerpro',
                    'ajaxshipping',
                    ['ajax' => true]
                ),
                'defaultIdCarrierReference' => $defaultIdCarrierReference,
                'carriersIdsByIdReference' => $carriersIdsByIdReference,
            ]);
        }
    }

    public function hookDisplayHeader()
    {
        return $this->getHookByName('displayHeader');
    }

    public function getContent()
    {
        Tools::redirectAdmin(SymfonyContainer::getInstance()->get('router')->generate('admin_agile_configuration'));
        exit;
    }

    public static function ensureDateCustomField()
    {
        $conf = Configuration::getMultiple([
            'AGILE_MS_SELLER_DATE1',
            'AGILE_MS_SELLER_DATE2',
            'AGILE_MS_SELLER_DATE3',
            'AGILE_MS_SELLER_DATE4',
            'AGILE_MS_SELLER_DATE5',
        ]);

        for ($idx = 1; $idx <= 5; ++$idx) {
            if (
                !$conf['AGILE_MS_SELLER_DATE' . $idx]
                || !Tools::getIsset('ams_custom_date' . $idx)
                || !Validate::isDate(Tools::getValue('ams_custom_date' . $idx))
            ) {
                $_POST['ams_custom_date' . $idx] = null;
            }
        }
    }

    public function createSellerAccount($customer, Sellerinfo $seller)
    {
        if (!Validate::isLoadedObject($customer)) {
            return;
        }

        $em = $this->get('doctrine.orm.entity_manager');
        /** @var EntityRepository $sellerInfoRepository */
        $sellerInfoRepository = $em->getRepository(Sellerinfo::class);

        $sid = $sellerInfoRepository->getLinkedSellerID($customer->id);
        if (!is_null($sid)) {
            return;
        }

        $aid = Address::getFirstCustomerAddressId($customer->id, true);

        $address = new Address((int) $aid);
        if (!Validate::isLoadedObject($address)) {
            $address->id_country = Configuration::get('PS_COUNTRY_DEFAULT');
        }
        $sellerinfo = self::createSellerInfo($customer, $address, $seller);

        if ($sellerinfo) {
            $this->setSellerDefaultCategories($sellerinfo);

            if (
                (int) Configuration::get(MembershipDataConfiguration::AGILE_MEMBERSHIP_FREE_TRIAL_TIMING)
                    == MembershipDataConfiguration::TIMING_NEW_SELLER
            ) {
                AgileHelperMembership::createFreeMembership($customer);
            }
        }

        (new SendEmail($sellerinfo))->sendEmailByType('newSellerAccount');
    }

    public function createSellerInfo($customer, $address, Sellerinfo $sellerinfo)
    {
        $context = Context::getContext();
        $em = $this->get('doctrine.orm.entity_manager');

        $langRepository = $em->getRepository(Lang::class);
        new PrestaShopBundle\Translation\Constraints\PassVsprintf();

        $sellerinfo->setIdCustomer($customer->id);

        $sellerinfo->setActive((int) Configuration::get('AGILE_MS_SELLER_APPROVAL') == 1 ? false : true);

        if (Tools::getValue('signin')) {
            $sellerinfo->setIdCountry((int) Tools::getValue('id_country'));

            if (Country::containsStates($sellerinfo->getIdCountry())) {
                $sellerinfo->setIdState((int) Tools::getValue('id_state'));
            }

            $sellerinfo->setPostcode(Tools::getValue('postcode'));
            $sellerinfo->setPhone(Tools::getValue('phone'));
            $languages = Language::getLanguages(false);

            $sellerinfo->getLangs()->clear();
            foreach ($languages as $lang) {
                $id_lang = $lang['id_lang'];
                $sil = new SellerinfoLang();
                $sil->setIdLang($langRepository->find((int) $id_lang));
                $sil->setCompany(Tools::getValue('company', ''));
                $sil->setCity(Tools::getValue('city', ''));
                $sil->setAddress1(Tools::getValue('address1', ''));
                $sil->setAddress2(Tools::getValue('address2', ''));
                $sil->setDescription(Tools::getValue('description', ''));
                $sellerinfo->addSellerLang($sil);
            }
        } else {
            $sellerinfo->setIdCountry($address->id_country);
            $sellerinfo->setIdState($address->id_state);
            $sellerinfo->setPostcode($address->postcode);
            $sellerinfo->setPhone($address->phone);
            $company = (empty($address->company) ? ($customer->firstname . ' ' .
                $customer->lastname) : $address->company);
            $sellerinfo->getLangs()->clear();
            $languages = Language::getLanguages(false);

            foreach ($languages as $lang) {
                $id_lang = $lang['id_lang'];
                $sil = new SellerinfoLang();

                $sil->setIdLang($langRepository->find((int) $id_lang));
                $sil->setCompany($company);
                $sil->setCity($address->city);
                $sil->setAddress1($address->address1);
                $sil->setAddress2($address->address2);
                $sellerinfo->addSellerLang($sil);
            }
        }

        $sellerinfo->setLongitude(0);
        $sellerinfo->setLatitude(0);
        $sellerinfo->setAmsCustomDate1(null);
        $sellerinfo->setAmsCustomDate2(null);
        $sellerinfo->setAmsCustomDate3(null);
        $sellerinfo->setAmsCustomDate4(null);
        $sellerinfo->setAmsCustomDate5(null);

        AgileHelperSellerInfo::syncSellerManufacturerSupplier($sellerinfo);

        $em->persist($sellerinfo);
        $em->flush();

        if ($sellerinfo->getIdShop() <= 0) {
            $shop_name = $sellerinfo->getCompany();

            if (empty($shop_name)) {
                $shop_name = $customer->firstname . '-' . $customer->lastname;
            }

            $vshop = AgileHelper::createNewShop(
                $sellerinfo->getIdSellerinfo(),
                $shop_name
            );

            $sellerinfo->setIdShop($vshop->id);
            $sellerinfo->setThemeName($vshop->theme_name);

            $em->persist($sellerinfo);
            $em->flush();
        }

        return $sellerinfo;
    }

    public function setSellerDefaultCategories(Sellerinfo $sellerinfo)
    {
        $root = Category::getRootCategory();

        $categories = $root->getSubCategories($this->context->language->id);

        $categories[] = ['id_category' => $root->id_category];

        $entityManager = $this->get('doctrine.orm.entity_manager');

        foreach ($categories as $category) {
            $sellerCategory = new SellerinfoCategory();

            $sellerCategory
                ->setSellerinfo($sellerinfo)
                ->setIdCategory((int) $category['id_category']);

            $entityManager->persist($sellerCategory);
            $entityManager->flush();
        }
    }

    public function renderWidget($hookName = null, array $configuration = [])
    {
        return $this->getHookByName($hookName);
    }

    public function getWidgetVariables($hookName = null, array $configuration = [])
    {
        return [];
    }

    public function hookModuleRoutes($params)
    {
        $my_link = [
            'module-agilemultisellerpro-seller' => [
                'controller' => 'seller',
                'rule' => 'shop/{shop_virtual_url}',
                'keywords' => [
                    'shop_virtual_url' => ['regexp' => '[_a-zA-Z0-9/-]*', 'param' => 'shop_virtual_url'],
                ],
                'params' => [
                    'fc' => 'module',
                    'module' => 'agilemultisellerpro',
                    'controller' => 'seller',
                ],
            ],
        ];

        return $my_link;
    }

    public function hookActionOrderStatusUpdate($params)
    {
        $this->getHookByName('actionOrderStatusUpdate', $params);
    }

    public function hookActionValidateOrder($params)
    {
        $this->getHookByName('actionValidateOrder', $params);
    }

    protected function getHookByName($hookName, $params = [])
    {
        $agileHooks = AgileHooks::getInstance();

        return $agileHooks->displayHookByName($hookName, $params);
    }

    public function hookDisplayOrderCarriersList($params)
    {
        $isAdmin = false;
        if (isset($params['isAdmin']) && $params['isAdmin'] == true) {
            $isAdmin = true;
        }

        $idOrder = $params['idOrder'];

        if (!$idOrder || $idOrder <= 0) {
            return false;
        }

        $order = new Order($idOrder);

        $idCurrency = $order->id_currency;

        $idCart = $order->id_cart;

        $entityManager = $this->get('doctrine.orm.entity_manager');
        $sellerInfoCartCarrierRepository = $entityManager->getRepository(SellerinfoCartCarrier::class);

        $sellerCartCarriers = $sellerInfoCartCarrierRepository->findBy([
            'idCart' => $idCart,
        ]);

        $idOrderCarrier = $order->getIdOrderCarrier();
        $orderCarrier = new OrderCarrier($idOrderCarrier);

        $sellerinfoLangRepository = $entityManager->getRepository(SellerinfoLang::class);
        $sellerinfoRepository = $entityManager->getRepository(Sellerinfo::class);
        $sellerinfoLocationCarrierRepository = $entityManager->getRepository(SellerinfoLocationCarrier::class);

        $carriers = [];
        foreach ($sellerCartCarriers as $key => $cartCarrier) {
            $carrier['date_add'] = $orderCarrier->date_add;
            $carrier['idOrderCarrier'] = $idOrderCarrier;

            $carrier['sellerinfoLang'] = $sellerinfoLangRepository->findOneBy([
                'sellerInfo' => $cartCarrier->getIdSellerInfo(),
                'lang' => $this->context->language->id,
            ]);

            $carrier['sellerinfo'] = $sellerinfoRepository->findOneBy([
                'idSellerinfo' => $cartCarrier->getIdSellerInfo(),
            ]);

            $carrier['trackingNumber'] = $cartCarrier->getTrackingNumber();

            $carrier['canEdit'] = false;
            if ($carrier['sellerinfo']) {
                $carrier['shop'] = new Shop($carrier['sellerinfo']->getIdShop());
                $carrier['shopName'] = $carrier['shop']->name;
            } elseif ($cartCarrier->getIdSellerInfo() == 0) {
                $carrier['shopName'] = Configuration::get('PS_SHOP_NAME', null, null, (int) $this->context->shop->id);
                $carrier['canEdit'] = true;
                $carrier['trackingNumber'] = $orderCarrier->tracking_number;
            } else {
                $carrier['shopName'] = 'no_name';
            }

            $carrier['carrier'] = Carrier::getCarrierByReference(
                $cartCarrier->getIdCarrierReference(),
                $this->context->language->id
            );

            $carrier['trackingUrl'] = str_replace('@', $carrier['trackingNumber'], $carrier['carrier']->url);

            $carrier['carrierName'] = $carrier['carrier']->name;

            $carrier['weight'] = $cartCarrier->getWeight();
            $carrier['weightUnit'] = Configuration::get('PS_WEIGHT_UNIT');

            $carrier['shippingCostDefaultCurrency'] = $cartCarrier->getShippingCost();

            $defaultCurrency = Currency::getDefaultCurrency();
            $orderCurrency = new Currency($idCurrency);

            $carrier['shippingCost'] = Tools::convertPriceFull(
                $carrier['shippingCostDefaultCurrency'],
                $defaultCurrency,
                $orderCurrency
            );

            $carrier['shippingCostFormated'] = $this->context->currentLocale->formatPrice(
                $carrier['shippingCost'],
                $orderCurrency->iso_code
            );

            $carrier['orderCarrierId'] = $order->id_carrier;
            $carrier['location'] = '';

            if ($cartCarrier->getIdLocationCarrier()) {
                $sellerinfoLocationCarrier = $sellerinfoLocationCarrierRepository->find($cartCarrier->getIdLocationCarrier());

                if ($sellerinfoLocationCarrier) {
                    $carrier['location'] = $sellerinfoLocationCarrier->getLocation();
                }
            }

            $carriers[] = $carrier;
        }

        $this->context->smarty->assign('carriers', $carriers);
        $this->context->smarty->assign('isAdmin', $isAdmin);

        return $this->context->smarty->fetch('module:agilemultisellerpro/views/templates/hook/ordercarrierslist.tpl');
    }

    public function hookDisplayOverrideTemplate($params)
    {
        if ($params['template_file'] == 'customer/order-detail'
            && $params['controller']->php_self == 'order-detail'
        ) {
            return 'module:agilemultisellerpro/views/templates/front/shipping/order-detail.tpl';
        }

        return null;
    }

    public function hookActionEmailSendBefore($params)
    {
        return $this->getHookByName('actionEmailSendBefore', $params);
    }

    public function hookActionCustomerAccountAdd($params)
    {
        $this->getHookByName('actionCustomerAccountAdd', $params);
    }

    public function hookActionProductSearchProviderRunQueryBefore($params)
    {
        $this->getHookByName('actionProductSearchProviderRunQueryBefore', $params);
    }

    public function hookActionProductSearchProviderRunQueryAfter($params)
    {
        $this->getHookByName('actionProductSearchProviderRunQueryAfter', $params);
    }

    public function hookActionCartSave($params)
    {
        $this->getHookByName('actionCartSave', $params);
    }

    public function hookActionProductGridDefinitionModifier($params)
    {
        return $this->getHookByName('actionProductGridDefinitionModifier', $params);
    }

    public function hookActionProductGridQueryBuilderModifier($params)
    {
        return $this->getHookByName('actionProductGridQueryBuilderModifier', $params);
    }

    public function hookActionAdminProductsListingFieldsModifier($params)
    {
        return $this->getHookByName('actionAdminProductsListingFieldsModifier', $params);
    }

    public function hookAdminCatalogSellersList($params)
    {
        $selelrRepository = $this->get('prestashop.module.agilemultisellerpro.repository.sellerinfo_repository');
        if (!$selelrRepository) {
            return '';
        }
        $sellers = $selelrRepository->getSellerInfos($this->context->language->id);

        $this->context->smarty->assign('sellers', $sellers);
        $this->context->smarty->assign('selected_seller_id', $this->context->cookie->__get('filter_column_product_id_seller'));

        return $this->context->smarty->fetch('module:agilemultisellerpro/views/templates/hook/adminCatalogSellersList.tpl');
    }

    public function getI18nText()
    {
        return [
            'renewOrderTitle' => $this->trans(
                'Renew or Order the subscription plan',
                [],
                'Modules.Agilemultisellerpro.Admin'
            ),
            'subscriptionLimitЕxceeded' => $this->trans(
                'The subscription plan limit has been reached! Please order the new plan or renew the current one!',
                [],
                'Modules.Agilemultisellerpro.Admin'
            ),
            'subscriptionNotAvaialable' => $this->trans(
                'You need to order the subscription plan to use this feature.',
                [],
                'Modules.Agilemultisellerpro.Admin'
            ),
            'buttonSend' => $this->trans('Send', [], 'Modules.Agilemultisellerpro.Admin'),
            'buttonCancel' => $this->trans('Cancel', [], 'Modules.Agilemultisellerpro.Admin'),
            'buttonClose' => $this->trans('Close', [], 'Modules.Agilemultisellerpro.Admin'),
            'renewOrOrderBtn' => $this->trans('Renew / Order', [], 'Modules.Agilemultisellerpro.Admin'),
            'noRecordsText' => $this->trans('No records found', [], 'Modules.Agilemultisellerpro.Admin'),
            'expired' => $this->trans('Expired!', [], 'Modules.Agilemultisellerpro.Admin'),
        ];
    }

    public function hookActionObjectProductAddAfter($params)
    {
        $this->getHookByName('actionObjectProductUpdateAfter', $params);
    }

    public function hookActionObjectProductUpdateAfter($params)
    {
        $this->getHookByName('actionObjectProductUpdateAfter', $params);
    }

    public function hookActionObjectProductDeleteAfter($params)
    {
        $this->getHookByName('actionObjectProductDeleteAfter', $params);
    }

    public function hookActionObjectOrderDetailDeleteAfter($params)
    {
        $this->getHookByName('actionObjectOrderDetailDeleteAfter', $params);
    }
}
