Merge branch 'b-3.6.1' of ../kivitendo-erp_20220811
[kivitendo-erp.git] / templates / webpages / record_links / add_filter.html
1 [%- USE L -%][%- USE LxERP -%][%- USE JavaScript -%]
2 [%- SET style='width: 500px' %]
3 <h1>[%- LxERP.t8("Add link: select records to link with") %]</h1>
4
5
6 <form method="post" action="controller.pl" id="record_links_add_filter_form">
7  [% L.hidden_tag('object_model',   SELF.object_model) %]
8  [% L.hidden_tag('object_id',      SELF.object_id) %]
9
10  <table>
11   <tr>
12    <td>[%- LxERP.t8("Link to") %]:</td>
13    <td>[% L.select_tag('link_type', LINK_TYPES, default=DEFAULT_LINK_TYPE, style=style, id='record_links_add_filter_link_type') %]</td>
14   </tr>
15
16   <tr>
17    <td>[%- LxERP.t8("Link direction") %]:</td>
18    <td>[% L.select_tag('link_direction',
19                        [ [ 'from', LxERP.t8("The link target to add has been created from the existing record."), ],
20                          [ 'to',   LxERP.t8("The existing record has been created from the link target to add."), ], ],
21                        style=style) %]</td>
22   </tr>
23
24   <tr>
25    <td>[%- LxERP.t8("Record number") %]:</td>
26    <td>[% L.input_tag('number', '', style=style) %]</td>
27   </tr>
28
29   <tr>
30    <td>[%- LxERP.t8("Customer/Vendor Number") %]:</td>
31    <td>[% L.input_tag('vc_number', is_sales ? SELF.object.customer.customernumber : SELF.object.vendor.vendornumber, style=style) %]</td>
32   </tr>
33
34   <tr>
35    <td>[%- LxERP.t8("Customer/Vendor Name") %]:</td>
36    <td>[% L.input_tag('vc_name', is_sales ? SELF.object.customer.name : SELF.object.vendor.name, style=style) %]</td>
37   </tr>
38
39   <tr id="record_links_add_filter_project_row">
40    <td>[%- LxERP.t8("Project") %]:</td>
41    <td>[% L.select_tag('globalproject_id', PROJECTS, default=SELF.object.globalproject_id, with_empty=1, style=style) %]</td>
42   </tr>
43
44   <tr>
45    <td><span id="record_links_add_filter_title">[%- LxERP.t8("Transaction description") %]</span>:</td>
46    <td>[% L.input_tag('transaction_description', '', style=style) %]</td>
47   </tr>
48  </table>
49
50  <p>
51   [% L.button_tag('filter_record_links()', LxERP.t8("Search")) %]
52   [% L.button_tag('add_selected_record_links()', LxERP.t8("Add links"), id='add_selected_record_links_button', disabled=1) %]
53   [% L.button_tag('$("#record_links_add_filter_form").resetForm()', LxERP.t8('Reset')) %]
54   <a href="#" onclick="$('#record_links_add').dialog('close');">[% LxERP.t8("Cancel") %]</a>
55  </p>
56
57  <hr>
58
59  <div id="record_list_filtered_list"></div>
60
61 </form>
62
63 <script type="text/javascript">
64 <!--
65 $(function() {
66   $('#record_links_add input[name=vc_name]').focus();
67   $('#record_links_add_filter_link_type').change(record_links_change_form_to_match_type);
68   record_links_change_form_to_match_type();
69 });
70
71 function filter_record_links() {
72   var url="controller.pl?action=RecordLinks/ajax_add_list&" + $("#record_links_add form").serialize();
73   $.ajax({
74     url: url,
75     success: function(new_data) {
76       $("#record_list_filtered_list").html(new_data['html']);
77       $('#add_selected_record_links_button').prop('disabled', new_data['count'] == 0);
78     }
79   });
80 }
81
82 function add_selected_record_links() {
83   var url="controller.pl?action=RecordLinks/ajax_add_do&" + $("#record_links_add form").serialize();
84   $.ajax({
85     url: url,
86     success: function(new_html) {
87       $('#record_links_list').replaceWith(new_html);
88       $('#record_links_add').dialog('close');
89     }
90   });
91 }
92
93 function record_links_change_form_to_match_type() {
94   var type  = $('#record_links_add_filter_link_type').val();
95   var title = type == 'requirement_spec' ? kivi.t8('Title')
96             : type == 'letter'           ? kivi.t8('Subject')
97             :                              kivi.t8('Transaction description');
98
99   if (type == 'letter') {
100     $('#record_links_add_filter_project_row').hide();
101
102   } else {
103     $('#record_links_add_filter_project_row').show();
104   }
105
106   $('#record_links_add_filter_title').html(title);
107 }
108 -->
109 </script>