home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 May / CMCD0505.ISO / Software / Shareware / Programare / bugzero / jsp / _queryform.jspf < prev    next >
Text File  |  2004-11-10  |  6KB  |  174 lines

  1. <%!
  2.   String[] getOptions(com.websina.bean.Filter filter, String fieldName) {
  3.     if (filter == null) {
  4.       return null;
  5.     } else {
  6.       return filter.getField(fieldName);
  7.     }
  8.   }
  9.  
  10.   String dateOp() {
  11.     return ListMaker.makeOptionList(new String[]{">=", "<", "-"}, new String[]{"after", "before", "between"}, null);
  12.   }
  13.  
  14.   String ageOp() {
  15.     return ListMaker.makeOptionList(new String[]{">=", "<"}, new String[]{"within last", "older than"}, null);
  16.   }
  17.  
  18.   String[] ageUnit() {
  19.     return new String[]{"day", "hour", "week"};
  20.   }
  21.  
  22.   String sortOrder(String order) {
  23.     return ListMaker.makeOptionList(new String[]{"", "A", "D"}, new String[]{"", "ascending", "descending"}, order);
  24.   }
  25.  
  26.   String onClick(Project conf, Person person, String form) {
  27.     StringBuffer buf = new StringBuffer();
  28.     String[] fields = conf.getFields();
  29.     String group = person.getGroup();
  30.     for (int ix=0; ix<fields.length; ix++) {
  31.       String fieldName = fields[ix];
  32.       com.websina.util.Field field = conf.getField(fieldName);
  33.       if (conf.isFieldEnabled(fieldName, group) && field != null) { 
  34.         if (field.isDateField()) {
  35.           buf.append("if(!validDatetime(")
  36.              .append(form).append(".")
  37.              .append(fieldName).append(".value))return false; ");
  38.         } else if (field.isNumberField()) {
  39.           buf.append("if(!validNumberQuery(")
  40.              .append(form).append(".")
  41.              .append(fieldName).append(".value))return false; ");
  42.         }
  43.       }
  44.     }
  45.     return buf.toString();
  46.   }
  47. %>
  48.  
  49. <%      
  50.   boolean isReport = "report.jsp".equals(parent);
  51.   String[] fields = conf.getFields();
  52.   com.websina.util.Field field;
  53. %>
  54.   <% for (int i=0; i<fields.length; i++) {
  55.       String fieldName = fields[i];
  56.       if (fieldName.equals("attachment")) {
  57.         continue;
  58.       } else if (fieldName.equals("author") && person.isGuest()) {
  59.         continue;
  60.       } else if (isReport) {
  61.         if (fieldName.equals("author")
  62.           ||fieldName.equals("cc_mail")
  63.           ||fieldName.equals("synopsis")
  64.           ||fieldName.equals("detail")
  65.         ) continue;
  66.       }
  67.       if (conf.isFieldEnabled(fieldName, person.getGroup()) && (field=conf.getField(fieldName)) != null) {
  68.   %>
  69. <%--/// The Description field ///--%>
  70.     <%   if (fieldName.equals("detail")) { %>
  71.     <tr><td class="e8">
  72.     <%=label.get(fieldName, projectId)%>/<br>
  73.     <%=label.get("response", projectId)%> <font color=red>²</font>
  74.     </td>
  75.     <td class="f1"><input name=detail size=60 maxlength=255></td></tr>
  76.  
  77. <%--/// Responsible field  ///--%>
  78. <% } else if (fieldName.equals("responsible")) { %>
  79.     <tr><td class="cf">
  80.     <%=label.get(fieldName, projectId)%></td>
  81.     <td class="cf"><select name=<%=fieldName%> size=3 multiple style="width: 400px;">
  82.         <%=ListMaker.makeOptionList(conf.getAccess().getUsers("edit", "editasgn"), getOptions(filter, fieldName)) %>
  83.         </select> </td></tr>
  84.  
  85. <%--/// Author field  ///--%>
  86. <% } else if (fieldName.equals("author")) { 
  87.      String selected= "";
  88.      if (filter != null && !filter.isOR(fieldName)) {
  89.        selected = "selected";
  90.      }
  91. %>
  92.     <tr><td class="cf">
  93.     <select name=author_or>
  94.        <option value="OR"> | |</option>
  95.        <option value="AND" <%=selected%>>&&</option>
  96.     </select>
  97.     <%=label.get(fieldName, projectId)%>
  98.     <font color=red>³</font>
  99.     </td>
  100.     <td class="cf"><select name=<%=fieldName%> size=3 multiple style="width: 400px;">
  101.         <%=ListMaker.makeOptionList(conf.getAccess().getAuthors(), getOptions(filter, fieldName)) %>
  102.         </select> </td></tr>
  103. <%--/// the author (second) text field ///--%>
  104.     <tr><td class="e8">
  105.     <%=label.get(fieldName, projectId)%> <font color=red>²</font></td>
  106.     <td class="f1"><input size=60 name=author2>  </td></tr>
  107.  
  108. <%--/// User type fields ///--%>
  109.        <% } else if (field.isUserField()) { %>
  110. <% if (!isReport) {
  111.      String selected= "";
  112.      if (filter != null && !filter.isOR(fieldName)) {
  113.        selected = "selected";
  114.      }
  115. %>
  116.     <tr><td class="cf">
  117.     <select name=<%=fieldName%>_or>
  118.        <option value="OR"> | |</option>
  119.        <option value="AND" <%=selected%>>&&</option>
  120.     </select>
  121.     <%=label.get(fieldName, projectId)%>
  122.     <font color=red>³</font>
  123. <% } else { %>
  124.     <tr><td class="cf">
  125.     <%=label.get(fieldName, projectId)%>
  126. <% } %> 
  127.     </td>
  128.     <td class="cf"><select name=<%=fieldName%> size=3 multiple style="width: 400px;">
  129.         <%=ListMaker.makeOptionList(conf.getAccess().getAuthors(), getOptions(filter, fieldName)) %>
  130.         </select> </td></tr>
  131.  
  132. <%--/// Datetime fields ///--%>
  133.        <% } else if (field.isDateField()) { %>
  134.     <tr><td class="e8">
  135.     <%=label.get(fieldName, projectId)%>
  136.     <font color=red>¹</font></td>
  137.     <td class="f1"><nobr>
  138.     <select name=<%=fieldName%>_dateOp style="width: 66px;">
  139.         <%=dateOp()%></select>
  140.     <input size=14 name=<%=fieldName%>>
  141.       ||  
  142.     <select name=<%=fieldName%>_ageOp style="width: 86px;">
  143.         <%=ageOp()%></select>
  144.     <input size=2  maxlength=4 name=<%=fieldName%>_age>
  145.     <select name=<%=fieldName%>_ageUnit>
  146.         <%=ListMaker.makeOptionList(label, ageUnit(), null)%></select>
  147.     </nobr>
  148.   </td></tr>
  149.  
  150. <%--/// Number fields ///--%>
  151.        <% } else if (field.isNumberField()) { %>
  152.     <tr><td class="e8">
  153.     <%=label.get(fieldName, projectId)%></td>
  154.     <td class="f1"><input name="<%=fieldName%>" size=60 maxlength=255>
  155.     </td></tr>
  156.  
  157. <%--/// Text Input and area fields ///--%>
  158.        <% } else if (field.isTextField()) { %>
  159.     <tr><td class="e8">
  160.     <%=label.get(fieldName, projectId)%>
  161.     <font color=red>²</font></td>
  162.     <td class="f1"><input name="<%=fieldName%>" size=60 maxlength=255>
  163.     </td></tr>
  164.     <input type="hidden" name="<%=fieldName%>_type" value="text">
  165.  
  166. <%--/// All Other Menu fields ///--%>
  167.        <% } else if ((optionList=field.getValue()) != null) { %>
  168.     <tr><td class="e8">
  169.     <%=label.get(fieldName, projectId)%></td>
  170.     <td class="f1"><select name=<%=fieldName%> size=3 multiple style="width: 400px;">
  171.         <%=ListMaker.makeOptionList(optionList, getOptions(filter, fieldName)) %>
  172.         </select> </td></tr>
  173. <% }}} %>
  174.