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/entity/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/lpost.delivery/lib/entity/pvztable.php
<?php
namespace Lpost\Delivery\Entity;

use \Bitrix\Main\Localization\Loc,
    \Bitrix\Main\ORM\Data\DataManager,
    \Bitrix\Main\ORM\Fields\BooleanField,
    \Bitrix\Main\ORM\Fields\DatetimeField,
    \Bitrix\Main\ORM\Fields\FloatField,
    \Bitrix\Main\ORM\Fields\IntegerField,
    \Bitrix\Main\ORM\Fields\StringField,
    \Bitrix\Main\ORM\Fields\TextField,
    \Bitrix\Main\ORM\Fields\Validators\LengthValidator,
    \Bitrix\Main\Type\DateTime;

Loc::loadMessages(__FILE__);


class PvzTable extends DataManager
{
    const IDS_REGIONS_OF_MOSCOW_REGION = [50, 77];
    /**
     * Returns DB table name for entity.
     *
     * @return string
     */
    public static function getTableName()
    {
        return 'lpost_delivery_pvz';
    }

    public static function getStorageTable()
    {
        return 'lpost_delivery_pickup_storage';
    }

    /**
     * Returns entity map definition.
     *
     * @return array
     */
    public static function getMap()
    {
        return [
            new IntegerField(
                'id',
                [
                    'primary' => true,
                    'autocomplete' => true,
                    'title' => Loc::getMessage('PVZ_ENTITY_ID_FIELD')
                ]
            ),
            new IntegerField(
                'id_pickup',
                [
                    'primary' => true,
                    'title' => Loc::getMessage('PVZ_ENTITY_ID_PICKUP_FIELD')
                ]
            ),
            new FloatField(
                'coord_lat',
                [
                    'default' => 0,
                    'title' => Loc::getMessage('PVZ_ENTITY_COORD_LAT_FIELD')
                ]
            ),
            new FloatField(
                'coord_long',
                [
                    'default' => 0,
                    'title' => Loc::getMessage('PVZ_ENTITY_COORD_LONG_FIELD')
                ]
            ),
            new StringField(
                'address',
                [
                    'required' => true,
                    'validation' => [__CLASS__, 'validateAddress'],
                    'title' => Loc::getMessage('PVZ_ENTITY_ADDRESS_FIELD')
                ]
            ),
            new TextField(
                'pickup_dop',
                [
                    'title' => Loc::getMessage('PVZ_ENTITY_PICKUP_DOP_FIELD')
                ]
            ),
            new TextField(
                'photo',
                [
                    'title' => Loc::getMessage('PVZ_ENTITY_PHOTO_FIELD')
                ]
            ),
            new StringField(
                'metro',
                [
                    'validation' => [__CLASS__, 'validateMetro'],
                    'title' => Loc::getMessage('PVZ_ENTITY_METRO_FIELD')
                ]
            ),
            new TextField(
                'time_work',
                [
                    'title' => Loc::getMessage('PVZ_ENTITY_TIME_WORK_FIELD')
                ]
            ),
            new StringField(
                'city_name',
                [
                    'required' => true,
                    'validation' => [__CLASS__, 'validateCityName'],
                    'title' => Loc::getMessage('PVZ_ENTITY_CITY_NAME_FIELD')
                ]
            ),
            new IntegerField(
                'id_region',
                [
                    'required' => true,
                    'title' => Loc::getMessage('PVZ_ENTITY_ID_REGION_FIELD')
                ]
            ),
            new IntegerField(
                'is_cash',
                [
                    'required' => true,
                    'title' => Loc::getMessage('PVZ_ENTITY_IS_CASH_FIELD')
                ]
            ),
            new IntegerField(
                'is_card',
                [
                    'required' => true,
                    'title' => Loc::getMessage('PVZ_ENTITY_IS_CARD_FIELD')
                ]
            ),
            new IntegerField(
                'id_zone',
                [
                    'required' => true,
                    'title' => Loc::getMessage('PVZ_ENTITY_ID_ZONE_FIELD')
                ]
            ),
            new IntegerField(
                'day_logistic',
                [
                    'required' => true,
                    'title' => Loc::getMessage('PVZ_ENTITY_DAY_LOGISTIC_FIELD')
                ]
            ),
            new BooleanField(
                'active',
                [
                    'values' => array('N', 'Y'),
                    'default' => 'Y',
                    'title' => Loc::getMessage('PVZ_ENTITY_ACTIVE_FIELD')
                ]
            ),
            new DatetimeField(
                'data_update',
                [
                    'default' => function()
                    {
                        return new DateTime();
                    },
                    'title' => Loc::getMessage('PVZ_ENTITY_DATA_UPDATE_FIELD')
                ]
            ),
            new TextField(
                'params',
                [
                    'title' => Loc::getMessage('PVZ_ENTITY_PARAMS_FIELD'),
                    'save_data_modification' => function () {
                        return array(
                            function ($value) {
                                return serialize($value);
                            }
                        );
                    },
                    'fetch_data_modification' => function () {
                        return array(
                            function ($value) {
                                return isset($value) ? unserialize($value) : false;
                            }
                        );
                    }
                ]
            ),
            new BooleanField(
                'has_fitting_room',
                [
                    'values' => array('N', 'Y'),
                    'default' => 'N',
                    'title' => Loc::getMessage('PVZ_ENTITY_HAS_FITTING_ROOM')
                ]
            ),

        ];
    }

    /**
     * Returns validators for address field.
     *
     * @return array
     */
    public static function validateAddress()
    {
        return [
            new LengthValidator(null, 255),
        ];
    }

    /**
     * Returns validators for metro field.
     *
     * @return array
     */
    public static function validateMetro()
    {
        return [
            new LengthValidator(null, 255),
        ];
    }

    /**
     * Returns validators for city_name field.
     *
     * @return array
     */
    public static function validateCityName()
    {
        return [
            new LengthValidator(null, 255),
        ];
    }

    public static function deActive()
    {
        global $DB;
        return $DB->Query(
            "UPDATE " . self::getTableName()  . "as t1
            SET t1.active = 'N'
            WHERE t1.id_pickup NOT IN (SELECT `id_pickup` FROM " . self::getStorageTable() . ")",
            true
        );

    }

    public static function isCityFromMoscowRegion($cityName): bool
    {
        $row = self::getRow([
            "select" => ["id"],
            "filter" => [
                "id_region" => [50, 77],
                "city_name" => $cityName,
            ]
        ]);
        return ($row ? true : false);
    }


}

Youez - 2016 - github.com/yon3zu
LinuXploit