<!--

   Name:  DGFilterPage.jsp



   Copyright (c) 1997-2003 Novell, Inc.  All Rights Reserved.



   THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.

   USE AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO THE LICENSE AGREEMENT

   ACCOMPANYING THE SOFTWARE DEVELOPMENT KIT (SDK) THAT CONTAINS THIS WORK.

   PURSUANT TO THE SDK LICENSE AGREEMENT, NOVELL HEREBY GRANTS TO DEVELOPER A

   ROYALTY-FREE, NON-EXCLUSIVE LICENSE TO INCLUDE NOVELL'S SAMPLE CODE IN ITS

   PRODUCT. NOVELL GRANTS DEVELOPER WORLDWIDE DISTRIBUTION RIGHTS TO MARKET,

   DISTRIBUTE, OR SELL NOVELL'S SAMPLE CODE AS A COMPONENT OF DEVELOPER'S

   PRODUCTS. NOVELL SHALL HAVE NO OBLIGATIONS TO DEVELOPER OR DEVELOPER'S

   CUSTOMERS WITH RESPECT TO THIS CODE.



-->

<%@  page pageEncoding="utf-8" contentType="text/html;charset=utf-8" import="com.novell.webaccess.common.JSPConduit, com.novell.emframe.dev.eMFrameUtils,

	java.util.Hashtable, com.novell.emframe.dev.eMFrameFactory" %>

<%@ taglib uri="/WEB-INF/iman.tld" prefix="iman" %>

<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>

<% JSPConduit c = new JSPConduit(request); %>





<iman:stringtable bundle="BaseResources"/>

<iman:stringtable bundle="DevResources"/>


<html>

   <head>

      <title><iman:string key="DynamicGroup.FilterPageTitle"/></title>

      <link rel="stylesheet" href="<c:out value="${ContextPath}" />/portal/modules/dev/css/hf_style.css">

      <iman:eMFrameScripts/>

      <iman:osScripts/>

     	<iman:include page="dev/ASScripts_inc.jsp"/>

      <iman:include page="dev/PageScripts_inc.jsp"/>

      <script language="JavaScript">



         function isPageValid()
         {
            //alert(document.DGFilterPageForm.basednControl2.value);
				document.DGFilterPageForm.basednControl.value = urlEncode( document.DGFilterPageForm.basednControl2.value );
				//alert(document.DGFilterPageForm.basednControl.value);
            document.DGFilterPageForm.asHiddenField.value = urlEncode( document.DGFilterPageForm.filterControl.value );
				document.DGFilterPageForm.target = "bookBody";

            return true;

         }



			function updateFilter( filter, filterXML )
			{
				with( document.forms[0] )

				{

					if ( useDynamicSettingsCheckbox.checked == true )

					{

						filterControl.value = filter;

						advancedSelectionXML.value = filterXML;

					}

				}

			}



			function EnableDisableDynamicControl()
			{
				with( document.forms[0] )
				{
               if (hasRoleAssignments.value == "true")
               {
                  alert("<iman:string key="DynamicGroup.HasRoleAssignment"/>");
                  if ( useDynamicSettingsCheckbox.checked == true )
                  {
                     useDynamicSettingsCheckbox.checked = false;
                  }
                  else
                  {
                     useDynamicSettingsCheckbox.checked = true;
                  }
               }

					if ( useDynamicSettingsCheckbox.checked == true && hasRoleAssignments.value == "false")
					{

						useDynamicSettings.value = "true";

						allValuesControl.disabled = false;

						basednControl2.disabled = false;

						scopeControl.disabled = false;

						xchainControl.disabled = false;

					}

					else if ( useDynamicSettingsCheckbox.checked == false && hasRoleAssignments.value == "false")
    				{

						useDynamicSettings.value = "false";

						allValuesControl.disabled = true;

						basednControl2.disabled = true;

						scopeControl.disabled = true;

						xchainControl.disabled = true;

					}

				}

			}



         function filterCallback(controlName,type, criterion)
         {
            var strResults="";

            strResults += criterion;

            document.DGFilterPageForm.hiddenActionField.value = "modify";

            document.DGFilterPageForm.nextState.value = "show";

				if ( isPageValid() )
				{
	            document.DGFilterPageForm.asHiddenField.value = urlEncode( strResults );

					document.DGFilterPageForm.target = "bookBody";

		    		document.DGFilterPageForm.submit();
				}

         }



         function addValue()

         {

				with( document.forms[0] )

				{
					isPageValid();
					if ( useDynamicSettingsCheckbox.checked == true )

					{

		            document.DGFilterPageForm.hiddenActionField.value = "add";

		            document.DGFilterPageForm.nextState.value = "show";

						document.DGFilterPageForm.target = "bookBody";

				    	document.DGFilterPageForm.submit();

					}

				}

         }



         function removeValue()

         {

				with( document.forms[0] )

				{

					if ( useDynamicSettingsCheckbox.checked == true )

					{

		            var opt = document.DGFilterPageForm.allValuesControl.options;

		            if(opt.length > 1)

		            {

		               document.DGFilterPageForm.hiddenActionField.value = "remove";

			            document.DGFilterPageForm.nextState.value = "show";

							document.DGFilterPageForm.target = "bookBody";

					    	document.DGFilterPageForm.submit();

		            }

		            else

		            {

		               alert("<iman:string key="DynamicGroup.LastValueWarning"/>");

		            }

					}

				}

         }



         function refreshValue()

         {

				isPageValid();
            var opt = document.DGFilterPageForm.allValuesControl.options;

            if(opt.length > 0)

            {

               document.DGFilterPageForm.hiddenActionField.value = "refresh";

	            document.DGFilterPageForm.nextState.value = "show";

					document.DGFilterPageForm.target = "bookBody";

			    	document.DGFilterPageForm.submit();

            }

         }



			function setDGEditFilterDlgElementValue(elementName, elementValue)

			{

				if (elementName!=null && elementName.length>0)

				{

					for (var j=0; j<document.DGEditFilterDlgPostData.elements.length; j++)

					{

						if (document.DGEditFilterDlgPostData.elements[j].name == elementName)

						{

							document.DGEditFilterDlgPostData.elements[j].value = elementValue;

							return;

						}

					}

				}

			}



			function dgFilterEdit()

			{

				with( document.forms[0] )

				{

					if ( useDynamicSettingsCheckbox.checked == true )

					{

						setDGEditFilterDlgElementValue( "filterParam", filterControl.value );



						// set up webaccess values



						var url 			 = '/nps/Empty.html';

						var windowName  = 'DGEditFilterDlg';

						var winOpts 	 = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=no,resizable=yes,width=500,height=215";

						var w 			 = window.open( url, windowName, winOpts );



						// submit

						document.DGEditFilterDlgPostData.target = windowName;

						document.DGEditFilterDlgPostData.submit();

					}

				}

			}



		   function getInitialCriterion(types)

		   {

			   return document.forms[0].advancedSelectionXML.value;

		   }

			function sparsefunction()
			{
			
				if(document.DGFilterPageForm.xchainControl.value=="<iman:string key="DynamicGroup.FilterXChainNSet"/>")
				{
					document.DGFilterPageForm.xsparseControl.disabled=false;
				}
				else
				{
					document.DGFilterPageForm.xsparseControl.disabled=true;
				}
			
			}	
			
			

      </script>



   </head>

	<body TEXT="#000000" LINK="#000000" VLINK="#000000" ALINK="#000000" bgcolor="#FFFFFF" onLoad="returnFromOS(); sparsefunction();">

		<form name="DGFilterPageForm" method=post action="<c:out value= "${ContextPath}"/>/servlet/frameservice">

         <input type=hidden name="taskId" value="<c:out value="${taskId}"/>"/>

			<input type=hidden name="asHiddenField" value="">

			<input type=hidden name="hiddenActionField" value="">

			<input type=hidden name="useDynamicSettings" value="<c:out value="${IsDynamicParam}"/>"/>

			<input type=hidden name="advancedSelectionXML" value="<c:out value="${filterParamXML}"/>"/>

         <input type=hidden name="hasRoleAssignments" value="<c:out value="${hasRoleAssignmentsParam}"/>">



			<iman:include page="dev/Messagebar_inc.jsp"/>

			<iman:include page="dev/BookVars_inc.jsp"/>



			<table width="100%" border="0" cellspacing="0" cellpadding="2" class="mediumtext">

            <tr>

               <td>

                  <div align="left">

                     <input
								
								alt="<iman:string key="DynamicGroup.UseDynamicSettings"/>"

                     	type="checkbox"

                     	name="useDynamicSettingsCheckbox"

                     	width="16"

                     	height="16"

								onClick="EnableDisableDynamicControl()"

	                   	<c:if test="${CanChangeDynamicParam == 'false'}">disabled</c:if>
	                   	<c:if test="${IsNestedSettingParam == 'true'}">disabled</c:if>
	                   	<c:if test="${IsDynamicParam == 'true'}">checked</c:if> />
	                   	
	                   	<iman:string key="DynamicGroup.UseDynamicSettings"/>

                  </div>

               </td>

            </tr>

				<tr>

					<td><br></td>

				</tr>

			</table>

			<table width="100%" border="0" cellspacing="0" cellpadding="2" class="mediumtext">

            <tr>

               <td align="left" colspan="5" class="tablesubhead1">
						<iman:string key="DynamicGroup.AllValuesLabel"/>

					</td>
				</tr>
			</table>
			<table width="600" border="0" cellspacing="0" cellpadding="2" class="mediumtext">

            <tr>

               <td width="30px" align="right">
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					</td>
					<td colspan="4">

						<select

	           			name="allValuesControl"

	           			onchange="refreshValue()"

							<c:if test="${IsDynamicParam == 'false'}"> disabled </c:if>

	           			style="WIDTH: 450px"/>

							<c:forEach items="${valuesParam}" var="element">

								<c:if test="${element == selectParam}">

									<option selected><c:out value="${element}"/></option>

								</c:if>

								<c:if test="${element != selectParam}">

									<option><c:out value="${element}"/></option>

								</c:if>

							</c:forEach>

						</select>

						<iman:button key="AddValuePlus" onClick="addValue()"/>

						<iman:button key="RemoveValueMinus" onClick="removeValue()"/>

					</td>

				</tr>

				<tr>

					<td></td>

					<td align="left" valign="top" colspan="4">

						<br>

						<iman:string key="DynamicGroup.baseDNLabel"/>

						<br>

						<input type=hidden name="basednControl" value="<c:out value="${basednParam}"/>" >

                  <input

                  	type=text

                  	name="basednControl2"

							<c:if test="${IsDynamicParam == 'false'}"> disabled </c:if>

                  	style="WIDTH: 450px"

                  	value="<c:out value="${basednParam}"/>"

                  	size=40 />

                     <iman:os typeFilter="[containers],[root]" control="basednControl2" history="true" multiSelect="false"/>

						<script>
							document.DGFilterPageForm.basednControl.value = urlDecode( document.DGFilterPageForm.basednControl2.value );
							document.DGFilterPageForm.basednControl2.value = document.DGFilterPageForm.basednControl.value;
						</script>
					</td>

            </tr>

            <tr>

					<td></td>

               <td align="left" valign="top">

	               <br>

	               <iman:string key="DynamicGroup.ScopeLabel"/>

	               <br>

                  <select

                  	name="scopeControl"

							<c:if test="${IsDynamicParam == 'false'}"> disabled </c:if>

                  	size="1"

                  	style="WIDTH: 450px" />

							<c:choose>

								<c:when test="${scopeParam == 'sub'}">

									<option selected><iman:string key="DynamicGroup.FilterScopeSub"/></option>

									<option><iman:string key="DynamicGroup.FilterScopeOne"/></option>

									<option><iman:string key="DynamicGroup.FilterScopeBase"/></option>

								</c:when>

								<c:when test="${scopeParam == 'base'}">

									<option selected><iman:string key="DynamicGroup.FilterScopeBase"/></option>

									<option><iman:string key="DynamicGroup.FilterScopeSub"/></option>

									<option><iman:string key="DynamicGroup.FilterScopeOne"/></option>

								</c:when>

								<c:when test="${scopeParam == 'one'}">

									<option selected><iman:string key="DynamicGroup.FilterScopeOne"/></option>

									<option><iman:string key="DynamicGroup.FilterScopeSub"/></option>

									<option><iman:string key="DynamicGroup.FilterScopeBase"/></option>

								</c:when>

								<c:otherwise>

									<option selected><iman:string key="DynamicGroup.FilterScopeSub"/></option>

									<option><iman:string key="DynamicGroup.FilterScopeOne"/></option>

									<option><iman:string key="DynamicGroup.FilterScopeBase"/></option>

								</c:otherwise>

							</c:choose>

                  </select>

               </td>

            </tr>

            <tr>

					<td></td>

               <td align="left" valign="top">

                  <br>

                  <iman:string key="DynamicGroup.XChainLabel"/>

                  <br>

						<select

							name="xchainControl"

							size="1" onchange="sparsefunction()"

							<c:if test="${IsDynamicParam == 'false'}"> disabled </c:if>

							style="WIDTH: 450px" />

							<c:choose>

								<c:when test="${xchainParam == 'x-chain'}">

									<option selected value="<iman:string key="DynamicGroup.FilterXChainSet"/>"><iman:string key="DynamicGroup.FilterXChainSet"/></option>

									<option value="<iman:string key="DynamicGroup.FilterXChainNSet"/>"><iman:string key="DynamicGroup.FilterXChainNSet"/></option>

								</c:when>

								<c:when test="${xchainParam == ''}">

									<option selected value="<iman:string key="DynamicGroup.FilterXChainNSet"/>"><iman:string key="DynamicGroup.FilterXChainNSet"/></option>

									<option value="<iman:string key="DynamicGroup.FilterXChainSet"/>"><iman:string key="DynamicGroup.FilterXChainSet"/></option>

								</c:when>
								
								<c:when test="${xsparseParam == 'x-sparse'}">

									<option selected value="<iman:string key="DynamicGroup.FilterXChainNSet"/>"><iman:string key="DynamicGroup.FilterXChainNSet"/></option>

									<option value="<iman:string key="DynamicGroup.FilterXChainSet"/>"><iman:string key="DynamicGroup.FilterXChainSet"/></option>

								</c:when>

								<c:otherwise>

									<option selected value="<iman:string key="DynamicGroup.FilterXChainSet"/>"><iman:string key="DynamicGroup.FilterXChainSet"/></option>

									<option value="<iman:string key="DynamicGroup.FilterXChainNSet"/>"><iman:string key="DynamicGroup.FilterXChainNSet"/></option>

								</c:otherwise>

							</c:choose>

						</select>

               </td>

            </tr>

 <tr>

					<td></td>

               <td align="left" valign="top">

                  <br>

                  <iman:string key="DynamicGroup.XSprarseLabel"/>

                  <br>

						<select

							name="xsparseControl"

							size="1"

							<c:if test="${IsDynamicParam == 'false'}"> disabled </c:if>

							style="WIDTH: 450px" />

							<c:choose>

								<c:when test="${xsparseParam == 'x-sparse'}">

									<option selected><iman:string key="DynamicGroup.FilterXChainSet"/></option>

									<option><iman:string key="DynamicGroup.FilterXChainNSet"/></option>

								</c:when>

								<c:when test="${xsparseParam == ''}">

									<option selected><iman:string key="DynamicGroup.FilterXChainNSet"/></option>

									<option><iman:string key="DynamicGroup.FilterXChainSet"/></option>

								</c:when>

								<c:otherwise>

									<option selected><iman:string key="DynamicGroup.FilterXChainSet"/></option>

									<option><iman:string key="DynamicGroup.FilterXChainNSet"/></option>

								</c:otherwise>

							</c:choose>

						</select>

               </td>

            </tr>


				<tr>

					<td></td>

					<td align="left">

						<br>

						<iman:string key="DynamicGroup.FilterLabel"/>

						<br>

						<textarea

            			name="filterControl"

            			style="WIDTH: 450px"

							readonly

            			rows="6"

            			cols="40"></textarea>

						<script>
							document.DGFilterPageForm.filterControl.value = urlDecode( "<c:out value="${filterParam}"/>" );
						</script>
					</td>

					<td valign="top">

						<br>

						<br>

	               <c:set var="AS.Types" value="*" scope="request" />

	               <c:set var="AS.ControlCallBack" value="filterCallback" scope="request" />

					   <c:set var="AS.TypeInfoCallBack" value="com.novell.emframe.base.DGMemberQueryCallback" scope="request" />

				      <c:set var="AS.InitialCriterionCallBack" value="getInitialCriterion" scope="request" />

					   <jsp:include page='<%= c.getPath("dev/AS_inc.jsp") %>' flush="true" />

					</td>

					<td valign="top">

						<br>

						<br>

					   <A href="javascript:dgFilterEdit();">

					   	<img alt="<iman:string key="Widgets.editItem"/>"

					   		src="<%= c.getModulesUrl() %>/dev/images/iconedit.gif"
						    title="<iman:string key="Widgets.editItem"/>"	
					   		border="0" />
                          <!-- Changes made for bug No:268291 a title  attribute was added as mozilla 
                          did not consider alt attribute as a tooltip text -->
				   	</a>

					</td>

					<td width="100%"></td>

				</tr>

				<tr>

					<td></td>

	            <td valign= bottom class="mediumtext" colspan="3">

	            	<div>

	            		<iman:string key="DynamicGroup.ModifyDynamicGroupFilterWarning"/>

	            	</div>

	            </td>

	         </tr>

				<tr height="9">

					<td><br></td>

				</tr>

			</table>

			<table width="100%" border="0" cellspacing="0" cellpadding="2" class="mediumtext">

				<tr>

					<td class="tablesubhead1">

						<iman:string key="DynamicGroup.QueryResultsLabel"/>

					</td>

				</tr>

				<tr>

					<td class="instructions">

						<iman:string key="DynamicGroup.UpdateDynamicGroupResultsWarning"/>

					</td>

				</tr>

            <tr>

               <td align=left>

						<br>

                  <select name="dynamicMembersControl" size="6" style="WIDTH: 640px" >

	                  <c:forEach items="${DynamicMembersParam}" var="element">

	                     <option style="color: #808080;"> <c:out value="${element}"/> </option>

	                  </c:forEach>

						</select><br>

                  <iman:string key="DynamicGroup.CountLabel"/> <INPUT type="text" id="<c:out value="${DynamicMembersParamCount}"/>" value="<c:out value="${DynamicMembersParamCount}"/>" style="border:none;background:white;color:black;" disabled="true">
               </td>

				</tr>

         </table>

      </form>



		<form name="DGEditFilterDlgPostData" method=post action="webacc" target="DGEditFilterDlg">



			<input type=hidden name="filterParam" value="">

			<input type=hidden name="taskId" value="fw.DGEditFilterDlg">

			<input type=hidden name="merge"  value="base.DGEditFilterDlg">

			<input type=hidden name="error"  value="dev.GenErr">



		</form>



      <iman:osFooter/>

   </body>

</html>

