<h2 align="center"><?php echo $FormParams['heading'].$reportname.' - '.RPT_BTN_CRIT; ?></h2>
<form name="CritFieldForm" method="post" action="ReportCreator.php?action=step7">
  <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="3"><div align="center"><?php echo RPT_DATEINFO; ?></div></td>
    </tr>
    <tr>
      <td width="33%"><?php echo RPT_DATELIST; ?><br><br><?php echo RPT_DATEINST; ?></td>
      <td width="33%">
	    <?php if (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 (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 (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 (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 (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 (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="33%">
	    <?php if (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 (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 (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 (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 (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>
    </tr>
    <tr>
      <td><?php echo RPT_DATEDEF; ?></td>
      <td colspan="2"><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="4">
	    <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="4"><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="4">
			<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>
<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 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 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 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 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 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=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 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 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>
