Skip to content
Code-Schnipsel Gruppen Projekte
AbstractShippingEntry.php 3,24 KiB
Newer Older
  • Learn to ignore specific revisions
  • Henning Leutz's avatar
    Henning Leutz committed
    <?php
    
    /**
     * This file contains \QUI\ERP\Shipping\Api\AbstractShippingEntry
     */
    
    namespace QUI\ERP\Shipping\Api;
    
    use QUI;
    
    
    use function get_class;
    use function md5;
    
    
    Henning Leutz's avatar
    Henning Leutz committed
    /**
     * Shipping abstract class
     * This is the parent shipping class for all shipping methods
     *
     * @author www.pcsg.de (Henning Leutz)
     */
    
    Henning Leutz's avatar
    Henning Leutz committed
    abstract class AbstractShippingEntry extends QUI\CRUD\Child implements ShippingInterface
    
    Henning Leutz's avatar
    Henning Leutz committed
    {
        /**
         * shipping fields - extra fields for the shipping / accounting
         *
         * @var array
         */
    
        protected array $shippingFields = [];
    
    Henning Leutz's avatar
    Henning Leutz committed
    
        /**
         * default settings
         *
         * @var array
         */
    
        protected array $defaults = [];
    
    Henning Leutz's avatar
    Henning Leutz committed
    
        /**
         * Locale object for the shipping
         *
    
        protected ?QUI\Locale $Locale = null;
    
    Henning Leutz's avatar
    Henning Leutz committed
    
        /**
         * Set the locale object to the shipping
         *
         * @param QUI\Locale $Locale
         */
    
        public function setLocale(QUI\Locale $Locale): void
    
    Henning Leutz's avatar
    Henning Leutz committed
        {
            $this->Locale = $Locale;
        }
    
        /**
         * Return the Locale of the shipping
         *
         * @return QUI\Locale
         */
    
        public function getLocale(): QUI\Locale
    
    Henning Leutz's avatar
    Henning Leutz committed
        {
            if ($this->Locale === null) {
                $this->Locale = QUI::getLocale();
            }
    
            return $this->Locale;
        }
    
        /**
         * @return string
         */
    
        public function getName(): string
    
            return md5(get_class($this));
    
    Henning Leutz's avatar
    Henning Leutz committed
        }
    
        /**
         * Return the class of the instance
         *
         * @return string
         */
    
        public function getClass(): string
    
            return get_class($this);
    
         * @param null $Locale
    
    Henning Leutz's avatar
    Henning Leutz committed
         * @return string
         */
    
        abstract public function getTitle($Locale = null): string;
    
         * @param null|QUI\Locale $Locale
    
    Henning Leutz's avatar
    Henning Leutz committed
         * @return string
         */
    
        abstract public function getDescription(null | QUI\Locale $Locale = null): string;
    
    Henning Leutz's avatar
    Henning Leutz committed
        /**
         * @return string
         */
    
        abstract public function getWorkingTitle(): string;
    
    Henning Leutz's avatar
    Henning Leutz committed
        /**
         * Return the shipping icon (the URL path)
         * Can be overwritten
         *
         * @return string
         */
    
        public function getIcon(): string
    
    Henning Leutz's avatar
    Henning Leutz committed
            return QUI\ERP\Shipping\Shipping::getInstance()->getHost() .
                URL_OPT_DIR
                . 'quiqqer/shipping/bin/images/shipping/default.png';
    
    Henning Leutz's avatar
    Henning Leutz committed
        }
    
        /**
         * Return the shipping as an array
         *
         * @return array
         */
    
        public function toArray(): array
    
    Henning Leutz's avatar
    Henning Leutz committed
        {
            return [
    
    Henning Leutz's avatar
    Henning Leutz committed
                'name' => $this->getName(),
                'title' => $this->getTitle(),
    
    Henning Leutz's avatar
    Henning Leutz committed
                'description' => $this->getDescription()
            ];
        }
    
        /**
         * Is the shipping be visible in the frontend?
         * Every shipping method can determine this by itself (API for developers)
         *
         * @return bool
         */
    
        public function isVisible(): bool
    
    Henning Leutz's avatar
    Henning Leutz committed
        {
            return true;
        }
    
        //region text messages
    
        /**
         * Return the extra text for the invoice
         *
         * @param QUI\ERP\Accounting\Invoice\Invoice|QUI\ERP\Accounting\Invoice\InvoiceTemporary|QUI\ERP\Accounting\Invoice\InvoiceView $Invoice
    
        public function getInvoiceInformationText(
    
            QUI\ERP\Accounting\Invoice\Invoice | QUI\ERP\Accounting\Invoice\InvoiceTemporary | QUI\ERP\Accounting\Invoice\InvoiceView $Invoice
    
    Henning Leutz's avatar
    Henning Leutz committed
            return '';
        }
    
        //endregion
    }