Bug 10853: Add DB field export_format.type ('marc' or 'sql').
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / tools / csv-profiles.tt
index 2d98836..9c58751 100644 (file)
@@ -7,6 +7,30 @@ function reloadPage(p) {
 }
      $(document).ready(function() {
         $('#csvexporttabs').tabs();
+
+        $("#profile_type").find("option:first").attr("selected", "selected");
+        $("#csvnew").find("li.marc_specific").show();
+        $("#csvnew").find("li.sql_specific").hide();
+
+        $("#profile_type").change(function(){
+            if ( $(this).find("option:selected").val() == "marc" ) {
+                $("#csvnew li.marc_specific").show();
+                $("#csvnew li.sql_specific").hide();
+            } else {
+                $("#csvnew li.marc_specific").hide();
+                $("#csvnew li.sql_specific").show();
+            }
+        });
+        $("#modify_profile_type").change(function(){
+            if ( $(this).find("option:selected").val() == "marc" ) {
+                $("#csvedit li.marc_specific").show();
+                $("#csvedit li.sql_specific").hide();
+            } else {
+                $("#csvedit li.marc_specific").hide();
+                $("#csvedit li.sql_specific").show();
+            }
+        });
+        $("#modify_profile_type").change();
      });
 //]]>
 </script>
@@ -53,9 +77,18 @@ function reloadPage(p) {
 
                                             <form action="/cgi-bin/koha/tools/csv-profiles.pl" method="post">
                                                <fieldset class="rows">
-                                                   <ol><li><label for="profile_name" class="required">Profile name: </label>
+                          <ol>
+                            <li><label for="profile_name" class="required">Profile name: </label>
                                                    <input type="text" id="profile_name" name="profile_name" /></li>
 
+                            <li>
+                              <label for="profile_type" class="required">Profile type: </label>
+                              <select id="profile_type" name="profile_type">
+                                <option value="marc" selected="selected">MARC</option>
+                                <option value="sql">SQL</option>
+                              </select>
+                            </li>
+
                                                    <li><label for="profile_description">Profile description: </label>
                                                    <textarea cols="50" rows="2" name="profile_description" id="profile_description"></textarea></li>
 
@@ -72,7 +105,7 @@ function reloadPage(p) {
                                                    </select>
                             </li>
 
-                                                   <li><label for="new_field_separator">Field separator: </label>
+                            <li class="marc_specific"><label for="new_field_separator">Field separator: </label>
                                                    <select name="field_separator" id="new_field_separator">
                                                        <option value=":">Colon (:)</option>
                                                        <option value=",">Comma (,)</option>
@@ -85,7 +118,7 @@ function reloadPage(p) {
                                                    </select>
                             </li>
 
-                                                   <li><label for="new_subfield_separator">Subfield separator: </label>
+                                                   <li class="marc_specific"><label for="new_subfield_separator">Subfield separator: </label>
                                                    <select name="subfield_separator" id="new_subfield_separator">
                                                        <option value=":">Colon (:)</option>
                                                        <option value=",">Comma (,)</option>
@@ -98,10 +131,10 @@ function reloadPage(p) {
                                                    </select>
                             </li>
                                        
-                                                   <li><label for="new_encoding">Encoding: </label>
+                                                   <li class="marc_specific"><label for="new_encoding">Encoding: </label>
                                                    <select name="encoding" id="new_encoding">
                                                        [% FOREACH encoding IN encodings %]
-                                                               [% IF ( encoding == 'utf8' ) %]
+                                [% IF ( encoding.encoding == 'utf8' ) %]
                                                                        <option selected="selected">[% encoding.encoding %]</option>
                                                                [% ELSE %]
                                                                        <option>[% encoding.encoding %]</option>
@@ -110,12 +143,19 @@ function reloadPage(p) {
                                                    </select></li>
 
 
-                            <li><label for="new_profile_content">Profile MARC fields: </label>
-                                                   <textarea cols="50" rows="2" name="profile_content" id="new_profile_content"></textarea>
+                            <li class="marc_specific"><label for="new_profile_marc_content">Profile MARC fields: </label>
+                                                   <textarea cols="50" rows="2" name="profile_marc_content" id="new_profile_marc_content"></textarea>
                                                    <p>You have to define which fields or subfields you want to export, separated by pipes.</p>
                             <p>You can also use your own headers (instead of the ones from Koha) by prefixing the field number with an header, followed by the equal sign.</p>
                                                    <p>Example: Personal name=200|Entry element=210$a|300|009</p>
                                                    </li>
+                            <li class="sql_specific">
+                              <label for="new_profile_sql_content">Profile SQL fields: </label>
+                              <textarea cols="50" rows="2" name="profile_sql_content" id="new_profile_sql_content"></textarea>
+                              <p>You have to define which fields you want to export, separated by pipes.</p>
+                              <p>You can also use your own headers (instead of the ones from Koha) by prefixing the field name with an header, followed by the equal sign.</p>
+                              <p>Example: Name=subscription.name|Title=subscription.title|Issue number=serial.serialseq</p>
+                            </li>
                                                    </ol>
                                                </fieldset>
                                                <fieldset class="action"><input type="hidden" name="action" value="create" />
@@ -129,7 +169,8 @@ function reloadPage(p) {
 
                                            <form action="/cgi-bin/koha/tools/csv-profiles.pl" method="post">
                                                <fieldset class="rows">
-                                                   <ol><li><label for="modify_profile_name">Profile name: </label>
+                            <ol>
+                            <li><label for="modify_profile_name">Profile name: </label>
                                                    <select id="modify_profile_name" name="profile_name" onchange="javascript:reloadPage(this)">
                                                        <option value="0">-- Choose One --</option>
                                                        [% FOREACH existing_profile IN existing_profiles %]
@@ -141,6 +182,19 @@ function reloadPage(p) {
                                                        [% END %]
                                                    </select></li>
 
+                            <li>
+                              <label for="modify_profile_type">Profile type: </label>
+                              <select id="modify_profile_type" name="profile_type">
+                                <option value="marc">MARC</option>
+                                [% IF selected_profile_type == "sql" %]
+                                  <option value="sql" selected="selected">SQL</option>
+                                [% ELSE %]
+                                  <option value="sql">SQL</option>
+                                [% END %]
+                              </select>
+                            </li>
+
+
                                                    <li><label for="modify_profile_description">Profile description: </label>
                                                    <textarea cols="50" rows="2" name="profile_description" id="modify_profile_description">[% selected_profile_description %]</textarea></li>
 
@@ -184,7 +238,7 @@ function reloadPage(p) {
                                                                [% END %]
                             </select></li>
 
-                                                   <li><label for="field_separator">Field separator: </label>
+                                                   <li class="marc_specific"><label for="field_separator">Field separator: </label>
                                                    <select name="field_separator" id="field_separator">
                                 <option value=":">Colon (:)</option>
 
@@ -231,7 +285,7 @@ function reloadPage(p) {
                                                    </select></li>
 
 
-                                                   <li><label for="subfield_separator">Subfield separator: </label>
+                                                   <li class="marc_specific"><label for="subfield_separator">Subfield separator: </label>
                                                    <select name="subfield_separator" id="subfield_separator">
                                 <option value=":">Colon (:)</option>
 
@@ -278,10 +332,10 @@ function reloadPage(p) {
        
                                                    </select></li>
 
-                                                   <li><label for="encoding">Encoding: </label>
+                                                   <li class="marc_specific"><label for="encoding">Encoding: </label>
                                                    <select name="encoding" id="encoding">
                                                        [% FOREACH encoding IN encodings %]
-                                                           [% IF ( selected_encoding == encoding ) %]
+                                [% IF ( selected_encoding == encoding.encoding ) %]
                                                            <option selected="selected">[% encoding.encoding %]</option>
                                                            [% ELSE %]
                                                            <option>[% encoding.encoding %]</option>
@@ -289,8 +343,13 @@ function reloadPage(p) {
                                                        [% END %]
                                                    </select></li>
 
-                            <li><label for="modify_profile_content">Profile MARC fields: </label>
-                                                   <textarea cols="50" rows="2" name="profile_content" id="modify_profile_content">[% selected_profile_marcfields %]</textarea></li>
+                            <li class="marc_specific"><label for="modify_profile_marc_content">Profile MARC fields: </label>
+                                                   <textarea cols="50" rows="2" name="profile_marc_content" id="modify_profile_marc_content">[% selected_profile_content %]</textarea></li>
+
+                            <li class="sql_specific">
+                              <label for="modify_profile_sql_content">Profile SQL fields: </label>
+                              <textarea cols="50" rows="2" name="profile_sql_content" id="modify_profile_sql_content">[% selected_profile_content %]</textarea>
+                            </li>
 
                                                   <li class="radio"> <label for="delete">Delete selected profile ?</label>
                                                    <input type="checkbox" name="delete" id="delete" /></li>