Historiensuchmaschine von date Magic befreit
authorSven Schöling <s.schoeling@linet-services.de>
Thu, 16 Aug 2012 16:55:09 +0000 (18:55 +0200)
committerSven Schöling <s.schoeling@linet-services.de>
Thu, 16 Aug 2012 16:55:09 +0000 (18:55 +0200)
War ursprünglich Teil von 46bc75c8079099de22ccbc6281b04f42ade67f1a.
Das Javascript hatte noch ein paar Bugs, die sollten damit behoben sein.

templates/webpages/common/search_history.html

index bacb711..cc8074d 100644 (file)
 [%- USE T8 %]
+[%- USE L %]
 [% USE HTML %]<style type="text/css">@import url(js/jscalendar/calendar-win2k-1.css);</style>
 <script type="text/javascript" src="js/jscalendar/calendar.js"></script>
 <script type="text/javascript" src="js/jscalendar/lang/calendar-de.js"></script>
 <script type="text/javascript" src="js/jscalendar/calendar-setup.js"></script>
 
+<h1>[% 'history search engine' | $T8 %]</h1>
+
 <form method="post" action="am.pl">
 
 <input type="hidden" name="action" value="show_am_history">
 
-  <table>
-    <tr>
-      <th class ="listtop">[% 'history search engine' | $T8 %]</th>
-      </th>
-    </tr>
-    <tr>
-      <td>
-        <script type="text/javascript">
-          <!--
-                    function uncheckOther(id) {
-            if(!(
-                (document.getElementById('non-deleted').checked == false)
-                &&
-                (document.getElementById('both').checked == false)
-                &&
-                (document.getElementById('deleted').checked == false)
-              )) {
-                if(id == "deleted") {
-                  document.getElementById('non-deleted').checked = false;
-                  document.getElementById('both').checked = false;
-                }
-                if(id == "non-deleted") {
-                  document.getElementById('deleted').checked = false;
-                  document.getElementById('both').checked = false;
-                }
-                if(id == "both") {
-                  document.getElementById('non-deleted').checked = false;
-                  document.getElementById('deleted').checked = false;
-                }
-            }
-          }
-
-          var defaults = new Array('SAVED', 'DELETED', 'ADDED', 'PAYMENT POSTED', 'POSTED', 'POSTED AS NEW', 'SAVED FOR DUNNING', 'DUNNING STARTED', 'PRINTED');
-          var translated = new Object();
-          translated['SAVED'] = '[% 'SAVED' | $T8 %]';
-          translated['DELETED'] = '[% 'DELETED' | $T8 %]';
-          translated['ADDED'] = '[% 'ADDED' | $T8 %]';
-          translated['PAYMENT POSTED'] = '[% 'PAYMENT POSTED' | $T8 %]';
-          translated['POSTED'] = '[% 'POSTED' | $T8 %]';
-          translated['POSTED AS NEW'] = '[% 'POSTED AS NEW' | $T8 %]'
-          translated['SAVED FOR DUNNING'] = '[% 'SAVED FOR DUNNING' | $T8 %]';
-          translated['DUNNING STARTED'] = '[% 'DUNNING STARTED' | $T8 %]';
-          translated['PRINTED'] = '[% 'PRINTED' | $T8 %]';
-
-          var jscalender = "<table valign=\"top\">"
-                  + "<tr><td colspan=\"2\"><b>[% 'Period' | $T8 %]:&nbsp;</b></td></tr>"
-                  + "<tr><td>[% 'from (time)' | $T8 %]:&nbsp;"
-                  + "<input name=\"fromdate\" id=\"fromdate\" size=\"11\" title=\"[% HTML.escape(myconfig_dateformat) %]\" value=\"[% HTML.escape(fromdate) %]\">"
-                  + "<input type=\"button\" name=\"fromdate\" id=\"trigger1\" value=\"?\">"
-                  + "&nbsp;</td><td>[% 'to (time)' | $T8 %]:&nbsp;"
-                  + "<input name=\"todate\" id=\"todate\" size=\"11\" title=\"[% HTML.escape(myconfig_dateformat) %]\" value=\"[% HTML.escape(todate) %]\">"
-                  + "<input type=\"button\" name=\"todate\" id=\"trigger2\" value=\"?\"></td></tr></table>";
-          var mitarbeiter = "<table valign=\"top\">"
-                  + "<tr><td><b>Mitarbeiter:</b>&nbsp;</td>"
-                  + "<td><input type='text' name='mitarbeiter' id='mitarbeiter'></td>"
-                  + "</tr></table>";
-
-          var tempString = "";
-          function addForm(last, remove) {
-            if(last == "INIT") {
-              tempString = "<select id='selectForm'><option></option>";
-              for(i=0;i<defaults.length;i++) {
-                tempString += "\<option value\=\'" + defaults[i] + "\'\ onClick=\"javascript:addForm(\'" + defaults[i] + "\', " + i + ");\">" + translated[defaults[i]] + "\<\/option\>" + "\n";
-              }
-              tempString += "</select>";
-              document.getElementById('selectEmployee').innerHTML = mitarbeiter;
-              document.getElementById('selectDate').innerHTML = jscalender;
-              document.getElementById('selectTable').innerHTML = tempString;
-
-              Calendar.setup(
-                    {
-                          inputField : "fromdate",
-                          ifFormat :"%d.%m.%Y",
-                          align : "BL",
-                          button : "trigger1"
-                      });
-
-                    Calendar.setup(
-                    {
-                          inputField : "todate",
-                          ifFormat :"%d.%m.%Y",
-                          align : "BL",
-                          button : "trigger2"
-                    });
-            }
-            else {
-              defaults.splice(remove,1);
-              document.getElementById('inputText').innerHTML += ((document.getElementById('inputText').innerHTML == "") ? ("<b>[%- 'You\'ve already chosen the following limitations:' | $T8 %]</b><br>") : ("<br>")) + translated[last];
-              if(defaults.length > 0) {
-                document.getElementById('einschraenkungen').value += ((document.getElementById('einschraenkungen').value == "") ? ("") : (",")) + last;
-                tempString = "<select id='selectForm'><option></option>";
-                for(i=0;i<defaults.length;i++) {
-                  tempString += "\<option value\=\'" + defaults[i] + "\'\ onClick=\"javascript:addForm(\'" + defaults[i] + "\', " + i + ");\">" + translated[defaults[i]] + "\<\/option\>" + "\n";
-                }
-                tempString += "</select>";
-                document.getElementById('selectTable').innerHTML = tempString;
-              }
-              else {
-                document.getElementById('selectTable').innerHTML = "";
-              }
-            }
-          }
-
-          function resetAll() {
-            document.getElementById('selectTable').innerHTML = "<a href=\"javascript:addForm('INIT')\">[% 'Yes' | $T8 %]";
-            document.getElementById('inputText').innerHTML = "";
-          }
-          //-->
-        </script>
-        <table>
-          <tr>
-            <td>
-              [% '<b>What</b> do you want to look for?' | $T8 %]:
-            </td>
-            <td>
-              <select name="what2search" id="what2search">
-                <option name="Artikelnummer" value="Artikelnummer" id="Artikelnummer">[% 'Part Number' | $T8 %]</option>
-                <option name="Kundennummer" value="Kundennummer" id="Kundennummer">[% 'Customer Number' | $T8 %]</option>
-                <option name="Lieferantennummer" value="Lieferantennummer" id="Lieferantennummer">[% 'Vendor Number' | $T8 %]</option>
-                <option name="Projektnummer" value="Projektnummer" id="Projektnummer">[% 'Project Number' | $T8 %]</option>
-                <option name="Buchungsnummer" value="Buchungsnummer" id="Buchungsnummer">[% 'ID' | $T8 %]</option>
-                <option name="Eingangsrechnungnummer" value="Eingangsrechnungnummer" id="Eingangsrechnungnummer">[% 'Incoming invoice number' | $T8 %]</option>
-                <option name="Ausgangsrechnungnummer" value="Ausgangsrechnungnummer" id="Ausgangsrechnungnummer">[% 'Sales invoice number' | $T8 %]</option>
-                <option name="Mahnungsnummer" value="Mahnungsnummer" id="Mahnungsnummer">[% 'Dunning number' | $T8 %]</option>
+<table>
+  <tr>
+    <td>[% '<b>What</b> do you want to look for?' | $T8 %]:</td>
+    <td>
+      <select name="what2search" id="what2search">
+        <option name="Artikelnummer" value="Artikelnummer" id="Artikelnummer">[% 'Part Number' | $T8 %]</option>
+        <option name="Kundennummer" value="Kundennummer" id="Kundennummer">[% 'Customer Number' | $T8 %]</option>
+        <option name="Lieferantennummer" value="Lieferantennummer" id="Lieferantennummer">[% 'Vendor Number' | $T8 %]</option>
+        <option name="Projektnummer" value="Projektnummer" id="Projektnummer">[% 'Project Number' | $T8 %]</option>
+        <option name="Buchungsnummer" value="Buchungsnummer" id="Buchungsnummer">[% 'ID' | $T8 %]</option>
+        <option name="Eingangsrechnungnummer" value="Eingangsrechnungnummer" id="Eingangsrechnungnummer">[% 'Incoming invoice number' | $T8 %]</option>
+        <option name="Ausgangsrechnungnummer" value="Ausgangsrechnungnummer" id="Ausgangsrechnungnummer">[% 'Sales invoice number' | $T8 %]</option>
+        <option name="Mahnungsnummer" value="Mahnungsnummer" id="Mahnungsnummer">[% 'Dunning number' | $T8 %]</option>
+      </select>
+    </td>
+  </tr>
+  <tr>
+    <td>[% 'What <b>term</b> you are looking for?' | $T8 %]</td>
+    <td><input type="text" name="searchid" id="searchid" value="[% searchid  | html %]"></td>
+  </tr>
+  <tr>
+    <td valign="top">[% 'Do you want to <b>limit</b> your search?' | $T8 %]</td>
+    <td>
+      <table>
+        <tr>
+          <td>
+            <div id="initForm">
+              <a id='show_extended_options' href='#'>[% 'Yes' | $T8 %]</a>
+            </div>
+            <div id="selectTable" style="display:none;">
+              <select id='selectForm'>
               </select>
-            </td>
-          </tr>
-          <tr>
-            <td>
-             [% 'What <b>term</b> you are looking for?' | $T8 %]
-            </td>
-            <td>
-              <input type="text" name="searchid" id="searchid" value="[% HTML.escape(searchid) %]">
-            </td>
-          </tr>
-          <tr>
-            <td valign="top">
-             [% 'Do you want to <b>limit</b> your search?' | $T8 %]
-            </td>
-            <td>
-              <table valign="top" cellpadding="0" marginheight="0" marginwidth="0" cellspacing="0" topmargin="0" leftmargin="0">
-                <tr>
-                  <td>
-                    <div id="selectTable"><a href="javascript:addForm('INIT')">[% 'Yes' | $T8 %]</a></div>
-                    <div id="inputText"></div>
-                  </td>
-                </tr>
-                <tr>
-                  <td>
-                    <div id="selectEmployee"></div>
-                  </td>
-                </tr>
-                <tr>
-                  <td>
-                    <div id="selectDate"></div>
-                  </td>
-                </tr>
-              </table>
-              <input type="hidden" name="einschraenkungen" id="einschraenkungen" value="">
-            </td>
-          </tr>
-          </tr>
-          <tr>
-            <td colspan="6">
-              <input type="submit" class="submit" value="[% 'submit' | $T8 %]">
-              <input type="reset" class="submit" value="[% 'reset' | $T8 %]" onClick="javascript:resetAll();">
-            </td>
-            <td>
-            </td>
-          </tr>
-        </table>
-      </td>
-    </tr>
-  </table>
+            </div>
+            <div id="inputHead" style="display:none;"><b>[% 'You\'ve already chosen the following limitations:' | $T8 %]</b></div>
+            <div id="inputText" style="display:none;"></div>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <div id="selectEmployee" style="display:none;">
+              <b>Mitarbeiter:</b>&nbsp; <input type="text" name="mitarbeiter" id="mitarbeiter">
+            </div>
+          </td>
+        </tr>
+        <tr>
+          <td>
+            <div id="selectDate" style="display:none;">
+                  <b>[% 'Period' | $T8 %]:&nbsp;</b>
+                     [% 'from (time)' | $T8 %]:&nbsp; [% L.date_tag('fromdate', todate) %]
+                     [% 'to (time)' | $T8 %]:&nbsp; [% L.date_tag('todate', todate) %]
+            </div>
+          </td>
+        </tr>
+      </table>
+      <input type="hidden" name="einschraenkungen" id="einschraenkungen" value="">
+    </td>
+  </tr>
+</table>
+
+<hr>
+<input type="submit" class="submit" value="[% 'submit' | $T8 %]">
+<input type="reset" class="submit" value="[% 'reset' | $T8 %]" id='reset_button'>
+
 </form>
+
+<script type="text/javascript">
+  <!--
+  var defaults = ['SAVED', 'DELETED', 'ADDED', 'PAYMENT POSTED', 'POSTED', 'POSTED AS NEW', 'SAVED FOR DUNNING', 'DUNNING STARTED', 'PRINTED'];
+  var available;
+  var selected;
+  var translated = {
+    'SAVED'             : '[% 'SAVED' | $T8 %]',
+    'DELETED'           : '[% 'DELETED' | $T8 %]',
+    'ADDED'             : '[% 'ADDED' | $T8 %]',
+    'PAYMENT POSTED'    : '[% 'PAYMENT POSTED' | $T8 %]',
+    'POSTED'            : '[% 'POSTED' | $T8 %]',
+    'POSTED AS NEW'     : '[% 'POSTED AS NEW' | $T8 %]',
+    'SAVED FOR DUNNING' : '[% 'SAVED FOR DUNNING' | $T8 %]',
+    'DUNNING STARTED'   : '[% 'DUNNING STARTED' | $T8 %]',
+    'PRINTED'           : '[% 'PRINTED' | $T8 %]',
+  };
+
+  function addForm(index) {
+    $('#inputHead').show();
+    selected.push(available.splice(index, 1));
+    $('#inputText').html($(selected).map(function(){ return translated[this]; }).get().join('<br>'));
+    $('#einschraenkungen').val(selected.join(','));
+
+    showForm();
+  }
+
+  function showForm() {
+    $('#selectForm').empty();
+    $('<option/>').appendTo('#selectForm');
+    $(available).map(function(){
+      $('<option/>').val(this).text(translated[this]).click(function(){ addForm(this) }).appendTo('#selectForm');
+    });
+  }
+
+  function resetAll() {
+    available = defaults.slice(0);
+    selected  = [];
+    initForm();
+
+    $('#inputForm').empty();
+    $('#inputText').html('');
+    $('#selectTable, #inputHead, #inputText, #selectEmployee, #selectDate').hide();
+    $('#initForm').show();
+  }
+
+  function initForm() {
+    showForm();
+
+    $('#selectTable, #inputText, #selectEmployee, #selectDate').show();
+    $('#initForm').hide();
+  }
+
+  $(function(){
+    resetAll();
+    $('#show_extended_options').click(initForm);
+    $('#reset_button').click(resetAll);
+  });
+  //-->
+</script>
+
+</body>
+</html>