<?php
/**
 * Copyright since 2007 PrestaShop SA and Contributors
 * PrestaShop is an International Registered Trademark & Property of PrestaShop SA
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License version 3.0
 * that is bundled with this package in the file LICENSE.md.
 * It is also available through the world-wide-web at this URL:
 * https://opensource.org/licenses/AFL-3.0
 * 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.
 *
 * @author    PrestaShop SA and Contributors <contact@prestashop.com>
 * @copyright Since 2007 PrestaShop SA and Contributors
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0
 */
if (!defined('_PS_VERSION_')) {
    exit;
}

class opartProductsOrder extends Module
{
    public function __construct()
    {
        $this->name = 'opartproductsorder';
        $this->version = '1.0.9';
        $this->author = 'Réussir mon ecommerce';
        $this->need_instance = 1;
        $this->tab = 'administration';
        $this->bootstrap = true;
        $this->module_key = '34703ca24ef8298bd74362243850a28d';

        parent::__construct();
        
        $this->displayName = $this->l('Products order');
        $this->description = $this->l('Quickly reorder products in your backoffice');

        $this->confirmUninstall = $this->l('Are you sure you want to uninstall this module ?');

        $this->ps_versions_compliancy = ['min' => '1.7.5.0', 'max' => _PS_VERSION_];
    }

    public function install()
    {
        $id_lang_fr = Language::getIdByIso('fr');
        if ($id_lang_fr) {
            if (!Db::getInstance()->insert('translation', [
                'id_lang' => (int)$id_lang_fr,
                'key' => 'Reorder',
                'translation' => 'Réordonner',
                'domain' => 'AdminProductActions',
                'theme' => null,
            ]) || !Db::getInstance()->insert('translation', [
                    'id_lang' => (int)$id_lang_fr,
                    'key' => 'Reclassify',
                    'translation' => 'Reclasser',
                    'domain' => 'AdminProductActions',
                    'theme' => null,
                ])) {
                return false;
            }
        }

        return parent::install() && $this->registerHook('actionAdminControllerSetMedia');
    }

    public function hookActionAdminControllerSetMedia()
    {
        $this->context->controller->addCSS(_MODULE_DIR_ . $this->name . '/views/css/opartproductreorder.css');
        $this->context->controller->addJs(_MODULE_DIR_ . $this->name . '/views/js/opartproductreorder.js?v=' . $this->version);
    }
}
