403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/boxberry.delivery/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/boxberry.delivery/profile.php
<?php

namespace Sale\Handlers\Delivery;

use Bitrix\Main\ArgumentException;
use Bitrix\Main\ArgumentNullException;
use Bitrix\Main\Result;
use Bitrix\Main\SystemException;
use Bitrix\Main\Localization\Loc;
use Bitrix\Sale\Delivery\CalculationResult;
use Bitrix\Sale\Delivery\Services\Base;
use Bitrix\Sale\Delivery\Services\EmptyDeliveryService;
use Bitrix\Sale\Delivery\Services\Manager;
use Bitrix\Sale\Shipment;
use Boxberry\Bitrix\Helpers\Delivery;
use Boxberry\Bitrix\Helpers\Extensions;
use Boxberry\Bitrix\Helpers\Options;

Loc::loadMessages(__FILE__);

class BoxberryProfile extends Base
{
    public const CODE = 'boxberry_profile';
    protected static $isProfile = true;
    protected ?BoxberryHandler $parent;

    public function __construct(array $initParams)
    {
        if (empty($initParams['PARENT_ID'])) {
            throw new ArgumentNullException(Loc::getMessage('NO_PARENT_ID_IN_PROFILE_CONSTRUCTOR'));
        }

        parent::__construct($initParams);
        $this->parent = Manager::getObjectById($this->parentId);

        if (!($this->parent instanceof BoxberryHandler)) {
            throw new SystemException(Loc::getMessage('PARENT_IS_NOT_BOXBERRY_HANDLER'));
        }
    }

    public static function getClassTitle(): string
    {
        return Loc::getMessage('CLASS_TITLE');
    }

    /**
     * @return string
     */
    public function getCode(): string
    {
        return self::CODE;
    }

    public function setDescription($description): void
    {
        $this->description .= $description;
    }

    public function setName($name): void
    {
        $this->name .= $name;
    }

    public static function getClassDescription(): string
    {
        return Loc::getMessage('CLASS_DESCRIPTION');
    }

    public function getParentService(): ?BoxberryHandler
    {
        return $this->parent;
    }

    /**
     * @throws ArgumentNullException
     * @throws SystemException
     */
    public function isCalculatePriceImmediately(): bool
    {
        return $this->getParentService()->isCalculatePriceImmediately();
    }

    public static function isProfile(): bool
    {
        return self::$isProfile;
    }

    /**
     * @throws SystemException
     * @throws ArgumentException
     */
    public function isCompatible(Shipment $shipment): bool
    {
        return Delivery::calculate($shipment, true, null, $this->id)->isSuccess();
    }

    public function getConfigStructure(): array
    {
        return Options::getConfigStructureForProfile();
    }

    /**
     * @throws ArgumentException
     * @throws SystemException
     */
    protected function calculateConcrete(Shipment $shipment): CalculationResult
    {
        return Delivery::calculate($shipment);
    }

    public function execAdminAction(): Result
    {
        $result = new Result();
        Extensions::initProfile();
        return $result;
    }

    /**
     * @param array $fields
     * @return Result
     */
    public static function onBeforeAdd(array &$fields = array()): Result
    {
        $fields['LOGOTIP'] = Options::getLogoId();
        self::saveSettings($fields);
        return new Result();
    }

    /**
     * @param int $serviceId
     * @param array $fields
     * @return bool
     */
    public static function onBeforeUpdate($serviceId, array &$fields = array()): bool
    {
        self::saveSettings($fields);
        return true;
    }

    private static function saveSettings(&$fields = []): void
    {
        $fields['CONFIG']['DELIVERY_PERIOD']['ADD_DELIVERY_DAY'] = !empty($fields['CONFIG']['DELIVERY_PERIOD']['ADD_DELIVERY_DAY']) ? $fields['CONFIG']['DELIVERY_PERIOD']['ADD_DELIVERY_DAY'] : 0;
        $fields['CONFIG']['COSTS']['RANGE_FIRST_COST'] = !empty($fields['CONFIG']['COSTS']['RANGE_FIRST_COST']) ? $fields['CONFIG']['COSTS']['RANGE_FIRST_COST'] : 0;
        $fields['CONFIG']['COSTS']['RANGE_FIRST_FIX_COST'] = !empty($fields['CONFIG']['COSTS']['RANGE_FIRST_FIX_COST']) ? $fields['CONFIG']['COSTS']['RANGE_FIRST_FIX_COST'] : 0;
        $fields['CONFIG']['COSTS']['RANGE_SECOND_COST'] = !empty($fields['CONFIG']['COSTS']['RANGE_SECOND_COST']) ? $fields['CONFIG']['COSTS']['RANGE_SECOND_COST'] : 0;
        $fields['CONFIG']['COSTS']['RANGE_SECOND_FIX_COST'] = !empty($fields['CONFIG']['COSTS']['RANGE_SECOND_FIX_COST']) ? $fields['CONFIG']['COSTS']['RANGE_SECOND_FIX_COST'] : 0;
        $fields['CONFIG']['SURCHARGE']['WEIGHT'] = !empty($fields['CONFIG']['SURCHARGE']['WEIGHT']) ? $fields['CONFIG']['SURCHARGE']['WEIGHT'] : 0;
        $fields['CONFIG']['SURCHARGE']['PRICE_BASE_PERCENT'] = !empty($fields['CONFIG']['SURCHARGE']['PRICE_BASE_PERCENT']) ? $fields['CONFIG']['SURCHARGE']['PRICE_BASE_PERCENT'] : 0;
        $fields['CONFIG']['SURCHARGE']['ORDER_SUM_PERCENT'] = !empty($fields['CONFIG']['SURCHARGE']['ORDER_SUM_PERCENT']) ? $fields['CONFIG']['SURCHARGE']['ORDER_SUM_PERCENT'] : 0;
        $fields['CONFIG']['SURCHARGE']['PAY_SUM_PERCENT'] = !empty($fields['CONFIG']['SURCHARGE']['PAY_SUM_PERCENT']) ? $fields['CONFIG']['SURCHARGE']['PAY_SUM_PERCENT'] : 0;
        $fields['CONFIG']['SURCHARGE']['FIX_SUM'] = !empty($fields['CONFIG']['SURCHARGE']['FIX_SUM']) ? $fields['CONFIG']['SURCHARGE']['FIX_SUM'] : 0;
        $fields['CONFIG']['OPTIONS']['MIN_TARIFF'] = !empty($fields['CONFIG']['OPTIONS']['MIN_TARIFF']) ? $fields['CONFIG']['OPTIONS']['MIN_TARIFF'] : 0;
        $fields['CONFIG']['OPTIONS']['MAX_TARIFF'] = !empty($fields['CONFIG']['OPTIONS']['MAX_TARIFF']) ? $fields['CONFIG']['OPTIONS']['MAX_TARIFF'] : 0;

        Delivery::clearCache('calculator');
        Delivery::clearCache('settings');
    }


}

Youez - 2016 - github.com/yon3zu
LinuXploit