<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="CSEasyWMDefinitionSelection.aspx.vb" Inherits="CSEasyWM.CSEasyWMDefinitionSelection" %>
<%@ register tagprefix="ex" namespace="Exact.Web.UI.Controls" assembly="Exact.Web.UI.Controls" %>
<html>
<head>
	<meta name="save" content="history" />
	<link rel="stylesheet" type="text/css" href="Exact.css" />
<style type="text/css">
#SelectionCriteria, #SelectionValues
{
    font-family: Consolas, Courier New, Courier, monospace !important;
}
</style>
    <script language="javascript" type="text/javascript" src="jquery.js"></script>
    <script language="javascript" type="text/javascript" src="CSEasyWMDefinitionPopup.js"></script>
    <script language="javascript" type="text/javascript">
	$(document).ready(function () {
		$('#Topic').change(function () {
			ShowHideSelectionValues($('#Topic').val());
		});

		$('#ColumnID').change(function () {
			var columnid = $('#ColumnID').val();
			SysSet('ColumnName', columnid);
		});
	});

	function ShowHideSelectionValues(sTopic) {
		if (sTopic == 'E' || sTopic == 'F') {
			$('#cfSelectionCriteria').hide();
			$('#cfTopicHelp').hide();
			$('#cfSelectionValues').show();
			$('#cfLinkToSelectionID').hide();
			$('#btnShowSelection').hide();
			$('#SelectionValues').focus();
		} else if (sTopic == 'B' || sTopic == 'C' || sTopic == 'D' || sTopic == 'N') {
			$('#cfSelectionCriteria').hide();
			$('#cfTopicHelp').hide();
			$('#cfSelectionValues').hide();
			$('#cfLinkToSelectionID').hide();
			$('#btnShowSelection').hide();
			$('#ColumnName').focus();
		} else if (sTopic == '') {
			$('#cfSelectionCriteria').hide();
			$('#cfTopicHelp').hide();
			$('#cfSelectionValues').hide();
			$('#cfLinkToSelectionID').hide();
			$('#btnShowSelection').hide();
		} else {
			$('#cfSelectionCriteria').show();
			$('#cfTopicHelp').show();
			$('#cfSelectionValues').hide();
			$('#btnShowSelection').show();
			$('#SelectionCriteria').focus();
		}
}


	var OldCaption = '';
	function SetLabel(label, termid) {
		if (OldCaption == SysGet('Caption')) {
			SysSet('Caption', label);
			SysSet('CaptionTermID', termid);
		}
		OldCaption = label;
	}


function ShowSelectionBrowser() {
	var strparam;
	var where = '';
	var browser = '';
	var fieldBrowserResultCols = '';

	var topicvalue = $('#Topic').val();

	switch (topicvalue) {
		case '0': // Topic Project
			{
				browser = "ProjectAll";
				fieldBrowserResultCols = "PrProject.ProjectNr, PrProject.Description";
				where = SysURLEncode(SysGet('EncryptedBrowserWhere'));
				strparam = "Name=" + browser;
				strparam = strparam + "&ResultCols=" + fieldBrowserResultCols;
				strparam = strparam + "&Where=" + where;
				SysBrowseData(null, strparam, null, false, false, null, null);
				break;
			}
		case '1': // Topic Parent Project
			{
				browser = "ProjectAll";
				fieldBrowserResultCols = "PrProject.ProjectNr, PrProject.Description";
				where = SysURLEncode(SysGet('EncryptedBrowserWhere'));
				strparam = "Name=" + browser;
				strparam = strparam + "&ResultCols=" + fieldBrowserResultCols;
				strparam = strparam + "&Where=" + where;
				SysBrowseData(null, strparam, null, false, false, null, null);
				break;
			}
		case '2': // Topic Debitor
			{
				browser = "CustomerWWN";
				fieldBrowserResultCols = "c.cmp_wwn, c.cmp_name";
				where = SysURLEncode(SysGet('EncryptedBrowserWhere'));
				strparam = "Name=" + browser;
				strparam = strparam + "&ResultCols=" + fieldBrowserResultCols;
				strparam = strparam + "&Where=" + where;
				SysBrowseData(null, strparam, null, false, false, null, null);
				break;
			}
		case '3': // Topic Creditor
			{
				browser = "CustomerWWN";
				fieldBrowserResultCols = "c.cmp_wwn, c.cmp_name";
				where = SysURLEncode(SysGet('EncryptedBrowserWhere'));
				strparam = "Name=" + browser;
				strparam = strparam + "&ResultCols=" + fieldBrowserResultCols;
				strparam = strparam + "&Where=" + where;
				SysBrowseData(null, strparam, null, false, false, null, null);
				break;
			}
		case '4': // Topic Account
			{
				browser = "CustomerWWN";
				fieldBrowserResultCols = "c.cmp_wwn, c.cmp_name";
				where = SysURLEncode(SysGet('EncryptedBrowserWhere'));
				strparam = "Name=" + browser;
				strparam = strparam + "&ResultCols=" + fieldBrowserResultCols;
				strparam = strparam + "&Where=" + where;
				SysBrowseData(null, strparam, null, false, false, null, null);
				break;
			}
		case '5': // Topic Contactperson
			{
				browser = "RequestAllContacts";
				fieldBrowserResultCols = "cicntp.cnt_id";
				where = SysURLEncode(SysGet('EncryptedBrowserWhere'));
				strparam = "Name=" + browser;
				strparam = strparam + "&ResultCols=" + fieldBrowserResultCols;
				strparam = strparam + "&Where=" + where;
				SysBrowseData(null, strparam, null, false, false, null, null);
				break;
			}
		case '7': // Topic Item
			{
				browser = "Items";
				fieldBrowserResultCols = "Items.ItemCode, Items.Description";
				where = SysURLEncode(SysGet('EncryptedBrowserWhere'));
				strparam = "Name=" + browser;
				strparam = strparam + "&ResultCols=" + fieldBrowserResultCols;
				strparam = strparam + "&Where=" + where;
				SysBrowseData(null, strparam, null, false, false, null, null);
				break;
			}
		case '8': // Topic Employee
			{
				browser = "Employee";
				fieldBrowserResultCols = "humres.ID, humres.fullname";
				where = SysURLEncode(SysGet('EncryptedBrowserWhere'));
				strparam = "Name=" + browser;
				strparam = strparam + "&ResultCols=" + fieldBrowserResultCols;
				strparam = strparam + "&Where=" + where;
				SysBrowseData(null, strparam, null, false, false, null, null);
				break;
			}
		case '9': // Topic Opportunities
			{
				browser = "Opportunities";
				fieldBrowserResultCols = "o.Code, o.Description";
				where = SysURLEncode(SysGet('EncryptedBrowserWhere'));
				strparam = "Name=" + browser;
				strparam = strparam + "&ResultCols=" + fieldBrowserResultCols;
				strparam = strparam + "&Where=" + where;
				SysBrowseData(null, strparam, null, false, false, null, null);
				break;
			}
		case 'A': // Topic Request
			{
				browser = "Requests";
				fieldBrowserResultCols = "absences.ID";
				where = SysURLEncode(SysGet('EncryptedBrowserWhere'));
				strparam = "Name=" + browser;
				strparam = strparam + "&ResultCols=" + fieldBrowserResultCols;
				strparam = strparam + "&Where=" + where;
				SysBrowseData(null, strparam, null, false, false, null, null);
				break;
			}

		default:
			break;
	}
	
}

function ShowSelectionClicked() {
	var where = "";
}
</script>
</head>
<body>

<ep:form id="frm" runat="server">

<ex:InputField runat="server" Hidden="True" ID="DoClose" ValidationAs="Int" ValidationDefault="0" CreateClientControl="True" />

<ex:CardControl runat="server" ID="Card" Action="Show">
	<ex:Header runat="server" ID="hdr">
	</ex:Header>

	<ex:headerproperties runat="server" id="hdrProps" headerpropertiesstyle="CreatedModified" datasource="bc" datafieldcreated="Created" datafieldcreator="Creator" datafieldcreatorname="CreatorFullName" datafieldmodified="Modified" datafieldmodifier="Modifier" datafieldmodifiername="ModifierFullName" />

	<ex:ButtonBar runat="server" ID="Buttons">
		<ex:Button runat="server" ID="btnSave" ButtonStyle="Save" DataSource="bc" />
		<ex:Button runat="server" ID="btnDelete" ButtonStyle="Delete" DataSource="bc" />
		<ex:Button runat="server" ID="btnClose" ButtonStyle="Close" />
	</ex:ButtonBar>

	<ex:BCDataSource runat="server" ID="bc" Component="CSEasyWMDefSelection" AddNewProps="DefID" />
	
	<ex:cardrow runat="server" id="cr">
		<ex:cardcolumn runat="server" id="cc">
			<ex:cardsection runat="server" id="csGeneral" caption="Selection field" captionid="421037">
				<ex:cardfield runat="server" id="cfDefinition" caption="WordMerge Definition" captionid="421008" ReadOnly="True">
					<ex:inputfield runat="server" id="DefIDTitle" datasource="bc" ReadOnly="True" />
				</ex:cardfield>
				<ex:cardfield runat="server" id="cfCaption" caption="Label" captionid="205">
					<ex:inputfield runat="server" id="Caption" datasource="bc" StartFocus="True" />
				</ex:cardfield>
				<ex:cardfield runat="server" id="cfCaptionTermID" caption="Label" captionid="205" CaptionSuffix=":Term ID" CaptionSuffixID="37212">
					<ex:inputfield runat="server" id="CaptionTermID" datasource="bc" />
				</ex:cardfield>
				<ex:cardfield runat="server" id="cfDisplayOrder" caption="Sorting" captionid="1272">
					<ex:combobox runat="server" id="DisplayOrder" datasource="bc" ShowKey="True" />
				</ex:cardfield>
				<ex:cardfield runat="server" id="cfEnabled" caption="Enabled" captionid="9086">
					<ex:checkbox runat="server" id="Enabled" datasource="bc" />
				</ex:cardfield>
			</ex:cardsection>
			<ex:cardsection runat="server" id="csSelection" caption="Selection" captionid="8792">
				<ex:cardfield runat="server" id="cfTopic" caption="Subject" captionid="213">
					<ex:combobox runat="server" id="Topic" datasource="bc" AllowEmpty="True" />
					<ex:button runat="server" id="btnShowSelection" caption="Show" captionid="8804" onclick="SysSet('BrowserAction', 1); SysSubmit(1);" /><ex:inputfield runat="server" id="EncryptedBrowserWhere" hidden="true" /><ex:inputfield runat="server" id="BrowserAction" hidden="true" />
				</ex:cardfield>
				<ex:cardfield runat="server" id="cfLinkToSelectionID" caption="Linked" captionid="3690" captionsuffix=":Selection field" captionsuffixid="421037">
					<ex:combobox runat="server" id="LinkToSelectionID" datasource="bc" AllowEmpty="True" />
				</ex:cardfield>
				<ex:cardfield runat="server" id="cfSelectionCriteria" caption="Filter" captionid="1378">
					<ex:memofield id="SelectionCriteria" runat="server" datasource="bc" width="100%" height="6" htmlencoded="true" />
				</ex:cardfield>
				<ex:cardfield runat="server" id="cfSelectionValues" caption="Selection" captionid="8792">
					<ex:memofield id="SelectionValues" runat="server" datasource="bc" width="100%" height="6" htmlencoded="true" />
				</ex:cardfield>

				<ex:cardfield runat="server" id="cfTopicHelp">
					<table class="form">
						<tr class="Header">
							<th align="left"><ex:literal runat="server" caption="Browser" captionid="37658" /></th>
							<th align="left"><ex:literal runat="server" caption="Table" captionid="8890" /></th>
							<th align="left"><ex:literal runat="server" caption="Prefix" captionid="24847" /></th>
						</tr>
						<tr class="Datalight">
							<td class="Field" id="topicbrowser"></td>
							<td class="Field" id="topictable"></td>
							<td class="Field" id="topicprefix"></td>
						</tr>
					</table>
					<table class="form">
						<tr class="Header">
							<th align="left"><ex:literal runat="server" caption="Example" captionid="1857" /></th>
						</tr>
						<tr class="Datalight">
							<td class="field">
								<table><tr><td id="topicexample"></td></tr></table>
							</td>
						</tr>
					</table>
				</ex:cardfield>

			</ex:cardsection>
			<ex:cardsection runat="server" id="csColumn" caption="Column" captionid="8451">
				<ex:cardfield runat="server" id="cfColumnID" caption="Definition: Column" captionid="421026">
					<ex:combobox runat="server" id="ColumnID" />
				</ex:cardfield>
				<ex:cardfield runat="server" id="cfColumnName" caption="Column name" captionid="22703">
					<ex:inputfield runat="server" id="ColumnName" datasource="bc" />
				</ex:cardfield>
			</ex:cardsection>
		</ex:cardcolumn>
	</ex:cardrow>
</ex:CardControl>

</ep:form>
</body>
</html>
