<?php define('NO_KEEP_STATISTIC', 'Y'); define('NO_AGENT_STATISTIC', 'Y'); define('NO_AGENT_CHECK', true); define('PUBLIC_AJAX_MODE', true); define('DisableEventsCheck', true); use Bitrix\Main\Web\Uri; use Bitrix\Main\Loader; use Bitrix\Disk; use Bitrix\Disk\Ui; $siteID = isset($_REQUEST['site']) ? substr(preg_replace('/[^a-z0-9_]/i', '', $_REQUEST['site']), 0, 2) : ''; if ($siteID !== '') { define('SITE_ID', $siteID); } require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/prolog_before.php'); if (!Loader::includeModule('crm')) { die(); } $GLOBALS['APPLICATION']->ShowAjaxHead(); $mode = 'deal'; $driver = Disk\Driver::getInstance(); $urlManager = $driver->getUrlManager(); $rightsManager = $driver->getRightsManager(); $options = json_decode($_REQUEST['PLACEMENT_OPTIONS'], true); $dealId = $options['ID']; if ($dealId) { $entityTypeId = \CCrmOwnerType::Deal; $factory = \Bitrix\Crm\Service\Container::getInstance()->getFactory($entityTypeId); $item = $factory->getItem($dealId); $data = $item->getData(); if ($data['UF_CRM_1661847646---1111----']) { $factory = \Bitrix\Crm\Service\Container::getInstance()->getFactory($entityTypeId); $item = $factory->getItem($data['UF_CRM_1661847646']); if ($item) { $data = $item->getData(); } } $storage = $driver->getStorageByCommonId('shared_files_s1'); try { $conf = [ 'NAME' => 'crm', 'STORAGE_ID' => $storage->getId(), ]; $diskFolder = Disk\Folder::load($conf); if ($diskFolder) { $conf = [ 'NAME' => '[сделка'.$data['ID'].']', 'STORAGE_ID' => $diskFolder->getStorageId(), ]; $dealFolder = Disk\Folder::load($conf); if ($dealFolder) { $pathBase = $urlManager->getPathFolderList($dealFolder->getRealObject()); $path = $urlManager->encodeUrn($pathBase); } else { $addResult = $diskFolder->addSubFolder([ 'NAME' => '[сделка'.$data['ID'].']', 'CREATED_BY' => $USER->GetID() ]); if ($addResult) { $dealFolder = Disk\Folder::load($conf); $pathBase = $urlManager->getPathFolderList($addResult->getRealObject()); $path = $urlManager->encodeUrn($pathBase); $dfid = $dealFolder->getStorageId(); } else { throw new \Exception('problem add folder >> ' . implode(', ', $diskFolder->getErrors())); } } $requestUri = new Uri($path); $requestUri->addParams([ 'site' => SITE_ID, 'sessid' => bitrix_sessid(), 'IFRAME' => 'Y', 'mode' => $mode ]); ?> <iframe src="<?= $requestUri->getUri() ?>" frameborder="0" class="app-frame" style="border: 1px dashed #dbe4e8; min-height:800px; height: 100%; width: 100%; padding: 0px;" allow="geolocation *; microphone *; camera *" ></iframe> <style> body { margin: 0; } </style> </body> </html> <? } } catch (\Exception $e) { die('Exception: ' . $e->getMessage()); } } require_once($_SERVER['DOCUMENT_ROOT'] . '/bitrix/modules/main/include/epilog_after.php'); die();
Обсуждают сегодня