コード例 #1
0
function OnProductCatalogHandler($ID, $arFields)
{
    Bitrix\Main\Loader::includeModule('iblock');
    Bitrix\Main\Loader::includeModule('catalog');
    define('IBLOCK_ID_PRODUCTS', 2);
    define('IBLOCK_ID_OFFERS', 3);
    $query = new \Bitrix\Main\Entity\Query(Bitrix\Iblock\ElementTable::getEntity());
    $query->setSelect(array("ID", "IBLOCK_ID"))->setFilter(array("ID" => $ID))->setOrder(array("ID" => "ASC"));
    $resElement = $query->exec()->fetch();
    if ($resElement['IBLOCK_ID'] == IBLOCK_ID_PRODUCTS) {
        CIBlockElement::SetPropertyValuesEx($ID, $resElement['IBLOCK_ID'], array("AVAILABLE_QUANTITY_CATALOG" => $arFields['QUANTITY']));
    } elseif ($resElement['IBLOCK_ID'] == IBLOCK_ID_OFFERS) {
        //1
        $rsElementOffer = CIBlockElement::GetList(array(), array("ID" => $ID), false, false, array("ID", "IBLOCK_ID", 'NAME', "PROPERTY_CML2_LINK"))->fetch();
        $resElemOfferProduct = (int) $rsElementOffer['PROPERTY_CML2_LINK_VALUE'];
        //2
        $resOffersCML2 = CIBlockElement::GetList(array(), array("PROPERTY_CML2_LINK" => $resElemOfferProduct, 'IBLOCK_ID' => IBLOCK_ID_OFFERS), false, false, array("ID", "IBLOCK_ID", 'NAME'));
        //3
        $arrOffersIDs = array();
        while ($res = $resOffersCML2->fetch()) {
            $arrOffersIDs[] = $res['ID'];
        }
        //4
        $availQuant = array();
        foreach ($arrOffersIDs as $k => $v) {
            $ar_res_cat = CCatalogProduct::GetList(array("ID" => "DESC"), array("ID" => (int) $v), false, false, array("ID", "QUANTITY", 'ELEMENT_IBLOCK_ID', 'ELEMENT_NAME'))->fetch();
            $availQuant[] = $ar_res_cat['QUANTITY'];
        }
        //5
        $minAvailQuant = (int) min($availQuant);
        //6
        $resUpdateSCU = CIBlockElement::SetPropertyValuesEx($resElemOfferProduct, IBLOCK_ID_PRODUCTS, array("AVAILABLE_QUANTITY_CATALOG" => $minAvailQuant));
    }
}
コード例 #2
0
ファイル: vi_sip.php プロジェクト: DarneoStudio/bitrix
 public function Add($fields)
 {
     $arAdd = $this->PrepareFiedls($fields);
     if (!$arAdd) {
         return false;
     }
     if ($arAdd['TYPE'] == self::TYPE_CLOUD) {
         $countQuery = new \Bitrix\Main\Entity\Query(VI\SipTable::getEntity());
         $countQuery->addSelect(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(1)'));
         $countQuery->setFilter(array('TYPE' => self::TYPE_CLOUD));
         $totalCount = $countQuery->setLimit(null)->setOffset(null)->exec()->fetch();
         if ($totalCount['CNT'] >= 5) {
             $this->error = new CVoxImplantError(__METHOD__, 'MAX_CLOUD_PBX', GetMessage('VI_SIP_ADD_CLOUD_ERR', array("#NUMBER#" => 5)));
             return false;
         }
     }
     if (strlen($arAdd['PHONE_NAME']) > 0) {
         $orm = VI\ConfigTable::getList(array('filter' => array('=PHONE_NAME' => $arAdd['PHONE_NAME'])));
         if ($orm->fetch()) {
             $this->error = new CVoxImplantError(__METHOD__, 'TITLE_EXISTS', GetMessage('VI_SIP_TITLE_EXISTS'));
             return false;
         }
     }
     $melodyLang = 'EN';
     if (LANGUAGE_ID == 'ru') {
         $melodyLang = 'RU';
     } else {
         if (LANGUAGE_ID == 'de') {
             $melodyLang = 'DE';
         } else {
             if (LANGUAGE_ID == 'ua') {
                 $melodyLang = 'UA';
             }
         }
     }
     $result = VI\ConfigTable::add(array('PORTAL_MODE' => 'SIP', 'SEARCH_ID' => $arAdd['SEARCH_ID'], 'PHONE_NAME' => trim($arAdd['PHONE_NAME']), 'MELODY_LANG' => $melodyLang));
     if (!$result) {
         $this->error = new CVoxImplantError(__METHOD__, 'TITLE_EXISTS', GetMessage('VI_SIP_TITLE_EXISTS'));
         return false;
     }
     $configId = $result->getId();
     $userId = $GLOBALS['USER']->GetId();
     if ($userId > 0) {
         VI\QueueTable::add(array('CONFIG_ID' => $configId, 'USER_ID' => $userId, 'STATUS' => 'OFFLINE'));
     }
     if (CVoxImplantConfig::GetPortalNumber() == CVoxImplantConfig::LINK_BASE_NUMBER) {
         CVoxImplantConfig::SetPortalNumber($arAdd['SEARCH_ID']);
     }
     unset($arAdd['SEARCH_ID']);
     unset($arAdd['PHONE_NAME']);
     $arAdd['CONFIG_ID'] = $configId;
     VI\SipTable::add($arAdd);
     return $configId;
 }
コード例 #3
0
ファイル: ajax.php プロジェクト: mrdeadmouse/u136006
 protected function processActionCalculate()
 {
     if (!$this->checkRequiredPostParams(array('objectId'))) {
         $this->sendJsonErrorResponse();
     }
     /** @var Folder $folder */
     $folder = Folder::loadById((int) $this->request->getPost('objectId'), array('STORAGE'));
     if (!$folder) {
         $this->errorCollection->addOne(new Error(Loc::getMessage('DISK_TRASHCAN_ERROR_COULD_NOT_FIND_OBJECT'), self::ERROR_COULD_NOT_FIND_OBJECT));
         $this->sendJsonErrorResponse();
     }
     $securityContext = $folder->getStorage()->getCurrentUserSecurityContext();
     if (!$folder->canRead($securityContext)) {
         $this->sendJsonAccessDeniedResponse();
     }
     $countQuery = new Bitrix\Main\Entity\Query(FolderTable::getEntity());
     $totalCount = $countQuery->setFilter(array('PATH_CHILD.PARENT_ID' => $folder->getId(), '!PATH_CHILD.OBJECT_ID' => $folder->getId(), '!=DELETED_TYPE' => ObjectTable::DELETED_TYPE_NONE, '=RIGHTS_CHECK' => true))->registerRuntimeField('RIGHTS_CHECK', new ExpressionField('RIGHTS_CHECK', 'CASE WHEN ' . $securityContext->getSqlExpressionForList('%1$s', '%2$s') . ' THEN 1 ELSE 0 END', array('ID', 'CREATED_BY')))->addSelect(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(1)'))->setLimit(null)->setOffset(null)->exec()->fetch();
     $this->sendJsonSuccessResponse(array('countItems' => $totalCount['CNT']));
 }
コード例 #4
0
ファイル: CISCity.php プロジェクト: AlexPrya/iShop
    public static function GetCityList() {

        $arResult = array();

        $rsData = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter'=>array('NAME'=>CITY_LIST_HLB)));
        if ( !($arData = $rsData->fetch()) ){
            echo 'Инфоблок не найден';
        } else {
            $Entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($arData);

            $Query = new \Bitrix\Main\Entity\Query($Entity);
            $Query->setSelect(array('*'));

            $result = $Query->exec();
            $result = new CDBResult($result);

            while ($row = $result->Fetch()){
                $arResult[$row['UF_CITY_CODE']] = $row['UF_CITY_NAME'];
            }

        }
        return $arResult;

    }
コード例 #5
0
 static function GetUserData($arParams = array())
 {
     $getDepartment = $arParams['DEPARTMENT'] == 'N' ? false : true;
     $getHrPhoto = $arParams['HR_PHOTO'] == 'Y' ? true : false;
     $getPhones = $arParams['PHONES'] == 'Y' ? true : false;
     $useCache = !$getPhones && $arParams['USE_CACHE'] == 'Y' ? true : false;
     $showOnline = $arParams['SHOW_ONLINE'] == 'N' ? false : true;
     $arFilter = array();
     if (isset($arParams['ID']) && is_array($arParams['ID']) && !empty($arParams['ID'])) {
         foreach ($arParams['ID'] as $key => $value) {
             if (intval($value) > 0) {
                 $arParams['ID'][$key] = intval($value);
             }
         }
         $arFilter['=ID'] = $arParams['ID'];
     } else {
         if (isset($arParams['ID']) && intval($arParams['ID']) > 0) {
             $arFilter['=ID'] = array(intval($arParams['ID']));
         }
     }
     if (empty($arFilter)) {
         return false;
     }
     $nameTemplate = self::GetUserNameTemplate(SITE_ID);
     $nameTemplateSite = CSite::GetNameFormat(false);
     $bIntranetEnable = false;
     if (IsModuleInstalled('intranet') && CModule::IncludeModule('intranet')) {
         $bIntranetEnable = true;
     }
     $bVoximplantEnable = IsModuleInstalled('voximplant');
     $bColorEnabled = IM\Color::isEnabled();
     if ($useCache) {
         global $USER;
         $obCache = new CPHPCache();
         $cache_ttl = intval($arParams['CACHE_TTL']);
         if ($cache_ttl <= 0) {
             $cache_ttl = defined("BX_COMP_MANAGED_CACHE") ? 18144000 : 1800;
         }
         $cache_id = 'user_data_v8_' . (is_object($USER) ? $USER->GetID() : 'AGENT') . '_' . implode('|', $arFilter['=ID']) . '_' . $nameTemplate . '_' . $nameTemplateSite . '_' . $getPhones . '_' . $getDepartment . '_' . $bIntranetEnable . '_' . $bVoximplantEnable . '_' . LANGUAGE_ID . '_' . $bColorEnabled;
         $cache_dir = '/bx/imc/userdata';
         if ($obCache->InitCache($cache_ttl, $cache_id, $cache_dir)) {
             $arCacheResult = $obCache->GetVars();
             if ($showOnline) {
                 $arOnline = CIMStatus::GetList(array('ID' => array_keys($arCacheResult['users']), 'GET_OFFLINE' => 'Y'));
             }
             foreach ($arCacheResult['users'] as $userId => $value) {
                 $arCacheResult['users'][$userId]['birthday'] = $bIntranetEnable ? CIntranetUtils::IsToday($arCacheResult['users'][$userId]['birthday']) : false;
                 if ($showOnline) {
                     $arCacheResult['users'][$userId]['status'] = isset($arOnline['users'][$userId]) ? $arOnline['users'][$userId]['status'] : 'offline';
                     $arCacheResult['users'][$userId]['idle'] = isset($arOnline['users'][$userId]) ? $arOnline['users'][$userId]['idle'] : 0;
                     $arCacheResult['users'][$userId]['mobileLastDate'] = isset($arOnline['users'][$userId]) ? $arOnline['users'][$userId]['mobileLastDate'] : 0;
                     if ($arOnline['users'][$userId]) {
                         $arCacheResult['users'][$userId]['color'] = $arOnline['users'][$userId]['color'];
                     }
                 }
                 if ($getHrPhoto && !isset($arCacheResult['hrphoto'])) {
                     $arPhotoHrTmp = CFile::ResizeImageGet($arCacheResult['source'][$userId]["PERSONAL_PHOTO"], array('width' => 200, 'height' => 200), BX_RESIZE_IMAGE_EXACT, false, false, true);
                     $arCacheResult['hrphoto'][$userId] = empty($arPhotoHrTmp['src']) ? '/bitrix/js/im/images/hidef-avatar-v3.png' : $arPhotoHrTmp['src'];
                     // TODO REMOVE DEFAULT
                 }
             }
             return $arCacheResult;
         }
     }
     $arSelect = array("ID", "LAST_NAME", "NAME", "LOGIN", "PERSONAL_PHOTO", "SECOND_NAME", "PERSONAL_BIRTHDAY", "WORK_POSITION", "PERSONAL_GENDER", "EXTERNAL_AUTH_ID");
     if ($getPhones) {
         $arSelect[] = 'WORK_PHONE';
         $arSelect[] = 'PERSONAL_PHONE';
         $arSelect[] = 'PERSONAL_MOBILE';
     }
     if ($bIntranetEnable) {
         $arSelect[] = 'UF_PHONE_INNER';
         $arSelect[] = 'UF_DEPARTMENT';
     }
     if ($bVoximplantEnable) {
         $arSelect[] = 'UF_VI_PHONE';
         $arSelect[] = 'UF_PHONE_INNER';
     }
     $arUsers = array();
     $arUserInGroup = array();
     $arPhones = array();
     $arWoUserInGroup = array();
     $arHrPhoto = array();
     $arSource = array();
     $query = new \Bitrix\Main\Entity\Query(\Bitrix\Main\UserTable::getEntity());
     $query->registerRuntimeField('', new \Bitrix\Main\Entity\ReferenceField('ref', 'Bitrix\\Im\\StatusTable', array('=this.ID' => 'ref.USER_ID')));
     $query->addSelect('ref.COLOR', 'COLOR')->addSelect('ref.STATUS', 'STATUS')->addSelect('ref.IDLE', 'IDLE')->addSelect('ref.MOBILE_LAST_DATE', 'MOBILE_LAST_DATE');
     $sago = Bitrix\Main\Application::getConnection()->getSqlHelper()->addSecondsToDateTime('-180');
     $query->registerRuntimeField('', new \Bitrix\Main\Entity\ExpressionField('IS_ONLINE_CUSTOM', 'CASE WHEN LAST_ACTIVITY_DATE > ' . $sago . ' THEN \'Y\' ELSE \'N\' END'));
     $query->addSelect('IS_ONLINE_CUSTOM');
     foreach ($arSelect as $value) {
         $query->addSelect($value);
     }
     foreach ($arFilter as $key => $value) {
         $query->addFilter($key, $value);
     }
     $resultQuery = $query->exec();
     global $USER;
     $arExtraUser = array();
     while ($arUser = $resultQuery->fetch()) {
         foreach ($arUser as $key => $value) {
             $arUser[$key] = !is_array($value) && !is_object($value) ? htmlspecialcharsEx($value) : $value;
         }
         $arExtraUser[$arUser["ID"]] = $arUser;
         $arSource[$arUser["ID"]]["PERSONAL_PHOTO"] = $arUser["PERSONAL_PHOTO"];
         $arPhotoTmp = CFile::ResizeImageGet($arUser["PERSONAL_PHOTO"], array('width' => 58, 'height' => 58), BX_RESIZE_IMAGE_EXACT, false, false, true);
         $color = self::GetUserColor($arUser["ID"], $arUser['PERSONAL_GENDER'] == 'M' ? 'M' : 'F');
         if (isset($arUser['COLOR']) && strlen($arUser['COLOR']) > 0) {
             $color = IM\Color::getColor($arUser['COLOR']);
         }
         if (!$color) {
             $color = self::GetUserColor($arUser["ID"], $arUser['PERSONAL_GENDER'] == 'M' ? 'M' : 'F');
         }
         $arUsers[$arUser["ID"]] = array('id' => $arUser["ID"], 'name' => CUser::FormatName($nameTemplateSite, $arUser, true, false), 'nameList' => CUser::FormatName($nameTemplate, $arUser, true, false), 'workPosition' => $arUser['WORK_POSITION'], 'color' => $color, 'avatar' => empty($arPhotoTmp['src']) ? '/bitrix/js/im/images/blank.gif' : $arPhotoTmp['src'], 'status' => 'offline', 'birthday' => $arUser['PERSONAL_BIRTHDAY'], 'gender' => $arUser['PERSONAL_GENDER'] == 'F' ? 'F' : 'M', 'phoneDevice' => $bVoximplantEnable && $arUser['UF_VI_PHONE'] == 'Y', 'extranet' => self::IsExtranet($arUser), 'network' => $arUser['EXTERNAL_AUTH_ID'] == self::NETWORK_AUTH_ID, 'profile' => CIMContactList::GetUserPath($arUser["ID"]));
         if ($getDepartment && is_array($arUser["UF_DEPARTMENT"]) && !empty($arUser["UF_DEPARTMENT"])) {
             foreach ($arUser["UF_DEPARTMENT"] as $dep_id) {
                 if (isset($arUserInGroup[$dep_id])) {
                     $arUserInGroup[$dep_id]['users'][] = $arUser["ID"];
                 } else {
                     $arUserInGroup[$dep_id] = array('id' => $dep_id, 'users' => array($arUser["ID"]));
                 }
             }
             if (isset($arWoUserInGroup['all'])) {
                 $arWoUserInGroup['all']['users'][] = $arUser["ID"];
             } else {
                 $arWoUserInGroup['all'] = array('id' => 'all', 'users' => array($arUser["ID"]));
             }
         }
         if ($getHrPhoto) {
             $arPhotoHrTmp = CFile::ResizeImageGet($arUser["PERSONAL_PHOTO"], array('width' => 200, 'height' => 200), BX_RESIZE_IMAGE_EXACT, false, false, true);
             $arHrPhoto[$arUser["ID"]] = empty($arPhotoHrTmp['src']) ? '/bitrix/js/im/images/hidef-avatar-v3.png' : $arPhotoHrTmp['src'];
             // TODO REMOVE DEFAULT
         }
         if ($getPhones) {
             if (CModule::IncludeModule('voximplant')) {
                 $result = CVoxImplantPhone::Normalize($arUser["WORK_PHONE"]);
                 if ($result) {
                     $arPhones[$arUser["ID"]]['WORK_PHONE'] = $arUser['WORK_PHONE'];
                 }
                 $result = CVoxImplantPhone::Normalize($arUser["PERSONAL_MOBILE"]);
                 if ($result) {
                     $arPhones[$arUser["ID"]]['PERSONAL_MOBILE'] = $arUser['PERSONAL_MOBILE'];
                 }
                 $result = CVoxImplantPhone::Normalize($arUser["PERSONAL_PHONE"]);
                 if ($result) {
                     $arPhones[$arUser["ID"]]['PERSONAL_PHONE'] = $arUser['PERSONAL_PHONE'];
                 }
                 $result = preg_replace("/[^0-9\\#\\*]/i", "", $arUser["UF_PHONE_INNER"]);
                 if ($result) {
                     $arPhones[$arUser["ID"]]['INNER_PHONE'] = $result;
                 }
             } else {
                 $arPhones[$arUser["ID"]]['WORK_PHONE'] = $arUser['WORK_PHONE'];
                 $arPhones[$arUser["ID"]]['PERSONAL_MOBILE'] = $arUser['PERSONAL_MOBILE'];
                 $arPhones[$arUser["ID"]]['PERSONAL_PHONE'] = $arUser['PERSONAL_PHONE'];
             }
         }
     }
     foreach ($arUsers as $userId => $arUser) {
         $arUsers[$userId]['birthday'] = $bIntranetEnable ? CIntranetUtils::IsToday($arUsers[$userId]['birthday']) : false;
         $arUsers[$userId]['status'] = $arExtraUser[$userId]['IS_ONLINE_CUSTOM'] == 'Y' ? $arExtraUser[$userId]['STATUS'] : 'offline';
         $arUsers[$userId]['idle'] = $arExtraUser[$userId]['IS_ONLINE_CUSTOM'] == 'Y' && is_object($arExtraUser[$userId]['IDLE']) ? $arExtraUser[$userId]['IDLE']->getTimestamp() : 0;
         $arUsers[$userId]['mobileLastDate'] = $arExtraUser[$userId]['IS_ONLINE_CUSTOM'] == 'Y' && is_object($arExtraUser[$userId]['MOBILE_LAST_DATE']) ? $arExtraUser[$userId]['MOBILE_LAST_DATE']->getTimestamp() : 0;
     }
     $result = array('users' => $arUsers, 'hrphoto' => $arHrPhoto, 'userInGroup' => $arUserInGroup, 'woUserInGroup' => $arWoUserInGroup, 'phones' => $arPhones, 'source' => $arSource);
     if ($useCache) {
         $cacheTag = array();
         if ($obCache->StartDataCache()) {
             if (defined("BX_COMP_MANAGED_CACHE")) {
                 global $CACHE_MANAGER;
                 $CACHE_MANAGER->StartTagCache($cache_dir);
                 $CACHE_MANAGER->RegisterTag("IM_CONTACT_LIST");
                 if (is_array($arParams['ID'])) {
                     foreach ($arParams['ID'] as $id) {
                         $tag = 'USER_NAME_' . intval($id);
                         if (!in_array($tag, $cacheTag)) {
                             $cacheTag[] = $tag;
                             $CACHE_MANAGER->RegisterTag($tag);
                         }
                     }
                 } elseif (isset($arParams['ID']) && intval($arParams['ID']) > 0) {
                     $tag = 'USER_NAME_' . intval($arParams['ID']);
                     $CACHE_MANAGER->RegisterTag($tag);
                 }
                 $CACHE_MANAGER->EndTagCache();
             }
             $obCache->EndDataCache($result);
             unset($cacheTag);
         }
     }
     unset($result['source']);
     return $result;
 }
コード例 #6
0
 public static function beforeViewDataQuery(&$select, &$filter, &$group, &$order, &$limit, &$options, &$runtime)
 {
     parent::beforeViewDataQuery($select, $filter, $group, $order, $limit, $options, $runtime);
     global $USER, $DB, $DBType;
     $permFilter = array('LOGIC' => 'OR');
     // owner permission
     if (isset($_GET['select_my_tasks']) || !isset($_GET['select_my_tasks']) && !isset($_GET['select_depts_tasks']) && !isset($_GET['select_group_tasks'])) {
         $runtime['IS_TASK_COWORKER'] = array('data_type' => 'integer', 'expression' => array("(CASE WHEN EXISTS(" . "SELECT 'x' FROM b_tasks_member TM " . "WHERE TM.TASK_ID = " . $DB->escL . (ToUpper($DBType) === "ORACLE" ? "TASKS_TASK" : "tasks_task") . $DB->escR . ".ID AND TM.USER_ID = " . $USER->GetID() . " AND TM.TYPE = 'A'" . ") THEN 1 ELSE 0 END)"));
         $permFilter[] = array('LOGIC' => 'OR', '=RESPONSIBLE_ID' => $USER->GetID(), '=IS_TASK_COWORKER' => 1);
     }
     // own departments permission
     if (isset($_GET['select_depts_tasks'])) {
         $permFilterDepts = array('LOGIC' => 'OR', '=CREATED_BY' => $USER->GetID());
         $deptsPermSql = CTasks::GetSubordinateSql('__ULTRAUNIQUEPREFIX__');
         if (strlen($deptsPermSql)) {
             $deptsPermSql = "EXISTS(" . $deptsPermSql . ")";
             $deptsPermSql = str_replace('__ULTRAUNIQUEPREFIX__T.', $DB->escL . (ToUpper($DBType) === "ORACLE" ? "TASKS_TASK" : "tasks_task") . $DB->escR . '.', $deptsPermSql);
             $deptsPermSql = str_replace('__ULTRAUNIQUEPREFIX__', '', $deptsPermSql);
             $runtime['IS_SUBORDINATED_TASK'] = array('data_type' => 'integer', 'expression' => array("(CASE WHEN " . $deptsPermSql . " THEN 1 ELSE 0 END)"));
             $permFilterDepts[] = array('!RESPONSIBLE_ID' => $USER->GetID(), '=IS_SUBORDINATED_TASK' => 1);
         }
         $permFilter[] = $permFilterDepts;
     }
     // group permission
     if (isset($_GET['select_group_tasks'])) {
         $allowedGroups = CTasks::GetAllowedGroups();
         $permFilter[] = array('=GROUP_ID' => $allowedGroups);
     }
     // re-aggregate aggregated subquery in DURATION for mssql
     if (\Bitrix\Main\Application::getConnection() instanceof \Bitrix\Main\DB\MssqlConnection) {
         foreach ($select as $k => $v) {
             if (substr($k, -9) == '_DURATION') {
                 // we have aggregated duration
                 $subQuery = new \Bitrix\Main\Entity\Query(\Bitrix\Tasks\ElapsedTimeTable::getEntity());
                 $subQuery->addSelect('TASK_ID');
                 $subQuery->addSelect(new \Bitrix\Main\Entity\ExpressionField('DURATION', 'ROUND(SUM(%s)/60, 0)', 'SECONDS'));
                 $subEntity = \Bitrix\Main\Entity\Base::getInstanceByQuery($subQuery);
                 // make reference
                 $subReferenceName = $k . '_REF';
                 $runtime[$subReferenceName] = array('data_type' => $subEntity, 'reference' => array('=this.ID' => 'ref.TASK_ID'));
                 // rewrite aggregated duration (put it in the end, after refence)
                 $runtimeField = $runtime[$k];
                 unset($runtime[$k]);
                 $runtimeField['expression'][1] = $subReferenceName . '.DURATION';
                 $runtime[$k] = $runtimeField;
             } else {
                 if (substr($k, -20) == '_DURATION_FOR_PERIOD' && isset($options['SQL_TIME_INTERVAL'])) {
                     // we have aggregated DURATION_FOR_PERIOD field
                     $subQuery = new \Bitrix\Main\Entity\Query(\Bitrix\Tasks\ElapsedTimeTable::getEntity());
                     $subQuery->addSelect('TASK_ID');
                     $subQuery->addSelect(new \Bitrix\Main\Entity\ExpressionField('DURATION_FOR_PERIOD', 'ROUND((SUM(CASE WHEN CREATED_DATE ' . $options['SQL_TIME_INTERVAL'] . ' THEN %s ELSE 0 END)/60),0)', 'SECONDS'));
                     $subEntity = \Bitrix\Main\Entity\Base::getInstanceByQuery($subQuery);
                     // make reference
                     $subReferenceName = $k . '_REF';
                     $runtime[$subReferenceName] = array('data_type' => $subEntity, 'reference' => array('=this.ID' => 'ref.TASK_ID'));
                     // rewrite aggregated duration (put it in the end, after refence)
                     $runtimeField = $runtime[$k];
                     unset($runtime[$k]);
                     $runtimeField['expression'][1] = $subReferenceName . '.DURATION_FOR_PERIOD';
                     $runtime[$k] = $runtimeField;
                 }
             }
         }
     }
     // concat permissions with common filter
     $filter[] = $permFilter;
 }
コード例 #7
0
ファイル: pull_push.php プロジェクト: DarneoStudio/bitrix
 public static function GetDeviceInfo($userId, $appId = 'Bitrix24')
 {
     $result = array();
     if (is_array($userId)) {
         foreach ($userId as $key => $id) {
             $id = intval($id);
             if ($id > 0) {
                 $result[$id] = array('mode' => self::RECORD_NOT_FOUND, 'device' => array());
             }
         }
     } else {
         if (intval($userId) > 0) {
             $result[intval($userId)] = array('mode' => self::RECORD_NOT_FOUND, 'device' => array());
         }
     }
     if (empty($result)) {
         return false;
     }
     $imInclude = false;
     if (CModule::IncludeModule('im')) {
         $imInclude = true;
     }
     $query = new \Bitrix\Main\Entity\Query(\Bitrix\Main\UserTable::getEntity());
     $sago = Bitrix\Main\Application::getConnection()->getSqlHelper()->addSecondsToDateTime('-180');
     $query->registerRuntimeField('', new \Bitrix\Main\Entity\ExpressionField('IS_ONLINE_CUSTOM', 'CASE WHEN LAST_ACTIVITY_DATE > ' . $sago . ' THEN \'Y\' ELSE \'N\' END'));
     $query->addSelect('ID')->addSelect('EMAIL')->addSelect('IS_ONLINE_CUSTOM');
     if ($imInclude) {
         $query->registerRuntimeField('', new \Bitrix\Main\Entity\ReferenceField('im', 'Bitrix\\Im\\StatusTable', array('=this.ID' => 'ref.USER_ID')));
         $query->addSelect('im.IDLE', 'IDLE')->addSelect('im.MOBILE_LAST_DATE', 'MOBILE_LAST_DATE');
     }
     $query->registerRuntimeField('', new \Bitrix\Main\Entity\ReferenceField('push', 'Bitrix\\Pull\\PushTable', array('=this.ID' => 'ref.USER_ID')));
     $query->registerRuntimeField('', new \Bitrix\Main\Entity\ExpressionField('HAS_MOBILE', 'CASE WHEN main_user_push.USER_ID > 0 THEN \'Y\' ELSE \'N\' END'));
     $query->addSelect('HAS_MOBILE')->addSelect('push.APP_ID', 'APP_ID')->addSelect('push.UNIQUE_HASH', 'UNIQUE_HASH')->addSelect('push.DEVICE_TYPE', 'DEVICE_TYPE')->addSelect('push.DEVICE_TOKEN', 'DEVICE_TOKEN');
     $query->addFilter('=ID', array_keys($result));
     $queryResult = $query->exec();
     while ($user = $queryResult->fetch()) {
         $uniqueHashes[] = CPullPush::getUniqueHash($user["ID"], $appId);
         $uniqueHashes[] = CPullPush::getUniqueHash($user["ID"], $appId . "_bxdev");
         if (in_array($user['UNIQUE_HASH'], $uniqueHashes)) {
             $result[$user['ID']]['device'][] = array('APP_ID' => $user['APP_ID'], 'USER_ID' => $user['ID'], 'DEVICE_TYPE' => $user['DEVICE_TYPE'], 'DEVICE_TOKEN' => $user['DEVICE_TOKEN']);
             //$result[$user['ID']]['email'] = $user['EMAIL'];
         } else {
             continue;
         }
         if ($result[$user['ID']]['mode'] != self::RECORD_NOT_FOUND) {
             continue;
         }
         $isMobile = false;
         $isOnline = false;
         $isDesktop = false;
         $isDesktopIdle = false;
         if ($user['HAS_MOBILE'] == 'N') {
             $result[$user['ID']]['mode'] = self::RECORD_NOT_FOUND;
             $result[$user['ID']]['device'] = array();
             continue;
         }
         if ($user['IS_ONLINE_CUSTOM'] == 'Y') {
             $isOnline = true;
         }
         if ($imInclude) {
             $mobileLastDate = 0;
             if (is_object($user['MOBILE_LAST_DATE'])) {
                 $mobileLastDate = $user['MOBILE_LAST_DATE']->getTimestamp();
             }
             if ($mobileLastDate > 0 && $mobileLastDate + 180 > time()) {
                 $isMobile = true;
             }
             $isDesktop = CIMMessenger::CheckDesktopStatusOnline($user['ID']);
             if ($isDesktop && $isOnline && is_object($user['IDLE'])) {
                 if ($user['IDLE']->getTimestamp() > 0) {
                     $isDesktopIdle = true;
                 }
             }
         }
         $status = self::SEND_IMMEDIATELY;
         if ($isMobile) {
             $status = self::SEND_IMMEDIATELY;
         } else {
             if ($isOnline) {
                 $status = self::SEND_DEFERRED;
                 if ($isDesktop) {
                     $status = self::SEND_SKIP;
                     if ($isDesktopIdle) {
                         $status = self::SEND_IMMEDIATELY;
                     } else {
                         $result[$user['ID']]['device'] = array();
                     }
                 } else {
                     $result[$user['ID']]['device'] = array();
                 }
             }
         }
         $result[$user['ID']]['mode'] = $status;
     }
     return $result;
 }
コード例 #8
0
ファイル: im_status.php プロジェクト: rasuldev/torino
 public static function GetList($arParams = array())
 {
     if (!is_array($arParams)) {
         $arParams = array();
     }
     $arID = array();
     if (isset($arParams['ID']) && is_array($arParams['ID']) && !empty($arParams['ID'])) {
         foreach ($arParams['ID'] as $key => $value) {
             $arID[] = intval($value);
         }
     } else {
         if (isset($arParams['ID']) && intval($arParams['ID']) > 0) {
             $arID[] = intval($arParams['ID']);
         }
     }
     global $USER;
     if (!isset($arParams['ID']) && !IsModuleInstalled('intranet') && is_object($USER)) {
         $arID[] = $USER->GetID();
         if (CModule::IncludeModule('socialnetwork') && CSocNetUser::IsFriendsAllowed()) {
             $dbFriends = CSocNetUserRelations::GetList(array(), array("USER_ID" => $USER->GetID(), "RELATION" => SONET_RELATIONS_FRIEND), false, false, array("ID", "FIRST_USER_ID", "SECOND_USER_ID"));
             if ($dbFriends) {
                 while ($arFriends = $dbFriends->GetNext(true, false)) {
                     $friendId = $pref = IntVal($USER->GetID()) == $arFriends["FIRST_USER_ID"] ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"];
                     $arID[] = $friendId;
                 }
             }
         }
     }
     $enable = self::Enable();
     $arUsers = array();
     $query = new \Bitrix\Main\Entity\Query(\Bitrix\Main\UserTable::getEntity());
     if ($enable) {
         $query->registerRuntimeField('', new \Bitrix\Main\Entity\ReferenceField('ref', 'Bitrix\\Im\\StatusTable', array('=this.ID' => 'ref.USER_ID')));
     }
     $query->addSelect('ID');
     if ($enable) {
         $query->addSelect('ref.STATUS', 'STATUS')->addSelect('ref.IDLE', 'IDLE');
     }
     $query->addFilter('>LAST_ACTIVITY_DATE', new \Bitrix\Main\DB\SqlExpression(Bitrix\Main\Application::getConnection()->getSqlHelper()->addSecondsToDateTime('-180')));
     $result = $query->exec();
     while ($arUser = $result->fetch()) {
         if (!empty($arID) && !in_array($arUser["ID"], $arID)) {
             continue;
         }
         $arUsers[$arUser["ID"]] = array('id' => $arUser["ID"], 'status' => $enable && in_array($arUser['STATUS'], self::$AVAILABLE_STATUSES) ? $arUser['STATUS'] : 'online', 'idle' => $enable && is_object($arUser['IDLE']) ? $arUser['IDLE']->getTimestamp() : 0);
     }
     return array('users' => $arUsers);
 }
コード例 #9
0
ファイル: order.php プロジェクト: Satariall/izurit
}
if (array_key_exists('=SOURCE.TRADING_PLATFORM_ID', $arFilterTmp) || in_array('SOURCE_NAME', $arSelectFields)) {
    $runtimeFields['SOURCE'] = array('data_type' => 'Bitrix\\Sale\\TradingPlatform\\OrderTable', 'reference' => array('ref.ORDER_ID' => 'this.ID'), 'join_type' => 'left');
    $arSelectFields["SOURCE_NAME"] = 'SOURCE.TRADING_PLATFORM.NAME';
    if ($searchIndex = array_search('SOURCE_NAME', $arSelectFields)) {
        unset($arSelectFields[$searchIndex]);
    }
}
$getListParams = array('order' => $arFilterOrder, 'filter' => $arFilterTmp, 'group' => $arGroupByTmp, 'select' => $arSelectFields, 'runtime' => $runtimeFields);
if ($usePageNavigation) {
    $getListParams['limit'] = $navyParams['SIZEN'];
    $getListParams['offset'] = $navyParams['SIZEN'] * ($navyParams['PAGEN'] - 1);
}
$totalPages = 0;
if ($usePageNavigation) {
    $countQuery = new \Bitrix\Main\Entity\Query(\Bitrix\Sale\Internals\OrderTable::getEntity());
    $countQuery->addSelect(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(1)'));
    $countQuery->setFilter($getListParams['filter']);
    foreach ($runtimeFields as $key => $field) {
        $countQuery->registerRuntimeField($key, $field);
    }
    $totalCount = $countQuery->setLimit(null)->setOffset(null)->exec()->fetch();
    unset($countQuery);
    $totalCount = (int) $totalCount['CNT'];
    if ($totalCount > 0) {
        $totalPages = ceil($totalCount / $navyParams['SIZEN']);
        if ($navyParams['PAGEN'] > $totalPages) {
            $navyParams['PAGEN'] = $totalPages;
        }
        $getListParams['limit'] = $navyParams['SIZEN'];
        $getListParams['offset'] = $navyParams['SIZEN'] * ($navyParams['PAGEN'] - 1);
コード例 #10
0
ファイル: converter.php プロジェクト: Satariall/izurit
									BEFORE INSERT
									ON B_SALE_BASKET_PROPS
									FOR EACH ROW
									BEGIN
										IF :NEW.ID IS NULL THEN
											SELECT SQ_B_SALE_BASKET_PROPS.NEXTVAL INTO :NEW.ID FROM dual;
										END IF;
									END;');
                    }
                }
            }
            if (empty($error)) {
                $message = Loc::getMessage('SALE_CONVERTER_AJAX_STEP_FINAL');
                $type = 'OK';
                if (\Bitrix\Main\ModuleManager::isModuleInstalled('catalog') && \Bitrix\Main\Config\Option::get('sale', 'basket_discount_converted')) {
                    $countQuery = new \Bitrix\Main\Entity\Query(\Bitrix\Sale\Internals\OrderTable::getEntity());
                    $countQuery->addSelect(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(1)'));
                    $countQuery->setFilter(array('ORDER_DISCOUNT_DATA.ID' => null));
                    $totalCount = $countQuery->setLimit(1)->setOffset(null)->exec()->fetch();
                    unset($countQuery);
                    if ((int) $totalCount['CNT'] > 0) {
                        $adminNotify = false;
                        $adminNotifyIterator = CAdminNotify::GetList(array(), array('MODULE_ID' => 'sale', 'TAG' => 'BASKET_DISCOUNT_CONVERTED'));
                        if (!$adminNotifyIterator) {
                            $adminNotify = $adminNotifyIterator->Fetch();
                        }
                        unset($adminNotifyIterator);
                        if (empty($adminNotify)) {
                            $langMess = array();
                            $langList = array();
                            $languageIterator = \Bitrix\Main\Localization\LanguageTable::getList(array('select' => array('ID'), 'filter' => array('=ACTIVE' => 'Y')));
コード例 #11
0
ファイル: component.php プロジェクト: mrdeadmouse/u136006
    $filterByUser = intval($_GET['USER_ID']);
    $filter["PORTAL_USER_ID"] = $filterByUser;
}
$filterByCode = '';
if (isset($_GET['CODE']) && preg_match('#^[[:alnum:]\\-]+$#D', $_GET['CODE'])) {
    $filterByCode = $_GET['CODE'];
    $filter["CALL_FAILED_CODE"] = $filterByCode;
}
$parametrs = array('order' => array('CALL_START_DATE' => 'DESC'), 'filter' => $filter, 'select' => array('*'));
if (!$_GET['SHOWALL_1']) {
    $parametrs['limit'] = $limit;
    $parametrs['offset'] = ($page - 1) * $limit;
}
$data = VI\StatisticTable::getList($parametrs);
$result = new CDBResult($data);
$countQuery = new Bitrix\Main\Entity\Query(VI\StatisticTable::getEntity());
$countQuery->addSelect(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(1)'));
$countQuery->setFilter($filter);
$totalCount = $countQuery->setLimit(null)->setOffset(null)->exec()->fetch();
$totalCount = intval($totalCount['CNT']);
if (!$_GET['SHOWALL_1']) {
    $totalPage = ceil($totalCount / $limit);
    $result->NavStart($limit);
} else {
    $totalPage = 1;
    $result->NavStart();
}
$result->NavRecordCount = $totalCount;
$result->NavPageCount = $totalPage;
$result->NavPageNomer = $page;
$arResult["NAV_OBJECT"] = $result;
コード例 #12
0
ファイル: im_status.php プロジェクト: Satariall/izurit
 public static function GetList($arParams = array())
 {
     if (!is_array($arParams)) {
         $arParams = array();
     }
     $arID = array();
     if (isset($arParams['ID']) && is_array($arParams['ID']) && !empty($arParams['ID'])) {
         foreach ($arParams['ID'] as $key => $value) {
             $arID[] = intval($value);
         }
     } else {
         if (isset($arParams['ID']) && intval($arParams['ID']) > 0) {
             $arID[] = intval($arParams['ID']);
         }
     }
     $arParams['GET_OFFLINE'] = !empty($arID) && isset($arParams['GET_OFFLINE']) && $arParams['GET_OFFLINE'] == 'Y' ? 'Y' : 'N';
     global $USER;
     $userId = is_object($USER) ? intval($USER->GetID()) : 0;
     $bBusShowAll = !IsModuleInstalled('intranet') && COption::GetOptionInt('im', 'contact_list_show_all_bus');
     if (!$bBusShowAll && !isset($arParams['ID']) && $userId > 0 && !isset($arParams['SKIP_CHECK'])) {
         if (isset(self::$FRIENDS_USERS[$userId])) {
             $arID = self::$FRIENDS_USERS[$userId];
         } else {
             if (CModule::IncludeModule('socialnetwork') && CSocNetUser::IsFriendsAllowed()) {
                 $arID = array($userId);
                 $dbFriends = CSocNetUserRelations::GetList(array(), array("USER_ID" => $userId, "RELATION" => SONET_RELATIONS_FRIEND), false, false, array("ID", "FIRST_USER_ID", "SECOND_USER_ID"));
                 if ($dbFriends) {
                     while ($arFriends = $dbFriends->Fetch()) {
                         $arID[] = $userId == $arFriends["FIRST_USER_ID"] ? $arFriends["SECOND_USER_ID"] : $arFriends["FIRST_USER_ID"];
                     }
                 }
                 self::$FRIENDS_USERS[$userId] = $arID;
             }
         }
     }
     $arUsers = array();
     if (self::$ONLINE_USERS && $arParams['GET_OFFLINE'] == 'N') {
         $arUsers = self::$ONLINE_USERS;
     } else {
         if (!self::$ONLINE_USERS || $arParams['GET_OFFLINE'] == 'Y') {
             $enable = self::Enable();
             $arUsers = array();
             $query = new \Bitrix\Main\Entity\Query(\Bitrix\Main\UserTable::getEntity());
             $query->registerRuntimeField('', new \Bitrix\Main\Entity\ReferenceField('ref', 'Bitrix\\Im\\StatusTable', array('=this.ID' => 'ref.USER_ID')));
             $query->addSelect('ID')->addSelect('ref.COLOR', 'COLOR')->addSelect('PERSONAL_GENDER');
             if ($enable) {
                 $query->addSelect('ref.STATUS', 'STATUS')->addSelect('ref.IDLE', 'IDLE')->addSelect('ref.MOBILE_LAST_DATE', 'MOBILE_LAST_DATE');
             }
             if ($arParams['GET_OFFLINE'] == 'N') {
                 $query->addFilter('>LAST_ACTIVITY_DATE', new \Bitrix\Main\DB\SqlExpression(Bitrix\Main\Application::getConnection()->getSqlHelper()->addSecondsToDateTime('-180')));
             } else {
                 $sago = Bitrix\Main\Application::getConnection()->getSqlHelper()->addSecondsToDateTime('-180');
                 $query->registerRuntimeField('', new \Bitrix\Main\Entity\ExpressionField('IS_ONLINE_CUSTOM', 'CASE WHEN LAST_ACTIVITY_DATE > ' . $sago . ' THEN \'Y\' ELSE \'N\' END'));
                 $query->addSelect('IS_ONLINE_CUSTOM');
                 $query->addFilter('=ID', $arID);
             }
             $result = $query->exec();
             while ($arUser = $result->fetch()) {
                 $color = null;
                 if (isset($arUser['COLOR']) && strlen($arUser['COLOR']) > 0) {
                     $color = IM\Color::getColor($arUser['COLOR']);
                 }
                 if (!$color) {
                     $color = \CIMContactList::GetUserColor($arUser["ID"], $arUser['PERSONAL_GENDER'] == 'M' ? 'M' : 'F');
                 }
                 $arUsers[$arUser["ID"]] = array('id' => $arUser["ID"], 'status' => $enable && in_array($arUser['STATUS'], self::$AVAILABLE_STATUSES) ? $arUser['STATUS'] : 'online', 'color' => $color, 'idle' => $enable && is_object($arUser['IDLE']) ? $arUser['IDLE']->getTimestamp() : 0, 'mobileLastDate' => $enable && is_object($arUser['MOBILE_LAST_DATE']) ? $arUser['MOBILE_LAST_DATE']->getTimestamp() : 0);
                 if ($arParams['GET_OFFLINE'] == 'Y' && $arUser['IS_ONLINE_CUSTOM'] == 'N') {
                     $arUsers[$arUser["ID"]]['status'] = 'offline';
                     $arUsers[$arUser["ID"]]['idle'] = 0;
                     $arUsers[$arUser["ID"]]['mobileLastDate'] = 0;
                 }
             }
             if ($arParams['GET_OFFLINE'] == 'N') {
                 self::$ONLINE_USERS = $arUsers;
             }
         }
     }
     $arResult = array();
     if (empty($arID)) {
         $arResult = $arUsers;
     } else {
         foreach ($arID as $userId) {
             if (isset($arUsers[$userId])) {
                 $arResult[$userId] = $arUsers[$userId];
             }
         }
     }
     return array('users' => $arResult);
 }
コード例 #13
0
 private static function getSelectedTypeIds($type, $siteId)
 {
     static $index;
     // this function is called hell number of times outside, so a little cache is provided
     if ($index == null) {
         $index = array();
     }
     if (!isset($index[$type][$siteId])) {
         $result = array();
         $class = self::CONN_ENTITY_NAME . 'Table';
         $index[$type][$siteId] = array();
         // check if link even used
         if (!$class::checkLinkUsageAny($siteId)) {
             $index[$type][$siteId] = array('');
         } else {
             $types = \CSaleLocation::getTypes();
             $query = new \Bitrix\Main\Entity\Query(self::LOCATION_ENTITY_NAME);
             $query->registerRuntimeField('L', array('data_type' => self::LOCATION_ENTITY_NAME, 'reference' => array('=ref.TYPE_ID' => array('?', $types[$type]), '>=ref.LEFT_MARGIN' => 'this.LEFT_MARGIN', '<=ref.RIGHT_MARGIN' => 'this.RIGHT_MARGIN'), 'join_type' => 'inner'));
             $query->setSelect(array('ID__' => 'L.ID'));
             // get all connection points of interested types (if any)
             $sql = $class::getConnectedLocationsQuery($siteId, array('select' => array('ID')), array('GET_LINKED_THROUGH_GROUPS' => true));
             if ($sql) {
                 $query->setFilter(array('@ID' => new \Bitrix\Main\DB\SqlExpression($sql)));
             }
             $res = $query->exec();
             while ($item = $res->fetch()) {
                 $index[$type][$siteId][] = $item['ID__'];
             }
             $res = Location\LocationTable::getList(array('filter' => array('TYPE_ID' => $types[$type]), 'runtime' => array('CNT' => array('data_type' => 'integer', 'expression' => array('COUNT(*)'))), 'select' => array('CNT')))->fetch();
             if ($res['CNT'] == count($index[$type][$siteId])) {
                 $index[$type][$siteId][] = '';
             }
         }
     }
     return $index[$type][$siteId];
 }
コード例 #14
0
ファイル: vi_user.php プロジェクト: mrdeadmouse/u136006
 public static function QueuedGetList($params)
 {
     $query = new \Bitrix\Main\Entity\Query(Bitrix\Voximplant\QueueTable::getEntity());
     $query->registerRuntimeField('', new \Bitrix\Main\Entity\ExpressionField('IS_ONLINE_CUSTOM', 'CASE WHEN %s > ' . CVoxImplantUser::GetLastActivityDateAgo() . ' THEN \'Y\' ELSE \'N\' END', array('USER.LAST_ACTIVITY_DATE')));
     if (isset($params['select'])) {
         $query->setSelect($params['select']);
     } else {
         $query->addSelect('ID')->addSelect('IS_ONLINE_CUSTOM');
     }
     if (isset($params['filter'])) {
         $query->setFilter($params['filter']);
     }
     if (isset($params['order'])) {
         $query->setOrder($params['order']);
     }
     return $query->exec();
 }
コード例 #15
0
ファイル: task.php プロジェクト: DarneoStudio/bitrix
 protected static function getRuntimeFieldMixinsCheckRights($parameters)
 {
     $result = false;
     $parameters['USER_ID'] = Assert::expectIntegerPositive($parameters['USER_ID'], '$parameters[USER_ID]');
     $rf = $parameters['REF_FIELD'];
     if (!\CTasksTools::IsAdmin($userId) && !\CTasksTools::IsPortalB24Admin($userId)) {
         list($conditions, $expression) = \CTasks::getPermissionFilterConditions($parameters, array('USE_PLACEHOLDERS' => true));
         $conditions = "(case when (" . implode(' OR ', $conditions) . ") then '1' else '0' end)";
         array_unshift($expression, $conditions);
         $query = new \Bitrix\Main\Entity\Query('Bitrix\\Tasks\\Task');
         $query->registerRuntimeField('F', array('data_type' => 'string', 'expression' => $expression));
         $query->setFilter(array('=F' => '1'));
         $query->setSelect(array('TASK_ID' => 'ID'));
         $result = new Entity\ReferenceField($parameters['NAME'], \Bitrix\Main\Entity\Base::getInstanceByQuery($query), array('=this.' . ((string) $rf != '' ? $rf : 'ID') => 'ref.TASK_ID'), array('join_type' => 'inner'));
     }
     return $result;
 }
コード例 #16
0
ファイル: class.php プロジェクト: DarneoStudio/bitrix
 /**
  * Perform reading main data from database, no cache is used
  * @return void
  */
 protected function obtainDataOrders()
 {
     $select = array('ID', 'LID', 'PERSON_TYPE_ID', 'PAYED', 'DATE_PAYED', 'EMP_PAYED_ID', 'CANCELED', 'DATE_CANCELED', 'EMP_CANCELED_ID', 'REASON_CANCELED', 'MARKED', 'DATE_MARKED', 'EMP_MARKED_ID', 'REASON_MARKED', 'STATUS_ID', 'DATE_STATUS', 'PAY_VOUCHER_NUM', 'PAY_VOUCHER_DATE', 'EMP_STATUS_ID', 'PRICE_DELIVERY', 'ALLOW_DELIVERY', 'DATE_ALLOW_DELIVERY', 'EMP_ALLOW_DELIVERY_ID', 'DEDUCTED', 'DATE_DEDUCTED', 'EMP_DEDUCTED_ID', 'REASON_UNDO_DEDUCTED', 'RESERVED', 'PRICE', 'CURRENCY', 'DISCOUNT_VALUE', 'SUM_PAID', 'USER_ID', 'PAY_SYSTEM_ID', 'DELIVERY_ID', 'DATE_INSERT', 'DATE_UPDATE', 'USER_DESCRIPTION', 'ADDITIONAL_INFO', 'COMMENTS', 'TAX_VALUE', 'STAT_GID', 'RECURRING_ID', 'RECOUNT_FLAG', 'DELIVERY_DOC_NUM', 'DELIVERY_DOC_DATE', 'STORE_ID', 'ORDER_TOPIC', 'RESPONSIBLE_ID', 'DATE_PAY_BEFORE', 'DATE_BILL', 'ACCOUNT_NUMBER', 'TRACKING_NUMBER', 'XML_ID');
     $usePageNavigation = true;
     $navyParams = array();
     $navyParams = \CDBResult::GetNavParams();
     if ($navyParams['SHOW_ALL']) {
         $usePageNavigation = false;
     } else {
         $navyParams['PAGEN'] = (int) $navyParams['PAGEN'];
         $navyParams['SIZEN'] = (int) $navyParams['SIZEN'];
     }
     if (isset($this->arParams["ORDERS_PER_PAGE"]) && intval($this->arParams["ORDERS_PER_PAGE"]) > 0) {
         $navyParams['SIZEN'] = $this->arParams["ORDERS_PER_PAGE"];
     }
     if (isset($_REQUEST['show_all']) && $_REQUEST['show_all'] == "Y") {
         $usePageNavigation = false;
     }
     $getListParams = array('order' => array($this->sortBy => $this->sortOrder), 'filter' => $this->filter, 'select' => $select);
     if ($usePageNavigation) {
         $getListParams['limit'] = $navyParams['SIZEN'];
         $getListParams['offset'] = $navyParams['SIZEN'] * ($navyParams['PAGEN'] - 1);
     }
     $totalPages = 0;
     if ($usePageNavigation) {
         $countQuery = new \Bitrix\Main\Entity\Query(\Bitrix\Sale\Internals\OrderTable::getEntity());
         $countQuery->addSelect(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(1)'));
         $countQuery->setFilter($getListParams['filter']);
         $totalCount = $countQuery->setLimit(null)->setOffset(null)->exec()->fetch();
         unset($countQuery);
         $totalCount = (int) $totalCount['CNT'];
         if ($totalCount > 0) {
             $totalPages = ceil($totalCount / $navyParams['SIZEN']);
             if ($navyParams['PAGEN'] > $totalPages) {
                 $navyParams['PAGEN'] = $totalPages;
             }
             $getListParams['limit'] = $navyParams['SIZEN'];
             $getListParams['offset'] = $navyParams['SIZEN'] * ($navyParams['PAGEN'] - 1);
         } else {
             $navyParams['PAGEN'] = 1;
             $getListParams['limit'] = $navyParams['SIZEN'];
             $getListParams['offset'] = 0;
         }
     }
     $this->dbQueryResult['ORDERS'] = new \CDBResult(\Bitrix\Sale\Internals\OrderTable::getList($getListParams));
     if ($usePageNavigation) {
         $this->dbQueryResult['ORDERS']->NavStart($getListParams['limit'], $navyParams['SHOW_ALL'], $navyParams['PAGEN']);
         $this->dbQueryResult['ORDERS']->NavRecordCount = $totalCount;
         $this->dbQueryResult['ORDERS']->NavPageCount = $totalPages;
         $this->dbQueryResult['ORDERS']->NavPageNomer = $navyParams['PAGEN'];
     } else {
         $this->dbQueryResult['ORDERS']->NavStart($this->arParams["ORDERS_PER_PAGE"], false);
     }
     if (empty($this->dbQueryResult['ORDERS'])) {
         return;
     }
     while ($arOrder = $this->dbQueryResult['ORDERS']->GetNext()) {
         $arOBasket = array();
         $dbBasket = CSaleBasket::GetList(array('NAME' => 'asc'), array("ORDER_ID" => $arOrder["ID"]), false, false, array('*'));
         while ($arBasket = $dbBasket->Fetch()) {
             if (CSaleBasketHelper::isSetItem($arBasket)) {
                 continue;
             }
             $arOBasket[$arBasket['ID']] = $arBasket;
         }
         $arOShipment = array();
         $dbShipment = \Bitrix\Sale\Internals\ShipmentTable::getList(array('select' => array('DELIVERY_NAME', 'SYSTEM', 'DELIVERY_ID'), 'filter' => array('ORDER_ID' => $arOrder['ID'])));
         while ($arShipment = $dbShipment->fetch()) {
             if ($arShipment['SYSTEM'] == 'Y') {
                 continue;
             }
             $arOShipment[] = $arShipment;
         }
         $dbPayment = \Bitrix\Sale\Internals\PaymentTable::getList(array('select' => array('PAY_SYSTEM_NAME', 'PAY_SYSTEM_ID'), 'filter' => array('ORDER_ID' => $arOrder['ID'])));
         $arOPayment = array();
         while ($arPayment = $dbPayment->fetch()) {
             $arOPayment[] = $arPayment;
         }
         $this->dbResult['ORDERS'][] = array("ORDER" => $arOrder, "BASKET_ITEMS" => $arOBasket, "SHIPMENT" => $arOShipment, "PAYMENT" => $arOPayment);
     }
 }
コード例 #17
0
ファイル: index.php プロジェクト: akniyev/itprom_dobrohost
//while($ob = $res->GetNextElement()){
//	$arFields = $ob->GetFields();
//	test_dump($arFields["ID"]);
//	$arProps = $ob->GetProperties()["SPECIALOFFER"]["VALUE"];
//	test_dump($arProps);
//}
?>

<?php 
CModule::IncludeModule('highloadblock');
$rsData = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('ID' => '5')));
if (!($arData = $rsData->fetch())) {
    echo 'Инфоблок не найден';
}
$Entity = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($arData);
$Query = new \Bitrix\Main\Entity\Query($Entity);
//Зададим параметры запроса, любой параметр можно опустить
$Query->setSelect(array('*'));
//Выполним запрос
$result = $Query->exec();
//Получаем результат по привычной схеме
$result = new CDBResult($result);
$arLang = array();
?>

<div class="container_brands">
    <div class="slideshow_brands">
        <ul class="slides_brands">
            <?php 
while ($row = $result->Fetch()) {
    $resized_src = GetResizedImage($row["UF_FILE"], 250, 100)["src"];
コード例 #18
0
ファイル: delivery.php プロジェクト: Satariall/izurit
 /**
  * @return \Bitrix\Sale\Result
  * @throws Exception
  * @throws \Bitrix\Main\ArgumentException
  * @internal
  */
 public static function convertPSRelations()
 {
     $result = new \Bitrix\Sale\Result();
     $con = \Bitrix\Main\Application::getConnection();
     if (!$con->isTableExists("b_sale_delivery2paysystem")) {
         return $result;
     }
     $query = new \Bitrix\Main\Entity\Query(DeliveryPaySystemTable::getEntity());
     $query->setSelect(array('DELIVERY_ID'));
     $query->addFilter('LINK_DIRECTION', NULL);
     $query->setLimit(1);
     $res = $query->exec();
     if (!$res->fetch()) {
         return $result;
     }
     $con->queryExecute('UPDATE b_sale_delivery2paysystem SET LINK_DIRECTION=\'' . DeliveryPaySystemTable::LINK_DIRECTION_DELIVERY_PAYSYSTEM . '\'');
     $res = DeliveryPaySystemTable::getList(array());
     while ($rec = $res->fetch()) {
         unset($rec["ID"]);
         $rec["LINK_DIRECTION"] = DeliveryPaySystemTable::LINK_DIRECTION_PAYSYSTEM_DELIVERY;
         DeliveryPaySystemTable::Add($rec);
     }
     return $result;
 }
コード例 #19
0
ファイル: component.php プロジェクト: bereza-evgenij/1bit
function getNumberCabinet($idCabinet, $relativePath)
{
    $numberCabinet = '';
    $obCache = new CPHPCache();
    $cache_id = SITE_ID . '|tickets|numbersCabinets|' . $idCabinet;
    $cache_path = '/' . SITE_ID . $relativePath;
    if ($obCache->StartDataCache(36000, $cache_id, $cache_path)) {
        $rsCabinetData = \Bitrix\Highloadblock\HighloadBlockTable::getList(array('filter' => array('NAME' => 'Cabinet')));
        if ($arCabinetData = $rsCabinetData->fetch()) {
            $EntityCabinet = \Bitrix\Highloadblock\HighloadBlockTable::compileEntity($arCabinetData);
            $QueryCabinet = new \Bitrix\Main\Entity\Query($EntityCabinet);
            $QueryCabinet->setSelect(array('UF_NUMBER'));
            $QueryCabinet->setFilter(array('ID' => $idCabinet));
            $resultCabinet = $QueryCabinet->exec();
            $resultCabinet = new CDBResult($resultCabinet);
            $rowCabinet = $resultCabinet->Fetch();
            $numberCabinet = $rowCabinet['UF_NUMBER'];
        }
        $obCache->EndDataCache(array("numberCabinet" => $numberCabinet));
    } else {
        $arVars = $obCache->GetVars();
        $numberCabinet = $arVars["numberCabinet"];
    }
    return $numberCabinet;
}
コード例 #20
0
     $arFilter["DATE_FROM"] = ConvertTimeStamp(AddToTimeStamp(array("DD" => "-" . $dateBack), mktime(0, 0, 0, date("n"), date("j"), date("Y"))), "SHORT");
 }
 CAdminMessage::ShowNote($viewedMessage);
 CAdminMessage::ShowMessage($viewedError);
 $newFilter = array();
 foreach ($arFilter as $key => $value) {
     if ($key == "DATE_FROM") {
         $newFilter['>=DATE_VISIT'] = $value;
     } elseif ($key == "DATE_TO") {
         $newFilter['<DATE_VISIT'] = $value;
     } else {
         $newFilter[$key] = $value;
     }
 }
 if (\Bitrix\Main\Loader::includeModule("catalog")) {
     $viewedQuery = new \Bitrix\Main\Entity\Query(\Bitrix\Catalog\CatalogViewedProductTable::getEntity());
     $viewedQuery->setSelect(array("PRODUCT_ID", "DATE_VISIT", "SITE_ID", "VIEW_COUNT", "NAME" => "ELEMENT.NAME", "PRICE" => "PRODUCT.PRICE", "QUANTITY" => "PRODUCT.QUANTITY", "CURRENCY" => "PRODUCT.CURRENCY", "RATE" => "PRODUCT.CURRENT_CURRENCY_RATE", "CURRENCY_RATE" => "PRODUCT.CURRENT_CURRENCY_RATE_CNT"))->setfilter($newFilter);
     $viewedIterator = $viewedQuery->exec();
 } else {
     $viewedIterator = new CDBResult();
 }
 $dbViewsList = new CAdminResult($viewedIterator, $sTableID_tab5);
 $dbViewsList->NavStart();
 $lAdmin_tab5->NavText($dbViewsList->GetNavPrint(GetMessage('BUYER_PRODUCT_LIST')));
 $viewedHeader = array(array("id" => "DATE_VISIT", "content" => GetMessage("BUYER_V_DATE_INSERT"), "sort" => "DATE_VISIT", "default" => true), array("id" => "NAME", "content" => GetMessage("BUYER_V_NAME"), "sort" => "NAME", "default" => true), array("id" => "PRICE", "content" => GetMessage("BUYER_V_PRICE"), "sort" => "PRICE", "default" => true), array("id" => "QUANTITY", "content" => GetMessage("BUYER_V_QUANTITY"), "sort" => "", "default" => true));
 if (count($arSites) > 1) {
     $viewedHeader[] = array("id" => "SITE_ID", "content" => GetMessage("BUYER_V_LID"), "sort" => "SITE_ID", "default" => true);
 }
 $lAdmin_tab5->AddHeaders($viewedHeader);
 $arProductId = array();
 $arCatalogProductId = array();
コード例 #21
-1
ファイル: event.php プロジェクト: mrdeadmouse/u136006
 function GetListEx($arOrder = array(), $arFilter = array(), $arParams = array())
 {
     global $DB;
     $arSearch = $arSearch1 = $arSearch2 = array();
     $arSelect = array();
     $arSqlSearch = array();
     $strSqlSearch = "";
     $arSqlOrder = array();
     foreach ($arFilter as $key => $val) {
         if (strlen($val) <= 0) {
             continue;
         }
         $val = $DB->ForSql($val);
         $key_res = CEventType::GetFilterOperation($key);
         $key = strToUpper($key_res["FIELD"]);
         $strNegative = $key_res["NEGATIVE"];
         $strOperation = $key_res["OPERATION"];
         $strNOperation = $key_res["NOPERATION"];
         $arOperationReplace = array('LIKE' => '=%', 'QUERY' => '', 'IN' => '');
         switch ($key) {
             case "EVENT_NAME":
             case "TYPE_ID":
                 if ($strOperation == "LIKE") {
                     $val = "%" . $val . "%";
                 }
                 $arSearch[] = array($strNOperation . 'EVENT_NAME' => $val);
                 break;
             case "DESCRIPTION":
             case "NAME":
                 if ($strOperation == "LIKE") {
                     $val = "%" . $val . "%";
                 }
                 $arSearch1[] = array($strNOperation . 'EVENT_MESSAGE_TYPE.' . $key => $val);
                 $arSearch2[] = array($strNOperation . $key => $val);
                 break;
             case "LID":
                 $arSearch1[] = array($strNOperation . 'EVENT_MESSAGE_TYPE.' . $key => $val);
                 $arSearch2[] = array($strNOperation . $key => $val);
                 break;
             case "ID":
                 $val = intVal($val);
                 $arSearch1[] = array($strNOperation . 'EVENT_MESSAGE_TYPE.' . $key => $val);
                 $arSearch2[] = array($strNOperation . $key => $val);
                 break;
             case "MESSAGE_ID":
                 $val = intVal($val);
                 $arSearch1[] = array($strNOperation . "ID" => $val);
                 $arSearch2[] = array($strNOperation . 'EVENT_MESSAGE.ID' => $val);
                 break;
         }
     }
     if (is_array($arOrder)) {
         foreach ($arOrder as $by => $order) {
             $by = strtoupper($by);
             $order = strtoupper($order);
             $order = $order != "DESC" ? "ASC" : "DESC";
             if ($by == "EVENT_NAME" || $by == "ID") {
                 $arSqlOrder["EVENT_NAME"] = "EVENT_NAME1 " . $order;
             }
         }
     }
     if (empty($arSqlOrder)) {
         $arSqlOrder["EVENT_NAME"] = "EVENT_NAME1 ASC";
     }
     $strSqlOrder = " ORDER BY " . implode(", ", $arSqlOrder);
     $arSearch['!EVENT_NAME'] = null;
     $arQuerySelect = array('ID1' => 'EVENT_NAME', 'EVENT_NAME1' => 'EVENT_NAME');
     $query1 = new \Bitrix\Main\Entity\Query(Mail\Internal\EventMessageTable::getEntity());
     $query1->setSelect($arQuerySelect);
     $query1->setFilter(array_merge($arSearch, $arSearch1));
     $query1->registerRuntimeField('EVENT_MESSAGE_TYPE', array('data_type' => 'Bitrix\\Main\\Mail\\Internal\\EventType', 'reference' => array('=this.EVENT_NAME' => 'ref.EVENT_NAME')));
     $query2 = new \Bitrix\Main\Entity\Query(Mail\Internal\EventTypeTable::getEntity());
     $query2->setSelect($arQuerySelect);
     $query2->setFilter(array_merge($arSearch, $arSearch2));
     $query2->registerRuntimeField('EVENT_MESSAGE', array('data_type' => 'Bitrix\\Main\\Mail\\Internal\\EventMessage', 'reference' => array('=this.EVENT_NAME' => 'ref.EVENT_NAME')));
     $connection = \Bitrix\Main\Application::getConnection();
     $strSql = $query1->getQuery() . " UNION " . $query2->getQuery() . " " . $strSqlOrder;
     $db_res = $connection->query($strSql);
     $db_res->addFetchDataModifier(array('CEventType', 'GetListExFetchDataModifier'));
     $db_res = new _CEventTypeResult($db_res, $arParams);
     return $db_res;
 }