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/lpost.delivery/lib/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/lpost.delivery/lib/handler.php
<?

namespace Sale\Handlers\Delivery;

use Bitrix\Crm\Controller\Type;
use Bitrix\Sale\Delivery\CalculationResult;
use Bitrix\Sale\Delivery\Services\Base;
use Bitrix\Main\Localization\Loc;
use Lpost\Delivery\Repository\RepositoryAddressPoints;

Loc::loadMessages(__FILE__);

\Bitrix\Main\UI\Extension::load("ui.hint");

\Bitrix\Main\Loader::includeModule('lpost.delivery');

class  lpost_deliveryHandler extends Base
{
    public static function getProfiles()
    {
        return [
            'pvz' => '\Lpost\Delivery\Handlers\Pvz',
            'zone' => '\Lpost\Delivery\Handlers\Zone'
        ];
    }

    public static function getClassTitle()
    {
        return Loc::getMessage("lpost.handler_delivery_name");
    }

    public static function getClassDescription()
    {
        return Loc::getMessage("lpost.handler_delivery_desc");
    }

    protected function calculateConcrete(\Bitrix\Sale\Shipment $shipment)
    {
        $result = new CalculationResult();
        $overPrice = floatval($this->config["MAIN"]["PRICE"]);
        $tmpPrice = $overPrice;

        if (!empty($_REQUEST['order']['price'])) {
            $tmpPrice += $_REQUEST['order']['price'];
        }
        elseif (!empty($_REQUEST['price'])) {
            $tmpPrice += $_REQUEST['price'];
        }
        else {
            $result->addError(new \Bitrix\Main\Error("ERRORR!!!"));
        }

        $result->setDeliveryPrice(roundEx($tmpPrice, 2));

        return $result;
    }

    public function getConfigStructure()
    {
        \Lpost\Delivery\Admin\Input\Manager::register();
        
        $configList['MAIN'] = [
            "TITLE" => Loc::getMessage("lpost.handler_setting_delivery"),
            "DESCRIPTION" => Loc::getMessage("lpost.handler_setting_delivery_desc"),
            "ITEMS" =>  self::getConfigItemList()
        ];

        return $configList;
    }

    private static function getConfigItemList(): array
    {

        if(self::isExistPartnerWarehouseAddressPointList()) {
            $configList['PARTNER_WAREHOUSE_ID'] = [
                "TYPE" => "ENUM",
                "DEFAULT" => 0,
                'OPTIONS' => self::getPartnerWarehouseAddressPointList(),
                "NAME" => Loc::getMessage("lpost.handler_setting_partner_warehouse_address_point_list")
            ];
        } else {
            $configList["ID_SKLAD"] = [
                "TYPE" => "ENUM",
                "DEFAULT" => 3,
                'OPTIONS' => self::getRpList(),
                "NAME" => Loc::getMessage("lpost.handler_setting_rplist")
            ];
        }

        $configList['ISSUE_TYPE'] = [
            "TYPE" => "ENUM",
            "DEFAULT" => 0,
            'OPTIONS' => [
                0 => Loc::getMessage("lpost.handler_setting_issue_type0"),
                1 => Loc::getMessage("lpost.handler_setting_issue_type1"),
                2 => Loc::getMessage("lpost.handler_setting_issue_type2")
            ],
            "NAME" => Loc::getMessage("lpost.handler_setting_issue_type")
        ];
        $configList['TYPE_OVERPRICE'] = [
            "TYPE" => "ENUM",
            'DEFAULT' => 'percent',
            'OPTIONS' => [
                'percent' => Loc::getMessage("lpost.handler_setting_typeoverprice_percent"),
                'fixed' => Loc::getMessage("lpost.handler_setting_typeoverprice_fixed"),
            ],
            "NAME" => Loc::getMessage("lpost.handler_setting_typeoverprice")
        ];
        $configList['IS_COMMISSION'] = [
            "TYPE" => "Y/N",
            "DEFAULT" => "N",
            "NAME" => Loc::getMessage("lpost.handler_setting_is_commission")
        ];
        $configList['OVERPRICE'] = [
            "TYPE" => "NUMBER",
            'DEFAULT' => '0',
            "MIN" => 0,
            "NAME" => Loc::getMessage("lpost.handler_setting_overprice"),
            "REQUIRED" => true,
        ];
        $configList['INSURANCE'] = [
            "TYPE" => "ENUM",
            'DEFAULT' => 100,
            'OPTIONS' => [
                0 => "0%",
                25 => "25%",
                50 => "50%",
                75 => "75%",
                100 => "100%",
            ],
            "NAME" => Loc::getMessage("lpost.handler_setting_insurance_name")
        ];
        $configList['DAYS_FOR_COMPLETE'] = [
            "TYPE" => "ENUM",
            'DEFAULT' => '0',
            'OPTIONS' => [
                0 => "0",
                1 => "1",
                2 => "2",
            ],
            "NAME" => Loc::getMessage("lpost.handler_setting_complete_days")
        ];
        $configList['USE_MIN_DELIVERY_TIME'] = [
            "TYPE" => "LPOST_EITHERYN",
            "DEFAULT" => "N",
            "NAME" => Loc::getMessage("lpost.handler_setting_use_minimum_delivery_time"),
            "HINT" => Loc::getMessage("lpost.handler_setting_use_minimum_delivery_time_hint"). "<script>BX.ready(function () {BX.UI.Hint.init(BX(\"edit_MAIN\"));})</script>",
        ];
        $configList['GOODS_DIMENSIONS_FROM'] = [
            "TYPE" => "ENUM",
            'DEFAULT' => 'default',
            'OPTIONS' => [
                'product' => Loc::getMessage("lpost.handler_setting_goods_dimensions_from_product"),
                'default' => Loc::getMessage("lpost.handler_setting_goods_dimensions_from_default"),
            ],
            "NAME" => Loc::getMessage("lpost.handler_setting_goods_dimensions_from")
        ];
        $configList['DEFAULT_LENGTH'] = [
            "TYPE" => "NUMBER",
            'DEFAULT' => 380,
            "MIN" => 90,
            "MAX" => 1200,
            "NAME" => Loc::getMessage("lpost.handler_setting_default_length"),
            "REQUIRED" => true,
        ];
        $configList['DEFAULT_WIDTH'] = [
            "TYPE" => "NUMBER",
            'DEFAULT' => 310,
            "MIN" => 90,
            "MAX" => 800,
            "NAME" => Loc::getMessage("lpost.handler_setting_default_width"),
            "REQUIRED" => true,
        ];
        $configList['DEFAULT_HEIGHT'] = [
            "TYPE" => "NUMBER",
            'DEFAULT' => 290,
            "MIN" => 90,
            "MAX" => 500,
            "NAME" => Loc::getMessage("lpost.handler_setting_default_height"),
            "REQUIRED" => true,
        ];
        $configList['DEFAULT_WEIGHT'] = [
            "TYPE" => "NUMBER",
            'DEFAULT' => 100,
            "MIN" => 90,
            "MAX" => 20000,
            "NAME" => Loc::getMessage("lpost.handler_setting_default_weight"),
            "REQUIRED" => true,
        ];
        $configList['CALC_DIMENSIONS_DEFAULT'] = [
            "TYPE" => "ENUM",
            'DEFAULT' => 'order',
            'OPTIONS' => [
                'order' => Loc::getMessage("lpost.handler_setting_calc_dimensions_order"),
                'product' => Loc::getMessage("lpost.handler_setting_calc_dimensions_product"),
            ],
            "NAME" => Loc::getMessage("lpost.handler_setting_calc_dimensions")
        ];

        return $configList;
    }

    private static function isExistPartnerWarehouseAddressPointList(): bool
    {
        return (new RepositoryAddressPoints())->isExistItems();
    }

    private static function getPartnerWarehouseAddressPointList(): array
    {
        return (new RepositoryAddressPoints())->getAllActiveAddressKeyWarehouseId();
    }

    public function isCalculatePriceImmediately()
    {
        return true;
    }

    public static function whetherAdminExtraServicesShow()
    {
        return false;
    }

    public static function whetherAdminRestrictionsShow()
    {
        return false;
    }


    //profiles
    protected static $canHasProfiles = true;

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

    public static function getChildrenClassNames()
    {
        $classes = self::getProfiles();
        if (!empty($_REQUEST['PROFILE_ID']) && !empty($classes[$_REQUEST['PROFILE_ID']])) {
            return [$classes[$_REQUEST['PROFILE_ID']]];
        }
        return $classes;
    }

    public function getProfilesList()
    {
        return ['pvz' => Loc::getMessage("lpost.handler_children_pvzname"), 'zone' => Loc::getMessage("lpost.handler_children_zonename")];
    }

    /**
     * add child profiles for this delivery
     * @param int $id
     * @param array $fields
     * @return bool
     * @throws \Exception
     */
    public static function onAfterAdd($id, array $fields = [])
    {
        $sort = 100;
        $classes = self::getProfiles();

        $fileArr=\CFile::MakeFileArray('https://l-post.ru/img/lpost_plugin_logo.png');
        $fileArr['MODULE_ID']='sale';
        $fid = \CFile::SaveFile($fileArr, "sale");
        $defaultConfig = \Bitrix\Sale\Delivery\Services\Table::getList([
            "select" => ["CONFIG"],
            "filter" => [
                "ID" => $id
            ]
        ])->fetch();


        foreach ($classes as $nextClass) {
            $name = $nextClass::getClassTitle();
            $desc = $nextClass::getClassDescription();
            $childFields = [
                'SORT' => $sort,
                'NAME' => $name,
                'CURRENCY' => $fields['CURRENCY'],
                'PARENT_ID' => $id,
                'CLASS_NAME' => $nextClass,
                'DESCRIPTION' => $desc,
                'ACTIVE' => 'Y',
                'CONFIG' => $defaultConfig['CONFIG']
            ];
            if (intval($fid)>0){
                $childFields['LOGOTIP']=$fid;
            }
            $sort += 100;
            \Bitrix\Sale\Delivery\Services\Table::add($childFields);
        }
        if (intval($fid)>0){
            \Bitrix\Sale\Delivery\Services\Table::update($id, ['LOGOTIP'=>$fid]);
        }
        return true;
    }

    public static function getRPList()
    {
        $list = \Lpost\Delivery\Settings::getInstance()->getReceivePoints();
        $listHtml = [];
        foreach ($list as $nextOption) {
            if ($nextOption['id_sklad'] == 3) {
                $courier = [$nextOption['id_sklad'] => Loc::getMessage("lpost.handler_setting_rplist_coorier")];
                $listHtml = $courier + $listHtml;
                continue;
            }
            $listHtml[$nextOption['id_sklad']] = $nextOption['city_name'] . ' - ' . $nextOption['address'] . '[' . $nextOption['id_sklad'] . ']';
        }
        return $listHtml;
    }

    public static function isTokenReady()
    {
        $options = \Lpost\Delivery\Settings::getInstance()->getOptions();
        if(empty($options['lpost_token']) OR empty($options['secret_key']))
        {
            return false;
        }
        return true;
    }


}

?>

Youez - 2016 - github.com/yon3zu
LinuXploit