示例#1
0
Loc::loadMessages(__FILE__);

if($APPLICATION->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(!$returnUrl)
		$returnUrl = Helper::getListUrl($parentId); // default return page for "cancel" action

	#####################################
	#### READ FORM DATA
	#####################################

	$readAsId = $id ? $id : $copyId;

	if($formSubmitted && $actionFailure) // if form were submitted, but form action (add or update) failed
	{
		// load from request
		$formData = $_REQUEST['element'];

		if($readAsId)
			$nameToDisplay = Helper::getNameToDisplay($readAsId);

		// cleaning up empty external data
		if(is_array($formData['EXTERNAL']) && !empty($formData['EXTERNAL']))
		{
			foreach($formData['EXTERNAL'] as $eId => $external)
			{
				if(!strlen($external['XML_ID']))
					unset($formData['EXTERNAL'][$eId]);
			}
		}
	}
	else
	{
		if($readAsId)
		{