if ($saleModulePermissions >= 'W') { ?> <tr> <td><strong><?php echo GetMessage("COMPANY_LOCATION_ID"); ?> </strong></td> <td> <?php $APPLICATION->IncludeComponent("bitrix:sale.location.selector." . \Bitrix\Sale\Location\Admin\LocationHelper::getWidgetAppearance(), "", array("ID" => "", "CODE" => $fields['LOCATION_ID'], "INPUT_NAME" => "LOCATION_ID", "PROVIDE_LINK_BY" => "code", "SHOW_ADMIN_CONTROLS" => 'Y', "SELECT_WHEN_SINGLE" => 'N', "FILTER_BY_SITE" => 'Y', "FILTER_SITE_ID" => Application::getInstance()->getContext()->getSite(), "SHOW_DEFAULT_LOCATIONS" => 'N', "SEARCH_BY_PRIMARY" => 'Y'), false); ?> </td> </tr> <?php } else { $res = \Bitrix\Sale\Location\LocationTable::getPathToNodeByCode($fields['LOCATION_ID'], array('select' => array('CHAIN' => 'NAME.NAME'), 'filter' => array('NAME.LANGUAGE_ID' => $lang))); $path = array(); while ($item = $res->fetch()) { $path[] = $item['CHAIN']; } $path = implode(', ', array_reverse($path)); ?> <tr> <td><?php echo GetMessage("COMPANY_LOCATION"); ?> </td> <td><?php echo $path; ?> </td>
public static function getLocationPathDisplay($code) { if(!strlen($code)) return ''; $parameters = array( 'select' => array('LNAME' => 'NAME.NAME'), 'filter' => array('NAME.LANGUAGE_ID' => LANGUAGE_ID) ); try { $res = Location\LocationTable::getPathToNodeByCode($code, $parameters); } catch(\Exception $e) { return $code; } $path = array(); while($item = $res->fetch()) $path[] = $item['LNAME']; return implode(', ', array_reverse($path)); }
protected static function getViewHtmlSingle(array $input, $value) { if ((string) $value == '') { return ''; } try { $result = \Bitrix\Sale\Location\LocationTable::getPathToNodeByCode($value, array('select' => array('CHAIN' => 'NAME.NAME'), 'filter' => array('NAME.LANGUAGE_ID' => LANGUAGE_ID))); $path = array(); while ($row = $result->fetch()) { $path[] = $row['CHAIN']; } return htmlspecialcharsbx(implode(', ', $path)); } catch (\Bitrix\Main\SystemException $e) { return ''; } }
foreach ($fields as $field) { $select[] = $field['FIELD_NAME']; } $params = array('select' => $select, 'filter' => $filter, 'order' => array($by => $order)); $company = CompanyTable::getList($params); $dbResultList = new CAdminResult($company, $sTableID); $dbResultList->NavStart(); $lAdmin->NavText($dbResultList->GetNavPrint(Loc::getMessage("SALE_COMPANY"))); $headers = array(array("id" => "ID", "content" => "ID", "sort" => "ID", "default" => true), array("id" => "ACTIVE", "content" => Loc::getMessage("SALE_COMPANY_ACTIVE"), "sort" => "ACTIVE", "default" => true), array("id" => "NAME", "content" => Loc::getMessage("SALE_COMPANY_NAME"), "sort" => "NAME", "default" => true), array("id" => "LOCATION_ID", "content" => Loc::getMessage("SALE_COMPANY_LOCATION_ID"), "sort" => "LOCATION_ID", "default" => true), array("id" => "CODE", "content" => Loc::getMessage("SALE_COMPANY_CODE"), "sort" => "CODE", "default" => true)); $USER_FIELD_MANAGER->AdminListAddHeaders(CompanyTable::getUfId(), $headers); $lAdmin->AddHeaders($headers); $allSelectedFields = array("ID" => false, "ACTIVE" => false, "NAME" => false, "LOCATION_ID" => false, "CODE" => false); $selectedFields = $lAdmin->GetVisibleHeaderColumns(); $allSelectedFields = array_merge($allSelectedFields, array_fill_keys($selectedFields, true)); while ($company = $dbResultList->NavNext(true, "f_")) { $res = \Bitrix\Sale\Location\LocationTable::getPathToNodeByCode($company['LOCATION_ID'], array('select' => array('CHAIN' => 'NAME.NAME'), 'filter' => array('NAME.LANGUAGE_ID' => Application::getInstance()->getContext()->getLanguage()))); $path = array(); while ($item = $res->fetch()) { $path[] = $item['CHAIN']; } $company['LOCATION_ID'] = implode(', ', array_reverse($path)); $row =& $lAdmin->AddRow($f_ID, $company, "sale_company_edit.php?ID=" . $f_ID . "&lang=" . $lang, Loc::getMessage("SALE_COMPANY_EDIT_DESCR")); $row->AddField("ID", "<a href=\"sale_company_edit.php?ID=" . $f_ID . "&lang=" . $lang . GetFilterParams("filter_") . "\">" . $f_ID . "</a>"); $row->AddCheckField("ACTIVE"); $row->AddInputField("NAME"); $row->AddField("LOCATION_ID", $company['LOCATION_ID']); $row->AddInputField("CODE"); $USER_FIELD_MANAGER->AddUserFields(CompanyTable::getUfId(), $company, $row); $arActions = array(array("ICON" => "edit", "TEXT" => Loc::getMessage("SALE_COMPANY_EDIT"), "TITLE" => Loc::getMessage("SALE_COMPANY_EDIT_DESCR"), "ACTION" => $lAdmin->ActionRedirect("sale_company_edit.php?ID=" . $f_ID . "&lang=" . $lang), "DEFAULT" => true)); if ($saleModulePermissions >= "W") { $arActions[] = array("SEPARATOR" => true);
protected function obtainDataLocation() { $parameters = $this->getLocationListParameters(); $this->dbResult['PATH'] = array(); $this->dbResult['LOCATION'] = array(); $toBeFound = false; $res = false; try { if($this->arParams['ID']) { $toBeFound = true; $res = Location\LocationTable::getPathToNode($this->arParams['ID'], $parameters); } elseif(strlen($this->arParams['CODE'])) { $toBeFound = true; $res = Location\LocationTable::getPathToNodeByCode($this->arParams['CODE'], $parameters); } if($res) { $res->addReplacedAliases(array('LNAME' => 'NAME')); while($item = $res->Fetch()) $this->dbResult['PATH'][intval($item['ID'])] = $this->forceToType($item); end($this->dbResult['PATH']); $this->dbResult['LOCATION'] = current($this->dbResult['PATH']); } } catch(Main\SystemException $e) { } if(empty($this->dbResult['PATH']) && $toBeFound) $this->errors['NONFATAL'][] = Loc::getMessage('SALE_SLS_SELECTED_NODE_NOT_FOUND'); }