/** * Экспортирует данные в файл * @param int $id * @param string $type * @param null|array $params * @return null|BFile */ public function exportAction(int $id, string $type, ?array $params = []): ?BFile { try { $pFilename = \TEMP_DIR . '/' . 'item.xls'; \file_put_contents($pFilename, $data); $arFile = \CFile::MakeFileArray($pFilename, false, true); $file = new BFile($arFile); } catch (\Throwable $th) { $this->addError(new Error($th->getMessage(), $th->getCode())); } return $file; } |
BX.ajax.runComponentAction('company:sale.basket.detail', 'export', { mode: 'ajax', data: {id, type}, method: 'POST', }) ?.then(response => { if (response.status === 'success' && response.data?.url) { window.location.href = response.data.url; } }) .catch(response => {...}) |