eb6aee74062fa3dc94999078eae8a240ff3dfe3e
[kivitendo-erp.git] / templates / webpages / custom_variable_config / form.html
1 [%- USE HTML -%][%- USE LxERP -%][%- USE L -%][%- USE T8 -%]<h1>[% HTML.escape(title) %]</h1>
2
3 <form action="controller.pl" method="post">
4  [%- L.hidden_tag("id", SELF.config.id) %]
5
6  <p>
7   <table>
8    <tr>
9     <td align="right">[% 'Module' | $T8 %]</td>
10     <td>[%- L.select_tag('module', SELF.modules, value_key='module', title_key='description', default=SELF.module, onchange="update_ic_rows();") %]</td>
11    </tr>
12
13    <tr>
14     <td align="right">[% 'Variable Name' | $T8 %]<sup><span class="small-text">(1)</span></sup></td>
15     <td>[%- L.input_tag("config.name", SELF.config.name, class='initial_focus') %]</td>
16    </tr>
17
18    <tr>
19     <td align="right">[% 'Variable Description' | $T8 %]<sup><span class="small-text">(2)</span></sup></td>
20     <td>[%- L.input_tag("config.description", SELF.config.description) %]</td>
21    </tr>
22
23    <tr>
24     <td align="right">[% 'Type' | $T8 %]<sup><span class="small-text">(3)</span></sup></td>
25     <td>[% L.select_tag("config.type", SELF.translated_types, value_key='type', title_key='translation', default=SELF.config.type) %]</td>
26    </tr>
27
28    <tr>
29     <td align="right">[% 'Default value' | $T8 %]<sup><span class="small-text">(4)</span></sup></td>
30     <td>[%- L.input_tag("config.default_value", SELF.config.type == 'number' ? LxERP.format_amount(SELF.config.default_value, 2) : SELF.config.default_value) %]</td>
31    </tr>
32
33    <tr>
34     <td align="right">[% 'Options' | $T8 %]<sup><span class="small-text">(5)</span></sup></td>
35     <td>[%- L.input_tag("config.options", SELF.config.options) %]</td>
36    </tr>
37
38    <tr>
39     <td align="right">[% 'Is Searchable' | $T8 %]</td>
40     <td>
41      [% L.radio_button_tag('config.searchable', value='1', id='config_searchable_1', label=LxERP.t8('Yes'), checked=(SELF.config.searchable ?  1 : '')) %]
42      [% L.radio_button_tag('config.searchable', value='0', id='config_searchable_0', label=LxERP.t8('No'),  checked=(SELF.config.searchable ? '' :  1)) %]
43     </td>
44    </tr>
45
46    <tr>
47     <td align="right">[% 'Includeable in reports' | $T8 %]</td>
48     <td>
49      [% L.radio_button_tag('config.includeable', value='1', id='config_includeable_1', label=LxERP.t8('Yes'), checked=(SELF.config.includeable ?  1 : ''), onclick='update_included_by_default()') %]
50      [% L.radio_button_tag('config.includeable', value='0', id='config_includeable_0', label=LxERP.t8('No'),  checked=(SELF.config.includeable ? '' :  1), onclick='update_included_by_default()') %]
51     </td>
52    </tr>
53
54    <tr>
55     <td align="right">[% 'Included in reports by default' | $T8 %]</td>
56     <td>
57      [% SET disabled = SELF.config.includeable ? '' : 'disabled' %]
58      [% L.radio_button_tag('config.included_by_default', value='1', id='config_included_by_default_1', label=LxERP.t8('Yes'), checked=(SELF.config.included_by_default ?  1 : ''), disabled=disabled) %]
59      [% L.radio_button_tag('config.included_by_default', value='0', id='config_included_by_default_0', label=LxERP.t8('No'),  checked=(SELF.config.included_by_default ? '' :  1), disabled=disabled) %]
60     </td>
61    </tr>
62
63    <tr data-show-for="IC"[% UNLESS SELF.module == 'IC' %] style="display: none;"[% END %]>
64     <td align="right">[% 'Editable' | $T8 %]<sup><span class="small-text">(6)</span></sup></td>
65     <td>
66      [% L.radio_button_tag('config.flag_editable', value='1', id='config.flag_editable_1', label=LxERP.t8('Yes'), checked=(SELF.flags.editable ?  1 : '')) %]
67      [% L.radio_button_tag('config.flag_editable', value='0', id='config.flag_editable_0', label=LxERP.t8('No'),  checked=(SELF.flags.editable ? '' :  1)) %]
68     </td>
69    </tr>
70    <tr data-show-for="IC"[% UNLESS SELF.module == 'IC' %] style="display: none;"[% END %]>
71     <td align="right">[% 'Deactivate by default' | $T8 %]<sup><span class="small-text">(7)</span></sup></td>
72     <td>
73      [% L.radio_button_tag('config.flag_defaults_to_invalid', value='1', id='config.flag_defaults_to_invalid_1', label=LxERP.t8('Yes'), checked=(SELF.flags.defaults_to_invalid ?  1 : '')) %]
74      [% L.radio_button_tag('config.flag_defaults_to_invalid', value='0', id='config.flag_defaults_to_invalid_0', label=LxERP.t8('No'),  checked=(SELF.flags.defaults_to_invalid ? '' :  1)) %]
75     </td>
76    </tr>
77    <tr data-show-for="IC"[% UNLESS SELF.module == 'IC' %] style="display: none;"[% END %]>
78     <td align="right">[% 'Filter by Partsgroups' | $T8 %]</td>
79     <td>
80      [% L.radio_button_tag('config.flag_partsgroup_filter', value='1', id='config_flag_partsgroup_filter_1', label=LxERP.t8('Yes'), checked=(SELF.flags.partsgroup_filter ?  1 : ''), onclick='update_pg_filter_row()') %]
81      [% L.radio_button_tag('config.flag_partsgroup_filter', value='0', id='config_flag_partsgroup_filter_0', label=LxERP.t8('No'),  checked=(SELF.flags.partsgroup_filter ? '' :  1), onclick='update_pg_filter_row()') %]
82     </td>
83    </tr>
84    <tr data-show-for="IC+PGFILTER"[% UNLESS (SELF.module == 'IC' && SELF.flags.partsgroup_filter) %] style="display: none;"[% END %]>
85     <td></td>
86     <td>
87   [% L.select_tag('config.partsgroups[]',
88                       all_partsgroups,
89                       id                => "partsgroups",
90                       value_key         => "id",
91                       title_key         => "partsgroup",
92                       default           => SELF.config.partsgroups,
93                       default_value_key => "id",
94                       multiple          => 1) %]
95       [% L.multiselect2side("partsgroups",
96                             labelsx => LxERP.t8("All partsgroups"),
97                             labeldx => LxERP.t8("Partsgroups where variables are shown")) %]
98     </td>
99    </tr>
100   </table>
101  </p>
102
103  <p>
104   [% L.hidden_tag("action", "CustomVariableConfig/dispatch") %]
105   [% L.submit_tag("action_" _  (SELF.config.id ? "update" : "create"), LxERP.t8('Save'), onclick="return check_prerequisites();") %]
106   [%- IF SELF.config.id %]
107    [% L.submit_tag("action_create", LxERP.t8('Save as new'), onclick="return check_prerequisites();") %]
108    [% L.submit_tag("action_destroy", LxERP.t8('Delete'), confirm=LxERP.t8('Are you sure?')) %]
109   [%- END %]
110   <a href="[% SELF.url_for(action='list', module=SELF.module) %]">[%- LxERP.t8("Cancel") %]</a>
111  </p>
112
113  <hr>
114
115  <h3>[% 'Annotations' | $T8 %]</h3>
116
117  <p>
118   (1) [% 'The variable name must only consist of letters, numbers and underscores. It must begin with a letter. Example: send_christmas_present' | $T8 %]
119  </p>
120
121  <p>
122   (2) [% 'The description is shown on the form. Chose something short and descriptive.' | $T8 %]
123  </p>
124  <p>
125   (3) [% 'For type "customer" the perl module JSON is required. Please check this on system level: $ ./scripts/installation_check.pl' | $T8 %]
126  </p>
127
128  <p>
129   (4) [% 'The default value depends on the variable type:' | $T8 %]
130   <br>
131   <ul>
132    <li>[%- 'Text, text field and number variables: The default value will be used as-is.' | $T8 %]</li>
133    <li>[%- 'Boolean variables: If the default value is non-empty then the checkbox will be checked by default and unchecked otherwise.' | $T8 %]</li>
134    <li>[%- 'Date and timestamp variables: If the default value equals \'NOW\' then the current date/current timestamp will be used. Otherwise the default value is copied as-is.' | $T8 %]</li>
135   </ul>
136  </p>
137
138  <p>
139   (5) [% 'The available options depend on the varibale type:' | $T8 %]
140   <br>
141   <ul>
142    <li>[%- 'Text variables: \'MAXLENGTH=n\' sets the maximum entry length to \'n\'.' | $T8 %]</li>
143    <li>[%- 'Text field variables: \'WIDTH=w HEIGHT=h\' sets the width and height of the text field. They default to 30 and 5 respectively.' | $T8 %]</li>
144    <li>[%- 'Number variables: \'PRECISION=n\' forces numbers to be shown with exactly n decimal places.' | $T8 %]</li>
145    <li>[%- 'Selection fields: The option field must contain the available options for the selection. Options are separated by \'##\', for example \'Early##Normal##Late\'.' | $T8 %]</li>
146   </ul>
147   <br>
148   [% 'Other values are ignored.' | $T8 %]
149  </p>
150
151  <p data-show-for="IC"[% UNLESS SELF.module == 'IC' %] style="display: none;"[% END %]>
152   (6)
153
154   [%- 'A variable marked as \'editable\' can be changed in each quotation, order, invoice etc.' | $T8 %]
155
156   [% 'Otherwise the variable is only available for printing.' | $T8 %]
157  </p>
158
159  <p data-show-for="IC"[% UNLESS SELF.module == 'IC' %] style="display: none;"[% END %]>
160   (7)
161
162   [%- 'A variable marked as \'Deactivate by default\' isn\'t automatically added to all articles, and has to be explicitly added for each desired article in its master data tab. Only then can the variable be used for that article in the records.' | $T8 %]
163  </p>
164
165 </form>
166
167 <script type="text/javascript">
168 <!--
169 function update_included_by_default() {
170   $('INPUT[name="config.included_by_default"]').prop('disabled', !$('#config_includeable_1').prop('checked'));
171 }
172
173 function update_ic_rows() {
174   $('[data-show-for="IC"]').toggle($('#module').val() === "IC");
175   $('[data-show-for="IC+PGFILTER"]').toggle($('#module').val() === "IC" && $('#config_flag_partsgroup_filter_1').prop('checked'));
176 }
177
178 function update_pg_filter_row() {
179   $('[data-show-for="IC+PGFILTER"]').toggle($('#module').val() === "IC" && $('#config_flag_partsgroup_filter_1').prop('checked'));
180 }
181
182 function check_prerequisites() {
183   if (($('#config_type').val() === "select") && ($('#config_options').val() === "")) {
184     alert(kivi.t8('The option field is empty.'));
185     return false;
186   }
187
188   if ($('#config_name').val() === "") {
189     alert(kivi.t8('The name is missing.'));
190     return false;
191   }
192
193   if (!$('#config_name').val().match(/^[a-z][a-z0-9_]*$/i)) {
194     alert(kivi.t8('The name must only consist of letters, numbers and underscores and start with a letter.'));
195     return false;
196   }
197
198   if ($('#config_description').val() === "") {
199     alert(kivi.t8('The description is missing.'));
200     return false;
201   }
202
203   return true;
204 }
205 -->
206 </script>