GetGroupRight("sale") < "W") $APPLICATION->AuthForm(Loc::getMessage('SALE_MODULE_ACCES_DENIED')); $userIsAdmin = $APPLICATION->GetGroupRight("sale") >= "W"; ##################################### #### Data prepare ##################################### try { $itemId = intval($_REQUEST[Helper::URL_PARAM_PARENT_ID]) ? intval($_REQUEST[Helper::URL_PARAM_PARENT_ID]) : false; $nameToDisplay = Helper::getNameToDisplay($itemId); // get entity fields for columns & filter $columns = Helper::getColumns('list'); $arFilterFields = array(); $arFilterTitles = array(); foreach($columns as $code => $fld) { $arFilterFields[] = 'find_'.$code; $arFilterTitles[] = $fld['title']; } $sTableID = "tbl_location_node_list"; // spike for filter if($_REQUEST['del_filter'] != 'Y') { if(isset($_SESSION['SESS_ADMIN'][$sTableID][Helper::URL_PARAM_PARENT_ID]) && isset($_REQUEST[Helper::URL_PARAM_PARENT_ID]) && ($_SESSION['SESS_ADMIN'][$sTableID][Helper::URL_PARAM_PARENT_ID] != $_REQUEST[Helper::URL_PARAM_PARENT_ID])) $_SESSION['SESS_ADMIN'][$sTableID][Helper::URL_PARAM_PARENT_ID] = $_REQUEST[Helper::URL_PARAM_PARENT_ID]; } $oFilter = new CAdminFilter( $sTableID."_filter", $arFilterTitles ); $oSort = new CAdminSorting($sTableID, "SORT", "asc"); $lAdmin = new CAdminList($sTableID, $oSort); $lAdmin->InitFilter($arFilterFields); // order, select and filter for the list $listParams = Helper::proxyListRequest('list'); ##################################### #### ACTIONS ##################################### global $DB; // group UPDATE if($lAdmin->EditAction() && $userIsAdmin) { foreach($FIELDS as $id => $arFields) { $DB->StartTransaction(); if(!$lAdmin->IsUpdated($id)) // if there were no data change on this row - do nothing with it continue; try { $res = Helper::update($id, $arFields, true); if(!empty($res['errors'])) { foreach($res['errors'] as &$error) $error = '  '.$error; unset($error); throw new Main\SystemException(implode(',
', $res['errors'])); } } catch(Main\SystemException $e) { // todo: do smth $lAdmin->AddUpdateError(Loc::getMessage('SALE_LOCATION_L_ITEM_SAVE_ERROR', array('#ITEM#' => $id)).":
".$e->getMessage().'
', $id); $DB->Rollback(); } $DB->Commit(); } Location\LocationTable::resetLegacyPath(); } // group DELETE if(($ids = $lAdmin->GroupAction()) && $userIsAdmin) { // all by filter or certain ids if($_REQUEST['action_target'] == 'selected') // get all ids if they were not specified (user choice was "for all") { $ids = Helper::getIdsByFilter($listParams['filter']); } @set_time_limit(0); foreach($ids as $id) { if(!($id = intval($id))) { continue; } if($_REQUEST['action'] == 'delete') { $DB->StartTransaction(); try { $res = Helper::delete($id, true); if(!$res['success']) { throw new Main\SystemException(Loc::getMessage('SALE_LOCATION_L_ITEM').' '.$id.' : '.implode('
', $res['errors'])); } $DB->Commit(); } catch(Main\SystemException $e) { $lAdmin->AddGroupError(Loc::getMessage('SALE_LOCATION_L_ITEM_DELETE_ERROR').":

".$e->getMessage(), $id); $DB->Rollback(); } } } Location\LocationTable::resetLegacyPath(); } $adminResult = Helper::getList($listParams, $sTableID); $lAdmin->NavText($adminResult->GetNavPrint(Loc::getMessage('SALE_LOCATION_L_PAGES'), true)); // do not relocate the call relative to DisplayList(), or you`ll catch a strange nav bar disapper bug } catch(Main\SystemException $e) { $code = $e->getCode(); $fatal = $e->getMessage().(!empty($code) ? ' ('.$code.')' : ''); } ##################################### #### PAGE INTERFACE GENERATION ##################################### if(empty($fatal)) { $headers = array(); foreach(Helper::getListGridColumns() as $code => $fld) $headers[] = array("id" => $code, "content" => $columns[$code]['title'], "default" => $fld['DEFAULT'], "sort" => $code); $lAdmin->AddHeaders($headers); while($elem = $adminResult->NavNext(true, "f_")) { // CAdminList will escape values by itself /* foreach($columns as $code => $fld) { if(isset($elem[$code])) Helper::makeSafeDisplay($elem[$code], $code); } */ // urls $editUrl = Helper::getEditUrl($elem['ID']); $copyUrl = Helper::getEditUrl(false, array('copy_id' => $elem['ID'])); $listUrl = Helper::getListUrl($elem['ID'], array()); $row =& $lAdmin->AddRow($f_ID, $elem, $listUrl, Loc::getMessage('SALE_LOCATION_L_VIEW_CHILDREN')); foreach($columns as $code => $fld) { if($code == 'ID') $row->AddViewField($code, ''.$f_ID.''); elseif($code == 'TYPE_ID') $row->AddSelectField($code, Helper::getTypeList()); else $row->AddInputField($code); } $arActions = array(); $arActions[] = array("ICON" => "edit", "TEXT" => Loc::getMessage('SALE_LOCATION_L_EDIT_ITEM'), "ACTION" => $lAdmin->ActionRedirect($editUrl), "DEFAULT" => true); if($userIsAdmin) { $arActions[] = array("ICON"=>"copy", "TEXT"=>Loc::getMessage('SALE_LOCATION_L_COPY_ITEM'), "ACTION"=>$lAdmin->ActionRedirect($copyUrl)); $arActions[] = array("SEPARATOR"=>true); $arActions[] = array("ICON"=>"delete", "TEXT"=>Loc::getMessage('SALE_LOCATION_L_DELETE_ITEM'), "ACTION"=>"if(confirm('".CUtil::JSEscape(Loc::getMessage('SALE_LOCATION_L_CONFIRM_DELETE_ITEM'))."')) ".$lAdmin->ActionDoGroup($f_ID, "delete")); } $row->AddActions($arActions); } $lAdmin->AddGroupActionTable(Array( "delete" => true )); $aContext = array( array( "TEXT" => Loc::getMessage('SALE_LOCATION_L_ADD_ITEM'), "LINK" => Helper::getEditUrl(false, array('parent_id' => $itemId)), "TITLE" => Loc::getMessage('SALE_LOCATION_L_ADD_ITEM'), "ICON" => "btn_new" ), ); $lAdmin->AddAdminContextMenu($aContext); $lAdmin->CheckListMode(); } // empty($fatal) ?> SetTitle(Loc::getMessage('SALE_LOCATION_L_EDIT_PAGE_TITLE').($nameToDisplay ? ': '.$nameToDisplay : ''))?>
$fatal, 'type' => 'ERROR'))?>