<h2 align="center"><?php echo $FormParams['heading'].$reportname.' - '.RPT_BTN_CRIT; ?></h2>
<form name="CritFieldForm" method="post" action="ReportCreator.php?action=step7">
  <input type="hidden" name="FormID" value="<?php echo $_SESSION['FormID']; ?>">
  <input name="ReportID" type="hidden" value="<?php echo $ReportID; ?>">
  <input name="Type" type="hidden" value="<?php echo $Type; ?>">
  <input name="ReportName" type="hidden" value="<?php echo $reportname; ?>">
  <table align="center" width="550" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td width="33%"><input name="todo" type="submit" id="todo" value="<?php echo RPT_BTN_BACK; ?>"></td>
      <td width="34%"><div align="center"><input name="todo" type="submit" id="todo" value="<?php echo RPT_BTN_UPDATE; ?>"></div></td>
      <td width="33%"><div align="right"><input name="todo" type="submit" id="todo" value="<?php echo RPT_BTN_FINISH; ?>"></div></td>
    </tr>
  </table>
  <table width="700" align="center" border="2" cellspacing="1" cellpadding="1">
    <tr bgcolor="#CCCCCC">
      <td colspan="6"><div align="center"><?php echo RPT_DATEINFO; ?></div></td>
    </tr>
    <tr>
      <td width="20%"><?php echo RPT_DATELIST; ?><br /><br /><?php echo RPT_DATEINST; ?></td>
      <td width="16%">
	    <?php if (mb_strpos($DateListings['displaydesc'],'a')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange1" value="a"<?php echo $Checked; ?>><?php echo $DateChoices['a']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'b')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange2" value="b"<?php echo $Checked; ?>><?php echo $DateChoices['b']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'c')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange3" value="c"<?php echo $Checked; ?>><?php echo $DateChoices['c']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'d')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange4" value="d"<?php echo $Checked; ?>><?php echo $DateChoices['d']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'e')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange5" value="e"<?php echo $Checked; ?>><?php echo $DateChoices['e']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'f')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange6" value="f"<?php echo $Checked; ?>><?php echo $DateChoices['f']; ?><br />
	  </td>
      <td width="16%">
	    <?php if (mb_strpos($DateListings['displaydesc'],'g')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange7" value="g"<?php echo $Checked; ?>><?php echo $DateChoices['g']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'h')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange8" value="h"<?php echo $Checked; ?>><?php echo $DateChoices['h']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'i')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange9" value="i"<?php echo $Checked; ?>><?php echo $DateChoices['i']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'j')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange10" value="j"<?php echo $Checked; ?>><?php echo $DateChoices['j']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'k')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange11" value="k"<?php echo $Checked; ?>><?php echo $DateChoices['k']; ?><br />
	  </td>
      <td width="16%">
	    <?php if (mb_strpos($DateListings['displaydesc'],'l')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange12" value="l"<?php echo $Checked; ?>><?php echo $DateChoices['l']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'m')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange13" value="m"<?php echo $Checked; ?>><?php echo $DateChoices['m']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'n')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange14" value="n"<?php echo $Checked; ?>><?php echo $DateChoices['n']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'o')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange15" value="o"<?php echo $Checked; ?>><?php echo $DateChoices['o']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'p')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange16" value="p"<?php echo $Checked; ?>><?php echo $DateChoices['p']; ?><br />
	  </td>
      <td width="16%">
	    <?php if (mb_strpos($DateListings['displaydesc'],'q')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange17" value="q"<?php echo $Checked; ?>><?php echo $DateChoices['q']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'r')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange18" value="r"<?php echo $Checked; ?>><?php echo $DateChoices['r']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'s')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange19" value="s"<?php echo $Checked; ?>><?php echo $DateChoices['s']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'t')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange20" value="t"<?php echo $Checked; ?>><?php echo $DateChoices['t']; ?><br />
	  </td>
      <td width="16%">
	    <?php if (mb_strpos($DateListings['displaydesc'],'u')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange21" value="u"<?php echo $Checked; ?>><?php echo $DateChoices['u']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'v')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange22" value="v"<?php echo $Checked; ?>><?php echo $DateChoices['v']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'w')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange23" value="w"<?php echo $Checked; ?>><?php echo $DateChoices['w']; ?><br />
	    <?php if (mb_strpos($DateListings['displaydesc'],'x')===false) $Checked = ''; else $Checked = ' checked'; ?>
		<input type="checkbox" name="DateRange24" value="x"<?php echo $Checked; ?>><?php echo $DateChoices['x']; ?><br />
	  </td>
    </tr>
    <tr>
      <td><?php echo RPT_DATEDEF; ?></td>
      <td colspan="5"><select name="DefDate">
		<?php foreach($DateChoices as $key=>$value) {
			if ($DateListings['params']==$key) $Selected = ' selected'; else $Selected = '';
			echo '<option value="'.$key.'"'.$Selected.'>'.$value.'</option>';
		} ?>
      </select></td>
    </tr>
    <tr>
      <td><?php echo RPT_DATEFNAME; ?></td>
      <td colspan="5">
	    <select name="DateField"><OPTION Value=""><?php echo RPT_SLCTFIELD; ?>
		<?php echo CreateFieldList($ReportID,$DateListings['fieldname'],''); ?></select>
	  </td>
    </tr>
	<?php if ($Type<>'frm') { ?>
	   <tr>
		  <td><?php echo RPT_TRUNC; ?></td>
		  <td colspan="5"><p>
			<?php if ($TruncListings['params']=='1') $Checked = ' checked'; else $Checked = ''; ?>
			  <input type="radio" name="TruncLongDesc" value="1"<?php echo $Checked; ?>><?php echo RPT_YES; ?>
			<?php if ($TruncListings['params']=='0') $Checked = ' checked'; else $Checked = ''; ?>
			  <input type="radio" name="TruncLongDesc" value="0"<?php echo $Checked; ?>><?php echo RPT_NO; ?></p></td>
		</tr>
	<?php } else { ?>
		<tr>
		  <td><?php echo 'Form Page Break Field (table.fieldname)'; ?></td>
		  <td colspan="5">
			<select name="FormBreakField"><OPTION Value=""><?php echo RPT_SLCTFIELD; ?>
			<?php echo CreateFieldList($ReportID,$GroupListings['lists'][0]['fieldname'],''); ?></select>
		  </td>
		</tr>
	<?php } // end if ($Type<>'frm') ?>
  </table>
</form>
<br />
<table align="center" border="2" cellspacing="1" cellpadding="1">
<?php if ($Type<>'frm') { // then show the sort and group information ?>
    <tr bgcolor="#CCCCCC">
      <td colspan="5"><div align="center"><?php echo RPT_GRPLIST; ?></div></td>
    </tr>
    <tr>
      <td><?php echo RPT_SEQ; ?></td>
      <td align="center"><?php echo RPT_TBLFNAME; ?></td>
      <td align="center"><?php echo RPT_DISPNAME; ?></td>
      <td align="center"><?php echo RPT_DEFAULT; ?></td>
      <td>&nbsp;</td>
    </tr>
    <tr><form name="CritFieldForm" method="post" action="ReportCreator.php?action=step7">
	<input type="hidden" name="FormID" value="<?php echo $_SESSION['FormID']; ?>" />
	    <input name="ReportID" type="hidden" value="<?php echo $ReportID ?>">
		<input name="Type" type="hidden" value="<?php echo $Type; ?>">
		<input name="ReportName" type="hidden" value="<?php echo $reportname; ?>">
	    <input name="EntryType" type="hidden" value="grouplist">
	  <td align="center">
	    <?php if ($GroupListings['defaults']['buttonvalue']=='Change') { ?>
	    <input name="SeqNum" type="hidden" value="<?php echo $GroupListings['defaults']['seqnum']; ?>">
	    <?php echo $GroupListings['defaults']['seqnum']; } else { ?>
	    <input name="SeqNum"  type="text" value="<?php echo $GroupListings['defaults']['seqnum']; ?>" size="4" maxlength="3">
	    <?php } // end if ?>
	  </td>
      <td>
	    <select name="FieldName"><OPTION Value=""><?php echo RPT_SLCTFIELD; ?>
		<?php echo CreateFieldList($ReportID,$GroupListings['defaults']['fieldname'],''); ?></select>
	  </td>
      <td>
	    <input name="DisplayDesc" type="text" value="<?php echo $GroupListings['defaults']['displaydesc']; ?>" size="26" maxlength="25">
	  </td>
      <td><div align="center">
	    <input name="Params" type="checkbox" value="1"></div>
	  </td>
      <td align = "center">
	    <input name="todo" type="submit" value="<?php echo $GroupListings['defaults']['buttonvalue']; ?>">
	  </td>
      </form>
	</tr>
	<?php if (!$GroupListings['lists']) {
		echo '<tr><td align="center" colspan="7">'.RPT_NOFIELD.'</td></tr>';
	} else {
		foreach ($GroupListings['lists'] as $FieldDetails) { ?>
			<tr>
				<form name="CritFieldForm" method="post" action="ReportCreator.php?action=step7">
				<input type="hidden" name="FormID" value="<?php echo $_SESSION['FormID']; ?>" />
				<input name="ReportID" type="hidden" value="<?php echo $ReportID ?>">
				<input name="Type" type="hidden" value="<?php echo $Type; ?>">
				<input name="ReportName" type="hidden" value="<?php echo $reportname; ?>">
				<input name="EntryType" type="hidden" value="grouplist">
				<input name="SeqNum" type="hidden" value="<?php echo $FieldDetails['seqnum'] ?>">
				<input name="FieldName" type="hidden" value="<?php echo $FieldDetails['fieldname'] ?>">
				<input name="DisplayDesc" type="hidden" value="<?php echo $FieldDetails['displaydesc'] ?>">
				<input name="Params" type="hidden" value="<?php echo $FieldDetails['params'] ?>">
				  <td align = "center"><?php echo $FieldDetails['seqnum']; ?></td>
				  <td><?php echo $FieldDetails['fieldname']; ?></td>
				  <td><?php echo $FieldDetails['displaydesc']; ?></td>
				  <?php if ($FieldDetails['params']=='1') $selected=' checked'; else $selected=''; ?>
				  <td align = "center"><input disabled type="checkbox"<?php echo $selected; ?>></td>
				  <td>
					<INPUT type=image name="up" value="up" src="../images/upicon.png" border="0">
					<INPUT type=image name="dn" value="down" src="../images/downicon.png" border="0">
					<INPUT type=image name="ed" value="edit" src="../images/editicon.png" border="0">
					<INPUT type=image name="rm" value="delete" src="../images/delicon.png" border="0" onClick="return confirm('Delete this field?')">
				  </td>
				  </form>
			</tr>
		<?php } // end foreach
	} // end else  ?>
    <tr bgcolor="#CCCCCC">
      <td colspan="5"><div align="center"><?php echo RPT_SORTLIST; ?></div></td>
    </tr>
    <tr>
      <td><?php echo RPT_SEQ; ?></td>
      <td align="center"><?php echo RPT_TBLFNAME; ?></td>
      <td align="center"><?php echo RPT_DISPNAME; ?></td>
      <td align="center"><?php echo RPT_DEFAULT; ?></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
	<form name="CritFieldForm" method="post" action="ReportCreator.php?action=step7">
	<input type="hidden" name="FormID" value="<?php echo $_SESSION['FormID']; ?>" />
	  <input name="ReportID" type="hidden" value="<?php echo $ReportID ?>">
	  <input name="Type" type="hidden" value="<?php echo $Type; ?>">
	  <input name="ReportName" type="hidden" value="<?php echo $reportname; ?>">
	  <input name="EntryType" type="hidden" value="sortlist">
	  <td align="center">
	    <?php if ($SortListings['defaults']['buttonvalue']=='Change') { ?>
	    <input name="SeqNum" type="hidden" value="<?php echo $SortListings['defaults']['seqnum']; ?>">
	    <?php echo $SortListings['defaults']['seqnum']; } else { ?>
	    <input name="SeqNum"  type="text" value="<?php echo $SortListings['defaults']['seqnum']; ?>" size="4" maxlength="3">
	    <?php } // end if ?>
	  </td>
      <td>
	    <select name="FieldName"><OPTION Value=""><?php echo RPT_SLCTFIELD; ?>
		<?php echo CreateFieldList($ReportID,$SortListings['defaults']['fieldname'],''); ?></select>
	  </td>
      <td>
	    <input name="DisplayDesc" type="text" value="<?php echo $SortListings['defaults']['displaydesc']; ?>" size="26" maxlength="25">
	  </td>
      <td><div align="center">
        <input name="Params" type="checkbox" value="1">
      </div></td>
      <td align = "center">
	    <input name="todo" type="submit" value="<?php echo $SortListings['defaults']['buttonvalue']; ?>">
	  </td>
      </form>
	</tr>
	<?php if (!$SortListings['lists']) {
		echo '<tr><td align="center" colspan="7">'.RPT_NOFIELD.'</td></tr>';
	} else {
	foreach ($SortListings['lists'] as $FieldDetails) { ?>
		<tr>
		  <form name="CritFieldForm" method="post" action="ReportCreator.php?action=step7">
	<input type="hidden" name="FormID" value="<?php echo $_SESSION['FormID']; ?>" />
		  <input name="ReportID" type="hidden" value="<?php echo $ReportID ?>">
		  <input name="Type" type="hidden" value="<?php echo $Type; ?>">
		  <input name="ReportName" type="hidden" value="<?php echo $reportname; ?>">
		  <input name="EntryType" type="hidden" value="sortlist">
		  <input name="SeqNum" type="hidden" value="<?php echo $FieldDetails['seqnum'] ?>">
		  <input name="FieldName" type="hidden" value="<?php echo $FieldDetails['fieldname'] ?>">
		  <input name="DisplayDesc" type="hidden" value="<?php echo $FieldDetails['displaydesc'] ?>">
		  <input name="Params" type="hidden" value="<?php echo $FieldDetails['params'] ?>">
		  <td align = "center"><?php echo $FieldDetails['seqnum']; ?></td>
		  <td><?php echo $FieldDetails['fieldname']; ?></td>
		  <td><?php echo $FieldDetails['displaydesc']; ?></td>
		  <?php if ($FieldDetails['params']=='1') $selected=' checked'; else $selected=''; ?>
		  <td align = "center"><input disabled type="checkbox"<?php echo $selected; ?>></td>
		  <td>
			<INPUT type=image name="up" value="up" src="../images/upicon.png" border="0">
			<INPUT type=image name="dn" value="down" src="../images/downicon.png" border="0">
			<INPUT type=image name="ed" value="edit" src="../images/editicon.png" border="0">
			<INPUT type=image name="rm" value="delete" src="../images/delicon.png" border="0" onClick="return confirm('Delete this field?')">
		  </td>
		  </form>
		</tr>
	<?php } // end foreach
	} // end else
} // end if ($Type<>'frm') ?>
    <tr bgcolor="#CCCCCC">
      <td colspan="5"><div align="center"><?php echo RPT_BTN_CRIT; ?></div></td>
    </tr>
    <tr>
      <td><?php echo RPT_SEQ; ?></td>
      <td align="center"><?php echo RPT_TBLFNAME; ?></td>
      <td align="center"><?php echo RPT_DISPNAME; ?></td>
      <td align="center"><?php echo RPT_CRITTYPE; ?></td>
      <td>&nbsp;</td>
    </tr>
    <tr>
	  <form name="CritFieldForm" method="post" action="ReportCreator.php?action=step7">
	<input type="hidden" name="FormID" value="<?php echo $_SESSION['FormID']; ?>" />
	  <input name="ReportID" type="hidden" value="<?php echo $ReportID ?>">
	  <input name="Type" type="hidden" value="<?php echo $Type; ?>">
	  <input name="ReportName" type="hidden" value="<?php echo $reportname; ?>">
	  <input name="EntryType" type="hidden" value="critlist">
	  <td align="center">
	    <?php if ($CritListings['defaults']['buttonvalue']=='Change') { ?>
	    <input name="SeqNum" type="hidden" value="<?php echo $CritListings['defaults']['seqnum']; ?>">
	    <?php echo $CritListings['defaults']['seqnum']; } else { ?>
	    <input name="SeqNum"  type="text" value="<?php echo $CritListings['defaults']['seqnum']; ?>" size="4" maxlength="3">
	    <?php } // end if ?>
	  </td>
      <td>
	    <select name="FieldName"><OPTION Value=""><?php echo RPT_SLCTFIELD; ?>
		<?php echo CreateFieldList($ReportID,$CritListings['defaults']['fieldname'],''); ?></select>
	  </td>
      <td>
	    <input name="DisplayDesc" type="text" value="<?php echo $CritListings['defaults']['displaydesc']; ?>" size="26" maxlength="25">
	  </td>
      <td>
		<select name="Params">
		<?php foreach($CritChoices as $key=>$value) {
			$value=mb_substr($value,2);
			if ($CritListings['defaults']['params']==$key) $selected = ' selected'; else  $selected = '';
			echo '<option value="'.$key.'"'.$selected.'>'.$value.'</option>';
		} ?>
        </select></td>
      <td align = "center">
	    <input name="todo" type="submit" value="<?php echo $CritListings['defaults']['buttonvalue']; ?>">
	  </td>
      </form>
	</tr>
	<?php if (!$CritListings['lists']) {
		echo '<tr><td align="center" colspan="7">'.RPT_NOFIELD.'</td></tr>';
	} else {
	foreach ($CritListings['lists'] as $FieldDetails) { ?>
    <tr>
	  <form name="CritFieldForm" method="post" action="ReportCreator.php?action=step7">
	<input type="hidden" name="FormID" value="<?php echo $_SESSION['FormID']; ?>" />
	  <input name="ReportID" type="hidden" value="<?php echo $ReportID ?>">
	  <input name="Type" type="hidden" value="<?php echo $Type; ?>">
	  <input name="ReportName" type="hidden" value="<?php echo $reportname; ?>">
	  <input name="EntryType" type="hidden" value="critlist">
	  <input name="SeqNum" type="hidden" value="<?php echo $FieldDetails['seqnum'] ?>">
	  <input name="FieldName" type="hidden" value="<?php echo $FieldDetails['fieldname'] ?>">
	  <input name="DisplayDesc" type="hidden" value="<?php echo $FieldDetails['displaydesc'] ?>">
	  <input name="Params" type="hidden" value="<?php echo $FieldDetails['params'] ?>">
	  <td align = "center"><?php echo $FieldDetails['seqnum']; ?></td>
      <td><?php echo $FieldDetails['fieldname']; ?></td>
      <td><?php echo $FieldDetails['displaydesc']; ?></td>
      <td align = "center"><?php echo mb_substr($CritChoices[$FieldDetails['params']],2); ?></td>
      <td>
		<INPUT type=image name="up" value="up" src="../images/upicon.png" border="0">
		<INPUT type=image name="dn" value="down" src="../images/downicon.png" border="0">
		<INPUT type=image name="ed" value="edit" src="../images/editicon.png" border="0">
		<INPUT type=image name="rm" value="delete" src="../images/delicon.png" border="0" onClick="return confirm('Delete this field?')">
	  </td>
      </form>
	</tr>
<?php } // end foreach
} // end else ?>
</table>